aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2012-06-27 21:42:23 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2012-06-27 21:42:23 +0200
commit193886f467b636a91d546656017de3fd0fa62677 (patch)
treea8ef69e6ee47dddb6c746c0f65ce19daa86118f2 /src
parent315c058bcc7c152615cf35f11c0f29d8ee9ec01b (diff)
downloadayatana-indicator-messages-193886f467b636a91d546656017de3fd0fa62677.tar.gz
ayatana-indicator-messages-193886f467b636a91d546656017de3fd0fa62677.tar.bz2
ayatana-indicator-messages-193886f467b636a91d546656017de3fd0fa62677.zip
Use gdbus-codegen also for the server side messages service
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am30
-rw-r--r--src/indicator-messages.c1
-rw-r--r--src/messages-service-dbus.c511
-rw-r--r--src/messages-service-dbus.h65
-rw-r--r--src/messages-service.c36
5 files changed, 39 insertions, 604 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e9f88e6..1bc5b59 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,8 +15,8 @@ messaginglibdir = $(INDICATORDIR)
messaginglib_LTLIBRARIES = libmessaging.la
libmessaging_la_SOURCES = \
indicator-messages.c \
- gen-messages-service.xml.h \
- gen-messages-service.xml.c \
+ indicator-messages-service.c \
+ indicator-messages-service.h
dbus-data.h
libmessaging_la_CFLAGS = \
$(APPLET_CFLAGS) \
@@ -38,10 +38,8 @@ libmessaging_la_LDFLAGS = \
indicator_messages_service_SOURCES = \
messages-service.c \
- messages-service-dbus.c \
- messages-service-dbus.h \
- gen-messages-service.xml.h \
- gen-messages-service.xml.c \
+ indicator-messages-service.c \
+ indicator-messages-service.h \
app-section.c \
app-section.h \
dbus-data.h \
@@ -68,19 +66,17 @@ indicator_messages_service_LDADD = \
indicator_messages_service_LDFLAGS = \
$(COVERAGE_LDFLAGS)
-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 ";" >> $@
+indicator-messages-service.c: $(top_srcdir)/src/messages-service.xml
+ $(AM_V_GEN) gdbus-codegen \
+ --interface-prefix com.canonical.indicator.messages. \
+ --generate-c-code indicator-messages-service \
+ --c-namespace IndicatorMessages \
+ $^
+indicator-messages-service.h: indicator-messages-service.c
BUILT_SOURCES += \
- gen-messages-service.xml.h \
- gen-messages-service.xml.c
+ indicator-messages-service.c \
+ indicator-messages-service.h
EXTRA_DIST += \
messages-service.xml
diff --git a/src/indicator-messages.c b/src/indicator-messages.c
index 70efd52..6278461 100644
--- a/src/indicator-messages.c
+++ b/src/indicator-messages.c
@@ -35,7 +35,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libindicator/indicator-service-manager.h>
#include "dbus-data.h"
-#include "gen-messages-service.xml.h"
#define INDICATOR_MESSAGES_TYPE (indicator_messages_get_type ())
#define INDICATOR_MESSAGES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessages))
diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c
deleted file mode 100644
index 211b1f5..0000000
--- a/src/messages-service-dbus.c
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
-An indicator to show information that is in messaging applications
-that the user is using.
-
-Copyright 2009 Canonical Ltd.
-
-Authors:
- Ted Gould <ted@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 "messages-service-dbus.h"
-#include "dbus-data.h"
-#include "gen-messages-service.xml.h"
-
-enum {
- ATTENTION_CHANGED,
- ICON_CHANGED,
- REGISTER_APPLICATION,
- UNREGISTER_APPLICATION,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate;
-
-struct _MessageServiceDbusPrivate
-{
- GDBusConnection * connection;
- GCancellable * accounts_cancel;
- GDBusProxy * accounts_user;
- gboolean dot;
- gboolean hidden;
-};
-
-#define MESSAGE_SERVICE_DBUS_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusPrivate))
-
-static void message_service_dbus_class_init (MessageServiceDbusClass *klass);
-static void message_service_dbus_init (MessageServiceDbus *self);
-static void message_service_dbus_dispose (GObject *object);
-static void message_service_dbus_finalize (GObject *object);
-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 GDBusNodeInfo * bus_node_info = NULL;
-static GDBusInterfaceInfo * bus_interface_info = NULL;
-static const GDBusInterfaceVTable bus_interface_table = {
- method_call: bus_method_call,
- get_property: NULL, /* No properties */
- set_property: NULL /* No properties */
-};
-
-G_DEFINE_TYPE (MessageServiceDbus, message_service_dbus, G_TYPE_OBJECT);
-
-
-static void
-message_service_dbus_class_init (MessageServiceDbusClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (MessageServiceDbusPrivate));
-
- object_class->dispose = message_service_dbus_dispose;
- object_class->finalize = message_service_dbus_finalize;
-
- signals[ATTENTION_CHANGED] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED,
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MessageServiceDbusClass, attention_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
- signals[ICON_CHANGED] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_ICON_CHANGED,
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (MessageServiceDbusClass, icon_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-
- signals[REGISTER_APPLICATION] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_REGISTER_APPLICATION,
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_generic,
- G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- signals[UNREGISTER_APPLICATION] = g_signal_new(MESSAGE_SERVICE_DBUS_SIGNAL_UNREGISTER_APPLICATION,
- G_TYPE_FROM_CLASS(klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
- if (bus_node_info == NULL) {
- GError * error = NULL;
-
- bus_node_info = g_dbus_node_info_new_for_xml(_messages_service, &error);
- if (error != NULL) {
- g_error("Unable to parse Messaging Menu Interface description: %s", error->message);
- g_error_free(error);
- }
- }
-
- if (bus_interface_info == NULL) {
- bus_interface_info = g_dbus_node_info_lookup_interface(bus_node_info, INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE);
-
- if (bus_interface_info == NULL) {
- g_error("Unable to find interface '" INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE "'");
- }
- }
-
- return;
-}
-
-static void
-connection_cb (GObject * object, GAsyncResult * res, gpointer user_data)
-{
- GError * error = NULL;
- GDBusConnection * connection = g_bus_get_finish(res, &error);
-
- if (error != NULL) {
- g_error("Unable to connect to the session bus: %s", error->message);
- g_error_free(error);
- return;
- }
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
- priv->connection = connection;
-
- g_dbus_connection_register_object(connection,
- INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
- bus_interface_info,
- &bus_interface_table,
- user_data,
- NULL, /* destroy */
- &error);
-
- if (error != NULL) {
- g_error("Unable to register on session bus: %s", error->message);
- g_error_free(error);
- return;
- }
-
- g_debug("Service on session bus");
-
- return;
-}
-
-static void
-accounts_notify_cb (GObject *source_object, GAsyncResult *res,
- gpointer user_data)
-{
- GError * error = NULL;
- GVariant * answer = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error);
-
- if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free(error);
- return; /* Must exit before accessing freed memory */
- }
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
-
- if (priv->accounts_cancel != NULL) {
- g_object_unref(priv->accounts_cancel);
- priv->accounts_cancel = NULL;
- }
-
- if (error != NULL) {
- g_warning("Unable to get notify accounts service of message status: %s", error->message);
- g_error_free(error);
- return;
- }
-
- g_variant_unref (answer);
-}
-
-static void
-accounts_notify (MessageServiceDbus *self)
-{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
-
- if (priv->accounts_user == NULL)
- return; /* We're not able to talk to accounts service */
-
- if (priv->accounts_cancel != NULL) {
- /* Cancel old notify before starting new one */
- g_cancellable_cancel(priv->accounts_cancel);
- g_object_unref(priv->accounts_cancel);
- priv->accounts_cancel = NULL;
- }
-
- priv->accounts_cancel = g_cancellable_new();
- g_dbus_proxy_call(priv->accounts_user,
- "SetXHasMessages",
- g_variant_new ("(b)", priv->dot),
- G_DBUS_CALL_FLAGS_NONE,
- -1, /* timeout */
- priv->accounts_cancel,
- accounts_notify_cb,
- self);
-}
-
-static void
-get_accounts_user_proxy_cb (GObject *source_object, GAsyncResult *res,
- gpointer user_data)
-{
- GError * error = NULL;
- GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
-
- if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free(error);
- return; /* Must exit before accessing freed memory */
- }
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
-
- if (priv->accounts_cancel != NULL) {
- g_object_unref(priv->accounts_cancel);
- priv->accounts_cancel = NULL;
- }
-
- if (error != NULL) {
- g_warning("Unable to get proxy of accountsservice: %s", error->message);
- g_error_free(error);
- return;
- }
-
- priv->accounts_user = proxy;
- accounts_notify (MESSAGE_SERVICE_DBUS (user_data));
-}
-
-static void
-get_accounts_user_find_user_cb (GObject *source_object, GAsyncResult *res,
- gpointer user_data)
-{
- GError * error = NULL;
- GVariant * answer = g_dbus_proxy_call_finish(G_DBUS_PROXY(source_object), res, &error);
-
- /* We're done with main accounts proxy now */
- g_object_unref (source_object);
-
- if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free(error);
- return; /* Must exit before accessing freed memory */
- }
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
-
- if (priv->accounts_cancel != NULL) {
- g_object_unref(priv->accounts_cancel);
- priv->accounts_cancel = NULL;
- }
-
- if (error != NULL) {
- g_warning("Unable to get object name of user from accountsservice: %s", error->message);
- g_error_free(error);
- return;
- }
-
- if (!g_variant_is_of_type (answer, G_VARIANT_TYPE ("(o)"))) {
- g_warning("Unexpected type from FindUserByName: %s", g_variant_get_type_string (answer));
- g_variant_unref(answer);
- return;
- }
-
- const gchar *path;
- g_variant_get(answer, "(&o)", &path);
-
- priv->accounts_cancel = g_cancellable_new();
- g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "org.freedesktop.Accounts",
- path,
- "org.freedesktop.Accounts.User",
- priv->accounts_cancel,
- get_accounts_user_proxy_cb,
- user_data);
-
- g_variant_unref (answer);
-}
-
-static void
-get_accounts_proxy_cb (GObject *source_object, GAsyncResult *res,
- gpointer user_data)
-{
- GError * error = NULL;
- GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
-
- if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_error_free(error);
- return; /* Must exit before accessing freed memory */
- }
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
-
- if (priv->accounts_cancel != NULL) {
- g_object_unref(priv->accounts_cancel);
- priv->accounts_cancel = NULL;
- }
-
- if (error != NULL) {
- g_warning("Unable to get proxy of accountsservice: %s", error->message);
- g_error_free(error);
- return;
- }
-
- priv->accounts_cancel = g_cancellable_new();
- g_dbus_proxy_call(proxy,
- "FindUserByName",
- g_variant_new ("(s)", g_get_user_name ()),
- G_DBUS_CALL_FLAGS_NONE,
- -1, /* timeout */
- priv->accounts_cancel,
- get_accounts_user_find_user_cb,
- user_data);
-}
-
-static void
-get_accounts_proxy (MessageServiceDbus *self)
-{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
-
- g_return_if_fail(priv->accounts_cancel == NULL);
-
- priv->accounts_cancel = g_cancellable_new();
- g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- NULL,
- "org.freedesktop.Accounts",
- "/org/freedesktop/Accounts",
- "org.freedesktop.Accounts",
- priv->accounts_cancel,
- get_accounts_proxy_cb,
- self);
-}
-
-static void
-message_service_dbus_init (MessageServiceDbus *self)
-{
- g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self);
- get_accounts_proxy (self);
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
-
- priv->dot = FALSE;
- priv->hidden = FALSE;
-
- return;
-}
-
-static void
-message_service_dbus_dispose (GObject *object)
-{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(object);
-
- if (priv->connection != NULL) {
- g_object_unref(priv->connection);
- priv->connection = NULL;
- }
-
- if (priv->accounts_cancel != NULL) {
- g_cancellable_cancel(priv->accounts_cancel);
- g_object_unref(priv->accounts_cancel);
- priv->accounts_cancel = NULL;
- }
-
- if (priv->accounts_user != NULL) {
- g_object_unref(priv->accounts_user);
- priv->accounts_user = NULL;
- }
-
- G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object);
- return;
-}
-
-static void
-message_service_dbus_finalize (GObject *object)
-{
-
-
- G_OBJECT_CLASS (message_service_dbus_parent_class)->finalize (object);
- return;
-}
-
-MessageServiceDbus *
-message_service_dbus_new (void)
-{
- return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL));
-}
-
-/* Method request off of DBus */
-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)
-{
- MessageServiceDbus * ms = MESSAGE_SERVICE_DBUS(user_data);
- if (ms == NULL) { return; }
-
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(ms);
-
- if (g_strcmp0("AttentionRequested", method) == 0) {
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->dot));
- return;
- } else if (g_strcmp0("IconShown", method) == 0) {
- g_dbus_method_invocation_return_value(invocation, g_variant_new("(b)", priv->hidden));
- return;
- } else if (g_strcmp0("ClearAttention", method) == 0) {
- message_service_dbus_set_attention(ms, FALSE);
- g_dbus_method_invocation_return_value(invocation, NULL);
- return;
- } else if (g_strcmp0("RegisterApplication", method) == 0) {
- const gchar *desktop_id, *object_path;
- g_variant_get(params, "(&s&o)", &desktop_id, &object_path);
- g_signal_emit(ms, signals[REGISTER_APPLICATION], 0, sender, desktop_id, object_path);
- g_dbus_method_invocation_return_value(invocation, NULL);
- } else if (g_strcmp0("UnregisterApplication", method) == 0) {
- const gchar *desktop_id;
- g_variant_get(params, "(&s)", &desktop_id);
- g_signal_emit(ms, signals[UNREGISTER_APPLICATION], 0, desktop_id);
- g_dbus_method_invocation_return_value(invocation, NULL);
- } else {
- g_warning("Unknown function call '%s'", method);
- }
-
- return;
-}
-
-void
-message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attention)
-{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
- /* Do signal */
- if (attention != priv->dot) {
- priv->dot = attention;
- g_signal_emit(G_OBJECT(self), signals[ATTENTION_CHANGED], 0, priv->dot, TRUE);
-
- if (priv->connection != NULL) {
- g_dbus_connection_emit_signal(priv->connection,
- NULL,
- INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
- INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE,
- "AttentionChanged",
- g_variant_new("(b)", priv->dot),
- NULL);
- }
-
- accounts_notify (self);
- }
- return;
-}
-
-void
-message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden)
-{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
- /* Do signal */
- if (hidden != priv->hidden) {
- priv->hidden = hidden;
- g_signal_emit(G_OBJECT(self), signals[ICON_CHANGED], 0, priv->hidden, TRUE);
-
- if (priv->connection != NULL) {
- g_dbus_connection_emit_signal(priv->connection,
- NULL,
- INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
- INDICATOR_MESSAGES_DBUS_SERVICE_INTERFACE,
- "IconChanged",
- g_variant_new("(b)", priv->hidden),
- NULL);
- }
- }
- return;
-}
-
-GDBusConnection *
-message_service_dbus_get_connection (MessageServiceDbus *msd)
-{
- MessageServiceDbusPrivate * priv;
-
- g_return_val_if_fail (IS_MESSAGE_SERVICE_DBUS (msd), NULL);
-
- priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(msd);
- return priv->connection;
-}
diff --git a/src/messages-service-dbus.h b/src/messages-service-dbus.h
deleted file mode 100644
index 63564b6..0000000
--- a/src/messages-service-dbus.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-An indicator to show information that is in messaging applications
-that the user is using.
-
-Copyright 2009 Canonical Ltd.
-
-Authors:
- Ted Gould <ted@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 __MESSAGE_SERVICE_DBUS_H__
-#define __MESSAGE_SERVICE_DBUS_H__
-
-#include <glib.h>
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define MESSAGE_SERVICE_DBUS_TYPE (message_service_dbus_get_type ())
-#define MESSAGE_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbus))
-#define MESSAGE_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusClass))
-#define IS_MESSAGE_SERVICE_DBUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MESSAGE_SERVICE_DBUS_TYPE))
-#define IS_MESSAGE_SERVICE_DBUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MESSAGE_SERVICE_DBUS_TYPE))
-#define MESSAGE_SERVICE_DBUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MESSAGE_SERVICE_DBUS_TYPE, MessageServiceDbusClass))
-
-#define MESSAGE_SERVICE_DBUS_SIGNAL_ATTENTION_CHANGED "attention-changed"
-#define MESSAGE_SERVICE_DBUS_SIGNAL_ICON_CHANGED "icon-changed"
-#define MESSAGE_SERVICE_DBUS_SIGNAL_REGISTER_APPLICATION "register-application"
-#define MESSAGE_SERVICE_DBUS_SIGNAL_UNREGISTER_APPLICATION "unregister-application"
-
-typedef struct _MessageServiceDbus MessageServiceDbus;
-typedef struct _MessageServiceDbusClass MessageServiceDbusClass;
-
-struct _MessageServiceDbusClass {
- GObjectClass parent_class;
-
- void (*attention_changed) (gboolean dot);
- void (*icon_changed) (gboolean hidden);
-};
-
-struct _MessageServiceDbus {
- GObject parent;
-};
-
-GType message_service_dbus_get_type (void);
-MessageServiceDbus * message_service_dbus_new (void);
-void message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attention);
-void message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden);
-GDBusConnection * message_service_dbus_get_connection (MessageServiceDbus *msd);
-
-G_END_DECLS
-
-#endif
diff --git a/src/messages-service.c b/src/messages-service.c
index 4bd7e0c..ec36335 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -29,13 +29,14 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "app-section.h"
#include "dbus-data.h"
-#include "messages-service-dbus.h"
#include "gactionmuxer.h"
#include "gsettingsstrv.h"
#include "gmenuutils.h"
+#include "indicator-messages-service.h"
static GHashTable *applications;
+IndicatorMessagesService *messages_service;
static GSimpleActionGroup *actions;
static GActionMuxer *action_muxer;
static GMenu *toplevel_menu;
@@ -266,33 +267,39 @@ change_status (GSimpleAction *action,
}
static void
-register_application (MessageServiceDbus *msd,
- const gchar *sender,
+register_application (IndicatorMessagesService *service,
+ GDBusMethodInvocation *invocation,
const gchar *desktop_id,
const gchar *menu_path,
gpointer user_data)
{
AppSection *section;
GDBusConnection *bus;
+ const gchar *sender;
section = add_application (desktop_id);
if (!section)
return;
- bus = message_service_dbus_get_connection (msd);
+ bus = g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (service));
+ sender = g_dbus_method_invocation_get_sender (invocation);
app_section_set_object_path (section, bus, sender, menu_path);
-
g_settings_strv_append_unique (settings, "applications", desktop_id);
+
+ indicator_messages_service_complete_register_application (service, invocation);
}
static void
-unregister_application (MessageServiceDbus *msd,
+unregister_application (IndicatorMessagesService *service,
+ GDBusMethodInvocation *invocation,
const gchar *desktop_id,
gpointer user_data)
{
remove_application (desktop_id);
g_settings_strv_remove (settings, "applications", desktop_id);
+
+ indicator_messages_service_complete_unregister_application (service, invocation);
}
GSimpleActionGroup *
@@ -371,6 +378,15 @@ got_bus (GObject *object,
return;
}
+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (messages_service),
+ bus, INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
+ &error);
+ if (error) {
+ g_warning ("unable to export messages service on dbus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
g_object_unref (bus);
}
@@ -379,7 +395,6 @@ main (int argc, char ** argv)
{
GMainLoop * mainloop = NULL;
IndicatorService * service = NULL;
- MessageServiceDbus * dbus_interface = NULL;
GMenuModel *status_items;
GMenuItem *header;
@@ -399,7 +414,7 @@ main (int argc, char ** argv)
textdomain (GETTEXT_PACKAGE);
/* Bring up the service DBus interface */
- dbus_interface = message_service_dbus_new();
+ messages_service = indicator_messages_service_skeleton_new ();
g_bus_get (G_BUS_TYPE_SESSION, NULL, got_bus, NULL);
@@ -408,9 +423,9 @@ main (int argc, char ** argv)
action_muxer = g_action_muxer_new ();
g_action_muxer_insert (action_muxer, NULL, G_ACTION_GROUP (actions));
- g_signal_connect (dbus_interface, MESSAGE_SERVICE_DBUS_SIGNAL_REGISTER_APPLICATION,
+ g_signal_connect (messages_service, "handle-register-application",
G_CALLBACK (register_application), NULL);
- g_signal_connect (dbus_interface, MESSAGE_SERVICE_DBUS_SIGNAL_UNREGISTER_APPLICATION,
+ g_signal_connect (messages_service, "handle-unregister-application",
G_CALLBACK (unregister_application), NULL);
menu = g_menu_new ();
@@ -434,6 +449,7 @@ main (int argc, char ** argv)
g_main_loop_run(mainloop);
/* Clean up */
+ g_object_unref (messages_service);
g_object_unref (status_items);
g_object_unref (settings);
g_hash_table_unref (applications);