2
* Copyright 2010 Canonical Ltd.
5
* Conor Curran <conor.curran@canonical.com>
6
* Cody Russell <crussell@canonical.com>
8
* This program is free software: you can redistribute it and/or modify it
9
* under the terms of the GNU General Public License version 3, as published
10
* by the Free Software Foundation.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranties of
14
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
* PURPOSE. See the GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
25
#include <dbus/dbus-glib.h>
26
#include "dbus-shared-names.h"
27
#include "sound-service-dbus.h"
28
#include "sound-service-client.h"
29
#include "sound-service-server.h"
30
#include "common-defs.h"
31
#include "sound-service-marshal.h"
34
typedef struct _SoundServiceDbusPrivate SoundServiceDbusPrivate;
36
struct _SoundServiceDbusPrivate
38
DBusGConnection *system_bus;
39
DBusGConnection *connection;
44
SINK_INPUT_WHILE_MUTED,
48
static guint signals[LAST_SIGNAL] = { 0 };
50
#define SOUND_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SOUND_SERVICE_DBUS_TYPE, SoundServiceDbusPrivate))
53
static void sound_service_dbus_class_init (SoundServiceDbusClass *klass);
54
static void sound_service_dbus_init (SoundServiceDbus *self);
55
static void sound_service_dbus_dispose (GObject *object);
56
static void sound_service_dbus_finalize (GObject *object);
59
/* GObject Boilerplate */
60
G_DEFINE_TYPE (SoundServiceDbus, sound_service_dbus, G_TYPE_OBJECT);
63
sound_service_dbus_class_init (SoundServiceDbusClass *klass)
65
GObjectClass *object_class = G_OBJECT_CLASS (klass);
67
g_type_class_add_private (object_class, sizeof(SoundServiceDbusPrivate));
69
object_class->dispose = sound_service_dbus_dispose;
70
object_class->finalize = sound_service_dbus_finalize;
72
g_assert(klass != NULL);
73
dbus_g_object_type_install_info(SOUND_SERVICE_DBUS_TYPE,
74
&dbus_glib__sound_service_server_object_info);
76
signals[SINK_INPUT_WHILE_MUTED] = g_signal_new(SIGNAL_SINK_INPUT_WHILE_MUTED,
77
G_TYPE_FROM_CLASS (klass),
81
_sound_service_marshal_VOID__INT_BOOLEAN,
82
G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_BOOLEAN);
87
Utility methods to emit signals from the service into the ether.
89
void sound_service_dbus_sink_input_while_muted(SoundServiceDbus* obj, gint sink_index, gboolean value){
90
/* g_assert((num < LAST_SIGNAL) && (num >= 0));*/
91
g_debug("Emitting signal: SINK_INPUT_WHILE_MUTED, with sink_index %i and value %i", sink_index, value);
93
signals[SINK_INPUT_WHILE_MUTED],
103
sound_service_dbus_init (SoundServiceDbus *self)
105
GError *error = NULL;
106
SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
108
priv->system_bus = NULL;
109
priv->connection = NULL;
111
/* Get the system bus */
112
priv->system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
113
/* Put the object on DBus */
114
priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
117
g_error("Unable to connect to the session bus when creating application indicator: %s", error->message);
121
dbus_g_connection_register_g_object(priv->connection,
122
"/org/ayatana/indicator/sound/service",
129
sound_service_dbus_dispose (GObject *object)
131
G_OBJECT_CLASS (sound_service_dbus_parent_class)->dispose (object);
136
sound_service_dbus_finalize (GObject *object)
138
G_OBJECT_CLASS (sound_service_dbus_parent_class)->finalize (object);