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

GSList* hildon_uri_get_actions_by_uri ( const gchar *  uri_str,
HildonURIActionType  action_type,
GError **  error 
)

hildon_uri_action_get_actions_by_uri: : A const pointer to a URI. : The type of actions you want returned, can be -1 to all. : The address of a pointer to a structure. This is optional and can be NULL.

This function operates the same way () does but instead uses the mime type of the uri to know which actions it can return and has the added ability to specify the types you want returned. For most cases, this will be -1 to return all actions available for a given URI.

Return: A of actions. This list is freed using ().

Definition at line 1528 of file hildon-uri.c.

{
      GnomeVFSURI      *uri;
      GnomeVFSFileInfo *info;
      GnomeVFSResult    result;
      GSList           *actions = NULL;
      GSList           *desktop_files;
      GSList           *l;
      gchar            *filename;
      gchar            *scheme = NULL;
      gchar            *mime_type = NULL;

      g_return_val_if_fail (uri_str != NULL && uri_str[0] != '\0', NULL);

      uri = gnome_vfs_uri_new (uri_str);
      if (!uri) {
            g_set_error (error,
                       HILDON_URI_ERROR,
                       HILDON_URI_INVALID_URI,
                       "Could not create GnomeVFSURI from uri");
            return NULL;
      }

      /* Get scheme */
      scheme = g_strdup (gnome_vfs_uri_get_scheme (uri));
      if (!scheme || scheme[0] == '\0') {
            g_set_error (error,
                       HILDON_URI_ERROR,
                       HILDON_URI_INVALID_URI,
                       "The scheme could not be obtained from the uri.");
            return NULL;
      }

      /* Get mime type */
      info = gnome_vfs_file_info_new ();

      result = gnome_vfs_get_file_info (uri_str, info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
      if (result == GNOME_VFS_OK && 
          info->mime_type && 
          info->mime_type != '\0') {
            mime_type = g_strdup (info->mime_type);
      }

      DEBUG_MSG (("URI: Getting actions by uri: %s, found scheme:'%s' and mime type'%s'", 
                uri_str, scheme, mime_type));

      gnome_vfs_file_info_unref (info);
      gnome_vfs_uri_unref (uri);
      
      /* Get desktop files */
      desktop_files = uri_get_desktop_files_by_scheme (scheme);

      DEBUG_MSG (("URI: Getting actions by uri: %s, found %d desktop files", 
                uri_str, g_slist_length (desktop_files)));

      for (l = desktop_files; l; l = l->next) {
            GSList *actions_found;

            filename = l->data;

            actions_found = uri_get_desktop_file_actions (filename, scheme);
            if (actions_found) {
                  actions = g_slist_concat (actions, actions_found);
            }
      }

      actions = uri_get_desktop_file_actions_filtered (actions, 
                                           action_type, 
                                           mime_type);

      g_slist_foreach (desktop_files, (GFunc) g_free, NULL);
      g_slist_free (desktop_files);
      
      g_free (mime_type);
      g_free (scheme);

      return actions;
}


Generated by  Doxygen 1.6.0   Back to index