From efd24605727ee979b35053397463246456cf0ed0 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 10 Sep 2009 16:26:01 -0500 Subject: work in progress --- src/Makefile.am | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index e2f0008..f7fa7a7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,7 +11,8 @@ sessionlib_LTLIBRARIES = libsession.la libsession_la_SOURCES = \ indicator-session.c \ dbus-shared-names.h \ - status-service-client.h + status-service-client.h \ + users-service-client.h libsession_la_CFLAGS = $(APPLET_CFLAGS) -Wall -Werror libsession_la_LIBADD = $(APPLET_LIBS) libsession_la_LDFLAGS = -module -avoid-version @@ -25,6 +26,9 @@ indicator_status_service_SOURCES = \ status-service-dbus.h \ status-service-dbus.c \ status-service-server.h \ + users-service-dbus.h \ + users-service-dbus.c \ + users-service-server.h \ status-provider.h \ status-provider.c \ status-provider-pidgin.h \ @@ -38,6 +42,20 @@ indicator_status_service_SOURCES = \ indicator_status_service_CFLAGS = $(STATUSSERVICE_CFLAGS) -Wall -Werror indicator_status_service_LDADD = $(STATUSSERVICE_LIBS) +users-service-client.h: $(srcdir)/users-service.xml + dbus-binding-tool \ + --prefix=_users_service_client \ + --mode=glib-client \ + --output=users-service-client.h \ + $(srcdir)/users-service.xml + +users-service-server.h: $(srcdir)/users-service.xml + dbus-binding-tool \ + --prefix=_users_service_server \ + --mode=glib-server \ + --output=users-service-server.h \ + $(srcdir)/users-service.xml + status-service-client.h: $(srcdir)/status-service.xml dbus-binding-tool \ --prefix=_status_service_client \ @@ -93,6 +111,8 @@ indicator_session_service_LDADD = $(SESSIONSERVICE_LIBS) $(GCONF_LIBS) ############### BUILT_SOURCES = \ + users-service-client.h \ + users-service-server.h \ status-service-client.h \ status-service-server.h \ status-provider-pidgin-marshal.h \ -- cgit v1.2.3 From a29d1126f86a164d598cda4e4bf000c8afc675c7 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 10 Sep 2009 16:33:12 -0500 Subject: fix link problem --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index f7fa7a7..ffce9b3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,7 +94,7 @@ status-provider-telepathy-marshal.c: $(srcdir)/status-provider-telepathy.list # Users Stuff ############### -indicator_users_service_SOURCES = users-service.c +indicator_users_service_SOURCES = users-service.c users-service-dbus.c indicator_users_service_CFLAGS = $(USERSSERVICE_CFLAGS) -Wall -Werror indicator_users_service_LDADD = $(USERSSERVICE_LIBS) -- cgit v1.2.3 From 8a1dae9a1e1ce8cb59bca4196f1cfc41ea4338df Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Sep 2009 17:08:31 -0500 Subject: Creating a status provider object for Mission Control 5 based on the Telepathy one. --- .bzrignore | 2 + src/Makefile.am | 17 ++ src/status-provider-mc5.c | 383 +++++++++++++++++++++++++++++++++++++++++++ src/status-provider-mc5.h | 56 +++++++ src/status-provider-mc5.list | 1 + 5 files changed, 459 insertions(+) create mode 100644 src/status-provider-mc5.c create mode 100644 src/status-provider-mc5.h create mode 100644 src/status-provider-mc5.list (limited to 'src/Makefile.am') diff --git a/.bzrignore b/.bzrignore index 22ecc23..dd58cdf 100644 --- a/.bzrignore +++ b/.bzrignore @@ -44,3 +44,5 @@ src/status-provider-pidgin-marshal.c src/status-provider-pidgin-marshal.h src/status-provider-telepathy-marshal.c src/status-provider-telepathy-marshal.h +src/status-provider-mc5-marshal.c +src/status-provider-mc5-marshal.h diff --git a/src/Makefile.am b/src/Makefile.am index e2f0008..ae941e1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,6 +27,10 @@ indicator_status_service_SOURCES = \ status-service-server.h \ status-provider.h \ status-provider.c \ + status-provider-mc5.h \ + status-provider-mc5.c \ + status-provider-mc5-marshal.h \ + status-provider-mc5-marshal.c \ status-provider-pidgin.h \ status-provider-pidgin.c \ status-provider-pidgin-marshal.h \ @@ -72,6 +76,16 @@ status-provider-telepathy-marshal.c: $(srcdir)/status-provider-telepathy.list --prefix=_status_provider_telepathy_marshal $(srcdir)/status-provider-telepathy.list \ > status-provider-telepathy-marshal.c +status-provider-mc5-marshal.h: $(srcdir)/status-provider-mc5.list + glib-genmarshal --header \ + --prefix=_status_provider_mc5_marshal $(srcdir)/status-provider-mc5.list \ + > status-provider-mc5-marshal.h + +status-provider-mc5-marshal.c: $(srcdir)/status-provider-mc5.list + glib-genmarshal --body \ + --prefix=_status_provider_mc5_marshal $(srcdir)/status-provider-mc5.list \ + > status-provider-mc5-marshal.c + ############### # Users Stuff ############### @@ -95,6 +109,8 @@ indicator_session_service_LDADD = $(SESSIONSERVICE_LIBS) $(GCONF_LIBS) BUILT_SOURCES = \ status-service-client.h \ status-service-server.h \ + status-provider-mc5-marshal.h \ + status-provider-mc5-marshal.c \ status-provider-pidgin-marshal.h \ status-provider-pidgin-marshal.c \ status-provider-telepathy-marshal.h \ @@ -102,6 +118,7 @@ BUILT_SOURCES = \ EXTRA_DIST = \ status-service.xml \ + status-provider-mc5.list \ status-provider-pidgin.list \ status-provider-telepathy.list diff --git a/src/status-provider-mc5.c b/src/status-provider-mc5.c new file mode 100644 index 0000000..300818d --- /dev/null +++ b/src/status-provider-mc5.c @@ -0,0 +1,383 @@ +/* +A small wrapper utility to load indicators and put them as menu items +into the gnome-panel using it's applet interface. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "status-provider.h" +#include "status-provider-mc5.h" +#include "status-provider-mc5-marshal.h" + +#include + +typedef enum { + MC_STATUS_UNSET, + MC_STATUS_OFFLINE, + MC_STATUS_AVAILABLE, + MC_STATUS_AWAY, + MC_STATUS_EXTENDED_AWAY, + MC_STATUS_HIDDEN, + MC_STATUS_DND +} mc_status_t; + +static StatusProviderStatus mc_to_sp_map[] = { + /* MC_STATUS_UNSET, */ STATUS_PROVIDER_STATUS_OFFLINE, + /* MC_STATUS_OFFLINE, */ STATUS_PROVIDER_STATUS_OFFLINE, + /* MC_STATUS_AVAILABLE, */ STATUS_PROVIDER_STATUS_ONLINE, + /* MC_STATUS_AWAY, */ STATUS_PROVIDER_STATUS_AWAY, + /* MC_STATUS_EXTENDED_AWAY, */ STATUS_PROVIDER_STATUS_AWAY, + /* MC_STATUS_HIDDEN, */ STATUS_PROVIDER_STATUS_INVISIBLE, + /* MC_STATUS_DND */ STATUS_PROVIDER_STATUS_DND +}; + +static mc_status_t sp_to_mc_map[] = { + /* STATUS_PROVIDER_STATUS_ONLINE, */ MC_STATUS_AVAILABLE, + /* STATUS_PROVIDER_STATUS_AWAY, */ MC_STATUS_AWAY, + /* STATUS_PROVIDER_STATUS_DND */ MC_STATUS_DND, + /* STATUS_PROVIDER_STATUS_INVISIBLE*/ MC_STATUS_HIDDEN, + /* STATUS_PROVIDER_STATUS_OFFLINE */ MC_STATUS_OFFLINE, + /* STATUS_PROVIDER_STATUS_DISCONNECTED*/MC_STATUS_OFFLINE +}; + +typedef struct _StatusProviderMC5Private StatusProviderMC5Private; +struct _StatusProviderMC5Private { + DBusGProxy * proxy; + DBusGProxy * dbus_proxy; + mc_status_t mc_status; +}; + +#define STATUS_PROVIDER_MC5_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Private)) + +/* Prototypes */ +/* GObject stuff */ +static void status_provider_mc5_class_init (StatusProviderMC5Class *klass); +static void status_provider_mc5_init (StatusProviderMC5 *self); +static void status_provider_mc5_dispose (GObject *object); +static void status_provider_mc5_finalize (GObject *object); +/* Internal Funcs */ +static void build_mc5_proxy (StatusProviderMC5 * self); +static void dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderMC5 * self); +static void set_status (StatusProvider * sp, StatusProviderStatus status); +static StatusProviderStatus get_status (StatusProvider * sp); +static void changed_status (DBusGProxy * proxy, guint status, gchar * message, StatusProvider * sp); +static void proxy_destroy (DBusGProxy * proxy, StatusProvider * sp); +static void get_status_async (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata); + +G_DEFINE_TYPE (StatusProviderMC5, status_provider_mc5, STATUS_PROVIDER_TYPE); + +static void +status_provider_mc5_class_init (StatusProviderMC5Class *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (StatusProviderMC5Private)); + + object_class->dispose = status_provider_mc5_dispose; + object_class->finalize = status_provider_mc5_finalize; + + StatusProviderClass * spclass = STATUS_PROVIDER_CLASS(klass); + + spclass->set_status = set_status; + spclass->get_status = get_status; + + return; +} + + +static void +status_provider_mc5_init (StatusProviderMC5 *self) +{ + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self); + + priv->proxy = NULL; + priv->dbus_proxy = NULL; + priv->mc_status = MC_STATUS_OFFLINE; + + GError * error = NULL; + + /* Grabbing the session bus */ + DBusGConnection * bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (bus == NULL) { + g_warning("Unable to connect to Session Bus: %s", error == NULL ? "No message" : error->message); + g_error_free(error); + return; + } + + /* Set up the dbus Proxy */ + priv->dbus_proxy = dbus_g_proxy_new_for_name_owner (bus, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + &error); + if (error != NULL) { + g_warning("Unable to connect to DBus events: %s", error->message); + g_error_free(error); + return; + } + + /* Configure the name owner changing */ + dbus_g_proxy_add_signal(priv->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->dbus_proxy, "NameOwnerChanged", + G_CALLBACK(dbus_namechange), + self, NULL); + + build_mc5_proxy(self); + + return; +} + +/* Builds up the proxy to Mission Control and configures all of the + signals for getting info from the proxy. Also does a call to get + the inital value of the status. */ +static void +build_mc5_proxy (StatusProviderMC5 * self) +{ + g_debug("Building MC5 Proxy"); + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(self); + + if (priv->proxy != NULL) { + g_debug("Hmm, being asked to build a proxy we alredy have."); + return; + } + + GError * error = NULL; + + /* Grabbing the session bus */ + DBusGConnection * session_bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (session_bus == NULL) { + g_warning("Unable to connect to Session Bus: %s", error == NULL ? "No message" : error->message); + g_error_free(error); + return; + } + + /* Get the proxy to Mission Control */ + priv->proxy = dbus_g_proxy_new_for_name_owner(session_bus, + "org.freedesktop.Telepathy.MissionControl5", + "/org/freedesktop/Telepathy/MissionControl5", + "org.freedesktop.Telepathy.MissionControl5", + &error); + + if (priv->proxy != NULL) { + /* If it goes, we set the proxy to NULL */ + g_object_add_weak_pointer (G_OBJECT(priv->proxy), (gpointer *)&priv->proxy); + /* And we clean up other variables associated */ + g_signal_connect(G_OBJECT(priv->proxy), "destroy", + G_CALLBACK(proxy_destroy), self); + + /* Set up the signal handler for watching when status changes. */ + dbus_g_object_register_marshaller(_status_provider_mc5_marshal_VOID__UINT_STRING, + G_TYPE_NONE, + G_TYPE_UINT, + G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_add_signal (priv->proxy, + "PresenceChanged", + G_TYPE_UINT, + G_TYPE_STRING, + G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->proxy, + "PresenceChanged", + G_CALLBACK(changed_status), + (void *)self, + NULL); + + /* Do a get here, to init the status */ + dbus_g_proxy_begin_call(priv->proxy, + "GetStatus", + get_status_async, + self, + NULL, + G_TYPE_INVALID); + } else { + g_warning("Unable to connect to Mission Control"); + if (error != NULL) { + g_error_free(error); + } + } + + return; +} + +/* Watch to see if the Mission Control comes up on Dbus */ +static void +dbus_namechange (DBusGProxy * proxy, const gchar * name, const gchar * prev, const gchar * new, StatusProviderMC5 * self) +{ + g_return_if_fail(name != NULL); + g_return_if_fail(new != NULL); + + if (g_strcmp0(name, "org.freedesktop.Telepathy.MissionControl5") == 0) { + build_mc5_proxy(self); + } + return; +} + +static void +status_provider_mc5_dispose (GObject *object) +{ + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(object); + + if (priv->proxy != NULL) { + g_object_unref(priv->proxy); + priv->proxy = NULL; + } + + G_OBJECT_CLASS (status_provider_mc5_parent_class)->dispose (object); + return; +} + +static void +status_provider_mc5_finalize (GObject *object) +{ + + G_OBJECT_CLASS (status_provider_mc5_parent_class)->finalize (object); + return; +} + +/** + status_provider_mc5_new: + + Creates a new #StatusProviderMC5 object. No parameters or anything + like that. Just a convience function. + + Return value: A new instance of #StatusProviderMC5 +*/ +StatusProvider * +status_provider_mc5_new (void) +{ + return STATUS_PROVIDER(g_object_new(STATUS_PROVIDER_MC5_TYPE, NULL)); +} + +static void +set_status (StatusProvider * sp, StatusProviderStatus status) +{ + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp); + if (priv->proxy == NULL) { + priv->mc_status = MC_STATUS_OFFLINE; + return; + } + + priv->mc_status = sp_to_mc_map[status]; + + guint mcstatus = MC_STATUS_UNSET; + gboolean ret = FALSE; + GError * error = NULL; + + ret = dbus_g_proxy_call(priv->proxy, + "GetPresence", &error, + G_TYPE_INVALID, + G_TYPE_UINT, &priv->mc_status, + G_TYPE_INVALID); + + /* If we can't get the get call to work, let's not set */ + if (!ret) { + if (error != NULL) { + g_error_free(error); + } + return; + } + + /* If the get call doesn't return a status, that means that there + are no clients connected. We don't want to connect them by telling + MC that we're going online -- we'd like to be more passive than that. */ + if (mcstatus == MC_STATUS_UNSET) { + return; + } + + ret = dbus_g_proxy_call(priv->proxy, + "SetPresence", &error, + G_TYPE_UINT, priv->mc_status, + G_TYPE_STRING, "", + G_TYPE_INVALID, + G_TYPE_INVALID); + + if (!ret) { + if (error != NULL) { + g_warning("Unable to set Mission Control Presence: %s", error->message); + g_error_free(error); + } else { + g_warning("Unable to set Mission Control Presence"); + } + return; + } + + return; +} + +static StatusProviderStatus +get_status (StatusProvider * sp) +{ + g_return_val_if_fail(IS_STATUS_PROVIDER_MC5(sp), STATUS_PROVIDER_STATUS_DISCONNECTED); + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp); + + if (priv->proxy == NULL) { + return STATUS_PROVIDER_STATUS_DISCONNECTED; + } + + return mc_to_sp_map[priv->mc_status]; +} + +static void +changed_status (DBusGProxy * proxy, guint status, gchar * message, StatusProvider * sp) +{ + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(sp); + priv->mc_status = status; + g_signal_emit(G_OBJECT(sp), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, mc_to_sp_map[priv->mc_status], TRUE); +} + +static void +proxy_destroy (DBusGProxy * proxy, StatusProvider * sp) +{ + g_debug("Signal: Mission Control proxy destroyed"); + g_signal_emit(G_OBJECT(sp), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, STATUS_PROVIDER_STATUS_OFFLINE, TRUE); + return; +} + +static void +get_status_async (DBusGProxy * proxy, DBusGProxyCall * call, gpointer userdata) +{ + GError * error = NULL; + guint status = 0; + if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_UINT, &status, G_TYPE_INVALID)) { + g_warning("Unable to get type from Mission Control: %s", error->message); + g_error_free(error); + return; + } + + StatusProviderMC5Private * priv = STATUS_PROVIDER_MC5_GET_PRIVATE(userdata); + + gboolean changed = FALSE; + if (status != priv->mc_status) { + changed = TRUE; + } + + priv->mc_status = status; + + if (changed) { + g_signal_emit(G_OBJECT(userdata), STATUS_PROVIDER_SIGNAL_STATUS_CHANGED_ID, 0, mc_to_sp_map[priv->mc_status], TRUE); + } + + return; +} diff --git a/src/status-provider-mc5.h b/src/status-provider-mc5.h new file mode 100644 index 0000000..2c03729 --- /dev/null +++ b/src/status-provider-mc5.h @@ -0,0 +1,56 @@ +/* +A small wrapper utility to load indicators and put them as menu items +into the gnome-panel using it's applet interface. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +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 . +*/ + +#ifndef __STATUS_PROVIDER_MC5_H__ +#define __STATUS_PROVIDER_MC5_H__ + +#include +#include + +#include "status-provider.h" + +G_BEGIN_DECLS + +#define STATUS_PROVIDER_MC5_TYPE (status_provider_mc5_get_type ()) +#define STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderTelepathy)) +#define STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), STATUS_PROVIDER_MC5_TYPE, StatusProviderTelepathyClass)) +#define IS_STATUS_PROVIDER_MC5(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), STATUS_PROVIDER_MC5_TYPE)) +#define IS_STATUS_PROVIDER_MC5_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), STATUS_PROVIDER_MC5_TYPE)) +#define STATUS_PROVIDER_MC5_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), STATUS_PROVIDER_MC5_TYPE, StatusProviderMC5Class)) + + +typedef struct _StatusProviderMC5Class StatusProviderMC5Class; +struct _StatusProviderMC5Class { + StatusProviderClass parent_class; +}; + +typedef struct _StatusProviderMC5 StatusProviderMC5; +struct _StatusProviderMC5 { + StatusProvider parent; +}; + +GType status_provider_mc5_get_type (void); +StatusProvider * status_provider_mc5_new (void); + +G_END_DECLS + +#endif diff --git a/src/status-provider-mc5.list b/src/status-provider-mc5.list new file mode 100644 index 0000000..5ab45bf --- /dev/null +++ b/src/status-provider-mc5.list @@ -0,0 +1 @@ +VOID:UINT,STRING -- cgit v1.2.3 From 91c2993398771ca1ff5a65003c681724291d9e2f Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Tue, 22 Sep 2009 14:52:45 -0500 Subject: dbus fu updates --- src/Makefile.am | 16 +++- src/users-service-dbus.c | 221 +++++++++++++++++++++++++++++++++++++---------- src/users-service-dbus.h | 10 ++- src/users-service.c | 19 ++++ src/users-service.list | 1 + src/users-service.xml | 24 ++--- 6 files changed, 226 insertions(+), 65 deletions(-) create mode 100644 src/users-service.list (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index ffce9b3..6404af0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,6 +29,8 @@ indicator_status_service_SOURCES = \ users-service-dbus.h \ users-service-dbus.c \ users-service-server.h \ + users-service-marshal.c \ + users-service-marshal.h \ status-provider.h \ status-provider.c \ status-provider-pidgin.h \ @@ -70,6 +72,16 @@ status-service-server.h: $(srcdir)/status-service.xml --output=status-service-server.h \ $(srcdir)/status-service.xml +users-service-marshal.h: $(srcdir)/users-service.list + glib-genmarshal --header \ + --prefix=_users_service_marshal $(srcdir)/users-service.list \ + > users-service-marshal.h + +users-service-marshal.c: $(srcdir)/users-service.list + glib-genmarshal --body \ + --prefix=_users_service_marshal $(srcdir)/users-service.list \ + > users-service-marshal.c + status-provider-pidgin-marshal.h: $(srcdir)/status-provider-pidgin.list glib-genmarshal --header \ --prefix=_status_provider_pidgin_marshal $(srcdir)/status-provider-pidgin.list \ @@ -94,7 +106,7 @@ status-provider-telepathy-marshal.c: $(srcdir)/status-provider-telepathy.list # Users Stuff ############### -indicator_users_service_SOURCES = users-service.c users-service-dbus.c +indicator_users_service_SOURCES = users-service.c users-service-dbus.c users-service-marshal.c indicator_users_service_CFLAGS = $(USERSSERVICE_CFLAGS) -Wall -Werror indicator_users_service_LDADD = $(USERSSERVICE_LIBS) @@ -115,6 +127,8 @@ BUILT_SOURCES = \ users-service-server.h \ status-service-client.h \ status-service-server.h \ + users-service-marshal.h \ + users-service-marshal.c \ status-provider-pidgin-marshal.h \ status-provider-pidgin-marshal.c \ status-provider-telepathy-marshal.h \ diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 95b0f49..ce22e6f 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -26,36 +26,44 @@ #include "dbus-shared-names.h" #include "users-service-dbus.h" #include "users-service-client.h" - -static void users_service_dbus_class_init (UsersServiceDbusClass *klass); -static void users_service_dbus_init (UsersServiceDbus *self); -static void users_service_dbus_dispose (GObject *object); -static void users_service_dbus_finalize (GObject *object); -static gboolean _users_service_server_count_users (UsersServiceDbus *service, - gint *count, - GError **error); -static gboolean _users_service_server_get_user_list (UsersServiceDbus *service, - GArray **list, - GError **error); -static gboolean _users_service_server_get_user_info (UsersServiceDbus *service, - const gint64 uid, - gchar **username, - gchar **real_name, - gchar **shell, - char **icon_url, - GError **error); -static gboolean _users_service_server_get_users_info (UsersServiceDbus *service, - const GArray *uids, - GPtrArray **user_info, - GError **error); -static void users_loaded (DBusGProxy *proxy, - gpointer user_data); -static void user_added (DBusGProxy *proxy, - guint uid, - gpointer user_data); -static void user_removed (DBusGProxy *proxy, - guint uid, - gpointer user_data); +#include "users-service-marshal.h" + +static void users_service_dbus_class_init (UsersServiceDbusClass *klass); +static void users_service_dbus_init (UsersServiceDbus *self); +static void users_service_dbus_dispose (GObject *object); +static void users_service_dbus_finalize (GObject *object); +static gboolean _users_service_server_count_users (UsersServiceDbus *service, + gint *count, + GError **error); +static gboolean _users_service_server_get_users_loaded (UsersServiceDbus *self, + gboolean *is_loaded, + GError **error); +static gboolean _users_service_server_get_user_list (UsersServiceDbus *service, + GArray **list, + GError **error); +static gboolean _users_service_server_get_user_info (UsersServiceDbus *service, + const gint64 uid, + gchar **username, + gchar **real_name, + gchar **shell, + gint *login_count, + gchar **icon_url, + GError **error); +static gboolean _users_service_server_get_users_info (UsersServiceDbus *service, + const GArray *uids, + GPtrArray **user_info, + GError **error); +static void users_loaded (DBusGProxy *proxy, + gpointer user_data); +static void user_added (DBusGProxy *proxy, + guint uid, + gpointer user_data); +static void user_removed (DBusGProxy *proxy, + guint uid, + gpointer user_data); +static void user_updated (DBusGProxy *proxy, + guint uid, + gpointer user_data); #include "users-service-server.h" @@ -71,6 +79,9 @@ struct _UsersServiceDbusPrivate DBusGConnection *system_bus; DBusGProxy *dbus_proxy_session; DBusGProxy *dbus_proxy_system; + DBusGProxy *gdm_proxy; + + gchar *error; }; #define USERS_SERVICE_DBUS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), USERS_SERVICE_DBUS_TYPE, UsersServiceDbusPrivate)) @@ -80,6 +91,7 @@ enum { USERS_LOADED, USER_ADDED, USER_REMOVED, + USER_UPDATED, LAST_SIGNAL }; @@ -111,16 +123,24 @@ users_service_dbus_class_init (UsersServiceDbusClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (UsersServiceDbusClass, user_added), NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); + _users_service_marshal_VOID__INT64, + G_TYPE_NONE, 1, G_TYPE_INT64); signals[USER_REMOVED] = g_signal_new ("user-removed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (UsersServiceDbusClass, user_removed), NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); + _users_service_marshal_VOID__INT64, + G_TYPE_NONE, 1, G_TYPE_INT64); + + signals[USER_UPDATED] = g_signal_new ("user-updated", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (UsersServiceDbusClass, user_updated), + NULL, NULL, + _users_service_marshal_VOID__INT64, + G_TYPE_NONE, 1, G_TYPE_INT64); dbus_g_object_type_install_info (USERS_SERVICE_DBUS_TYPE, &dbus_glib__users_service_server_object_info); } @@ -140,6 +160,8 @@ users_service_dbus_init (UsersServiceDbus *self) g_error ("Unable to get session bus: %s", error->message); g_error_free (error); + priv->error = g_strdup ("Failed to get session bus"); + return; } @@ -148,6 +170,8 @@ users_service_dbus_init (UsersServiceDbus *self) g_error("Unable to get system bus: %s", error->message); g_error_free(error); + priv->error = g_strdup ("Failed to get system bus"); + return; } @@ -161,42 +185,89 @@ users_service_dbus_init (UsersServiceDbus *self) DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, &error); - if (error != NULL) { - g_error ("Unable to get dbus proxy on session bus: %s", error->message); - g_error_free (error); + if (error != NULL) + { + g_error ("Unable to get dbus proxy on session bus: %s", error->message); + g_error_free (error); - return; - } + priv->error = g_strdup ("Failed to get session proxy"); + + return; + } priv->dbus_proxy_system = dbus_g_proxy_new_for_name_owner (priv->system_bus, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, &error); - if (error != NULL) { - g_error ("Unable to get dbus proxy on system bus: %s", error->message); - g_error_free (error); + if (error != NULL) + { + g_error ("Unable to get dbus proxy on system bus: %s", error->message); + g_error_free (error); - return; - } + priv->error = g_strdup ("Failed to get system proxy"); + + return; + } + + priv->gdm_proxy = dbus_g_proxy_new_for_name_owner (priv->system_bus, // XXX ? + "org.gnome.DisplayManager", + "/org/gnome/DisplayManager/UserManager", + "org.gnome.DisplayManager.UserManager", + &error); + + if (error != NULL) + { + g_error ("Unable to get DisplayManager proxy on system bus: %s", error->message); + g_error_free (error); + + priv->error = g_strdup_printf ("Unable to get DisplayManager proxy: %s", error->message); + } + + dbus_g_proxy_add_signal (priv->gdm_proxy, + "UsersLoaded", + G_TYPE_INVALID); - dbus_g_proxy_connect_signal (priv->dbus_proxy_system, + dbus_g_proxy_add_signal (priv->gdm_proxy, + "UserAdded", + G_TYPE_UINT64, + G_TYPE_INVALID); + + dbus_g_proxy_add_signal (priv->gdm_proxy, + "UserRemoved", + G_TYPE_UINT64, + G_TYPE_INVALID); + + dbus_g_proxy_add_signal (priv->gdm_proxy, + "UserUpdated", + G_TYPE_UINT64, + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (priv->gdm_proxy, "UsersLoaded", G_CALLBACK (users_loaded), self, NULL); - dbus_g_proxy_connect_signal (priv->dbus_proxy_system, + dbus_g_proxy_connect_signal (priv->gdm_proxy, "UserAdded", G_CALLBACK (user_added), self, NULL); - dbus_g_proxy_connect_signal (priv->dbus_proxy_system, + dbus_g_proxy_connect_signal (priv->gdm_proxy, "UserRemoved", G_CALLBACK (user_removed), self, NULL); + + dbus_g_proxy_connect_signal (priv->gdm_proxy, + "UserUpdated", + G_CALLBACK (user_updated), + self, + NULL); + + users_loaded (priv->gdm_proxy, self); } static void @@ -231,6 +302,7 @@ users_loaded (DBusGProxy *proxy, &error)) { g_warning ("failed to retrieve user count: %s", error->message); + priv->error = g_strdup_printf ("Failed to retrieve user count: %s", error->message); g_error_free (error); return; @@ -243,6 +315,8 @@ users_loaded (DBusGProxy *proxy, &error)) { g_warning ("failed to retrieve user list: %s", error->message); + priv->error = g_strdup_printf ("Failed to retrieve user list: %s", error->message); + g_print ("priv->error == %s\n", priv->error); g_error_free (error); return; @@ -254,6 +328,8 @@ users_loaded (DBusGProxy *proxy, &error)) { g_warning ("failed to retrieve user info: %s", error->message); + priv->error = g_strdup_printf ("Failed to get user info: %s", error->message); + g_print ("priv->error == %s\n", priv->error); g_error_free (error); return; @@ -261,7 +337,13 @@ users_loaded (DBusGProxy *proxy, for (i = 0; i < users_info->len; i++) { - UserData *data = g_ptr_array_index (users_info, i); + UserData *data; + + g_print (" -> setting up user %d\n", i); + + data = g_ptr_array_index (users_info, i); + + g_print (" * user_name: %s\n", data->user_name); priv->users = g_list_prepend (priv->users, data); } @@ -280,6 +362,11 @@ users_service_dbus_get_user_list (UsersServiceDbus *self) { UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + g_print ("users_service_dbus_get_user_list()\n"); + + if (!priv->users) + g_print ("users_service_dbus_get_user_list(): priv->users is NULL\n"); + return priv->users; } @@ -300,6 +387,7 @@ user_added (DBusGProxy *proxy, &user->user_name, &user->real_name, &user->shell, + &user->login_count, &user->icon_url, &error)) { @@ -341,6 +429,26 @@ user_removed (DBusGProxy *proxy, } } +static void +user_updated (DBusGProxy *proxy, + guint uid, + gpointer user_data) +{ + UsersServiceDbus *service = (UsersServiceDbus *)user_data; + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service); + GList *l; + + for (l = priv->users; l != NULL; l = g_list_next (l)) + { + UserData *user = (UserData *)l->data; + + if (user->uid == uid) + { + // XXX - update user data + } + } +} + static gboolean _users_service_server_count_users (UsersServiceDbus *service, gint *uids, @@ -357,12 +465,21 @@ _users_service_server_get_user_list (UsersServiceDbus *service, return TRUE; } +static gboolean +_users_service_server_get_users_loaded (UsersServiceDbus *self, + gboolean *is_loaded, + GError **error) +{ + return TRUE; +} + static gboolean _users_service_server_get_user_info (UsersServiceDbus *service, const gint64 uid, gchar **username, gchar **real_name, gchar **shell, + gint *login_count, char **icon_url, GError **error) { @@ -377,3 +494,11 @@ _users_service_server_get_users_info (UsersServiceDbus *service, { return TRUE; } + +gchar * +users_service_dbus_get_error (UsersServiceDbus *self) +{ + UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self); + + return priv->error; +} diff --git a/src/users-service-dbus.h b/src/users-service-dbus.h index 5889aba..370df2e 100644 --- a/src/users-service-dbus.h +++ b/src/users-service-dbus.h @@ -38,10 +38,11 @@ typedef struct _UserData UserData; struct _UserData { - guint64 uid; + uid_t uid; gchar *user_name; gchar *real_name; gchar *shell; + gint login_count; gchar *icon_url; }; @@ -58,15 +59,16 @@ struct _UsersServiceDbusClass { void (* users_loaded) (UsersServiceDbus *self, gpointer user_data); - void (* user_added) (UsersServiceDbus *self, UserData *user, gpointer user_data); - void (* user_removed) (UsersServiceDbus *self, UserData *user, gpointer user_data); + void (* user_added) (UsersServiceDbus *self, gint64 uid, gpointer user_data); + void (* user_removed) (UsersServiceDbus *self, gint64 uid, gpointer user_data); void (* user_updated) (UsersServiceDbus *self, gint64 uid, gpointer user_data); }; GType users_service_dbus_get_type (void) G_GNUC_CONST; gint users_service_dbus_get_user_count (UsersServiceDbus *self); -GList *users_service_dbus_get_user_list (UsersServiceDbus *self); +GList *users_service_dbus_get_user_list (UsersServiceDbus *self); +gchar *users_service_dbus_get_error (UsersServiceDbus *self); G_END_DECLS diff --git a/src/users-service.c b/src/users-service.c index 7c8ab01..c7c2a53 100644 --- a/src/users-service.c +++ b/src/users-service.c @@ -135,6 +135,7 @@ rebuild_items (DbusmenuMenuitem *root, DbusmenuMenuitem *mi = NULL; GList *u; UserData *user; + gchar *error; dbusmenu_menuitem_foreach (root, remove_menu_item, NULL); @@ -145,12 +146,26 @@ rebuild_items (DbusmenuMenuitem *root, g_signal_connect (G_OBJECT (mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_guest_session), NULL); } + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, g_strdup_printf ("START (count is %d)", count)); + dbusmenu_menuitem_child_append (root, mi); + + error = users_service_dbus_get_error (service); + + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, g_strdup_printf ("ERROR: %s", error)); + dbusmenu_menuitem_child_append (root, mi); + + g_print ("count == %d\n", count); + if (count > 1 && count < 7) { for (u = users; u != NULL; u = g_list_next (u)) { user = u->data; + g_print ("user->real_name == %s\n", user->real_name); + mi = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, user->real_name); dbusmenu_menuitem_child_append (root, mi); @@ -158,6 +173,10 @@ rebuild_items (DbusmenuMenuitem *root, } } + mi = dbusmenu_menuitem_new (); + dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, "END"); + dbusmenu_menuitem_child_append (root,mi); + if (check_new_session ()) { mi = dbusmenu_menuitem_new (); dbusmenu_menuitem_property_set (mi, DBUSMENU_MENUITEM_PROP_LABEL, _("New Session...")); diff --git a/src/users-service.list b/src/users-service.list new file mode 100644 index 0000000..36f34ba --- /dev/null +++ b/src/users-service.list @@ -0,0 +1 @@ +VOID:INT64 diff --git a/src/users-service.xml b/src/users-service.xml index 9eccf5d..c90f1e8 100644 --- a/src/users-service.xml +++ b/src/users-service.xml @@ -18,6 +18,7 @@ + @@ -25,23 +26,17 @@ - + - - + + + + - + - - - - - @@ -52,5 +47,10 @@ + + + + + -- cgit v1.2.3 From c608393d5e0650f348fc39769531cb0a1e7c95a0 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 23 Sep 2009 23:15:56 -0500 Subject: remove the server code --- src/Makefile.am | 9 ------- src/users-service-dbus.c | 69 ------------------------------------------------ 2 files changed, 78 deletions(-) (limited to 'src/Makefile.am') diff --git a/src/Makefile.am b/src/Makefile.am index 6404af0..239a943 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,6 @@ indicator_status_service_SOURCES = \ status-service-server.h \ users-service-dbus.h \ users-service-dbus.c \ - users-service-server.h \ users-service-marshal.c \ users-service-marshal.h \ status-provider.h \ @@ -51,13 +50,6 @@ users-service-client.h: $(srcdir)/users-service.xml --output=users-service-client.h \ $(srcdir)/users-service.xml -users-service-server.h: $(srcdir)/users-service.xml - dbus-binding-tool \ - --prefix=_users_service_server \ - --mode=glib-server \ - --output=users-service-server.h \ - $(srcdir)/users-service.xml - status-service-client.h: $(srcdir)/status-service.xml dbus-binding-tool \ --prefix=_status_service_client \ @@ -124,7 +116,6 @@ indicator_session_service_LDADD = $(SESSIONSERVICE_LIBS) $(GCONF_LIBS) BUILT_SOURCES = \ users-service-client.h \ - users-service-server.h \ status-service-client.h \ status-service-server.h \ users-service-marshal.h \ diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c index 0ae0170..5a9b874 100644 --- a/src/users-service-dbus.c +++ b/src/users-service-dbus.c @@ -38,27 +38,6 @@ static void users_service_dbus_class_init (UsersServiceDbusClass *k static void users_service_dbus_init (UsersServiceDbus *self); static void users_service_dbus_dispose (GObject *object); static void users_service_dbus_finalize (GObject *object); -static gboolean _users_service_server_count_users (UsersServiceDbus *service, - gint *count, - GError **error); -static gboolean _users_service_server_get_users_loaded (UsersServiceDbus *self, - gboolean *is_loaded, - GError **error); -static gboolean _users_service_server_get_user_list (UsersServiceDbus *service, - GArray **list, - GError **error); -static gboolean _users_service_server_get_user_info (UsersServiceDbus *service, - const gint64 uid, - gchar **username, - gchar **real_name, - gchar **shell, - gint *login_count, - gchar **icon_url, - GError **error); -static gboolean _users_service_server_get_users_info (UsersServiceDbus *service, - const GArray *uids, - GPtrArray **user_info, - GError **error); static void create_system_proxy (UsersServiceDbus *self); static void create_gdm_proxy (UsersServiceDbus *self); static void create_seat_proxy (UsersServiceDbus *self); @@ -87,8 +66,6 @@ static gboolean do_add_session (UsersServiceDbus *servi const gchar *ssid); static gchar * get_seat_internal (UsersServiceDbus *self); -#include "users-service-server.h" - /* Private */ typedef struct _UsersServiceDbusPrivate UsersServiceDbusPrivate; @@ -1064,52 +1041,6 @@ user_updated (DBusGProxy *proxy, #endif } -static gboolean -_users_service_server_count_users (UsersServiceDbus *service, - gint *uids, - GError **error) -{ - return TRUE; -} - -static gboolean -_users_service_server_get_user_list (UsersServiceDbus *service, - GArray **list, - GError **error) -{ - return TRUE; -} - -static gboolean -_users_service_server_get_users_loaded (UsersServiceDbus *self, - gboolean *is_loaded, - GError **error) -{ - return TRUE; -} - -static gboolean -_users_service_server_get_user_info (UsersServiceDbus *service, - const gint64 uid, - gchar **username, - gchar **real_name, - gchar **shell, - gint *login_count, - char **icon_url, - GError **error) -{ - return TRUE; -} - -static gboolean -_users_service_server_get_users_info (UsersServiceDbus *service, - const GArray *uids, - GPtrArray **user_info, - GError **error) -{ - return TRUE; -} - gint users_service_dbus_get_user_count (UsersServiceDbus *self) { -- cgit v1.2.3