28
29
#include "session-dbus.h"
29
30
#include "dbus-shared-names.h"
31
static GVariant * get_icon (SessionDbus * service);
32
static GVariant * get_users_real_name (SessionDbus * service);
32
33
static void bus_get_cb (GObject * object, GAsyncResult * res, gpointer user_data);
33
34
static void bus_method_call (GDBusConnection * connection, const gchar * sender, const gchar * path, const gchar * interface, const gchar * method, GVariant * params, GDBusMethodInvocation * invocation, gpointer user_data);
99
101
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(self);
101
priv->name = g_strdup(ICON_DEFAULT);
102
104
priv->bus = NULL;
103
105
priv->bus_cancel = NULL;
104
106
priv->dbus_registration = 0;
107
priv->user_menu_is_visible = FALSE;
106
109
priv->bus_cancel = g_cancellable_new();
107
110
g_bus_get(G_BUS_TYPE_SESSION,
160
163
const gchar * method, GVariant * params,
161
164
GDBusMethodInvocation * invocation, gpointer user_data)
163
SessionDbus * service = SESSION_DBUS(user_data);
166
SessionDbus * service = SESSION_DBUS (user_data);
167
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE (service);
164
169
GVariant * retval = NULL;
166
if (g_strcmp0(method, "GetIcon") == 0) {
167
retval = get_icon(service);
169
g_warning("Calling method '%s' on the indicator service and it's unknown", method);
171
if (g_strcmp0(method, "GetUserRealName") == 0) {
172
retval = get_users_real_name (service);
174
else if (g_strcmp0 (method, "GetUserMenuVisibility") == 0){
175
retval = g_variant_new ("(b)", priv->user_menu_is_visible);
178
g_warning("Calling method '%s' on the indicator service and it's unknown", method);
172
180
g_dbus_method_invocation_return_value(invocation, retval);
216
224
static GVariant *
217
get_icon (SessionDbus * service)
225
get_users_real_name (SessionDbus * service)
219
227
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(service);
220
return g_variant_new("(s)", priv->name);
228
return g_variant_new ("(s)", priv->name);
230
238
session_dbus_set_name (SessionDbus * session, const gchar * name)
243
session_dbus_set_users_real_name (SessionDbus * session, const gchar * name)
232
245
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
233
246
GError * error = NULL;
234
247
if (priv->name != NULL) {
235
248
g_free(priv->name);
236
249
priv->name = NULL;
238
252
priv->name = g_strdup(name);
240
254
if (priv->bus != NULL) {
241
255
g_dbus_connection_emit_signal (priv->bus,
243
INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
244
INDICATOR_SESSION_SERVICE_DBUS_IFACE,
246
g_variant_new ("(s)", priv->name, NULL),
257
INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
258
INDICATOR_SESSION_SERVICE_DBUS_IFACE,
259
"UserRealNameUpdated",
260
g_variant_new ("(s)", priv->name, NULL),
249
263
if (error != NULL) {
250
g_warning("Unable to send IconUpdated signal: %s", error->message);
264
g_warning("Unable to send UserRealNameUpdated signal: %s", error->message);
251
265
g_error_free(error);
273
session_dbus_set_user_menu_visibility (SessionDbus* session,
276
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
277
GError * error = NULL;
279
priv->user_menu_is_visible = visible;
281
if (priv->bus != NULL) {
282
g_dbus_connection_emit_signal (priv->bus,
284
INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
285
INDICATOR_SESSION_SERVICE_DBUS_IFACE,
287
g_variant_new ("(b)", priv->user_menu_is_visible),
291
g_warning("Unable to send UserMenuIsVisible signal: %s", error->message);
297
void session_dbus_restart_required (SessionDbus* session)
299
SessionDbusPrivate * priv = SESSION_DBUS_GET_PRIVATE(session);
300
GError * error = NULL;
302
if (priv->bus != NULL) {
303
g_debug("About to send RebootRequired signal");
305
g_dbus_connection_emit_signal (priv->bus,
307
INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
308
INDICATOR_SESSION_SERVICE_DBUS_IFACE,
314
g_warning("Unable to send reboot-required signal: %s", error->message);