Preliminary addition of mimetype handling for file associations; not yet tested much
authorskeezix <skeezix@flotsam-vm.(none)>
Wed, 6 Mar 2013 16:31:49 +0000 (11:31 -0500)
committerskeezix <skeezix@flotsam-vm.(none)>
Wed, 6 Mar 2013 16:31:49 +0000 (11:31 -0500)
include/pnd_discovery.h
lib/pnd_desktop.c
lib/pnd_discovery.c

index 00c93db..2d10889 100644 (file)
@@ -89,6 +89,17 @@ typedef struct {
   char *package_version_minor;
   char *package_version_release;
   char *package_version_build;
   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
 } pnd_disco_t;
 
 void pnd_disco_destroy ( pnd_disco_t *p ); // a function name that simply could not be avoided
index 3fffa36..fb875ff 100644 (file)
@@ -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 );
   }
 
     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 );
 #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 );
index fd12224..615c9c3 100644 (file)
@@ -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 ) );
       }
       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 ) {
 
       // look for any PXML overrides, if requested
       if ( disco_overrides ) {