From 38d0da186bbf6c0fd0ac1375d9b1f5f07a15ef62 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 2 Nov 2011 21:39:57 -0400 Subject: [PATCH] Allow parse_dotdesktop() to mark libpnd origin or not, and convenience filter to ditch non-libpnd ones --- include/pnd_desktop.h | 4 +++- lib/pnd_desktop.c | 14 ++++++++++---- test/discotest.c | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/pnd_desktop.h b/include/pnd_desktop.h index 94bc2eb..5c53812 100644 --- a/include/pnd_desktop.h +++ b/include/pnd_desktop.h @@ -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 ); -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 diff --git a/lib/pnd_desktop.c b/lib/pnd_desktop.c index 2d20809..dc7aa63 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -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? -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 @@ -832,9 +832,15 @@ pnd_disco_t *pnd_parse_dotdesktop ( char *ddpath ) { // 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 diff --git a/test/discotest.c b/test/discotest.c index 8745706..985968c 100644 --- a/test/discotest.c +++ b/test/discotest.c @@ -115,7 +115,7 @@ int main ( int argc, char *argv[] ) { 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) ); -- 2.39.2