aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sound-service-dbus.c119
-rw-r--r--src/sound-service.c4
2 files changed, 52 insertions, 71 deletions
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 1bdb2cf..2c1dc4f 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -258,34 +258,6 @@ sound_service_dbus_finalize (GObject *object)
return;
}
-/* A method has been called from our dbus inteface. Figure out what it
- is and dispatch it. */
- // TODO we will need to implement the black_list method.
-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", priv->current_sound_state );
- retval = g_variant_new ( "(i)", priv->current_sound_state);
- }
- else {
- g_warning("Calling method '%s' on the sound service but it's unknown", method);
- }
- g_dbus_method_invocation_return_value (invocation, retval);
-}
-
// TODO until the pulsemanager has been refactored keep in place the consistent api
// for it to talk to the UI.
void sound_service_dbus_update_volume(SoundServiceDbus* self,
@@ -309,41 +281,6 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* self,
sound_service_dbus_update_sound_state (self, state);
}
-// TODO: this will be a bit messy until the pa_manager is sorted.
-// And we figure out all of the edge cases.
-void sound_service_dbus_update_sound_state (SoundServiceDbus* self,
- SoundState new_state)
-{
- SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
- SoundState update = new_state;
- // Ensure that after it has become available update the state with the current volume level
- if (new_state == AVAILABLE &&
- dbusmenu_menuitem_property_get_bool ( DBUSMENU_MENUITEM(priv->mute_menuitem),
- DBUSMENU_MUTE_MENUITEM_VALUE) == FALSE ){
- update = sound_service_dbus_get_state_from_volume (self);
- }
-
- priv->current_sound_state = update;
-
- GVariant* v_output = g_variant_new("(i)", (int)update);
-
- GError * error = NULL;
-
- g_debug ("emitting signal with value %i", (int)update);
- 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_error("Unable to emit signal 'sinkinputwhilemuted' because : %s", error->message);
- g_error_free(error);
- return;
- }
-}
-
static SoundState sound_service_dbus_get_state_from_volume (SoundServiceDbus* self)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
@@ -373,7 +310,6 @@ static void sound_service_dbus_determine_state (SoundServiceDbus* self,
gboolean mute,
gdouble volume)
{
- //SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
SoundState update;
if (availability == FALSE) {
update = UNAVAILABLE;
@@ -384,13 +320,32 @@ static void sound_service_dbus_determine_state (SoundServiceDbus* self,
else{
update = sound_service_dbus_get_state_from_volume (self);
}
+ sound_service_dbus_update_sound_state (self, update);
+}
- sound_service_dbus_update_sound_state (self, update);
- /*GVariant* v_output = g_variant_new("(i)", (int)priv->current_sound_state);
+// EMIT STATE SIGNAL
+
+// TODO: this will be a bit messy until the pa_manager is sorted.
+// And we figure out all of the edge cases.
+void sound_service_dbus_update_sound_state (SoundServiceDbus* self,
+ SoundState new_state)
+{
+ SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
+ SoundState update = new_state;
+ // Ensure that after it has become available update the state with the current volume level
+ if (new_state == AVAILABLE &&
+ dbusmenu_menuitem_property_get_bool ( DBUSMENU_MENUITEM(priv->mute_menuitem),
+ DBUSMENU_MUTE_MENUITEM_VALUE) == FALSE ){
+ update = sound_service_dbus_get_state_from_volume (self);
+ }
+
+ priv->current_sound_state = update;
+
+ GVariant* v_output = g_variant_new("(i)", (int)update);
GError * error = NULL;
- g_debug ("emitting signal with value %i", (int)priv->current_sound_state);
+ g_debug ("emitting signal with value %i", (int)update);
g_dbus_connection_emit_signal( priv->connection,
NULL,
INDICATOR_SOUND_SERVICE_DBUS_OBJECT_PATH,
@@ -402,8 +357,34 @@ static void sound_service_dbus_determine_state (SoundServiceDbus* self,
g_error("Unable to emit signal 'sinkinputwhilemuted' because : %s", error->message);
g_error_free(error);
return;
- }*/
-
+ }
+}
+
+//HANDLE DBUS METHOD CALLS
+// TODO we will need to implement the black_list method.
+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", priv->current_sound_state );
+ retval = g_variant_new ( "(i)", priv->current_sound_state);
+ }
+ else {
+ g_warning("Calling method '%s' on the sound service but it's unknown", method);
+ }
+ g_dbus_method_invocation_return_value (invocation, retval);
}
diff --git a/src/sound-service.c b/src/sound-service.c
index e72a917..9a5c6fe 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -40,8 +40,8 @@ service_shutdown (IndicatorService *service, gpointer user_data)
{
if (mainloop != NULL) {
g_debug("Service shutdown !");
- //close_pulse_activites();
- //g_main_loop_quit(mainloop);
+ close_pulse_activites();
+ g_main_loop_quit(mainloop);
}
return;
}