From 1aa0f59434ed735409fe138dd15c84f0bec6ec9a Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 11 Nov 2009 10:20:13 -0500 Subject: [PATCH] Added desc-en and preview-pic[12] to the discovery struct; man, we need to improve that whole disco-t thing someday :) --- include/pnd_discovery.h | 5 +++++ lib/pnd_discovery.c | 11 +++++++++++ test/discotest.c | 11 ++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/pnd_discovery.h b/include/pnd_discovery.h index 97d8ebc..f41d10a 100644 --- a/include/pnd_discovery.h +++ b/include/pnd_discovery.h @@ -41,6 +41,8 @@ typedef enum { // another struct? Have always intended discovery_t to have minimal members.. just enough to lead to an // application (PXML, xecutable, name); if the apps want more details, they can use the pnd_pxml code to // fetch the full PXML and get all the details. But I think we got out of control here :) +// NOTE: We really need to rework disco-t so it can include non-english titles/desc; perhaps more info as optional, +// or a name/value pairing system so it can have extra data in it, without a complex structure. typedef struct { // base unsigned char object_type; // see enum above @@ -49,6 +51,7 @@ typedef struct { unsigned int pnd_icon_pos; // offset to the byte after end of PXML in a pnd file (should be icon if present) // strdup'd from PXML -- hey, who was the idiot who thought it was a reat idea not to just re-use the pxml-struct? char *title_en; + char *desc_en; char *unique_id; char *icon; char *exec; @@ -61,6 +64,8 @@ typedef struct { char *alt_category; char *alt_category1; char *alt_category2; + char *preview_pic1; + char *preview_pic2; } pnd_disco_t; void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could not be avoided diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index c150f9f..b29f733 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -139,6 +139,7 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( pnd_is_pxml_valid_app ( pxmlh ) ) { pnd_disco_t *p; char *fixpxml; + char *z; p = pnd_box_allocinsert ( disco_box, (char*) fpath, sizeof(pnd_disco_t) ); @@ -165,6 +166,9 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( pnd_pxml_get_app_name_en ( pxmlh ) ) { p -> title_en = strdup ( pnd_pxml_get_app_name_en ( pxmlh ) ); } + if ( pnd_pxml_get_description_en ( pxmlh ) ) { + p -> desc_en = strdup ( pnd_pxml_get_description_en ( pxmlh ) ); + } if ( pnd_pxml_get_icon ( pxmlh ) ) { p -> icon = strdup ( pnd_pxml_get_icon ( pxmlh ) ); } @@ -202,6 +206,13 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( pnd_pxml_get_altsubcategory2 ( pxmlh ) ) { p -> alt_category2 = strdup ( pnd_pxml_get_altsubcategory2 ( pxmlh ) ); } + // preview pics + if ( ( z = pnd_pxml_get_previewpic1 ( pxmlh ) ) ) { + p -> preview_pic1 = strdup ( z ); + } + if ( ( z = pnd_pxml_get_previewpic2 ( pxmlh ) ) ) { + p -> preview_pic2 = strdup ( z ); + } } else { //printf ( "Invalid PXML; skipping.\n" ); diff --git a/test/discotest.c b/test/discotest.c index a1b3038..79e71fc 100644 --- a/test/discotest.c +++ b/test/discotest.c @@ -124,7 +124,10 @@ int main ( int argc, char *argv[] ) { printf ( " Base path: %s filename: %s\n", d -> object_path, d -> object_filename ); if ( d -> title_en ) { - printf ( " Name: %s\n", d -> title_en ); + printf ( " Name EN: %s\n", d -> title_en ); + } + if ( d -> desc_en ) { + printf ( " Desc EN: %s\n", d -> desc_en ); } if ( d -> icon ) { printf ( " Icon: %s\n", d -> icon ); @@ -147,6 +150,12 @@ int main ( int argc, char *argv[] ) { if ( d -> clockspeed ) { printf ( " Clockspeed: %s\n", d -> clockspeed ); } + if ( d -> preview_pic1 ) { + printf ( " Preview Pic 1: %s\n", d -> preview_pic1 ); + } + if ( d -> preview_pic2 ) { + printf ( " Preview Pic 2: %s\n", d -> preview_pic2 ); + } if ( do_icon ) { if ( pnd_emit_icon ( "./testdata/dotdesktop", d ) ) { -- 2.39.2