From 9d8efac55eedac560ba5928853142f0bc92e1cdd Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 6 Mar 2013 17:16:42 -0500 Subject: [PATCH] file associations should more or less work; only filetype is honored in the line. --- include/pnd_discovery.h | 6 +++--- lib/pnd_desktop.c | 3 +++ lib/pnd_discovery.c | 28 +++++++++++++++++++--------- lib/pnd_tinyxml.cpp | 33 ++++++++++++++++++++------------- 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/include/pnd_discovery.h b/include/pnd_discovery.h index 2d10889..b296f46 100644 --- a/include/pnd_discovery.h +++ b/include/pnd_discovery.h @@ -93,13 +93,13 @@ typedef struct { // existing above, lets just copy from pxml and use a list of [123] members.. char *associationitem1_name; char *associationitem1_filetype; - char *associationitem1_parameter; + char *associationitem1_parameter; // placeholder char *associationitem2_name; char *associationitem2_filetype; - char *associationitem2_parameter; + char *associationitem2_parameter; // placeholder char *associationitem3_name; char *associationitem3_filetype; - char *associationitem3_parameter; + char *associationitem3_parameter; // placeholder } 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_desktop.c b/lib/pnd_desktop.c index fb875ff..51de406 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -122,7 +122,9 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t fprintf ( f, "X-Pandora-Info-Name=%s\n", p -> info_name ); } +#if 1 if ( p -> associationitem1_name || p -> associationitem2_name || p -> associationitem3_name ) { + pnd_log ( PND_LOG_DEFAULT, " EmitDesktop: Found file association request in PXML (%s)\n", p -> title_en ); fprintf ( f, "MimeType=" ); if ( p -> associationitem1_name ) { fprintf ( f, "%s;", p -> associationitem1_filetype ); @@ -138,6 +140,7 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t } fprintf ( f, "\n" ); } +#endif #if 0 // we let pnd_run.sh command line handle this instead of in .desktop if ( p -> startdir ) { diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index 615c9c3..a28d89e 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -61,6 +61,13 @@ void pnd_disco_destroy ( pnd_disco_t *p ) { if ( p -> package_version_minor ) { free ( p -> package_version_minor ); } if ( p -> package_version_release ) { free ( p -> package_version_release ); } if ( p -> package_version_build ) { free ( p -> package_version_build ); } + if ( p -> associationitem1_name ) { free ( p -> associationitem1_name ); } + if ( p -> associationitem1_filetype ) { free ( p -> associationitem1_filetype ); } + if ( p -> associationitem2_name ) { free ( p -> associationitem2_name ); } + if ( p -> associationitem2_filetype ) { free ( p -> associationitem2_filetype ); } + if ( p -> associationitem3_name ) { free ( p -> associationitem3_name ); } + if ( p -> associationitem3_filetype ) { free ( p -> associationitem3_filetype ); } + return; } @@ -335,22 +342,25 @@ static int pnd_disco_callback ( const char *fpath, const struct stat *sb, if ( pnd_pxml_get_package_version_build ( pxmlh ) ) { p -> package_version_build = strdup ( pnd_pxml_get_package_version_build ( pxmlh ) ); } +#if 1 // file associations if ( pnd_pxml_get_associationitem1_name ( pxmlh ) ) { - p -> associationitem1_name = pnd_pxml_get_associationitem1_name ( pxmlh ); - p -> associationitem1_filetype = pnd_pxml_get_associationitem1_filetype ( pxmlh ); - p -> associationitem1_parameter = pnd_pxml_get_associationitem1_parameter ( pxmlh ); + p -> associationitem1_name = strdup ( pnd_pxml_get_associationitem1_name ( pxmlh ) ); + p -> associationitem1_filetype = strdup ( pnd_pxml_get_associationitem1_filetype ( pxmlh ) ); + //p -> associationitem1_parameter = strdup ( pnd_pxml_get_associationitem1_parameter ( pxmlh ) ); + pnd_log ( PND_LOG_DEFAULT, " Disco: Found file association request in PXML (%s)\n", p -> title_en ); } if ( pnd_pxml_get_associationitem2_name ( pxmlh ) ) { - p -> associationitem2_name = pnd_pxml_get_associationitem2_name ( pxmlh ); - p -> associationitem2_filetype = pnd_pxml_get_associationitem2_filetype ( pxmlh ); - p -> associationitem2_parameter = pnd_pxml_get_associationitem2_parameter ( pxmlh ); + p -> associationitem2_name = strdup ( pnd_pxml_get_associationitem2_name ( pxmlh ) ); + p -> associationitem2_filetype = strdup ( pnd_pxml_get_associationitem2_filetype ( pxmlh ) ); + //p -> associationitem2_parameter = strdup ( pnd_pxml_get_associationitem2_parameter ( pxmlh ) ); } if ( pnd_pxml_get_associationitem3_name ( pxmlh ) ) { - p -> associationitem3_name = pnd_pxml_get_associationitem3_name ( pxmlh ); - p -> associationitem3_filetype = pnd_pxml_get_associationitem3_filetype ( pxmlh ); - p -> associationitem3_parameter = pnd_pxml_get_associationitem3_parameter ( pxmlh ); + p -> associationitem3_name = strdup ( pnd_pxml_get_associationitem3_name ( pxmlh ) ); + p -> associationitem3_filetype = strdup ( pnd_pxml_get_associationitem3_filetype ( pxmlh ) ); + //p -> associationitem3_parameter = strdup ( pnd_pxml_get_associationitem3_parameter ( pxmlh ) ); } +#endif // look for any PXML overrides, if requested if ( disco_overrides ) { diff --git a/lib/pnd_tinyxml.cpp b/lib/pnd_tinyxml.cpp index 1aa8f9b..8ddc538 100644 --- a/lib/pnd_tinyxml.cpp +++ b/lib/pnd_tinyxml.cpp @@ -411,6 +411,7 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int } //All file associations: +#if 1 //Step into the associations node if ( (pElem = hRoot.FirstChild(PND_PXML_NODENAME_ASSOCS).Element()) ) { @@ -421,13 +422,15 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int { char *name = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ASSOCNAME); char *filetype = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ASSOCFTYPE); - char *paramter = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ASSOCARGS); + //char *paramter = pnd_pxml_get_attribute(pElem, PND_PXML_ATTRNAME_ASSOCARGS); - if (!(name && filetype && paramter)) + //pnd_log ( PND_LOG_DEFAULT, " Found file association request in PXML - parse (%p %p)\n", name, filetype/*, paramter */ ); + + if (!(name && filetype /* && paramter*/ )) { if(name) free(name); if(filetype) free(filetype); - if(paramter) free(paramter); + //if(paramter) free(paramter); continue; } @@ -435,30 +438,34 @@ unsigned char pnd_pxml_parse ( const char *pFilename, char *buffer, unsigned int { case 0: { - app->associationitem1_name = name; - app->associationitem1_filetype = filetype; - app->associationitem1_parameter = paramter; + app->associationitem1_name = strdup ( name ); + app->associationitem1_filetype = strdup ( filetype ); + //app->associationitem1_parameter = paramter; + pnd_log ( PND_LOG_DEFAULT, " Found file association request in PXML (%d-0)\n", i ); break; } case 1: { - app->associationitem2_name = name; - app->associationitem2_filetype = filetype; - app->associationitem2_parameter = paramter; + app->associationitem2_name = strdup ( name ); + app->associationitem2_filetype = strdup ( filetype ); + //app->associationitem2_parameter = paramter; + pnd_log ( PND_LOG_DEFAULT, " Found file association request in PXML (%d-1)\n", i ); break; } case 2: { - app->associationitem3_name = name; - app->associationitem3_filetype = filetype; - app->associationitem3_parameter = paramter; + app->associationitem3_name = strdup ( name ); + app->associationitem3_filetype = strdup ( filetype ); + //app->associationitem3_parameter = paramter; + pnd_log ( PND_LOG_DEFAULT, " Found file association request in PXML (%d-2)\n", i ); } } if(name) free(name); if(filetype) free(filetype); - if(paramter) free(paramter); + //if(paramter) free(paramter); } } +#endif //Performance related things (aka: Clockspeed XD): pElem = hRoot.FirstChild(PND_PXML_ENAME_CLOCK).Element(); -- 2.39.2