From 60a3f1f3249d615306fd9b3d26e60565ac7cf133 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Fri, 19 Sep 2025 23:44:14 +0200 Subject: [PATCH] aqhome-cgi: add functions for loading users and modules. --- apps/aqhome-cgi/modules/common/mservice.c | 75 +++++++++++++++++++++++ apps/aqhome-cgi/modules/common/mservice.h | 2 + 2 files changed, 77 insertions(+) diff --git a/apps/aqhome-cgi/modules/common/mservice.c b/apps/aqhome-cgi/modules/common/mservice.c index 360f86d..bd170f6 100644 --- a/apps/aqhome-cgi/modules/common/mservice.c +++ b/apps/aqhome-cgi/modules/common/mservice.c @@ -603,4 +603,79 @@ uint32_t AQH_ModService_ReadPermsFromForm(GWEN_DB_NODE *dbPost, const AQH_PERMDE +AQH_MODULE_LIST *AQH_ModService_LoadRawModules(AQH_MODULE *m) +{ + AQH_SERVICE *sv; + GWEN_STRINGLIST *slModuleNames; + + sv=AQH_ModService_GetService(m); + slModuleNames=AQH_Service_ListModules(sv); + if (slModuleNames) { + AQH_MODULE_LIST *modList; + GWEN_STRINGLISTENTRY *se; + + modList=AQH_Module_List_new(); + se=GWEN_StringList_FirstEntry(slModuleNames); + while(se) { + const char *sModName; + + sModName=GWEN_StringListEntry_Data(se); + if (sModName && *sModName) { + AQH_MODULE *currentMod; + + currentMod=AQH_Service_LoadModule(sv, sModName); + if (currentMod) + AQH_Module_List_Add(currentMod, modList); + } + se=GWEN_StringListEntry_Next(se); + } + GWEN_StringList_free(slModuleNames); + if (AQH_Module_List_GetCount(modList)) + return modList; + AQH_Module_List_free(modList); + } + + return NULL; +} + + + +AQH_USER_LIST *AQH_ModService_LoadRawUsers(AQH_MODULE *m) +{ + AQH_SERVICE *sv; + GWEN_STRINGLIST *slUserNames; + + sv=AQH_ModService_GetService(m); + slUserNames=AQH_Service_ListUsers(sv); + if (slUserNames) { + AQH_USER_LIST *userList; + GWEN_STRINGLISTENTRY *se; + + userList=AQH_User_List_new(); + se=GWEN_StringList_FirstEntry(slUserNames); + while(se) { + const char *sModName; + + sModName=GWEN_StringListEntry_Data(se); + if (sModName && *sModName) { + AQH_USER *u; + + u=AQH_Service_LoadUser(sv, sModName); + if (u) + AQH_User_List_Add(u, userList); + } + se=GWEN_StringListEntry_Next(se); + } + GWEN_StringList_free(slUserNames); + if (AQH_User_List_GetCount(userList)) + return userList; + AQH_User_List_free(userList); + } + + return NULL; +} + + + + diff --git a/apps/aqhome-cgi/modules/common/mservice.h b/apps/aqhome-cgi/modules/common/mservice.h index 5666e1e..3cd1b76 100644 --- a/apps/aqhome-cgi/modules/common/mservice.h +++ b/apps/aqhome-cgi/modules/common/mservice.h @@ -66,6 +66,8 @@ void AQH_ModService_AddRole(AQH_ROLE_LIST *roleList, int id, const char *name, u void AQH_ModService_WritePermsToForm(uint32_t perms, const AQH_PERMDEF_LIST *permDefList, const char *sPrefix, GWEN_BUFFER *dbuf); uint32_t AQH_ModService_ReadPermsFromForm(GWEN_DB_NODE *dbPost, const AQH_PERMDEF_LIST *permDefList, const char *sPrefix); +AQH_MODULE_LIST *AQH_ModService_LoadRawModules(AQH_MODULE *m); +AQH_USER_LIST *AQH_ModService_LoadRawUsers(AQH_MODULE *m); void AQH_ModService_SetHandleRequestFn(AQH_MODULE *m, AQH_MODSERVICE_HANDLEREQUEST_FN fn);