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
|
/*
* 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 "users.h"
/* signals enum */
enum
{
USER_ADDED,
USER_REMOVED,
USER_CHANGED,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (IndicatorSessionUsers, indicator_session_users, G_TYPE_OBJECT)
enum
{
PROP_0,
PROP_IS_LIVE_SESSION,
PROP_LAST
};
static GParamSpec *properties[PROP_LAST];
static void
my_get_property (GObject * o,
guint property_id,
GValue * value,
GParamSpec * pspec)
{
IndicatorSessionUsers * self = INDICATOR_SESSION_USERS (o);
switch (property_id)
{
case PROP_IS_LIVE_SESSION:
g_value_set_boolean (value, indicator_session_users_is_live_session (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (o, property_id, pspec);
}
}
static void
/* cppcheck-suppress unusedFunction */
indicator_session_users_class_init (IndicatorSessionUsersClass * klass)
{
GObjectClass * object_class;
const GParamFlags flags = G_PARAM_READABLE | G_PARAM_STATIC_STRINGS;
object_class = G_OBJECT_CLASS (klass);
object_class->get_property = my_get_property;
signals[USER_ADDED] = g_signal_new (INDICATOR_SESSION_USERS_SIGNAL_USER_ADDED,
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicatorSessionUsersClass, user_added),
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
signals[USER_REMOVED] = g_signal_new (INDICATOR_SESSION_USERS_SIGNAL_USER_REMOVED,
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicatorSessionUsersClass, user_removed),
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
signals[USER_CHANGED] = g_signal_new (INDICATOR_SESSION_USERS_SIGNAL_USER_CHANGED,
G_TYPE_FROM_CLASS(klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (IndicatorSessionUsersClass, user_changed),
NULL, NULL,
g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
properties[PROP_IS_LIVE_SESSION] =
g_param_spec_boolean (INDICATOR_SESSION_USERS_PROP_IS_LIVE_SESSION,
"Is Live Session",
"Whether or this is a 'live session', such as booting from a live CD",
FALSE, flags);
g_object_class_install_properties (object_class, PROP_LAST, properties);
}
static void
/* cppcheck-suppress unusedFunction */
indicator_session_users_init (IndicatorSessionUsers * self G_GNUC_UNUSED)
{
}
/***
**** Virtual Functions
***/
GList *
indicator_session_users_get_uids (IndicatorSessionUsers * self)
{
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS (self), NULL);
return INDICATOR_SESSION_USERS_GET_CLASS (self)->get_uids (self);
}
IndicatorSessionUser *
indicator_session_users_get_user (IndicatorSessionUsers * self,
guint uid)
{
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS (self), NULL);
return INDICATOR_SESSION_USERS_GET_CLASS (self)->get_user (self, uid);
}
void
indicator_session_users_activate_user (IndicatorSessionUsers * self,
guint uid)
{
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
INDICATOR_SESSION_USERS_GET_CLASS (self)->activate_user (self, uid);
}
gboolean
indicator_session_users_is_live_session (IndicatorSessionUsers * self)
{
g_return_val_if_fail (INDICATOR_IS_SESSION_USERS (self), FALSE);
return INDICATOR_SESSION_USERS_GET_CLASS (self)->is_live_session (self);
}
void
indicator_session_user_free (IndicatorSessionUser * user)
{
g_return_if_fail (user != NULL);
g_free (user->real_name);
g_free (user->user_name);
g_free (user->icon_file);
g_free (user);
}
/***
**** Signal Convenience
***/
void
indicator_session_users_added (IndicatorSessionUsers * self, guint uid)
{
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
g_signal_emit (self, signals[USER_ADDED], 0, uid);
}
void
indicator_session_users_removed (IndicatorSessionUsers * self, guint uid)
{
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
g_signal_emit (self, signals[USER_REMOVED], 0, uid);
}
void
indicator_session_users_changed (IndicatorSessionUsers * self, guint uid)
{
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
g_signal_emit (self, signals[USER_CHANGED], 0, uid);
}
void
indicator_session_users_notify_is_live_session (IndicatorSessionUsers * self)
{
g_return_if_fail (INDICATOR_IS_SESSION_USERS (self));
g_object_notify_by_pspec (G_OBJECT(self), properties[PROP_IS_LIVE_SESSION]);
}
|