aqhome: removed unneeded classes.

This commit is contained in:
Martin Preuss
2023-07-24 21:53:31 +02:00
parent 16ce958964
commit 53e1fbae56
10 changed files with 0 additions and 573 deletions

View File

@@ -46,18 +46,12 @@
<headers dist="true" install="$(pkgincludedir)/http" >
endpoint_http.h
urlhandler.h
content.h
content_files.h
httpservice.h
</headers>
<headers dist="true" >
endpoint_http_p.h
urlhandler_p.h
content_p.h
content_files_p.h
httpservice_p.h
</headers>
@@ -66,9 +60,6 @@
$(local/typefiles)
endpoint_http.c
urlhandler.c
content.c
content_files.c
httpservice.c
</sources>

View File

@@ -1,84 +0,0 @@
/****************************************************************************
* 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 <config.h>
#endif
#include "aqhome/http/content_p.h"
#include <gwenhywfar/debug.h>
GWEN_INHERIT_FUNCTIONS(AQH_HTTP_CONTENT)
GWEN_TREE2_FUNCTIONS(AQH_HTTP_CONTENT, AQH_HttpContent)
AQH_HTTP_CONTENT *AQH_HttpContent_new(void)
{
AQH_HTTP_CONTENT *cp;
GWEN_NEW_OBJECT(AQH_HTTP_CONTENT, cp);
GWEN_INHERIT_INIT(AQH_HTTP_CONTENT, cp);
GWEN_TREE2_INIT(AQH_HTTP_CONTENT, cp, AQH_HttpContent);
return cp;
}
void AQH_HttpContent_free(AQH_HTTP_CONTENT *cp)
{
if (cp) {
GWEN_TREE2_FINI(AQH_HTTP_CONTENT, cp, AQH_HttpContent);
GWEN_INHERIT_FINI(AQH_HTTP_CONTENT, cp);
GWEN_FREE_OBJECT(cp);
}
}
int AQH_HttpContent_AddOpeningContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer)
{
return (cp && cp->addOpeningContentFn)?(cp->addOpeningContentFn(cp, mode, buffer)):0;
}
int AQH_HttpContent_AddClosingContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer)
{
return (cp && cp->addClosingContentFn)?(cp->addClosingContentFn(cp, mode, buffer)):0;
}
void AQH_HttpContent_SetAddOpeningContentFn(AQH_HTTP_CONTENT *cp, AQH_HTTP_CONTENT_ADD_OPENING_CONTENT_FN f)
{
if (cp)
cp->addOpeningContentFn=f;
}
void AQH_HttpContent_SetAddClosingContentFn(AQH_HTTP_CONTENT *cp, AQH_HTTP_CONTENT_ADD_CLOSING_CONTENT_FN f)
{
if (cp)
cp->addClosingContentFn=f;
}

View File

@@ -1,58 +0,0 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQHOME_CONTENT_H
#define AQHOME_CONTENT_H
#include <aqhome/api.h>
#include <gwenhywfar/buffer.h>
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/tree2.h>
#define AQH_HTTP_CONTENT_MODE_DESKTOP 0
#define AQH_HTTP_CONTENT_MODE_MOBILE 1
#ifdef __cplusplus
extern "C" {
#endif
typedef struct AQH_HTTP_CONTENT AQH_HTTP_CONTENT;
GWEN_INHERIT_FUNCTION_LIB_DEFS(AQH_HTTP_CONTENT, AQHOME_API)
GWEN_TREE2_FUNCTION_LIB_DEFS(AQH_HTTP_CONTENT, AQH_HttpContent, AQHOME_API)
typedef int (*AQH_HTTP_CONTENT_ADD_OPENING_CONTENT_FN)(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer);
typedef int (*AQH_HTTP_CONTENT_ADD_CLOSING_CONTENT_FN)(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer);
AQHOME_API AQH_HTTP_CONTENT *AQH_HttpContent_new(void);
AQHOME_API void AQH_HttpContent_free(AQH_HTTP_CONTENT *cp);
AQHOME_API int AQH_HttpContent_AddOpeningContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer);
AQHOME_API int AQH_HttpContent_AddClosingContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer);
AQHOME_API void AQH_HttpContent_SetAddOpeningContentFn(AQH_HTTP_CONTENT *cp, AQH_HTTP_CONTENT_ADD_OPENING_CONTENT_FN f);
AQHOME_API void AQH_HttpContent_SetAddClosingContentFn(AQH_HTTP_CONTENT *cp, AQH_HTTP_CONTENT_ADD_CLOSING_CONTENT_FN f);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,145 +0,0 @@
/****************************************************************************
* 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 <config.h>
#endif
#include "aqhome/http/content_files_p.h"
#include <gwenhywfar/debug.h>
#include <gwenhywfar/syncio.h>
GWEN_INHERIT(AQH_HTTP_CONTENT, AQH_HTTP_CONTENT_FILES)
/* ------------------------------------------------------------------------------------------------
* forward declarations
* ------------------------------------------------------------------------------------------------
*/
static void _freeData(void *bp, void *p);
static int _addOpeningContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer);
static int _addClosingContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer);
/* ------------------------------------------------------------------------------------------------
* implementations
* ------------------------------------------------------------------------------------------------
*/
AQH_HTTP_CONTENT *AQH_HttpContentFiles_new(const char *headerFilename, const char *footerFilename)
{
AQH_HTTP_CONTENT *cp;
AQH_HTTP_CONTENT_FILES *xcp;
cp=AQH_HttpContent_new();
GWEN_NEW_OBJECT(AQH_HTTP_CONTENT_FILES, xcp);
GWEN_INHERIT_SETDATA(AQH_HTTP_CONTENT, AQH_HTTP_CONTENT_FILES, cp, xcp, _freeData);
xcp->headerFilename=(headerFilename && *headerFilename)?strdup(headerFilename):NULL;
xcp->footerFilename=(footerFilename && *footerFilename)?strdup(footerFilename):NULL;
AQH_HttpContent_SetAddOpeningContentFn(cp, _addOpeningContent);
AQH_HttpContent_SetAddClosingContentFn(cp, _addClosingContent);
return cp;
}
void _freeData(void *bp, void *p)
{
AQH_HTTP_CONTENT_FILES *xcp;
xcp=(AQH_HTTP_CONTENT_FILES*) p;
free(xcp->footerData);
free(xcp->headerData);
free(xcp->footerFilename);
free(xcp->headerFilename);
GWEN_FREE_OBJECT(xcp);
}
int _addOpeningContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer)
{
if (cp) {
AQH_HTTP_CONTENT_FILES *xcp;
xcp=GWEN_INHERIT_GETDATA(AQH_HTTP_CONTENT, AQH_HTTP_CONTENT_FILES, cp);
if (xcp) {
if (xcp->headerData==NULL) {
if (xcp->headerFilename) {
int rv;
GWEN_BUFFER *fileBuffer;
fileBuffer=GWEN_Buffer_new(0, 256, 0, 1);
rv=GWEN_SyncIo_Helper_ReadFile(xcp->headerFilename, fileBuffer);
if (rv<0) {
DBG_ERROR(AQH_LOGDOMAIN, "Error reading header file \"%s\": %d", xcp->headerFilename, rv);
GWEN_Buffer_free(fileBuffer);
return rv;
}
xcp->headerData=strdup(GWEN_Buffer_GetStart(fileBuffer));
GWEN_Buffer_free(fileBuffer);
}
}
if (xcp->headerData)
GWEN_Buffer_AppendString(buffer, xcp->headerData);
}
}
return 0;
}
int _addClosingContent(AQH_HTTP_CONTENT *cp, int mode, GWEN_BUFFER *buffer)
{
if (cp) {
AQH_HTTP_CONTENT_FILES *xcp;
xcp=GWEN_INHERIT_GETDATA(AQH_HTTP_CONTENT, AQH_HTTP_CONTENT_FILES, cp);
if (xcp) {
if (xcp->footerData==NULL) {
if (xcp->footerFilename) {
int rv;
GWEN_BUFFER *fileBuffer;
fileBuffer=GWEN_Buffer_new(0, 256, 0, 1);
rv=GWEN_SyncIo_Helper_ReadFile(xcp->footerFilename, fileBuffer);
if (rv<0) {
DBG_ERROR(AQH_LOGDOMAIN, "Error reading footer file \"%s\": %d", xcp->footerFilename, rv);
GWEN_Buffer_free(fileBuffer);
return rv;
}
xcp->footerData=strdup(GWEN_Buffer_GetStart(fileBuffer));
GWEN_Buffer_free(fileBuffer);
}
if (xcp->footerData)
GWEN_Buffer_AppendString(buffer, xcp->footerData);
}
}
}
return 0;
}

View File

@@ -1,34 +0,0 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQHOME_CONTENT_FILES_H
#define AQHOME_CONTENT_FILES_H
#include <aqhome/api.h>
#include <aqhome/http/content.h>
#ifdef __cplusplus
extern "C" {
#endif
AQHOME_API AQH_HTTP_CONTENT *AQH_HttpContentFiles_new(const char *headerFilename, const char *footerFilename);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,28 +0,0 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQHOME_CONTENT_FILES_P_H
#define AQHOME_CONTENT_FILES_P_H
#include "aqhome/http/content_files.h"
typedef struct AQH_HTTP_CONTENT_FILES AQH_HTTP_CONTENT_FILES;
struct AQH_HTTP_CONTENT_FILES {
char *headerFilename;
char *footerFilename;
char *headerData;
char *footerData;
};
#endif

View File

@@ -1,27 +0,0 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQHOME_CONTENT_P_H
#define AQHOME_CONTENT_P_H
#include "aqhome/http/content.h"
struct AQH_HTTP_CONTENT {
GWEN_INHERIT_ELEMENT(AQH_HTTP_CONTENT);
GWEN_TREE2_ELEMENT(AQH_HTTP_CONTENT);
AQH_HTTP_CONTENT_ADD_OPENING_CONTENT_FN addOpeningContentFn;
AQH_HTTP_CONTENT_ADD_CLOSING_CONTENT_FN addClosingContentFn;
};
#endif

View File

@@ -1,111 +0,0 @@
/****************************************************************************
* 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 <config.h>
#endif
#include "./urlhandler_p.h"
#include <gwenhywfar/debug.h>
#include <gwenhywfar/misc.h>
#include <gwenhywfar/text.h>
GWEN_INHERIT_FUNCTIONS(AQH_URLHANDLER)
GWEN_LIST_FUNCTIONS(AQH_URLHANDLER, AQH_UrlHandler)
AQH_URLHANDLER *AQH_UrlHandler_new(void)
{
AQH_URLHANDLER *uh;
GWEN_NEW_OBJECT(AQH_URLHANDLER, uh);
GWEN_INHERIT_INIT(AQH_URLHANDLER, uh);
uh->urlPatternList=GWEN_StringList_new();
return uh;
}
void AQH_UrlHandler_free(AQH_URLHANDLER *uh)
{
if (uh) {
GWEN_INHERIT_FINI(AQH_URLHANDLER, uh);
GWEN_StringList_free(uh->urlPatternList);
GWEN_FREE_OBJECT(uh);
}
}
AQH_HTTP_CONTENT *AQH_UrlHandler_GetContentProvider(const AQH_URLHANDLER *uh)
{
return uh?uh->httpContentProvider:NULL;
}
void AQH_UrlHandler_SetContentProvider(AQH_URLHANDLER *uh, AQH_HTTP_CONTENT *cp)
{
if (uh)
uh->httpContentProvider=cp;
}
void AQH_UrlHandler_AddUrlPattern(AQH_URLHANDLER *uh, const char *s)
{
if (uh && s && *s)
GWEN_StringList_AppendString(uh->urlPatternList, s, 0, 1);
}
int AQH_UrlHandler_UrlMatches(const AQH_URLHANDLER *uh, const char *s)
{
if (uh && s && *s) {
GWEN_STRINGLISTENTRY *se;
se=GWEN_StringList_FirstEntry(uh->urlPatternList);
while(se) {
const char *pattern;
pattern=GWEN_StringListEntry_Data(se);
if (GWEN_Text_ComparePattern(s, pattern, 0)!=-1)
return 1;
se=GWEN_StringListEntry_Next(se);
}
}
return 0;
}
GWEN_MSG *AQH_UrlHandler_HandleMessage(AQH_URLHANDLER *uh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msgReceived)
{
if (uh && uh->handleFn)
return uh->handleFn(uh, ep, msgReceived);
return NULL;
}

View File

@@ -1,48 +0,0 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQHOME_URLHANDLER_H
#define AQHOME_URLHANDLER_H
#include <aqhome/api.h>
#include "aqhome/http/content.h"
#include <gwenhywfar/inherit.h>
#include <gwenhywfar/stringlist.h>
#include <gwenhywfar/endpoint.h>
#include <gwenhywfar/msg.h>
typedef struct AQH_URLHANDLER AQH_URLHANDLER;
GWEN_INHERIT_FUNCTION_LIB_DEFS(AQH_URLHANDLER, AQHOME_API)
GWEN_LIST_FUNCTION_LIB_DEFS(AQH_URLHANDLER, AQH_UrlHandler, AQHOME_API)
typedef GWEN_MSG*(*AQH_URLHANDLER_HANDLE_FN)(AQH_URLHANDLER *uh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msgReceived);
AQHOME_API AQH_URLHANDLER *AQH_UrlHandler_new(void);
AQHOME_API void AQH_UrlHandler_free(AQH_URLHANDLER *uh);
AQHOME_API AQH_HTTP_CONTENT *AQH_UrlHandler_GetContentProvider(const AQH_URLHANDLER *uh);
AQHOME_API void AQH_UrlHandler_SetContentProvider(AQH_URLHANDLER *uh, AQH_HTTP_CONTENT *cp);
AQHOME_API void AQH_UrlHandler_AddUrlPattern(AQH_URLHANDLER *uh, const char *s);
AQHOME_API int AQH_UrlHandler_UrlMatches(const AQH_URLHANDLER *uh, const char *s);
AQHOME_API GWEN_MSG *AQH_UrlHandler_HandleMessage(AQH_URLHANDLER *uh, GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msgReceived);
#endif

View File

@@ -1,29 +0,0 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQHOME_URLHANDLER_P_H
#define AQHOME_URLHANDLER_P_H
#include "aqhome/http/urlhandler.h"
struct AQH_URLHANDLER {
GWEN_INHERIT_ELEMENT(AQH_URLHANDLER);
GWEN_LIST_ELEMENT(AQH_URLHANDLER);
GWEN_STRINGLIST *urlPatternList;
AQH_URLHANDLER_HANDLE_FN handleFn;
AQH_HTTP_CONTENT *httpContentProvider;
};
#endif