aqhome-apps: all apps now work again.

This commit is contained in:
Martin Preuss
2025-03-09 23:25:02 +01:00
parent 9c1188b4d1
commit 3e4e3ffe2d
58 changed files with 1695 additions and 1425 deletions

View File

@@ -1,6 +1,6 @@
/****************************************************************************
* This file is part of the project AqHome.
* AqHome (c) by 2024 Martin Preuss, all rights reserved.
* AqHome (c) by 2025 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.
@@ -11,6 +11,7 @@
#endif
#include "./net_read.h"
#include "./server_p.h"
#include "aqhome-react/aqhome_react_p.h"
#include "aqhome-react/types/unit.h"
#include "aqhome-react/units/u_module.h"
@@ -35,9 +36,9 @@
*/
static time_t _getNewestFiletimeFromFileList(const GWEN_STRINGLIST *sl);
static AQHREACT_UNIT *_readNetworkFromFile(AQHOME_REACT *aqh, const char *filename);
static AQHREACT_UNIT *_readNetworkFromFile(AQH_OBJECT *o, const char *filename);
static GWEN_XMLNODE *_readUnitNetFileToXml(const char *sFilename);
static int _readUnitNetFilesIntoList(AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl, AQHREACT_UNIT_LIST *unitList);
static int _readUnitNetFilesIntoList(AQH_OBJECT *o, const GWEN_STRINGLIST *sl, AQHREACT_UNIT_LIST *unitList);
@@ -47,7 +48,7 @@ static int _readUnitNetFilesIntoList(AQHOME_REACT *aqh, const GWEN_STRINGLIST *s
*/
time_t AQHomeReact_GetNewestUnitNetFiletime(void)
time_t AQH_ReactServer_GetNewestUnitNetFiletime(void)
{
GWEN_STRINGLIST *sl;
time_t t1;
@@ -66,62 +67,73 @@ time_t AQHomeReact_GetNewestUnitNetFiletime(void)
int AQHomeReact_ReadUnitNetFiles(AQHOME_REACT *aqh)
int AQH_ReactServer_ReadUnitNetFiles(AQH_OBJECT *aqh)
{
GWEN_STRINGLIST *sl;
AQH_REACT_SERVER *xo;
sl=AQH_GetListOfMatchingSysconfFiles("aqhome/react/networks", "*.xml");
if (sl) {
int rv;
xo=AQH_ReactServer_GetServerData(aqh);
if (xo) {
GWEN_STRINGLIST *sl;
GWEN_StringList_Sort(sl, 1, GWEN_StringList_SortModeNoCase);
rv=_readUnitNetFilesIntoList(aqh, sl, aqh->unitList);
GWEN_StringList_free(sl);
if (rv<0) {
DBG_INFO(NULL, "Error reading unit network files (%d)", rv);
return rv;
sl=AQH_GetListOfMatchingSysconfFiles("aqhome/react/networks", "*.xml");
if (sl) {
int rv;
GWEN_StringList_Sort(sl, 1, GWEN_StringList_SortModeNoCase);
rv=_readUnitNetFilesIntoList(aqh, sl, xo->unitList);
GWEN_StringList_free(sl);
if (rv<0) {
DBG_INFO(NULL, "Error reading unit network files (%d)", rv);
return rv;
}
}
else {
DBG_ERROR(NULL, "No unit network files");
}
return 0;
}
else {
DBG_ERROR(NULL, "No unit network files");
}
return 0;
return GWEN_ERROR_INVALID;
}
AQHREACT_UNIT *AQHomeReact_FindAndReadDataDirNetwork(AQHOME_REACT *aqh, const char *networkName)
AQHREACT_UNIT *AQH_ReactServer_FindAndReadDataDirNetwork(AQH_OBJECT *o, const char *networkName)
{
if (aqh && networkName) {
AQHREACT_UNIT *unit;
GWEN_BUFFER *bufFilename;
GWEN_BUFFER *bufPath;
const char *s;
if (o && networkName) {
AQH_REACT_SERVER *xo;
xo=AQH_ReactServer_GetServerData(o);
if (xo) {
AQHREACT_UNIT *unit;
GWEN_BUFFER *bufFilename;
GWEN_BUFFER *bufPath;
const char *s;
bufFilename=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Buffer_AppendString(bufFilename, "aqhome/react/networks/");
s=networkName;
while(*s)
GWEN_Buffer_AppendByte(bufFilename, tolower((unsigned char) *(s++)));
GWEN_Buffer_AppendString(bufFilename, ".xml");
bufFilename=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Buffer_AppendString(bufFilename, "aqhome/react/networks/");
s=networkName;
while(*s)
GWEN_Buffer_AppendByte(bufFilename, tolower((unsigned char) *(s++)));
GWEN_Buffer_AppendString(bufFilename, ".xml");
bufPath=AQH_FindPathOfDataFile(GWEN_Buffer_GetStart(bufFilename));
if (bufPath==NULL) {
DBG_ERROR(NULL, "Network file \"%s\" not found in data folders", GWEN_Buffer_GetStart(bufFilename));
bufPath=AQH_FindPathOfDataFile(GWEN_Buffer_GetStart(bufFilename));
if (bufPath==NULL) {
DBG_ERROR(NULL, "Network file \"%s\" not found in data folders", GWEN_Buffer_GetStart(bufFilename));
GWEN_Buffer_free(bufFilename);
return NULL;
}
GWEN_Buffer_free(bufFilename);
return NULL;
}
GWEN_Buffer_free(bufFilename);
unit=_readNetworkFromFile(aqh, GWEN_Buffer_GetStart(bufPath));
if (unit==NULL) {
DBG_ERROR(NULL, "Error reading network from file \"%s\"", GWEN_Buffer_GetStart(bufPath));
unit=_readNetworkFromFile(o, GWEN_Buffer_GetStart(bufPath));
if (unit==NULL) {
DBG_ERROR(NULL, "Error reading network from file \"%s\"", GWEN_Buffer_GetStart(bufPath));
GWEN_Buffer_free(bufPath);
return NULL;
}
GWEN_Buffer_free(bufPath);
return NULL;
return unit;
}
GWEN_Buffer_free(bufPath);
return unit;
}
return NULL;
}
@@ -162,7 +174,7 @@ time_t _getNewestFiletimeFromFileList(const GWEN_STRINGLIST *sl)
AQHREACT_UNIT *_readNetworkFromFile(AQHOME_REACT *aqh, const char *filename)
AQHREACT_UNIT *_readNetworkFromFile(AQH_OBJECT *o, const char *filename)
{
GWEN_XMLNODE *n;
AQHREACT_UNIT *unit;
@@ -173,7 +185,7 @@ AQHREACT_UNIT *_readNetworkFromFile(AQHOME_REACT *aqh, const char *filename)
return NULL;
}
unit=AqHomeReact_UnitModule_fromXml(aqh, n);
unit=AqHomeReact_UnitModule_fromXml(o, n);
if (unit==NULL) {
DBG_ERROR(NULL, "Error reading network from file \"%s\"", filename);
GWEN_XMLNode_free(n);
@@ -214,7 +226,7 @@ GWEN_XMLNODE *_readUnitNetFileToXml(const char *sFilename)
int _readUnitNetFilesIntoList(AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl, AQHREACT_UNIT_LIST *unitList)
int _readUnitNetFilesIntoList(AQH_OBJECT *o, const GWEN_STRINGLIST *sl, AQHREACT_UNIT_LIST *unitList)
{
GWEN_STRINGLISTENTRY *se;
@@ -227,7 +239,7 @@ int _readUnitNetFilesIntoList(AQHOME_REACT *aqh, const GWEN_STRINGLIST *sl, AQHR
AQHREACT_UNIT *unit;
DBG_INFO(NULL, "Reading unit network file \"%s\"", s);
unit=_readNetworkFromFile(aqh, s);
unit=_readNetworkFromFile(o, s);
if (unit==NULL) {
DBG_WARN(NULL, "No network read from network file \"%s\"", s);
return GWEN_ERROR_GENERIC;