From: skeezix Date: Fri, 2 Jul 2010 01:37:42 +0000 (-0400) Subject: Doc-link was using unique-id instead of appdata-dir when present; also referencing... X-Git-Tag: sz_beta3~146^2~1 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89ebc08031a4d11edd92f58d8e3d095613700648;p=pandora-libraries.git Doc-link was using unique-id instead of appdata-dir when present; also referencing bug bugs.openpandora.org/index.php?do=details&task_id=112 --- diff --git a/include/pnd_apps.h b/include/pnd_apps.h index 80b5aaf..3ad4fc9 100644 --- a/include/pnd_apps.h +++ b/include/pnd_apps.h @@ -64,7 +64,8 @@ extern "C" { #define PND_EXEC_OPTION_NOUNION 2 /* request pnd_run not use a union, just do the mount/run */ #define PND_EXEC_OPTION_NOX11 4 /* request pnd_run to kill x11 and restart it after */ #define PND_EXEC_OPTION_NORUN 8 /* don't try to run; just form the pnd_run.sh line and cache it */ -#define PND_EXEC_OPTION_FUTURE2 16 +#define PND_EXEC_OPTION_INFO 16 /* for apps_exec_disco() only; implies that 'reserved' points to pnd_apps_exec_info_t struct */ +#define PND_EXEC_OPTION_FUTURE2 32 unsigned char pnd_apps_exec ( char *pndrun, char *fullpath, char *unique_id, char *rel_exec, char *rel_startdir, @@ -80,6 +81,12 @@ char *pnd_apps_exec_runline ( void ); // returns the cached pnd_run.sh line from // - 'pndrun' is a reference to a pnd_run.sh script, to avoid seeking it out every time unsigned char pnd_apps_exec_disco ( char *pndrun, pnd_disco_t *app, unsigned int options, void *reserved ); +// for pnd_apps_exec_disco(), when option PND_EXEC_OPTION_INFO is used +typedef struct { + char *viewer; // required; viewer's executable + char *args; // optional; arg to viewer; ie: the file to view +} pnd_apps_exec_info_t; + // should you wish to know where an app will get mounted, call this function to obtain a guess. The // logic is wrapped up in pnd_run.sh, but in theory should be easily determined. diff --git a/lib/pnd_apps.c b/lib/pnd_apps.c index fd5d566..e90ea61 100644 --- a/lib/pnd_apps.c +++ b/lib/pnd_apps.c @@ -52,14 +52,25 @@ unsigned char pnd_apps_exec_disco ( char *pndrun, pnd_disco_t *app, argv [ f++ ] = "-p"; argv [ f++ ] = fullpath; argv [ f++ ] = "-e"; - argv [ f++ ] = app -> exec; + if ( options & PND_EXEC_OPTION_INFO ) { + argv [ f++ ] = ((pnd_apps_exec_info_t*)reserved) -> viewer; + } else { + argv [ f++ ] = app -> exec; + } if ( app -> startdir ) { argv [ f++ ] = "-s"; argv [ f++ ] = app -> startdir; } - if ( app -> execargs ) { - argv [ f++ ] = "-a"; - argv [ f++ ] = app -> execargs; + if ( options & PND_EXEC_OPTION_INFO ) { + if ( ((pnd_apps_exec_info_t*)reserved) -> args ) { + argv [ f++ ] = "-a"; + argv [ f++ ] = ((pnd_apps_exec_info_t*)reserved) -> args; + } + } else { + if ( app -> execargs ) { + argv [ f++ ] = "-a"; + argv [ f++ ] = app -> execargs; + } } if ( app -> appdata_dirname ) { argv [ f++ ] = "-b"; @@ -117,10 +128,27 @@ unsigned char pnd_apps_exec_disco ( char *pndrun, pnd_disco_t *app, if ( quotenext ) { quotenext = 0; } else { + // deprecated; need to handle spaces in some additional args + // if ( strcmp ( argv [ i ], "-a" ) == 0 ) { // if this is for -a, we need to wrap with quotes - if ( strcmp ( argv [ i ], "-a" ) == 0 ) { + // ivanovic: + // to allow spaces in filenames we have to add quotes around most terms! + // terms with quotes: + // -a additional arguments + // -p fullpath to pnd + // -e name of execuatable inside the pnd + // -s startdir + // -b name for the appdir + + if ( ( strcmp ( argv [ i ], "-a" ) == 0 ) || + ( strcmp ( argv [ i ], "-p" ) == 0 ) || + ( strcmp ( argv [ i ], "-e" ) == 0 ) || + ( strcmp ( argv [ i ], "-s" ) == 0 ) || + ( strcmp ( argv [ i ], "-b" ) == 0 ) ) + { quotenext = 1; } + } } // for diff --git a/lib/pnd_desktop.c b/lib/pnd_desktop.c index 3ef81a0..3abf62d 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -103,11 +103,11 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t // basics if ( p -> object_type == pnd_object_type_directory ) { - snprintf ( buffer, 1020, "Exec=%s%s -p %s -e %s -b %s", + snprintf ( buffer, 1020, "Exec=%s%s -p \"%s\" -e \"%s\" -b \"%s\"", nohup, pndrun, p -> object_path, p -> exec, p -> appdata_dirname ? p -> appdata_dirname : p -> unique_id ); } else if ( p -> object_type == pnd_object_type_pnd ) { - snprintf ( buffer, 1020, "Exec=%s%s -p %s/%s -e %s -b %s", + snprintf ( buffer, 1020, "Exec=%s%s -p \"%s/%s\" -e \"%s\" -b \"%s\"", nohup, pndrun, p -> object_path, p -> object_filename, p -> exec, p -> appdata_dirname ? p -> appdata_dirname : p -> unique_id ); } @@ -303,6 +303,8 @@ unsigned char pnd_emit_dotinfo ( char *targetpath, char *pndrun, pnd_disco_t *p pnd_conf_get_as_char ( desktoph, "info.viewer_args" ), p -> info_filename ); } else { pargs = NULL; + // WARNING: This might not be quite right; if no viewer-args, shouldn't we still append the info-filename? likewise, + // even if we do have view-args, shouldn't we check if filename is present? } char pndfile [ 1024 ]; @@ -314,9 +316,11 @@ unsigned char pnd_emit_dotinfo ( char *targetpath, char *pndrun, pnd_disco_t *p snprintf ( pndfile, 1020, "%s/%s", p -> object_path, p -> object_filename ); } - if ( ! pnd_apps_exec ( pndrun, pndfile, p -> unique_id, viewer, p -> startdir, pargs, - p -> clockspeed ? atoi ( p -> clockspeed ) : 0, PND_EXEC_OPTION_NORUN ) ) - { + pnd_apps_exec_info_t info; + info.viewer = viewer; + info.args = pargs; + + if ( ! pnd_apps_exec_disco ( pndrun, p, PND_EXEC_OPTION_NORUN | PND_EXEC_OPTION_INFO, &info ) ) { return ( 0 ); }