From 36c5d5aeb4b03ca5b03ea0f6518c381dd428c5ba Mon Sep 17 00:00:00 2001 From: skeezix Date: Wed, 6 Mar 2013 11:31:49 -0500 Subject: [PATCH] Preliminary addition of mimetype handling for file associations; not yet tested much --- include/pnd_discovery.h | 11 +++++++++++ lib/pnd_desktop.c | 17 +++++++++++++++++ lib/pnd_discovery.c | 16 ++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/include/pnd_discovery.h b/include/pnd_discovery.h index 00c93db..2d10889 100644 --- a/include/pnd_discovery.h +++ b/include/pnd_discovery.h @@ -89,6 +89,17 @@ typedef struct { char *package_version_minor; char *package_version_release; char *package_version_build; + // why are we not using typedef'd arrays here? :/ in the name of consistency with + // existing above, lets just copy from pxml and use a list of [123] members.. + char *associationitem1_name; + char *associationitem1_filetype; + char *associationitem1_parameter; + char *associationitem2_name; + char *associationitem2_filetype; + char *associationitem2_parameter; + char *associationitem3_name; + char *associationitem3_filetype; + char *associationitem3_parameter; } 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 3fffa36..fb875ff 100644 --- a/lib/pnd_desktop.c +++ b/lib/pnd_desktop.c @@ -122,6 +122,23 @@ unsigned char pnd_emit_dotdesktop ( char *targetpath, char *pndrun, pnd_disco_t fprintf ( f, "X-Pandora-Info-Name=%s\n", p -> info_name ); } + if ( p -> associationitem1_name || p -> associationitem2_name || p -> associationitem3_name ) { + fprintf ( f, "MimeType=" ); + if ( p -> associationitem1_name ) { + fprintf ( f, "%s;", p -> associationitem1_filetype ); + pnd_log ( PND_LOG_DEFAULT, "App %s is handling mimetype %s [1]\n", p -> title_en, p -> associationitem1_filetype ); + } + if ( p -> associationitem2_name ) { + fprintf ( f, "%s;", p -> associationitem2_filetype ); + pnd_log ( PND_LOG_DEFAULT, "App %s is handling mimetype %s [2]\n", p -> title_en, p -> associationitem2_filetype ); + } + if ( p -> associationitem3_name ) { + fprintf ( f, "%s;", p -> associationitem3_filetype ); + pnd_log ( PND_LOG_DEFAULT, "App %s is handling mimetype %s [3]\n", p -> title_en, p -> associationitem3_filetype ); + } + fprintf ( f, "\n" ); + } + #if 0 // we let pnd_run.sh command line handle this instead of in .desktop if ( p -> startdir ) { snprintf ( buffer, 1020, "Path=%s\n", p -> startdir ); diff --git a/lib/pnd_discovery.c b/lib/pnd_discovery.c index fd12224..615c9c3 100644 --- a/lib/pnd_discovery.c +++ b/lib/pnd_discovery.c @@ -335,6 +335,22 @@ 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 ) ); } + // 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 ); + } + 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 ); + } + 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 ); + } // look for any PXML overrides, if requested if ( disco_overrides ) { -- 2.39.5