+ } // new form or old form?
+
+ return ( 1 );
+}
+
+unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int length, pnd_pxml_t **apps ) {
+
+ //Load the XML document
+ TiXmlDocument doc;
+ doc.Parse(buffer);
+
+ unsigned char appwrappermode = 0; // >=1 -> using <application>...</application> wrapper
+ unsigned char appcount = 0;
+ pnd_pxml_t *app = NULL;
+
+ TiXmlElement *pElem = NULL;
+ TiXmlElement *appElem = NULL;
+
+ //Find the root element
+ TiXmlHandle hDoc(&doc);
+ TiXmlHandle hRoot(0);
+
+ pElem = hDoc.FirstChild("PXML").Element();
+ if (!pElem) return (0);
+
+ // new Strategy; really, we want multiple app support within a PXML, without the lameness of
+ // multiple <PXML>..</PXML> within a single PXML.xml file. As such, we should have an app within
+ // an <application>..</application> wrapper level, with the ID on that. Further, the icon and
+ // .desktop filenames can have a # appended which is the application-count-# within the PXML,
+ // so that they can have their own .desktop and icon without collisions, but still use the
+ // same unique-id if they want to.
+ // To avoid breaking existing PXML's (even though we're pre-launch), can detect if ID
+ // is present in PXML line or not; if not, assume application mode?
+ hRoot = TiXmlHandle(pElem);
+
+ // workaround for package ID's used by some package managers
+ // get the package ID and store it for each application
+ char* package_id = NULL;
+ char* package_version_major = NULL;
+ char* package_version_minor = NULL;
+ char* package_version_release = NULL;
+ char* package_version_build = NULL;
+ pElem = hRoot.FirstChild ( PND_PXML_ENAME_PACKAGE ).Element();
+ if ( pElem ) {
+ package_id = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_PACKAGE_ID );
+ TiXmlHandle pRoot = TiXmlHandle( pElem );
+ if ( (pElem = pRoot.FirstChild(PND_PXML_ENAME_VERSION).Element()) )
+ {
+ package_version_major = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_VERMAJOR);
+ package_version_minor = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_VERMINOR);
+ package_version_release = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_VERREL);
+ package_version_build = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_VERBUILD);
+ }
+ }
+
+ // move to applications element then
+ if ( hRoot.FirstChild(PND_PXML_APP).Element() != NULL ) {
+ appwrappermode = 1;
+ appElem = hRoot.FirstChild(PND_PXML_APP).Element();
+ hRoot = TiXmlHandle ( appElem );
+ }
+
+ // until we run out of applications in the PXML..
+ while ( 1 ) {
+
+ //pnd_log ( PND_LOG_DEFAULT, (char*)" App #%u inside of PXML %s\n", appcount, pFilename );
+
+ // create the buffer to hold the pxml
+ apps [ appcount ] = (pnd_pxml_t*) malloc ( sizeof(pnd_pxml_t) );
+ memset ( apps [ appcount ], '\0', sizeof(pnd_pxml_t) );
+
+ // due to old code, just make life easier a minute..
+ app = apps [ appcount ];
+ if ( appwrappermode ) {
+ app -> subapp_number = appcount;
+ } else {
+ app -> subapp_number = 0;
+ }
+
+ // give application the package id, if there is one
+ if( package_id )
+ app -> package_id = strdup(package_id);
+ if( package_version_major )
+ app -> package_version_major = strdup(package_version_major);
+ if( package_version_minor )
+ app -> package_version_minor = strdup(package_version_minor);
+ if( package_version_release )
+ app -> package_version_release = strdup(package_version_release);
+ if( package_version_build )
+ app -> package_version_build = strdup(package_version_build);
+
+ //Get unique ID first.
+ if ( appwrappermode ) {
+ app->unique_id = pnd_pxml_get_attribute(appElem, PND_PXML_ATTRNAME_UID);
+ //pnd_log ( PND_LOG_DEFAULT, (char*)" Subapp #%u has unique_id %s\n", appcount, app -> unique_id );
+ app->appdata_dirname = pnd_pxml_get_attribute(appElem, PND_PXML_ATTRNAME_APPDATANAME);
+ } else {
+ app->unique_id = pnd_pxml_get_attribute(hRoot.Element(), PND_PXML_ATTRNAME_UID);
+ //pnd_log ( PND_LOG_DEFAULT, (char*)" Only-app #%u has unique_id %s\n", appcount, app -> unique_id );
+ }
+
+ //Everything related to the title:
+ pnd_pxml_parse_titles(hRoot, app);
+
+ //Everything description-related:
+ pnd_pxml_parse_descriptions(hRoot, app);
+
+ //Everything launcher-related in one tag:
+ if ( (pElem = hRoot.FirstChild(PND_PXML_ENAME_EXEC).Element()) )
+ {
+ app->background = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECBG); //if this returns NULL, the struct is filled with NULL. No need to check.
+ app->standalone = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECSTAL);
+ app->exec = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECCMD);
+ app->startdir = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECWD);
+ app->exec_no_x11 = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECNOX11);
+ app->execargs = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_EXECARGS);
+ app->exec_dashdash_args = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_DASHDASH);
+ }
+
+ //The app icon:
+ if ( (pElem = hRoot.FirstChild(PND_PXML_ENAME_ICON).Element()) ) {
+ app->icon = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ICONSRC);
+ }
+
+ // <info>
+ if ( (pElem = hRoot.FirstChild(PND_PXML_ENAME_INFO).Element()) )
+ {
+ app-> info_name = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_INFONAME );
+ app-> info_filename = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_INFOSRC );
+ app-> info_type = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_INFOTYPE );
+ }
+
+ //The preview pics:
+ if ( (pElem = hRoot.FirstChild(PND_PXML_NODENAME_PREVPICS).Element()) )
+ {
+ //TODO: Change this if pnd_pxml_t gains the feature of more pics than 2.
+ if ( (pElem = pElem->FirstChildElement(PND_PXML_ENAME_PREVPIC)) )
+ {
+ app->previewpic1 = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_PREVPICSRC);
+
+ if ( (pElem = pElem->NextSiblingElement(PND_PXML_ENAME_PREVPIC)) )