57
get_public_key_for_uid (guint uid)
60
g_snprintf (buf, sizeof(buf), "%u", uid);
65
57
emit_user_added (IndicatorSessionUsersDbus * self, guint uid)
67
const gchar * const public_key = get_public_key_for_uid (uid);
68
indicator_session_users_added (INDICATOR_SESSION_USERS(self), public_key);
59
indicator_session_users_added (INDICATOR_SESSION_USERS(self), uid);
72
63
emit_user_changed (IndicatorSessionUsersDbus * self, guint uid)
74
const gchar * const public_key = get_public_key_for_uid (uid);
75
indicator_session_users_changed (INDICATOR_SESSION_USERS(self), public_key);
65
indicator_session_users_changed (INDICATOR_SESSION_USERS(self), uid);
79
69
emit_user_removed (IndicatorSessionUsersDbus * self, guint uid)
81
const gchar * const public_key = get_public_key_for_uid (uid);
82
indicator_session_users_removed (INDICATOR_SESSION_USERS(self), public_key);
71
indicator_session_users_removed (INDICATOR_SESSION_USERS(self), uid);
124
113
set_logins (IndicatorSessionUsersDbus * self, GHashTable * logins)
126
115
GHashTable * old_logins = self->priv->logins;
128
117
GHashTableIter iter;
130
119
self->priv->logins = logins;
132
121
/* fire 'user changed' event for users who logged out */
133
122
g_hash_table_iter_init (&iter, old_logins);
134
while ((g_hash_table_iter_next (&iter, &key, NULL)))
135
if (!g_hash_table_contains (logins, key))
136
emit_user_changed (self, GPOINTER_TO_INT(key));
123
while ((g_hash_table_iter_next (&iter, &uid, NULL)))
124
if (!g_hash_table_contains (logins, uid))
125
emit_user_changed (self, GPOINTER_TO_UINT(uid));
138
127
/* fire 'user changed' event for users who logged in */
139
128
g_hash_table_iter_init (&iter, logins);
140
while ((g_hash_table_iter_next (&iter, &key, NULL)))
141
if (!g_hash_table_contains (old_logins, key))
142
emit_user_changed (self, GPOINTER_TO_INT(key));
129
while ((g_hash_table_iter_next (&iter, &uid, NULL)))
130
if (!g_hash_table_contains (old_logins, uid))
131
emit_user_changed (self, GPOINTER_TO_UINT(uid));
144
133
g_hash_table_destroy (old_logins);
205
194
return g_hash_table_lookup (p->uid_to_account, GUINT_TO_POINTER(uid));
208
static AccountsUser *
209
get_user_for_public_key (IndicatorSessionUsersDbus * self, const char * public_key)
211
return get_user_for_uid (self, g_ascii_strtoull (public_key, NULL, 10));
215
198
**** User Account Tracking
521
504
/* switch to (or create) a session for the specified user */
523
my_activate_user (IndicatorSessionUsers * users, const char * public_key)
506
my_activate_user (IndicatorSessionUsers * users, guint uid)
525
508
IndicatorSessionUsersDbus * self = INDICATOR_SESSION_USERS_DBUS(users);
526
509
priv_t * p = self->priv;
527
510
AccountsUser * au;
528
511
const char * username;
530
au = get_user_for_public_key (self, public_key);
513
au = get_user_for_uid (self, uid);
531
514
username = au ? accounts_user_get_user_name (au) : NULL;
535
g_warning ("%s %s can't find user for '%s'", G_STRLOC, G_STRFUNC, public_key);
518
g_warning ("%s %s can't find user '%u'", G_STRLOC, G_STRFUNC, uid);
556
539
return INDICATOR_SESSION_USERS_DBUS(users)->priv->is_live;
559
/* get a list of public keys for the users that we know about */
561
my_get_keys (IndicatorSessionUsers * users)
542
/* get a list of our user ids */
544
my_get_uids (IndicatorSessionUsers * users)
566
548
GHashTableIter iter;
571
552
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS_DBUS(users), NULL);
572
553
p = INDICATOR_SESSION_USERS_DBUS (users)->priv;
575
h = p->uid_to_account;
576
keys = g_new (gchar*, g_hash_table_size(h)+1);
577
g_hash_table_iter_init (&iter, h);
556
g_hash_table_iter_init (&iter, p->uid_to_account);
578
557
while (g_hash_table_iter_next (&iter, &uid, &user))
579
558
if (!accounts_user_get_system_account (user))
580
keys[i++] = g_strdup (get_public_key_for_uid ((guint)uid));
559
uids = g_list_prepend (uids, uid);
586
564
/* build a new struct populated with info on the specified user */
587
565
static IndicatorSessionUser *
588
my_get_user (IndicatorSessionUsers * users, const gchar * public_key)
566
my_get_user (IndicatorSessionUsers * users, guint uid)
590
568
IndicatorSessionUsersDbus * self = INDICATOR_SESSION_USERS_DBUS (users);
591
569
priv_t * p = self->priv;
593
571
AccountsUser * au;
596
au = get_user_for_public_key (self, public_key);
574
au = get_user_for_uid (self, uid);
598
575
if (au && !accounts_user_get_system_account(au))
600
const guint uid = accounts_user_get_uid (au);
577
g_assert (uid == accounts_user_get_uid (au));
602
579
ret = g_new0 (IndicatorSessionUser, 1);
663
640
users_class = INDICATOR_SESSION_USERS_CLASS (klass);
664
641
users_class->is_live_session = my_is_live_session;
665
users_class->get_keys = my_get_keys;
642
users_class->get_uids = my_get_uids;
666
643
users_class->get_user = my_get_user;
667
644
users_class->activate_user = my_activate_user;