aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am16
-rw-r--r--src/users-service-dbus.c221
-rw-r--r--src/users-service-dbus.h10
-rw-r--r--src/users-service.c19
-rw-r--r--src/users-service.list1
-rw-r--r--src/users-service.xml24
6 files changed, 226 insertions, 65 deletions
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,
@@ -358,11 +466,20 @@ _users_service_server_get_user_list (UsersServiceDbus *service,
}
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 @@
<arg name="user_name" direction="out" type="s"/>
<arg name="real_name" direction="out" type="s"/>
<arg name="shell" direction="out" type="s"/>
+ <arg name="login_count" direction="out" type="i"/>
<arg name="icon_url" direction="out" type="s"/>
</method>
@@ -25,23 +26,17 @@
<method name="GetUsersInfo">
<arg name="uid" direction="in" type="ax"/>
<!-- (uid, user_name, real_name, shell, icon_url) -->
- <arg name="user_info" direction="out" type="a(xssss)"/>
+ <arg name="user_info" direction="out" type="a(xsssis)"/>
</method>
- <!-- Triggered when user information is being reloaded.
- All existing user information is invalid from this signal.
- Wait for the UsersLoaded signal -->
- <signal name="LoadingUsers"></signal>
+ <!-- Query if the initial user list is loaded -->
+ <method name="GetUsersLoaded">
+ <arg name="is_loaded" direction="out" type="b"/>
+ </method>
- <!-- Triggered when user information has been reloaded.
- A client should call GetUserList() now -->
+ <!-- Triggered when the initial user list is loaded -->
<signal name="UsersLoaded"></signal>
- <!-- Triggered when a user has updated information -->
- <signal name="UserUpdated">
- <arg name="uid" type="x"/>
- </signal>
-
<!-- Triggered when a users are added to/removed from the system.
Clients should monitor these signals as soon as they connect to
this object -->
@@ -52,5 +47,10 @@
<arg name="uid" type="x"/>
</signal>
+ <!-- Triggered when a user has updated information -->
+ <signal name="UserUpdated">
+ <arg name="uid" type="x"/>
+ </signal>
+
</interface>
</node>