1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
|
/*
* Copyright 2013 Canonical Ltd.
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "dbus-accounts.h"
#include "dbus-consolekit-seat.h"
#include "dbus-consolekit-session.h"
#include "dbus-consolekit-manager.h"
#include "dbus-user.h"
#include "users.h"
struct _IndicatorSessionUsersDbusPriv
{
char * active_session_id;
Accounts * accounts;
DisplayManagerSeat * dm_seat;
ConsoleKitSeat * seat_proxy;
/* user's dbus object path -> AccountsUser* */
GHashTable * path_to_user;
/* uint32 user-id --> user's dbus object path */
GHashTable * uid_to_user_path;
/* uint32 user-id --> hashset of ssid strings */
GHashTable * uid_to_sessions;
/* ssid string --> uint32 user-id */
GHashTable * session_to_uid;
GCancellable * cancellable;
};
typedef IndicatorSessionUsersDbusPriv priv_t;
G_DEFINE_TYPE (IndicatorSessionUsersDbus,
indicator_session_users_dbus,
INDICATOR_TYPE_SESSION_USERS)
/***
****
***/
static void create_user_proxy_for_path (IndicatorSessionUsersDbus * self,
const char * path);
static void create_session_proxy_for_ssid (IndicatorSessionUsersDbus * self,
const char * ssid);
static void
emit_user_changed_for_path (IndicatorSessionUsersDbus * self, const char * path)
{
AccountsUser * user = g_hash_table_lookup (self->priv->path_to_user, path);
if (user && !accounts_user_get_system_account (user))
indicator_session_users_changed (INDICATOR_SESSION_USERS(self), path);
}
static void
emit_user_changed_for_uid (IndicatorSessionUsersDbus * self, guint uid)
{
const char * path;
if ((path = g_hash_table_lookup (self->priv->uid_to_user_path, GUINT_TO_POINTER(uid))))
emit_user_changed_for_path (self, path);
}
/***
**** ACCOUNT MANAGER / USER TRACKING
***/
/* called when a user proxy gets the 'Changed' signal */
static void
on_user_changed (AccountsUser * user, gpointer gself)
{
/* Accounts.User doesn't update properties in the standard way,
* so create a new proxy to pull in the new properties.
* The older proxy is freed when it's removed from our path_to_user hash */
const char * path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(user));
create_user_proxy_for_path (gself, path);
}
static void
track_user (IndicatorSessionUsersDbus * self,
AccountsUser * user)
{
priv_t * p;
const char * path;
gboolean already_had_user;
p = self->priv;
path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(user));
already_had_user = g_hash_table_contains (p->path_to_user, path);
g_signal_connect (user, "changed", G_CALLBACK(on_user_changed), self);
g_hash_table_insert (p->path_to_user, g_strdup(path), user);
if (already_had_user)
{
emit_user_changed_for_path (self, path);
}
else
{
const guint uid = (guint) accounts_user_get_uid (user);
g_hash_table_insert (p->uid_to_user_path,
GUINT_TO_POINTER(uid),
g_strdup(path));
if (!accounts_user_get_system_account (user))
indicator_session_users_added (INDICATOR_SESSION_USERS(self), path);
}
}
static void
untrack_user (IndicatorSessionUsersDbus * self,
const gchar * path)
{
g_hash_table_remove (self->priv->path_to_user, path);
indicator_session_users_removed (INDICATOR_SESSION_USERS(self), path);
}
static void
on_user_proxy_ready (GObject * o G_GNUC_UNUSED,
GAsyncResult * res,
gpointer self)
{
GError * err;
AccountsUser * user;
err = NULL;
user = accounts_user_proxy_new_for_bus_finish (res, &err);
if (err != NULL)
{
g_warning ("%s: %s", G_STRFUNC, err->message);
g_error_free (err);
}
else
{
track_user (self, user);
}
}
static void
create_user_proxy_for_path (IndicatorSessionUsersDbus * self,
const char * path)
{
const char * name = "org.freedesktop.Accounts";
const GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES;
accounts_user_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
flags, name, path,
self->priv->cancellable,
on_user_proxy_ready, self);
}
static void
on_user_list_ready (GObject * o, GAsyncResult * res, gpointer gself)
{
GError * err;
gchar ** paths;
err = NULL;
paths = NULL;
accounts_call_list_cached_users_finish (ACCOUNTS(o), &paths, res, &err);
if (err != NULL)
{
g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message);
g_error_free (err);
}
else
{
int i;
for (i=0; paths && paths[i]; ++i)
create_user_proxy_for_path (gself, paths[i]);
g_strfreev (paths);
}
}
static void
set_account_manager (IndicatorSessionUsersDbus * self, Accounts * a)
{
priv_t * p = self->priv;
if (p->accounts != NULL)
{
g_signal_handlers_disconnect_by_data (p->accounts, self);
g_clear_object (&p->accounts);
}
if (a != NULL)
{
p->accounts = g_object_ref (a);
accounts_call_list_cached_users (a,
self->priv->cancellable,
on_user_list_ready,
self);
g_signal_connect_swapped (a, "user-added",
G_CALLBACK(create_user_proxy_for_path), self);
g_signal_connect_swapped (a, "user-deleted",
G_CALLBACK(untrack_user), self);
}
}
#if 0
static void
create_accounts_proxy (IndicatorSessionUsersDbus * self)
{
const char * name = "org.freedesktop.Accounts";
const char * path = "/org/freedesktop/Accounts";
GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES;
accounts_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
flags, name, path,
self->priv->cancellable,
on_accounts_proxy_ready, self);
}
#endif
/**
* SEAT / SESSION TRACKING
*
* There are two simple goals here:
*
* 1. Keep track of how many GUI sessions each user has
* so that we can set the 'is_logged_in' flag correctly
*
* 2. Also track which is the current session,
* so that we can compare it to those GUI sessions to
* set the 'is_current_session' flag correctly.
*
* Now that you know the goals, these steps may make more sense:
*
* 1. create a ConsoleKitManager proxy
* 2. ask it for the current session
* 3. create a corresponding Session proxy
* 4. ask that Session proxy for its seat
* 5. create a corresponding Seat proxy
* 6. connect to that seat's session-added / session-removed signals
* 7. ask the seat for a list of its current sessions
* 8. create corresponding Session proxies
* 9. of them, look for the GUI sessions by checking their X11 properties
* 10. for each GUI session, get the corresponding uid
* 11. use the information to update our uid <--> GUI sessions tables
*/
static void
track_session (IndicatorSessionUsersDbus * self,
const char * ssid,
guint uid)
{
gpointer uid_key;
GHashTable * sessions;
uid_key = GUINT_TO_POINTER (uid);
sessions = g_hash_table_lookup (self->priv->uid_to_sessions, uid_key);
if (sessions == NULL)
{
sessions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
g_hash_table_insert (self->priv->uid_to_sessions, uid_key, sessions);
}
g_hash_table_add (sessions, g_strdup (ssid));
g_hash_table_insert (self->priv->session_to_uid, g_strdup(ssid), uid_key);
g_debug ("%s %s now tracking ssid:%s uid:%u. uid has %u tracked ssids.",
G_STRLOC, G_STRFUNC, ssid, uid, g_hash_table_size (sessions));
emit_user_changed_for_uid (self, uid);
}
static void
untrack_session (IndicatorSessionUsersDbus * self,
const char * ssid)
{
gpointer uidptr;
priv_t * p = self->priv;
if (g_hash_table_lookup_extended (p->session_to_uid, ssid, NULL, &uidptr))
{
const guint uid = GPOINTER_TO_UINT (uidptr);
GHashTable * sessions = g_hash_table_lookup (p->uid_to_sessions, uidptr);
g_hash_table_remove (p->session_to_uid, ssid);
g_hash_table_remove (sessions, ssid);
g_debug ("%s %s not tracking ssid:%s uid:%u. uid has %u tracked ssids.",
G_STRLOC, G_STRFUNC, ssid, uid,
sessions ? g_hash_table_size (sessions) : 0);
emit_user_changed_for_uid (self, uid);
}
}
static void
on_session_proxy_uid_ready (GObject * o,
GAsyncResult * res,
gpointer gself)
{
guint uid;
GError * err;
ConsoleKitSession * session = CONSOLE_KIT_SESSION (o);
uid = 0;
err = NULL;
console_kit_session_call_get_unix_user_finish (session, &uid, res, &err);
if (err != NULL)
{
g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message);
g_error_free (err);
}
else if (uid)
{
const char * path = g_dbus_proxy_get_object_path (G_DBUS_PROXY(session));
track_session (gself, path, uid);
}
g_object_unref (o);
}
static void
on_session_x11_display_ready (GObject * o,
GAsyncResult * res,
gpointer gself)
{
priv_t * p;
GError * err;
gchar * gui;
ConsoleKitSession * session;
p = INDICATOR_SESSION_USERS_DBUS(gself)->priv;
err = NULL;
gui = NULL;
session = CONSOLE_KIT_SESSION (o);
console_kit_session_call_get_x11_display_finish (session, &gui, res, &err);
if (err != NULL)
{
g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message);
g_error_free (err);
}
else
{
gboolean is_gui_session;
is_gui_session = gui && *gui;
if (!is_gui_session)
g_clear_object (&session);
else
console_kit_session_call_get_unix_user (session,
p->cancellable,
on_session_proxy_uid_ready,
gself);
g_free (gui);
}
}
static void
on_session_proxy_ready (GObject * o G_GNUC_UNUSED, GAsyncResult * res, gpointer gself)
{
GError * err;
ConsoleKitSession * session;
err = NULL;
session = console_kit_session_proxy_new_finish (res, &err);
if (err != NULL)
{
g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message);
g_error_free (err);
}
else if (session != NULL)
{
priv_t * p = INDICATOR_SESSION_USERS_DBUS(gself)->priv;
console_kit_session_call_get_x11_display (session,
p->cancellable,
on_session_x11_display_ready,
gself);
}
}
static void
create_session_proxy_for_ssid (IndicatorSessionUsersDbus * self,
const char * ssid)
{
const char * name = "org.freedesktop.ConsoleKit";
GDBusProxyFlags flags = G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES;
console_kit_session_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
flags, name, ssid,
self->priv->cancellable,
on_session_proxy_ready, self);
}
static void
on_session_list_ready (GObject * o, GAsyncResult * res, gpointer gself)
{
GError * err;
gchar ** sessions;
err = NULL;
sessions = NULL;
console_kit_seat_call_get_sessions_finish (CONSOLE_KIT_SEAT(o),
&sessions, res, &err);
if (err != NULL)
{
g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message);
g_error_free (err);
}
else
{
int i;
for (i=0; sessions && sessions[i]; i++)
create_session_proxy_for_ssid (gself, sessions[i]);
g_strfreev (sessions);
}
}
static inline guint
get_uid_for_session (IndicatorSessionUsersDbus * self, const char * ssid)
{
guint uid = 0;
gpointer value;
if (ssid != NULL)
if ((value = g_hash_table_lookup (self->priv->session_to_uid, ssid)))
uid = GPOINTER_TO_UINT (value);
return uid;
}
/* it's a live session if username is 'ubuntu' and uid is 999 */
static gboolean
is_live_ssid (IndicatorSessionUsersDbus * self, const char * ssid)
{
priv_t * p;
guint uid;
p = INDICATOR_SESSION_USERS_DBUS (self)->priv;
uid = get_uid_for_session (self, ssid);
if (uid == 999)
{
const char * path;
AccountsUser * user = NULL;
if ((path = g_hash_table_lookup (p->uid_to_user_path, GUINT_TO_POINTER (uid))))
user = g_hash_table_lookup (p->path_to_user, path);
return (user != NULL) && !g_strcmp0 (accounts_user_get_user_name(user), "ubuntu");
}
return FALSE;
}
static void
set_active_session (IndicatorSessionUsersDbus * self, const char * ssid)
{
priv_t * p = self->priv;
const guint old_uid = get_uid_for_session (self, p->active_session_id);
const guint new_uid = get_uid_for_session (self, ssid);
const gboolean old_live = is_live_ssid (self, p->active_session_id);
const gboolean new_live = is_live_ssid (self, ssid);
g_debug ("%s %s changing active_session_id from '%s' to '%s'",
G_STRLOC, G_STRFUNC, p->active_session_id, ssid);
g_free (p->active_session_id);
p->active_session_id = g_strdup (ssid);
if (old_uid != new_uid)
{
emit_user_changed_for_uid (self, old_uid);
emit_user_changed_for_uid (self, new_uid);
}
if (old_live != new_live)
{
indicator_session_users_notify_is_live_session (INDICATOR_SESSION_USERS(self));
}
}
static void
on_seat_active_session_ready (GObject * o, GAsyncResult * res, gpointer gself)
{
GError * err;
gchar * ssid;
ConsoleKitSeat * seat;
err = NULL;
ssid = NULL;
seat = CONSOLE_KIT_SEAT (o);
console_kit_seat_call_get_active_session_finish (seat, &ssid, res, &err);
if (err != NULL)
{
g_warning ("%s %s: %s", G_STRLOC, G_STRFUNC, err->message);
g_error_free (err);
}
else if (ssid != NULL)
{
set_active_session (INDICATOR_SESSION_USERS_DBUS(gself), ssid);
g_free (ssid);
}
}
static void
set_seat (IndicatorSessionUsersDbus * self, ConsoleKitSeat * seat)
{
priv_t * p = self->priv;
if (p->seat_proxy != NULL)
{
g_signal_handlers_disconnect_by_data (p->seat_proxy, self);
g_clear_object (&p->seat_proxy);
}
if (seat != NULL)
{
p->seat_proxy = g_object_ref (seat);
/* ask the seat for a list of all the sessions */
console_kit_seat_call_get_sessions (seat,
p->cancellable,
on_session_list_ready,
self);
/* ask the seat for the name of the active session */
console_kit_seat_call_get_active_session (p->seat_proxy,
p->cancellable,
on_seat_active_session_ready,
self);
/* listen for session changes in this seat */
g_signal_connect_swapped (seat, "session-added",
G_CALLBACK(create_session_proxy_for_ssid),self);
g_signal_connect_swapped (seat, "session-removed",
G_CALLBACK(untrack_session), self);
g_signal_connect_swapped (seat, "active-session-changed",
G_CALLBACK(set_active_session), self);
}
}
/***
****
***/
static void
set_dm_seat (IndicatorSessionUsersDbus * self, DisplayManagerSeat * dm_seat)
{
priv_t * p = self->priv;
g_clear_object (&p->dm_seat);
if (dm_seat != NULL)
p->dm_seat = g_object_ref (dm_seat);
}
static void
activate_username (IndicatorSessionUsersDbus * self, const char * username)
{
priv_t * p = self->priv;
const char * session = "";
g_return_if_fail (p->dm_seat != NULL);
display_manager_seat_call_switch_to_user (p->dm_seat, username, session,
p->cancellable, NULL, NULL);
}
/***
****
***/
static void
my_dispose (GObject * o)
{
IndicatorSessionUsersDbus * self = INDICATOR_SESSION_USERS_DBUS (o);
priv_t * p = self->priv;
if (p->cancellable)
{
g_cancellable_cancel (p->cancellable);
g_clear_object (&p->cancellable);
}
set_seat (self, NULL);
set_dm_seat (self, NULL);
set_account_manager (self, NULL);
g_clear_pointer (&p->path_to_user, g_hash_table_destroy);
g_clear_pointer (&p->session_to_uid, g_hash_table_destroy);
g_clear_pointer (&p->uid_to_sessions, g_hash_table_destroy);
g_clear_pointer (&p->uid_to_user_path, g_hash_table_destroy);
G_OBJECT_CLASS (indicator_session_users_dbus_parent_class)->dispose (o);
}
static void
my_finalize (GObject * o)
{
IndicatorSessionUsersDbus * u = INDICATOR_SESSION_USERS_DBUS (o);
g_free (u->priv->active_session_id);
G_OBJECT_CLASS (indicator_session_users_dbus_parent_class)->finalize (o);
}
static void
my_activate_user (IndicatorSessionUsers * users, const char * key)
{
priv_t * p;
const char * username = 0;
p = INDICATOR_SESSION_USERS_DBUS (users)->priv;
if (p != 0)
{
AccountsUser * au = g_hash_table_lookup (p->path_to_user, key);
if (au != NULL)
username = accounts_user_get_user_name (au);
}
if (username != 0)
activate_username (INDICATOR_SESSION_USERS_DBUS(users), username);
else
g_warning ("%s %s can't find user for '%s'", G_STRLOC, G_STRFUNC, key);
}
static gboolean
my_is_live_session (IndicatorSessionUsers * users)
{
IndicatorSessionUsersDbus * self = INDICATOR_SESSION_USERS_DBUS(users);
return is_live_ssid (self, self->priv->active_session_id);
}
static GStrv
my_get_keys (IndicatorSessionUsers * users)
{
int i;
priv_t * p;
gchar ** keys;
GHashTableIter iter;
gpointer path;
gpointer user;
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS_DBUS(users), NULL);
p = INDICATOR_SESSION_USERS_DBUS (users)->priv;
i = 0;
keys = g_new (gchar*, g_hash_table_size(p->path_to_user)+1);
g_hash_table_iter_init (&iter, p->path_to_user);
while (g_hash_table_iter_next (&iter, &path, &user))
if (!accounts_user_get_system_account (user))
keys[i++] = g_strdup (path);
keys[i] = NULL;
return keys;
}
static IndicatorSessionUser *
my_get_user (IndicatorSessionUsers * users, const gchar * key)
{
priv_t * p;
AccountsUser * au;
IndicatorSessionUser * ret = NULL;
p = INDICATOR_SESSION_USERS_DBUS (users)->priv;
au = g_hash_table_lookup (p->path_to_user, key);
if (au && !accounts_user_get_system_account(au))
{
const guint uid = (guint) accounts_user_get_uid (au);
GHashTable * s;
ret = g_new0 (IndicatorSessionUser, 1);
s = g_hash_table_lookup (p->uid_to_sessions, GUINT_TO_POINTER(uid));
if (s == NULL)
{
ret->is_logged_in = FALSE;
ret->is_current_user = FALSE;
}
else
{
ret->is_logged_in = g_hash_table_size (s) > 0;
ret->is_current_user = g_hash_table_contains (s, p->active_session_id);
}
ret->uid = uid;
ret->user_name = g_strdup (accounts_user_get_user_name (au));
ret->real_name = g_strdup (accounts_user_get_real_name (au));
ret->icon_file = g_strdup (accounts_user_get_icon_file (au));
ret->login_frequency = accounts_user_get_login_frequency (au);
}
return ret;
}
static void
/* cppcheck-suppress unusedFunction */
indicator_session_users_dbus_class_init (IndicatorSessionUsersDbusClass * klass)
{
GObjectClass * object_class;
IndicatorSessionUsersClass * users_class;
object_class = G_OBJECT_CLASS (klass);
object_class->dispose = my_dispose;
object_class->finalize = my_finalize;
users_class = INDICATOR_SESSION_USERS_CLASS (klass);
users_class->is_live_session = my_is_live_session;
users_class->get_keys = my_get_keys;
users_class->get_user = my_get_user;
users_class->activate_user = my_activate_user;
g_type_class_add_private (klass, sizeof (IndicatorSessionUsersDbusPriv));
}
static void
/* cppcheck-suppress unusedFunction */
indicator_session_users_dbus_init (IndicatorSessionUsersDbus * self)
{
priv_t * p;
p = G_TYPE_INSTANCE_GET_PRIVATE (self,
INDICATOR_TYPE_SESSION_USERS_DBUS,
IndicatorSessionUsersDbusPriv);
self->priv = p;
p->cancellable = g_cancellable_new ();
p->path_to_user = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_object_unref);
p->uid_to_user_path = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_free);
p->session_to_uid = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, NULL);
p->uid_to_sessions = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL,
(GDestroyNotify)g_hash_table_destroy);
#if 0
console_kit_manager_proxy_new_for_bus (
G_BUS_TYPE_SYSTEM,
G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES,
"org.freedesktop.ConsoleKit",
"/org/freedesktop/ConsoleKit/Manager",
p->cancellable,
on_console_kit_manager_proxy_ready,
self);
#endif
}
/***
**** Public
***/
IndicatorSessionUsers *
indicator_session_users_dbus_new (void)
{
gpointer o = g_object_new (INDICATOR_TYPE_SESSION_USERS_DBUS, NULL);
return INDICATOR_SESSION_USERS (o);
}
void
indicator_session_users_dbus_set_proxies (IndicatorSessionUsersDbus * self,
Accounts * accounts,
DisplayManagerSeat * dm_seat,
ConsoleKitSeat * seat)
{
g_return_if_fail (INDICATOR_IS_SESSION_USERS_DBUS (self));
set_account_manager (self, accounts);
set_seat (self, seat);
set_dm_seat (self, dm_seat);
}
|