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
|
/*
* 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/>.
*/
#ifndef __USERS_H__
#define __USERS_H__
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define INDICATOR_TYPE_SESSION_USERS (indicator_session_users_get_type())
#define INDICATOR_SESSION_USERS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), INDICATOR_TYPE_SESSION_USERS, IndicatorSessionUsers))
#define INDICATOR_SESSION_USERS_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), INDICATOR_TYPE_SESSION_USERS, IndicatorSessionUsersClass))
#define INDICATOR_SESSION_USERS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), INDICATOR_TYPE_SESSION_USERS, IndicatorSessionUsersClass))
#define INDICATOR_IS_SESSION_USERS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), INDICATOR_TYPE_SESSION_USERS))
typedef struct _IndicatorSessionUser IndicatorSessionUser;
typedef struct _IndicatorSessionUsers IndicatorSessionUsers;
typedef struct _IndicatorSessionUsersClass IndicatorSessionUsersClass;
/**
* A base class for monitoring the system's users and active sessions.
* Use backend.h's get_backend() to get an instance.
*/
struct _IndicatorSessionUsers
{
/*< private >*/
GObject parent;
};
struct _IndicatorSessionUser
{
gboolean is_current_user;
gboolean is_logged_in;
guint uid;
guint64 login_frequency;
gchar * user_name;
gchar * real_name;
gchar * icon_file;
};
/* signal keys */
#define INDICATOR_SESSION_USERS_SIGNAL_USER_ADDED "user-added"
#define INDICATOR_SESSION_USERS_SIGNAL_USER_REMOVED "user-removed"
#define INDICATOR_SESSION_USERS_SIGNAL_USER_CHANGED "user-changed"
/* property keys */
#define INDICATOR_SESSION_USERS_PROP_IS_LIVE_SESSION "is-live-session"
struct _IndicatorSessionUsersClass
{
GObjectClass parent_class;
/* signals */
void (* user_added) (IndicatorSessionUsers * self,
const gchar * key);
void (* user_removed) (IndicatorSessionUsers * self,
const gchar * key);
void (* user_changed) (IndicatorSessionUsers * self,
const gchar * key);
/* pure virtual functions */
gboolean (* is_live_session) (IndicatorSessionUsers * self);
GStrv (* get_keys) (IndicatorSessionUsers * self);
IndicatorSessionUser * (* get_user) (IndicatorSessionUsers * self,
const gchar * key);
void ( * activate_user) (IndicatorSessionUsers * self,
const gchar * key);
};
/***
****
***/
GType indicator_session_users_get_type (void);
/* emits the "user-added" signal */
void indicator_session_users_added (IndicatorSessionUsers * self,
const gchar * key);
/* emits the "user-removed" signal */
void indicator_session_users_removed (IndicatorSessionUsers * self,
const gchar * key);
/* emits the "user-changed" signal */
void indicator_session_users_changed (IndicatorSessionUsers * self,
const gchar * key);
/* notify listeners of a change to the 'is-live-session' property */
void indicator_session_users_notify_is_live_session (IndicatorSessionUsers * self);
/***
****
***/
gboolean indicator_session_users_is_live_session (IndicatorSessionUsers * users);
/**
* Get a list of user keys.
*
* Return value: (transfer full): a NULL-terminated array of user keys.
* Free with g_strfreev() when done.
*/
GStrv indicator_session_users_get_keys (IndicatorSessionUsers * users);
/**
* Get information about a particular user.
*
* Return value: (transfer full): an IndicatorSessionUser struct
* populated with information about the specified user.
* Free with indicator_session_user_free() when done.
*/
IndicatorSessionUser *
indicator_session_users_get_user (IndicatorSessionUsers * users,
const gchar * key);
/* frees a IndicatorSessionUser struct */
void indicator_session_user_free (IndicatorSessionUser * user);
/* activate to a different session */
void indicator_session_users_activate_user (IndicatorSessionUsers * self,
const char * key);
G_END_DECLS
#endif
|