Allow parse_dotdesktop() to mark libpnd origin or not, and convenience filter to...
authorskeezix <skeezix@fw.skeleton.org>
Thu, 3 Nov 2011 01:39:57 +0000 (21:39 -0400)
committerskeezix <skeezix@fw.skeleton.org>
Thu, 3 Nov 2011 01:39:57 +0000 (21:39 -0400)
include/pnd_desktop.h
lib/pnd_desktop.c
test/discotest.c

index 94bc2eb..5c53812 100644 (file)
@@ -14,7 +14,9 @@ extern "C" {
 #define PND_DOTDESKTOP_HEADER "[Desktop Entry]"
 #define PND_DOTDESKTOP_SOURCE "X-Pandora-Source=libpnd"
 unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p );
 #define PND_DOTDESKTOP_HEADER "[Desktop Entry]"
 #define PND_DOTDESKTOP_SOURCE "X-Pandora-Source=libpnd"
 unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p );
-pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath );
+
+#define PND_DOTDESKTOP_LIBPND_ONLY 1 /* convenience flag; caller can do this himself as well */
+pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath, unsigned int flags ); // sets object_flag CUSTOM1 for non-libpnd-origin
 
 // emit_dotinfo() will spit out a .desktop 'info entry', similar to the way emit_dotdesktop does its thing
 // - rather than slide this into emit_dotdesktop(), we wish to allow apps to do this or not by calling this
 
 // emit_dotinfo() will spit out a .desktop 'info entry', similar to the way emit_dotdesktop does its thing
 // - rather than slide this into emit_dotdesktop(), we wish to allow apps to do this or not by calling this
index 2d20809..dc7aa63 100644 (file)
@@ -729,7 +729,7 @@ unsigned char *pnd_emit_icon_to_buffer ( pnd_disco_t *p, unsigned int *r_buflen
 // parse_dotdesktop() can be used to read a libpnd generated .desktop and return a limited
 // but useful disco-t structure back; possibly useful for scanning .desktops rather than
 // scanning pnd-files?
 // parse_dotdesktop() can be used to read a libpnd generated .desktop and return a limited
 // but useful disco-t structure back; possibly useful for scanning .desktops rather than
 // scanning pnd-files?
-pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath ) {
+pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath, unsigned int flags ) {
 
   // will verify the .desktop has the libpnd-marking on it (X-Pandora-Source): PND_DOTDESKTOP_SOURCE
 
 
   // will verify the .desktop has the libpnd-marking on it (X-Pandora-Source): PND_DOTDESKTOP_SOURCE
 
@@ -832,9 +832,15 @@ pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath ) {
 
   // filter
   if ( ! libpnd_origin ) {
 
   // filter
   if ( ! libpnd_origin ) {
-    pnd_disco_destroy ( p );
-    free ( p );
-    return ( NULL );
+    p -> object_flags |= PND_DISCO_CUSTOM1; // so caller can do something if it wishes
+
+    // convenience flag
+    if ( flags & PND_DOTDESKTOP_LIBPND_ONLY ) {
+      pnd_disco_destroy ( p );
+      free ( p );
+      return ( NULL );
+    }
+
   }
 
   // additional
   }
 
   // additional
index 8745706..985968c 100644 (file)
@@ -115,7 +115,7 @@ int main ( int argc, char *argv[] ) {
   pnd_box_handle applist;
 
   if ( dotdesktoppath [ 0 ] ) {
   pnd_box_handle applist;
 
   if ( dotdesktoppath [ 0 ] ) {
-    pnd_disco_t *p = pnd_parse_dotdesktop ( dotdesktoppath );
+    pnd_disco_t *p = pnd_parse_dotdesktop ( dotdesktoppath, PND_DOTDESKTOP_LIBPND_ONLY );
     pnd_box_handle disco_box = pnd_box_new ( "discovery" );
     if ( p ) {
       pnd_disco_t *ai = pnd_box_allocinsert ( disco_box, dotdesktoppath, sizeof(pnd_disco_t) );
     pnd_box_handle disco_box = pnd_box_new ( "discovery" );
     if ( p ) {
       pnd_disco_t *ai = pnd_box_allocinsert ( disco_box, dotdesktoppath, sizeof(pnd_disco_t) );