aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac3
-rw-r--r--src/Makefile.am12
-rw-r--r--src/music-bridge.vala93
-rw-r--r--src/music-player-bridge.vala89
-rw-r--r--src/sound-service.c6
5 files changed, 99 insertions, 104 deletions
diff --git a/configure.ac b/configure.ac
index b751fb2..0abf6c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,7 +52,8 @@ AC_SUBST(PULSEAUDIO_LIBS)
PKG_CHECK_MODULES(SOUNDSERVICE, dbusmenu-glib >= $DBUSMENUGLIB_REQUIRED_VERSION
indicator >= $INDICATOR_REQUIRED_VERSION
- indicate >= $INDICATOR_REQUIRED_VERSION)
+ indicate >= $INDICATOR_REQUIRED_VERSION
+ gee-1.0)
AC_SUBST(SOUNDSERVICE_CFLAGS)
AC_SUBST(SOUNDERVICE_LIBS)
diff --git a/src/Makefile.am b/src/Makefile.am
index 12db62c..a1ecece 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,25 +47,23 @@ sound-service-server.h: $(srcdir)/sound-service.xml
# libsoundmenu vala
#####################
music_bridge_VALASOURCES = \
- music-bridge.vala \
- rhythmbox-controller.vala
+ music-player-bridge.vala
music_bridge_VALAFLAGS = \
--ccode \
- -H music-bridge.h -d . \
+ -H music-player-bridge.h -d . \
--library music-bridge \
--vapidir=./ \
- --vapidir=$(abs_top_builddir)/vapi/ \
--thread \
--pkg gee-1.0 \
- --pkg indicate \
- --pkg DbusmenuGlib-0.2 \
+ --pkg Indicate-0.2 \
+ --pkg Dbusmenu-Glib-0.2 \
--pkg dbus-glib-1
$(MAINTAINER_VALAFLAGS)
music_bridge_APIFILES = \
- music-bridge.h
+ music-player-bridge.h
music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES)
$(AM_V_GEN) $(VALAC) $(music_bridge_VALAFLAGS) $^
diff --git a/src/music-bridge.vala b/src/music-bridge.vala
deleted file mode 100644
index e0900ba..0000000
--- a/src/music-bridge.vala
+++ /dev/null
@@ -1,93 +0,0 @@
-using Indicate;
-using DbusmenuGlib;
-using DbusmenuMenuitem;
-//using Gee;
-
-public class BridgeServer : GLib.Object
-{
-
- private Listener listener;
- private DbusmenuMenuitem root_menu;
- //private HashMap<string, DbusmenuMenuitem> registered_clients;
-
- public BridgeServer()
- {
- //registered_clients = new HashMap<string, DbusmenuMenuitem> ();
- root_menu = null;
- listener = Listener.ref_default();
- listener.indicator_added.connect(on_indicator_added);
- listener.indicator_removed.connect(on_indicator_removed);
- listener.indicator_modified.connect(on_indicator_modified);
- listener.server_added.connect(on_server_added);
- listener.server_removed.connect(on_server_removed);
- listener.server_count_changed.connect(on_server_count_changed);
- }
-
- public void set_root_menu_item(DbusmenuMenuitem menu)
- {
- debug("BridgeServer -> set_root_menu_item");
- root_menu = menu;
- }
-
- public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
- {
- debug("BridgerServer -> on_indicator_added");
- }
-
- public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
- {
- debug("BridgeServer -> on_indicator_removed");
- }
-
- public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s)
- {
- debug("BridgeServer -> indicator_modified with vale %s", s );
- }
-
- public void on_server_added(Indicate.ListenerServer object, string type)
- {
- debug("BridgeServer -> on_server_added with value %s", type);
- if (type == null) return;
- if (type.contains("music") == false) {
- debug("server is of no interest, it is not an music server");
- return;
- }
- else {
- debug("client of type %s has registered with us", type);
- if (root_menu != null){
- debug("Just about to create the registration menu item");
- DbusmenuMenuitem client_item = new DbusmenuMenuitem();
- string client_name = type.split(".")[1];
- client_item.property_set(DBUSMENU_MENUITEM_PROP_LABEL, client_name.concat(" is registered"));
- //registered_clients.set(client_name, client_item);
- root_menu.child_append(client_item);
- }
- }
- }
-
- public void on_server_removed(Indicate.ListenerServer object, string s)
- {
- debug("BridgeServer -> on_server_removed with value %s", s);
- }
-
- public void on_server_count_changed(Indicate.ListenerServer object, uint i)
- {
- debug("BridgeServer -> on_server_count_changed with value %u", i);
- }
-
-}
-
-
-//public void main (string[] args) {
-
-// // Creating a GLib main loop with a default context
-// var loop = new MainLoop(null, false);
-
-// BridgeServer server = new BridgeServer();
-
-// // Start GLib mainloop
-// loop.run();
-//}
-
-
-
diff --git a/src/music-player-bridge.vala b/src/music-player-bridge.vala
new file mode 100644
index 0000000..c2cfc7a
--- /dev/null
+++ b/src/music-player-bridge.vala
@@ -0,0 +1,89 @@
+using Indicate;
+using Dbusmenu;
+using Gee;
+
+public class MusicPlayerBridge : GLib.Object
+{
+
+ private Listener listener;
+ private Dbusmenu.Menuitem root_menu;
+ private HashMap<string, Dbusmenu.Menuitem> registered_clients;
+
+ public MusicPlayerBridge()
+ {
+ registered_clients = new HashMap<string, Dbusmenu.Menuitem> ();
+ listener = Listener.ref_default();
+ listener.indicator_added.connect(on_indicator_added);
+ listener.indicator_removed.connect(on_indicator_removed);
+ listener.indicator_modified.connect(on_indicator_modified);
+ listener.server_added.connect(on_server_added);
+ listener.server_removed.connect(on_server_removed);
+ listener.server_count_changed.connect(on_server_count_changed);
+ }
+
+ public void set_root_menu_item(Dbusmenu.Menuitem menu)
+ {
+ debug("MusicPlayerBridge -> set_root_menu_item");
+ root_menu = menu;
+ }
+
+ public void on_indicator_added(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
+ {
+ debug("MusicPlayerBridge-> on_indicator_added");
+ }
+
+ public void on_indicator_removed(Indicate.ListenerServer object, Indicate.ListenerIndicator p0)
+ {
+ debug("MusicPlayerBridge -> on_indicator_removed");
+ }
+
+ public void on_indicator_modified(Indicate.ListenerServer object, Indicate.ListenerIndicator p0, string s)
+ {
+ debug("MusicPlayerBridge -> indicator_modified with vale %s", s );
+ }
+
+ public void on_server_added(Indicate.ListenerServer object, string type)
+ {
+ debug("MusicPlayerBridge -> on_server_added with value %s", type);
+ if(server_is_not_of_interest(type)) return;
+ string client_name = type.split(".")[1];
+ if (root_menu != null && client_name != null){
+ Dbusmenu.Menuitem client_item = new Dbusmenu.Menuitem();
+ client_item.property_set(MENUITEM_PROP_LABEL, client_name.concat(" is registered"));
+ registered_clients.set(client_name, client_item);
+ root_menu.child_append(client_item);
+ debug("client of name %s has successfully registered with us", client_name);
+ }
+ }
+
+ public void on_server_removed(Indicate.ListenerServer object, string type)
+ {
+ debug("MusicPlayerBridge -> on_server_removed with value %s", type);
+ if(server_is_not_of_interest(type)) return;
+ string client_name = type.split(".")[1];
+ if (root_menu != null && client_name != null){
+ root_menu.child_delete(registered_clients[client_name]);
+ registered_clients.remove(client_name);
+ debug("Successively removed menu_item for client %s from registered_clients", client_name);
+ }
+ }
+
+ private bool server_is_not_of_interest(string type){
+ if (type == null) return true;
+ if (type.contains("music") == false) {
+ debug("server is of no interest, it is not an music server");
+ return true;
+ }
+ return false;
+ }
+
+ public void on_server_count_changed(Indicate.ListenerServer object, uint i)
+ {
+ debug("MusicPlayerBridge-> on_server_count_changed with value %u", i);
+ }
+
+}
+
+
+
+
diff --git a/src/sound-service.c b/src/sound-service.c
index db48676..84ad7f1 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -23,7 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sound-service.h"
#include "dbus-menu-manager.h"
#include "pulse-manager.h"
-#include "music-bridge.h"
+#include "music-player-bridge.h"
static GMainLoop *mainloop = NULL;
@@ -71,8 +71,8 @@ main (int argc, char ** argv)
G_CALLBACK(service_shutdown), NULL);
DbusmenuMenuitem* root_menuitem = dbus_menu_manager_setup();
- BridgeServer* server = bridge_server_new();
- bridge_server_set_root_menu_item(server, root_menuitem);
+ MusicPlayerBridge* server = music_player_bridge_new();
+ music_player_bridge_set_root_menu_item(server, root_menuitem);
// Run the loop
mainloop = g_main_loop_new(NULL, FALSE);