/* * * ProLinga-Data * * Copyright (C) 2002-2009 Xobas Software. * All rights reserved. * * This file is part of ProLinga-Data. * * ProLinga-Data 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-Data 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-Data. If not, see . * * More information is available at the following addresses: * * Website : http://www.prolinga.org * * Email : prolinga-list@prolinga.org * * */ #include "DatCommon.h" #include #include #include #include #include "DatMain.hpp" #include "DCAdmin.hpp" #include "DCSession.hpp" #include "DatConfig.hpp" #include "Utility.hpp" int DCListProviders(const char *objName, const xmlDocPtr docObj, const char *sessionId, char **externalError, xmlDocPtr *docReturn) { xmlNodePtr curReturn, curTmp; GdaDataModel *pl; gint row_id; const GValue *value; char *str; /* Get Provider List. Don't free or modify it! */ pl = gda_config_list_providers(); /* Create return document */ *docReturn = xmlNewDoc((const xmlChar *)XML_VERSION); (*docReturn)->children = xmlNewDocNode(*docReturn, NULL, (const xmlChar *)ROOT_ELEM, NULL); curReturn = xmlDocGetRootElement(*docReturn); /* Insert all providers in return document */ for (row_id = 0; row_id < gda_data_model_get_n_rows (pl); row_id++) { value = gda_data_model_get_value_at (pl, 0, row_id, NULL); str = gda_value_stringify(value); if (WildcardMatch((char *)objName, str) == 0) continue; curTmp = xmlNewTextChild(curReturn, NULL, (const xmlChar *)"Object", (const xmlChar *)""); xmlNewProp(curTmp, (const xmlChar *)"Name", (const xmlChar *)str); g_free(str); } /* Return */ return 0; } int DCListDataSources(const char *objName, const xmlDocPtr docObj, const char *sessionId, char **externalError, xmlDocPtr *docReturn) { xmlNodePtr curReturn, curTmp; GdaDataModel *dl; gint row_id; const GValue *value; char *str; /* Get List of Data Sources */ dl = gda_config_list_dsn(); /* Create return document */ *docReturn = xmlNewDoc((const xmlChar *)XML_VERSION); (*docReturn)->children = xmlNewDocNode(*docReturn, NULL, (const xmlChar *)ROOT_ELEM, NULL); curReturn = xmlDocGetRootElement(*docReturn); /* Insert all data sources in return document */ for (row_id = 0; row_id < gda_data_model_get_n_rows (dl); row_id++) { value = gda_data_model_get_value_at (dl, 0, row_id, NULL); str = gda_value_stringify(value); if (WildcardMatch((char *)objName, str) == 0) continue; curTmp = xmlNewTextChild(curReturn, NULL, (const xmlChar *)"Object", (const xmlChar *)""); xmlNewProp(curTmp, (const xmlChar *)"Name", (const xmlChar *)str); g_free(str); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Provider", (const xmlChar *)gda_value_stringify(gda_data_model_get_value_at(dl, 1, row_id, NULL))); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Description", (const xmlChar *)gda_value_stringify(gda_data_model_get_value_at(dl, 2, row_id, NULL))); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"Cnc", (const xmlChar *)gda_value_stringify(gda_data_model_get_value_at(dl, 3, row_id, NULL))); xmlNewTextChild(curTmp, NULL, (const xmlChar *)"UserName", (const xmlChar *)gda_value_stringify(gda_data_model_get_value_at(dl, 4, row_id, NULL))); } /* Return */ return 0; }