[gnome-settings-daemon/wip/identity: 1/2] blah



commit 1ec50b942a891ab76ed71c455b072312ff5d290e
Author: Ray Strode <rstrode redhat com>
Date:   Wed May 23 13:48:49 2012 -0400

    blah

 configure.ac                                    |   30 ++
 plugins/Makefile.am                             |    6 +
 plugins/identity/gsd-alarm.c                    |  490 +++++++++++++++++++++++
 plugins/identity/gsd-alarm.h                    |   66 +++
 plugins/identity/gsd-identity-manager-private.h |   45 ++
 plugins/identity/gsd-identity-manager.c         |  171 ++++++++
 plugins/identity/gsd-identity-manager.h         |  115 ++++++
 plugins/identity/gsd-identity-plugin.c          |  224 +++++++++++
 plugins/identity/gsd-identity-plugin.h          |   59 +++
 plugins/identity/gsd-identity.c                 |   57 +++
 plugins/identity/gsd-identity.h                 |   63 +++
 11 files changed, 1326 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 923d3e5..aae00a2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -287,6 +287,35 @@ fi
 
 AC_SUBST(NSS_DATABASE)
 
+dnl ==============================================
+dnl kerberos section
+dnl ==============================================
+AC_ARG_ENABLE([kerberos],
+              AS_HELP_STRING([--enable-kerberos], [Use Kerberos]),
+              [with_kerberos=$enableval],
+              [with_kerberos=no])
+
+AC_PATH_PROG([KRB5_CONFIG], krb5-config, none, $PATH:/usr/kerberos/bin)
+
+if test "x$KRB5_CONFIG" != "xnone"; then
+    KRB5_LIBS="`${KRB5_CONFIG} --libs krb5`"
+    KRB5_CFLAGS="`${KRB5_CONFIG} --cflags krb5`"
+    have_kerberos=yes
+else
+    KRB5_LIBS=""
+    KRB5_CFLAGS=""
+    have_kerberos=no
+fi
+AC_SUBST(KRB5_CFLAGS)
+AC_SUBST(KRB5_LIBS)
+
+if test "$with_kerberos" = "yes" ; then
+  if test "$have_kerberos" = "no" ; then
+      AC_MSG_ERROR([kerberos support requested, but not available])
+  fi
+  AC_DEFINE(HAVE_KERBEROS, 1, [Define to 1 if kerberos is available])
+fi
+AM_CONDITIONAL(BUILD_KERBEROS, [test x$with_kerberos = xyes])
 
 dnl ==============================================
 dnl power section
@@ -458,6 +487,7 @@ plugins/color/Makefile
 plugins/common/Makefile
 plugins/cursor/Makefile
 plugins/dummy/Makefile
+plugins/identity/Makefile
 plugins/power/Makefile
 plugins/housekeeping/Makefile
 plugins/keyboard/Makefile
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index a4aa666..418c86e 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -33,6 +33,12 @@ else
 disabled_plugins += smartcard
 endif
 
+if BUILD_KERBEROS
+enabled_plugins += identity
+else
+disabled_plugins += identity
+endif
+
 if HAVE_GUDEV
 enabled_plugins += orientation
 else
diff --git a/plugins/identity/gsd-alarm.c b/plugins/identity/gsd-alarm.c
new file mode 100644
index 0000000..c5f67af
--- /dev/null
+++ b/plugins/identity/gsd-alarm.c
@@ -0,0 +1,490 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Ray Strode
+ * Based on work by Colin Walters
+ */
+
+#include "config.h"
+
+#include "gsd-alarm.h"
+
+#ifdef HAVE_TIMERFD
+#include <sys/timerfd.h>
+#endif
+
+#include <unistd.h>
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+#include <gio/gunixinputstream.h>
+
+typedef struct {
+        GSource      *source;
+        GInputStream *stream;
+} Timer;
+
+typedef struct {
+        GSource *source;
+} Timeout;
+
+#define MAX_TIMEOUT_INTERVAL (10 * 1000)
+
+typedef enum {
+    GSD_ALARM_TYPE_UNSCHEDULED,
+    GSD_ALARM_TYPE_TIMER,
+    GSD_ALARM_TYPE_TIMEOUT,
+} GsdAlarmType;
+
+struct _GsdAlarmPrivate
+{
+        GCancellable *cancellable;
+        GDateTime    *time;
+        GDateTime    *previous_wakeup_time;
+        GMainContext *context;
+        GSource      *immediate_wakeup_source;
+
+        GsdAlarmType type;
+        union {
+                Timer   timer;
+                Timeout timeout;
+        };
+};
+
+enum {
+        FIRED,
+        REARMED,
+        NGSDBER_OF_SIGNALS,
+};
+
+static void schedule_wakeups (GsdAlarm *self);
+static void schedule_wakeups_with_timeout_source (GsdAlarm *self);
+static guint signals[NGSDBER_OF_SIGNALS] = { 0 };
+
+G_DEFINE_TYPE (GsdAlarm, gsd_alarm, G_TYPE_OBJECT);
+
+static void
+clear_scheduled_immediate_wakeup (GsdAlarm *self)
+{
+        if (self->priv->immediate_wakeup_source != NULL) {
+                g_source_destroy (self->priv->immediate_wakeup_source);
+                self->priv->immediate_wakeup_source = NULL;
+        }
+}
+
+static void
+clear_scheduled_timer_wakeups (GsdAlarm *self)
+{
+#ifdef HAVE_TIMERFD
+        GError *error;
+        gboolean is_closed;
+
+        if (self->priv->timer.stream == NULL) {
+                return;
+        }
+
+        g_source_destroy (self->priv->timer.source);
+        self->priv->timer.source = NULL;
+
+        error = NULL;
+        is_closed = g_input_stream_close (self->priv->timer.stream,
+                                          NULL,
+                                          &error);
+
+        if (!is_closed) {
+                g_warning ("GsdAlarm: could not close timer stream: %s",
+                           error->message);
+                g_error_free (error);
+        }
+
+        g_object_unref (self->priv->timer.stream);
+        self->priv->timer.stream = NULL;
+
+#endif
+}
+
+static void
+clear_scheduled_timeout_wakeups (GsdAlarm *self)
+{
+        g_source_destroy (self->priv->timeout.source);
+        self->priv->timeout.source = NULL;
+}
+
+static void
+clear_scheduled_wakeups (GsdAlarm *self)
+{
+        clear_scheduled_immediate_wakeup (self);
+
+        switch (self->priv->type) {
+                case GSD_ALARM_TYPE_TIMER:
+                        clear_scheduled_timer_wakeups (self);
+                        break;
+
+                case GSD_ALARM_TYPE_TIMEOUT:
+                        clear_scheduled_timeout_wakeups (self);
+                        break;
+
+                default:
+                        break;
+        }
+
+        if (self->priv->cancellable != NULL) {
+                g_object_unref (self->priv->cancellable);
+                self->priv->cancellable = NULL;
+        }
+
+        if (self->priv->context != NULL) {
+                g_main_context_unref (self->priv->context);
+                self->priv->context = NULL;
+        }
+
+        if (self->priv->previous_wakeup_time != NULL) {
+                g_date_time_unref (self->priv->previous_wakeup_time);
+                self->priv->previous_wakeup_time = NULL;
+        }
+
+        self->priv->type = GSD_ALARM_TYPE_UNSCHEDULED;
+}
+
+static void
+gsd_alarm_finalize (GObject *object)
+{
+        GsdAlarm *self = GSD_ALARM (object);
+
+        if (self->priv->cancellable != NULL &&
+            !g_cancellable_is_cancelled (self->priv->cancellable)) {
+                g_cancellable_cancel (self->priv->cancellable);
+        }
+
+        clear_scheduled_wakeups (self);
+
+        if (self->priv->time != NULL) {
+                g_date_time_unref (self->priv->time);
+        }
+
+        if (self->priv->previous_wakeup_time != NULL) {
+                g_date_time_unref (self->priv->previous_wakeup_time);
+        }
+
+        G_OBJECT_CLASS (gsd_alarm_parent_class)->finalize (object);
+}
+
+static void
+gsd_alarm_class_init (GsdAlarmClass *klass)
+{
+        GObjectClass *object_class;
+
+        object_class = G_OBJECT_CLASS (klass);
+
+        object_class->finalize = gsd_alarm_finalize;
+
+        g_type_class_add_private (klass, sizeof (GsdAlarmPrivate));
+
+        signals[FIRED] = g_signal_new ("fired",
+                                       G_TYPE_FROM_CLASS (klass),
+                                       G_SIGNAL_RUN_LAST,
+                                       0,
+                                       NULL, NULL, NULL,
+                                       G_TYPE_NONE, 0);
+
+        signals[REARMED] = g_signal_new ("rearmed",
+                                         G_TYPE_FROM_CLASS (klass),
+                                         G_SIGNAL_RUN_LAST,
+                                         0,
+                                         NULL, NULL, NULL,
+                                         G_TYPE_NONE, 0);
+}
+
+static void
+gsd_alarm_init (GsdAlarm *self)
+{
+        self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+                                                  GSD_TYPE_ALARM,
+                                                  GsdAlarmPrivate);
+        self->priv->type = GSD_ALARM_TYPE_UNSCHEDULED;
+}
+
+static void
+on_cancelled (GCancellable *cancellable,
+              gpointer      user_data)
+{
+        GsdAlarm *self = GSD_ALARM (user_data);
+
+        clear_scheduled_wakeups (self);
+}
+
+static void
+fire_alarm (GsdAlarm *self)
+{
+        g_signal_emit (G_OBJECT (self), signals[FIRED], 0);
+}
+
+static void
+rearm_alarm (GsdAlarm *self)
+{
+        g_signal_emit (G_OBJECT (self), signals[REARMED], 0);
+}
+
+static void
+fire_or_rearm_alarm (GsdAlarm *self)
+{
+        GTimeSpan  time_until_fire;
+        GTimeSpan  previous_time_until_fire;
+        GDateTime *now;
+
+        now = g_date_time_new_now_local ();
+        time_until_fire = g_date_time_difference (self->priv->time, now);
+
+        if (self->priv->previous_wakeup_time == NULL) {
+                self->priv->previous_wakeup_time = now;
+
+                /* If, according to the time, we're past when we should have fired,
+                 * then fire the alarm.
+                 */
+                if (time_until_fire <= 0) {
+                        fire_alarm (self);
+                }
+        } else {
+                previous_time_until_fire = g_date_time_difference (self->priv->time,
+                                                                   self->priv->previous_wakeup_time);
+
+                g_date_time_unref (self->priv->previous_wakeup_time);
+                self->priv->previous_wakeup_time = now;
+
+                /* If, according to the time, we're past when we should have fired,
+                 * and this is the first wakeup where that's been true then fire
+                 * the alarm. The first check makes sure we don't fire prematurely,
+                 * and the second check makes sure we don't fire more than once
+                 */
+                if (time_until_fire <= 0 && previous_time_until_fire > 0) {
+                        fire_alarm (self);
+
+                /* If, according to the time, we're before when we should fire,
+                 * and we previously fired the alarm, then we've jumped back in
+                 * time and need to rearm the alarm.
+                 */
+                } else if (time_until_fire > 0 && previous_time_until_fire <= 0) {
+                        rearm_alarm (self);
+                }
+        }
+}
+
+static gboolean
+on_immediate_wakeup_source_ready (gpointer user_data)
+{
+        GsdAlarm *self = GSD_ALARM (user_data);
+
+        fire_or_rearm_alarm (self);
+
+        return FALSE;
+}
+
+#ifdef HAVE_TIMERFD
+static gboolean
+on_timer_source_ready (GObject  *stream,
+                       gpointer  user_data)
+{
+        GsdAlarm *self = GSD_ALARM (user_data);
+        gint64 number_of_fires;
+        gssize bytes_read;
+
+        bytes_read = g_pollable_input_stream_read_nonblocking (G_POLLABLE_INPUT_STREAM (stream),
+                                                               &number_of_fires,
+                                                               sizeof (gint64),
+                                                               NULL,
+                                                               NULL);
+
+        if (bytes_read == sizeof (gint64)) {
+                if (number_of_fires < 0 || number_of_fires > 1) {
+                        g_warning ("GsdAlarm: expected timerfd to report firing once,"
+                                   "but it reported firing %ld times\n",
+                                   (long) number_of_fires);
+                }
+        }
+
+        fire_or_rearm_alarm (self);
+        return TRUE;
+}
+#endif
+
+static gboolean
+schedule_wakeups_with_timerfd (GsdAlarm *self)
+{
+#ifdef HAVE_TIMERFD
+        struct itimerspec timer_spec;
+        int fd;
+        int result;
+
+        g_debug ("GsdAlarm: trying to use kernel timer");
+
+        fd = timerfd_create (CLOCK_REALTIME, TFD_CLOEXEC | TFD_NONBLOCK);
+
+        if (fd < 0) {
+                g_debug ("GsdAlarm: could not create timer fd: %m");
+                return FALSE;
+        }
+
+        memset (&timer_spec, 0, sizeof (timer_spec));
+        timer_spec.it_value.tv_sec = g_date_time_to_unix (self->priv->time) + 1;
+
+        result = timerfd_settime (fd,
+                                  TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET,
+                                  &timer_spec,
+                                  NULL);
+
+        if (result < 0) {
+                g_debug ("GsdAlarm: could not set timer: %m");
+                return FALSE;
+        }
+
+        self->priv->type = GSD_ALARM_TYPE_TIMER;
+        self->priv->timer.stream = g_unix_input_stream_new (fd, TRUE);
+
+        self->priv->timer.source = g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM (self->priv->timer.stream),
+                                                                          self->priv->cancellable);
+        g_source_set_callback (self->priv->timer.source,
+                               (GSourceFunc)
+                               on_timer_source_ready,
+                               self,
+                               NULL);
+        g_source_attach (self->priv->timer.source,
+                         self->priv->context);
+
+        return TRUE;
+
+#endif /* HAVE_TIMERFD */
+
+    return FALSE;
+}
+
+static gboolean
+on_timeout_source_ready (gpointer user_data)
+{
+        GsdAlarm *self = GSD_ALARM (user_data);
+
+        fire_or_rearm_alarm (self);
+
+        schedule_wakeups_with_timeout_source (self);
+
+        return FALSE;
+}
+
+static void
+schedule_wakeups_with_timeout_source (GsdAlarm *self)
+{
+        GDateTime *now;
+        GTimeSpan time_span;
+        guint interval;
+        self->priv->type = GSD_ALARM_TYPE_TIMEOUT;
+
+        now = g_date_time_new_now_local ();
+        time_span = g_date_time_difference (self->priv->time, now);
+        g_date_time_unref (now);
+
+        time_span = CLAMP (time_span, 1000 * G_TIME_SPAN_MILLISECOND, G_MAXUINT * G_TIME_SPAN_MILLISECOND);
+        interval = time_span / G_TIME_SPAN_MILLISECOND;
+
+        /* We poll every 10 seconds or so because we want to catch time skew
+         */
+        interval = MIN (interval, MAX_TIMEOUT_INTERVAL);
+
+        self->priv->timeout.source = g_timeout_source_new (interval);
+        g_source_set_callback (self->priv->timeout.source,
+                               (GSourceFunc)
+                               on_timeout_source_ready,
+                               self,
+                               NULL);
+
+        g_source_attach (self->priv->timeout.source,
+                         self->priv->context);
+}
+
+static void
+schedule_wakeups (GsdAlarm *self)
+{
+        gboolean wakeup_scheduled;
+
+        wakeup_scheduled = schedule_wakeups_with_timerfd (self);
+
+        if (!wakeup_scheduled) {
+                g_debug ("GsdAlarm: falling back to polling timeout\n");
+                schedule_wakeups_with_timeout_source (self);
+        }
+}
+
+static void
+schedule_immediate_wakeup (GsdAlarm *self)
+{
+        self->priv->immediate_wakeup_source = g_idle_source_new ();
+
+        g_source_set_callback (self->priv->immediate_wakeup_source,
+                               (GSourceFunc)
+                               on_immediate_wakeup_source_ready,
+                               self,
+                               NULL);
+
+        g_source_attach (self->priv->immediate_wakeup_source,
+                         self->priv->context);
+}
+
+void
+gsd_alarm_set (GsdAlarm      *self,
+              GDateTime    *time,
+              GCancellable *cancellable)
+{
+        if (self->priv->cancellable != NULL) {
+                if (!g_cancellable_is_cancelled (self->priv->cancellable)) {
+                        g_cancellable_cancel (cancellable);
+                }
+
+                if (self->priv->cancellable != NULL) {
+                    g_object_unref (self->priv->cancellable);
+                    self->priv->cancellable = NULL;
+                }
+        }
+
+        if (cancellable == NULL) {
+                self->priv->cancellable = g_cancellable_new ();
+        } else {
+                self->priv->cancellable = g_object_ref (cancellable);
+        }
+
+        g_cancellable_connect (self->priv->cancellable,
+                               G_CALLBACK (on_cancelled),
+                               self,
+                               NULL);
+        self->priv->time = g_date_time_ref (time);
+        self->priv->context = g_main_context_ref (g_main_context_default ());
+
+        schedule_wakeups (self);
+
+        /* Wake up right away, in case it's already expired leaving the gate */
+        schedule_immediate_wakeup (self);
+}
+
+GsdAlarm *
+gsd_alarm_new (void)
+{
+        GsdAlarm *self;
+
+        self = GSD_ALARM (g_object_new (GSD_TYPE_ALARM, NULL));
+
+        return GSD_ALARM (self);
+}
diff --git a/plugins/identity/gsd-alarm.h b/plugins/identity/gsd-alarm.h
new file mode 100644
index 0000000..8932b80
--- /dev/null
+++ b/plugins/identity/gsd-alarm.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors: Ray Strode
+ */
+
+#ifndef __GSD_ALARM_H__
+#define __GSD_ALARM_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_ALARM             (gsd_alarm_get_type ())
+#define GSD_ALARM(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_ALARM, GsdAlarm))
+#define GSD_ALARM_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_ALARM, GsdAlarmClass))
+#define GSD_IS_ALARM(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_ALARM))
+#define GSD_IS_ALARM_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GSD_TYPE_ALARM))
+#define GSD_ALARM_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), GSD_TYPE_ALARM, GsdAlarmClass))
+
+typedef struct _GsdAlarm        GsdAlarm;
+typedef struct _GsdAlarmClass   GsdAlarmClass;
+typedef struct _GsdAlarmPrivate GsdAlarmPrivate;
+
+struct _GsdAlarm
+{
+        GObject parent;
+
+        GsdAlarmPrivate *priv;
+};
+
+struct _GsdAlarmClass
+{
+        GObjectClass parent_class;
+
+        void     (* fired)       (GsdAlarm *alarm);
+        void     (* rearmed)     (GsdAlarm *alarm);
+};
+
+GType         gsd_alarm_get_type (void);
+
+GsdAlarm      *gsd_alarm_new    (void);
+void          gsd_alarm_set    (GsdAlarm      *alarm,
+                               GDateTime    *time,
+                               GCancellable *cancellable);
+G_END_DECLS
+
+#endif /* __GSD_ALARM_H__ */
diff --git a/plugins/identity/gsd-identity-manager-private.h b/plugins/identity/gsd-identity-manager-private.h
new file mode 100644
index 0000000..e80f60a
--- /dev/null
+++ b/plugins/identity/gsd-identity-manager-private.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors: Ray Strode
+ */
+
+#ifndef __GSD_IDENTITY_MANAGER_PRIVATE_H__
+#define __GSD_IDENTITY_MANAGER_PRIVATE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "gsd-identity-manager.h"
+
+G_BEGIN_DECLS
+
+void      _gsd_identity_manager_emit_identity_added (GsdIdentityManager *identity_manager,
+                                                    GsdIdentity *identity);
+void      _gsd_identity_manager_emit_identity_removed (GsdIdentityManager *identity_manager,
+                                                      GsdIdentity *identity);
+void      _gsd_identity_manager_emit_identity_expired (GsdIdentityManager *identity_manager,
+                                                      GsdIdentity *identity);
+void      _gsd_identity_manager_emit_identity_renewed (GsdIdentityManager *identity_manager,
+                                                      GsdIdentity *identity);
+void      _gsd_identity_manager_emit_identity_renamed (GsdIdentityManager *identity_manager,
+                                                      GsdIdentity *identity);
+G_END_DECLS
+
+#endif /* __GSD_IDENTITY_MANAGER_PRIVATE_H__ */
diff --git a/plugins/identity/gsd-identity-manager.c b/plugins/identity/gsd-identity-manager.c
new file mode 100644
index 0000000..9b87c3a
--- /dev/null
+++ b/plugins/identity/gsd-identity-manager.c
@@ -0,0 +1,171 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+#include <gio/gio.h>
+
+#include "gsd-identity-manager.h"
+#include "gsd-identity-manager-private.h"
+
+enum {
+        IDENTITY_ADDED,
+        IDENTITY_REMOVED,
+        IDENTITY_EXPIRED,
+        IDENTITY_RENEWED,
+        IDENTITY_RENAMED,
+        NUMBER_OF_SIGNALS,
+};
+
+static guint signals[NUMBER_OF_SIGNALS] = { 0 };
+
+G_DEFINE_INTERFACE (GsdIdentityManager, gsd_identity_manager, G_TYPE_OBJECT);
+
+static void
+gsd_identity_manager_default_init (GsdIdentityManagerInterface *interface)
+{
+      signals[IDENTITY_ADDED] = g_signal_new ("identity-added",
+                                              G_TYPE_FROM_INTERFACE (interface),
+                                              G_SIGNAL_RUN_LAST,
+                                              G_STRUCT_OFFSET (GsdIdentityManagerInterface, identity_added),
+                                              NULL, NULL, NULL,
+                                              G_TYPE_NONE, 1, GSD_TYPE_IDENTITY);
+      signals[IDENTITY_REMOVED] = g_signal_new ("identity-removed",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (GsdIdentityManagerInterface, identity_removed),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, GSD_TYPE_IDENTITY);
+      signals[IDENTITY_EXPIRED] = g_signal_new ("identity-expired",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (GsdIdentityManagerInterface, identity_expired),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, GSD_TYPE_IDENTITY);
+      signals[IDENTITY_RENEWED] = g_signal_new ("identity-renewed",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (GsdIdentityManagerInterface, identity_renewed),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, GSD_TYPE_IDENTITY);
+      signals[IDENTITY_RENAMED] = g_signal_new ("identity-renamed",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (GsdIdentityManagerInterface, identity_renamed),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, GSD_TYPE_IDENTITY);
+}
+
+GQuark
+gsd_identity_manager_error_quark (void)
+{
+        static GQuark error_quark = 0;
+
+        if (error_quark == 0) {
+                error_quark = g_quark_from_static_string ("gsd-identity-manager-error");
+        }
+
+        return error_quark;
+}
+
+void
+gsd_identity_manager_list_identities (GsdIdentityManager   *self,
+                                      GCancellable        *cancellable,
+                                      GAsyncReadyCallback  callback,
+                                      gpointer             user_data)
+{
+        GSD_IDENTITY_MANAGER_GET_IFACE (self)->list_identities (self,
+                                                               cancellable,
+                                                               callback,
+                                                               user_data);
+}
+
+GList *
+gsd_identity_manager_list_identities_finish (GsdIdentityManager  *self,
+                                             GAsyncResult       *result,
+                                             GError            **error)
+{
+        return GSD_IDENTITY_MANAGER_GET_IFACE (self)->list_identities_finish (self,
+                                                                             result,
+                                                                             error);
+}
+
+void
+gsd_identity_manager_sign_identity_out (GsdIdentityManager   *self,
+                                        GsdIdentity          *identity,
+                                        GCancellable        *cancellable,
+                                        GAsyncReadyCallback  callback,
+                                        gpointer             user_data)
+{
+        GSD_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out (self, identity, cancellable, callback, user_data);
+}
+
+void
+gsd_identity_manager_sign_identity_out_finish (GsdIdentityManager  *self,
+                                               GAsyncResult       *result,
+                                               GError            **error)
+{
+        GSD_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out_finish (self, result, error);
+}
+
+char *
+gsd_identity_manager_name_identity (GsdIdentityManager *self,
+                                   GsdIdentity        *identity)
+{
+        return GSD_IDENTITY_MANAGER_GET_IFACE (self)->name_identity (self,
+                                                                    identity);
+}
+
+void
+_gsd_identity_manager_emit_identity_added (GsdIdentityManager *self,
+                                           GsdIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_ADDED], 0, identity);
+}
+
+void
+_gsd_identity_manager_emit_identity_removed (GsdIdentityManager *self,
+                                             GsdIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_REMOVED], 0, identity);
+}
+
+void
+_gsd_identity_manager_emit_identity_expired (GsdIdentityManager *self,
+                                             GsdIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_EXPIRED], 0, identity);
+}
+
+void
+_gsd_identity_manager_emit_identity_renewed (GsdIdentityManager *self,
+                                             GsdIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_RENEWED], 0, identity);
+}
+
+void
+_gsd_identity_manager_emit_identity_renamed (GsdIdentityManager *self,
+                                             GsdIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_RENAMED], 0, identity);
+}
diff --git a/plugins/identity/gsd-identity-manager.h b/plugins/identity/gsd-identity-manager.h
new file mode 100644
index 0000000..0b2adda
--- /dev/null
+++ b/plugins/identity/gsd-identity-manager.h
@@ -0,0 +1,115 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors: Ray Strode
+ */
+
+#ifndef __GSD_IDENTITY_MANAGER_H__
+#define __GSD_IDENTITY_MANAGER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "gsd-identity.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_IDENTITY_MANAGER             (gsd_identity_manager_get_type ())
+#define GSD_IDENTITY_MANAGER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_IDENTITY_MANAGER, GsdIdentityManager))
+#define GSD_IDENTITY_MANAGER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_IDENTITY_MANAGER, GsdIdentityManagerInterface))
+#define GSD_IS_IDENTITY_MANAGER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_IDENTITY_MANAGER))
+#define GSD_IDENTITY_MANAGER_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE((obj), GSD_TYPE_IDENTITY_MANAGER, GsdIdentityManagerInterface))
+#define GSD_IDENTITY_MANAGER_ERROR            (gsd_identity_manager_error_quark ())
+
+typedef struct _GsdIdentityManager          GsdIdentityManager;
+typedef struct _GsdIdentityManagerInterface GsdIdentityManagerInterface;
+typedef enum   _GsdIdentityManagerError     GsdIdentityManagerError;
+
+struct _GsdIdentityManagerInterface
+{
+        GTypeInterface base_interface;
+
+        /* Signals */
+        void      (* identity_added)    (GsdIdentityManager *identity_manager,
+                                         GsdIdentity        *identity);
+
+        void      (* identity_removed)  (GsdIdentityManager *identity_manager,
+                                         GsdIdentity        *identity);
+        void      (* identity_expired)  (GsdIdentityManager *identity_manager,
+                                         GsdIdentity        *identity);
+        void      (* identity_renewed)  (GsdIdentityManager *identity_manager,
+                                         GsdIdentity        *identity);
+        void      (* identity_renamed)  (GsdIdentityManager *identity_manager,
+                                         GsdIdentity        *identity);
+
+        /* Virtual Functions */
+        void      (* list_identities)        (GsdIdentityManager   *identity_manager,
+                                              GCancellable        *cancellable,
+                                              GAsyncReadyCallback  callback,
+                                              gpointer             user_data);
+        GList *   (* list_identities_finish) (GsdIdentityManager  *identity_manager,
+                                              GAsyncResult       *result,
+                                              GError            **error);
+
+        void      (* sign_identity_out)  (GsdIdentityManager   *identity_manager,
+                                          GsdIdentity          *identity,
+                                          GCancellable        *cancellable,
+                                          GAsyncReadyCallback  callback,
+                                          gpointer             user_data);
+        void      (* sign_identity_out_finish)  (GsdIdentityManager  *identity_manager,
+                                                 GAsyncResult       *result,
+                                                 GError            **error);
+
+        char  *   (* name_identity)      (GsdIdentityManager *identity_manager,
+                                          GsdIdentity        *identity);
+};
+
+enum _GsdIdentityManagerError {
+        GSD_IDENTITY_MANAGER_ERROR_INITIALIZING,
+        GSD_IDENTITY_MANAGER_ERROR_MONITORING,
+        GSD_IDENTITY_MANAGER_ERROR_SIGNING_OUT
+};
+
+GType      gsd_identity_manager_get_type         (void);
+GQuark     gsd_identity_manager_error_quark      (void);
+
+void       gsd_identity_manager_list_identities  (GsdIdentityManager   *identity_manager,
+                                                 GCancellable        *cancellable,
+                                                 GAsyncReadyCallback  callback,
+                                                 gpointer             user_data);
+GList *    gsd_identity_manager_list_identities_finish  (GsdIdentityManager  *identity_manager,
+                                                        GAsyncResult       *result,
+                                                        GError            **error);
+
+void       gsd_identity_manager_sign_identity_out    (GsdIdentityManager   *identity_manager,
+                                                      GsdIdentity          *identity,
+                                                      GCancellable        *cancellable,
+                                                      GAsyncReadyCallback  callback,
+                                                      gpointer             user_data);
+void       gsd_identity_manager_sign_identity_out_finish (GsdIdentityManager *identity_manager,
+                                                         GAsyncResult       *result,
+                                                         GError            **error);
+
+char      *gsd_identity_manager_name_identity    (GsdIdentityManager *identity_manager,
+                                                 GsdIdentity        *identity);
+
+G_END_DECLS
+
+#endif /* __GSD_IDENTITY_MANAGER_H__ */
diff --git a/plugins/identity/gsd-identity-plugin.c b/plugins/identity/gsd-identity-plugin.c
new file mode 100644
index 0000000..525bd15
--- /dev/null
+++ b/plugins/identity/gsd-identity-plugin.c
@@ -0,0 +1,224 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "gnome-settings-plugin.h"
+#include "gsd-identity-plugin.h"
+#include "gsd-identity-manager.h"
+#include "gsd-kerberos-identity-manager.h"
+
+struct GsdIdentityPluginPrivate {
+        GsdIdentityManager *identity_manager;
+
+        guint32             is_active : 1;
+};
+
+#define GSD_IDENTITY_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_IDENTITY_PLUGIN, GsdIdentityPluginPrivate))
+
+GNOME_SETTINGS_PLUGIN_REGISTER (GsdIdentityPlugin, gsd_identity_plugin);
+
+static void
+gsd_identity_plugin_init (GsdIdentityPlugin *self)
+{
+        self->priv = GSD_IDENTITY_PLUGIN_GET_PRIVATE (self);
+
+        g_debug ("GsdIdentityPlugin initializing");
+
+        self->priv->identity_manager = gsd_kerberos_identity_manager_new ();
+}
+
+static void
+gsd_identity_plugin_finalize (GObject *object)
+{
+        GsdIdentityPlugin *self;
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GSD_IS_IDENTITY_PLUGIN (object));
+
+        g_debug ("GsdIdentityPlugin finalizing");
+
+        self = GSD_IDENTITY_PLUGIN (object);
+
+        g_return_if_fail (self->priv != NULL);
+
+        if (self->priv->identity_manager != NULL) {
+                g_object_unref (self->priv->identity_manager);
+        }
+
+        G_OBJECT_CLASS (gsd_identity_plugin_parent_class)->finalize (object);
+}
+
+static void
+on_identity_added (GsdIdentityManager *manager,
+                   GsdIdentity        *identity,
+                   GsdIdentityPlugin  *self)
+{
+}
+
+static void
+on_identity_renewed (GsdIdentityManager *manager,
+                     GsdIdentity        *identity,
+                     GsdIdentityPlugin  *self)
+{
+}
+
+static void
+on_identity_removed (GsdIdentityManager *manager,
+                     GsdIdentity        *identity,
+                     GsdIdentityPlugin  *self)
+{
+}
+
+static void
+on_identity_expired (GsdIdentityManager *manager,
+                     GsdIdentity        *identity,
+                     GsdIdentityPlugin  *self)
+{
+}
+
+static void
+on_identity_renamed (GsdIdentityManager *manager,
+                     GsdIdentity        *identity,
+                     GsdIdentityPlugin  *self)
+{
+}
+
+static void
+on_identities_listed (GsdIdentityManager *manager,
+                      GAsyncResult       *result,
+                      GsdIdentityPlugin  *self)
+{
+        GList *identities, *node;
+        GError *error;
+
+        g_signal_connect (manager,
+                          "identity-added",
+                          G_CALLBACK (on_identity_added),
+                          self);
+
+        g_signal_connect (manager,
+                          "identity-removed",
+                          G_CALLBACK (on_identity_removed),
+                          self);
+
+        g_signal_connect (manager,
+                          "identity-expired",
+                          G_CALLBACK (on_identity_expired),
+                          self);
+
+        g_signal_connect (manager,
+                          "identity-renewed",
+                          G_CALLBACK (on_identity_renewed),
+                          self);
+        g_signal_connect (manager,
+                          "identity-renamed",
+                          G_CALLBACK (on_identity_renamed),
+                          self);
+
+        error = NULL;
+        identities = gsd_identity_manager_list_identities_finish (manager,
+                                                                  result,
+                                                                  &error);
+
+        if (identities == NULL) {
+                if (error != NULL) {
+                        g_warning ("GsdUserPanel: Could not list identities: %s",
+                                   error->message);
+                        g_error_free (error);
+                }
+
+                return;
+        }
+
+        node = identities;
+        while (node != NULL) {
+                GsdIdentity *identity = GSD_IDENTITY (node->data);
+
+                if (gsd_identity_is_signed_in (identity)) {
+                }
+
+                node = node->next;
+        }
+}
+
+static void
+impl_activate (GnomeSettingsPlugin *plugin)
+{
+        GsdIdentityPlugin *self = GSD_IDENTITY_PLUGIN (plugin);
+
+        if (self->priv->is_active) {
+                g_debug ("GsdIdentityPlugin Not activating identity plugin, because it's "
+                         "already active");
+                return;
+        }
+
+        g_debug ("GsdIdentityPlugin Activating identity plugin");
+
+        gsd_identity_manager_list_identities (self->priv->identity_manager,
+                                              NULL,
+                                              (GAsyncReadyCallback)
+                                              on_identities_listed,
+                                              self);
+
+        self->priv->is_active = TRUE;
+}
+
+static void
+impl_deactivate (GnomeSettingsPlugin *plugin)
+{
+        GsdIdentityPlugin *self = GSD_IDENTITY_PLUGIN (plugin);
+
+        if (!self->priv->is_active) {
+                g_debug ("GsdIdentityPlugin Not deactivating identity plugin, "
+                         "because it's already inactive");
+                return;
+        }
+
+        g_debug ("GsdIdentityPlugin Deactivating identity plugin");
+
+        self->priv->is_active = FALSE;
+}
+
+static void
+gsd_identity_plugin_class_init (GsdIdentityPluginClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
+
+        object_class->finalize = gsd_identity_plugin_finalize;
+
+        plugin_class->activate = impl_activate;
+        plugin_class->deactivate = impl_deactivate;
+
+        g_type_class_add_private (klass, sizeof (GsdIdentityPluginPrivate));
+}
+
+static void
+gsd_identity_plugin_class_finalize (GsdIdentityPluginClass *klass)
+{
+}
diff --git a/plugins/identity/gsd-identity-plugin.h b/plugins/identity/gsd-identity-plugin.h
new file mode 100644
index 0000000..ddfd9d4
--- /dev/null
+++ b/plugins/identity/gsd-identity-plugin.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef __GSD_IDENTITY_PLUGIN_H__
+#define __GSD_IDENTITY_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "gnome-settings-plugin.h"
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_IDENTITY_PLUGIN                (gsd_identity_plugin_get_type ())
+#define GSD_IDENTITY_PLUGIN(o)                  (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_IDENTITY_PLUGIN, GsdIdentityPlugin))
+#define GSD_IDENTITY_PLUGIN_CLASS(k)            (G_TYPE_CHECK_CLASS_CAST ((k), GSD_TYPE_IDENTITY_PLUGIN, GsdIdentityPluginClass))
+#define GSD_IS_IDENTITY_PLUGIN(o)               (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_IDENTITY_PLUGIN))
+#define GSD_IS_IDENTITY_PLUGIN_CLASS(k)         (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_IDENTITY_PLUGIN))
+#define GSD_IDENTITY_PLUGIN_GET_CLASS(o)        (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_IDENTITY_PLUGIN, GsdIdentityPluginClass))
+
+typedef struct GsdIdentityPluginPrivate GsdIdentityPluginPrivate;
+
+typedef struct
+{
+        GnomeSettingsPlugin parent;
+        GsdIdentityPluginPrivate *priv;
+} GsdIdentityPlugin;
+
+typedef struct
+{
+        GnomeSettingsPluginClass parent_class;
+} GsdIdentityPluginClass;
+
+GType gsd_identity_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GSD_IDENTITY_PLUGIN_H__ */
diff --git a/plugins/identity/gsd-identity.c b/plugins/identity/gsd-identity.c
new file mode 100644
index 0000000..2a03d37
--- /dev/null
+++ b/plugins/identity/gsd-identity.c
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include "gsd-identity.h"
+
+G_DEFINE_INTERFACE (GsdIdentity, gsd_identity, G_TYPE_OBJECT);
+
+static void
+gsd_identity_default_init (GsdIdentityInterface *interface)
+{
+}
+
+GQuark
+gsd_identity_error_quark (void)
+{
+        static GQuark error_quark = 0;
+
+        if (error_quark == 0) {
+                error_quark = g_quark_from_static_string ("gsd-identity-error");
+        }
+
+        return error_quark;
+}
+
+const char *
+gsd_identity_get_identifier (GsdIdentity *self)
+{
+        return GSD_IDENTITY_GET_IFACE (self)->get_identifier (self);
+}
+
+gboolean
+gsd_identity_is_signed_in (GsdIdentity *self)
+{
+        return GSD_IDENTITY_GET_IFACE (self)->is_signed_in (self);
+}
diff --git a/plugins/identity/gsd-identity.h b/plugins/identity/gsd-identity.h
new file mode 100644
index 0000000..d5c7e86
--- /dev/null
+++ b/plugins/identity/gsd-identity.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors: Ray Strode <rstrode redhat com>
+ */
+
+#ifndef __GSD_IDENTITY_H__
+#define __GSD_IDENTITY_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GSD_TYPE_IDENTITY             (gsd_identity_get_type ())
+#define GSD_IDENTITY(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_IDENTITY, GsdIdentity))
+#define GSD_IDENTITY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_IDENTITY, GsdIdentityInterface))
+#define GSD_IS_IDENTITY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSD_TYPE_IDENTITY))
+#define GSD_IDENTITY_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE((obj), GSD_TYPE_IDENTITY, GsdIdentityInterface))
+#define GSD_IDENTITY_ERROR            (gsd_identity_error_quark ())
+
+typedef struct _GsdIdentity          GsdIdentity;
+typedef struct _GsdIdentityInterface GsdIdentityInterface;
+typedef enum   _GsdIdentityError     GsdIdentityError;
+
+struct _GsdIdentityInterface
+{
+        GTypeInterface base_interface;
+
+        const char * (* get_identifier)  (GsdIdentity *identity);
+        gboolean     (* is_signed_in)    (GsdIdentity *identity);
+};
+
+enum _GsdIdentityError {
+        GSD_IDENTITY_ERROR_VERIFYING,
+        GSD_IDENTITY_ERROR_ERASING
+};
+
+GType       gsd_identity_get_type         (void);
+GQuark      gsd_identity_error_quark      (void);
+
+const char *gsd_identity_get_identifier   (GsdIdentity *identity);
+gboolean    gsd_identity_is_signed_in     (GsdIdentity *identity);
+
+G_END_DECLS
+
+#endif /* __GSD_IDENTITY_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]