Back to index

indicator-session  12.10.0
Classes | Defines | Enumerations | Functions | Variables
users-service-dbus.c File Reference
#include <glib.h>
#include <errno.h>
#include <pwd.h>
#include "dbus-accounts.h"
#include "dbus-consolekit-manager.h"
#include "dbus-consolekit-seat.h"
#include "dbus-consolekit-session.h"
#include "dbus-display-manager.h"
#include "dbus-user.h"
#include "shared-names.h"
#include "users-service-dbus.h"

Go to the source code of this file.

Classes

struct  _UsersServiceDbusPrivate

Defines

#define CK_ADDR   "org.freedesktop.ConsoleKit"
#define CK_SESSION_IFACE   "org.freedesktop.ConsoleKit.Session"

Enumerations

enum  { USER_LIST_CHANGED, USER_LOGGED_IN_CHANGED, GUEST_LOGGED_IN_CHANGED, N_SIGNALS }

Functions

static void update_user_list (UsersServiceDbus *self)
static gchar * get_seat (UsersServiceDbus *service)
static void on_user_added (Accounts *o, const gchar *user_object_path, UsersServiceDbus *service)
static void on_user_deleted (Accounts *o, const gchar *user_object_path, UsersServiceDbus *service)
static void on_session_added (ConsoleKitSeat *seat, const gchar *ssid, UsersServiceDbus *service)
static void on_session_removed (ConsoleKitSeat *seat, const gchar *ssid, UsersServiceDbus *service)
static void on_session_list (ConsoleKitSeat *seat, GAsyncResult *result, UsersServiceDbus *service)
 G_DEFINE_TYPE (UsersServiceDbus, users_service_dbus, G_TYPE_OBJECT)
static void users_service_dbus_dispose (GObject *object)
static void users_service_dbus_finalize (GObject *object)
static void users_service_dbus_class_init (UsersServiceDbusClass *klass)
static void users_service_dbus_init (UsersServiceDbus *self)
static void emit_user_list_changed (UsersServiceDbus *self)
static void emit_user_login_changed (UsersServiceDbus *self, AccountsUser *user)
static void emit_guest_login_changed (UsersServiceDbus *self)
static ConsoleKitSession * create_consolekit_session_proxy (const char *ssid)
static gchar * get_seat_from_session_proxy (ConsoleKitSession *session_proxy)
static GHashTable * user_get_sessions_hashset (AccountsUser *user)
static void user_add_session (AccountsUser *user, const char *ssid)
static void user_remove_session (AccountsUser *user, const char *ssid)
static guint user_count_sessions (AccountsUser *user)
static void add_user_session (UsersServiceDbus *service, AccountsUser *user, const gchar *ssid)
static void add_user_sessions (UsersServiceDbus *self, AccountsUser *user)
static gboolean is_interesting_user_property (const char *key)
static void sync_user_properties (GDBusProxy *source, GDBusProxy *target)
static void on_user_changed (AccountsUser *user, UsersServiceDbus *service)
 The AccountsUserProxy's properties aren't being updated automatically for some reason...
static void add_user_from_object_path (UsersServiceDbus *self, const char *user_object_path)
static void on_user_added (Accounts *o G_GNUC_UNUSED, const gchar *user_path G_GNUC_UNUSED, UsersServiceDbus *service)
static void on_user_deleted (Accounts *o G_GNUC_UNUSED, const gchar *user_path, UsersServiceDbus *service)
static AccountsUser * find_user_from_username (UsersServiceDbus *self, const gchar *username)
static gchar * get_unix_username_from_ssid (UsersServiceDbus *self, const gchar *ssid)
static gboolean is_guest_username (const char *username)
static void on_session_added (ConsoleKitSeat *seat_proxy G_GNUC_UNUSED, const gchar *ssid, UsersServiceDbus *service)
static DisplayManagerSeat * create_display_proxy (UsersServiceDbus *self)
GList * users_service_dbus_get_user_list (UsersServiceDbus *self)
 users_service_dbus_get_user_list:
void users_service_dbus_show_greeter (UsersServiceDbus *self)
 users_service_dbus_show_greeter:
void users_service_dbus_activate_guest_session (UsersServiceDbus *self)
 users_service_dbus_activate_guest_session:
void users_service_dbus_activate_user_session (UsersServiceDbus *self, AccountsUser *user)
 users_service_dbus_activate_user_session:
gboolean users_service_dbus_guest_session_enabled (UsersServiceDbus *self)
 users_service_dbus_guest_session_enabled:
gboolean users_service_dbus_can_activate_session (UsersServiceDbus *self)
gboolean users_service_dbus_is_guest_logged_in (UsersServiceDbus *self)
gboolean users_service_dbus_is_user_logged_in (UsersServiceDbus *self, AccountsUser *user)

Variables

static guint signals [N_SIGNALS] = { 0 }

Class Documentation

struct _UsersServiceDbusPrivate

Definition at line 76 of file users-service-dbus.c.

Class Members
Accounts * accounts_proxy
GCancellable * cancellable
ConsoleKitManager * ck_manager_proxy
gchar * guest_ssid
gchar * seat
ConsoleKitSeat * seat_proxy
GHashTable * sessions
GHashTable * users

Define Documentation

#define CK_ADDR   "org.freedesktop.ConsoleKit"

Definition at line 41 of file users-service-dbus.c.

#define CK_SESSION_IFACE   "org.freedesktop.ConsoleKit.Session"

Definition at line 42 of file users-service-dbus.c.


Enumeration Type Documentation

anonymous enum
Enumerator:
USER_LIST_CHANGED 
USER_LOGGED_IN_CHANGED 
GUEST_LOGGED_IN_CHANGED 
N_SIGNALS 

Definition at line 97 of file users-service-dbus.c.


Function Documentation

static void add_user_from_object_path ( UsersServiceDbus *  self,
const char *  user_object_path 
) [static]

Definition at line 593 of file users-service-dbus.c.

{
  GError * error = NULL;

  AccountsUser * user = accounts_user_proxy_new_for_bus_sync (
                          G_BUS_TYPE_SYSTEM,
                          G_DBUS_PROXY_FLAGS_NONE,
                          "org.freedesktop.Accounts",
                          user_object_path,
                          NULL,
                          &error);

  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRLOC, error->message);
      g_clear_error (&error);
    }
  else
    {
      AccountsUser * prev = g_hash_table_lookup (self->priv->users, user_object_path);

      if (prev != NULL) /* we've already got this user... sync its properties */
        {
          sync_user_properties (G_DBUS_PROXY(user), G_DBUS_PROXY(prev));
          g_object_unref (user);
          user = prev;
        }
      else /* ooo, we got a new user */
        {
          g_signal_connect (user, "changed", G_CALLBACK(on_user_changed), self);
          g_hash_table_insert (self->priv->users, g_strdup(user_object_path), user);
        }

      add_user_sessions (self, user);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void add_user_session ( UsersServiceDbus *  service,
AccountsUser *  user,
const gchar *  ssid 
) [static]

Definition at line 435 of file users-service-dbus.c.

{
  ConsoleKitSession * session_proxy = create_consolekit_session_proxy (ssid);
  if (session_proxy != NULL)
    {
      UsersServiceDbusPrivate * priv = service->priv;
      gchar * seat = get_seat_from_session_proxy (session_proxy);

      /* is this session in our seat? */
      if (seat && priv->seat && !g_strcmp0 (seat, priv->seat))
        {
          /* does this session have a display? */
          gchar * display = NULL;
          console_kit_session_call_get_x11_display_sync (session_proxy,
                                                         &display,
                                                         NULL, NULL);
          const gboolean has_display = display && *display;
          g_free (display);

          if (has_display)
            {
              const gchar * username = accounts_user_get_user_name (user);
              g_debug ("%s adding %s's session '%s' to our tables",
                       G_STRLOC, username, ssid);

              g_hash_table_insert (priv->sessions,
                                   g_strdup (ssid),
                                   g_object_ref (user));

              user_add_session (user, ssid);
            }
        }

      g_free (seat);
      g_object_unref (session_proxy);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void add_user_sessions ( UsersServiceDbus *  self,
AccountsUser *  user 
) [static]

Definition at line 477 of file users-service-dbus.c.

{
  const guint64 uid = accounts_user_get_uid (user);
  const char * username = accounts_user_get_user_name (user);
  g_debug ("%s adding %s (%i)", G_STRLOC, username, (int)uid);

  GError * error = NULL;
  gchar ** sessions = NULL;
  console_kit_manager_call_get_sessions_for_unix_user_sync (
                                              self->priv->ck_manager_proxy,
                                              uid,
                                              &sessions,
                                              NULL,
                                              &error);

  if (error != NULL)
    {
      g_debug ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }
  else if (sessions != NULL)
    {
      int i;

      for (i=0; sessions[i]; i++)
        {
          const char * const ssid = sessions[i];
          g_debug ("%s adding %s's session %s", G_STRLOC, username, ssid);
          add_user_session (self, user, ssid);
        }

      g_strfreev (sessions);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static ConsoleKitSession* create_consolekit_session_proxy ( const char *  ssid) [static]

Definition at line 315 of file users-service-dbus.c.

{
  GError * error = NULL;

  ConsoleKitSession * p = console_kit_session_proxy_new_for_bus_sync (
                            G_BUS_TYPE_SYSTEM,
                            G_DBUS_PROXY_FLAGS_NONE,
                            CK_ADDR,
                            ssid,
                            NULL,
                            &error);
  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }

  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static DisplayManagerSeat* create_display_proxy ( UsersServiceDbus *  self) [static]

Definition at line 882 of file users-service-dbus.c.

{
  const gchar * const seat = g_getenv ("XDG_SEAT_PATH");
  g_debug ("%s creating a DisplayManager proxy for seat %s", G_STRLOC, seat);

  GError * error = NULL;
  DisplayManagerSeat * p = display_manager_seat_proxy_new_for_bus_sync (
                             G_BUS_TYPE_SYSTEM,
                             G_DBUS_PROXY_FLAGS_NONE,
                             "org.freedesktop.DisplayManager",
                             seat,
                             NULL,
                             &error);

  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }

  return p;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void emit_guest_login_changed ( UsersServiceDbus *  self) [static]

Definition at line 305 of file users-service-dbus.c.

{
  g_signal_emit (self, signals[GUEST_LOGGED_IN_CHANGED], 0);
}

Here is the caller graph for this function:

static void emit_user_list_changed ( UsersServiceDbus *  self) [static]

Definition at line 293 of file users-service-dbus.c.

{
  g_signal_emit (self, signals[USER_LIST_CHANGED], 0);
}

Here is the caller graph for this function:

static void emit_user_login_changed ( UsersServiceDbus *  self,
AccountsUser *  user 
) [static]

Definition at line 299 of file users-service-dbus.c.

{
  g_signal_emit (self, signals[USER_LOGGED_IN_CHANGED], 0, user);
}

Here is the caller graph for this function:

static AccountsUser* find_user_from_username ( UsersServiceDbus *  self,
const gchar *  username 
) [static]

Definition at line 700 of file users-service-dbus.c.

{
  AccountsUser * match = NULL;

  g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), match);

  gpointer user;
  GHashTableIter iter;
  g_hash_table_iter_init (&iter, self->priv->users);
  while (!match && g_hash_table_iter_next (&iter, NULL, &user))
    {
      if (!g_strcmp0 (username, accounts_user_get_user_name (user)))
        {
          match = user;
        }
    }

  return match;
}

Here is the call graph for this function:

Here is the caller graph for this function:

G_DEFINE_TYPE ( UsersServiceDbus  ,
users_service_dbus  ,
G_TYPE_OBJECT   
)
static gchar * get_seat ( UsersServiceDbus *  service) [static]

Definition at line 355 of file users-service-dbus.c.

{
  gchar * seat = NULL;
  gchar * ssid = NULL;
  GError * error = NULL;
  UsersServiceDbusPrivate * priv = service->priv;

  console_kit_manager_call_get_current_session_sync (priv->ck_manager_proxy,
                                                     &ssid,
                                                     NULL,
                                                     &error);

  if (error != NULL)
    {
      g_debug ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }
  else
    {
      ConsoleKitSession * session = create_consolekit_session_proxy (ssid);

      if (session != NULL)
        {
          seat = get_seat_from_session_proxy (session);
          g_object_unref (session);
        }
    }

  return seat;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gchar* get_seat_from_session_proxy ( ConsoleKitSession *  session_proxy) [static]

Definition at line 336 of file users-service-dbus.c.

{
  gchar * seat = NULL;

  GError * error = NULL;
  console_kit_session_call_get_seat_id_sync (session_proxy,
                                             &seat,
                                             NULL,
                                             &error);
  if (error != NULL)
    {
      g_debug ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }

  return seat;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gchar* get_unix_username_from_ssid ( UsersServiceDbus *  self,
const gchar *  ssid 
) [static]

Definition at line 760 of file users-service-dbus.c.

{
  gchar * username = NULL;

  ConsoleKitSession * session_proxy = create_consolekit_session_proxy (ssid);
  if (session_proxy != NULL)
    {
      guint uid = 0;
      GError * error = NULL;
      console_kit_session_call_get_unix_user_sync (session_proxy,
                                                   &uid,
                                                   NULL, &error);
      if (error != NULL)
        {
          g_warning ("%s: %s", G_STRLOC, error->message);
          g_clear_error (&error);
        }
      else
        {
          errno = 0;
          const struct passwd * pwent = getpwuid (uid);
          if (pwent == NULL)
            {
              g_warning ("Failed to lookup user id %d: %s", (int)uid, g_strerror(errno));
            }
          else
            {
              username = g_strdup (pwent->pw_name);
            }
        }

      g_object_unref (session_proxy);
    }

  return username;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean is_guest_username ( const char *  username) [static]

Definition at line 799 of file users-service-dbus.c.

{
  if (!g_strcmp0 (username, "guest"))
    return TRUE;

  if (username && g_str_has_prefix (username, "guest-"))
    return TRUE;

  return FALSE;
}

Here is the caller graph for this function:

static gboolean is_interesting_user_property ( const char *  key) [static]

Definition at line 514 of file users-service-dbus.c.

{
  return !g_strcmp0 (key, "IconFile")
      || !g_strcmp0 (key, "LoginFrequency")
      || !g_strcmp0 (key, "RealName")
      || !g_strcmp0 (key, "Uid")
      || !g_strcmp0 (key, "UserName");
}

Here is the caller graph for this function:

static void on_session_added ( ConsoleKitSeat *  seat,
const gchar *  ssid,
UsersServiceDbus *  service 
) [static]

Here is the caller graph for this function:

static void on_session_added ( ConsoleKitSeat *seat_proxy  G_GNUC_UNUSED,
const gchar *  ssid,
UsersServiceDbus *  service 
) [static]

Definition at line 813 of file users-service-dbus.c.

{
  g_return_if_fail (IS_USERS_SERVICE_DBUS(service));

  gchar * username = get_unix_username_from_ssid (service, ssid);
  g_debug ("%s %s() username %s has new session %s", G_STRLOC, G_STRFUNC, username, ssid);

  if (is_guest_username (username))
    {
      /* handle guest as a special case -- it's not in the GDM
         user tables and there isn't be an AccountsUser for it */
      g_debug("Found guest session: %s", ssid);
      g_free (service->priv->guest_ssid);
      service->priv->guest_ssid = g_strdup (ssid);
      emit_guest_login_changed (service);
    }
  else
    {
      AccountsUser * user = find_user_from_username (service, username);

      if (user != NULL)
        {
          add_user_session (service, user, ssid);
          emit_user_login_changed (service, user);
        }
    }

  g_free (username);
}

Here is the call graph for this function:

static void on_session_list ( ConsoleKitSeat *  seat,
GAsyncResult *  result,
UsersServiceDbus *  service 
) [static]

Definition at line 847 of file users-service-dbus.c.

{
  GError * error = NULL;
  gchar ** sessions = NULL;
  g_debug ("%s bootstrapping the session list", G_STRLOC);

  console_kit_seat_call_get_sessions_finish (seat_proxy,
                                             &sessions,
                                             result,
                                             &error);

  if (error != NULL)
    {
      g_debug ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }
  else if (sessions != NULL)
    {
      int i;

      for (i=0; sessions[i]; i++)
        {
          g_debug ("%s adding initial session '%s'", G_STRLOC, sessions[i]);
          on_session_added (seat_proxy, sessions[i], self);
        }

      g_strfreev (sessions);
    }

  g_debug ("%s done bootstrapping the session list", G_STRLOC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_session_removed ( ConsoleKitSeat *  seat,
const gchar *  ssid,
UsersServiceDbus *  service 
) [static]

Definition at line 726 of file users-service-dbus.c.

{
  g_return_if_fail (IS_USERS_SERVICE_DBUS (service));

  UsersServiceDbusPrivate * priv = service->priv;
  g_debug ("%s %s() session removed %s", G_STRLOC, G_STRFUNC, ssid);

  if (!g_strcmp0 (ssid, priv->guest_ssid))
    {
      g_debug ("%s removing guest session %s", G_STRLOC, ssid);
      g_clear_pointer (&priv->guest_ssid, g_free);
      emit_guest_login_changed (service);
    }
  else
    {
      AccountsUser * user = g_hash_table_lookup (priv->sessions, ssid);
      if (user == NULL)
        {
          g_debug ("%s we're not tracking ssid %s", G_STRLOC, ssid);
        }
      else
        {
          GObject * o = g_object_ref (G_OBJECT(user));
          g_hash_table_remove (service->priv->users, ssid);
          user_remove_session (user, ssid);
          emit_user_login_changed (service, user);
          g_object_unref (o);
        }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_user_added ( Accounts *  o,
const gchar *  user_object_path,
UsersServiceDbus *  service 
) [static]

Here is the caller graph for this function:

static void on_user_added ( Accounts *o  G_GNUC_UNUSED,
const gchar *user_path  G_GNUC_UNUSED,
UsersServiceDbus *  service 
) [static]

Definition at line 671 of file users-service-dbus.c.

{
  /* We see a new user but we might not want to list it --
     for example, lightdm shows up when we switch to the greeter.
     So instead of adding the user directly here, let's ask
     org.freedesktop.Accounts for a fresh list of users
     because it filters out special cases. */
  update_user_list (service);
}

Here is the call graph for this function:

static void on_user_changed ( AccountsUser *  user,
UsersServiceDbus *  service 
) [static]

The AccountsUserProxy's properties aren't being updated automatically for some reason...

the only update we get is the 'changed' signal. This function is a workaround to update our User object's properties.

Definition at line 576 of file users-service-dbus.c.

{
  AccountsUser * tmp = accounts_user_proxy_new_for_bus_sync (
                          G_BUS_TYPE_SYSTEM,
                          G_DBUS_PROXY_FLAGS_NONE,
                          "org.freedesktop.Accounts",
                          g_dbus_proxy_get_object_path (G_DBUS_PROXY(user)),
                          NULL,
                          NULL);
  if (tmp != NULL)
    {
      sync_user_properties (G_DBUS_PROXY(tmp), G_DBUS_PROXY(user));
      g_object_unref (tmp);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void on_user_deleted ( Accounts *  o,
const gchar *  user_object_path,
UsersServiceDbus *  service 
) [static]

Here is the caller graph for this function:

static void on_user_deleted ( Accounts *o  G_GNUC_UNUSED,
const gchar *  user_path,
UsersServiceDbus *  service 
) [static]

Definition at line 684 of file users-service-dbus.c.

{
  AccountsUser * user = g_hash_table_lookup (service->priv->users, user_path);

  if (user != NULL)
    {
      GObject * o = g_object_ref (G_OBJECT(user));
      g_hash_table_remove (service->priv->users, user_path);
      emit_user_list_changed (service);
      g_object_unref (o);
    }
}

Here is the call graph for this function:

static void sync_user_properties ( GDBusProxy *  source,
GDBusProxy *  target 
) [static]

Definition at line 524 of file users-service-dbus.c.

{
  gchar ** keys = g_dbus_proxy_get_cached_property_names (source);

  if (keys != NULL)
    {
      int i;
      GVariantBuilder builder;
      gboolean changed = FALSE;
      g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));

      for (i=0; keys[i]; i++)
        {
          const gchar * const key = keys[i];

          if (is_interesting_user_property (key))
            {
              GVariant * oldval = g_dbus_proxy_get_cached_property (target, key);
              GVariant * newval = g_dbus_proxy_get_cached_property (source, key);

              /* all the properties we're interested in are
                 basic types safe for g_variant_compare()... */
              g_assert (g_variant_type_is_basic(g_variant_get_type(newval)));

              if (g_variant_compare (oldval, newval))
                {
                  changed = TRUE;
                  g_dbus_proxy_set_cached_property (target, key, newval);
                  g_variant_builder_add (&builder, "{sv}", key, newval);
                }

              g_variant_unref (newval);
              g_variant_unref (oldval);
            }
        }

      if (changed)
        {
          g_signal_emit_by_name (target, "g-properties-changed", g_variant_builder_end(&builder), keys);
        }

      g_variant_builder_clear (&builder);
      g_strfreev (keys);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void update_user_list ( UsersServiceDbus *  self) [static]

Definition at line 635 of file users-service-dbus.c.

{
  g_return_if_fail(IS_USERS_SERVICE_DBUS(self));

  GError * error = NULL;
  char ** object_paths = NULL;
  UsersServiceDbusPrivate * priv = self->priv;

  accounts_call_list_cached_users_sync (priv->accounts_proxy,
                                        &object_paths,
                                        NULL,
                                        &error);

  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRFUNC, error->message);
      g_clear_error (&error);
    }
  else if (object_paths != NULL)
    {
      gint i;

      for (i=0; object_paths[i] != NULL; ++i)
        {
          add_user_from_object_path (self, object_paths[i]);
        }

      emit_user_list_changed (self);

      g_strfreev (object_paths);
    }

  g_debug ("%s finished updating the user list", G_STRLOC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void user_add_session ( AccountsUser *  user,
const char *  ssid 
) [static]

Definition at line 412 of file users-service-dbus.c.

{
  g_hash_table_add (user_get_sessions_hashset(user), g_strdup(ssid));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static guint user_count_sessions ( AccountsUser *  user) [static]

Definition at line 424 of file users-service-dbus.c.

{
  return g_hash_table_size (user_get_sessions_hashset(user));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static GHashTable* user_get_sessions_hashset ( AccountsUser *  user) [static]

Definition at line 391 of file users-service-dbus.c.

{
  static GQuark q = 0;

  if (G_UNLIKELY(!q))
    {
      q = g_quark_from_static_string ("sessions");
    }

  GObject * o = G_OBJECT (user);
  GHashTable * h = g_object_get_qdata (o, q);
  if (h == NULL)
    {
      h = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
      g_object_set_qdata_full (o, q, h, (GDestroyNotify)g_hash_table_destroy);
    }

  return h;
}

Here is the caller graph for this function:

static void user_remove_session ( AccountsUser *  user,
const char *  ssid 
) [static]

Definition at line 418 of file users-service-dbus.c.

{
  g_hash_table_remove (user_get_sessions_hashset(user), ssid);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void users_service_dbus_activate_guest_session ( UsersServiceDbus *  self)

users_service_dbus_activate_guest_session:

Activates the guest account.

Definition at line 943 of file users-service-dbus.c.

{
  g_return_if_fail(IS_USERS_SERVICE_DBUS(self));

  DisplayManagerSeat * dp = create_display_proxy (self);
  display_manager_seat_call_switch_to_guest_sync (dp, "", NULL, NULL);
  g_clear_object (&dp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void users_service_dbus_activate_user_session ( UsersServiceDbus *  self,
AccountsUser *  user 
)

users_service_dbus_activate_user_session:

Activates a specific user.

Definition at line 958 of file users-service-dbus.c.

{
  g_return_if_fail (IS_USERS_SERVICE_DBUS(self));

  const char * const username = accounts_user_get_user_name (user);
  DisplayManagerSeat * dp = create_display_proxy (self);
  display_manager_seat_call_switch_to_user_sync (dp, username, "", NULL, NULL);
  g_clear_object (&dp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean users_service_dbus_can_activate_session ( UsersServiceDbus *  self)

Definition at line 986 of file users-service-dbus.c.

{
  gboolean can_activate = FALSE;

  g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), can_activate);

  GError * error = NULL;
  console_kit_seat_call_can_activate_sessions_sync (self->priv->seat_proxy,
                                                    &can_activate,
                                                    NULL,
                                                    &error);
  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRLOC, error->message);
      g_error_free (error);
    }

  return can_activate;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void users_service_dbus_class_init ( UsersServiceDbusClass *  klass) [static]

Definition at line 151 of file users-service-dbus.c.

{
  GObjectClass *object_class = G_OBJECT_CLASS (klass);

  g_type_class_add_private (object_class, sizeof (UsersServiceDbusPrivate));

  object_class->dispose = users_service_dbus_dispose;
  object_class->finalize = users_service_dbus_finalize;

  signals[USER_LIST_CHANGED] = g_signal_new (
              "user-list-changed",
              G_TYPE_FROM_CLASS (klass),
              G_SIGNAL_RUN_LAST,
              G_STRUCT_OFFSET (UsersServiceDbusClass, user_list_changed),
              NULL, NULL,
              g_cclosure_marshal_VOID__VOID,
              G_TYPE_NONE, 0);

  signals[USER_LOGGED_IN_CHANGED] = g_signal_new (
              "user-logged-in-changed",
              G_TYPE_FROM_CLASS (klass),
              G_SIGNAL_RUN_LAST,
              G_STRUCT_OFFSET (UsersServiceDbusClass, user_logged_in_changed),
              NULL, NULL,
              g_cclosure_marshal_VOID__OBJECT,
              G_TYPE_NONE, 1, G_TYPE_OBJECT);

  signals[GUEST_LOGGED_IN_CHANGED] = g_signal_new (
              "guest-logged-in-changed",
              G_TYPE_FROM_CLASS (klass),
              G_SIGNAL_RUN_LAST,
              G_STRUCT_OFFSET (UsersServiceDbusClass, guest_logged_in_changed),
              NULL, NULL,
              g_cclosure_marshal_VOID__VOID,
              G_TYPE_NONE, 0);
}

Here is the call graph for this function:

static void users_service_dbus_dispose ( GObject *  object) [static]

Definition at line 110 of file users-service-dbus.c.

{
  UsersServiceDbusPrivate * priv = USERS_SERVICE_DBUS(object)->priv;

  g_clear_object (&priv->accounts_proxy);
  g_clear_object (&priv->seat_proxy);
  g_clear_object (&priv->ck_manager_proxy);

  if (priv->cancellable != NULL)
    {
      g_cancellable_cancel (priv->cancellable);
      g_clear_object (&priv->cancellable);
    }

  if (priv->users != NULL)
    {
      g_hash_table_destroy (priv->users);
      priv->users = NULL;
    }

  if (priv->sessions != NULL)
    {
      g_hash_table_destroy (priv->sessions);
      priv->sessions = NULL;
    }

  G_OBJECT_CLASS (users_service_dbus_parent_class)->dispose (object);
}

Here is the caller graph for this function:

static void users_service_dbus_finalize ( GObject *  object) [static]

Definition at line 140 of file users-service-dbus.c.

{
  UsersServiceDbusPrivate * priv = USERS_SERVICE_DBUS(object)->priv;

  g_free (priv->guest_ssid);
  g_free (priv->seat);

  G_OBJECT_CLASS (users_service_dbus_parent_class)->finalize (object);
}

Here is the caller graph for this function:

GList* users_service_dbus_get_user_list ( UsersServiceDbus *  self)

users_service_dbus_get_user_list:

Returns: (transfer container): a list of AccountsUser objects

Definition at line 915 of file users-service-dbus.c.

{
  g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), NULL);

  return g_hash_table_get_values (self->priv->users);
}

Here is the caller graph for this function:

gboolean users_service_dbus_guest_session_enabled ( UsersServiceDbus *  self)

users_service_dbus_guest_session_enabled:

Tells whether or not guest sessions are allowed.

Definition at line 975 of file users-service-dbus.c.

{
  g_return_val_if_fail(IS_USERS_SERVICE_DBUS(self), FALSE);

  DisplayManagerSeat * dp = create_display_proxy (self);
  const gboolean enabled = display_manager_seat_get_has_guest_account (dp);
  g_clear_object (&dp);
  return enabled;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void users_service_dbus_init ( UsersServiceDbus *  self) [static]

create the consolekit manager proxy...

create the consolekit seat proxy...

create the accounts manager proxy...

Definition at line 189 of file users-service-dbus.c.

{
  GError * error = NULL;

  self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
                                            USERS_SERVICE_DBUS_TYPE,
                                            UsersServiceDbusPrivate);

  UsersServiceDbusPrivate * p  = self->priv;

  p->cancellable = g_cancellable_new ();

  /* ssid -> AccountsUser */
  p->sessions = g_hash_table_new_full (g_str_hash,
                                       g_str_equal,
                                       g_free,
                                       g_object_unref);

  /* user object path -> AccountsUser */
  p->users = g_hash_table_new_full (g_str_hash,
                                    g_str_equal,
                                    g_free,
                                    g_object_unref);

  p->ck_manager_proxy = console_kit_manager_proxy_new_for_bus_sync (
                             G_BUS_TYPE_SYSTEM,
                             G_DBUS_PROXY_FLAGS_NONE,
                             "org.freedesktop.ConsoleKit",
                             "/org/freedesktop/ConsoleKit/Manager",
                             NULL,
                             &error);
  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRLOC, error->message);
      g_clear_error (&error);
    }

  p->seat = get_seat (self);

  if (p->seat != NULL)
    {
      ConsoleKitSeat * proxy = console_kit_seat_proxy_new_for_bus_sync (
                                 G_BUS_TYPE_SYSTEM,
                                 G_DBUS_PROXY_FLAGS_NONE,
                                 "org.freedesktop.ConsoleKit",
                                 p->seat,
                                 NULL,
                                 &error);

      if (error != NULL)
        {
          g_warning ("Failed to connect to the ConsoleKit seat: %s", error->message);
          g_clear_error (&error);
        }
      else
        {
          g_signal_connect (proxy, "session-added",
                            G_CALLBACK (on_session_added), self);
          g_signal_connect (proxy, "session-removed",
                            G_CALLBACK (on_session_removed), self);
          console_kit_seat_call_get_sessions (proxy, p->cancellable,
                            (GAsyncReadyCallback)on_session_list, self);
          p->seat_proxy = proxy;
        }
    }

  Accounts * proxy = accounts_proxy_new_for_bus_sync (
                       G_BUS_TYPE_SYSTEM,
                       G_DBUS_PROXY_FLAGS_NONE,
                       "org.freedesktop.Accounts",
                       "/org/freedesktop/Accounts",
                       NULL,
                       &error);
  if (error != NULL)
    {
      g_warning ("%s: %s", G_STRFUNC, error->message);
      g_clear_error (&error);
    }
  else
    {
      g_signal_connect (proxy, "user-added", G_CALLBACK(on_user_added), self);
      g_signal_connect (proxy, "user-deleted", G_CALLBACK(on_user_deleted), self);
      p->accounts_proxy = proxy;
      update_user_list (self);
    }
}

Here is the call graph for this function:

gboolean users_service_dbus_is_guest_logged_in ( UsersServiceDbus *  self)

Definition at line 1007 of file users-service-dbus.c.

{
  g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), FALSE);

  return self->priv->guest_ssid != NULL;
}

Here is the caller graph for this function:

gboolean users_service_dbus_is_user_logged_in ( UsersServiceDbus *  self,
AccountsUser *  user 
)

Definition at line 1015 of file users-service-dbus.c.

{
  g_return_val_if_fail (IS_USERS_SERVICE_DBUS(self), FALSE);
  g_return_val_if_fail (IS_ACCOUNTS_USER(user), FALSE);

  return user_count_sessions (user) > 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void users_service_dbus_show_greeter ( UsersServiceDbus *  self)

users_service_dbus_show_greeter:

Ask the Display Mnaager to switch to the greeter screen.

Definition at line 928 of file users-service-dbus.c.

{
  g_return_if_fail (IS_USERS_SERVICE_DBUS(self));

  DisplayManagerSeat * dp = create_display_proxy (self);
  display_manager_seat_call_switch_to_greeter_sync (dp, NULL, NULL);
  g_clear_object (&dp);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

guint signals[N_SIGNALS] = { 0 } [static]

Definition at line 105 of file users-service-dbus.c.