Logo Search packages:      
Sourcecode: libhildonmime version File versions  Download package

gint hildon_mime_open_file_list ( DBusConnection *  con,
GSList *  files 
)

hildon_mime_open_file_list: : The D-BUS connection to use. : A of const pointer URIs to be opened (UTF-8).

This function opens a list of . The will be sent to each application that handles their MIME-type. If more then one type of file is specified, many applications may be launched.

For more information on opening files, see hildon_mime_open_file().

Return: 1 in case of success, < 1 if an error occurred or if some parameter is invalid.

Definition at line 441 of file hildon-mime-open.c.

{
      GHashTable *apps = NULL;
      GSList     *list = NULL;
      GSList     *l;
      gint        num_apps;
      gboolean    success = TRUE;

      if (con == NULL) {
            DLOG_OPEN("libossomime");
            DLOG_ERR_F("error: no D-BUS connection!");
            LOG_CLOSE();
            return 0;
      }

      if (files == NULL) {
            DLOG_OPEN("libossomime");
            DLOG_ERR_F("error: no files to open!");
            LOG_CLOSE();
            return 0;
      }

      apps = g_hash_table_new_full (g_str_hash, 
                              g_str_equal,
                              NULL, 
                              (GDestroyNotify) app_entry_free);
    
      gnome_vfs_init (); /* make sure that gnome vfs is initialized */

      for (l = files; l; l = l->next) {
            AppEntry *entry;
            gchar    *file;
            gchar    *service_name;

            file = l->data;

            service_name = get_service_name_by_path (file);
            if (service_name) {
                  dprint ("Got service_name '%s' for file '%s'",
                        service_name, file);

                  entry = g_hash_table_lookup (apps, service_name);
                  if (!entry) {
                        entry = g_new0 (AppEntry, 1);
                        
                        entry->service_name = service_name;
                        g_hash_table_insert (apps, entry->service_name, entry);
                  } else {
                        g_free (service_name);
                  }
                              
                  entry->files = g_slist_append (entry->files, file);
            } else {
                  dprint ("No D-Bus service for file '%s'", file);
            }                 
      }     

      num_apps = g_hash_table_size (apps);
      g_hash_table_foreach (apps, (GHFunc) mime_open_file_list_foreach, &list);

      /* If we didn't find an application to launch, it's an error. */
      success &= list != NULL;

      for (l = list; l; l = l->next) {
            AppEntry *entry;

            entry = l->data;
            success &= mime_launch (con, entry);
      }
      
      g_slist_free (list);
      g_hash_table_destroy (apps);
      
      return success ? 1 : 0;
}


Generated by  Doxygen 1.6.0   Back to index