aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-08-19 18:10:09 +0100
committerConor Curran <conor.curran@canonical.com>2011-08-19 18:10:09 +0100
commit733c32bb8d9619109ad47ab599c2f960cf19308b (patch)
treec44b7bdd9e5560ad736e24d6845d40b2e0bc3cdc
parentdea3599b2e7061a1ece931ac5afae57c8c28f125 (diff)
downloadayatana-indicator-session-733c32bb8d9619109ad47ab599c2f960cf19308b.tar.gz
ayatana-indicator-session-733c32bb8d9619109ad47ab599c2f960cf19308b.tar.bz2
ayatana-indicator-session-733c32bb8d9619109ad47ab599c2f960cf19308b.zip
users now dynamically responsive to addition and deletion of users
-rw-r--r--src/user-menu-mgr.c12
-rw-r--r--src/users-service-dbus.c29
2 files changed, 30 insertions, 11 deletions
diff --git a/src/user-menu-mgr.c b/src/user-menu-mgr.c
index 44c1960..e1796ce 100644
--- a/src/user-menu-mgr.c
+++ b/src/user-menu-mgr.c
@@ -76,7 +76,7 @@ user_menu_mgr_init (UserMenuMgr *self)
G_CALLBACK (user_change),
self);
g_signal_connect (G_OBJECT (self->users_dbus_interface),
- "user-removed",
+ "user-deleted",
G_CALLBACK (user_change),
self);
}
@@ -174,6 +174,9 @@ user_menu_mgr_rebuild_items (UserMenuMgr *self, gboolean greeter_mode)
user_menu_is_visible = self->user_count > 1;
}
+ g_debug ("USER COUNT FROM REBUILD PERSPECTIVE : %i",
+ self->user_count);
+
session_dbus_set_user_menu_visibility (self->session_dbus_interface,
user_menu_is_visible);
@@ -364,9 +367,10 @@ user_change (UsersServiceDbus *service,
const gchar *user_id,
gpointer user_data)
{
- //DbusmenuMenuitem *root = (DbusmenuMenuitem *)user_data;
- // TODO sort this out.
- //rebuild_user_items (root, service);
+ g_debug ("user change in the user menu mgr");
+ g_return_if_fail (USER_IS_MENU_MGR (user_data));
+ UserMenuMgr* user_mgr = USER_MENU_MGR(user_data);
+ user_menu_mgr_rebuild_items (user_mgr, FALSE);
return;
}
diff --git a/src/users-service-dbus.c b/src/users-service-dbus.c
index e7507a4..434bab8 100644
--- a/src/users-service-dbus.c
+++ b/src/users-service-dbus.c
@@ -711,11 +711,6 @@ sync_users (UsersServiceDbus *self)
g_return_if_fail(IS_USERS_SERVICE_DBUS(self));
UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (self);
- if (g_hash_table_size (priv->users) > 0)
- {
- return;
- }
-
if (priv->count > MINIMUM_USERS && priv->count < MAXIMUM_USERS)
{
GPtrArray *users = NULL;
@@ -758,7 +753,13 @@ sync_users (UsersServiceDbus *self)
continue;
}
-
+ // Double check we havent processed this user already
+ if (users_service_dbus_get_user_by_username (self,
+ g_value_get_string (g_hash_table_lookup (properties, "UserName"))) != NULL)
+ {
+ continue;
+ }
+
user = g_new0 (UserData, 1);
user->uid = g_value_get_uint64 (g_hash_table_lookup (properties, "Uid"));
@@ -788,13 +789,19 @@ user_added (DBusGProxy *proxy,
{
UsersServiceDbus *service = (UsersServiceDbus *)user_data;
UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service);
-
+ g_debug ("user added in the service dbus");
priv->count++;
if (priv->count < MAXIMUM_USERS)
{
+ g_debug ("syncing users");
sync_users (service);
}
+
+ g_signal_emit (service,
+ signals[USER_ADDED],
+ 0,
+ user_id);
}
static void
@@ -802,11 +809,19 @@ user_deleted (DBusGProxy *proxy,
const gchar *user_id,
gpointer user_data)
{
+ g_debug ("user deleted in the service dbus");
+
UsersServiceDbus *service = (UsersServiceDbus *)user_data;
UsersServiceDbusPrivate *priv = USERS_SERVICE_DBUS_GET_PRIVATE (service);
priv->count--;
g_hash_table_remove (priv->users, user_id);
+
+ g_signal_emit (service,
+ signals[USER_DELETED],
+ 0,
+ user_id);
+
}
UserData *