/* * * ProLinga-Run * * Copyright (C) 2002-2008 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Run. * * ProLinga-Run is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * ProLinga-Run is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ProLinga-Run. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "RunCommon.h" #include #include #include #include #include "CmdList.hpp" #include "DataRef.hpp" #include "ValidateAccess.hpp" #ifndef BUILD_VALIDATE extern char *validateEndPoint; extern int validateCompressionLevel; #endif extern ListStorePtr listStorePtr; xmlDocPtr VC_ValObject(const char *objApplication, const char *objType, const char *objName) { xmlDocPtr docReq, docRes; xmlNodePtr curReq; /* Create RC List */ docReq = xmlNewDoc((const xmlChar *)"1.0"); docReq->children = xmlNewDocNode(docReq, NULL, (const xmlChar *)"ProLinga", NULL); curReq = xmlDocGetRootElement(docReq); curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Validate", (const xmlChar *)""); xmlNewProp (curReq, (const xmlChar *)"Version", (const xmlChar *)"1.0"); curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Command", (const xmlChar *)""); xmlNewProp (curReq, (const xmlChar *)"Name", (const xmlChar *)"Validate"); xmlNewProp (curReq, (const xmlChar *)"Mode", (const xmlChar *)"Request"); curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Object", (const xmlChar *)""); xmlNewProp (curReq, (const xmlChar *)"Application", (const xmlChar *)objApplication); xmlNewProp (curReq, (const xmlChar *)"Type", (const xmlChar *)objType); xmlNewProp (curReq, (const xmlChar *)"Name", (const xmlChar *)objName); /* Process Request */ #if BUILD_VALIDATE docRes = ValidateAccess(docReq); #else docRes = ValidateAccess(docReq, validateEndPoint, validateCompressionLevel); #endif /* Return */ return docRes; } xmlDocPtr VC_Ping(const char *objApplication, const char *objType, const char *objName) { xmlDocPtr docReq, docRes; xmlNodePtr curReq; /* Create RC Ping */ docReq = xmlNewDoc((const xmlChar *)"1.0"); docReq->children = xmlNewDocNode(docReq, NULL, (const xmlChar *)"ProLinga", NULL); curReq = xmlDocGetRootElement(docReq); curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Validate", (const xmlChar *)""); xmlNewProp (curReq, (const xmlChar *)"Version", (const xmlChar *)"1.0"); curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Command", (const xmlChar *)""); xmlNewProp (curReq, (const xmlChar *)"Name", (const xmlChar *)"Ping"); xmlNewProp (curReq, (const xmlChar *)"Mode", (const xmlChar *)"Request"); curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Object", (const xmlChar *)""); xmlNewProp (curReq, (const xmlChar *)"Application", (const xmlChar *)objApplication); xmlNewProp (curReq, (const xmlChar *)"Type", (const xmlChar *)objType); xmlNewProp (curReq, (const xmlChar *)"Name", (const xmlChar *)objName); /* Process Request */ #if BUILD_VALIDATE docRes = ValidateAccess(docReq); #else docRes = ValidateAccess(docReq, validateEndPoint, validateCompressionLevel); #endif /* Return */ return docRes; } int valValObject(const char *objAppn, const char *objType, const char *objName, const bool isMainThread) { xmlDocPtr docRes; xmlXPathContextPtr ctxRes; xmlXPathObjectPtr resRes; char *status, evalString[1024]; int i, retStatus = 0, valErrorCount; GtkListStore *store; GtkTreeIter iter; /* Validate Document */ docRes = VC_ValObject(objAppn, objType, objName); /* Create XPath environment */ ctxRes = xmlXPathNewContext(docRes); /* Find Out Status */ resRes = xmlXPathEval((const xmlChar *)"/ProLinga/Validate/Command/@Status", ctxRes); if(!xmlXPathNodeSetIsEmpty(resRes->nodesetval)) status = (char *)xmlXPathCastToString(resRes); else { resRes = xmlXPathEval((const xmlChar *)"/ProLinga/Soap/Command/@Status", ctxRes); if(!xmlXPathNodeSetIsEmpty(resRes->nodesetval)) status = (char *)xmlXPathCastToString(resRes); } if (strncmp(status, "No",2) == 0) retStatus = 50001; else if (strcmp(status, "Ok") != 0) { /* Load up List Store with Validate Errors */ /* Clear list store */ listStorePtr->deleteFromList(&listStorePtr, "_validate_"); /* Get Store */ store = listStorePtr->getStore(&listStorePtr, "_validate_", isMainThread); /* Get number of validate errors */ resRes = xmlXPathEval((const xmlChar *)"count(/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError)", ctxRes); valErrorCount = (int)xmlXPathCastToNumber(resRes); /* Go through all validate errors */ for (i=1; i<=valErrorCount;i++) { /* Append */ gtk_list_store_append(store, &iter); /* Severity */ sprintf(evalString, "/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError[%d]/Severity", i); resRes = xmlXPathEval((const xmlChar *)evalString, ctxRes); gtk_list_store_set(store, &iter, 0, (char *)xmlXPathCastToString(resRes), -1); /* LineNo */ sprintf(evalString, "/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError[%d]/@LineNo", i); resRes = xmlXPathEval((const xmlChar *)evalString, ctxRes); gtk_list_store_set(store, &iter, 1, (char *)xmlXPathCastToString(resRes), -1); /* ArgumentNo */ sprintf(evalString, "/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError[%d]/@ArgumentNo", i); resRes = xmlXPathEval((const xmlChar *)evalString, ctxRes); if (strcmp((char *)xmlXPathCastToString(resRes), "0") == 0) gtk_list_store_set(store, &iter, 2, "", -1); else gtk_list_store_set(store, &iter, 2, (char *)xmlXPathCastToString(resRes), -1); /* Id */ sprintf(evalString, "/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError[%d]/Id", i); resRes = xmlXPathEval((const xmlChar *)evalString, ctxRes); gtk_list_store_set(store, &iter, 3, (char *)xmlXPathCastToString(resRes), -1); /* Description */ sprintf(evalString, "/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError[%d]/Description", i); resRes = xmlXPathEval((const xmlChar *)evalString, ctxRes); gtk_list_store_set(store, &iter, 4, (char *)xmlXPathCastToString(resRes), -1); /* Details */ sprintf(evalString, "/ProLinga/Validate/Command/Object/ValidateErrors/ValidateError[%d]/Details", i); resRes = xmlXPathEval((const xmlChar *)evalString, ctxRes); gtk_list_store_set(store, &iter, 5, (char *)xmlXPathCastToString(resRes), -1); } /* Set Return Status */ retStatus = 12345; } /* Clean up */ xmlFreeDoc(docRes); /* Return */ return retStatus; }