unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t *p ) {
char filename [ FILENAME_MAX ];
- char buffer [ 1024 ];
+ char buffer [ 4096 ];
FILE *f;
// specification
if ( p -> alt_category2 ) {
fprintf ( f, "X-Pandora-AltCategory2=%s\n", p -> alt_category2 );
}
+ if ( p -> info_filename ) {
+ fprintf ( f, "X-Pandora-Info-Filename=%s\n", p -> info_filename );
+ }
+ if ( p -> info_name ) {
+ fprintf ( f, "X-Pandora-Info-Name=%s\n", p -> info_name );
+ }
#if 0 // we let pnd_run.sh command line handle this instead of in .desktop
if ( p -> startdir ) {
}
#endif
+ // association requests
+ if ( p -> associationitem1_filetype ) {
+ fprintf ( f, "MimeType=%s\n", p -> associationitem1_filetype );
+ }
+
if ( p -> exec ) {
char *nohup;
strncat ( buffer, p -> startdir, 1020 );
}
- // args
+ // args (regular args, for pnd_run.sh to handle)
if ( p -> execargs ) {
char argbuf [ 1024 ];
snprintf ( argbuf, 1000, " -a \"%s\"", p -> execargs );
strncat ( buffer, " -x ", 1020 );
}
+ // args (dashdash -- args, that the shell can screw with before pnd_run.sh gets them)
+ if ( p -> exec_dashdash_args ) {
+ char argbuf [ 4096 ];
+ snprintf ( argbuf, 4096, " -- %s", p -> exec_dashdash_args );
+ strncat ( buffer, argbuf, 4096 );
+ }
+
// newline
strncat ( buffer, "\n", 1020 );
// emit
fprintf ( f, "%s", buffer );
+
+ // and lets copy in some stuff in case it makes .desktop consumers life easier
+ if ( p -> exec ) { fprintf ( f, "X-Pandora-Exec=%s\n", p -> exec ); }
+ if ( p -> appdata_dirname ) { fprintf ( f, "X-Pandora-Appdata-Dirname=%s\n", p -> appdata_dirname ); }
+ if ( p -> execargs ) { fprintf ( f, "X-Pandora-ExecArgs=%s\n", p -> execargs ); }
+ if ( p -> object_flags & PND_DISCO_FLAG_OVR ) { fprintf ( f, "X-Pandora-Object-Flag-OVR=%s\n", "Yes" ); }
+ if ( p -> object_type == pnd_object_type_pnd ) {
+ fprintf ( f, "X-Pandora-Object-Path=%s\n", p -> object_path );
+ fprintf ( f, "X-Pandora-Object-Filename=%s\n", p -> object_filename );
+ }
+
}
// categories
}
if ( strstr ( ddpath, ".desktop" ) == NULL ) {
- return ( NULL );
+ return ( NULL ); // no .desktop in filename, must be something else... skip!
}
if ( strstr ( ddpath, "info.desktop" ) != NULL ) {
+ // ".....info.desktop" is the 'document help' (README) emitted from a pnd, not an actual app; minimenu rather
+ // expects the doc-info as part of the main app, not a separate app.. so lets drop it here, to avoid doubling up
+ // the number of applications, needlessly..
return ( NULL );
}
p -> clockspeed = strdup ( dd + 21 );
} else if ( strncmp ( dd, "X-Pandora-Startdir=", 19 ) == 0 ) {
p -> startdir = strdup ( dd + 19 );
+ } else if ( strncmp ( dd, "X-Pandora-Appdata-Dirname=", 26 ) == 0 ) {
+ p -> appdata_dirname = strdup ( dd + 26 );
+ } else if ( strncmp ( dd, "X-Pandora-ExecArgs=", 19 ) == 0 ) {
+ p -> execargs = strdup ( dd + 19 );
+ } else if ( strncmp ( dd, "X-Pandora-Exec=", 15 ) == 0 ) {
+ p -> exec = strdup ( dd + 15 );
+ } else if ( strncmp ( dd, "X-Pandora-Object-Path=", 22 ) == 0 ) {
+ p -> object_path = strdup ( dd + 22 );
+ } else if ( strncmp ( dd, "X-Pandora-Object-Filename=", 26 ) == 0 ) {
+ p -> object_filename = strdup ( dd + 26 );
+ } else if ( strncmp ( dd, "X-Pandora-Object-Flag-OVR=", 26 ) == 0 ) {
+ p -> object_flags |= PND_DISCO_FLAG_OVR;
} else if ( strncmp ( dd, "X-Pandora-MainCategory=", 23 ) == 0 ) {
p -> main_category = strdup ( dd + 23 );
} else if ( strncmp ( dd, "X-Pandora-AltCategory2=", 23 ) == 0 ) {
p -> alt_category2 = strdup ( dd + 23 );
+ } else if ( strncmp ( dd, "X-Pandora-Info-Filename=", 24 ) == 0 ) {
+ p -> info_filename = strdup ( dd + 24 );
+ } else if ( strncmp ( dd, "X-Pandora-Info-Name=", 20 ) == 0 ) {
+ p -> info_name = strdup ( dd + 20 );
+
} else if ( strncmp ( dd, "Comment=", 8 ) == 0 ) {
p -> desc_en = strdup ( dd + 8 );
} else if ( strncmp ( dd, "Comment[en]=", 12 ) == 0 ) {
if ( e ) {
// probably libpnd app
+#if 0 // no needed due to above X-Pandora attributes
if ( e ) {
e += 5;
char *space = strchr ( p, ' ' );
strncpy ( pndpath, p, space - p - 1 );
}
+#endif
} else {
// probably not libpnd app
}
} else {
- p -> object_flags |= PND_DISCO_CUSTOM1; // so caller can do something if it wishes
+ p -> object_flags |= PND_DISCO_LIBPND_DD; // so caller can do something if it wishes
}
// filter on content
// additional
p -> object_type = pnd_object_type_pnd;
+#if 0 // nolonger needed due to above X-Pandora attributes
char *source;
if ( pndpath [ 0 ] ) {
source = pndpath;
p -> object_path = "./";
p -> object_filename = strdup ( source );
}
+#endif
+
+ // lame guards, in case of lazy consumers and broken .desktop files
+ if ( p -> object_path == NULL ) {
+ p -> object_path = strdup ( "/tmp" );
+ }
+ if ( p -> object_filename == NULL ) {
+ p -> object_filename = strdup ( "" ); // force bad filename
+ }
// return disco-t
return ( p );