/**************************************************************************** * This file is part of the project AqHome. * 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. ****************************************************************************/ #ifdef HAVE_CONFIG_H # include #endif #include "./mdevices_index.h" #include "aqhome-cgi/service/module.h" #include "aqhome-cgi/modules/mdataclient.h" #include #include #include /* ------------------------------------------------------------------------------------------------ * defs and enums * ------------------------------------------------------------------------------------------------ */ #define GBAS GWEN_Buffer_AppendString #define GBAA GWEN_Buffer_AppendArgs /* ------------------------------------------------------------------------------------------------ * forward declarations * ------------------------------------------------------------------------------------------------ */ static void _addLinkForDevice(const char *page, const char *sDevice, const char *action, const char *imgName, GWEN_BUFFER *dbuf); /* ------------------------------------------------------------------------------------------------ * code * ------------------------------------------------------------------------------------------------ */ void AQH_ModDevices_RunIndex(AQH_MODULE *m, AQCGI_REQUEST *rq, AQH_SESSION *session, AQH_DATACLIENT *dc, GWEN_BUFFER *dbuf) { AQH_DEVICE_LIST *deviceList; AQH_DEVICE *device; uint32_t perms; perms=AQH_ModService_GetUserPerms(m); deviceList=AQH_DataClient_GetDevices(dc, NULL); if (deviceList==NULL) { DBG_ERROR(NULL, "No device received"); GBAS(dbuf, "

No devices.

"); return; } GBAS(dbuf, "

Devices

\n"); GBAS(dbuf, "\n" "\n" "" "" "" "" "" "" "" "\n" "\n" "\n"); device=AQH_Device_List_First(deviceList); while(device) { const char *s; const char *sDevice; GBAA(dbuf, ""); /* name for system */ sDevice=AQH_Device_GetNameForSystem(device); GBAA(dbuf,"", sDevice?sDevice:""); /* nameForGui */ s=AQH_Device_GetNameForGui(device); GBAA(dbuf, "", s?s:""); /* room */ s=AQH_Device_GetRoomName(device); GBAA(dbuf, "", s?s:""); /* location */ s=AQH_Device_GetLocation(device); GBAA(dbuf, "", s?s:""); /* description */ s=AQH_Device_GetDescription(device); GBAA(dbuf, "", s?s:""); GBAS(dbuf, ""); GBAA(dbuf, ""); device=AQH_Device_List_Next(device); } GBAS(dbuf, "\n" "
Name For SystemName For GUIRoomLocationDescriptionActions
%s%s%s%s%s"); if (perms & AQH_MODDEVICES_PERMS_VALUEREAD) { _addLinkForDevice("vtable.html", sDevice, "table view", "/pics/document-table.png", dbuf); _addLinkForDevice("vgraph.html", sDevice, "graph view", "/pics/graph.png", dbuf); } if (perms & AQH_MODDEVICES_PERMS_DEVICEWRITE) { _addLinkForDevice("device.html", sDevice, "edit device", "/pics/edit.png", dbuf); } GBAS(dbuf, "
\n"); AQH_Device_List_free(deviceList); } void _addLinkForDevice(const char *page, const char *sDevice, const char *action, const char *imgName, GWEN_BUFFER *dbuf) { GBAA(dbuf,""); GBAA(dbuf,"\"%s\"", imgName, action, action); GBAS(dbuf,""); }