@@ -21,44 +21,35 @@ public enum UserState {
2121}
2222
2323public class QuickSettings.UserManager : Object {
24- private const string LOGIN_IFACE = " org.freedesktop.login1" ;
25- private const string LOGIN_PATH = " /org/freedesktop/login1" ;
26-
27- private static string active_user_real_name;
28- private static SystemInterface ? login_proxy;
29-
30- private static async void init_login_proxy () {
31- try {
32- login_proxy = yield Bus . get_proxy (BusType . SYSTEM , LOGIN_IFACE , LOGIN_PATH , DBusProxyFlags . NONE );
33- } catch (IOError e) {
34- critical (" Failed to create login1 dbus proxy: %s " , e. message);
35- }
36- }
24+ private static string ? active_user_real_name;
3725
3826 public static async UserState get_user_state (uid_t uuid ) {
39- if (login_proxy == null ) {
40- yield init_login_proxy ();
41- }
42-
4327 try {
44- UserInfo [] users = login_proxy . list_users ();
28+ var users = Login1Manager . get_default () . proxy . list_users ();
4529 if (users == null ) {
4630 return UserState . OFFLINE ;
4731 }
4832
49- foreach (UserInfo user in users) {
50- if (((uid_t) user. uid) == uuid) {
51- if (user. user_object == null ) {
52- return UserState . OFFLINE ;
53- }
54- UserInterface ? user_interface = yield Bus . get_proxy (BusType . SYSTEM , LOGIN_IFACE , user. user_object, DBusProxyFlags . NONE );
55- if (user_interface == null ) {
56- return UserState . OFFLINE ;
57- }
58- return UserState . to_enum (user_interface. state);
33+ foreach (var user in users) {
34+ if (((uid_t) user. uid) != uuid) {
35+ continue ;
36+ }
37+
38+ if (user. user_object == null ) {
39+ return UserState . OFFLINE ;
40+ }
41+
42+ var user_interface = yield Bus . get_proxy< UserInterface > (
43+ SYSTEM ,
44+ " org.freedesktop.login1" ,
45+ user. user_object
46+ );
47+ if (user_interface == null ) {
48+ return UserState . OFFLINE ;
5949 }
60- }
6150
51+ return UserState . to_enum (user_interface. state);
52+ }
6253 } catch (GLib . Error e) {
6354 critical (" Failed to get user state: %s " , e. message);
6455 }
@@ -67,13 +58,9 @@ public class QuickSettings.UserManager : Object {
6758 }
6859
6960 public static async UserState get_guest_state () {
70- if (login_proxy == null ) {
71- return UserState . OFFLINE ;
72- }
73-
7461 try {
75- UserInfo [] users = login_proxy . list_users ();
76- foreach (UserInfo user in users) {
62+ var users = Login1Manager . get_default () . proxy . list_users ();
63+ foreach (var user in users) {
7764 var state = yield get_user_state (user. uid);
7865 if (user. user_name. has_prefix (" guest-" )
7966 && state == UserState . ACTIVE ) {
0 commit comments