aqhome-cgi: fixed path of diagrams generated for pages.
This commit is contained in:
@@ -61,13 +61,15 @@ static void _writeActor(AQH_DATACLIENT *dc, const char *sPageId, GWEN_XMLNODE *n
|
||||
static void _writeGraph(const char *sPageId, GWEN_XMLNODE *n, int layout, GWEN_BUFFER *dbuf);
|
||||
|
||||
static void _handlePageActor(AQCGI_REQUEST *rq, AQH_DATACLIENT *dc, const char *sActorId, GWEN_XMLNODE *nActor);
|
||||
static void _handlePageGraph(AQCGI_MODULE *m, AQCGI_REQUEST *rq, AQH_DATACLIENT *dc, const char *sGraphId, GWEN_XMLNODE *nGraph, GWEN_BUFFER *dbuf);
|
||||
static void _genPageGraph(AQH_DATACLIENT *dc, const char *sGraphId, const char *sFilename, GWEN_XMLNODE *nGraph);
|
||||
static void _handlePageGraph(AQCGI_MODULE *m, AQCGI_REQUEST *rq, AQH_DATACLIENT *dc,
|
||||
const char *sPageId, const char *sGraphId,
|
||||
GWEN_XMLNODE *nGraph, GWEN_BUFFER *dbuf);
|
||||
static void _genPageGraph(AQH_DATACLIENT *dc, const char *sFilename, GWEN_XMLNODE *nGraph);
|
||||
static void _addCurves(AQH_DATACLIENT *dc, AQDG_GRAPH *g, GWEN_XMLNODE *nGraph, uint64_t tsBegin, uint64_t tsEnd);
|
||||
static AQDG_GRAPH_DATAPAIR_LIST *_readCurveData(AQH_DATACLIENT *dc, GWEN_XMLNODE *nCurve, uint64_t tsBegin, uint64_t tsEnd);
|
||||
static uint64_t _parseTime(const char *s);
|
||||
static GWEN_XMLNODE *_getSubItemNode(GWEN_XMLNODE *nPage, const char *sId, const char *sElementName);
|
||||
static void _mkPathForGraph(AQCGI_MODULE *m, const char *sGraphId, GWEN_BUFFER *dbuf);
|
||||
static void _mkPathForGraph(AQCGI_MODULE *m, const char *sPageId, const char *sGraphId, GWEN_BUFFER *dbuf);
|
||||
static void _addGraphLink(const char *sPageId, const char *sGraphId, int w, int h, GWEN_BUFFER *dbuf);
|
||||
static void _writeRgbwToForm(const char *sValueName, uint32_t color, GWEN_BUFFER *dbuf);
|
||||
static void _writeOnOffToForm(const char *sValueName, int intVal, GWEN_BUFFER *dbuf);
|
||||
@@ -148,7 +150,7 @@ void AQH_ModDevices_RunPageGraph(AQCGI_MODULE *m, AQCGI_REQUEST *rq, AQCGI_SESSI
|
||||
nPage=GWEN_XMLNode_FindFirstTag(fileNode, "page", "id", sPageId);
|
||||
nGraph=_getSubItemNode(nPage, sGraphId, "graph");
|
||||
if (nPage && nGraph)
|
||||
_handlePageGraph(m, rq, dc, sGraphId, nGraph, dbuf);
|
||||
_handlePageGraph(m, rq, dc, sPageId, sGraphId, nGraph, dbuf);
|
||||
else {
|
||||
DBG_ERROR(NULL, "Graph %s/%s not found", sPageId, sGraphId);
|
||||
}
|
||||
@@ -247,16 +249,16 @@ void _handlePageActor(AQCGI_REQUEST *rq, AQH_DATACLIENT *dc, const char *sActorI
|
||||
|
||||
|
||||
|
||||
void _handlePageGraph(AQCGI_MODULE *m, AQCGI_REQUEST *rq, AQH_DATACLIENT *dc, const char *sGraphId, GWEN_XMLNODE *nGraph, GWEN_BUFFER *dbuf)
|
||||
void _handlePageGraph(AQCGI_MODULE *m, AQCGI_REQUEST *rq, AQH_DATACLIENT *dc, const char *sPageId, const char *sGraphId, GWEN_XMLNODE *nGraph, GWEN_BUFFER *dbuf)
|
||||
{
|
||||
GWEN_BUFFER *fbuf;
|
||||
int refreshTime;
|
||||
|
||||
refreshTime=GWEN_XMLNode_GetIntProperty(nGraph, "refreshTime", 120);
|
||||
fbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
_mkPathForGraph(m, sGraphId, fbuf);
|
||||
_mkPathForGraph(m, sPageId, sGraphId, fbuf);
|
||||
if (!AQH_ModService_FileIsCurrent(GWEN_Buffer_GetStart(fbuf), refreshTime)) {
|
||||
_genPageGraph(dc, sGraphId, GWEN_Buffer_GetStart(fbuf), nGraph);
|
||||
_genPageGraph(dc, GWEN_Buffer_GetStart(fbuf), nGraph);
|
||||
}
|
||||
AQH_ModService_RespondWithMimeFile(rq, GWEN_Buffer_GetStart(fbuf), "image/png", dbuf);
|
||||
GWEN_Buffer_free(fbuf);
|
||||
@@ -264,7 +266,7 @@ void _handlePageGraph(AQCGI_MODULE *m, AQCGI_REQUEST *rq, AQH_DATACLIENT *dc, co
|
||||
|
||||
|
||||
|
||||
void _genPageGraph(AQH_DATACLIENT *dc, const char *sGraphId, const char *sFilename, GWEN_XMLNODE *nGraph)
|
||||
void _genPageGraph(AQH_DATACLIENT *dc, const char *sFilename, GWEN_XMLNODE *nGraph)
|
||||
{
|
||||
const char *s;
|
||||
const char *sTitle;
|
||||
@@ -309,7 +311,7 @@ void _genPageGraph(AQH_DATACLIENT *dc, const char *sGraphId, const char *sFilena
|
||||
_addCurves(dc, g, nGraph, tsBegin, tsEnd);
|
||||
AQDG_TimeGraph_SetupTicks(g, tickFlags, lowerLimit, upperLimit);
|
||||
|
||||
DBG_DEBUG(NULL, "Draw graph for %s", sGraphId);
|
||||
DBG_DEBUG(NULL, "Draw graph %s", sFilename);
|
||||
drawContext=AQDG_Draw_ContextCairo_Png_new(sFilename, w, h);
|
||||
graphObject=AQDG_GraphWidget_new(NULL, AQDG_OBJECT_OPTIONS_STRETCHX | AQDG_OBJECT_OPTIONS_STRETCHY, drawContext);
|
||||
AQDG_Object_SetWidth(graphObject, w);
|
||||
@@ -460,14 +462,14 @@ GWEN_XMLNODE *_getSubItemNode(GWEN_XMLNODE *nPage, const char *sId, const char *
|
||||
|
||||
|
||||
|
||||
void _mkPathForGraph(AQCGI_MODULE *m, const char *sGraphId, GWEN_BUFFER *buf)
|
||||
void _mkPathForGraph(AQCGI_MODULE *m, const char *sPageId, const char *sGraphId, GWEN_BUFFER *buf)
|
||||
{
|
||||
AQCGI_SERVICE *sv;
|
||||
const char *s;
|
||||
|
||||
sv=AQH_ModService_GetService(m);
|
||||
s=AQCGI_Service_GetCacheFolder(sv);
|
||||
GBAA(buf, "%s%s%s", s, GWEN_DIR_SEPARATOR_S, sGraphId);
|
||||
GBAA(buf, "%s%s%s-%s", s, GWEN_DIR_SEPARATOR_S, sPageId, sGraphId);
|
||||
AQH_ModService_EscapeToBuffer(s, buf);
|
||||
GBAS(buf, ".png");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user