#include "pnd_desktop.h"
#include "pnd_logger.h"
#include "pnd_dbusnotify.h"
+#include "pnd_pndfiles.h"
// this piece of code was simpler once; but need to grow it a bit and in a rush
// moving all these to globals rather than refactor the code a bit; tsk tsk..
pnd_log ( pndn_debug, " Icon not already present, so trying to write it! %s\n", existingpath );
+ // handle same-path icon override for davec :)
+ char ovrfile [ PATH_MAX ];
+ char *fixpxml;
+ sprintf ( ovrfile, "%s/%s", d -> object_path, d -> object_filename );
+ fixpxml = strcasestr ( ovrfile, PND_PACKAGE_FILEEXT );
+ if ( fixpxml ) {
+ strcpy ( fixpxml, ".png" );
+ fixpxml = NULL;
+ struct stat statbuf;
+ if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ d -> icon = strdup ( ovrfile );
+ fixpxml = ovrfile; // !NULL will be the trigger to skip emittinf desktop from .pnd
+ } // stat
+ } // ovr?
+
// attempt to create icon files; if successful, alter the disco struct to contain new
// path, otherwise leave it alone (since it could be a generic icon reference..)
- if ( pnd_emit_icon ( emiticonpath, d ) ) {
- // success; fix up icon path to new one..
- if ( d -> icon ) {
- free ( d -> icon );
+ if ( fixpxml == NULL ) {
+ // don't have an same-path override icon, so go fetch something from pnd file
+
+ if ( pnd_emit_icon ( emiticonpath, d ) ) {
+ // success; fix up icon path to new one..
+ if ( d -> icon ) {
+ free ( d -> icon );
+ }
+ d -> icon = strdup ( existingpath );
+ } else {
+ pnd_log ( pndn_debug, " WARN: Couldn't write out icon %s\n", existingpath );
}
- d -> icon = strdup ( existingpath );
- } else {
- pnd_log ( pndn_debug, " WARN: Couldn't write out icon %s\n", existingpath );
- }
+
+ } // got ovr icon already?
} // icon already exists?
/* find_by_key() will attempt to locate a payload based on the specified key.
* Returns the payload pointer or NULL if not found.
+ * CASE INSENSITIVE.
*/
void *pnd_box_find_by_key ( pnd_box_handle box, char *key );
#define PXML_MAXAPPS 20 /* max number of <application>'s within a single PXML */
+// for DaveC, we will support same-path-as-.pnd file override, that is simple format and not XML
+#define PXML_SAMEPATH_OVERRIDE_FILEEXT ".ovr" /* ./foo/bar.pnd could have overrides in ./foo/bar.ovr */
+
// use this handle to interact with PXML; this hides the mechanics of parsing a PXML file so that
// it can be upgraded with impacting applications
typedef void* pnd_pxml_handle;
while ( n ) {
- if ( strcmp ( n -> key, key ) == 0 ) {
+ if ( strcasecmp ( n -> key, key ) == 0 ) {
return ( NODE2PAYLOAD(n) );
}
#include <stdio.h> /* for FILE etc */
#include <stdlib.h> /* for malloc */
#include <unistd.h> /* for unlink */
+#include <limits.h> /* for PATH_MAX */
+#include <sys/types.h>
+#include <sys/stat.h>
#define __USE_GNU /* for strcasestr */
#include <string.h> /* for making ftw.h happy */
#include "pnd_apps.h"
#include "pnd_pndfiles.h"
#include "pnd_logger.h"
+#include "pnd_conf.h"
// need these 'globals' due to the way nftw and ftw work :/
static pnd_box_handle disco_box;
return ( 0 ); // continue tree walk
}
+ // for ovr-file
+ char ovrfile [ PATH_MAX ];
+ pnd_box_handle ovrh = 0; // 0 didn't try, -1 tried and failed, >0 tried and got
+
// iterate across apps in the PXML
pxmlappiter = pxmlapps;
while ( 1 ) {
break; // all done
}
- // look for any overrides, if requested
- if ( disco_overrides ) {
- pnd_pxml_merge_override ( pxmlh, disco_overrides );
- }
-
// check for validity and add to resultset if it looks executable
if ( pnd_is_pxml_valid_app ( pxmlh ) ) {
pnd_disco_t *p;
p -> info_type = strdup ( pnd_pxml_get_info_type ( pxmlh ) );
}
+ // look for any PXML overrides, if requested
+ if ( disco_overrides ) {
+ pnd_pxml_merge_override ( pxmlh, disco_overrides );
+ }
+
+ // handle ovr overrides
+ // try to load a same-path-as-pnd override file
+ if ( ovrh == 0 ) {
+ sprintf ( ovrfile, "%s/%s", p -> object_path, p -> object_filename );
+ fixpxml = strcasestr ( ovrfile, PND_PACKAGE_FILEEXT );
+ if ( fixpxml ) {
+ strcpy ( fixpxml, PXML_SAMEPATH_OVERRIDE_FILEEXT );
+ struct stat statbuf;
+ if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ ovrh = pnd_conf_fetch_by_path ( ovrfile );
+
+ if ( ! ovrh ) {
+ // couldn't pull conf out of file, so don't try again
+ ovrh = (void*)(-1);
+ }
+
+ } else {
+ ovrh = (void*)(-1); // not found, don't try again
+ } // stat
+ } // can find .pnd
+ } // tried ovr yet?
+
+ // is ovr file open?
+ if ( ovrh != 0 && ovrh != (void*)(-1) ) {
+ // pull in appropriate values
+ char key [ 100 ];
+ char *v;
+
+ // title
+ snprintf ( key, 100, "Application-%u.title", p -> subapp_number );
+ pnd_log ( PND_LOG_DEFAULT, "find key %s\n", key );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ pnd_log ( PND_LOG_DEFAULT, " find key %s\n", key );
+ if ( p -> title_en ) {
+ free ( p -> title_en );
+ }
+ p -> title_en = strdup ( v );
+ }
+
+ // clockspeed
+ snprintf ( key, 100, "Application-%u.clockspeed", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> clockspeed ) {
+ free ( p -> clockspeed );
+ }
+ p -> clockspeed = strdup ( v );
+ }
+
+ // categories
+ snprintf ( key, 100, "Application-%u.maincategory", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> main_category ) {
+ free ( p -> main_category );
+ }
+ p -> main_category = strdup ( v );
+ }
+ snprintf ( key, 100, "Application-%u.maincategorysub1", p -> subapp_number );
+ if ( ( v = pnd_conf_get_as_char ( ovrh, key ) ) ) {
+ if ( p -> main_category1 ) {
+ free ( p -> main_category1 );
+ }
+ p -> main_category1 = strdup ( v );
+ }
+
+ } // got ovr conf loaded?
+
} else {
//printf ( "Invalid PXML; skipping.\n" );
}
} // while pxmlh is good
+ // free up ovr
+ if ( ovrh != 0 && ovrh != (void*)(-1) ) {
+ pnd_box_delete ( ovrh );
+ }
+
// free up the applist
free ( pxmlapps );
- libpnd: appdata-dir-name?
- About screen and shoutouts // konami code?
-- override
- - .desktop in same place as .pnd, override category
- - icon
- deploy..
- .desktop for deployment, for running from xfce
+#include <stdio.h> /* for FILE etc */
+#include <stdlib.h> /* for malloc */
+#include <unistd.h> /* for unlink */
+#include <limits.h> /* for PATH_MAX */
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define __USE_GNU /* for strcasestr */
+#include <string.h> /* for making ftw.h happy */
+
+#include <fcntl.h>
#include <limits.h>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_rotozoom.h"
+#define __USE_GNU /* for strcasestr */
+#include <unistd.h> /* for unlink */
+#include <string.h> /* for making ftw.h happy */
+
#include "pnd_pxml.h"
#include "pnd_utility.h"
#include "pnd_conf.h"
// not cached, load it up
//
-
- // pull icon into buffer
+ unsigned char *iconbuf = NULL;
unsigned int buflen = 0;
- unsigned char *iconbuf;
- iconbuf = pnd_emit_icon_to_buffer ( app, &buflen );
+
+ // same-path override?
+ char ovrfile [ PATH_MAX ];
+ char *fixpxml;
+ sprintf ( ovrfile, "%s/%s", app -> object_path, app -> object_filename );
+ fixpxml = strcasestr ( ovrfile, PND_PACKAGE_FILEEXT );
+ if ( fixpxml ) {
+ strcpy ( fixpxml, ".png" );
+ struct stat statbuf;
+ if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ buflen = statbuf.st_size;
+ if ( ( iconbuf = malloc ( statbuf.st_size ) ) ) {
+ int fd = open ( ovrfile, O_RDONLY );
+ if ( fd >= 0 ) {
+ if ( read ( fd, iconbuf, statbuf.st_size ) != statbuf.st_size ) {
+ free ( iconbuf );
+ close ( fd );
+ return ( 0 );
+ }
+ close ( fd );
+ } // open
+ } // malloc
+ } // stat
+ } // ovr?
+
+ // pull icon into buffer from .pnd
+ if ( ! iconbuf ) {
+ iconbuf = pnd_emit_icon_to_buffer ( app, &buflen );
+ }
if ( ! iconbuf ) {
return ( 0 );