253
251
static GVariant *
254
user_info_to_args (UserInfo *info)
256
return g_variant_new ("(sssb)",
258
info->real_name ? info->real_name : "",
259
info->image ? info->image : "",
264
handle_user_manager_call (GDBusConnection *connection,
266
const gchar *object_path,
267
const gchar *interface_name,
268
const gchar *method_name,
269
GVariant *parameters,
270
GDBusMethodInvocation *invocation,
273
if (g_strcmp0 (method_name, "GetUsers") == 0)
275
GVariantBuilder *builder;
279
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("()")))
282
builder = g_variant_builder_new (G_VARIANT_TYPE ("a(sssb)"));
283
users = user_manager_get_users (user_manager);
284
for (iter = users; iter; iter = iter->next)
286
UserInfo *info = iter->data;
287
g_variant_builder_add_value (builder, user_info_to_args (info));
289
arg0 = g_variant_builder_end (builder);
290
g_dbus_method_invocation_return_value (invocation, g_variant_new_tuple (&arg0, 1));
291
g_variant_builder_unref (builder);
293
else if (g_strcmp0 (method_name, "GetUserDefaults") == 0)
295
gchar *username, *language, *layout, *session;
297
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(s)")))
300
g_variant_get (parameters, "(s)", &username);
301
if (user_manager_get_user_defaults (user_manager, username, &language, &layout, &session))
303
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(sss)", language, layout, session));
313
user_added_cb (UserManager *user_manager, UserInfo *info)
315
g_dbus_connection_emit_signal (bus,
317
"/org/lightdm/LightDisplayManager/Users",
318
"org.lightdm.LightDisplayManager.Users",
320
user_info_to_args (info),
325
user_changed_cb (UserManager *user_manager, UserInfo *info)
327
g_dbus_connection_emit_signal (bus,
329
"/org/lightdm/LightDisplayManager/Users",
330
"org.lightdm.LightDisplayManager.Users",
332
user_info_to_args (info),
337
user_removed_cb (UserManager *user_manager, UserInfo *info)
339
g_dbus_connection_emit_signal (bus,
341
"/org/lightdm/LightDisplayManager/Users",
342
"org.lightdm.LightDisplayManager.Users",
344
g_variant_new ("(s)", info->name),
252
handle_display_manager_get_property (GDBusConnection *connection,
254
const gchar *object_path,
255
const gchar *interface_name,
256
const gchar *property_name,
260
if (g_strcmp0 (property_name, "ConfigFile") == 0)
262
return g_variant_new_string (config_path);
362
283
static const GDBusInterfaceVTable display_manager_vtable =
364
handle_display_manager_call
367
const gchar *user_manager_interface =
369
" <interface name='org.lightdm.LightDisplayManager.Users'>"
370
" <method name='GetUsers'>"
371
" <arg name='users' direction='out' type='a(sssb)'/>"
373
" <method name='GetUserDefaults'>"
374
" <arg name='username' direction='in' type='s'/>"
375
" <arg name='language' direction='out' type='s'/>"
376
" <arg name='layout' direction='out' type='s'/>"
377
" <arg name='session' direction='out' type='s'/>"
379
" <signal name='UserAdded'>"
380
" <arg name='username' type='s'/>"
381
" <arg name='real-name' type='s'/>"
382
" <arg name='image' type='s'/>"
383
" <arg name='username' type='b'/>"
385
" <signal name='UserChanged'>"
386
" <arg name='username' type='s'/>"
387
" <arg name='real-name' type='s'/>"
388
" <arg name='image' type='s'/>"
389
" <arg name='username' type='b'/>"
391
" <signal name='UserRemoved'>"
392
" <arg name='username' type='s'/>"
396
static const GDBusInterfaceVTable user_manager_vtable =
398
handle_user_manager_call
400
GDBusNodeInfo *display_manager_info, *user_manager_info;
285
handle_display_manager_call,
286
handle_display_manager_get_property
288
GDBusNodeInfo *display_manager_info;
402
290
bus = connection;
409
297
&display_manager_vtable,
413
user_manager_info = g_dbus_node_info_new_for_xml (user_manager_interface, NULL);
414
g_assert (user_manager_info != NULL);
415
g_dbus_connection_register_object (connection,
416
"/org/lightdm/LightDisplayManager/Users",
417
user_manager_info->interfaces[0],
418
&user_manager_vtable,
422
g_signal_connect (user_manager, "user-added", G_CALLBACK (user_added_cb), NULL);
423
g_signal_connect (user_manager, "user-changed", G_CALLBACK (user_changed_cb), NULL);
424
g_signal_connect (user_manager, "user-removed", G_CALLBACK (user_removed_cb), NULL);