changeset 2771:4585019eb82e trunk

[svn] -Renamed MPRIS /TrackList Shuffle method to Random -Added stubs for the MPRIS /Player signals -Added stubs for the MPRIS /TrackList methods (implemented AddTrack) -Modified build system to be more ignorant of DBus support
author magma
date Tue, 15 May 2007 21:53:37 -0700
parents e21a9128e683
children 3c2786bbcf36
files ChangeLog configure.ac mk/rules.mk.in src/Makefile src/audacious/Makefile src/audacious/build_stamp.c src/audacious/dbus-service.h src/audacious/dbus.c src/audacious/mpris_tracklist.xml
diffstat 9 files changed, 161 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon May 14 01:10:54 2007 -0700
+++ b/ChangeLog	Tue May 15 21:53:37 2007 -0700
@@ -1,3 +1,12 @@
+2007-05-14 08:10:54 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
+  revision [4566]
+  - remove -laudacious from audacious.pc.in. -laudclient will be put into audacious.pc if --enable-dbus is specified.
+  
+  trunk/audacious.pc.in |    2 +-
+  trunk/configure.ac    |    2 ++
+  2 files changed, 3 insertions(+), 1 deletion(-)
+
+
 2007-05-14 01:38:53 +0000  Ben Tucker <bnt@interchange.ubc.ca>
   revision [4564]
   Implemented CMD_IS_ADVANCE and CMD_TOGGLE_ADVANCE. Added partial MPRIS support. Root is complete, Player is partially implemented, and TrackList has not been started.
--- a/configure.ac	Mon May 14 01:10:54 2007 -0700
+++ b/configure.ac	Tue May 15 21:53:37 2007 -0700
@@ -235,18 +235,13 @@
 		AC_DEFINE(USE_DBUS, 1, [Define if D-Bus support enabled])
 		AC_DEFINE(DBUS_SERVICES_DIR, "$datadir/dbus-1/services",
 			[Location of D-Bus services directory])
-		DBUS_C=dbus.c
-		DBUS_BINDINGS="dbus-server-bindings.h dbus-client-bindings.h"
-		LIBAUDCLIENT_OBJECTIVE="libaudclient audtool"
+		USE_DBUS=1
 		LIBAUDCLIENT_LDFLAGS="-laudclient"
-		AC_SUBST(DBUS_C)
-		AC_SUBST(DBUS_BINDINGS)
 		AC_SUBST(USE_DBUS)
 		AC_SUBST(DBUS_CFLAGS)
 		AC_SUBST(DBUS_LIBS)
 		AC_SUBST(DBUS_SERVICES_DIR)
 		AC_SUBST(DBUS_BINDING_TOOL)
-		AC_SUBST(LIBAUDCLIENT_OBJECTIVE)
 		AC_SUBST(LIBAUDCLIENT_LDFLAGS)
 	fi
 fi
--- a/mk/rules.mk.in	Mon May 14 01:10:54 2007 -0700
+++ b/mk/rules.mk.in	Tue May 15 21:53:37 2007 -0700
@@ -97,9 +97,8 @@
 CYGPATH_W ?= @CYGPATH_W@
 DATADIRNAME ?= @DATADIRNAME@
 DCT64 ?= @DCT64@
-DBUS_C ?= @DBUS_C@
-DBUS_BINDINGS ?= @DBUS_BINDINGS@
 DBUS_BINDING_TOOL ?= @DBUS_BINDING_TOOL@
+DBUS_SERVICES_TOOL ?= @DBUS_SERVICES_DIR@
 DBUS_CFLAGS ?= @DBUS_CFLAGS@
 DBUS_LIBS ?= @DBUS_LIBS@
 DEFS ?= @DEFS@
@@ -252,6 +251,7 @@
 SNDFILE_CFLAGS ?= @SNDFILE_CFLAGS@
 SNDFILE_LIBS ?= @SNDFILE_LIBS@
 STRIP ?= @STRIP@
+USE_DBUS ?= @USE_DBUS@
 USE_INCLUDED_LIBINTL ?= @USE_INCLUDED_LIBINTL@
 USE_NLS ?= @USE_NLS@
 USE_X86ASM_FALSE ?= @USE_X86ASM_FALSE@
--- a/src/Makefile	Mon May 14 01:10:54 2007 -0700
+++ b/src/Makefile	Tue May 15 21:53:37 2007 -0700
@@ -3,10 +3,17 @@
 include ../mk/rules.mk
 include ../mk/init.mk
 
-SUBDIRS = $(INTL_OBJECTIVE) $(SUBDIR_GUESS) $(LIBAUDCLIENT_OBJECTIVE) audacious libid3tag
+SUBDIRS = $(INTL_OBJECTIVE) $(SUBDIR_GUESS)
+
+ifdef USE_DBUS
+SUBDIRS += libaudclient audtool
+endif
+
+SUBDIRS += audacious libid3tag
 
 include ../mk/objective.mk
 
+ifdef USE_DBUS
 depend-prehook:
 	@cd audacious; $(MAKE) $@ || exit; cd ..;
-
+endif
--- a/src/audacious/Makefile	Mon May 14 01:10:54 2007 -0700
+++ b/src/audacious/Makefile	Tue May 15 21:53:37 2007 -0700
@@ -5,7 +5,6 @@
 SUBDIRS = widgets glade images ui
 
 OBJECTIVE_BINS = audacious
-OBJECTIVE_LIBS_NOINST = $(DBUS_BINDINGS)
 
 LDFLAGS += $(AUDLDFLAGS)
 
@@ -63,7 +62,6 @@
 	auddrct.c \
 	build_stamp.c \
 	configdb.c \
-	$(DBUS_C) \
 	dnd.c \
 	dock.c \
 	effect.c \
@@ -117,6 +115,13 @@
 	visualization.c \
 	xconvert.c
 
+ifdef USE_DBUS
+SOURCES += dbus.c
+DBUS_BINDINGS = dbus-server-bindings.h dbus-client-bindings.h
+depend-prehook: $(DBUS_BINDINGS)
+OBJECTIVE_LIBS_NOINST += $(DBUS_BINDINGS)
+endif
+
 DBUS_BINDINGS_SOURCES = \
 	objects.xml \
 	mpris_root.xml \
@@ -130,8 +135,6 @@
 desktop_DATA = audacious.desktop
 desktopdir = $(datadir)/applications
 
-depend-prehook: $(DBUS_BINDINGS)
-
 audacious: $(OBJECTS) $(LIBDEP)
 	$(CXX) $(LDFLAGS) $(OBJECTS) $(LDADD) -o $@ 
 	@printf "%10s     %-20s\n" LINK $@
@@ -139,7 +142,7 @@
 dbus-server-bindings.h: $(DBUS_BINDINGS_SOURCES)
 	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=audacious_rc objects.xml > $@
 	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=mpris_root mpris_root.xml >> $@
-	# $(DBUS_BINDING_TOOL) --mode=glib-server --prefix=mpris_tracklist mpris_tracklist.xml >> $@
+	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=mpris_tracklist mpris_tracklist.xml >> $@
 	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=mpris_player mpris_player.xml >> $@
 	@printf "%10s     %-20s\n" DBUS-BIND $@
 
--- a/src/audacious/build_stamp.c	Mon May 14 01:10:54 2007 -0700
+++ b/src/audacious/build_stamp.c	Tue May 15 21:53:37 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070514-4564";
+const gchar *svn_stamp = "20070514-4566";
--- a/src/audacious/dbus-service.h	Mon May 14 01:10:54 2007 -0700
+++ b/src/audacious/dbus-service.h	Tue May 15 21:53:37 2007 -0700
@@ -27,11 +27,11 @@
 
 typedef struct {
     GObject parent;
-} RemoteObject, MprisRoot, MprisPlayer;
+} RemoteObject, MprisRoot, MprisPlayer, MprisTrackList;
 
 typedef struct {
     GObjectClass parent_class;
-} RemoteObjectClass, MprisRootClass, MprisPlayerClass;
+} RemoteObjectClass, MprisRootClass, MprisPlayerClass, MprisTrackListClass;
 
 void init_dbus();
 void free_dbus();
@@ -40,8 +40,10 @@
 ///////////////////////////
 // MPRIS defined methods //
 ///////////////////////////
+// MPRIS /
 gboolean mpris_root_identity(MprisRoot *obj, gchar **identity,
                              GError **error);
+// MPRIS /Player
 gboolean mpris_player_next(MprisPlayer *obj, GError **error);
 gboolean mpris_player_prev(MprisPlayer *obj, GError **error);
 gboolean mpris_player_pause(MprisPlayer *obj, GError **error);
@@ -59,6 +61,32 @@
 gboolean mpris_player_position_set(MprisPlayer *obj, gint pos, GError **error);
 gboolean mpris_player_position_get(MprisPlayer *obj, gint *pos,
                                    GError **error);
+enum {
+    CAPS_CHANGE_SIG,
+    TRACK_CHANGE_SIG,
+    STATUS_CHANGE_SIG,
+    LAST_SIG
+};
+gboolean mpris_player_emit_caps_change(MprisPlayer *obj, GError **error);
+gboolean mpris_player_emit_track_change(MprisPlayer *obj, GError **error);
+gboolean mpris_player_emit_status_change(MprisPlayer *obj, GError **error);
+
+// MPRIS /TrackList
+gboolean mpris_tracklist_get_metadata(MprisTrackList *obj, gint pos,
+                                      GHashTable *metadata, GError **error);
+gboolean mpris_tracklist_get_current_track(MprisTrackList *obj, gint *pos,
+                                           GError **error);
+gboolean mpris_tracklist_get_length(MprisTrackList *obj, gint *pos,
+                                    GError **error);
+gboolean mpris_tracklist_add_track(MprisTrackList *obj, gchar *uri,
+                                   gboolean play, GError **error);
+gboolean mpris_tracklist_del_track(MprisTrackList *obj, gint pos,
+                                   GError **error);
+gboolean mpris_tracklist_loop(MprisTrackList *obj, gboolean loop,
+                              GError **error);
+gboolean mpris_tracklist_random(MprisTrackList *obj, gboolean random,
+                                GError **error);
+
 
 // Audacious General Information
 gboolean audacious_rc_version(RemoteObject *obj, gchar **version,
--- a/src/audacious/dbus.c	Mon May 14 01:10:54 2007 -0700
+++ b/src/audacious/dbus.c	Tue May 15 21:53:37 2007 -0700
@@ -40,16 +40,44 @@
 #include "ui_jumptotrack.h"
 
 static DBusGConnection *dbus_conn = NULL;
+static guint signals[LAST_SIG] = { 0 };
 
 G_DEFINE_TYPE(RemoteObject, audacious_rc, G_TYPE_OBJECT);
 G_DEFINE_TYPE(MprisRoot, mpris_root, G_TYPE_OBJECT);
 G_DEFINE_TYPE(MprisPlayer, mpris_player, G_TYPE_OBJECT);
-// G_DEFINE_TYPE(MprisTracklist, mpris_tracklist, G_TYPE_OBJECT);
+G_DEFINE_TYPE(MprisTrackList, mpris_tracklist, G_TYPE_OBJECT);
 
 void audacious_rc_class_init(RemoteObjectClass *klass) {}
 void mpris_root_class_init(MprisRootClass *klass) {}
-void mpris_player_class_init(MprisPlayerClass *klass) {}
-// void mpris_tracklist_class_init(MprisTracklistClass *klass) {}
+
+void mpris_player_class_init(MprisPlayerClass *klass) {
+    signals[CAPS_CHANGE_SIG] =
+        g_signal_new("caps_change",
+            G_OBJECT_CLASS_TYPE(klass),
+                G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                0,
+                NULL, NULL,
+                g_cclosure_marshal_VOID__STRING,
+                G_TYPE_NONE, 1, G_TYPE_STRING);
+    signals[TRACK_CHANGE_SIG] =
+        g_signal_new("track_change",
+            G_OBJECT_CLASS_TYPE(klass),
+                G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                0,
+                NULL, NULL,
+                g_cclosure_marshal_VOID__STRING,
+                G_TYPE_NONE, 1, G_TYPE_STRING);
+    signals[STATUS_CHANGE_SIG] =
+        g_signal_new("status_change",
+            G_OBJECT_CLASS_TYPE(klass),
+                G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
+                0,
+                NULL, NULL,
+                g_cclosure_marshal_VOID__STRING,
+                G_TYPE_NONE, 1, G_TYPE_STRING);
+}
+
+void mpris_tracklist_class_init(MprisTrackListClass *klass) {}
 
 void audacious_rc_init(RemoteObject *object) {
     GError *error = NULL;
@@ -105,6 +133,16 @@
                                         G_OBJECT(object));
 }
 
+void mpris_tracklist_init(MprisTrackList *object) {
+    dbus_g_object_type_install_info(mpris_tracklist_get_type(),
+                                    &dbus_glib_mpris_tracklist_object_info);
+    
+    // Register DBUS path
+    dbus_g_connection_register_g_object(dbus_conn,
+                                        AUDACIOUS_DBUS_PATH_MPRIS_TRACKLIST,
+                                        G_OBJECT(object));
+}
+
 void init_dbus() {
     GError *error = NULL;
     // Initialize the DBus connection
@@ -119,19 +157,21 @@
     g_object_new(audacious_rc_get_type(), NULL);
     g_object_new(mpris_root_get_type(), NULL);
     g_object_new(mpris_player_get_type(), NULL);
-    // g_object_new(mpris_tracklist_get_type(), NULL);
+    g_object_new(mpris_tracklist_get_type(), NULL);
     g_message("D-Bus support has been activated");
 }
 
 ///////////////////////////
 // MPRIS defined methods //
 ///////////////////////////
+// MPRIS /
 gboolean mpris_root_identity(MprisRoot *obj, gchar **identity,
                              GError **error) {
     *identity = g_strdup_printf("Audacious %s", VERSION);
     return TRUE;
 }
 
+// MPRIS /Player
 gboolean mpris_player_next(MprisPlayer *obj, GError **error) {
     return audacious_rc_advance(obj, error);
 }
@@ -157,28 +197,79 @@
 }
 gboolean mpris_player_get_status(MprisPlayer *obj, gint *status,
                                  GError **error) {
-    return TRUE;
+    return FALSE;
 }
 gboolean mpris_player_get_caps(MprisPlayer *obj, gint *capabilities,
                                  GError **error) {
-    return TRUE;
+    return FALSE;
 }
 gboolean mpris_player_volume_set(MprisPlayer *obj, gint vol, GError **error) {
-    return TRUE;
+    return FALSE;
 }
 gboolean mpris_player_volume_get(MprisPlayer *obj, gint *vol,
                                  GError **error) {
-    return TRUE;
+    return FALSE;
 }
 gboolean mpris_player_position_set(MprisPlayer *obj, gint pos,
                                    GError **error) {
-    return TRUE;
+    return FALSE;
 }
 gboolean mpris_player_position_get(MprisPlayer *obj, gint *pos,
                                    GError **error) {
+    return FALSE;
+}
+// MPRIS /Player signals
+gboolean mpris_player_emit_caps_change(MprisPlayer *obj, GError **error) {
+    g_signal_emit(obj, signals[CAPS_CHANGE_SIG], 0, "capabilities changed");
     return TRUE;
 }
 
+gboolean mpris_player_emit_track_change(MprisPlayer *obj, GError **error) {
+    g_signal_emit(obj, signals[TRACK_CHANGE_SIG], 0, "track changed");
+    return TRUE;
+}
+
+gboolean mpris_player_emit_status_change(MprisPlayer *obj, GError **error) {
+    g_signal_emit(obj, signals[STATUS_CHANGE_SIG], 0, "status changed");
+    return TRUE;
+}
+
+// MPRIS /TrackList
+gboolean mpris_tracklist_get_metadata(MprisTrackList *obj, gint pos,
+                                      GHashTable *metadata, GError **error) {
+    return FALSE;
+}
+gboolean mpris_tracklist_get_current_track(MprisTrackList *obj, gint *pos,
+                                           GError **error) {
+    return audacious_rc_position(obj, pos, error);
+}
+gboolean mpris_tracklist_get_length(MprisTrackList *obj, gint *pos,
+                                    GError **error) {
+    return FALSE;
+}
+gboolean mpris_tracklist_add_track(MprisTrackList *obj, gchar *uri,
+                                   gboolean play, GError **error) {
+    playlist_add_url(playlist_get_active(), uri);
+    if (play) {
+        int pos = playlist_get_length(playlist_get_active()) - 1;
+        playlist_set_position(playlist_get_active(), pos);
+        playback_initiate();
+    }
+    return TRUE;
+}
+gboolean mpris_tracklist_del_track(MprisTrackList *obj, gint pos,
+                                   GError **error) {
+    return FALSE;
+}
+gboolean mpris_tracklist_loop(MprisTrackList *obj, gboolean loop,
+                              GError **error) {
+    return FALSE;
+}
+gboolean mpris_tracklist_random(MprisTrackList *obj, gboolean random,
+                                GError **error) {
+    return FALSE;
+}
+
 // Audacious General Information
 gboolean audacious_rc_version(RemoteObject *obj, gchar **version,
                               GError **error) {
--- a/src/audacious/mpris_tracklist.xml	Mon May 14 01:10:54 2007 -0700
+++ b/src/audacious/mpris_tracklist.xml	Tue May 15 21:53:37 2007 -0700
@@ -41,7 +41,7 @@
         <method name="Loop">
             <arg type="b" direction="in" />
         </method>
-        <method name="Shuffle">
+        <method name="Random">
             <arg type="b" direction="in" />
         </method>
     </interface>