Logo
  • Main Page
  • Related Pages
  • Modules
  • Classes
  • Files

mmsrcparser.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005-2007 Stefan Schwarzer, Jens Schneider,             *
00003  *                           Matthias Hardt, Guido Madaus                  *
00004  *                                                                         *
00005  *   Copyright (C) 2007-2008 BerLinux Solutions GbR                        *
00006  *                           Stefan Schwarzer & Guido Madaus               *
00007  *                                                                         *
00008  *   Copyright (C) 2009-2012 BerLinux Solutions GmbH                       *
00009  *                                                                         *
00010  *   Authors:                                                              *
00011  *      Stefan Schwarzer   <stefan.schwarzer@diskohq.org>,                 *
00012  *      Matthias Hardt     <matthias.hardt@diskohq.org>,                   *
00013  *      Jens Schneider     <jens.schneider@diskohq.org>,                   *
00014  *      Guido Madaus       <guido.madaus@diskohq.org>,                     *
00015  *      Patrick Helterhoff <patrick.helterhoff@diskohq.org>,               *
00016  *      René Bählkow       <rene.baehlkow@diskohq.org>                     *
00017  *                                                                         *
00018  *   This library is free software; you can redistribute it and/or         *
00019  *   modify it under the terms of the GNU Lesser General Public            *
00020  *   License version 2.1 as published by the Free Software Foundation.     *
00021  *                                                                         *
00022  *   This library is distributed in the hope that it will be useful,       *
00023  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00024  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00025  *   Lesser General Public License for more details.                       *
00026  *                                                                         *
00027  *   You should have received a copy of the GNU Lesser General Public      *
00028  *   License along with this library; if not, write to the                 *
00029  *   Free Software Foundation, Inc.,                                       *
00030  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
00031  **************************************************************************/
00032 
00033 using namespace std;
00034 
00035 #include <iostream>
00036 
00037 #include <cstring>
00038 #include "mmsconfig/mmsrcparser.h"
00039 #include "mmstools/tools.h"
00040 #include "diskoversion.h"
00041 
00042 #define WRONG_VALUE(parname, parvalue, validvals, addmsg) throw MMSRcParserError(1, "wrong value '" + string(parvalue) + "' for parameter '" + string((const char *)parname) + "'\n valid value(s): " + validvals + "\n " + addmsg);
00043 
00044 
00045 MMSRcParser::MMSRcParser() {
00046     this->configdb.database = "/tmp/mmsconfigdb";
00047     this->datadb.database   = "/tmp/mmsdatadb";
00048 }
00049 
00050 MMSRcParser::~MMSRcParser() {
00051 
00052 }
00053 
00054 void MMSRcParser::parseFile(string filename) {
00055 
00056     try {
00057         xmlDoc *parser = NULL;
00058 
00059         LIBXML_TEST_VERSION
00060 
00061 #ifdef __ENABLE_LOG__
00062         parser = xmlReadFile((char *)filename.c_str(), NULL, XML_PARSE_NOBLANKS | XML_PARSE_NONET);
00063 #else
00064         parser = xmlReadFile((char *)filename.c_str(), NULL, XML_PARSE_NOBLANKS | XML_PARSE_NONET | XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
00065 #endif
00066 
00067         if(parser == NULL) {
00068             throw MMSRcParserError(1,"Could not parse file:" + filename);
00069         }
00070 
00071         if(parser) {
00072             //Walk the tree:
00073             xmlNode* pNode = xmlDocGetRootElement(parser);
00074             if(xmlStrcmp(pNode->name, (const xmlChar *) "mmsrc")) {
00075                 if(xmlStrcmp(pNode->name, (const xmlChar *) "diskorc")) {
00076                     std::cout << "invalid configuration file (" << filename << ") - does not contain mmsrc root node" << std::endl;
00077                     throw MMSRcParserError(1, "invalid file");
00078                 }
00079             }
00080             this->throughFile(pNode);
00081 
00082             if (this->graphics.vrect.w <= 0)
00083                 this->graphics.vrect.w = this->graphics.graphicslayer.rect.w;
00084             if (this->graphics.vrect.h <= 0)
00085                 this->graphics.vrect.h = this->graphics.graphicslayer.rect.h;
00086             if ((this->graphics.vrect.x < 0)||(this->graphics.vrect.x > this->graphics.graphicslayer.rect.w))
00087                 this->graphics.vrect.x = 0;
00088             if ((this->graphics.vrect.y < 0)||(this->graphics.vrect.y > this->graphics.graphicslayer.rect.h))
00089                 this->graphics.vrect.y = 0;
00090             if (this->graphics.vrect.w - this->graphics.vrect.x > this->graphics.graphicslayer.rect.w)
00091                 this->graphics.vrect.w = this->graphics.graphicslayer.rect.w - this->graphics.vrect.x;
00092             if (this->graphics.vrect.h - this->graphics.vrect.y > this->graphics.graphicslayer.rect.h)
00093                 this->graphics.vrect.h = this->graphics.graphicslayer.rect.h - this->graphics.vrect.y;
00094 
00095 
00096             /*free the document */
00097             xmlFreeDoc(parser);
00098         }
00099     }
00100     catch(MMSError &error)
00101     {
00102         std::cout << "RcParser exception: " << error.getMessage() << std::endl;
00103         throw MMSRcParserError(1, error.getMessage());
00104     }
00105 
00106 }
00107 
00108 void MMSRcParser::getMMSRc(MMSConfigDataGlobal      **global,
00109                            MMSConfigDataDB          **configdb,
00110                            MMSConfigDataDB          **datadb,
00111                            MMSConfigDataGraphics    **graphics,
00112                            MMSConfigDataLanguage    **language) {
00113     if (global)     *global   = &this->global;
00114     if (configdb)   *configdb = &this->configdb;
00115     if (datadb)     *datadb   = &this->datadb;
00116     if (graphics)   *graphics = &this->graphics;
00117     if (language)   *language = &this->language;
00118 }
00119 
00120 void MMSRcParser::getMMSRc(MMSConfigDataGlobal      *global,
00121                            MMSConfigDataDB          *configdb,
00122                            MMSConfigDataDB          *datadb,
00123                            MMSConfigDataGraphics    *graphics,
00124                            MMSConfigDataLanguage    *language) {
00125     if (global)     *global   = this->global;
00126     if (configdb)   *configdb = this->configdb;
00127     if (datadb)     *datadb   = this->datadb;
00128     if (graphics)   *graphics = this->graphics;
00129     if (language)   *language = this->language;
00130 }
00131 
00132 /**
00133  * Checks for version of the configuration file.
00134  *
00135  * If the version does not match, an exception is thrown.
00136  *
00137  * @param   node    should be the mmsrc root node
00138  */
00139 void MMSRcParser::checkVersion(xmlNode* node) {
00140 
00141     xmlChar *version;
00142 
00143     version = xmlGetProp(node, (const xmlChar*)"version");
00144 
00145     if(!version) {
00146         std::cout << "Configuration file misses version entity!" << std::endl;
00147         throw MMSRcParserError(1, "missing version");
00148     }
00149 
00150     // sep version
00151     version[1]=0;
00152     version[3]=0;
00153     int mav = atoi((char*)&version[0]);
00154     int miv = atoi((char*)&version[2]);
00155 
00156     // disko version check
00157     if ((mav > DISKO_MAJOR_VERSION )||(miv > DISKO_MINOR_VERSION)) {
00158         std::cout << "Version of configuration file does not match!" << std::endl;
00159         xmlFree(version);
00160         throw MMSRcParserError(1, "version mismatch");
00161     }
00162 
00163     xmlFree(version);
00164 }
00165 
00166 void MMSRcParser::throughGlobal(xmlNode* node) {
00167     xmlNode *cur_node = NULL;
00168     xmlChar *parname;
00169     xmlChar *parvalue;
00170 
00171     node = node->xmlChildrenNode;
00172 
00173     for (cur_node = node; cur_node; cur_node = cur_node->next) {
00174         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "text")) continue;
00175         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "comment")) continue;
00176         if(xmlStrcmp(cur_node->name, (const xmlChar *) "parameter")) {
00177             printf("RcParser: ignoring tag <%s/>\n", cur_node->name);
00178             continue;
00179         }
00180 
00181         parname  = xmlGetProp(cur_node, (const xmlChar*)"name");
00182         parvalue = xmlGetProp(cur_node, (const xmlChar*)"value");
00183 
00184         if(parname == NULL && parvalue == NULL)
00185             continue;
00186 
00187         if(!xmlStrcmp(parname, (const xmlChar *) "logfile"))
00188             this->global.logfile = string((const char *)parvalue);
00189         else if(!xmlStrcmp(parname, (const xmlChar *) "inputmap"))
00190             this->global.inputmap = string((const char *)parvalue);
00191         else if(!xmlStrcmp(parname, (const xmlChar *) "prefix"))
00192             this->global.prefix = string((const char *)parvalue);
00193         else if(!xmlStrcmp(parname, (const xmlChar *) "theme"))
00194             this->global.theme = string((const char *)parvalue);
00195         else if(!xmlStrcmp(parname, (const xmlChar *) "sysconfig"))
00196             this->global.sysconfig = string((const char *)parvalue);
00197         else if(!xmlStrcmp(parname, (const xmlChar *) "data"))
00198             this->global.data = string((const char *)parvalue);
00199         else if(!xmlStrcmp(parname, (const xmlChar *) "inputinterval"))
00200             this->global.inputinterval = strToInt(string((const char *)parvalue));
00201         else if(!xmlStrcmp(parname, (const xmlChar *) "firstplugin"))
00202             this->global.firstplugin = string((const char *)parvalue);
00203         else if(!xmlStrcmp(parname, (const xmlChar *) "shutdown"))
00204             this->global.shutdown = strToBool(string((const char *)parvalue));
00205         else if(!xmlStrcmp(parname, (const xmlChar *) "shutdowncmd"))
00206             this->global.shutdowncmd = string((const char *)parvalue);
00207         else if(!xmlStrcmp(parname, (const xmlChar *) "inputmode"))
00208             this->global.inputmode = string((const char *)parvalue);
00209         else if(!xmlStrcmp(parname, (const xmlChar *) "actmonaddress"))
00210             this->global.actmonaddress = string((const char *)parvalue);
00211         else if(!xmlStrcmp(parname, (const xmlChar *) "actmonport"))
00212             this->global.actmonport = atoi((const char*)parvalue);
00213         else
00214             printf("RcParser: ignoring parameter '%s' in tag <global/>\n", parname);
00215 
00216         xmlFree(parname);
00217         xmlFree(parvalue);
00218     }
00219 }
00220 
00221 void MMSRcParser::throughLanguage(xmlNode* node) {
00222     xmlNode *cur_node = NULL;
00223     xmlChar *parname;
00224     xmlChar *parvalue;
00225 
00226     node = node->xmlChildrenNode;
00227 
00228     for (cur_node = node; cur_node; cur_node = cur_node->next) {
00229         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "text")) continue;
00230         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "comment")) continue;
00231         if(xmlStrcmp(cur_node->name, (const xmlChar *) "parameter")) {
00232             printf("RcParser: ignoring tag <%s/>\n", cur_node->name);
00233             continue;
00234         }
00235 
00236         parname  = xmlGetProp(cur_node, (const xmlChar*)"name");
00237         parvalue = xmlGetProp(cur_node, (const xmlChar*)"value");
00238 
00239         if(parname == NULL && parvalue == NULL)
00240             continue;
00241 
00242         if(!xmlStrcmp(parname, (const xmlChar *) "sourcelang"))
00243             this->language.sourcelang = getMMSLanguageFromString((const char *)parvalue);
00244         else if(!xmlStrcmp(parname, (const xmlChar *) "defaultdestlang"))
00245             this->language.defaulttargetlang = getMMSLanguageFromString((const char *)parvalue);
00246         else if(!xmlStrcmp(parname, (const xmlChar *) "addtranslations"))
00247             this->language.addtranslations = strToBool(string((const char *)parvalue));
00248         else if(!xmlStrcmp(parname, (const xmlChar *) "languagefiledir"))
00249             this->language.languagefiledir = string((const char *)parvalue);
00250         else
00251             printf("RcParser: ignoring parameter '%s' in tag <global/>\n", parname);
00252 
00253         xmlFree(parname);
00254         xmlFree(parvalue);
00255     }
00256 }
00257 
00258 void MMSRcParser::throughDBSettings(xmlNode* node) {
00259     MMSConfigDataDB *db;
00260     xmlChar *type;
00261 
00262     type = xmlGetProp(node, (const xmlChar*)"type");
00263 
00264     if(!xmlStrcmp(type, (const xmlChar *) "config")) {
00265         db = &this->configdb;
00266     }
00267     else if(!xmlStrcmp(type, (const xmlChar *) "data")) {
00268         db = &this->datadb;
00269     }
00270     else {
00271         throw MMSRcParserError(1, "unknown database type (" + string((const char*)type) + ")");
00272     }
00273 
00274     xmlFree(type);
00275 
00276     xmlNode *cur_node = NULL;
00277     xmlChar *parname;
00278     xmlChar *parvalue;
00279 
00280     for (cur_node = node->xmlChildrenNode; cur_node; cur_node = cur_node->next) {
00281         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "text")) continue;
00282         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "comment")) continue;
00283         if(xmlStrcmp(cur_node->name, (const xmlChar *) "parameter")) {
00284             printf("RcParser: ignoring tag <%s/>\n", cur_node->name);
00285             continue;
00286         }
00287 
00288         parname  = xmlGetProp(cur_node, (const xmlChar*)"name");
00289         parvalue = xmlGetProp(cur_node, (const xmlChar*)"value");
00290 
00291         if(!xmlStrcmp(parname, (const xmlChar *) "dbms"))
00292             db->dbms = string((const char *)parvalue);
00293         else if(!xmlStrcmp(parname, (const xmlChar *) "address"))
00294             db->address = string((const char *)parvalue);
00295         else if(!xmlStrcmp(parname, (const xmlChar *) "port"))
00296             db->port = atoi((const char*)parvalue);
00297         else if(!xmlStrcmp(parname, (const xmlChar *) "user"))
00298             db->user = string((const char *)parvalue);
00299         else if(!xmlStrcmp(parname, (const xmlChar *) "password"))
00300             db->password = string((const char *)parvalue);
00301         else if(!xmlStrcmp(parname, (const xmlChar *) "database"))
00302             db->database = string((const char *)parvalue);
00303         else
00304             printf("RcParser: ignoring parameter '%s' in tag <dbsettings/>\n", parname);
00305 
00306         xmlFree(parname);
00307         xmlFree(parvalue);
00308     }
00309 }
00310 
00311 
00312 
00313 void MMSRcParser::check_outputtype(MMSFBOutputType outputtype, xmlChar *parname, xmlChar *parvalue) {
00314     string val = string((const char *)parvalue);
00315 
00316     // check value against backend type
00317     if (this->graphics.backend == MMSFB_BE_DFB) {
00318         switch (outputtype) {
00319         case MMSFB_OT_STDFB:
00320         case MMSFB_OT_MATROXFB:
00321         case MMSFB_OT_VIAFB:
00322         case MMSFB_OT_X11:
00323         case MMSFB_OT_DAVINCIFB:
00324         case MMSFB_OT_OMAPFB:
00325             // okay
00326             break;
00327         default:
00328             WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_DFB, "-> this depends on backend=\"DFB\"");
00329             break;
00330         }
00331     }
00332     else
00333     if (this->graphics.backend == MMSFB_BE_X11) {
00334         switch (outputtype) {
00335         case MMSFB_OT_X11:
00336         case MMSFB_OT_XSHM:
00337         case MMSFB_OT_XVSHM:
00338         case MMSFB_OT_OGL:
00339             // okay
00340             break;
00341         default:
00342             WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_X11, "-> this depends on backend=\"X11\"");
00343             break;
00344         }
00345     }
00346     else
00347     if (this->graphics.backend == MMSFB_BE_FBDEV) {
00348         switch (outputtype) {
00349         case MMSFB_OT_STDFB:
00350         case MMSFB_OT_MATROXFB:
00351         case MMSFB_OT_DAVINCIFB:
00352         case MMSFB_OT_OMAPFB:
00353         case MMSFB_OT_OGL:
00354             // okay
00355             break;
00356         default:
00357             WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_FBDEV, "-> this depends on backend=\"FBDEV\"");
00358             break;
00359         }
00360     }
00361 }
00362 
00363 
00364 void MMSRcParser::get_outputtype(THROUGH_GRAPHICS_MODE mode, xmlChar *parname, xmlChar *parvalue) {
00365     string val = string((const char *)parvalue);
00366 
00367     // get/check value
00368     switch (mode) {
00369     case THROUGH_GRAPHICS_MODE_NORMAL:
00370         this->graphics.videolayer.outputtype = this->graphics.graphicslayer.outputtype = getMMSFBOutputTypeFromString(strToUpr(val));
00371         if (this->graphics.videolayer.outputtype == MMSFB_OT_NONE)
00372             WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES, "");
00373         check_outputtype(this->graphics.graphicslayer.outputtype, parname, parvalue);
00374         break;
00375     case THROUGH_GRAPHICS_MODE_VIDEOLAYER:
00376         this->graphics.videolayer.outputtype = getMMSFBOutputTypeFromString(strToUpr(val));
00377         if (this->graphics.videolayer.outputtype == MMSFB_OT_NONE)
00378             WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES, "");
00379         check_outputtype(this->graphics.videolayer.outputtype, parname, parvalue);
00380         break;
00381     case THROUGH_GRAPHICS_MODE_GRAPHICSLAYER:
00382         this->graphics.graphicslayer.outputtype = getMMSFBOutputTypeFromString(strToUpr(val));
00383         if (this->graphics.graphicslayer.outputtype == MMSFB_OT_NONE)
00384             WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES, "");
00385         check_outputtype(this->graphics.graphicslayer.outputtype, parname, parvalue);
00386         break;
00387     }
00388 }
00389 
00390 void MMSRcParser::get_xres(THROUGH_GRAPHICS_MODE mode, xmlChar *parvalue) {
00391     switch (mode) {
00392     case THROUGH_GRAPHICS_MODE_NORMAL:
00393         this->graphics.videolayer.rect.w = this->graphics.graphicslayer.rect.w = strToInt(string((const char *)parvalue));
00394         break;
00395     case THROUGH_GRAPHICS_MODE_VIDEOLAYER:
00396         this->graphics.videolayer.rect.w = strToInt(string((const char *)parvalue));
00397         break;
00398     case THROUGH_GRAPHICS_MODE_GRAPHICSLAYER:
00399         this->graphics.graphicslayer.rect.w = strToInt(string((const char *)parvalue));
00400         break;
00401     }
00402 }
00403 
00404 
00405 void MMSRcParser::get_yres(THROUGH_GRAPHICS_MODE mode, xmlChar *parvalue) {
00406     switch (mode) {
00407     case THROUGH_GRAPHICS_MODE_NORMAL:
00408         this->graphics.videolayer.rect.h = this->graphics.graphicslayer.rect.h = strToInt(string((const char *)parvalue));
00409         break;
00410     case THROUGH_GRAPHICS_MODE_VIDEOLAYER:
00411         this->graphics.videolayer.rect.h = strToInt(string((const char *)parvalue));
00412         break;
00413     case THROUGH_GRAPHICS_MODE_GRAPHICSLAYER:
00414         this->graphics.graphicslayer.rect.h = strToInt(string((const char *)parvalue));
00415         break;
00416     }
00417 }
00418 
00419 
00420 void MMSRcParser::get_xpos(THROUGH_GRAPHICS_MODE mode, xmlChar *parvalue) {
00421     switch (mode) {
00422     case THROUGH_GRAPHICS_MODE_NORMAL:
00423         this->graphics.videolayer.rect.x = this->graphics.graphicslayer.rect.x = strToInt(string((const char *)parvalue));
00424         break;
00425     case THROUGH_GRAPHICS_MODE_VIDEOLAYER:
00426         this->graphics.videolayer.rect.x = strToInt(string((const char *)parvalue));
00427         break;
00428     case THROUGH_GRAPHICS_MODE_GRAPHICSLAYER:
00429         this->graphics.graphicslayer.rect.x = strToInt(string((const char *)parvalue));
00430         break;
00431     }
00432 }
00433 
00434 
00435 void MMSRcParser::get_ypos(THROUGH_GRAPHICS_MODE mode, xmlChar *parvalue) {
00436     switch (mode) {
00437     case THROUGH_GRAPHICS_MODE_NORMAL:
00438         this->graphics.videolayer.rect.y = this->graphics.graphicslayer.rect.y = strToInt(string((const char *)parvalue));
00439         break;
00440     case THROUGH_GRAPHICS_MODE_VIDEOLAYER:
00441         this->graphics.videolayer.rect.y = strToInt(string((const char *)parvalue));
00442         break;
00443     case THROUGH_GRAPHICS_MODE_GRAPHICSLAYER:
00444         this->graphics.graphicslayer.rect.y = strToInt(string((const char *)parvalue));
00445         break;
00446     }
00447 }
00448 
00449 
00450 void MMSRcParser::throughGraphics(xmlNode* node, THROUGH_GRAPHICS_MODE mode) {
00451     xmlNode *cur_node = NULL;
00452     xmlChar *parname;
00453     xmlChar *parvalue;
00454     MMSConfigDataLayer vl, gl;
00455 
00456     if (mode == THROUGH_GRAPHICS_MODE_NORMAL) {
00457         // save the old settings and set id to -1
00458         vl = this->graphics.videolayer;
00459         gl = this->graphics.graphicslayer;
00460         this->graphics.videolayer.id = -1;
00461         this->graphics.graphicslayer.id = -1;
00462     }
00463 
00464     node = node->xmlChildrenNode;
00465 
00466     for (cur_node = node; cur_node; cur_node = cur_node->next) {
00467         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "text")) continue;
00468         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "comment")) continue;
00469         if(xmlStrcmp(cur_node->name, (const xmlChar *) "parameter")) {
00470             if (mode == THROUGH_GRAPHICS_MODE_NORMAL) {
00471                 if(!xmlStrcmp(cur_node->name, (const xmlChar *) "videolayer")) {
00472                     // we detect the <videolayer/> tag inside the graphics section
00473                     throughGraphics(cur_node, THROUGH_GRAPHICS_MODE_VIDEOLAYER);
00474                     continue;
00475                 }
00476                 else
00477                 if(!xmlStrcmp(cur_node->name, (const xmlChar *) "graphicslayer")) {
00478                     // we detect the <graphicslayer/> tag inside the graphics section
00479                     throughGraphics(cur_node, THROUGH_GRAPHICS_MODE_GRAPHICSLAYER);
00480                     continue;
00481                 }
00482             }
00483             printf("RcParser: ignoring tag <%s/>\n", cur_node->name);
00484             continue;
00485         }
00486 
00487         // get next parameter/value pair
00488         parname  = xmlGetProp(cur_node, (const xmlChar*)"name");
00489         parvalue = xmlGetProp(cur_node, (const xmlChar*)"value");
00490 
00491         // checking all supported parameters
00492         if(!xmlStrcmp(parname, (const xmlChar *) "outputtype")) {
00493             // get the outputtype of the layer(s)
00494             get_outputtype(mode, parname, parvalue);
00495         }
00496         else if(!xmlStrcmp(parname, (const xmlChar *) "xres")) {
00497             // get the width of the layer(s)
00498             get_xres(mode, parvalue);
00499         }
00500         else if(!xmlStrcmp(parname, (const xmlChar *) "yres")) {
00501             // get the height of the layer(s)
00502             get_yres(mode, parvalue);
00503         }
00504         else if(!xmlStrcmp(parname, (const xmlChar *) "xpos")) {
00505             // get the x-position of the layer(s)
00506             get_xpos(mode, parvalue);
00507         }
00508         else if(!xmlStrcmp(parname, (const xmlChar *) "ypos")) {
00509             // get the y-position of the layer(s)
00510             get_ypos(mode, parvalue);
00511         } else if(!xmlStrcmp(parname, (const xmlChar *) "graphicslayerid")) {
00512             this->graphics.graphicslayer.id = atoi((const char *)parvalue);
00513         }
00514         else if(!xmlStrcmp(parname, (const xmlChar *) "graphicslayerpixelformat")) {
00515             string val = string((const char *)parvalue);
00516             if ((this->graphics.graphicslayer.pixelformat = getMMSFBPixelFormatFromString(strToUpr(val))) == MMSFB_PF_NONE)
00517                 WRONG_VALUE(parname, val, MMSFB_PF_VALID_VALUES_LAYER, "");
00518         }
00519         else if(!xmlStrcmp(parname, (const xmlChar *) "graphicslayeroptions")) {
00520             this->graphics.graphicslayer.options = strToUpr(string((const char *)parvalue));
00521         }
00522         else if(!xmlStrcmp(parname, (const xmlChar *) "graphicslayerbuffermode")) {
00523             if((this->graphics.graphicslayer.outputtype == MMSFB_OT_X11) &&
00524                xmlStrEqual(parvalue, (const xmlChar *) "FRONTONLY")) {
00525                 WRONG_VALUE(parname, string((const char *)parvalue), MMSFB_PF_VALID_BUFFERMODES_X11, "-> this depends on graphicslayer.outputtype=\"X11\"");
00526             } else if((xmlStrcasecmp(parvalue, (const xmlChar *) "BACKSYSTEM") != 0) &&
00527                (xmlStrcasecmp(parvalue, (const xmlChar *) "BACKVIDEO") != 0) &&
00528                (xmlStrcasecmp(parvalue, (const xmlChar *) "FRONTONLY") != 0) &&
00529                (xmlStrcasecmp(parvalue, (const xmlChar *) "TRIPLE") != 0) &&
00530                (xmlStrcasecmp(parvalue, (const xmlChar *) "WINDOWS") != 0)) {
00531                 WRONG_VALUE(parname, string((const char *)parvalue), MMSFB_PF_VALID_BUFFERMODES, "");
00532             } else {
00533                 this->graphics.graphicslayer.buffermode = strToUpr((const char *)parvalue);
00534             }
00535         }
00536         else if(!xmlStrcmp(parname, (const xmlChar *) "videolayerid")) {
00537             this->graphics.videolayer.id = atoi((const char *)parvalue);
00538         }
00539         else if(!xmlStrcmp(parname, (const xmlChar *) "videolayerpixelformat")) {
00540             string val = string((const char *)parvalue);
00541             if ((this->graphics.videolayer.pixelformat = getMMSFBPixelFormatFromString(strToUpr(val))) == MMSFB_PF_NONE)
00542                 WRONG_VALUE(parname, val, MMSFB_PF_VALID_VALUES_LAYER, "");
00543         }
00544         else if(!xmlStrcmp(parname, (const xmlChar *) "videolayeroptions")) {
00545             this->graphics.videolayer.options = strToUpr(string((const char *)parvalue));
00546         }
00547         else if(!xmlStrcmp(parname, (const xmlChar *) "videolayerbuffermode")) {
00548             if((this->graphics.videolayer.outputtype == MMSFB_OT_X11) &&
00549                xmlStrEqual(parvalue, (const xmlChar *) "FRONTONLY")) {
00550                 WRONG_VALUE(parname, string((const char *)parvalue), MMSFB_PF_VALID_BUFFERMODES_X11, "-> this depends on videolayer.outputtype=\"X11\"");
00551             } else if((xmlStrcasecmp(parvalue, (const xmlChar *) "BACKSYSTEM") != 0) &&
00552                (xmlStrcasecmp(parvalue, (const xmlChar *) "BACKVIDEO") != 0) &&
00553                (xmlStrcasecmp(parvalue, (const xmlChar *) "FRONTONLY") != 0) &&
00554                (xmlStrcasecmp(parvalue, (const xmlChar *) "TRIPLE") != 0) &&
00555                (xmlStrcasecmp(parvalue, (const xmlChar *) "WINDOWS") != 0)) {
00556                 WRONG_VALUE(parname, string((const char *)parvalue), MMSFB_PF_VALID_BUFFERMODES, "");
00557             } else {
00558                 this->graphics.videolayer.buffermode = strToUpr((const char *)parvalue);
00559             }
00560         } else if (mode == THROUGH_GRAPHICS_MODE_NORMAL) {
00561             // through parameters which are used outside <graphicslayer/> and <videolayer/>
00562             if(!xmlStrcmp(parname, (const xmlChar *) "backend")) {
00563                 string val = string((const char *)parvalue);
00564                 // get/check value
00565                 if ((this->graphics.backend = getMMSFBBackendFromString(strToUpr(val))) == MMSFB_BE_NONE)
00566                     WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES, "");
00567 /*
00568                 // check value against output type
00569                 if (this->graphics.outputtype == MMSFB_OT_STDFB) {
00570                     switch (this->graphics.backend) {
00571                     case MMSFB_BE_DFB:
00572                     case MMSFB_BE_FBDEV:
00573                         // okay
00574                         break;
00575                     default:
00576                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_FB, "-> this depends on outputtype=\"STDFB\"");
00577                     }
00578                 }
00579                 else
00580                 if (this->graphics.outputtype == MMSFB_OT_MATROXFB) {
00581                     switch (this->graphics.backend) {
00582                     case MMSFB_BE_DFB:
00583                     case MMSFB_BE_FBDEV:
00584                         // okay
00585                         break;
00586                     default:
00587                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_FB, "-> this depends on outputtype=\"MATROXFB\"");
00588                     }
00589                 }
00590                 else
00591                 if (this->graphics.outputtype == MMSFB_OT_VIAFB) {
00592                     switch (this->graphics.backend) {
00593                     case MMSFB_BE_DFB:
00594                     case MMSFB_BE_FBDEV:
00595                         // okay
00596                         break;
00597                     default:
00598                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_FB, "-> this depends on outputtype=\"VIAFB\"");
00599                     }
00600                 }
00601                 else
00602                 if (this->graphics.outputtype == MMSFB_OT_X11) {
00603                     switch (this->graphics.backend) {
00604                     case MMSFB_BE_DFB:
00605                     case MMSFB_BE_X11:
00606                     case MMSFB_BE_OGL:
00607                         // okay
00608                         break;
00609                     default:
00610                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_X11, "-> this depends on outputtype=\"X11\"");
00611                     }
00612                 }
00613                 else
00614                 if (this->graphics.outputtype == MMSFB_OT_XSHM) {
00615                     switch (this->graphics.backend) {
00616                     case MMSFB_BE_X11:
00617                         // okay
00618                         break;
00619                     default:
00620                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_X, "-> this depends on outputtype=\"XSHM\"");
00621                     }
00622                 }
00623                 else
00624                 if (this->graphics.outputtype == MMSFB_OT_XVSHM) {
00625                     switch (this->graphics.backend) {
00626                     case MMSFB_BE_X11:
00627                         // okay
00628                         break;
00629                     default:
00630                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_X, "-> this depends on outputtype=\"XVSHM\"");
00631                     }
00632                 }
00633                 else
00634                 if (this->graphics.outputtype == MMSFB_OT_DAVINCIFB) {
00635                     switch (this->graphics.backend) {
00636                     case MMSFB_BE_DFB:
00637                     case MMSFB_BE_FBDEV:
00638                         // okay
00639                         break;
00640                     default:
00641                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_FB, "-> this depends on outputtype=\"DAVINCIFB\"");
00642                     }
00643                 }
00644                 else
00645                 if (this->graphics.outputtype == MMSFB_OT_OMAPFB) {
00646                     switch (this->graphics.backend) {
00647                     case MMSFB_BE_DFB:
00648                     case MMSFB_BE_FBDEV:
00649                         // okay
00650                         break;
00651                     default:
00652                         WRONG_VALUE(parname, val, MMSFB_BE_VALID_VALUES_OT_FB, "-> this depends on outputtype=\"OMAPFB\"");
00653                     }
00654                 }*/
00655 
00656             }
00657 
00658 /*          else if(!xmlStrcmp(parname, (const xmlChar *) "outputtype")) {
00659                 string val = string((const char *)parvalue);
00660                 // get/check value
00661                 if ((this->graphics.outputtype = getMMSFBOutputTypeFromString(strToUpr(val))) == MMSFB_OT_NONE)
00662                     WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES, "");
00663 
00664                 // check value against backend type
00665                 if (this->graphics.backend == MMSFB_BE_DFB) {
00666                     switch (this->graphics.outputtype) {
00667                     case MMSFB_OT_STDFB:
00668                     case MMSFB_OT_MATROXFB:
00669                     case MMSFB_OT_VIAFB:
00670                     case MMSFB_OT_X11:
00671                     case MMSFB_OT_DAVINCIFB:
00672                     case MMSFB_OT_OMAPFB:
00673                         // okay
00674                         break;
00675                     default:
00676                         WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_DFB, "-> this depends on backend=\"DFB\"");
00677                     }
00678                 }
00679                 else
00680                 if (this->graphics.backend == MMSFB_BE_X11) {
00681                     switch (this->graphics.outputtype) {
00682                     case MMSFB_OT_X11:
00683                     case MMSFB_OT_XSHM:
00684                     case MMSFB_OT_XVSHM:
00685                         // okay
00686                         break;
00687                     default:
00688                         WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_X11, "-> this depends on backend=\"X11\"");
00689                     }
00690                 }
00691                 else
00692                 if (this->graphics.backend == MMSFB_BE_FBDEV) {
00693                     switch (this->graphics.outputtype) {
00694                     case MMSFB_OT_STDFB:
00695                     case MMSFB_OT_MATROXFB:
00696                     case MMSFB_OT_DAVINCIFB:
00697                     case MMSFB_OT_OMAPFB:
00698                         // okay
00699                         break;
00700                     default:
00701                         WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_FBDEV, "-> this depends on backend=\"FBDEV\"");
00702                     }
00703                 }
00704                 else
00705                 if (this->graphics.backend == MMSFB_BE_OGL) {
00706                     switch (this->graphics.outputtype) {
00707                     case MMSFB_OT_X11:
00708                         // okay
00709                         break;
00710                     default:
00711                         WRONG_VALUE(parname, val, MMSFB_OT_VALID_VALUES_BE_OGL, "-> this depends on backend=\"OGL\"");
00712                     }
00713                 }
00714             }*/
00715             else if(!xmlStrcmp(parname, (const xmlChar *) "vrect.x")) {
00716                 this->graphics.vrect.x = strToInt(string((const char *)parvalue));
00717             }
00718             else if(!xmlStrcmp(parname, (const xmlChar *) "vrect.y")) {
00719                 this->graphics.vrect.y = strToInt(string((const char *)parvalue));
00720             }
00721             else if(!xmlStrcmp(parname, (const xmlChar *) "vrect.w")) {
00722                 this->graphics.vrect.w = strToInt(string((const char *)parvalue));
00723             }
00724             else if(!xmlStrcmp(parname, (const xmlChar *) "vrect.h")) {
00725                 this->graphics.vrect.h = strToInt(string((const char *)parvalue));
00726             }
00727             else if(!xmlStrcmp(parname, (const xmlChar *) "touchrect.x")) {
00728                 this->graphics.touchrect.x = strToInt(string((const char *)parvalue));
00729             }
00730             else if(!xmlStrcmp(parname, (const xmlChar *) "touchrect.y")) {
00731                 this->graphics.touchrect.y = strToInt(string((const char *)parvalue));
00732             }
00733             else if(!xmlStrcmp(parname, (const xmlChar *) "touchrect.w")) {
00734                 this->graphics.touchrect.w = strToInt(string((const char *)parvalue));
00735             }
00736             else if(!xmlStrcmp(parname, (const xmlChar *) "touchrect.h")) {
00737                 this->graphics.touchrect.h = strToInt(string((const char *)parvalue));
00738             }
00739             else if(!xmlStrcmp(parname, (const xmlChar *) "pointer")) {
00740                 string val = string((const char *)parvalue);
00741                 if ((this->graphics.pointer = getMMSFBPointerModeFromString(strToUpr(val))) == MMSFB_PM_NONE)
00742                     WRONG_VALUE(parname, val, MMSFB_PM_VALID_VALUES, "");
00743             }
00744             else if(!xmlStrcmp(parname, (const xmlChar *) "graphicswindowpixelformat")) {
00745                 string val = string((const char *)parvalue);
00746                 if ((this->graphics.graphicswindowpixelformat = getMMSFBPixelFormatFromString(strToUpr(val))) == MMSFB_PF_NONE) {
00747                     string val2 = strToUpr(val);
00748                     if ((val2 != "") && (val2 != "AUTODETECT") && (val2 != "AUTO"))
00749                         WRONG_VALUE(parname, val, MMSFB_PF_VALID_VALUES_WINDOWS, "");
00750                 }
00751             }
00752             else if(!xmlStrcmp(parname, (const xmlChar *) "graphicssurfacepixelformat")) {
00753                 string val = string((const char *)parvalue);
00754                 if ((this->graphics.graphicssurfacepixelformat = getMMSFBPixelFormatFromString(strToUpr(val))) == MMSFB_PF_NONE) {
00755                     string val2 = strToUpr(val);
00756                     if ((val2 != "") && (val2 != "AUTODETECT") && (val2 != "AUTO"))
00757                         WRONG_VALUE(parname, val, MMSFB_PF_VALID_VALUES_SURFACES, "");
00758                 }
00759             }
00760             else if(!xmlStrcmp(parname, (const xmlChar *) "extendedaccel"))
00761                 this->graphics.extendedaccel = strToBool(string((const char *)parvalue));
00762             else if(!xmlStrcmp(parname, (const xmlChar *) "allocmethod"))
00763                 this->graphics.allocmethod = strToUpr(string((const char *)parvalue));
00764             else if(!xmlStrcmp(parname, (const xmlChar *) "fullscreen")) {
00765                 string val = string((const char *)parvalue);
00766                 if ((this->graphics.fullscreen = getMMSFBFullScreenModeFromString(strToUpr(val))) == MMSFB_FSM_NONE)
00767                     WRONG_VALUE(parname, val, MMSFB_FSM_VALID_VALUES, "");
00768             } else if(!xmlStrcmp(parname, (const xmlChar *) "rotatescreen")) {
00769                 string val = string((const char *)parvalue);
00770                 this->graphics.rotatescreen = strToInt(val);
00771                 if (this->graphics.rotatescreen != 0 && this->graphics.rotatescreen != 180)
00772                     WRONG_VALUE(parname, val, "0, 180", "");
00773             } else if(!xmlStrcmp(parname, (const xmlChar *) "hideapplication")) {
00774                 this->graphics.hideapplication = strToBool(string((const char *)parvalue));
00775             } else if(!xmlStrcmp(parname, (const xmlChar *) "initialload")) {
00776                 this->graphics.initialload = strToBool(string((const char *)parvalue));
00777             } else if(!xmlStrcmp(parname, (const xmlChar *) "debugframes")) {
00778                 this->graphics.debugframes = strToBool(string((const char *)parvalue));
00779             } else if(!xmlStrcmp(parname, (const xmlChar *) "touchSwapX")) {
00780                 this->graphics.touchSwapX = strToBool(string((const char *)parvalue));
00781             } else if(!xmlStrcmp(parname, (const xmlChar *) "touchSwapY")) {
00782                 this->graphics.touchSwapY = strToBool(string((const char *)parvalue));
00783             } else if(!xmlStrcmp(parname, (const xmlChar *) "touchSwapXY")) {
00784                 this->graphics.touchSwapXY = strToBool(string((const char *)parvalue));
00785             }
00786             else
00787                 printf("RcParser: ignoring parameter '%s' in tag <graphics/>\n", parname);
00788         }
00789         else {
00790             if (mode == THROUGH_GRAPHICS_MODE_GRAPHICSLAYER) {
00791                 // through parameters which are used inside <graphicslayer/>
00792                 if(!xmlStrcmp(parname, (const xmlChar *) "id")) {
00793                     this->graphics.graphicslayer.id = atoi((const char *)parvalue);
00794                 }
00795                 else if(!xmlStrcmp(parname, (const xmlChar *) "pixelformat")) {
00796                     string val = string((const char *)parvalue);
00797                     if ((this->graphics.graphicslayer.pixelformat = getMMSFBPixelFormatFromString(strToUpr(val))) == MMSFB_PF_NONE)
00798                         WRONG_VALUE(parname, val, MMSFB_PF_VALID_VALUES_LAYER, "");
00799                 }
00800                 else if(!xmlStrcmp(parname, (const xmlChar *) "options")) {
00801                     this->graphics.graphicslayer.options = strToUpr(string((const char *)parvalue));
00802                 }
00803                 else if(!xmlStrcmp(parname, (const xmlChar *) "buffermode")) {
00804                     this->graphics.graphicslayer.buffermode = strToUpr(string((const char *)parvalue));
00805                 }
00806                 else {
00807                     printf("RcParser: ignoring parameter '%s' in tag <graphicslayer/>\n", parname);
00808                 }
00809             }
00810             else if (mode == THROUGH_GRAPHICS_MODE_VIDEOLAYER) {
00811                 // through parameters which are used inside <videolayer/>
00812                 if(!xmlStrcmp(parname, (const xmlChar *) "id")) {
00813                     this->graphics.videolayer.id = atoi((const char *)parvalue);
00814                 }
00815                 else if(!xmlStrcmp(parname, (const xmlChar *) "pixelformat")) {
00816                     string val = string((const char *)parvalue);
00817                     if ((this->graphics.videolayer.pixelformat = getMMSFBPixelFormatFromString(strToUpr(val))) == MMSFB_PF_NONE)
00818                         WRONG_VALUE(parname, val, MMSFB_PF_VALID_VALUES_LAYER, "");
00819                 }
00820                 else if(!xmlStrcmp(parname, (const xmlChar *) "options")) {
00821                     this->graphics.videolayer.options = strToUpr(string((const char *)parvalue));
00822                 }
00823                 else if(!xmlStrcmp(parname, (const xmlChar *) "buffermode")) {
00824                     this->graphics.videolayer.buffermode = strToUpr(string((const char *)parvalue));
00825                 }
00826                 else {
00827                     printf("RcParser: ignoring parameter '%s' in tag <videolayer/>\n", parname);
00828                 }
00829             }
00830             else {
00831                 printf("RcParser: ignoring parameter '%s' in tag <.../>\n", parname);
00832             }
00833         }
00834 
00835         xmlFree(parname);
00836         xmlFree(parvalue);
00837 
00838     }
00839 
00840     // special modes?
00841     if (mode != THROUGH_GRAPHICS_MODE_NORMAL)
00842         return;
00843 
00844     // doing final checks...................
00845     // layer ids set?
00846     if (this->graphics.videolayer.id < 0) {
00847         // video layer id not set!
00848         if (this->graphics.graphicslayer.id < 0) {
00849             // graphics layer id not set, using defaults
00850             this->graphics.videolayer = vl;
00851             this->graphics.graphicslayer = gl;
00852             printf("RcParser: video and graphics layer not correctly set, using defaults\n");
00853         }
00854         else {
00855             // using graphics layer settings also for video layer
00856             this->graphics.videolayer = this->graphics.graphicslayer;
00857             printf("RcParser: video layer not correctly set, using graphics layer settings for both\n");
00858         }
00859     }
00860     else {
00861         if (this->graphics.graphicslayer.id < 0) {
00862             // using video layer settings also for graphics layer
00863             this->graphics.graphicslayer = this->graphics.videolayer;
00864             printf("RcParser: graphics layer not correctly set, using video layer settings for both\n");
00865         }
00866         else {
00867             if (this->graphics.videolayer.id == this->graphics.graphicslayer.id) {
00868                 if   (this->graphics.videolayer.rect.w != this->graphics.graphicslayer.rect.w
00869                     ||this->graphics.videolayer.rect.h != this->graphics.graphicslayer.rect.h
00870                     ||this->graphics.videolayer.rect.x != this->graphics.graphicslayer.rect.x
00871                     ||this->graphics.videolayer.rect.y != this->graphics.graphicslayer.rect.y
00872                     ||this->graphics.videolayer.outputtype != this->graphics.graphicslayer.outputtype
00873                     ||this->graphics.videolayer.pixelformat != this->graphics.graphicslayer.pixelformat
00874                     ||this->graphics.videolayer.options != this->graphics.graphicslayer.options
00875                     ||this->graphics.videolayer.buffermode != this->graphics.graphicslayer.buffermode) {
00876                     // same layers, but different definitions!
00877                     this->graphics.videolayer = this->graphics.graphicslayer;
00878                     printf("RcParser: video and graphics layer are the same, but definitions are not consistent, using graphics layer settings for both\n");
00879                 }
00880             }
00881         }
00882     }
00883 
00884     // checking layer ids
00885     if (this->graphics.backend == MMSFB_BE_X11) {
00886         if (this->graphics.videolayer.id != 0 && this->graphics.videolayer.id != 1) {
00887             WRONG_VALUE("videolayer.id", iToStr(this->graphics.videolayer.id), "0, 1", "-> this depends on backend=\"X11\", outputtype=\"X11/XVSHM\"");
00888         }
00889         if ((this->graphics.videolayer.id == 1) && (this->graphics.videolayer.outputtype != MMSFB_OT_XVSHM)) {
00890             WRONG_VALUE("videolayer.outputtype", getMMSFBOutputTypeString(this->graphics.videolayer.outputtype), "XVSHM", "-> this depends on backend=\"X11\", videolayer.id=\"1\"");
00891         }
00892         if (this->graphics.graphicslayer.id != 0) {
00893             WRONG_VALUE("graphicslayer.id", iToStr(this->graphics.graphicslayer.id), "0", "-> this depends on backend=\"X11\", outputtype=\"X11/XSHM/XVSHM/OGL\"");
00894         }
00895 
00896 /*      switch (this->graphics.outputtype) {
00897         case MMSFB_OT_X11:
00898         case MMSFB_OT_XVSHM:
00899             if (this->graphics.videolayer.id != 0 && this->graphics.videolayer.id != 1)
00900                 WRONG_VALUE("videolayerid", iToStr(this->graphics.videolayer.id), "0, 1", "-> this depends on backend=\"X11\", outputtype=\"X11/XVSHM\"");
00901             if (this->graphics.graphicslayer.id != 0)
00902                 WRONG_VALUE("graphicslayerid", iToStr(this->graphics.graphicslayer.id), "0", "-> this depends on backend=\"X11\", outputtype=\"X11/XVSHM\"");
00903             break;
00904         case MMSFB_OT_XSHM:
00905             if (this->graphics.videolayer.id != 0 && this->graphics.videolayer.id != 1)
00906                 WRONG_VALUE("videolayerid", iToStr(this->graphics.videolayer.id), "0, 1", "-> this depends on backend=\"X11\", outputtype=\"XSHM\"");
00907             if (this->graphics.graphicslayer.id != 0)
00908                 WRONG_VALUE("graphicslayerid", iToStr(this->graphics.graphicslayer.id), "0", "-> this depends on backend=\"X11\", outputtype=\"XSHM\"");
00909             break;
00910         default:
00911             break;
00912         }*/
00913     }
00914     else
00915     if (this->graphics.backend == MMSFB_BE_FBDEV) {
00916         switch (this->graphics.graphicslayer.outputtype) {
00917         case MMSFB_OT_DAVINCIFB:
00918             if (this->graphics.videolayer.id != this->graphics.graphicslayer.id) {
00919                 if ((this->graphics.videolayer.id != 1)&&(this->graphics.videolayer.id != 2))
00920                     WRONG_VALUE("videolayerid", iToStr(this->graphics.videolayer.id), "1, 2", "-> this depends on backend=\"FBDEV\", outputtype=\"DAVINCIFB\"");
00921                 if (this->graphics.graphicslayer.id != 0)
00922                     WRONG_VALUE("graphicslayerid", iToStr(this->graphics.graphicslayer.id), "0", "-> this depends on backend=\"FBDEV\", outputtype=\"DAVINCIFB\"");
00923             }
00924             break;
00925 /*      case MMSFB_OT_OMAPFB:
00926             if (this->graphics.videolayer.id != this->graphics.graphicslayer.id) {
00927                 if (this->graphics.videolayer.id != 1)
00928                     WRONG_VALUE("videolayerid", iToStr(this->graphics.videolayer.id), "1", "-> this depends on backend=\"FBDEV\", outputtype=\"OMAPFB\"");
00929                 if ((this->graphics.graphicslayer.id != 0)&&(this->graphics.graphicslayer.id != 2))
00930                     WRONG_VALUE("graphicslayerid", iToStr(this->graphics.graphicslayer.id), "0, 2", "-> this depends on backend=\"FBDEV\", outputtype=\"OMAPFB\"");
00931             }
00932             break;*/
00933         default:
00934             break;
00935         }
00936     }
00937 
00938     // checking pixelformats
00939     if (this->graphics.backend == MMSFB_BE_X11) {
00940         switch (this->graphics.graphicslayer.outputtype) {
00941         case MMSFB_OT_X11:
00942         case MMSFB_OT_XVSHM:
00943         case MMSFB_OT_XSHM:
00944             if (this->graphics.graphicslayer.pixelformat != MMSFB_PF_YV12 && this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB32 && this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB24 && this->graphics.graphicslayer.pixelformat != MMSFB_PF_ARGB)
00945                 WRONG_VALUE("graphicslayer.pixelformat", getMMSFBPixelFormatString(this->graphics.graphicslayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_X11_OT_XSHM, "-> this depends on backend=\"X11\", outputtype=\"XSHM\"");
00946             break;
00947         case MMSFB_OT_OGL:
00948             if (this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB32 && this->graphics.graphicslayer.pixelformat != MMSFB_PF_ARGB
00949                      && this->graphics.graphicslayer.pixelformat != MMSFB_PF_ABGR)
00950                 WRONG_VALUE("graphicslayer.pixelformat", getMMSFBPixelFormatString(this->graphics.graphicslayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_FBDEV_OT_OGL, "-> this depends on backend=\"FBDEV\", outputtype=\"OGL\"");
00951             break;
00952         default:
00953             break;
00954         }
00955         if (this->graphics.graphicslayer.id != this->graphics.videolayer.id) {
00956             switch (this->graphics.videolayer.outputtype) {
00957             case MMSFB_OT_X11:
00958             case MMSFB_OT_XVSHM:
00959             case MMSFB_OT_XSHM:
00960                 if (this->graphics.videolayer.pixelformat != MMSFB_PF_YV12 && this->graphics.videolayer.pixelformat != MMSFB_PF_RGB32 && this->graphics.videolayer.pixelformat != MMSFB_PF_ARGB)
00961                     WRONG_VALUE("videolayer.pixelformat", getMMSFBPixelFormatString(this->graphics.videolayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_X11_OT_XVSHM, "-> this depends on backend=\"X11\", outputtype=\"X11/XVSHM\"");
00962                 break;
00963             default:
00964                 break;
00965             }
00966         }
00967     }
00968     else
00969     if (this->graphics.backend == MMSFB_BE_FBDEV) {
00970         switch (this->graphics.graphicslayer.outputtype) {
00971         case MMSFB_OT_DAVINCIFB:
00972             if (this->graphics.videolayer.pixelformat != MMSFB_PF_YUY2)
00973                 WRONG_VALUE("videolayer.pixelformat", getMMSFBPixelFormatString(this->graphics.videolayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_FBDEV_OT_DAVINCIFB_LAYER_1, "-> this depends on backend=\"FBDEV\", outputtype=\"DAVINCIFB\"");
00974             if   ((this->graphics.graphicslayer.pixelformat != MMSFB_PF_ARGB3565)
00975                 &&(this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB16))
00976                 WRONG_VALUE("graphicslayer.pixelformat", getMMSFBPixelFormatString(this->graphics.graphicslayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_FBDEV_OT_DAVINCIFB_LAYER_0, "-> this depends on backend=\"FBDEV\", outputtype=\"DAVINCIFB\"");
00977             break;
00978 /*      case MMSFB_OT_OMAPFB:
00979             if   ((this->graphics.videolayer.pixelformat != MMSFB_PF_YUY2)
00980                 &&(this->graphics.videolayer.pixelformat != MMSFB_PF_RGB32))
00981                 WRONG_VALUE("videolayerpixelformat", getMMSFBPixelFormatString(this->graphics.videolayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_FBDEV_OT_OMAPFB_LAYER_1, "-> this depends on backend=\"FBDEV\", outputtype=\"OMAPFB\"");
00982             if   ((this->graphics.graphicslayer.pixelformat != MMSFB_PF_ARGB)
00983                 &&(this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB32)
00984                 &&(this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB16))
00985                 WRONG_VALUE("graphicslayerpixelformat", getMMSFBPixelFormatString(this->graphics.graphicslayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_FBDEV_OT_OMAPFB_LAYER_0, "-> this depends on backend=\"FBDEV\", outputtype=\"OMAPFB\"");
00986             break;*/
00987 
00988         case MMSFB_OT_OGL:
00989             if (this->graphics.graphicslayer.pixelformat != MMSFB_PF_RGB32 && this->graphics.graphicslayer.pixelformat != MMSFB_PF_ARGB
00990                      && this->graphics.graphicslayer.pixelformat != MMSFB_PF_ABGR)
00991                 WRONG_VALUE("graphicslayer.pixelformat", getMMSFBPixelFormatString(this->graphics.graphicslayer.pixelformat), MMSFB_PF_VALID_VALUES_BE_FBDEV_OT_OGL, "-> this depends on backend=\"FBDEV\", outputtype=\"OGL\"");
00992             break;
00993 
00994         default:
00995             break;
00996         }
00997 
00998         if (this->graphics.graphicslayer.id != this->graphics.videolayer.id) {
00999             //TODO...
01000             switch (this->graphics.videolayer.outputtype) {
01001             default:
01002                 break;
01003             }
01004         }
01005     }
01006 
01007     if ((this->graphics.backend == MMSFB_BE_X11)||(this->graphics.backend == MMSFB_BE_FBDEV)) {
01008         // overwite values needed for this backends
01009         this->graphics.extendedaccel = true;
01010         this->graphics.allocmethod = "MALLOC";
01011 
01012         if (this->graphics.graphicslayer.outputtype == MMSFB_OT_OGL) {
01013             // overwite values needed for this outputtype
01014             this->graphics.extendedaccel = false;
01015             this->graphics.allocmethod = "OGL";
01016         }
01017     }
01018 }
01019 
01020 void MMSRcParser::throughFile(xmlNode* node) {
01021 
01022     xmlNode *cur_node = NULL;
01023 
01024     if(node==NULL)
01025         return;
01026 
01027     if(!xmlStrcmp(node->name, (const xmlChar *) "mmsrc") || !xmlStrcmp(node->name, (const xmlChar *) "diskorc")) {
01028         checkVersion(node);
01029 
01030         node = node->xmlChildrenNode;
01031     }
01032     else {
01033         this->throughFile(node->next);
01034         return;
01035     }
01036 
01037     for (cur_node = node; cur_node; cur_node = cur_node->next) {
01038 
01039         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "text")) continue;
01040         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "comment")) continue;
01041 
01042         if(!xmlStrcmp(cur_node->name, (const xmlChar *) "global")) {
01043             throughGlobal(cur_node);
01044         }
01045         else if(!xmlStrcmp(cur_node->name, (const xmlChar *) "dbsettings")) {
01046             throughDBSettings(cur_node);
01047         }
01048         else if((!xmlStrcmp(cur_node->name, (const xmlChar *) "dfbsettings"))
01049               ||(!xmlStrcmp(cur_node->name, (const xmlChar *) "graphics"))) {
01050             throughGraphics(cur_node);
01051         }
01052         else if(!xmlStrcmp(cur_node->name, (const xmlChar *) "language")) {
01053             throughLanguage(cur_node);
01054         }
01055         else {
01056             printf("RcParser: ignoring tag <%s/>\n", cur_node->name);
01057         }
01058     }
01059 }
01060 
01061 
01062 void MMSRcParser::updateConfigParms(MMSConfigData *config, char *ap) {
01063 // helpers
01064 #define MMSRC_CPP_GET_PARAMETER(str,len) if(memcmp(ap,str,len)==0){char *val=ap+len;while(*val&&*val==' ')val++;char *vb=valbuf;*vb=0;while(*val&&*val!=' '){*vb=*val;vb++;*vb=0;val++;}val=valbuf;
01065 #define MMSRC_CPP_PROCESS_PIXELFORMAT_PARAMETER(str,len,setter) MMSRC_CPP_GET_PARAMETER(str,len)MMSFBSurfacePixelFormat pf=getMMSFBPixelFormatFromString(strToUpr(val));if(pf!=MMSFB_PF_NONE)setter else printf("DISKO: Parameter --disko:%s must be a valid pixelformat!\n",str);}
01066 #define MMSRC_CPP_PROCESS_BOOL_PARAMETER(str,len,truecall,falsecall) MMSRC_CPP_GET_PARAMETER(str,len)if((!strcmp(val,"true"))||(!strcmp(val,"TRUE")))truecall else if((!strcmp(val,"false"))||(!strcmp(val,"FALSE")))falsecall else printf("DISKO: Parameter --disko:%s must be true or false!\n",str);}
01067 
01068 // available commandline parameters
01069 #define MMSRC_CCP_GRAPHICS_VIDEOLAYER_PIXELFORMAT_STR       "graphics.videolayer.pixelformat="
01070 #define MMSRC_CCP_GRAPHICS_VIDEOLAYER_PIXELFORMAT_LEN       32
01071 #define MMSRC_CCP_GRAPHICS_GRAPHICSLAYER_PIXELFORMAT_STR    "graphics.graphicslayer.pixelformat="
01072 #define MMSRC_CCP_GRAPHICS_GRAPHICSLAYER_PIXELFORMAT_LEN    35
01073 #define MMSRC_CCP_GRAPHICS_FULLSCREEN_STR                   "graphics.fullscreen="
01074 #define MMSRC_CCP_GRAPHICS_FULLSCREEN_LEN                   20
01075 #define MMSRC_CCP_GRAPHICS_HIDEAPPLICATION_STR              "graphics.hideapplication="
01076 #define MMSRC_CCP_GRAPHICS_HIDEAPPLICATION_LEN              25
01077 
01078     //  buffer for value
01079     char valbuf[256];
01080 
01081     // check all my parameters
01082     MMSRC_CPP_PROCESS_PIXELFORMAT_PARAMETER(MMSRC_CCP_GRAPHICS_VIDEOLAYER_PIXELFORMAT_STR, MMSRC_CCP_GRAPHICS_VIDEOLAYER_PIXELFORMAT_LEN,
01083                                             {MMSConfigDataLayer l=config->getVideoLayer();l.pixelformat=pf;config->setVideoLayer(l);})
01084     else
01085     MMSRC_CPP_PROCESS_PIXELFORMAT_PARAMETER(MMSRC_CCP_GRAPHICS_GRAPHICSLAYER_PIXELFORMAT_STR, MMSRC_CCP_GRAPHICS_GRAPHICSLAYER_PIXELFORMAT_LEN,
01086                                             {MMSConfigDataLayer l=config->getGraphicsLayer();l.pixelformat=pf;config->setGraphicsLayer(l);})
01087     else
01088     MMSRC_CPP_GET_PARAMETER(MMSRC_CCP_GRAPHICS_FULLSCREEN_STR, MMSRC_CCP_GRAPHICS_FULLSCREEN_LEN) {
01089         MMSFBFullScreenMode fsm = getMMSFBFullScreenModeFromString(strToUpr(val));
01090         if (fsm != MMSFB_FSM_NONE)
01091             config->setFullScreen(fsm);
01092         else
01093             printf("DISKO: Parameter --disko:%s must be a valid fullscreen mode (%s)!\n",
01094                     MMSRC_CCP_GRAPHICS_FULLSCREEN_STR, MMSFB_FSM_VALID_VALUES);
01095     }}
01096     else
01097     MMSRC_CPP_PROCESS_BOOL_PARAMETER(MMSRC_CCP_GRAPHICS_HIDEAPPLICATION_STR, MMSRC_CCP_GRAPHICS_HIDEAPPLICATION_LEN,
01098                                      {config->setHideApplication(true);},{config->setHideApplication(false);});
01099 }
01100 
01101 void MMSRcParser::updateConfig(MMSConfigData *config, string args, int argc, char *argv[]) {
01102 
01103     if (!config) return;
01104 
01105     // args...
01106     char *ap = (char*)args.c_str();
01107     while (*ap) {
01108         // find parameter
01109         if (!(ap = strstr(ap, "--disko:"))) break;
01110         ap+= 8;
01111 
01112         // update parameter
01113         updateConfigParms(config, ap);
01114 
01115         // go to next parameter
01116         if (!(ap = strstr(ap, " "))) break;
01117         ap++;
01118     }
01119 
01120     // argv...
01121     for (int i = 1; i < argc; i++) {
01122         // find parameter
01123         char *ap= argv[i];
01124         if (memcmp(ap, "--disko:", 8)) continue;
01125         ap+= 8;
01126 
01127         // update parameter
01128         updateConfigParms(config, ap);
01129     }
01130 }
01131 

Generated by doxygen