aboutsummaryrefslogtreecommitdiff
path: root/src/status-service-dbus.c
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-08-07 21:05:58 +0100
committerTed Gould <ted@canonical.com>2009-08-07 21:05:58 +0100
commitc4dbc5ba3f963a74952c35ef23249694c3593217 (patch)
tree7a9bbd072edfe7ca86c271d7463f4b7e512fb8a4 /src/status-service-dbus.c
parent61e75b021a7adc56b685b890ff195a7d03cdb720 (diff)
parentd109578b8a84e07678762906021234404e53a8bf (diff)
downloadayatana-indicator-session-c4dbc5ba3f963a74952c35ef23249694c3593217.tar.gz
ayatana-indicator-session-c4dbc5ba3f963a74952c35ef23249694c3593217.tar.bz2
ayatana-indicator-session-c4dbc5ba3f963a74952c35ef23249694c3593217.zip
Merging in status shuffle branch to package it.
Diffstat (limited to 'src/status-service-dbus.c')
-rw-r--r--src/status-service-dbus.c106
1 files changed, 93 insertions, 13 deletions
diff --git a/src/status-service-dbus.c b/src/status-service-dbus.c
index 9ffc6aa..5d4ba0a 100644
--- a/src/status-service-dbus.c
+++ b/src/status-service-dbus.c
@@ -2,18 +2,41 @@
#include "config.h"
#endif
+#include <dbus/dbus-glib.h>
+
+#include "dbus-shared-names.h"
#include "status-service-dbus.h"
static void status_service_dbus_class_init (StatusServiceDbusClass *klass);
static void status_service_dbus_init (StatusServiceDbus *self);
static void status_service_dbus_dispose (GObject *object);
static void status_service_dbus_finalize (GObject *object);
-static void _status_service_server_watch (void);
-static void _status_service_server_status_icons (void);
-static void _status_service_server_pretty_user_name (void);
+static gboolean _status_service_server_watch (StatusServiceDbus * service, GError ** error);
+static gboolean _status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error);
+static gboolean _status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error);
#include "status-service-server.h"
+/* Private */
+typedef struct _StatusServiceDbusPrivate StatusServiceDbusPrivate;
+struct _StatusServiceDbusPrivate
+{
+ gchar * name;
+};
+
+#define STATUS_SERVICE_DBUS_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), STATUS_SERVICE_DBUS_TYPE, StatusServiceDbusPrivate))
+
+/* Signals */
+enum {
+ USER_CHANGED,
+ STATUS_ICONS_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+/* GObject Boilerplate */
G_DEFINE_TYPE (StatusServiceDbus, status_service_dbus, G_TYPE_OBJECT);
static void
@@ -21,8 +44,46 @@ status_service_dbus_class_init (StatusServiceDbusClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ g_type_class_add_private (object_class, sizeof(StatusServiceDbusPrivate));
+
object_class->dispose = status_service_dbus_dispose;
object_class->finalize = status_service_dbus_finalize;
+
+ /**
+ StatusServiceDbus::user-changed:
+ @arg0: The #StatusServiceDbus object.
+ @arg1: The place to put the new user name
+
+ Signals that the user name has changed and gives the
+ new user name.
+ */
+ signals[USER_CHANGED] = g_signal_new("user-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(StatusServiceDbusClass, user_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ /**
+ StatusServiceDbus::status-icons-changed:
+ @arg0: The #StatusServiceDbus object.
+ @arg1: The list of icon names representing the statuses in
+ the order they should be displayed. Left to right.
+
+ Signals that the user status set has changed and that
+ new icons may need to be loaded. The list of icons will
+ always be complete.
+ */
+ signals[STATUS_ICONS_CHANGED] = g_signal_new("status-icons-changed",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(StatusServiceDbusClass, status_icons_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
+ dbus_g_object_type_install_info(STATUS_SERVICE_DBUS_TYPE, &dbus_glib__status_service_server_object_info);
return;
}
@@ -31,6 +92,14 @@ static void
status_service_dbus_init (StatusServiceDbus *self)
{
+ DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+ dbus_g_connection_register_g_object(connection,
+ INDICATOR_STATUS_SERVICE_DBUS_OBJECT,
+ G_OBJECT(self));
+
+ StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(self);
+ priv->name = "test";
+
return;
}
@@ -50,23 +119,34 @@ status_service_dbus_finalize (GObject *object)
return;
}
-static void
-_status_service_server_watch (void)
+static gboolean
+_status_service_server_watch (StatusServiceDbus * service, GError ** error)
{
- return;
+ return TRUE;
}
-static void
-_status_service_server_status_icons (void)
+static gboolean
+_status_service_server_status_icons (StatusServiceDbus * service, GArray * array, GError ** error)
{
- return;
+ return TRUE;
}
-static void
-_status_service_server_pretty_user_name (void)
+static gboolean
+_status_service_server_pretty_user_name (StatusServiceDbus * service, gchar ** username, GError ** error)
{
-
- return;
+ if (!IS_STATUS_SERVICE_DBUS(service)) {
+ g_warning("NO BAD EVIL!");
+ return FALSE;
+ }
+
+ StatusServiceDbusPrivate * priv = STATUS_SERVICE_DBUS_GET_PRIVATE(service);
+ if (priv->name == NULL) {
+ *username = g_strdup("");
+ } else {
+ *username = g_strdup(priv->name);
+ }
+
+ return TRUE;
}