X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=test%2Fdiscotest.c;h=985968c446431a1d04b442880c852d081acb3156;hb=38d0da186bbf6c0fd0ac1375d9b1f5f07a15ef62;hp=79e71fcc2d9eecfad03db811dc74fe97966bdbb0;hpb=1aa0f59434ed735409fe138dd15c84f0bec6ec9a;p=pandora-libraries.git diff --git a/test/discotest.c b/test/discotest.c index 79e71fc..985968c 100644 --- a/test/discotest.c +++ b/test/discotest.c @@ -8,6 +8,7 @@ #include "pnd_apps.h" #include "pnd_pxml.h" #include "pnd_discovery.h" +#include "pnd_desktop.h" #include "pnd_locate.h" #include "pnd_utility.h" @@ -19,6 +20,7 @@ int main ( int argc, char *argv[] ) { unsigned char do_exec = 0; unsigned char do_icon = 0; unsigned char do_dotdesktop = 0; + char dotdesktoppath [ 1024 ] = ""; for ( i = 1; i < argc; i++ ) { @@ -31,11 +33,15 @@ int main ( int argc, char *argv[] ) { } else if ( argv [ i ][ 0 ] == '-' && argv [ i ][ 1 ] == 'd' ) { printf ( "Will attempt to extract dotdesktop.\n" ); do_dotdesktop = 1; + } else if ( strstr ( argv [ i ], ".desktop" ) ) { + strncpy ( dotdesktoppath, argv [ i ], 1023 ); + printf ( "Will scan '%s' instead of performing discovery\n", dotdesktoppath ); } else { - printf ( "%s [-e] [-i] [-d]\n", argv [ 0 ] ); + printf ( "%s [-e] [-i] [-d] [dotdesktop-file]\n", argv [ 0 ] ); printf ( "-e\tOptional. Attempt to exec a random app.\n" ); printf ( "-i\tOptional. Attempt to dump icon files from the end of pnd's to ./testdata/dotdesktop.\n" ); printf ( "-d\tOptional. Attempt to dump dotdesktop files from the end of pnd's to ./testdata/dotdesktop.\n" ); + printf ( "dotdesktop-file\tIf path specified and ends with .desktop, try to scan that .desktop instead of pnd-discovery\n" ); exit ( 0 ); } @@ -108,7 +114,17 @@ int main ( int argc, char *argv[] ) { */ pnd_box_handle applist; - applist = pnd_disco_search ( appspath, overridespath ); + if ( dotdesktoppath [ 0 ] ) { + 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) ); + memmove ( ai, p, sizeof(pnd_disco_t) ); + } + applist = disco_box; + } else { + applist = pnd_disco_search ( appspath, overridespath ); + } // list the found apps (if any) @@ -156,6 +172,9 @@ int main ( int argc, char *argv[] ) { if ( d -> preview_pic2 ) { printf ( " Preview Pic 2: %s\n", d -> preview_pic2 ); } + if ( d -> mkdir_sp ) { + printf ( " mkdir requests: %s\n", d -> mkdir_sp ); + } if ( do_icon ) { if ( pnd_emit_icon ( "./testdata/dotdesktop", d ) ) { @@ -180,11 +199,17 @@ int main ( int argc, char *argv[] ) { } } + // free current disco unique_id, d -> exec, d -> startdir, atoi ( d -> clockspeed ), PND_EXEC_OPTION_BLOCK ); + pnd_apps_exec ( pndrun, fullpath, d -> unique_id, d -> exec, d -> startdir, NULL, atoi ( d -> clockspeed ), PND_EXEC_OPTION_BLOCK ); } } @@ -238,7 +263,8 @@ int main ( int argc, char *argv[] ) { printf ( "Unrelated test..\n" ); char *p = strdup ( "~/.applications" ); printf ( "Tilde substitution: in '%s'\n", p ); - printf ( " out '%s'\n", pnd_expand_tilde ( p ) ); + char *expand = pnd_expand_tilde ( p ); + printf ( " out '%s'\n", expand ); free(expand); return ( 0 ); }