/**************************************************************************** * 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 "./c_connect.h" #include "./aqhome_data_p.h" #include "aqhome/ipc/data/ipc_data.h" #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/ipc/msg_ipc_result.h" #include "aqhome/ipc/data/msg_data_connect.h" #include "aqhome/ipc/msg_ipc_tag16.h" #include /* ------------------------------------------------------------------------------------------------ * defines * ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ * forward declarations * ------------------------------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------------------------------ * implementations * ------------------------------------------------------------------------------------------------ */ void AqHomeData_HandleConnect(AQHOME_DATA *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg) { GWEN_MSG *outMsg; int resultCode=AQH_MSG_IPC_SUCCESS; GWEN_TAG16_LIST *tagList; char *clientId=NULL; char *userId=NULL; char *passw=NULL; tagList=AQH_Tag16IpcMsg_ParseTags(msg, 0); if (tagList) { const GWEN_TAG16 *tag; tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_CONNECT_TAGS_CLIENTID); clientId=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL; tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_CONNECT_TAGS_USERID); userId=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL; tag=GWEN_Tag16_List_FindFirstByTagType(tagList, AQH_MSGDATA_CONNECT_TAGS_PASSWORD); passw=tag?GWEN_Tag16_GetTagDataAsNewString(tag, NULL):NULL; } if (clientId) AQH_IpcEndpoint_SetServiceName(ep, clientId); if (userId) AQH_IpcEndpoint_SetUserName(ep, userId); /* TODO: add user management, for now we allow all */ AQH_IpcEndpoint_SetPermissions(ep, AQH_IPCENDPOINT_PERMS_LISTVALUES | AQH_IPCENDPOINT_PERMS_READVALUE | AQH_IPCENDPOINT_PERMS_ADDVALUE | AQH_IPCENDPOINT_PERMS_LISTDATA | AQH_IPCENDPOINT_PERMS_READDATA | AQH_IPCENDPOINT_PERMS_ADDDATA); free(passw); free(userId); free(clientId); GWEN_Tag16_List_free(tagList); outMsg=AQH_ResultIpcMsg_new(AQH_MSGTYPE_IPC_DATA_RESULT, resultCode); GWEN_MsgEndpoint_AddSendMessage(ep, outMsg); }