changeset 4632:f733f3d75850

Automated merge with ssh://hg.atheme.org//hg/audacious
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 11 Jun 2008 18:03:27 +0300
parents 5ebedd1470c9 (current diff) 6cda48638a58 (diff)
children 3d5862f6c6c4 ca64cd387021
files src/audacious/dbus.c
diffstat 3 files changed, 45 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/dbus.c	Wed Jun 11 14:19:31 2008 +0900
+++ b/src/audacious/dbus.c	Wed Jun 11 18:03:27 2008 +0300
@@ -89,6 +89,7 @@
     DBusGProxy *driver_proxy;
     guint request_ret;
 
+    g_message("Registering remote D-Bus interfaces");
     
     dbus_g_object_type_install_info(audacious_rc_get_type(),
                                     &dbus_glib_audacious_rc_object_info);
@@ -137,14 +138,19 @@
                                         AUDACIOUS_DBUS_PATH_MPRIS_PLAYER,
                                         G_OBJECT(object));
 
-	// Add signals
-	DBusGProxy *proxy = object->proxy;
-	dbus_g_proxy_add_signal(proxy, "StatusChange",
-			G_TYPE_INT, G_TYPE_INVALID);
-	dbus_g_proxy_add_signal(proxy, "CapsChange",
-			G_TYPE_INT, G_TYPE_INVALID);
-	dbus_g_proxy_add_signal(proxy, "TrackChange",
-			DBUS_TYPE_G_STRING_VALUE_HASHTABLE, G_TYPE_INVALID);
+    // Add signals
+    DBusGProxy *proxy = object->proxy;
+    if (proxy != NULL) {
+        dbus_g_proxy_add_signal(proxy, "StatusChange",
+            G_TYPE_INT, G_TYPE_INVALID);
+        dbus_g_proxy_add_signal(proxy, "CapsChange",
+            G_TYPE_INT, G_TYPE_INVALID);
+        dbus_g_proxy_add_signal(proxy, "TrackChange",
+            DBUS_TYPE_G_STRING_VALUE_HASHTABLE, G_TYPE_INVALID);
+    } else {
+        /* XXX / FIXME: Why does this happen? -- ccr */
+        g_warning("in mpris_player_init object->proxy == NULL, not adding some signals.");
+    }
 }
 
 void mpris_tracklist_init(MprisTrackList *object) {
@@ -161,6 +167,7 @@
     GError *error = NULL;
     DBusConnection *local_conn;
     // Initialize the DBus connection
+    g_message("Trying to initialize D-Bus");
     dbus_conn = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
     if (dbus_conn == NULL) {
         g_warning("Unable to connect to dbus: %s", error->message);
@@ -169,9 +176,14 @@
     }
 
     g_type_init();
+    g_message("D-Bus RC");
     g_object_new(audacious_rc_get_type(), NULL);
+    g_message("D-Bus MPRIS root");
     g_object_new(mpris_root_get_type(), NULL);
+    g_message("D-Bus MPRIS player");
     mpris = g_object_new(mpris_player_get_type(), NULL);
+    g_message("result=%p", mpris);
+    g_message("D-Bus MPRIS tracklist");
     g_object_new(mpris_tracklist_get_type(), NULL);
     g_message("D-Bus support has been activated");
 
@@ -199,8 +211,14 @@
     return NULL;
 }
 
-static void
-remove_metadata_value(gpointer value)
+static void tuple_insert_to_hash(GHashTable *md, Tuple *tuple, const gchar *key)
+{
+    GValue *value = tuple_value_to_gvalue(tuple, key);
+    if (value != NULL)
+        g_hash_table_insert(md, key, value);
+}
+
+static void remove_metadata_value(gpointer value)
 {
     g_value_unset((GValue*)value);
     g_free((GValue*)value);
@@ -216,40 +234,13 @@
     md = g_hash_table_new_full(g_str_hash, g_str_equal,
                                NULL, remove_metadata_value);
 
-    value = tuple_value_to_gvalue(tuple, "length");
-    if (value != NULL) {
-        g_hash_table_insert(md, "length", value);
-    }
-
-    value = tuple_value_to_gvalue(tuple, "title");
-    if (value != NULL) {
-        g_hash_table_insert(md, "title", value);
-    }
-
-    value = tuple_value_to_gvalue(tuple, "artist");
-    if (value != NULL) {
-        g_hash_table_insert(md, "artist", value);
-    }
-
-    value = tuple_value_to_gvalue(tuple, "album");
-    if (value != NULL) {
-        g_hash_table_insert(md, "album", value);
-    }
-
-    value = tuple_value_to_gvalue(tuple, "genre");
-    if (value != NULL) {
-        g_hash_table_insert(md, "genre", value);
-    }
-
-    value = tuple_value_to_gvalue(tuple, "codec");
-    if (value != NULL) {
-        g_hash_table_insert(md, "codec", value);
-    }
-
-    value = tuple_value_to_gvalue(tuple, "quality");
-    if (value != NULL) {
-        g_hash_table_insert(md, "quality", value);
-    }
+    tuple_insert_to_hash(md, tuple, "length");
+    tuple_insert_to_hash(md, tuple, "title");
+    tuple_insert_to_hash(md, tuple, "artist");
+    tuple_insert_to_hash(md, tuple, "album");
+    tuple_insert_to_hash(md, tuple, "genre");
+    tuple_insert_to_hash(md, tuple, "codec");
+    tuple_insert_to_hash(md, tuple, "quality");
 
     return md;
 }
--- a/src/audacious/tuple.c	Wed Jun 11 14:19:31 2008 +0900
+++ b/src/audacious/tuple.c	Wed Jun 11 18:03:27 2008 +0300
@@ -159,10 +159,7 @@
     if ((value = tuple_associate_data(tuple, nfield, field, TUPLE_STRING)) == NULL)
         return FALSE;
 
-    if (string == NULL)
-        value->value.string = NULL;
-    else
-        value->value.string = g_strdup(string);
+    value->value.string = NULL;
 
     TUPLE_UNLOCK_WRITE();
     return TRUE;
@@ -179,18 +176,17 @@
     tuple = tuple_new();
     g_return_val_if_fail(tuple != NULL, NULL);
 
-    scratch = uri_to_display_basename(filename);
-    _tuple_associate_raw_string(tuple, FIELD_FILE_NAME, NULL, scratch);
-    g_free(scratch);
+    _tuple_associate_raw_string(tuple, FIELD_FILE_NAME, NULL,
+        uri_to_display_basename(filename));
 
-    scratch = uri_to_display_dirname(filename);
-    _tuple_associate_raw_string(tuple, FIELD_FILE_PATH, NULL, scratch);
-    g_free(scratch);
+    _tuple_associate_raw_string(tuple, FIELD_FILE_PATH, NULL,
+        uri_to_display_basename(filename));
     
     ext = strrchr(filename, '.');
     if (ext != NULL) {
         ++ext;
-        _tuple_associate_raw_string(tuple, FIELD_FILE_EXT, NULL, ext);
+        _tuple_associate_raw_string(tuple, FIELD_FILE_EXT, NULL,
+            g_strdup(ext));
     }
 
     return tuple;
--- a/src/audacious/util.c	Wed Jun 11 14:19:31 2008 +0900
+++ b/src/audacious/util.c	Wed Jun 11 18:03:27 2008 +0300
@@ -995,18 +995,16 @@
     // case 1: filename is raw full path or uri
     if (filename[0] == '/' || strstr(filename, "://")) {
         uri = g_filename_to_uri(filename, NULL, NULL);
-        if(!uri) {
+        if(!uri)
             uri = g_strdup(filename);
-        }
         g_free(filename);
     }
     // case 2: filename is not raw full path nor uri, playlist path is full path
     // make full path by replacing last part of playlist path with filename. (using g_build_filename)
     else if (playlist_name[0] == '/' || strstr(playlist_name, "://")) {
         path = g_filename_from_uri(playlist_name, NULL, NULL);
-        if (!path) {
+        if (!path)
             path = g_strdup(playlist_name);
-        }
         tmp = strrchr(path, '/'); *tmp = '\0';
         tmp = g_build_filename(path, filename, NULL);
         g_free(path); g_free(filename);
@@ -1017,7 +1015,7 @@
     // just abort.
     else {
         g_free(filename);
-        return NULL;
+        uri = NULL;
     }
 
     AUDDBG("uri=%s\n", uri);