aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--src/Makefile.am56
-rw-r--r--src/device.c276
-rw-r--r--src/device.h84
-rw-r--r--src/sound-service-dbus.c489
-rw-r--r--src/sound-service-dbus.h66
-rw-r--r--src/sound-service.c127
-rw-r--r--src/sound-service.h35
-rw-r--r--src/sound-service.xml34
9 files changed, 1 insertions, 1167 deletions
diff --git a/configure.ac b/configure.ac
index 119a4f4..ee5ff2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,4 @@
AC_INIT([indicator-sound],[12.10.1],[conor.curran@canonical.com])
-AC_CONFIG_SRCDIR([src/sound-service.c])
AM_INIT_AUTOMAKE([check-news])
AC_CONFIG_HEADERS([config.h])
diff --git a/src/Makefile.am b/src/Makefile.am
index 1de360c..993b0d2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,10 +1,5 @@
libexec_PROGRAMS = indicator-sound-service
-checkxml: $(srcdir)/sound-service.xml
- @xmllint -valid -noout $<
- @echo $< checks out ok
-
-
####################################################################
# Sound Service
####################################################################
@@ -22,19 +17,9 @@ music_bridge_VALASOURCES = \
volume-control.vala \
media-player.vala \
media-player-list.vala \
- music-player-bridge.vala \
- transport-menu-item.vala \
- specific-items-manager.vala \
- metadata-menu-item.vala \
- player-controller.vala \
mpris2-interfaces.vala \
mpris2-watcher.vala \
- mpris2-controller.vala \
- player-item.vala \
- settings-manager.vala \
- playlists-menu-item.vala \
- freedesktop-interfaces.vala \
- fetch-file.vala
+ freedesktop-interfaces.vala
music_bridge_VALAFLAGS = \
--ccode \
@@ -52,7 +37,6 @@ music_bridge_VALAFLAGS = \
--pkg libxml-2.0 \
--pkg libpulse \
--pkg libpulse-mainloop-glib \
- --pkg pulseaudio-mgr \
--target-glib=2.36
$(MAINTAINER_VALAFLAGS)
@@ -69,24 +53,6 @@ music_bridge_vala.stamp $(music_bridge_APIFILES): $(music_bridge_VALASOURCES)
###############################
indicator_sound_service_SOURCES = \
common-defs.h \
- sound-state.c \
- sound-state.h \
- pulseaudio-mgr.h \
- pulseaudio-mgr.c \
- device.c \
- device.h \
- sound-service-dbus.h \
- sound-service-dbus.c \
- slider-menu-item.h \
- slider-menu-item.c \
- voip-input-menu-item.h \
- voip-input-menu-item.c \
- mute-menu-item.h \
- mute-menu-item.c \
- gen-sound-service.xml.h \
- gen-sound-service.xml.c \
- sound-service-marshal.c \
- sound-service-marshal.h \
$(music_bridge_VALASOURCES:.vala=.c)
indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) \
@@ -97,26 +63,8 @@ indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) \
indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS)
indicator_sound_service_LDFLAGS = $(COVERAGE_LDFLAGS)
-#########################
-# Service xml compilation
-#########################
-DBUS_SPECS = \
- sound-service.xml
-
-gen-%.xml.h: %.xml
- @echo "Building $@ from $<"
- @echo "extern const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<))));" > $@
-
-gen-%.xml.c: %.xml
- @echo "Building $@ from $<"
- @echo "const char * _$(subst -,_,$(subst .,_,$(basename $(notdir $<)))) = " > $@
- @sed -e "s:\":\\\\\":g" -e s:^:\": -e s:\$$:\\\\n\": $< >> $@
- @echo ";" >> $@
-
-
EXTRA_DIST = \
$(DBUS_SPECS) \
- sound-service.xml \
$(music_bridge_APIFILES) \
$(music_bridge_VALASOURCES)
@@ -126,8 +74,6 @@ EXTRA_DIST = \
BUILT_SOURCES = \
music_bridge_vala.stamp \
$(music_bridge_APIFILES) \
- gen-sound-service.xml.h \
- gen-sound-service.xml.c \
$(music_bridge_VALASOURCES:.vala=.c)
CLEANFILES = \
diff --git a/src/device.c b/src/device.c
deleted file mode 100644
index 84db596..0000000
--- a/src/device.c
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
-Copyright 2011 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
-*/
-#include <libdbusmenu-glib/menuitem.h>
-
-#include "device.h"
-#include "slider-menu-item.h"
-#include "mute-menu-item.h"
-#include "voip-input-menu-item.h"
-#include "pulseaudio-mgr.h"
-#include "sound-state.h"
-
-typedef struct _DevicePrivate DevicePrivate;
-
-struct _DevicePrivate
-{
- SliderMenuItem* volume_slider_menuitem;
- MuteMenuItem* mute_menuitem;
- VoipInputMenuItem* voip_input_menu_item;
- SoundState current_sound_state;
- SoundServiceDbus* service;
-};
-
-#define DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DEVICE_TYPE, DevicePrivate))
-
-/* Prototypes */
-static void device_class_init (DeviceClass *klass);
-static void device_init (Device *self);
-static void device_dispose (GObject *object);
-static void device_finalize (GObject *object);
-
-static SoundState device_get_state_from_volume (Device* self);
-static void device_mute_update (Device* self, gboolean muted);
-
-G_DEFINE_TYPE (Device, device, G_TYPE_OBJECT);
-
-static void
-device_class_init (DeviceClass *klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (DevicePrivate));
-
- gobject_class->dispose = device_dispose;
- gobject_class->finalize = device_finalize;
-}
-
-static void
-device_init (Device *self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- priv->mute_menuitem = NULL;
- priv->volume_slider_menuitem = NULL;
- priv->voip_input_menu_item = NULL;
- priv->current_sound_state = UNAVAILABLE;
- priv->service = NULL;
-
- // Init our menu items.
- priv->mute_menuitem = g_object_new (MUTE_MENU_ITEM_TYPE, NULL);
- priv->voip_input_menu_item = g_object_new (VOIP_INPUT_MENU_ITEM_TYPE, NULL);;
- priv->volume_slider_menuitem = slider_menu_item_new (self);
- mute_menu_item_enable (priv->mute_menuitem, FALSE);
- slider_menu_item_enable (priv->volume_slider_menuitem, FALSE);
-}
-
-static void
-device_dispose (GObject *object)
-{
- G_OBJECT_CLASS (device_parent_class)->dispose (object);
-}
-
-static void
-device_finalize (GObject *object)
-{
- G_OBJECT_CLASS (device_parent_class)->finalize (object);
-}
-
-void
-device_sink_populate (Device* self,
- const pa_sink_info* update)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
- mute_menu_item_enable (priv->mute_menuitem, TRUE);
- slider_menu_item_populate (priv->volume_slider_menuitem, update);
- SoundState state = device_get_state_from_volume (self);
- if (priv->current_sound_state != state){
- priv->current_sound_state = state;
- sound_service_dbus_update_sound_state (priv->service,
- priv->current_sound_state);
- }
- device_mute_update (self, update->mute);
-}
-
-void
-device_sink_update (Device* self,
- const pa_sink_info* update)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- slider_menu_item_update (priv->volume_slider_menuitem, update);
-
- SoundState state = device_get_state_from_volume (self);
- if (priv->current_sound_state != state){
- priv->current_sound_state = state;
- sound_service_dbus_update_sound_state (priv->service,
- priv->current_sound_state);
- }
-
- device_mute_update (self, update->mute);
-}
-
-gint
-device_get_voip_source_output_index (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return voip_input_menu_item_get_source_output_index (priv->voip_input_menu_item);
-}
-
-static void
-device_mute_update (Device* self, gboolean muted)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- mute_menu_item_update (priv->mute_menuitem, muted);
- SoundState state = device_get_state_from_volume (self);
-
- if (muted == TRUE){
- state = MUTED;
- }
- // Only send signals if something has changed
- if (priv->current_sound_state != state){
- priv->current_sound_state = state;
- sound_service_dbus_update_sound_state (priv->service, state);
- }
-}
-
-void
-device_ensure_sink_is_unmuted (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- if (mute_menu_item_is_muted (priv->mute_menuitem)){
- pm_update_mute (FALSE);
- }
-}
-
-
-static SoundState
-device_get_state_from_volume (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem),
- DBUSMENU_VOLUME_MENUITEM_LEVEL);
- gdouble volume_percent = g_variant_get_double (v);
-
- return sound_state_get_from_volume ((int)volume_percent);
-}
-
-void
-device_determine_blocking_state (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- if (mute_menu_item_is_muted (priv->mute_menuitem)){
- /**
- We don't want to set the current state to blocking
- as this is a fire and forget event.
- */
- sound_service_dbus_update_sound_state (priv->service,
- BLOCKED);
- }
-}
-
-gint
-device_get_sink_index (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return slider_menu_item_get_sink_index (priv->volume_slider_menuitem);
-}
-
-gboolean
-device_is_sink_populated (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM (priv->volume_slider_menuitem),
- DBUSMENU_MENUITEM_PROP_ENABLED);
-}
-
-void
-device_activate_voip_item (Device* self, gint source_output_index, gint client_index)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
- source_output_index,
- client_index)){
- voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE);
- }
-}
-
-void
-device_deactivate_voip_source (Device* self, gboolean visible)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item);
- voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible);
-}
-
-void
-device_deactivate_voip_client (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item);
-}
-
-void
-device_sink_deactivated (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- priv->current_sound_state = UNAVAILABLE;
- sound_service_dbus_update_sound_state (priv->service,
- priv->current_sound_state);
- mute_menu_item_enable (priv->mute_menuitem, FALSE);
- slider_menu_item_enable (priv->volume_slider_menuitem, FALSE);
-}
-
-SoundState
-device_get_state (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return priv->current_sound_state;
-}
-
-void
-device_update_voip_input_source (Device* self, const pa_source_info* update)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- voip_input_menu_item_update (priv->voip_input_menu_item, update);
-}
-
-gboolean
-device_is_voip_source_populated (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return voip_input_menu_item_is_populated (priv->voip_input_menu_item);
-}
-
-gint device_get_source_index (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- return voip_input_menu_item_get_index (priv->voip_input_menu_item);
-}
-
-Device*
-device_new (SoundServiceDbus* service)
-{
- Device* sink = g_object_new (DEVICE_TYPE, NULL);
- DevicePrivate* priv = DEVICE_GET_PRIVATE (sink);
- priv->service = service;
- sound_service_dbus_build_sound_menu (service,
- mute_menu_item_get_button (priv->mute_menuitem),
- DBUSMENU_MENUITEM (priv->volume_slider_menuitem),
- DBUSMENU_MENUITEM (priv->voip_input_menu_item));
- pm_establish_pulse_connection (sink);
- return sink;
-}
diff --git a/src/device.h b/src/device.h
deleted file mode 100644
index ccaf4ea..0000000
--- a/src/device.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2010 Canonical Ltd.
- *
- * Authors:
- * Conor Curran <conor.curran@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __DEVICE_H__
-#define __DEVICE_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "common-defs.h"
-#include "sound-service-dbus.h"
-
-#include <pulse/pulseaudio.h>
-
-G_BEGIN_DECLS
-
-#define DEVICE_TYPE (device_get_type ())
-#define DEVICE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DEVICE_TYPE, Device))
-#define DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), DEVICE_TYPE, DeviceClass))
-#define IS_DEVICE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DEVICE_TYPE))
-#define IS_DEVICE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DEVICE_TYPE))
-#define DEVICE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DEVICE_TYPE, DeviceClass))
-
-typedef struct _Device Device;
-typedef struct _DeviceClass DeviceClass;
-
-struct _Device {
- GObject parent;
-};
-
-struct _DeviceClass {
- GObjectClass parent_class;
-};
-
-GType device_get_type (void) G_GNUC_CONST;
-
-/**
- * TODO
- * Refactor this to become a device manager obj basically acting as wrapper for
- * the communication between pulseaudio-mgr and the individual items.
- * First steps collapse slider/volume related stuff into slider-menu-item.
- */
-
-// Sink related
-void device_sink_populate (Device* sink, const pa_sink_info* update);
-void device_sink_update (Device* sink, const pa_sink_info* update);
-gboolean device_is_sink_populated (Device* sink);
-gint device_get_sink_index (Device* self);
-void device_sink_deactivated (Device* self);
-void device_update_mute (Device* self, gboolean mute_update);
-void device_ensure_sink_is_unmuted (Device* self);
-
-// source and sinkinput/client related for VOIP functionality
-void device_update_voip_input_source (Device* sink, const pa_source_info* update);
-void device_activate_voip_item (Device* sink, gint source_output_index, gint client_index);
-gint device_get_voip_source_output_index (Device* sink);
-gboolean device_is_voip_source_populated (Device* sink);
-gint device_get_source_index (Device* self);
-void device_determine_blocking_state (Device* self);
-void device_deactivate_voip_source (Device* self, gboolean visible);
-void device_deactivate_voip_client (Device* self);
-SoundState device_get_state (Device* self);
-
-Device* device_new (SoundServiceDbus* service);
-
-G_END_DECLS
-
-#endif
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
deleted file mode 100644
index 5e004cb..0000000
--- a/src/sound-service-dbus.c
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Copyright 2010 Canonical Ltd.
- *
- * Authors:
- * Conor Curran <conor.curran@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <gio/gio.h>
-#include <unistd.h>
-#include <glib/gi18n.h>
-#include <libindicator/indicator-service.h>
-#include <libdbusmenu-glib/server.h>
-#include <libdbusmenu-glib/client.h>
-
-#include "sound-service-dbus.h"
-#include "device.h"
-#include "gen-sound-service.xml.h"
-#include "dbus-shared-names.h"
-#include "sound-service-marshal.h"
-
-// DBUS methods
-static void bus_method_call (GDBusConnection * connection,
- const gchar * sender,
- const gchar * path,
- const gchar * interface,
- const gchar * method,
- GVariant * params,
- GDBusMethodInvocation * invocation,
- gpointer user_data);
-
-static GDBusInterfaceVTable interface_table = {
- method_call: bus_method_call,
- get_property: NULL, /* No properties */
- set_property: NULL /* No properties */
-};
-
-
-typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate;
-
-struct _SoundServiceDbusPrivate {
- GDBusConnection* connection;
- DbusmenuMenuitem* root_menuitem;
- Device* device;
- gboolean greeter_mode;
- guint registration_id;
-};
-
-enum {
- TRACK_SPECIFIC_ITEM,
- PLAYER_SPECIFIC_ITEM,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-static GDBusNodeInfo * node_info = NULL;
-static GDBusInterfaceInfo * interface_info = NULL;
-
-#define SOUND_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbusPrivate))
-
-static void sound_service_dbus_class_init (SoundServiceDbusClass *klass);
-static void sound_service_dbus_init (SoundServiceDbus *self);
-static void sound_service_dbus_dispose (GObject *object);
-static void sound_service_dbus_finalize (GObject *object);
-
-static void show_sound_settings_dialog (DbusmenuMenuitem *mi,
- gpointer user_data);
-static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self,
- const gchar* player_name,
- gboolean blacklist);
-
-static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus* self,
- const gchar* player_name);
-
-G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
-
-static void
-sound_service_dbus_class_init (SoundServiceDbusClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (object_class, sizeof(SoundServiceDbusPrivate));
-
- object_class->dispose = sound_service_dbus_dispose;
- object_class->finalize = sound_service_dbus_finalize;
-
- g_assert(klass != NULL);
-
- if (node_info == NULL) {
- GError * error = NULL;
-
- node_info = g_dbus_node_info_new_for_xml(_sound_service, &error);
- if (error != NULL) {
- g_critical ("Unable to parse Indicator Service Interface description: %s",
- error->message);
- g_error_free(error);
- }
- }
-
- if (interface_info == NULL) {
- interface_info = g_dbus_node_info_lookup_interface (node_info,
- INDICATOR_SOUND_DBUS_INTERFACE);
-
- if (interface_info == NULL) {
- g_critical("Unable to find interface '" INDICATOR_SOUND_DBUS_INTERFACE "'");
- }
- }
- signals[TRACK_SPECIFIC_ITEM] = g_signal_new("track-specific-item-requested",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _sound_service_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2, G_TYPE_STRING,
- G_TYPE_STRING);
- signals[PLAYER_SPECIFIC_ITEM] = g_signal_new("player-specific-item-requested",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- _sound_service_marshal_VOID__STRING_STRING,
- G_TYPE_NONE, 2, G_TYPE_STRING,
- G_TYPE_STRING);
-}
-
-static void
-sound_service_dbus_init (SoundServiceDbus *self)
-{
- GError *error = NULL;
- SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
-
- priv->connection = NULL;
-
- /* Fetch the session bus */
- priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
-
- if (error != NULL) {
- g_critical ("sound-service-dbus:Unable to connect to the session bus when creating indicator sound service : %s", error->message);
- g_error_free (error);
- return;
- }
- /* register the service on it */
- priv->registration_id = g_dbus_connection_register_object (priv->connection,
- INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH,
- interface_info,
- &interface_table,
- self,
- NULL,
- &error);
- if (error != NULL) {
- g_critical ("Unable to register the sound service on DBus: %s", error->message);
- g_error_free (error);
- }
-}
-
-DbusmenuMenuitem*
-sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode)
-{
- SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
- priv->greeter_mode = greeter_mode;
- priv->root_menuitem = dbusmenu_menuitem_new();
- DbusmenuServer *server = dbusmenu_server_new (INDICATOR_SOUND_MENU_DBUS_OBJECT_PATH);
- dbusmenu_server_set_root (server, priv->root_menuitem);
- g_object_unref (priv->root_menuitem);
- priv->device = device_new (self);
- return priv->root_menuitem;
-}
-
-void
-sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
- DbusmenuMenuitem* mute_item,
- DbusmenuMenuitem* slider_item,
- DbusmenuMenuitem* voip_input_menu_item)
-{
- SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
-
- // Mute, Volume and Voip widgets
- dbusmenu_menuitem_child_add_position (priv->root_menuitem, mute_item, 0);
- dbusmenu_menuitem_child_add_position (priv->root_menuitem, slider_item, 1);
- dbusmenu_menuitem_child_add_position (priv->root_menuitem, voip_input_menu_item, 2);
-
- if (!priv->greeter_mode) {
- // Separator
- DbusmenuMenuitem* separator = dbusmenu_menuitem_new();
-
- dbusmenu_menuitem_property_set (separator,
- DBUSMENU_MENUITEM_PROP_TYPE,
- DBUSMENU_CLIENT_TYPES_SEPARATOR);
- dbusmenu_menuitem_child_add_position (priv->root_menuitem, separator, 3);
- g_object_unref (separator);
-
- // Sound preferences dialog
- DbusmenuMenuitem* settings_mi = dbusmenu_menuitem_new();
-
- dbusmenu_menuitem_property_set( settings_mi,
- DBUSMENU_MENUITEM_PROP_LABEL,
- _("Sound Settings..."));
- dbusmenu_menuitem_child_append(priv->root_menuitem, settings_mi);
- g_object_unref (settings_mi);
- g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
- G_CALLBACK(show_sound_settings_dialog), NULL);
- }
-}
-
-/**
-show_sound_settings_dialog:
-Bring up the gnome volume preferences dialog
-**/
-static void
-show_sound_settings_dialog (DbusmenuMenuitem *mi,
- gpointer user_data)
-{
- GError * error = NULL;
- if (!g_spawn_command_line_async("gnome-volume-control --page=applications", &error) &&
- !g_spawn_command_line_async("gnome-control-center sound", &error) &&
- !g_spawn_command_line_async("xfce4-mixer", &error))
- {
- g_warning("Unable to show dialog: %s", error->message);
- g_error_free(error);
- }
-}
-
-static void
-sound_service_dbus_dispose (GObject *object)
-{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (object);
-
- if (priv->connection && priv->registration_id) {
- g_dbus_connection_unregister_object (priv->connection, priv->registration_id);
- priv->registration_id = 0;
- }
-
- g_clear_object(&priv->connection);
-
- G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object);
- //TODO dispose of the active sink instance !
- return;
-}
-
-static void
-sound_service_dbus_finalize (GObject *object)
-{
- G_OBJECT_CLASS (sound_service_dbus_parent_class)->finalize (object);
- return;
-}
-
-
-// EMIT STATE SIGNAL
-void
-sound_service_dbus_update_sound_state (SoundServiceDbus* self,
- SoundState new_state)
-{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
-
- GVariant* v_output = g_variant_new("(i)", (int)new_state);
-
- GError * error = NULL;
-
- if (priv->connection == NULL ||
- g_dbus_connection_is_closed (priv->connection) == TRUE){
- g_critical ("sound_service_dbus_update_sound_state - dbus connection is %s !!",
- priv->connection == NULL? "NULL" : "closed");
- return;
- }
-
- //g_debug ("emitting state signal with value %i", (int)new_state);
- g_dbus_connection_emit_signal( priv->connection,
- NULL,
- INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH,
- INDICATOR_SOUND_DBUS_INTERFACE,
- INDICATOR_SOUND_SIGNAL_STATE_UPDATE,
- v_output,
- &error );
- if (error != NULL) {
- g_critical ("Unable to emit signal because : %s", error->message);
- g_error_free(error);
- }
-}
-
-//HANDLE DBUS METHOD CALLS
-static void
-bus_method_call (GDBusConnection * connection,
- const gchar * sender,
- const gchar * path,
- const gchar * interface,
- const gchar * method,
- GVariant * params,
- GDBusMethodInvocation * invocation,
- gpointer user_data)
-{
- SoundServiceDbus* service = SOUND_SERVICE_DBUS(user_data);
- g_return_if_fail ( IS_SOUND_SERVICE_DBUS(service) );
- GVariant * retval = NULL;
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (service);
-
- if (g_strcmp0(method, "GetSoundState") == 0) {
- g_debug("Get state - %i", device_get_state (priv->device));
- retval = g_variant_new ( "(i)", device_get_state (priv->device));
- }
- else if (g_strcmp0(method, "BlacklistMediaPlayer") == 0) {
- gboolean blacklist;
- const gchar* player_name;
- g_variant_get (params, "(&sb)", &player_name, &blacklist);
-
- g_debug ("BlacklistMediaPlayer - bool %i", blacklist);
- g_debug ("BlacklistMediaPlayer - name %s", player_name);
- gboolean result = sound_service_dbus_blacklist_player (service,
- player_name,
- blacklist);
- retval = g_variant_new ("(b)", result);
- }
- else if (g_strcmp0(method, "IsBlacklisted") == 0) {
- const gchar* player_name;
- g_variant_get (params, "(&s)", &player_name);
-
- g_debug ("IsBlacklisted - name %s", player_name);
- gboolean result = sound_service_dbus_is_blacklisted (service,
- player_name);
- retval = g_variant_new ("(b)", result);
- }
- else if (g_strcmp0(method, "EnableTrackSpecificItems") == 0) {
- g_debug ("EnableTrackSpecificItems");
- gchar* player_object_path;
- gchar* player_id;
- g_variant_get (params, "(os)", &player_object_path, &player_id);
- //g_debug ("object path = %s and id = %s", player_object_path, player_id);
- g_signal_emit (service,
- signals[TRACK_SPECIFIC_ITEM],
- 0,
- player_object_path,
- player_id);
- g_free (player_object_path);
- g_free (player_id);
-
- }
- else if (g_strcmp0(method, "EnablePlayerSpecificItems") == 0) {
- gchar* player_object_path;
- gchar* player_id;
- g_variant_get (params, "(os)", &player_object_path, &player_id);
- g_debug ("PLayer specific item - object path = %s and id = %s",
- player_object_path,
- player_id);
- g_signal_emit (service,
- signals[PLAYER_SPECIFIC_ITEM],
- 0,
- player_object_path,
- player_id);
- g_free (player_object_path);
- g_free (player_id);
- }
- else {
- g_warning("Calling method '%s' on the sound service but it's unknown", method);
- }
- g_dbus_method_invocation_return_value (invocation, retval);
-}
-
-/**
- TODO - Works nicely but refactor into at least two different methods
-**/
-static gboolean sound_service_dbus_blacklist_player (SoundServiceDbus* self,
- const gchar* player_name,
- gboolean blacklist)
-{
- g_return_val_if_fail (player_name != NULL, FALSE);
- g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE);
-
- GVariant* the_black_list;
- gboolean result = FALSE;
- GSettings* our_settings;
- GVariantIter iter;
- gchar *str;
- GVariantBuilder builder;
-
- our_settings = g_settings_new ("com.canonical.indicator.sound");
- the_black_list = g_settings_get_value (our_settings,
- "blacklisted-media-players");
- g_variant_iter_init (&iter, the_black_list);
- g_variant_builder_init(&builder, G_VARIANT_TYPE_STRING_ARRAY);
-
- while (g_variant_iter_loop (&iter, "s", &str)){
- g_variant_builder_add (&builder, "s", str);
- }
- g_variant_iter_init (&iter, the_black_list);
-
- if (blacklist == TRUE){
- while (g_variant_iter_loop (&iter, "s", &str)){
- g_print ("first pass to check if %s is present\n", str);
- if (g_strcmp0 (player_name, str) == 0){
- // Return if its already there
- g_debug ("we have this already blacklisted, no need to do anything");
- g_variant_builder_clear (&builder);
- g_object_unref (our_settings);
- g_variant_unref (the_black_list);
- return result;
- }
- }
- // Otherwise blacklist it !
- g_debug ("about to blacklist %s", player_name);
- g_variant_builder_add (&builder, "s", player_name);
- }
- else{
- gboolean present = FALSE;
- g_variant_iter_init (&iter, the_black_list);
- g_debug ("attempting to UN-blacklist %s", player_name);
-
- while (g_variant_iter_loop (&iter, "s", &str)){
- if (g_strcmp0 (player_name, str) == 0){
- present = TRUE;
- }
- }
- // It was not there anyway, return false
- if (present == FALSE){
- g_debug ("it was not blacklisted ?, no need to do anything");
- g_variant_builder_clear (&builder);
- g_object_unref (our_settings);
- g_variant_unref (the_black_list);
- return result;
- }
-
- // Otherwise free the builder and reconstruct ensuring no duplicates.
- g_variant_builder_clear (&builder);
- g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
-
- g_variant_iter_init (&iter, the_black_list);
-
- while (g_variant_iter_loop (&iter, "s", &str)){
- if (g_strcmp0 (player_name, str) != 0){
- g_variant_builder_add (&builder, "s", str);
- }
- }
- }
- GVariant* value = g_variant_builder_end (&builder);
- result = g_settings_set_value (our_settings,
- "blacklisted-media-players",
- value);
-
- g_object_unref (our_settings);
- g_variant_unref (the_black_list);
-
- return result;
-}
-
-static gboolean sound_service_dbus_is_blacklisted (SoundServiceDbus *self,
- const gchar *player_name)
-{
- GSettings *our_settings;
- GVariant *the_black_list;
- GVariantIter iter;
- gchar *str;
- gboolean result = FALSE;
-
- g_return_val_if_fail (player_name != NULL, FALSE);
- g_return_val_if_fail (IS_SOUND_SERVICE_DBUS (self), FALSE);
-
- our_settings = g_settings_new ("com.canonical.indicator.sound");
- the_black_list = g_settings_get_value (our_settings,
- "blacklisted-media-players");
- g_variant_iter_init (&iter, the_black_list);
- while (g_variant_iter_next (&iter, "s", &str)){
- if (g_strcmp0 (player_name, str) == 0) {
- result = TRUE;
- g_free (str);
- break;
- }
- g_free (str);
- }
-
- g_object_unref (our_settings);
- g_variant_unref (the_black_list);
-
- return result;
-}
-
diff --git a/src/sound-service-dbus.h b/src/sound-service-dbus.h
deleted file mode 100644
index 1c15fc7..0000000
--- a/src/sound-service-dbus.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2010 Canonical Ltd.
- *
- * Authors:
- * Conor Curran <conor.curran@canonical.com>
- *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 3, as published
- * by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranties of
- * MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __SOUND_SERVICE_DBUS_H__
-#define __SOUND_SERVICE_DBUS_H__
-
-#include <glib.h>
-#include <glib-object.h>
-#include <libdbusmenu-glib/menuitem.h>
-#include "common-defs.h"
-
-
-G_BEGIN_DECLS
-
-#define SOUND_SERVICE_DBUS_TYPE (sound_service_dbus_get_type ())
-#define SOUND_SERVICE_DBUS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbus))
-#define SOUND_SERVICE_DBUS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbusClass))
-#define IS_SOUND_SERVICE_DBUS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SOUND_SERVICE_DBUS_TYPE))
-#define IS_SOUND_SERVICE_DBUS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SOUND_SERVICE_DBUS_TYPE))
-#define SOUND_SERVICE_DBUS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbusClass))
-
-typedef struct _SoundServiceDbus SoundServiceDbus;
-typedef struct _SoundServiceDbusClass SoundServiceDbusClass;
-typedef struct _SoundData SoundData;
-
-struct _SoundData {
- SoundServiceDbus *service;
-};
-
-struct _SoundServiceDbus {
- GObject parent;
-};
-
-struct _SoundServiceDbusClass {
- GObjectClass parent_class;
-};
-
-GType sound_service_dbus_get_type (void) G_GNUC_CONST;
-
-DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self, gboolean greeter_mode);
-void sound_service_dbus_update_sound_state (SoundServiceDbus* self, SoundState new_state);
-void sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
- DbusmenuMenuitem* mute_item,
- DbusmenuMenuitem* slider_item,
- DbusmenuMenuitem* voip_input_menu_item);
-
-
-G_END_DECLS
-
-#endif
diff --git a/src/sound-service.c b/src/sound-service.c
deleted file mode 100644
index 0170f81..0000000
--- a/src/sound-service.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-Copyright 2010 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <locale.h>
-
-#include "sound-service.h"
-#include "pulseaudio-mgr.h"
-#include "sound-service-dbus.h"
-#include "music-player-bridge.h"
-
-static GMainLoop *mainloop = NULL;
-static MusicPlayerBridge* player_bridge = NULL;
-/***********************************************************************************************************/
-// Init and exit functions
-/**********************************************************************************************************************/
-/**
-service_shutdown:
-When the service interface starts to shutdown, we
-should follow it.
-**/
-
-void
-service_shutdown (IndicatorService *service, gpointer user_data)
-{
- if (mainloop != NULL) {
- g_debug("Service shutdown !");
- close_pulse_activites();
- g_main_loop_quit(mainloop);
- }
- return;
-}
-
-static gboolean
-get_greeter_mode (void)
-{
- const gchar *var;
- var = g_getenv("INDICATOR_GREETER_MODE");
- return (g_strcmp0(var, "1") == 0);
-}
-
-void
-on_player_specific_item_requested (SoundServiceDbus* sound_service,
- const gchar* desktop_id,
- const gchar* player_object_path,
- gpointer userdata)
-{
- if (player_bridge != NULL){
- music_player_bridge_enable_player_specific_items_for_client (player_bridge,
- desktop_id,
- player_object_path);
- }
-}
-
-void
-on_track_specific_item_requested (SoundServiceDbus* sound_service,
- const gchar* desktop_id,
- const gchar* player_object_path,
- gpointer userdata)
-{
- if (player_bridge != NULL){
- music_player_bridge_enable_track_specific_items_for_client (player_bridge,
- desktop_id,
- player_object_path);
- }
-}
-
-/**
-main:
-**/
-int
-main (int argc, char ** argv)
-{
- gboolean greeter_mode;
-
- g_type_init();
- textdomain (GETTEXT_PACKAGE);
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- setlocale (LC_ALL, "");
-
- IndicatorService *service = indicator_service_new_version (INDICATOR_SOUND_DBUS_NAME,
- INDICATOR_SOUND_DBUS_VERSION);
- g_signal_connect(G_OBJECT(service),
- INDICATOR_SERVICE_SIGNAL_SHUTDOWN,
- G_CALLBACK(service_shutdown), NULL);
-
- SoundServiceDbus* sound_service = g_object_new(SOUND_SERVICE_DBUS_TYPE, NULL);
- g_signal_connect(G_OBJECT(sound_service),
- "track-specific-item-requested",
- G_CALLBACK(on_track_specific_item_requested), NULL);
- g_signal_connect(G_OBJECT(sound_service),
- "player-specific-item-requested",
- G_CALLBACK(on_player_specific_item_requested), NULL);
-
- greeter_mode = get_greeter_mode();
-
- DbusmenuMenuitem* root_menuitem = sound_service_dbus_create_root_item(sound_service, greeter_mode);
- if (!greeter_mode) {
- player_bridge = music_player_bridge_new();
- music_player_bridge_set_root_menu_item(player_bridge, root_menuitem);
- }
-
- // Run the loop
- mainloop = g_main_loop_new(NULL, FALSE);
- g_main_loop_run(mainloop);
-
- return 0;
-}
-
-
-
-
diff --git a/src/sound-service.h b/src/sound-service.h
deleted file mode 100644
index 7c5d0c3..0000000
--- a/src/sound-service.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __INCLUDE_SOUND_SERVICE_H__
-#define __INCLUDE_SOUND_SERVICE_H__
-
-/*
-Copyright 2010 Canonical Ltd.
-
-Authors:
- Conor Curran <conor.curran@canonical.com>
-
-This program is free software: you can redistribute it and/or modify it
-under the terms of the GNU General Public License version 3, as published
-by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranties of
-MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <config.h>
-#include <unistd.h>
-#include <glib/gi18n.h>
-
-#include <libindicator/indicator-service.h>
-
-#include "dbus-shared-names.h"
-
-// ENTRY AND EXIT POINTS
-void service_shutdown(IndicatorService * service, gpointer user_data);
-int main (int argc, char ** argv);
-
-#endif
diff --git a/src/sound-service.xml b/src/sound-service.xml
deleted file mode 100644
index cb1d928..0000000
--- a/src/sound-service.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
-<node name="/com/canonical/indicator/sound">
- <interface name="com.canonical.indicator.sound">
- <method name = "BlacklistMediaPlayer">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type='s' name='player_desktop_name' direction="in"/>
- <arg type='b' name='blacklist' direction="in"/>
- <arg type='b' name='result' direction="out"/>
- </method>
- <method name = "IsBlacklisted">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type='s' name='player_desktop_name' direction="in"/>
- <arg type='b' name='result' direction="out"/>
- </method>
- <method name = "GetSoundState">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type='i' name='current_state' direction="out"/>
- </method>
- <method name = "EnableTrackSpecificItems">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type='o' name='player_object_path' direction="in"/>
- <arg type='s' name='player_desktop_id' direction="in"/>
- </method>
- <method name = "EnablePlayerSpecificItems">
- <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
- <arg type='o' name='player_object_path' direction="in"/>
- <arg type='s' name='player_desktop_id' direction="in"/>
- </method>
- <signal name="SoundStateUpdate">
- <arg name="new_state" type="i" direction="out"/>
- </signal>
- </interface>
-</node>
-