diff --git a/apps/aqhome-storage/http.c b/apps/aqhome-storage/http.c index 429b178..a885eca 100644 --- a/apps/aqhome-storage/http.c +++ b/apps/aqhome-storage/http.c @@ -18,6 +18,7 @@ #include "aqhome/ipc/endpoint_ipc.h" #include "aqhome/mqtt/endpoint_mqttc.h" #include "aqhome/http/endpoint_http.h" +#include "aqhome/http/httpservice_http.h" #include #include @@ -61,10 +62,6 @@ */ -static GWEN_MSG *_handleUrl(AQHOME_STORAGE *aqh, const GWEN_MSG *msgReceived, const GWEN_URL *url); -static GWEN_MSG *_handleUrl_login(AQHOME_STORAGE *aqh, const GWEN_MSG *msgReceived, const GWEN_URL *url); - - /* ------------------------------------------------------------------------------------------------ * implementations @@ -72,121 +69,4 @@ static GWEN_MSG *_handleUrl_login(AQHOME_STORAGE *aqh, const GWEN_MSG *msgReceiv */ -int AqHomeStorage_AddFile(GWEN_UNUSED AQHOME_STORAGE *aqh, GWEN_UNUSED AQH_SESSION *session, const char *fname, GWEN_BUFFER *buf) -{ - if (fname && *fname) { - int rv; - - rv=GWEN_SyncIo_Helper_ReadFile(fname, buf); - if (rv<0) { - DBG_ERROR(AQH_LOGDOMAIN, "Error reading file \"%s\": %d", fname, rv); - return rv; - } - } - - return 0; -} - - - -int AqHomeStorage_AddSiteHeader(AQHOME_STORAGE *aqh, AQH_SESSION *session, GWEN_BUFFER *buf) -{ - return AqHomeStorage_AddFile(aqh, session, AQHOME_STORAGE_SITEHEADER, buf); -} - - - -int AqHomeStorage_AddSiteFooter(AQHOME_STORAGE *aqh, AQH_SESSION *session, GWEN_BUFFER *buf) -{ - return AqHomeStorage_AddFile(aqh, session, AQHOME_STORAGE_SITEFOOTER, buf); -} - - - -GWEN_MSG *AqHomeStorage_HandleMessage(AQHOME_STORAGE *aqh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msgReceived) -{ - GWEN_DB_NODE *dbParsedMsgInfo; - GWEN_DB_NODE *dbCommand; - GWEN_DB_NODE *dbHeader; - const char *sCmd; - const char *sUrl; - GWEN_URL *gUrl; - const char *sPath; - GWEN_MSG *msgToSend; - - dbParsedMsgInfo=GWEN_Msg_GetDbParsedInfo(msgReceived); - if (dbParsedMsgInfo==NULL) { - DBG_ERROR(AQH_LOGDOMAIN, "No parsed msg info in received message, SNH"); - return NULL; - } - dbCommand=GWEN_DB_GetGroup(dbParsedMsgInfo, GWEN_PATH_FLAGS_PATHMUSTEXIST, "command"); - dbHeader=GWEN_DB_GetGroup(dbParsedMsgInfo, GWEN_PATH_FLAGS_PATHMUSTEXIST, "header"); - if (dbCommand==NULL || dbHeader==NULL) { - DBG_ERROR(AQH_LOGDOMAIN, "Either command group or headser group missing in parsed msg info, SNH"); - return NULL; - } - - sCmd=GWEN_DB_GetCharValue(dbCommand, "command", 0, NULL); - if (!(sCmd && *sCmd)) { - DBG_ERROR(NULL, "No command in message"); - return NULL; - } - - sUrl=GWEN_DB_GetCharValue(dbCommand, "url", 0, NULL); - if (!(sUrl && *sUrl)) { - DBG_ERROR(NULL, "No url in message"); - return NULL; - } - - gUrl=GWEN_Url_fromCommandString(sUrl); - if (gUrl==NULL) { - DBG_ERROR(AQH_LOGDOMAIN, "Invalid url [%s]", sUrl); - return NULL; - } - sPath=GWEN_Url_GetPath(gUrl); - if (!(sPath && *sPath)) { - DBG_ERROR(AQH_LOGDOMAIN, "Invalid URL (no path): [%s]", sUrl); - GWEN_Url_free(gUrl); - return NULL; - } - /* now we have all info from the incoming http message */ - - msgToSend=_handleUrl(aqh, msgReceived, gUrl); - if (msgToSend==NULL) { - DBG_ERROR(AQH_LOGDOMAIN, "Error handling url [%s]", sUrl); - } - GWEN_Url_free(gUrl); - return msgToSend; -} - - - -GWEN_MSG *_handleUrl(AQHOME_STORAGE *aqh, const GWEN_MSG *msgReceived, const GWEN_URL *url) -{ - const char *sPath; - - sPath=GWEN_Url_GetPath(url); - if (strcasecmp(sPath, "/login")==0) - return _handleUrl_login(aqh, msgReceived, url); - else { - DBG_ERROR(NULL, "Invalid URL [%s]", sPath); - return NULL; - } -} - - - -GWEN_MSG *_handleUrl_login(AQHOME_STORAGE *aqh, const GWEN_MSG *msgReceived, const GWEN_URL *url) -{ -} - - - - - - - - - - diff --git a/apps/aqhomed/fini.c b/apps/aqhomed/fini.c index b3c5998..b69cfd0 100644 --- a/apps/aqhomed/fini.c +++ b/apps/aqhomed/fini.c @@ -55,6 +55,7 @@ void AqHomed_Fini(AQHOMED *aqh) _disconnectTree(aqh->rootEndpoint); GWEN_MsgEndpoint_Disconnect(aqh->rootEndpoint); } + GWEN_MsgEndpoint_free(aqh->rootEndpoint); aqh->rootEndpoint=NULL; aqh->ttyEndpoint=NULL; aqh->ipcdEndpoint=NULL;