458
update_user_property (CommonUser *user, const gchar *name, GVariant *value)
460
CommonUserPrivate *priv = GET_USER_PRIVATE (user);
462
if (strcmp (name, "UserName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
465
priv->name = g_variant_dup_string (value, NULL);
469
if (strcmp (name, "RealName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
471
g_free (priv->real_name);
472
priv->real_name = g_variant_dup_string (value, NULL);
476
if (strcmp (name, "HomeDirectory") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
478
g_free (priv->home_directory);
479
priv->home_directory = g_variant_dup_string (value, NULL);
483
if (strcmp (name, "Shell") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
485
g_free (priv->shell);
486
priv->shell = g_variant_dup_string (value, NULL);
490
if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
492
priv->system_account = g_variant_get_boolean (value);
496
if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
499
g_free (priv->language);
500
priv->language = g_variant_dup_string (value, NULL);
504
if (strcmp (name, "IconFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
506
g_free (priv->image);
507
priv->image = g_variant_dup_string (value, NULL);
508
if (strcmp (priv->image, "") == 0)
510
g_free (priv->image);
516
if (strcmp (name, "XSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
518
g_free (priv->session);
519
priv->session = g_variant_dup_string (value, NULL);
523
if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
525
g_free (priv->background);
526
priv->background = g_variant_dup_string (value, NULL);
527
if (strcmp (priv->background, "") == 0)
529
g_free (priv->background);
530
priv->background = NULL;
535
if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY))
537
g_strfreev (priv->layouts);
538
priv->layouts = g_variant_dup_strv (value, NULL);
541
priv->layouts = g_malloc (sizeof (gchar *) * 1);
542
priv->layouts[0] = NULL;
547
if (strcmp (name, "XHasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
549
priv->has_messages = g_variant_get_boolean (value);
553
if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64))
555
priv->uid = g_variant_get_uint64 (value);
454
static gboolean load_accounts_user (CommonUser *user);
563
457
accounts_user_changed_cb (GDBusConnection *connection,
571
465
CommonUser *user = data;
572
CommonUserPrivate *priv = GET_USER_PRIVATE (user);
573
gboolean changed = FALSE;
575
GVariantIter *invalidated_properties;
579
g_variant_get (parameters, "(sa{sv}as)", NULL, &iter, &invalidated_properties);
580
while (g_variant_iter_loop (iter, "{&sv}", &name, &value))
582
if (update_user_property (user, name, value))
585
g_variant_iter_free (iter);
586
while (g_variant_iter_loop (invalidated_properties, "&s", &name))
589
GError *error = NULL;
591
result = g_dbus_connection_call_sync (connection,
592
"org.freedesktop.Accounts",
594
"org.freedesktop.DBus.Properties",
596
g_variant_new ("(ss)", "org.freedesktop.Accounts.User", name),
597
G_VARIANT_TYPE ("(v)"),
598
G_DBUS_CALL_FLAGS_NONE,
603
g_warning ("Error updating user property %s: %s", name, error->message);
604
g_clear_error (&error);
610
g_variant_get (result, "(v)", &value);
611
if (update_user_property (user, name, value))
613
g_variant_unref (value);
614
g_variant_unref (result);
620
g_debug ("User %s changed", priv->path);
466
CommonUserPrivate *priv = GET_USER_PRIVATE (user);
468
g_debug ("User %s changed", priv->path);
469
if (load_accounts_user (user))
621
470
g_signal_emit (user, user_signals[CHANGED], 0);
629
477
GVariant *result, *value;
630
478
GVariantIter *iter;
480
gboolean system_account = FALSE;
632
481
GError *error = NULL;
634
483
/* Get the properties for this user */
635
484
if (!priv->changed_signal)
636
485
priv->changed_signal = g_dbus_connection_signal_subscribe (GET_LIST_PRIVATE (priv->user_list)->bus,
637
486
"org.freedesktop.Accounts",
638
"org.freedesktop.DBus.Properties",
487
"org.freedesktop.Accounts.User",
641
"org.freedesktop.Accounts.User",
642
491
G_DBUS_SIGNAL_FLAGS_NONE,
643
492
accounts_user_changed_cb,
663
512
/* Store the properties we need */
664
513
g_variant_get (result, "(a{sv})", &iter);
665
514
while (g_variant_iter_loop (iter, "{&sv}", &name, &value))
666
update_user_property (user, name, value);
516
if (strcmp (name, "UserName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
519
priv->name = g_variant_dup_string (value, NULL);
521
else if (strcmp (name, "RealName") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
523
g_free (priv->real_name);
524
priv->real_name = g_variant_dup_string (value, NULL);
526
else if (strcmp (name, "HomeDirectory") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
528
g_free (priv->home_directory);
529
priv->home_directory = g_variant_dup_string (value, NULL);
531
else if (strcmp (name, "Shell") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
533
g_free (priv->shell);
534
priv->shell = g_variant_dup_string (value, NULL);
536
else if (strcmp (name, "SystemAccount") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
537
system_account = g_variant_get_boolean (value);
538
else if (strcmp (name, "Language") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
541
g_free (priv->language);
542
priv->language = g_variant_dup_string (value, NULL);
544
else if (strcmp (name, "IconFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
546
g_free (priv->image);
547
priv->image = g_variant_dup_string (value, NULL);
548
if (strcmp (priv->image, "") == 0)
550
g_free (priv->image);
554
else if (strcmp (name, "XSession") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
556
g_free (priv->session);
557
priv->session = g_variant_dup_string (value, NULL);
559
else if (strcmp (name, "BackgroundFile") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
561
g_free (priv->background);
562
priv->background = g_variant_dup_string (value, NULL);
563
if (strcmp (priv->background, "") == 0)
565
g_free (priv->background);
566
priv->background = NULL;
569
else if (strcmp (name, "XKeyboardLayouts") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_STRING_ARRAY))
571
g_strfreev (priv->layouts);
572
priv->layouts = g_variant_dup_strv (value, NULL);
575
priv->layouts = g_malloc (sizeof (gchar *) * 1);
576
priv->layouts[0] = NULL;
579
else if (strcmp (name, "XHasMessages") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN))
580
priv->has_messages = g_variant_get_boolean (value);
581
else if (strcmp (name, "Uid") == 0 && g_variant_is_of_type (value, G_VARIANT_TYPE_UINT64))
582
priv->uid = g_variant_get_uint64 (value);
667
584
g_variant_iter_free (iter);
669
586
g_variant_unref (result);
671
return !priv->system_account;
588
return !system_account;