aboutsummaryrefslogtreecommitdiff
path: root/src/messages-service-dbus.c
diff options
context:
space:
mode:
authorEvgeni Golov <evgeni@debian.org>2011-03-31 14:09:07 +0200
committerEvgeni Golov <evgeni@debian.org>2011-03-31 14:09:07 +0200
commit38a90ca64a3d976218be46f7f5241805854d9ef1 (patch)
tree2b24bdb39e61fce6999511da451261daff1db7e2 /src/messages-service-dbus.c
parent36559fd986e3226f8c926c69f9c253d4da46cb19 (diff)
parentcb170c0fb193360740cc543816e6f00d46a480c7 (diff)
downloadayatana-indicator-messages-38a90ca64a3d976218be46f7f5241805854d9ef1.tar.gz
ayatana-indicator-messages-38a90ca64a3d976218be46f7f5241805854d9ef1.tar.bz2
ayatana-indicator-messages-38a90ca64a3d976218be46f7f5241805854d9ef1.zip
Merge Ubuntu up to 0.3.92-0ubuntu3
* Merge new upstream from Ubuntu. * debian/patches/lp_690668.patch - Memory leak fixes (LP: #690668) * debian/control - Bump standards version to 3.9.1 * debian/source/format - Use source format 3.0 (quilt) * src/launcher-menu-item.c - Make sure menu entries are displayed for launchers that aren't running (LP: #723873) * New upstream release. * Adding in accessible description support * debian/control: libindicator version 0.3.19 * New upstream release. * Fixing the service file * Adding a log domain * Fixing type handler for dbusmenu 0.3.94 * debian/control: dbusmenu to 0.3.94 [ Ted Gould ] * New upstream release. * GDBus Port * New libindicate and dbusmenu [ Ken VanDine ] * debian/control - Build depends on libindicate-dev to 0.4.91 - Build depends on dbusmenu to 0.3.91 - Set Vcs to ~ubuntu-desktop * data/indicator-messages.service.in - Fixed dbus interface name * debian/control - Bump build depends for libdbusmenu-* to >= 0.3.90 * debian/control: package description spelling (LP: #658096) * Rebuild for libindicator ABI change (LP: #637692) * debian/control: depends on latest libindicator-dev * New upstream release. * Fixing triangles by passing data to callback (LP: #623453) * New upstream release. * Shifting icons into the gutter and adjusting the arrow padding. * New upstream release. * Remove parens from counts * New upstream release. - running apps triangle indicator overlay - message counters are now rendered with a nice rounded background
Diffstat (limited to 'src/messages-service-dbus.c')
-rw-r--r--src/messages-service-dbus.c144
1 files changed, 110 insertions, 34 deletions
diff --git a/src/messages-service-dbus.c b/src/messages-service-dbus.c
index d9c0e8d..6cc33e0 100644
--- a/src/messages-service-dbus.c
+++ b/src/messages-service-dbus.c
@@ -24,9 +24,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config.h"
#endif
-#include <dbus/dbus-glib.h>
+#include <gio/gio.h>
#include "messages-service-dbus.h"
#include "dbus-data.h"
+#include "gen-messages-service.xml.h"
enum {
ATTENTION_CHANGED,
@@ -40,6 +41,7 @@ typedef struct _MessageServiceDbusPrivate MessageServiceDbusPrivate;
struct _MessageServiceDbusPrivate
{
+ GDBusConnection * connection;
gboolean dot;
gboolean hidden;
};
@@ -51,15 +53,26 @@ 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 _messages_service_server_watch (void);
-static gboolean _messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error);
-static gboolean _messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error);
-
-#include "messages-service-server.h"
+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)
{
@@ -86,8 +99,57 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass)
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ 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;
+ }
- dbus_g_object_type_install_info(MESSAGE_SERVICE_DBUS_TYPE, &dbus_glib__messages_service_server_object_info);
+ g_debug("Service on session bus");
return;
}
@@ -95,10 +157,7 @@ message_service_dbus_class_init (MessageServiceDbusClass *klass)
static void
message_service_dbus_init (MessageServiceDbus *self)
{
- DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- dbus_g_connection_register_g_object(connection,
- INDICATOR_MESSAGES_DBUS_SERVICE_OBJECT,
- G_OBJECT(self));
+ g_bus_get(G_BUS_TYPE_SESSION, NULL, connection_cb, self);
MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
@@ -111,7 +170,12 @@ message_service_dbus_init (MessageServiceDbus *self)
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;
+ }
G_OBJECT_CLASS (message_service_dbus_parent_class)->dispose (object);
return;
@@ -132,31 +196,23 @@ message_service_dbus_new (void)
return MESSAGE_SERVICE_DBUS(g_object_new(MESSAGE_SERVICE_DBUS_TYPE, NULL));
}
-/* DBus function to say that someone is watching */
+/* Method request off of DBus */
static void
-_messages_service_server_watch (void)
-{
-
-}
-
-/* DBus interface to request the private variable to know
- whether there is a green dot. */
-static gboolean
-_messages_service_server_attention_requested (MessageServiceDbus * self, gboolean * dot, GError ** error)
+bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data)
{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
- *dot = priv->dot;
- return TRUE;
-}
+ MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(user_data);
+
+ 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 {
+ g_warning("Unknown function call '%s'", method);
+ }
-/* DBus interface to request the private variable to know
- whether the icon is hidden. */
-static gboolean
-_messages_service_server_icon_shown (MessageServiceDbus * self, gboolean * hidden, GError ** error)
-{
- MessageServiceDbusPrivate * priv = MESSAGE_SERVICE_DBUS_GET_PRIVATE(self);
- *hidden = priv->hidden;
- return TRUE;
+ return;
}
void
@@ -167,6 +223,16 @@ message_service_dbus_set_attention (MessageServiceDbus * self, gboolean attentio
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);
+ }
}
return;
}
@@ -179,6 +245,16 @@ message_service_dbus_set_icon (MessageServiceDbus * self, gboolean hidden)
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;
}