Patch from Cloudef to add very basic support for 'package' PXML tags
authorskeezix <skeezix@flotsam-vm.(none)>
Tue, 24 May 2011 15:10:13 +0000 (11:10 -0400)
committerskeezix <skeezix@flotsam-vm.(none)>
Tue, 24 May 2011 15:10:13 +0000 (11:10 -0400)
include/pnd_discovery.h
include/pnd_pxml.h
include/pnd_pxml_names.h
lib/pnd_discovery.c
lib/pnd_pxml.c
lib/pnd_tinyxml.cpp

index d59c87e..237ef62 100644 (file)
@@ -57,6 +57,7 @@ typedef struct {
   unsigned char subapp_number; // # of app within PXML (ie: 0, 1, 2, 3, up to the number of apps within the PXML)
   unsigned int object_flags;   // see PND_DISCO_ bitmasks above
   // strdup'd from PXML -- hey, who was the idiot who thought it was a reat idea not to just re-use the pxml-struct?
+  char *package_id;
   char *title_en;
   char *desc_en;
   char *unique_id;
index bca88f4..15b3e96 100644 (file)
@@ -43,6 +43,8 @@ signed char pnd_pxml_merge_override ( pnd_pxml_handle h, char *searchpath );
 
 /* these accessor functions will return READ ONLY char*s; do not free them or modify them.
  */
+
+char *pnd_pxml_get_package_id ( pnd_pxml_handle h );
 char *pnd_pxml_get_app_name_en ( pnd_pxml_handle h );
 char *pnd_pxml_get_app_name_de ( pnd_pxml_handle h );
 char *pnd_pxml_get_app_name_it ( pnd_pxml_handle h );
@@ -162,6 +164,7 @@ typedef struct
        char *background;
        char *startdir;
        char *exec_no_x11;
+       char *package_id;
        char *package_name;
        char *package_release_date;
         char *mkdir_sp; // a colon separated list of paths to be mkdir'd (silently fail) when pnd is autodiscovered. path is always relative to the root of the hosting device.
index 24c2294..f3ae64c 100644 (file)
@@ -93,8 +93,9 @@ extern "C" {
 #define PND_PXML_ENAME_CLOCK "clockspeed"
 #define PND_PXML_ATTRNAME_CLOCKFREQ "frequency"
 
-/* <package name="foo" released="1/1/0001"/> */
+/* <package id="foo-package" name="foo" released="1/1/0001"/> */
 #define PND_PXML_ENAME_PACKAGE "package"
+#define PND_PXML_ATTRNAME_PACKAGE_ID "id"
 #define PND_PXML_ATTRNAME_PACKAGE_NAME "name"
 #define PND_PXML_ATTRNAME_PACKAGE_DATE "released"
 
index e1fc0ef..7d89475 100644 (file)
@@ -28,7 +28,7 @@ static pnd_box_handle disco_box;
 static char *disco_overrides = NULL;
 
 void pnd_disco_destroy ( pnd_disco_t *p ) {
-
+  if ( p -> package_id ) {     free ( p -> package_id);   }
   if ( p -> title_en ) {       free ( p -> title_en );    }
   if ( p -> unique_id ) {      free ( p -> unique_id );   }
   if ( p -> appdata_dirname ) { free ( p -> appdata_dirname );   }
@@ -224,6 +224,9 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb,
       p -> object_type = valid;
 
       // PXML fields
+      if ( pnd_pxml_get_package_id ( pxmlh ) ) {
+       p -> package_id = strdup ( pnd_pxml_get_package_id ( pxmlh ) );
+      }
       if ( pnd_pxml_get_app_name_en ( pxmlh ) ) {
        p -> title_en = strdup ( pnd_pxml_get_app_name_en ( pxmlh ) );
       }
index a6516ab..4b743d4 100644 (file)
@@ -315,6 +315,11 @@ char *pnd_pxml_get_best_localized_string(pnd_localized_string_t strings[], int s
   return ( NULL );
 }
 
+char *pnd_pxml_get_package_id ( pnd_pxml_handle h ) {
+  pnd_pxml_t *p = (pnd_pxml_t*) h;
+  return ( p -> package_id );
+}
+
 char *pnd_pxml_get_app_name ( pnd_pxml_handle h, char *iso_lang ) {
   pnd_pxml_t *p = (pnd_pxml_t *) h;
   return pnd_pxml_get_best_localized_string(p->titles, p->titles_c, iso_lang);
@@ -335,7 +340,6 @@ char *pnd_pxml_get_app_name_it ( pnd_pxml_handle h ) {
 char *pnd_pxml_get_app_name_fr ( pnd_pxml_handle h ) {
   return pnd_pxml_get_app_name(h, "fr");
 }
-
 char *pnd_pxml_get_unique_id ( pnd_pxml_handle h ) {
   pnd_pxml_t *p = (pnd_pxml_t*) h;
   return ( p -> unique_id );
index 8e8319f..1d64af2 100644 (file)
@@ -221,6 +221,15 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
   // 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;
+  pElem = hRoot.FirstChild ( PND_PXML_ENAME_PACKAGE ).Element();
+  if ( pElem ) {
+       package_id = pnd_pxml_get_attribute ( pElem, PND_PXML_ATTRNAME_PACKAGE_ID );
+  }
+
+  // move to applications element then
   if ( hRoot.FirstChild(PND_PXML_APP).Element() != NULL ) {
     appwrappermode = 1;
     appElem = hRoot.FirstChild(PND_PXML_APP).Element();
@@ -243,6 +252,9 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int
     } else {
       app -> subapp_number = 0;
     }
+    
+    // give application the package id, if there is one
+    app -> package_id = package_id;
 
     //Get unique ID first.
     if ( appwrappermode ) {