Index: jamboree/src/dbus.h
===================================================================
--- jamboree.orig/src/dbus.h	2005-06-02 12:21:05.000000000 +0200
+++ jamboree/src/dbus.h	2005-06-02 12:21:07.732775352 +0200
@@ -56,6 +56,7 @@
 
 
 void         jamboree_dbus_init_handler               (void);
+gboolean     jamboree_dbus_service_exists             (void);
 gboolean     jamboree_dbus_init_service               (void);
 gboolean     jamboree_dbus_send_remote_cmd            (const gchar  *msg,
 						       gboolean     *invalid_arg);
Index: jamboree/src/main.c
===================================================================
--- jamboree.orig/src/main.c	2005-06-02 12:21:05.000000000 +0200
+++ jamboree/src/main.c	2005-06-02 12:21:07.732775352 +0200
@@ -32,7 +32,6 @@
 #include "utils.h"
 #include "string-utils.h"
 #include "player.h"
-#include "bacon-message-connection.h"
 
 #ifdef HAVE_DBUS
 #include "dbus.h"
@@ -62,55 +61,6 @@
 	g_free (dir);
 }
 
-static void
-bacon_func (const char *message,
-	    gpointer    user_data)
-{
-	MainWindow *window;
-
-	window = user_data;
-
-	if (strcmp (message, "toggle-play") == 0) {
-		main_window_handle_play (window, TRUE);
-	}
-	else if (strcmp (message, "play") == 0) {
-		main_window_handle_play (window, FALSE);
-	}
-	else if (strcmp (message, "pause") == 0) {
-		main_window_handle_pause (window);
-	}
-	else if (strcmp (message, "stop") == 0) {
-		main_window_handle_stop (window);
-		player_stop ();
-	}
-	else if (strcmp (message, "prev") == 0) {
-		main_window_handle_prev (window);
-	}
-	else if (strcmp (message, "next") == 0) {
-		main_window_handle_next (window);
-	}
-	else if (strcmp (message, "toggle-hidden") == 0) {
-		main_window_toggle_visibility (window);
-	}
-	else if (strcmp (message, "select-all") == 0) {
-		main_window_select_all (window);
-	}
-	else if (strcmp (message, "select-playing-artist") == 0) {
-		main_window_select_playing_artist (window);
-	}
-	else if (strcmp (message, "select-playing-album") == 0) {
-		main_window_select_playing_album (window);
-	}
-	else if (strcmp (message, "show") == 0) {
-		main_window_present (window);
-	}
-	else if (strcmp (message, "quit") == 0) {
-		gtk_main_quit ();
-	} else {
-		g_warning ("Unhandled cmd: %s\n", message);
-	}
-}
-
 static gboolean  option_version;
 static char     *option_db;
 static gboolean  option_play;
@@ -173,11 +123,15 @@
 	{ NULL }
 };
 
+typedef struct {
+	gboolean *option;
+	const gchar *command;
+} ClientCommand;
+
 int
 main (int argc, char **argv)
 {
 	GError                 *error = NULL;
-	BaconMessageConnection *conn = NULL;
 	gboolean                is_server;
 	Source                 *database;
 	GtkWidget              *window;
@@ -209,48 +163,29 @@
 	 * contact one.
 	 */
 	if (!option_db) {
- 		conn = bacon_message_connection_new ("jamboree");
-		is_server = bacon_message_connection_get_is_server (conn);
-
 		/* First, handle the client case (toggle, stop, next, prev). */
-		if (!is_server) {
-			if (option_play) {
-				bacon_message_connection_send (conn, "play");
-			}
-			else if (option_pause) {
-				bacon_message_connection_send (conn, "pause");
-			}
-			else if (option_toggle_play) {
-				bacon_message_connection_send (conn, "toggle-play");
-			}
-			else if (option_stop) {
-				bacon_message_connection_send (conn, "stop");
-			}
-			else if (option_prev) {
-				bacon_message_connection_send (conn, "prev");
-			}
-			else if (option_next) {
-				bacon_message_connection_send (conn, "next");
-			}
-			else if (option_toggle_hidden) {
-				bacon_message_connection_send (conn, "toggle-hidden");
-			}
-			else if (option_select_all) {
-				bacon_message_connection_send (conn, "select-all");
-			}
-			else if (option_select_playing_artist) {
-				bacon_message_connection_send (conn, "select-playing-artist");
-			}
-			else if (option_select_playing_album) {
-				bacon_message_connection_send (conn, "select-playing-album");
-			}
-			else if (option_quit) {
-				bacon_message_connection_send (conn, "quit");
-			}
-			else if (option_hidden) {
-				/* This does not make sense in client mode. */
-			} else {
-				bacon_message_connection_send (conn, "show");
+		if (jamboree_dbus_service_exists ()) {
+			ClientCommand commands[] = 
+				{{ &option_play, "play" },
+				 { &option_pause, "pause" },
+				 { &option_toggle_play, NULL },
+				 { &option_stop, "stop" },
+				 { &option_prev, "prev" },
+				 { &option_next, "next" },
+				 { &option_toggle_hidden, NULL },
+				 { &option_select_all, NULL },
+				 { &option_select_playing_artist, NULL },
+				 { &option_select_playing_album, NULL },
+				 { &option_quit, "quit" },
+				 { NULL, NULL }};
+			ClientCommand *walk;
+			
+			for (walk = commands; walk->option; walk++) {
+				if (*walk->option) {
+					g_message (walk->command);
+					jamboree_dbus_send_remote_cmd (walk->command, NULL);
+					break;
+				}
 			}
 			
 			gdk_notify_startup_complete ();
@@ -319,10 +254,6 @@
 
 	g_object_unref (database);
 
-	if (conn) {
-		bacon_message_connection_set_callback (conn, bacon_func, window);
-	}
-	
 	if (!option_hidden) {
 		gtk_widget_show (window);
 	}
@@ -333,10 +264,6 @@
 	
 	gtk_main ();
 
-	if (conn) {
-		bacon_message_connection_free (conn);
-	}
-	
 	shared_string_shutdown ();
 
 	g_object_unref (gconf_client);
Index: jamboree/src/dbus.c
===================================================================
--- jamboree.orig/src/dbus.c	2005-06-02 12:21:05.000000000 +0200
+++ jamboree/src/dbus.c	2005-06-02 12:21:07.733775200 +0200
@@ -44,6 +44,25 @@
 
 
 gboolean
+jamboree_dbus_service_exists (void)
+{
+	DBusError       error;
+  
+	dbus_error_init (&error);
+	bus_conn = dbus_bus_get (DBUS_BUS_SESSION, &error);
+  
+	if (!bus_conn) {
+		g_warning ("Failed to connect to the D-BUS daemon: %s", error.message);
+		dbus_error_free (&error);
+		return FALSE;
+	}
+    
+        dbus_error_free (&error);
+
+	return dbus_bus_name_has_owner (bus_conn, JAMBOREE_DBUS_SERVICE, NULL);
+}
+
+gboolean
 jamboree_dbus_init_service (void)
 {
 	DBusError       error;
@@ -64,7 +83,7 @@
 		return FALSE;
 	}
   
-	dbus_bus_acquire_service (bus_conn, JAMBOREE_DBUS_SERVICE, 0, &error);
+	dbus_bus_request_name (bus_conn, JAMBOREE_DBUS_SERVICE, 0, &error);
 	if (dbus_error_is_set (&error)) {
 		g_warning ("Failed to acquire player service");
 		dbus_error_free (&error);
@@ -297,11 +316,13 @@
 			     MainWindow     *window)
 {
 	DBusMessage *reply;
+	gboolean val;
 	
 	reply = dbus_message_new_method_return (message);
 	
+	val = main_window_get_is_visible (window);
 	dbus_message_append_args (reply,
-				  DBUS_TYPE_BOOLEAN, main_window_get_is_visible (window),
+				  DBUS_TYPE_BOOLEAN, &val,
 				  DBUS_TYPE_INVALID);
 	
 	dbus_connection_send (connection, reply, NULL);
@@ -321,7 +342,7 @@
         random = main_window_get_random (window);
         
 	dbus_message_append_args (reply,
-                                  DBUS_TYPE_BOOLEAN, random,
+                                  DBUS_TYPE_BOOLEAN, &random,
                                   DBUS_TYPE_INVALID);
 	
 	dbus_connection_send (connection, reply, NULL);
@@ -358,7 +379,7 @@
         repeat = main_window_get_random (window);
         
 	dbus_message_append_args (reply,
-                                  DBUS_TYPE_BOOLEAN, repeat,
+                                  DBUS_TYPE_BOOLEAN, &repeat,
                                   DBUS_TYPE_INVALID);
 	
 	dbus_connection_send (connection, reply, NULL);
@@ -527,13 +548,15 @@
 						msg);
 
 	if (strcmp (arg, "show-window") == 0) {
+		gboolean val = TRUE;
 		dbus_message_append_args (message,
-					  DBUS_TYPE_BOOLEAN, TRUE,
+					  DBUS_TYPE_BOOLEAN, &val,
 					  DBUS_TYPE_INVALID);
 	}
 	else if (strcmp (arg, "hide-window") == 0) {
+		gboolean val = FALSE;
 		dbus_message_append_args (message,
-					  DBUS_TYPE_BOOLEAN, FALSE,
+					  DBUS_TYPE_BOOLEAN, &val,
 					  DBUS_TYPE_INVALID);
 	}
 
@@ -633,31 +656,68 @@
 }
 #endif
 
-static gboolean
-message_append_song (DBusMessage *message, Song *song)
+static void
+append_key_val (DBusMessageIter *iter, const gchar *key, int type,
+		const gpointer val)
 {
-	DBusMessageIter iter, dict;
-  
-	dbus_message_append_iter_init (message, &iter);
+	DBusMessageIter eiter, viter;
+	gchar sig[2] = "\0\0";
+	
+	dbus_message_iter_open_container (iter, DBUS_TYPE_DICT_ENTRY, NULL,
+					  &eiter);
+
+	dbus_message_iter_append_basic (&eiter, DBUS_TYPE_STRING, &key);
+
+	sig[0] = (char)type;
+	dbus_message_iter_open_container (&eiter, DBUS_TYPE_VARIANT,
+					  sig, &viter);
+	dbus_message_iter_append_basic (&viter, type, val);
+	dbus_message_iter_close_container (&eiter, &viter);
 
-	dbus_message_iter_append_dict (&iter, &dict);  
+	dbus_message_iter_close_container (iter, &viter);
+}
+
+static void
+append_key_sval (DBusMessageIter *iter, const gchar *key, const gchar *val)
+{
+	append_key_val (iter, key, DBUS_TYPE_STRING, &val);
+}
 
-	dbus_message_iter_append_dict_key (&dict, "title");
-	dbus_message_iter_append_string (&dict, song_get_title (song));
+static void
+append_key_ival (DBusMessageIter *iter, const gchar *key, dbus_int32_t val)
+{
+	append_key_val (iter, key, DBUS_TYPE_INT32, &val);
+}
 
-	dbus_message_iter_append_dict_key (&dict, "artist");
-	dbus_message_iter_append_string (&dict, song_get_artist (song));
+static gboolean
+message_append_song (DBusMessage *message, Song *song)
+{
+	DBusMessageIter iter, diter;
+  
+	dbus_message_iter_init_append (message, &iter);
 
-	dbus_message_iter_append_dict_key (&dict, "album");
-	dbus_message_iter_append_string (&dict, song_get_album (song));
+	if (!dbus_message_iter_open_container (&iter,
+					       DBUS_TYPE_ARRAY,
+					       DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+					       DBUS_TYPE_STRING_AS_STRING
+					       DBUS_TYPE_VARIANT_AS_STRING
+					       DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+					       &diter)) {
+		g_error ("Out of memory!!!");
+	}
+
+	append_key_sval (&diter, "title", song_get_title (song));
+	append_key_sval (&diter, "artist", song_get_artist (song));
+	append_key_sval (&diter, "album", song_get_album (song));
+	append_key_ival (&diter, "length", song_get_duration (song));
 
 	/*  dbus_message_iter_append_dict_key (&dict, "filename");
 	    dbus_message_iter_append_byte_array (&dict, (unsigned const char*)song->filename,
 	    strlen (song->filename));
 	*/
-	dbus_message_iter_append_dict_key (&dict, "length");
-	dbus_message_iter_append_int32 (&dict, song_get_duration (song));
   
+	dbus_message_iter_close_container (&iter, &diter);
+
 	return TRUE;
 }
 
@@ -708,7 +768,7 @@
         }
         
         dbus_message_append_args (message, 
-                                  DBUS_TYPE_STRING, state_str,
+                                  DBUS_TYPE_STRING, &state_str,
                                   DBUS_TYPE_INVALID);
 
 	dbus_connection_send (bus_conn, message, NULL);
Index: jamboree/ChangeLog
===================================================================
--- jamboree.orig/ChangeLog	2005-06-02 12:21:05.000000000 +0200
+++ jamboree/ChangeLog	2005-06-02 12:21:07.733775200 +0200
@@ -1,3 +1,23 @@
+2005-05-26  Andy Wingo  <wingo@pobox.com>
+
+	* src/dbus.h:
+	* src/dbus.c (jamboree_dbus_service_exists): New function.
+
+	* src/main.c (bacon_func): Remove, just use dbus.
+	(main): Detect 'client mode' by seeing if there is a jamboree
+	service. If there is, send dbus messages (instead of bacon
+	messages).
+	
+2005-05-25  Richard Hult  <richard@imendio.com>
+
+	* data/glade/jamboree.glade: Add frame for cover image.
+	* src/main-window.c: (main_window_finalize),
+	(rescale_cover_timeout_cb), (playlist_paned_notify_position_cb),
+	(rescale_cover_image), (update_cover_image), (update_playing_info),
+	(cover_button_press_event_cb), (cover_button_release_event_cb):
+	(setup_gui): Use any images found as cover images.
+	Inspired by a patch from bluegeek@eresmas.com.
+
 2005-05-18  Richard Hult  <richard@imendio.com>
 
 	* src/main-window.c:
