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

HildonURIAction* hildon_uri_get_default_action_by_uri ( const gchar *  uri_str,
GError **  error 

hildon_uri_get_default_action_by_uri : A string which represents a uri : The address of a pointer to a structure. This is optional and can be NULL.

: Use () instead.

This returns the which is the default for a . This function works similarly to () with the difference being that the mime type of the uri is used to look up the action. The reason for this being that default actions now are effective with scheme and mime type instead of JUST the scheme as before.

If NULL is returned and is NULL then there is no default for . If NULL is returned and is non-NULL, it will hold the error that occurred while trying to obtain the default .

Return: The default for .

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

References hildon_uri_get_default_action(), and hildon_uri_get_scheme_from_uri().

Referenced by hildon_uri_is_default_action_by_uri(), and hildon_uri_open().

      GKeyFile         *key_file;
      HildonURIAction  *action = NULL;
      gchar            *scheme = NULL;
      const gchar      *mime_type;
      gchar            *desktop_file = NULL;
      gchar            *filename;
      gchar            *full_path = NULL;
      gboolean          ok;

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

      scheme = hildon_uri_get_scheme_from_uri (uri_str, error);
      if (!scheme || scheme[0] == '\0') {
            return NULL;

      mime_type = gnome_vfs_get_mime_type_for_name (uri_str);
      if (strcmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) == 0) {
            mime_type = NULL;

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

      /* Open file and get the mime type and action name */
      key_file = g_key_file_new ();

      filename = g_build_filename ("applications", 

      ok = g_key_file_load_from_data_dirs (key_file, 

      if (ok) {
            gchar *str;

            DEBUG_MSG (("URI: Getting default actions from file:'%s'", full_path));

            if (mime_type) {
                  gchar *group;
                  gchar *mime_type_dup;

                  mime_type_dup = g_strdup (mime_type);
                  str = strchr (mime_type_dup, '/');
                  if (str) {
                        str[0] = '-';

                  group = g_strdup_printf (HILDON_URI_DEFAULTS_GROUP_FORMAT, scheme);
                  str = g_key_file_get_string (key_file, group, mime_type_dup, NULL);
                  DEBUG_MSG (("URI: %s string:'%s' in group:'%s' with key:'%s'", 
                            str ? "Found" : "Didn't find", 
                  g_free (group);

                  if (str) {
                        action = uri_get_desktop_file_action (scheme, str);
                        g_free (str);

                  g_free (mime_type_dup);

            if (!action) {
                  /* We fallback to the old function here because it is
                   * used for neutral and fallback actions.
                  DEBUG_MSG (("URI: Getting default action by falling back to old "
                            "function just using scheme:'%s'", 

                  action = hildon_uri_get_default_action (scheme, error);

      g_key_file_free (key_file);

      g_free (desktop_file);
      g_free (filename);
      g_free (scheme);

      return action;

Generated by  Doxygen 1.6.0   Back to index