changeset 2711:c35913222440 trunk

[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
author magma
date Wed, 09 May 2007 14:36:37 -0700
parents 982a825992e1
children aeb4d8da1543
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/dbus.h src/audacious/main.c src/audacious/objects.xml src/audacious/plugin.h src/audacious/pluginenum.c src/libaudaciousng/Makefile src/libaudaciousng/audctrl.c src/libaudaciousng/audctrl.h
diffstat 16 files changed, 631 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed May 09 14:35:33 2007 -0700
+++ b/ChangeLog	Wed May 09 14:36:37 2007 -0700
@@ -1,3 +1,13 @@
+2007-05-09 21:35:33 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [4446]
+  - drop client code
+  
+  trunk/src/libaudacious/Makefile   |    6 
+  trunk/src/libaudacious/beepctrl.c | 1746 --------------------------------------
+  trunk/src/libaudacious/beepctrl.h |  146 ---
+  3 files changed, 2 insertions(+), 1896 deletions(-)
+
+
 2007-05-09 21:03:11 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [4444]
   - drop controlsocket code. this probably does not compile yet.
--- a/configure.ac	Wed May 09 14:35:33 2007 -0700
+++ b/configure.ac	Wed May 09 14:36:37 2007 -0700
@@ -236,9 +236,9 @@
 		AC_DEFINE(DBUS_SERVICES_DIR, "$datadir/dbus-1/services",
 			[Location of D-Bus services directory])
 		DBUS_C=dbus.c
-		DBUS_BINDINGS_H=dbus-bindings.h
+		DBUS_BINDINGS="dbus-server-bindings.h dbus-client-bindings.h"
 		AC_SUBST(DBUS_C)
-		AC_SUBST(DBUS_BINDINGS_H)
+		AC_SUBST(DBUS_BINDINGS)
 		AC_SUBST(USE_DBUS)
 		AC_SUBST(DBUS_CFLAGS)
 		AC_SUBST(DBUS_LIBS)
--- a/mk/rules.mk.in	Wed May 09 14:35:33 2007 -0700
+++ b/mk/rules.mk.in	Wed May 09 14:36:37 2007 -0700
@@ -98,7 +98,7 @@
 DATADIRNAME ?= @DATADIRNAME@
 DCT64 ?= @DCT64@
 DBUS_C ?= @DBUS_C@
-DBUS_BINDINGS_H ?= @DBUS_BINDINGS_H@
+DBUS_BINDINGS ?= @DBUS_BINDINGS@
 DBUS_BINDING_TOOL ?= @DBUS_BINDING_TOOL@
 DBUS_CFLAGS ?= @DBUS_CFLAGS@
 DBUS_LIBS ?= @DBUS_LIBS@
--- a/src/Makefile	Wed May 09 14:35:33 2007 -0700
+++ b/src/Makefile	Wed May 09 14:36:37 2007 -0700
@@ -3,7 +3,7 @@
 include ../mk/rules.mk
 include ../mk/init.mk
 
-SUBDIRS = libaudacious $(INTL_OBJECTIVE) $(SUBDIR_GUESS) audacious audtool libid3tag
+SUBDIRS = $(INTL_OBJECTIVE) $(SUBDIR_GUESS) audacious libaudaciousng audtool libid3tag
 
 include ../mk/objective.mk
 
--- a/src/audacious/Makefile	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/Makefile	Wed May 09 14:36:37 2007 -0700
@@ -5,7 +5,7 @@
 SUBDIRS = widgets glade images ui
 
 OBJECTIVE_BINS = audacious
-OBJECTIVE_LIBS_NOINST += $(DBUS_BINDINGS_H)
+OBJECTIVE_LIBS_NOINST = $(DBUS_BINDINGS)
 
 LDFLAGS += $(AUDLDFLAGS)
 
@@ -35,6 +35,7 @@
 	-I../intl
 
 HEADERS = \
+	dbus.h \
 	formatter.h \
 	rcfile.h \
 	i18n.h \
@@ -57,6 +58,7 @@
 
 SOURCES = \
 	build_stamp.c \
+	controlsocket.c \
 	$(DBUS_C) \
 	dnd.c \
 	dock.c \
@@ -111,7 +113,7 @@
 	visualization.c \
 	xconvert.c
 
-DBUS_BINDINGS = \
+DBUS_BINDINGS_SOURCES = \
 	objects.xml \
 	mpris_root.xml \
 	mpris_tracklist.xml \
@@ -124,17 +126,21 @@
 desktop_DATA = audacious.desktop
 desktopdir = $(datadir)/applications
 
-dbus.o: dbus-bindings.h
+depend: $(DBUS_BINDINGS)
 
 audacious: $(OBJECTS) $(LIBDEP)
 	$(CXX) $(LDFLAGS) $(OBJECTS) $(LDADD) -o $@ 
 	@printf "%10s     %-20s\n" LINK $@
 
-dbus-bindings.h: $(DBUS_BINDINGS)
+dbus-server-bindings.h: $(DBUS_BINDINGS_SOURCES)
 	$(DBUS_BINDING_TOOL) --mode=glib-server --prefix=audacious_remote 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_player mpris_player.xml >> $@
 	@printf "%10s     %-20s\n" DBUS-BIND $@
 
+dbus-client-bindings.h: $(DBUS_BINDINGS_SOURCES)
+	$(DBUS_BINDING_TOOL) --mode=glib-client --prefix=audacious_remote objects.xml > $@
+	@printf "%10s     %-20s\n" DBUS-BIND $@
+
 OBJECTIVE_DATA = audacious.desktop:$(datadir)/applications
--- a/src/audacious/build_stamp.c	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/build_stamp.c	Wed May 09 14:36:37 2007 -0700
@@ -1,2 +1,2 @@
 #include <glib.h>
-const gchar *svn_stamp = "20070509-4444";
+const gchar *svn_stamp = "20070509-4446";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audacious/dbus-service.h	Wed May 09 14:36:37 2007 -0700
@@ -0,0 +1,91 @@
+/*
+ * Audacious: A cross-platform multimedia player
+ * Copyright (c) 2007 Ben Tucker
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef _DBUS_SERVICE_H
+#define _DBUS_SERVICE_H
+
+#include <glib.h>
+
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus-glib.h>
+
+typedef struct {
+    GObject parent;
+    DBusGConnection *connection;
+} RemoteObject;
+
+typedef struct {
+    GObjectClass parent_class;
+} RemoteObjectClass;
+
+void init_dbus();
+void free_dbus();
+DBusGProxy *audacious_get_dbus_proxy();
+
+// Audacious General Information
+gboolean audacious_remote_version(RemoteObject *obj, gchar **version,
+                                  GError **error);
+
+// Playback Information/Manipulation
+gboolean audacious_remote_play(RemoteObject *obj, GError **error);
+gboolean audacious_remote_pause(RemoteObject *obj, GError **error);
+gboolean audacious_remote_stop(RemoteObject *obj, GError **error);
+gboolean audacious_remote_playing(RemoteObject *obj, gboolean *is_playing,
+                                  GError **error);
+gboolean audacious_remote_paused(RemoteObject *obj, gboolean *is_paused,
+                                 GError **error);
+gboolean audacious_remote_stopped(RemoteObject *obj, gboolean *is_stopped,
+                                  GError **error);
+gboolean audacious_remote_status(RemoteObject *obj, gchar **status,
+                                 GError **error);
+gboolean audacious_remote_time(RemoteObject *obj, gint *time, GError **error);
+gboolean audacious_remote_seek(RemoteObject *obj, guint pos, GError **error);
+gboolean audacious_remote_volume(RemoteObject *obj, gint *vl, gint *vr,
+                                 GError **error);
+gboolean audacious_remote_set_volume(RemoteObject *obj, gint vl, gint vr,
+                                     GError **error);
+gboolean audacious_remote_balance(RemoteObject *obj, gint *balance,
+                                  GError **error);
+
+// Playlist Information/Manipulation
+gboolean audacious_remote_position(RemoteObject *obj, int *pos, GError **error);
+gboolean audacious_remote_advance(RemoteObject *obj, GError **error);
+gboolean audacious_remote_reverse(RemoteObject *obj, GError **error);
+gboolean audacious_remote_length(RemoteObject *obj, int *length,
+                                 GError **error);
+gboolean audacious_remote_song_title(RemoteObject *obj, int pos,
+                                     gchar **title, GError **error);
+gboolean audacious_remote_song_filename(RemoteObject *obj, int pos,
+                                        gchar **filename, GError **error);
+gboolean audacious_remote_song_length(RemoteObject *obj, int pos, int *length,
+                                      GError **error);
+gboolean audacious_remote_song_frames(RemoteObject *obj, int pos, int *length,
+                                      GError **error);
+gboolean audacious_remote_jump(RemoteObject *obj, int pos, GError **error);
+gboolean audacious_remote_add_url(RemoteObject *obj, gchar *url,
+                                  GError **error);
+gboolean audacious_remote_delete(RemoteObject *obj, int pos, GError **error);
+gboolean audacious_remote_clear(RemoteObject *obj, GError **error);
+gboolean audacious_remote_repeating(RemoteObject *obj, gboolean *is_repeating,
+                                    GError **error);
+gboolean audacious_remote_repeat(RemoteObject *obj, GError **error);
+gboolean audacious_remote_shuffling(RemoteObject *obj, gboolean *is_shuffling,
+                                    GError **error);
+gboolean audacious_remote_shuffle(RemoteObject *obj, GError **error);
+#endif // !_DBUS_SERVICE_H
--- a/src/audacious/dbus.c	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/dbus.c	Wed May 09 14:36:37 2007 -0700
@@ -24,7 +24,8 @@
 #include <glib.h>
 #include <dbus/dbus-glib-bindings.h>
 #include "dbus.h"
-#include "dbus-bindings.h"
+#include "dbus-service.h"
+#include "dbus-server-bindings.h"
 
 #include "main.h"
 #include "ui_equalizer.h"
@@ -39,13 +40,14 @@
 #include "titlestring.h"
 #include "ui_jumptotrack.h"
 
+static DBusGProxy *dbproxy = NULL;
+
 G_DEFINE_TYPE(RemoteObject, audacious_remote, G_TYPE_OBJECT);
 
 void audacious_remote_class_init(RemoteObjectClass *klass) {}
 
 void audacious_remote_init(RemoteObject *object) {
     GError *error = NULL;
-    DBusGProxy *driver_proxy;
     unsigned int request_ret;
 
     // Initialize the DBus connection
@@ -60,22 +62,20 @@
                                     &dbus_glib_audacious_remote_object_info);
     
     // Register DBUS path
-    dbus_g_connection_register_g_object(object->connection, DBUS_OBJECT_PATH,
-                                        G_OBJECT(object));
+    dbus_g_connection_register_g_object(object->connection,
+                                        AUDACIOUS_DBUS_PATH, G_OBJECT(object));
 
     // Register the service name, the constants here are defined in
     // dbus-glib-bindings.h
-    driver_proxy = dbus_g_proxy_new_for_name(object->connection,
+    dbproxy = dbus_g_proxy_new_for_name(object->connection,
                                              DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
                                              DBUS_INTERFACE_DBUS);
 
-    if (!org_freedesktop_DBus_request_name(driver_proxy, DBUS_SERVICE, 0,
-            &request_ret, &error)) {
+    if (!org_freedesktop_DBus_request_name(dbproxy,
+        AUDACIOUS_DBUS_SERVICE, 0, &request_ret, &error)) {
         g_warning("Unable to register service: %s", error->message);
         g_error_free(error);
     }
-    
-    g_object_unref(driver_proxy);
 }
 
 void init_dbus() {
@@ -83,6 +83,15 @@
     g_object_new(audacious_remote_get_type(), NULL);
 }
 
+void free_dbus() {
+    if (dbproxy != NULL)
+        g_object_unref(dbproxy);
+}
+
+DBusGProxy *audacious_get_dbus_proxy() {
+    return dbproxy;
+}
+
 // Audacious General Information
 gboolean audacious_remote_version(RemoteObject *obj, gchar **version,
                                   GError **error) {
@@ -143,6 +152,14 @@
     return TRUE;
 }
 
+gboolean audacious_remote_time(RemoteObject *obj, gint *time, GError **error) {
+    if (playback_get_playing())
+        *time = playback_get_time();
+    else
+        *time = 0;
+    return TRUE;
+}
+
 gboolean audacious_remote_seek(RemoteObject *obj, guint pos, GError **error) {
     if (playlist_get_current_length(playlist_get_active()) > 0 &&
             pos < (guint)playlist_get_current_length(playlist_get_active()))
@@ -151,6 +168,37 @@
     return TRUE;
 }
 
+gboolean audacious_remote_volume(RemoteObject *obj, gint *vl, gint *vr,
+                                 GError **error) {
+    input_get_volume(vl, vr);
+    return TRUE;
+}
+
+gboolean audacious_remote_set_volume(RemoteObject *obj, gint vl, gint vr,
+                                     GError **error) {
+    if (vl > 100)
+        vl = 100;
+    if (vr > 100)
+        vr = 100;
+    input_set_volume(vl, vr);
+    return TRUE;
+}
+
+gboolean audacious_remote_balance(RemoteObject *obj, gint *balance,
+                                  GError **error) {
+    gint vl, vr;
+    input_get_volume(&vl, &vr);
+    if (vl < 0 || vr < 0)
+        *balance = 0;
+    else if (vl > vr)
+        *balance = -100 + ((vr * 100) / vl);
+    else if (vr > vl)
+        *balance = 100 - ((vl * 100) / vr);
+    else
+        *balance = 0;
+    return TRUE;
+}
+
 // Playlist Information/Manipulation
 gboolean audacious_remote_position(RemoteObject *obj, int *pos, GError **error)
 {
--- a/src/audacious/dbus.h	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/dbus.h	Wed May 09 14:36:37 2007 -0700
@@ -20,66 +20,8 @@
 #ifndef _AUDDBUS_H
 #define _AUDDBUS_H
 
-#include <glib.h>
-
-#define DBUS_API_SUBJECT_TO_CHANGE
-#include <dbus/dbus-glib.h>
-
-#define DBUS_SERVICE "org.atheme.audacious"
-#define DBUS_OBJECT_PATH "/org/atheme/audacious"
-
-typedef struct {
-    GObject parent;
-    DBusGConnection *connection;
-} RemoteObject;
-
-typedef struct {
-    GObjectClass parent_class;
-} RemoteObjectClass;
-
-void init_dbus();
-
-// Audacious General Information
-gboolean audacious_remote_version(RemoteObject *obj, gchar **version,
-                                  GError **error);
+#define AUDACIOUS_DBUS_SERVICE      "org.atheme.audacious"
+#define AUDACIOUS_DBUS_PATH         "/org/atheme/audacious"
+#define AUDACIOUS_DBUS_INTERFACE    "org.atheme.audacious"
 
-// Playback Information/Manipulation
-gboolean audacious_remote_play(RemoteObject *obj, GError **error);
-gboolean audacious_remote_pause(RemoteObject *obj, GError **error);
-gboolean audacious_remote_stop(RemoteObject *obj, GError **error);
-gboolean audacious_remote_playing(RemoteObject *obj, gboolean *is_playing,
-                                  GError **error);
-gboolean audacious_remote_paused(RemoteObject *obj, gboolean *is_paused,
-                                 GError **error);
-gboolean audacious_remote_stopped(RemoteObject *obj, gboolean *is_stopped,
-                                  GError **error);
-gboolean audacious_remote_status(RemoteObject *obj, gchar **status,
-                                 GError **error);
-gboolean audacious_remote_seek(RemoteObject *obj, guint pos, GError **error);
-
-// Playlist Information/Manipulation
-gboolean audacious_remote_position(RemoteObject *obj, int *pos, GError **error);
-gboolean audacious_remote_advance(RemoteObject *obj, GError **error);
-gboolean audacious_remote_reverse(RemoteObject *obj, GError **error);
-gboolean audacious_remote_length(RemoteObject *obj, int *length,
-                                 GError **error);
-gboolean audacious_remote_song_title(RemoteObject *obj, int pos,
-                                     gchar **title, GError **error);
-gboolean audacious_remote_song_filename(RemoteObject *obj, int pos,
-                                        gchar **filename, GError **error);
-gboolean audacious_remote_song_length(RemoteObject *obj, int pos, int *length,
-                                      GError **error);
-gboolean audacious_remote_song_frames(RemoteObject *obj, int pos, int *length,
-                                      GError **error);
-gboolean audacious_remote_jump(RemoteObject *obj, int pos, GError **error);
-gboolean audacious_remote_add_url(RemoteObject *obj, gchar *url,
-                                  GError **error);
-gboolean audacious_remote_delete(RemoteObject *obj, int pos, GError **error);
-gboolean audacious_remote_clear(RemoteObject *obj, GError **error);
-gboolean audacious_remote_repeating(RemoteObject *obj, gboolean *is_repeating,
-                                    GError **error);
-gboolean audacious_remote_repeat(RemoteObject *obj, GError **error);
-gboolean audacious_remote_shuffling(RemoteObject *obj, gboolean *is_shuffling,
-                                    GError **error);
-gboolean audacious_remote_shuffle(RemoteObject *obj, GError **error);
 #endif // !_AUDDBUS_H
--- a/src/audacious/main.c	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/main.c	Wed May 09 14:36:37 2007 -0700
@@ -50,7 +50,7 @@
 #include "vfs.h"
 
 #ifdef USE_DBUS
-#  include "dbus.h"
+#  include "dbus-service.h"
 #endif
 
 #include "dnd.h"
@@ -1252,6 +1252,10 @@
 
         GDK_THREADS_LEAVE();
 
+#ifdef USE_DBUS
+        free_dbus();
+#endif
+
         g_cond_free(cond_scan);
         g_mutex_free(mutex_scan);
 
@@ -1271,6 +1275,10 @@
         g_timeout_add(10, aud_headless_iteration, NULL);
         g_main_loop_run(loop);
 
+#ifdef USE_DBUS
+        free_dbus();
+#endif
+
         return EXIT_SUCCESS;
     }
 }
--- a/src/audacious/objects.xml	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/objects.xml	Wed May 09 14:36:37 2007 -0700
@@ -102,13 +102,19 @@
     <!-- Playback Information/Manipulation -->
     <interface name="org.atheme.audacious.playback">
         <!-- Begin or resume playback -->
-        <method name="Play"/>
+        <method name="Play">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Pause playback -->
-        <method name="Pause"/>
+        <method name="Pause">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Stop playback -->
-        <method name="Stop"/>
+        <method name="Stop">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Is playback playing? -->
         <method name="Playing">
@@ -135,14 +141,44 @@
             <arg type="s" direction="out" name="status"/>
         </method>
 
+        <!-- What is the current output position? -->
+        <method name="Time">
+            <!-- Position of song, in ms -->
+            <arg type="i" direction="out" name="time"/>
+        </method>
+
         <!-- Seek to some absolute position in the current song -->
         <method name="Seek">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
             <!-- Position of song, in ms, to seek to -->
             <arg type="i" name="pos"/>
 
             <!-- Return true on success, or false if position out of range? -->
             <!-- <arg type="b" direction="out"/> -->
         </method>
+
+        <!-- What is the playback volume? -->
+        <method name="Volume">
+            <!-- Volume of the left channel -->
+            <arg type="i" direction="out" name="vl"/>
+            <!-- Volume of the right channel -->
+            <arg type="i" direction="out" name="vr"/>
+        </method>
+
+        <!-- Set the playback volume -->
+        <method name="SetVolume">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+            <!-- Volume of the left channel -->
+            <arg type="i" name="vl"/>
+            <!-- Volume of the right channel -->
+            <arg type="i" name="vr"/>
+        </method>
+
+        <!-- Get the playback balance -->
+        <method name="Balance">
+            <!-- Balance between left and right channels -->
+            <arg type="i" direction="out" name="balance"/>
+        </method>
     </interface>
 
     <!-- Playlist Information/Manipulation -->
@@ -154,10 +190,14 @@
         </method>
 
         <!-- Skip ahead one song in the current playlist -->
-        <method name="Advance"/>
+        <method name="Advance">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Skip backwards one song in the current playlist -->
-        <method name="Reverse"/>
+        <method name="Reverse">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Playlist length -->
         <method name="Length">
@@ -203,24 +243,29 @@
 
         <!-- Jump to some position in the playlist -->
         <method name="Jump">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
             <!-- Song position to jump to -->
             <arg type="i" name="pos"/>
         </method>
 
         <!-- Add some URL to the current playlist -->
         <method name="AddUrl">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
             <!-- URL to add -->
             <arg type="s" name="url"/>
         </method>
 
         <!-- Delete some song from the playlist -->
         <method name="Delete">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
             <!-- Position of song to delete -->
             <arg type="i" name="pos"/>
         </method>
 
         <!-- Clear the playlist -->
-        <method name="Clear"/>
+        <method name="Clear">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Query repeat status -->
         <method name="Repeating">
@@ -228,7 +273,9 @@
         </method>
 
         <!-- Toggle repeat -->
-        <method name="Repeat"/>
+        <method name="Repeat">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
 
         <!-- Query shuffle status -->
         <method name="Shuffling">
@@ -236,6 +283,8 @@
         </method>
 
         <!-- Toggle shuffle -->
-        <method name="Shuffle"/>
+        <method name="Shuffle">
+            <annotation name="org.freedesktop.DBus.GLib.NoReply" value=""/>
+        </method>
     </interface>
 </node>
--- a/src/audacious/plugin.h	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/plugin.h	Wed May 09 14:36:37 2007 -0700
@@ -37,11 +37,18 @@
 #ifndef BMP_PLUGIN_H
 #define BMP_PLUGIN_H
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
 
 #include <glib.h>
 #include "audacious/vfs.h"
 #include "audacious/titlestring.h"
 
+#ifdef USE_DBUS
+#include <dbus/dbus-glib.h>
+#endif
+
 #define INPUT_PLUGIN(x)   ((InputPlugin *)(x))
 #define OUTPUT_PLUGIN(x)  ((OutputPlugin *)(x))
 #define EFFECT_PLUGIN(x)  ((EffectPlugin *)(x))
@@ -214,6 +221,9 @@
     gchar *filename;
 
     gint xmms_session;
+#ifdef USE_DBUS
+    DBusGProxy *dbus_proxy;
+#endif
     gchar *description;
 
     void (*init) (void);
@@ -227,6 +237,9 @@
     gchar *filename;
 
     gint xmms_session;
+#ifdef USE_DBUS
+    DBusGProxy *dbus_proxy;
+#endif
     gchar *description;
 
     gint num_pcm_chs_wanted;
--- a/src/audacious/pluginenum.c	Wed May 09 14:35:33 2007 -0700
+++ b/src/audacious/pluginenum.c	Wed May 09 14:36:37 2007 -0700
@@ -36,6 +36,11 @@
 #include <glib/gprintf.h>
 #include <string.h>
 
+
+#ifdef USE_DBUS
+#include "dbus-service.h"
+#endif
+
 #include "main.h"
 #include "ui_main.h"
 #include "playback.h"
@@ -173,6 +178,9 @@
 {
     GeneralPlugin *p = GENERAL_PLUGIN(plugin);
     p->xmms_session = -1;
+#ifdef USE_DBUS
+    p->dbus_proxy = audacious_get_dbus_proxy();
+#endif
     gp_data.general_list = g_list_append(gp_data.general_list, p);
 }
 
@@ -181,6 +189,9 @@
 {
     VisPlugin *p = VIS_PLUGIN(plugin);
     p->xmms_session = -1;
+#ifdef USE_DBUS
+    p->dbus_proxy = audacious_get_dbus_proxy();
+#endif
     p->disable_plugin = vis_disable_plugin;
     vp_data.vis_list = g_list_append(vp_data.vis_list, p);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libaudaciousng/Makefile	Wed May 09 14:36:37 2007 -0700
@@ -0,0 +1,42 @@
+include ../../mk/rules.mk
+include ../../mk/init.mk
+
+PICLDFLAGS = $(LIBLDFLAGS)
+
+OBJECTIVE_LIBS = libaudaciousng$(SHARED_SUFFIX)
+OBJECTIVE_SONAME_SUFFIX = 1
+LIBAUDACIOUS_SUFFIX = 1.0.0
+
+LIBADD = \
+	$(GTK_LIBS) \
+	$(DBUS_LIBS) \
+	$(MOWGLI_LIBS) \
+	$(GCONF_LIBS) \
+	$(LIBMCS_LIBS)
+
+CFLAGS += $(PICFLAGS) \
+	$(MOWGLI_CFLAGS) \
+	$(GTK_CFLAGS) \
+	$(GCONF_CFLAGS) \
+	$(DBUS_CFLAGS) \
+	$(LIBMCS_CFLAGS) \
+	-D_AUDACIOUS_CORE \
+	-I.. -I../.. \
+	-I../intl
+
+SOURCES = \
+	audctrl.c
+
+OBJECTS = ${SOURCES:.c=.o}
+
+HEADERS = \
+	audctrl.h
+
+include ../../mk/objective.mk
+
+install-posthook:
+	@mv ${DESTDIR}/${LIBDIR}/libaudaciousng$(SHARED_SUFFIX) ${DESTDIR}/${LIBDIR}/libaudaciousng$(SHARED_SUFFIX).$(LIBAUDACIOUS_SUFFIX)
+	@ln -sf libaudaciousng$(SHARED_SUFFIX).$(LIBAUDACIOUS_SUFFIX) \
+		${DESTDIR}/${LIBDIR}/libaudaciousng$(SHARED_SUFFIX).5
+	@ln -sf libaudaciousng$(SHARED_SUFFIX).5 \
+		${DESTDIR}/${LIBDIR}/libaudaciousng$(SHARED_SUFFIX)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libaudaciousng/audctrl.c	Wed May 09 14:36:37 2007 -0700
@@ -0,0 +1,193 @@
+/*
+ * Audacious: A cross-platform multimedia player
+ * Copyright (c) 2007 Ben Tucker
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#    include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include "audacious/dbus.h"
+#include "audacious/dbus-client-bindings.h"
+#include "audctrl.h"
+
+GError *error = NULL;
+
+void audacious_remote_playlist(DBusGProxy *proxy, gchar **list, gint num,
+                               gboolean enqueue) {
+}
+
+gint audacious_remote_get_version(DBusGProxy *proxy) {
+    return 0;
+}
+
+void audacious_remote_playlist_add(DBusGProxy *proxy, GList *list) {
+}
+
+void audacious_remote_playlist_delete(DBusGProxy *proxy, gint pos) {
+}
+
+void audacious_remote_play(DBusGProxy *proxy) {
+    org_atheme_audacious_playback_play(proxy, &error);
+    g_error_free(error);
+}
+
+void audacious_remote_pause(DBusGProxy *proxy) {
+    org_atheme_audacious_playback_pause(proxy, &error);
+    g_error_free(error);
+}
+
+void audacious_remote_stop(DBusGProxy *proxy) {
+    org_atheme_audacious_playback_stop(proxy, &error);
+    g_error_free(error);
+}
+
+gboolean audacious_remote_is_playing(DBusGProxy *proxy) {
+    gboolean is_playing;
+    org_atheme_audacious_playback_playing(proxy, &is_playing, &error);
+    g_error_free(error);
+    return is_playing;
+}
+
+gboolean audacious_remote_is_paused(DBusGProxy *proxy) {
+    gboolean is_paused;
+    org_atheme_audacious_playback_paused(proxy, &is_paused, &error);
+    g_error_free(error);
+    return is_paused;
+}
+
+gint audacious_remote_get_playlist_pos(DBusGProxy *proxy) {
+    gint pos;
+    org_atheme_audacious_playlist_position(proxy, &pos, &error);
+    g_error_free(error);
+    return pos;
+}
+
+void audacious_remote_set_playlist_pos(DBusGProxy *proxy, gint pos) {
+}
+
+gint audacious_remote_get_playlist_length(DBusGProxy *proxy) {
+    gint len;
+    org_atheme_audacious_playlist_length(proxy, &len, &error);
+    g_error_free(error);
+    return len;
+}
+
+void audacious_remote_playlist_clear(DBusGProxy *proxy) {
+    org_atheme_audacious_playlist_clear(proxy, &error);
+    g_error_free(error);
+}
+
+gint audacious_remote_get_output_time(DBusGProxy *proxy) {
+    gint time;
+    org_atheme_audacious_playback_time(proxy, &time, &error);
+    g_error_free(error);
+    return time;
+}
+
+void audacious_remote_jump_to_time(DBusGProxy *proxy, gint pos) {
+}
+
+/**
+ * audacious_remote_get_volume:
+ * @proxy: DBus proxy for audacious
+ * @vl: Pointer to integer containing the left channel's volume.
+ * @vr: Pointer to integer containing the right channel's volume.
+ *
+ * Queries audacious about the current volume.
+ **/
+void audacious_remote_get_volume(DBusGProxy *proxy, gint * vl, gint * vr) {
+    org_atheme_audacious_playback_volume(proxy, vl, vr, &error);
+    g_error_free(error);
+}
+
+/**
+ * audacious_remote_get_main_volume:
+ * @proxy: DBus proxy for audacious
+ *
+ * Queries audacious about the current volume.
+ *
+ * Return value: The current volume.
+ **/
+gint audacious_remote_get_main_volume(DBusGProxy *proxy) {
+    gint vl, vr;
+
+    audacious_remote_get_volume(proxy, &vl, &vr);
+
+    return (vl > vr) ? vl : vr;
+}
+
+/**
+ * audacious_remote_set_volume:
+ * @proxy: DBus proxy for audacious
+ * @vl: The volume for the left channel.
+ * @vr: The volume for the right channel.
+ *
+ * Sets the volume for the left and right channels in Audacious.
+ **/
+void audacious_remote_set_volume(DBusGProxy *proxy, gint vl, gint vr) {
+    org_atheme_audacious_playback_set_volume(proxy, vl, vr,  &error);
+    g_error_free(error);
+}
+
+
+/**
+ * audacious_remote_set_main_volume:
+ * @proxy: DBus proxy for audacious
+ * @v: The volume to set.
+ *
+ * Sets the volume in Audacious.
+ **/
+void audacious_remote_set_main_volume(DBusGProxy *proxy, gint v) {
+    gint b, vl, vr;
+
+    b = audacious_remote_get_balance(proxy);
+
+    if (b < 0) {
+        vl = v;
+        vr = (v * (100 - abs(b))) / 100;
+    } else if (b > 0) {
+        vl = (v * (100 - b)) / 100;
+        vr = v;
+    } else
+        vl = vr = v;
+    audacious_remote_set_volume(proxy, vl, vr);
+}
+
+/**
+ * audacious_remote_get_balance:
+ * @proxy: DBus proxy for audacious
+ *
+ * Queries audacious about the current balance.
+ *
+ * Return value: The current balance.
+ **/
+gint audacious_remote_get_balance(DBusGProxy *proxy) {
+    gint balance;
+    org_atheme_audacious_playback_balance(proxy, &balance,  &error);
+    g_error_free(error);
+    return balance;
+}
+
+void audacious_remote_playlist_add_url_string(DBusGProxy *proxy,
+                                              gchar *string) {
+    org_atheme_audacious_playlist_add_url(proxy, string, &error);
+    g_error_free(error);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libaudaciousng/audctrl.h	Wed May 09 14:36:37 2007 -0700
@@ -0,0 +1,130 @@
+/*  Audacious - Cross-platform multimedia player
+ *  Copyright (DBusGProxy *proxy, C) 2005-2007  Audacious development team
+ *
+ *  Based on XMMS:
+ *  Copyright (DBusGProxy *proxy, C) 1998-2003  Peter Alm, Mikael Alm, Olle Hallnas,
+ *                           Thomas Nilsson and 4Front Technologies
+ *  Copyright (DBusGProxy *proxy, C) 1999-2003  Haavard Kvaalen
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; under version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#ifndef _AUDCTRL_H
+#define _AUDCTRL_H
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+    void audacious_remote_playlist(DBusGProxy *proxy, gchar **list, gint num,
+                                   gboolean enqueue);
+    gint audacious_remote_get_version(DBusGProxy *proxy);
+    void audacious_remote_playlist_add(DBusGProxy *proxy, GList *list);
+    void audacious_remote_playlist_delete(DBusGProxy *proxy, gint pos);
+    void audacious_remote_play(DBusGProxy *proxy);
+    void audacious_remote_pause(DBusGProxy *proxy);
+    void audacious_remote_stop(DBusGProxy *proxy);
+    gboolean audacious_remote_is_playing(DBusGProxy *proxy);
+    gboolean audacious_remote_is_paused(DBusGProxy *proxy);
+    gint audacious_remote_get_playlist_pos(DBusGProxy *proxy);
+    void audacious_remote_set_playlist_pos(DBusGProxy *proxy, gint pos);
+    gint audacious_remote_get_playlist_length(DBusGProxy *proxy);
+    void audacious_remote_playlist_clear(DBusGProxy *proxy);
+    gint audacious_remote_get_output_time(DBusGProxy *proxy);
+    void audacious_remote_jump_to_time(DBusGProxy *proxy, gint pos);
+    void audacious_remote_get_volume(DBusGProxy *proxy, gint *vl, gint *vr);
+    gint audacious_remote_get_main_volume(DBusGProxy *proxy);
+    gint audacious_remote_get_balance(DBusGProxy *proxy);
+    void audacious_remote_set_volume(DBusGProxy *proxy, gint vl, gint vr);
+    void audacious_remote_set_main_volume(DBusGProxy *proxy, gint v);
+    void audacious_remote_set_balance(DBusGProxy *proxy, gint b);
+    gchar *audacious_remote_get_skin(DBusGProxy *proxy);
+    void audacious_remote_set_skin(DBusGProxy *proxy, gchar *skinfile);
+    gchar *audacious_remote_get_playlist_file(DBusGProxy *proxy, gint pos);
+    gchar *audacious_remote_get_playlist_title(DBusGProxy *proxy, gint pos);
+    gint audacious_remote_get_playlist_time(DBusGProxy *proxy, gint pos);
+    void audacious_remote_get_info(DBusGProxy *proxy, gint *rate, gint *freq,
+                                   gint *nch);
+    void audacious_remote_main_win_toggle(DBusGProxy *proxy, gboolean show);
+    void audacious_remote_pl_win_toggle(DBusGProxy *proxy, gboolean show);
+    void audacious_remote_eq_win_toggle(DBusGProxy *proxy, gboolean show);
+    gboolean audacious_remote_is_main_win(DBusGProxy *proxy);
+    gboolean audacious_remote_is_pl_win(DBusGProxy *proxy);
+    gboolean audacious_remote_is_eq_win(DBusGProxy *proxy);
+    void audacious_remote_show_prefs_box(DBusGProxy *proxy);
+    void audacious_remote_toggle_aot(DBusGProxy *proxy, gboolean ontop);
+    void audacious_remote_eject(DBusGProxy *proxy);
+    void audacious_remote_playlist_prev(DBusGProxy *proxy);
+    void audacious_remote_playlist_next(DBusGProxy *proxy);
+    void audacious_remote_playlist_add_url_string(DBusGProxy *proxy,
+                                                  gchar *string);
+    gboolean audacious_remote_is_running(DBusGProxy *proxy);
+    void audacious_remote_toggle_repeat(DBusGProxy *proxy);
+    void audacious_remote_toggle_shuffle(DBusGProxy *proxy);
+    gboolean audacious_remote_is_repeat(DBusGProxy *proxy);
+    gboolean audacious_remote_is_shuffle(DBusGProxy *proxy);
+    void audacious_remote_get_eq(DBusGProxy *proxy, gfloat *preamp,
+                                 gfloat **bands);
+    gfloat audacious_remote_get_eq_preamp(DBusGProxy *proxy);
+    gfloat audacious_remote_get_eq_band(DBusGProxy *proxy, gint band);
+    void audacious_remote_set_eq(DBusGProxy *proxy, gfloat preamp,
+                                 gfloat *bands);
+    void audacious_remote_set_eq_preamp(DBusGProxy *proxy, gfloat preamp);
+    void audacious_remote_set_eq_band(DBusGProxy *proxy, gint band,
+                                      gfloat value);
+
+/* Added in XMMS 1.2.1 */
+    void audacious_remote_quit(DBusGProxy *proxy);
+
+/* Added in XMMS 1.2.6 */
+    void audacious_remote_play_pause(DBusGProxy *proxy);
+    void audacious_remote_playlist_ins_url_string(DBusGProxy *proxy,
+                                                  gchar *string, gint pos);
+
+/* Added in XMMS 1.2.11 */
+    void audacious_remote_playqueue_add(DBusGProxy *proxy, gint pos);
+    void audacious_remote_playqueue_remove(DBusGProxy *proxy, gint pos);
+    gint audacious_remote_get_playqueue_length(DBusGProxy *proxy);
+    void audacious_remote_toggle_advance(DBusGProxy *proxy);
+    gboolean audacious_remote_is_advance(DBusGProxy *proxy);
+
+/* Added in BMP 0.9.7 */
+    void audacious_remote_activate(DBusGProxy *proxy);
+
+/* Added in Audacious 1.1 */
+    void audacious_remote_show_jtf_box(DBusGProxy *proxy);
+    void audacious_remote_playqueue_clear(DBusGProxy *proxy);
+    gboolean audacious_remote_playqueue_is_queued(DBusGProxy *proxy, gint pos);
+    gint audacious_remote_get_playqueue_position(DBusGProxy *proxy, gint pos);
+    gint audacious_remote_get_playqueue_queue_position(DBusGProxy *proxy,
+                                                       gint pos);
+
+/* Added in Audacious 1.2 */
+    void audacious_set_session_uri(DBusGProxy *proxy, gchar *uri);
+    gchar *audacious_get_session_uri(DBusGProxy *proxy);
+    void audacious_set_session_type(DBusGProxy *proxy, gint type);
+
+/* Added in Audacious 1.3 */
+    void audacious_remote_playlist_enqueue_to_temp(DBusGProxy *proxy,
+                                                   gchar *string);
+    gchar *audacious_get_tuple_field_data(DBusGProxy *proxy, gchar *field,
+                                          gint pos);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif