mmenu; when an ovr file is found for an app, override categories are used even if...
authorskeezix <skeezix@flotsam-vm.(none)>
Mon, 7 Feb 2011 20:28:16 +0000 (15:28 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Mon, 7 Feb 2011 20:28:16 +0000 (15:28 -0500)
include/pnd_discovery.h
minimenu/mmcat.c
minimenu/mmenu.c

index f5dae7a..d59c87e 100644 (file)
@@ -44,8 +44,10 @@ typedef enum {
 // fetch the full PXML and get all the details. But I think we got out of control here :)
 // NOTE: We really need to rework disco-t so it can include non-english titles/desc; perhaps more info as optional,
 //   or a name/value pairing system so it can have extra data in it, without a complex structure.
-#define PND_DISCO_FLAG_OVR 1   // An ovr file was found for this app (not per subapp, just per .pnd)
-#define PND_DISCO_GENERATED 2  // This disco is 'faux', made up and not reflecting a real 'pnd file'
+#define PND_DISCO_FLAG_OVR 1       // An ovr file was found for this app (not per subapp, just per .pnd)
+#define PND_DISCO_GENERATED 2      // This disco is 'faux', made up and not reflecting a real 'pnd file'
+#define PND_DISCO_CUSTOM1 (1<<30)  // An app may make use of this bitflag safely
+#define PND_DISCO_CUSTOM2 (1<<31)  // An app may make use of this bitflag safely
 typedef struct {
   // base
   unsigned char object_type;   // see enum above
@@ -53,7 +55,7 @@ typedef struct {
   char *object_filename;       // filename within object_path of the app: the PXML.xml or awesomeapp.pnd file itself
   unsigned int pnd_icon_pos;   // offset to the byte after end of PXML in a pnd file (should be icon if present)
   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;
+  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 *title_en;
   char *desc_en;
index 8d460fa..c4a0533 100644 (file)
@@ -335,6 +335,11 @@ unsigned char category_meta_push ( char *catname, char *parentcatname, pnd_disco
     goto category_done_audit;
   }
 
+  // check if category came from an ovr-file; if so, we implicitly trust it instead of enforcing rules
+  if ( app -> object_flags & ( PND_DISCO_CUSTOM1 | PND_DISCO_CUSTOM1 ) ) {
+    goto category_done_audit;
+  }
+
   // category cleansing; lets..
   // - ensure we only let good freedesktop categories through
   // - we fix case.. no more UtIliTy (a good cat, studlycaps)
index 3dd91e4..f8ba263 100644 (file)
@@ -617,6 +617,25 @@ void applications_scan ( void ) {
       }
 #endif
 
+      if ( ovrh ) {
+       // lets also check to see if this ovr is specifying category overrides; if so, we can trust those
+       // more than categories specified by pnd-packager.
+       char ovrkey [ 41 ];
+
+       snprintf ( ovrkey, 40, "Application-%u.maincategory", iter -> subapp_number );
+       if ( pnd_conf_get_as_char ( ovrh, ovrkey ) ) {
+         iter -> object_flags |= PND_DISCO_CUSTOM1;
+         //printf ( "App '%s' has main cat ovr %s\n", iter -> title_en, pnd_conf_get_as_char ( ovrh, ovrkey ) );
+       }
+
+       snprintf ( ovrkey, 40, "Application-%u.maincategorysub1", iter -> subapp_number );
+       if ( pnd_conf_get_as_char ( ovrh, ovrkey ) ) {
+         iter -> object_flags |= PND_DISCO_CUSTOM2;
+         //printf ( "App '%s' has sub cat ovr %s\n", iter -> title_en, pnd_conf_get_as_char ( ovrh, ovrkey ) );
+       }
+
+      } // got ovr loaded/
+
     } // ovr
 
     // cache the icon, unless deferred