/**************************************************************************** * This file is part of the project AqHome. * AqHome (c) by 2023 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. ****************************************************************************/ #ifdef HAVE_CONFIG_H # include #endif #include "./aqhomed_p.h" #include "./tty_log.h" #include "./tty_write.h" #include "aqhome/msg/endpoint_tty.h" #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/mqtt/endpoint_mqttc.h" #include #include /* ------------------------------------------------------------------------------------------------ * defines * ------------------------------------------------------------------------------------------------ */ #define I18N(msg) msg #define I18S(msg) msg /* ------------------------------------------------------------------------------------------------ * forward declarations * ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ * implementations * ------------------------------------------------------------------------------------------------ */ AQHOMED *AqHomed_new(void) { AQHOMED *aqh; GWEN_NEW_OBJECT(AQHOMED, aqh); aqh->rootEndpoint=GWEN_MsgEndpoint_new("root", 0); aqh->nodeDb=AQH_NodeDb_new(); return aqh; } void AqHomed_free(AQHOMED *aqh) { if (aqh) { GWEN_MsgEndpoint_free(aqh->rootEndpoint); aqh->rootEndpoint=NULL; aqh->ttyEndpoint=NULL; aqh->ipcdEndpoint=NULL; aqh->mqttEndpoint=NULL; GWEN_DB_Group_free(aqh->dbArgs); AQH_NodeDb_free(aqh->nodeDb); aqh->dbArgs=NULL; free(aqh->logFile); free(aqh->writeFolder); free(aqh->pidFile); free(aqh->dbFile); free(aqh->mqttTopicPrefix); GWEN_FREE_OBJECT(aqh); } } GWEN_MSG_ENDPOINT *AqHomed_GetTtyEndpoint(const AQHOMED *aqh) { return aqh?aqh->ttyEndpoint:NULL; } GWEN_MSG_ENDPOINT *AqHomed_GetIpcdEndpoint(const AQHOMED *aqh) { return aqh?aqh->ipcdEndpoint:NULL; } GWEN_MSG_ENDPOINT *AqHomed_GetMqttEndpoint(const AQHOMED *aqh) { return aqh?aqh->mqttEndpoint:NULL; } GWEN_DB_NODE *AqHomed_GetDbArgs(const AQHOMED *aqh) { return aqh?aqh->dbArgs:NULL; } const char *AqHomed_GetLogFile(const AQHOMED *aqh) { return aqh?aqh->logFile:NULL; } void AqHomed_SetLogFile(AQHOMED *aqh, const char *s) { if (aqh) { free(aqh->logFile); aqh->logFile=s?strdup(s):NULL; } } const char *AqHomed_GetWriteFolder(const AQHOMED *aqh) { return aqh?aqh->writeFolder:NULL; } void AqHomed_SetWriteFolder(AQHOMED *aqh, const char *s) { if (aqh) { free(aqh->writeFolder); aqh->writeFolder=s?strdup(s):NULL; } } const char *AqHomed_GetPidFile(const AQHOMED *aqh) { return aqh?aqh->pidFile:NULL; } void AqHomed_SetPidFile(AQHOMED *aqh, const char *s) { if (aqh) { free(aqh->pidFile); aqh->pidFile=s?strdup(s):NULL; } } const char *AqHomed_GetDbFile(const AQHOMED *aqh) { return aqh?aqh->dbFile:NULL; } void AqHomed_SetDbFile(AQHOMED *aqh, const char *s) { if (aqh) { free(aqh->dbFile); aqh->dbFile=s?strdup(s):NULL; } } const char *AqHomed_GetMqttTopicPrefix(const AQHOMED *aqh) { return aqh?aqh->mqttTopicPrefix:NULL; } void AqHomed_SetMqttTopicPrefix(AQHOMED *aqh, const char *s) { if (aqh) { free(aqh->mqttTopicPrefix); aqh->mqttTopicPrefix=s?strdup(s):NULL; } }