From a677d5c0db43949d38bd48c3418b90e70bed2461 Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 10 Jul 2013 15:58:19 -0400 Subject: [PATCH] Thanks! Both of these are essentially patches from j-r; the tracker urls are.. http://bugs.openpandora.org/index.php?do=details&task_id=321&action=takeownership&ids=321# http://bugs.openpandora.org/index.php?do=details&task_id=322 --- lib/pnd_desktop.c | 6 ++++-- lib/pnd_discovery.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lib/pnd_desktop.c b/lib/pnd_desktop.c index 3977f19..4bb8130 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -532,8 +532,10 @@ int pnd_map_dotdesktop_categories ( pnd_conf_handle c, char *target_buffer, unsi #define MAPCAT(field) \ if ( ( t = d -> field ) ) { \ match = pnd_map_dotdesktop_category ( c, t ); \ - strncat ( target_buffer, match ? match : t, len ); \ - strncat ( target_buffer, ";", len ); \ + if ( ( !match ) || ( strcasecmp ( match, "NoCategory" ) ) ) { \ + strncat ( target_buffer, match ? match : t, len ); \ + strncat ( target_buffer, ";", len ); \ + } \ } MAPCAT(main_category); diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index 2fd1882..76f2868 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -420,6 +420,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( p -> main_category ) { free ( p -> main_category ); } + // the override file cannot suppress the main category p -> main_category = strdup ( v ); } snprintf ( key, 100, "Application-%u.maincategorysub1", p -> subapp_number ); @@ -432,6 +433,48 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, p -> main_category1 = strdup ( v ); } } + snprintf ( key, 100, "Application-%u.maincategorysub2", p -> subapp_number ); + if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) { + if ( p -> main_category2 ) { + free ( p -> main_category2 ); + p -> main_category2 = NULL; + } + if ( strcasecmp ( v, "NoSubcategory" ) != 0 ) { + p -> main_category2 = strdup ( v ); + } + } + // alt categories + snprintf ( key, 100, "Application-%u.altcategory", p -> subapp_number ); + if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) { + if ( p -> alt_category ) { + free ( p -> alt_category ); + p -> alt_category = NULL; + } + // but it makes sense to allow full suppression of the alternate category + if ( strcasecmp ( v, "NoCategory" ) != 0 ) { + p -> alt_category = strdup ( v ); + } + } + snprintf ( key, 100, "Application-%u.altcategorysub1", p -> subapp_number ); + if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) { + if ( p -> alt_category1 ) { + free ( p -> alt_category1 ); + p -> alt_category1 = NULL; + } + if ( strcasecmp ( v, "NoSubcategory" ) != 0 ) { + p -> alt_category1 = strdup ( v ); + } + } + snprintf ( key, 100, "Application-%u.altcategorysub2", p -> subapp_number ); + if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) { + if ( p -> alt_category2 ) { + free ( p -> alt_category2 ); + p -> alt_category2 = NULL; + } + if ( strcasecmp ( v, "NoSubcategory" ) != 0 ) { + p -> alt_category2 = strdup ( v ); + } + } } // got ovr conf loaded? -- 2.39.5