moved code for device module into its own folder. Implement graphs.
This commit is contained in:
@@ -5,11 +5,12 @@
|
||||
#include "aqhome-cgi/modules/common/madmin.h"
|
||||
#include "aqhome-cgi/modules/common/mmodules.h"
|
||||
#include "aqhome-cgi/modules/common/musers.h"
|
||||
#include "aqhome-cgi/modules/mdevices.h"
|
||||
#include "aqhome-cgi/modules/devices/mdevices.h"
|
||||
#include "aqhome/aqhome.h"
|
||||
|
||||
#include <aqcgi/cgi.h>
|
||||
#include <aqcgi/request.h>
|
||||
#include <aqdiagram/aqdiagram.h>
|
||||
|
||||
#include <gwenhywfar/gwenhywfar.h>
|
||||
#include <gwenhywfar/nogui.h>
|
||||
@@ -26,21 +27,34 @@
|
||||
|
||||
#define AQHOME_CGI_DEFAULT_STATIC_FILES AQHOME_CGI_WWWDIR"/static"
|
||||
#define AQHOME_CGI_DEFAULT_RUNTIME_FILES AQHOME_CGI_WWWDIR"/data"
|
||||
#define AQHOME_CGI_DEFAULT_CACHE_FILES AQHOME_CGI_WWWDIR"/cache"
|
||||
#define AQHOME_CGI_DEFAULT_BASE_URL "http://127.0.0.1/aqbt"
|
||||
|
||||
|
||||
|
||||
static void _handleRequest(AQCGI_REQUEST *rq, const char *sPathStaticFiles, const char *sPathRuntimeFiles);
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void _handleRequest(AQCGI_REQUEST *rq, const char *sPathStaticFiles, const char *sPathRuntimeFiles, const char *sBaseUrl);
|
||||
static int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles);
|
||||
static void logStart(void);
|
||||
static int _init(const char *sPathRuntimeFiles);
|
||||
static int _init(const char *sPathRuntimeFiles, const char *sBaseUrl);
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* code
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GWEN_GUI *gui;
|
||||
const char *sPathStaticFiles;
|
||||
const char *sPathRuntimeFiles;
|
||||
const char *sBaseUrl;
|
||||
|
||||
sPathStaticFiles=getenv("AQHOME_STATIC_FILES");
|
||||
if (!(sPathStaticFiles && *sPathStaticFiles))
|
||||
@@ -50,6 +64,10 @@ int main(int argc, char **argv)
|
||||
if (!(sPathRuntimeFiles && *sPathRuntimeFiles))
|
||||
sPathRuntimeFiles=AQHOME_CGI_DEFAULT_RUNTIME_FILES;
|
||||
|
||||
sBaseUrl=getenv("AQHOME_BASE_URL");
|
||||
if (!(sBaseUrl && *sBaseUrl))
|
||||
sBaseUrl=AQHOME_CGI_DEFAULT_BASE_URL;
|
||||
|
||||
GWEN_Init();
|
||||
gui=GWEN_NoGui_new();
|
||||
GWEN_Gui_SetGui(gui);
|
||||
@@ -58,6 +76,7 @@ int main(int argc, char **argv)
|
||||
GWEN_Logger_Open(GWEN_LOGDOMAIN, "gwenhywfar", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon);
|
||||
GWEN_Logger_Open(AQH_LOGDOMAIN, "aqhome", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon);
|
||||
GWEN_Logger_Open(AQCGI_LOGDOMAIN, "aqcgi", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon);
|
||||
GWEN_Logger_Open(AQDG_LOGDOMAIN, "aqdiagram", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon);
|
||||
GWEN_Logger_Open(NULL, "aqhome-cgi", AQHOME_CGI_LOGFILE, GWEN_LoggerType_File, GWEN_LoggerFacility_Daemon);
|
||||
|
||||
GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug);
|
||||
@@ -69,13 +88,14 @@ int main(int argc, char **argv)
|
||||
|
||||
GWEN_Logger_SetLevel(GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug);
|
||||
GWEN_Logger_SetLevel(AQCGI_LOGDOMAIN, GWEN_LoggerLevel_Debug);
|
||||
GWEN_Logger_SetLevel(AQDG_LOGDOMAIN, GWEN_LoggerLevel_Debug);
|
||||
GWEN_Logger_SetLevel(NULL, GWEN_LoggerLevel_Debug);
|
||||
|
||||
if (argc>1 && argv[1]) {
|
||||
if (0==strcasecmp(argv[1], "init")) {
|
||||
int rv;
|
||||
|
||||
rv=_init(sPathRuntimeFiles);
|
||||
rv=_init(sPathRuntimeFiles, sBaseUrl);
|
||||
if (rv<0) {
|
||||
fprintf(stderr, "Error on init (%d)\n", rv);
|
||||
return 2;
|
||||
@@ -90,7 +110,7 @@ int main(int argc, char **argv)
|
||||
AQCGI_Init();
|
||||
rq=AQCGI_ReadRequest();
|
||||
if (rq) {
|
||||
_handleRequest(rq, sPathStaticFiles, sPathRuntimeFiles);
|
||||
_handleRequest(rq, sPathStaticFiles, sPathRuntimeFiles, sBaseUrl);
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "Content-type: text/plain\n\n");
|
||||
@@ -104,12 +124,12 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
|
||||
void _handleRequest(AQCGI_REQUEST *rq, const char *sPathStaticFiles, const char *sPathRuntimeFiles)
|
||||
void _handleRequest(AQCGI_REQUEST *rq, const char *sPathStaticFiles, const char *sPathRuntimeFiles, const char *sBaseUrl)
|
||||
{
|
||||
AQH_SERVICE *sv;
|
||||
int rv;
|
||||
|
||||
sv=AQH_ServiceFiles_new(sPathRuntimeFiles);
|
||||
sv=AQH_ServiceFiles_new(sPathRuntimeFiles, sBaseUrl);
|
||||
|
||||
rv=_handlePath(sv, rq, sPathStaticFiles);
|
||||
if (rv<0) {
|
||||
@@ -160,6 +180,7 @@ int _handlePath(AQH_SERVICE *sv, AQCGI_REQUEST *rq, const char *sPathStaticFiles
|
||||
int rv;
|
||||
|
||||
/* last, let module handle remaining part */
|
||||
DBG_ERROR(NULL, "Entry: %s (last)", s);
|
||||
rv=AQH_ModService_HandleRequest(mParent, rq, session, s);
|
||||
if (rv<0) {
|
||||
DBG_INFO(NULL, "here (%d)", rv);
|
||||
@@ -199,13 +220,13 @@ void logStart()
|
||||
|
||||
|
||||
|
||||
int _init(const char *sPathRuntimeFiles)
|
||||
int _init(const char *sPathRuntimeFiles, const char *sBaseUrl)
|
||||
{
|
||||
AQH_SERVICE *sv;
|
||||
int rv;
|
||||
|
||||
fprintf(stdout, "Creating aqhome-cgi environment in \"%s\"\n", sPathRuntimeFiles);
|
||||
sv=AQH_ServiceFiles_new(sPathRuntimeFiles);
|
||||
DBG_ERROR(NULL, "Creating aqhome-cgi environment in \"%s\"", sPathRuntimeFiles);
|
||||
sv=AQH_ServiceFiles_new(sPathRuntimeFiles, sBaseUrl);
|
||||
rv=AQH_ModAdmin_Create(sv);
|
||||
if (rv<0) {
|
||||
DBG_ERROR(NULL, "Error creating module \"admin\"");
|
||||
|
||||
Reference in New Issue
Block a user