61
my_activate_user (IndicatorSessionUsers * users, const char * key)
61
my_activate_user (IndicatorSessionUsers * users, guint uid)
63
g_message ("%s %s users %p key %s FIXME", G_STRLOC, G_STRFUNC, (void*)users, key);
63
g_message ("%s %s users %p uid %u FIXME", G_STRLOC, G_STRFUNC, (void*)users, uid);
67
my_get_keys (IndicatorSessionUsers * users)
67
my_get_uids (IndicatorSessionUsers * users)
75
69
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS_MOCK(users), NULL);
76
p = INDICATOR_SESSION_USERS_MOCK (users)->priv;
79
keys = g_new (gchar*, g_hash_table_size(p->users)+1);
80
g_hash_table_iter_init (&iter, p->users);
81
while (g_hash_table_iter_next (&iter, &key, NULL))
82
keys[i++] = g_strdup (key);
71
return g_hash_table_get_keys (INDICATOR_SESSION_USERS_MOCK(users)->priv->users);
88
74
static IndicatorSessionUser *
89
my_get_user (IndicatorSessionUsers * self, const gchar * key)
75
my_get_user (IndicatorSessionUsers * self, guint uid)
92
78
const IndicatorSessionUser * src;
95
81
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS_MOCK(self), NULL);
96
82
p = INDICATOR_SESSION_USERS_MOCK (self)->priv;
98
if ((src = g_hash_table_lookup (p->users, key)))
84
if ((src = g_hash_table_lookup (p->users, GUINT_TO_POINTER(uid))))
100
86
ret = g_new0 (IndicatorSessionUser, 1);
101
87
ret->is_current_user = src->is_current_user;
124
110
users_class = INDICATOR_SESSION_USERS_CLASS (klass);
125
111
users_class->is_live_session = my_is_live_session;
126
users_class->get_keys = my_get_keys;
112
users_class->get_uids = my_get_uids;
127
113
users_class->get_user = my_get_user;
128
114
users_class->activate_user = my_activate_user;
141
127
IndicatorSessionUsersMockPriv);
144
p->users = g_hash_table_new_full (g_str_hash,
130
p->users = g_hash_table_new_full (g_direct_hash,
147
133
(GDestroyNotify)indicator_session_user_free);
149
135
g_signal_connect_swapped (mock_settings, "changed::is-live-session",
167
153
indicator_session_users_mock_add_user (IndicatorSessionUsersMock * self,
169
154
IndicatorSessionUser * user)
171
156
g_return_if_fail (INDICATOR_IS_SESSION_USERS_MOCK (self));
172
g_return_if_fail (key && *key);
173
157
g_return_if_fail (user != NULL);
158
g_return_if_fail (user->uid > 0);
159
g_return_if_fail (!g_hash_table_contains (self->priv->users, GUINT_TO_POINTER(user->uid)));
175
g_hash_table_insert (self->priv->users, g_strdup(key), user);
176
indicator_session_users_added (INDICATOR_SESSION_USERS (self), key);
161
g_hash_table_insert (self->priv->users, GUINT_TO_POINTER(user->uid), user);
162
indicator_session_users_added (INDICATOR_SESSION_USERS (self), user->uid);
180
166
indicator_session_users_mock_remove_user (IndicatorSessionUsersMock * self,
183
169
g_return_if_fail (INDICATOR_IS_SESSION_USERS_MOCK (self));
184
g_return_if_fail (key && *key);
170
g_return_if_fail (uid > 0);
186
g_hash_table_remove (self->priv->users, key);
187
indicator_session_users_removed (INDICATOR_SESSION_USERS (self), key);
172
g_hash_table_remove (self->priv->users, GUINT_TO_POINTER(uid));
173
indicator_session_users_removed (INDICATOR_SESSION_USERS (self), uid);