[gnome-control-center/wip/identity: 4/11] user-accounts: Add identity manager interface



commit 8c2329e409cb0c0bae74dc969a1ea5ba083223f0
Author: Ray Strode <rstrode redhat com>
Date:   Mon Feb 20 00:38:08 2012 -0500

    user-accounts: Add identity manager interface
    
    The page here:
    
    https://live.gnome.org/Design/Proposals/UserIdentities
    
    proposes adding a list of "accessible realms" to the user
    panel. To implement that we'll need to get a list of realms
    to show.
    
    This commit adds the basics of the required interface.  A
    subsequent commit will had a concrete implementation based
    on kerberos.  At some point, we may add an SSSD based
    implementation, too, which is why there's the abstraction.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=671156

 panels/user-accounts/Makefile.am                   |    4 +
 panels/user-accounts/um-identity-manager-private.h |   45 +++++
 panels/user-accounts/um-identity-manager.c         |  176 ++++++++++++++++++++
 panels/user-accounts/um-identity-manager.h         |  113 +++++++++++++
 panels/user-accounts/um-identity.c                 |   59 +++++++
 panels/user-accounts/um-identity.h                 |   63 +++++++
 6 files changed, 460 insertions(+), 0 deletions(-)
---
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index 13e86f9..db10d3d 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -30,6 +30,10 @@ BUILT_SOURCES = \
 libuser_accounts_la_SOURCES =		\
 	um-account-type.h		\
 	um-account-type.c 		\
+	um-identity-manager.h		\
+	um-identity-manager.c		\
+	um-identity.h			\
+	um-identity.c			\
 	um-user.h 			\
 	um-user.c 			\
 	um-user-manager.h 		\
diff --git a/panels/user-accounts/um-identity-manager-private.h b/panels/user-accounts/um-identity-manager-private.h
new file mode 100644
index 0000000..aba123c
--- /dev/null
+++ b/panels/user-accounts/um-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 __UM_IDENTITY_MANAGER_PRIVATE_H__
+#define __UM_IDENTITY_MANAGER_PRIVATE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "um-identity-manager.h"
+
+G_BEGIN_DECLS
+
+void      _um_identity_manager_emit_identity_added (UmIdentityManager *identity_manager,
+                                                    UmIdentity *identity);
+void      _um_identity_manager_emit_identity_removed (UmIdentityManager *identity_manager,
+                                                      UmIdentity *identity);
+void      _um_identity_manager_emit_identity_expired (UmIdentityManager *identity_manager,
+                                                      UmIdentity *identity);
+void      _um_identity_manager_emit_identity_renewed (UmIdentityManager *identity_manager,
+                                                      UmIdentity *identity);
+void      _um_identity_manager_emit_identity_renamed (UmIdentityManager *identity_manager,
+                                                      UmIdentity *identity);
+G_END_DECLS
+
+#endif /* __UM_IDENTITY_MANAGER_PRIVATE_H__ */
diff --git a/panels/user-accounts/um-identity-manager.c b/panels/user-accounts/um-identity-manager.c
new file mode 100644
index 0000000..8b8d9e0
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager.c
@@ -0,0 +1,176 @@
+/* -*- 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 "um-identity-manager.h"
+#include "um-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 (UmIdentityManager, um_identity_manager, G_TYPE_OBJECT);
+
+static void
+um_identity_manager_default_init (UmIdentityManagerInterface *interface)
+{
+      signals[IDENTITY_ADDED] = g_signal_new ("identity-added",
+                                              G_TYPE_FROM_INTERFACE (interface),
+                                              G_SIGNAL_RUN_LAST,
+                                              G_STRUCT_OFFSET (UmIdentityManagerInterface, identity_added),
+                                              NULL, NULL, NULL,
+                                              G_TYPE_NONE, 1, UM_TYPE_IDENTITY);
+      signals[IDENTITY_REMOVED] = g_signal_new ("identity-removed",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (UmIdentityManagerInterface, identity_removed),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, UM_TYPE_IDENTITY);
+      signals[IDENTITY_EXPIRED] = g_signal_new ("identity-expired",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (UmIdentityManagerInterface, identity_expired),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, UM_TYPE_IDENTITY);
+      signals[IDENTITY_RENEWED] = g_signal_new ("identity-renewed",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (UmIdentityManagerInterface, identity_renewed),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, UM_TYPE_IDENTITY);
+      signals[IDENTITY_RENAMED] = g_signal_new ("identity-renamed",
+                                                G_TYPE_FROM_INTERFACE (interface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (UmIdentityManagerInterface, identity_renamed),
+                                                NULL, NULL, NULL,
+                                                G_TYPE_NONE, 1, UM_TYPE_IDENTITY);
+}
+
+GQuark
+um_identity_manager_error_quark (void)
+{
+        static GQuark error_quark = 0;
+
+        if (error_quark == 0) {
+                error_quark = g_quark_from_static_string ("um-identity-manager-error");
+        }
+
+        return error_quark;
+}
+
+void
+um_identity_manager_list_identities (UmIdentityManager   *self,
+                                     GCancellable        *cancellable,
+                                     GAsyncReadyCallback  callback,
+                                     gpointer             user_data)
+{
+        g_return_if_fail (UM_IDENTITY_MANAGER_GET_IFACE (self)->list_identities);
+        UM_IDENTITY_MANAGER_GET_IFACE (self)->list_identities (self,
+                                                               cancellable,
+                                                               callback,
+                                                               user_data);
+}
+
+GList *
+um_identity_manager_list_identities_finish (UmIdentityManager  *self,
+                                            GAsyncResult       *result,
+                                            GError            **error)
+{
+        g_return_val_if_fail (UM_IDENTITY_MANAGER_GET_IFACE (self)->list_identities_finish, NULL);
+        return UM_IDENTITY_MANAGER_GET_IFACE (self)->list_identities_finish (self,
+                                                                             result,
+                                                                             error);
+}
+
+void
+um_identity_manager_sign_identity_out (UmIdentityManager   *self,
+                                       UmIdentity          *identity,
+                                       GCancellable        *cancellable,
+                                       GAsyncReadyCallback  callback,
+                                       gpointer             user_data)
+{
+        g_return_if_fail (UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out);
+        UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out (self, identity, cancellable, callback, user_data);
+}
+
+void
+um_identity_manager_sign_identity_out_finish (UmIdentityManager  *self,
+                                              GAsyncResult       *result,
+                                              GError            **error)
+{
+        g_return_if_fail (UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out_finish);
+        UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out_finish (self, result, error);
+}
+
+char *
+um_identity_manager_name_identity (UmIdentityManager *self,
+                                   UmIdentity        *identity)
+{
+        g_return_val_if_fail (UM_IDENTITY_MANAGER_GET_IFACE (self)->name_identity, NULL);
+        return UM_IDENTITY_MANAGER_GET_IFACE (self)->name_identity (self,
+                                                                    identity);
+}
+
+void
+_um_identity_manager_emit_identity_added (UmIdentityManager *self,
+                                          UmIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_ADDED], 0, identity);
+}
+
+void
+_um_identity_manager_emit_identity_removed (UmIdentityManager *self,
+                                            UmIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_REMOVED], 0, identity);
+}
+
+void
+_um_identity_manager_emit_identity_expired (UmIdentityManager *self,
+                                            UmIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_EXPIRED], 0, identity);
+}
+
+void
+_um_identity_manager_emit_identity_renewed (UmIdentityManager *self,
+                                            UmIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_RENEWED], 0, identity);
+}
+
+void
+_um_identity_manager_emit_identity_renamed (UmIdentityManager *self,
+                                            UmIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_RENAMED], 0, identity);
+}
diff --git a/panels/user-accounts/um-identity-manager.h b/panels/user-accounts/um-identity-manager.h
new file mode 100644
index 0000000..1a47b68
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager.h
@@ -0,0 +1,113 @@
+/* -*- 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 __UM_IDENTITY_MANAGER_H__
+#define __UM_IDENTITY_MANAGER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include "um-identity.h"
+
+G_BEGIN_DECLS
+
+#define UM_TYPE_IDENTITY_MANAGER             (um_identity_manager_get_type ())
+#define UM_IDENTITY_MANAGER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), UM_TYPE_IDENTITY_MANAGER, UmIdentityManager))
+#define UM_IDENTITY_MANAGER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), UM_TYPE_IDENTITY_MANAGER, UmIdentityManagerInterface))
+#define UM_IS_IDENTITY_MANAGER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UM_TYPE_IDENTITY_MANAGER))
+#define UM_IDENTITY_MANAGER_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE((obj), UM_TYPE_IDENTITY_MANAGER, UmIdentityManagerInterface))
+#define UM_IDENTITY_MANAGER_ERROR            (um_identity_manager_error_quark ())
+
+typedef struct _UmIdentityManager          UmIdentityManager;
+typedef struct _UmIdentityManagerInterface UmIdentityManagerInterface;
+typedef enum   _UmIdentityManagerError     UmIdentityManagerError;
+
+struct _UmIdentityManagerInterface
+{
+        GTypeInterface base_interface;
+
+        /* Signals */
+        void      (* identity_added)    (UmIdentityManager *identity_manager,
+                                         UmIdentity        *identity);
+
+        void      (* identity_removed)  (UmIdentityManager *identity_manager,
+                                         UmIdentity        *identity);
+        void      (* identity_expired)  (UmIdentityManager *identity_manager,
+                                         UmIdentity        *identity);
+        void      (* identity_renewed)  (UmIdentityManager *identity_manager,
+                                         UmIdentity        *identity);
+        void      (* identity_renamed)  (UmIdentityManager *identity_manager,
+                                         UmIdentity        *identity);
+
+        /* Virtual Functions */
+        void      (* list_identities)        (UmIdentityManager   *identity_manager,
+                                              GCancellable        *cancellable,
+                                              GAsyncReadyCallback  callback,
+                                              gpointer             user_data);
+        GList *   (* list_identities_finish) (UmIdentityManager  *identity_manager,
+                                              GAsyncResult       *result,
+                                              GError            **error);
+
+        void      (* sign_identity_out)  (UmIdentityManager   *identity_manager,
+                                          UmIdentity          *identity,
+                                          GCancellable        *cancellable,
+                                          GAsyncReadyCallback  callback,
+                                          gpointer             user_data);
+        void      (* sign_identity_out_finish)  (UmIdentityManager  *identity_manager,
+                                                 GAsyncResult       *result,
+                                                 GError            **error);
+
+        char  *   (* name_identity)      (UmIdentityManager *identity_manager,
+                                          UmIdentity        *identity);
+};
+
+enum _UmIdentityManagerError {
+        UM_IDENTITY_MANAGER_ERROR_INITIALIZING,
+        UM_IDENTITY_MANAGER_ERROR_MONITORING,
+        UM_IDENTITY_MANAGER_ERROR_SIGNING_OUT
+};
+
+GType      um_identity_manager_get_type         (void);
+GQuark     um_identity_manager_error_quark      (void);
+
+void       um_identity_manager_list_identities  (UmIdentityManager   *identity_manager,
+                                                 GCancellable        *cancellable,
+                                                 GAsyncReadyCallback  callback,
+                                                 gpointer             user_data);
+GList *    um_identity_manager_list_identities_finish  (UmIdentityManager  *identity_manager,
+                                                        GAsyncResult       *result,
+                                                        GError            **error);
+void       um_identity_manager_sign_identity_out    (UmIdentityManager   *identity_manager,
+                                                     UmIdentity          *identity,
+                                                     GCancellable        *cancellable,
+                                                     GAsyncReadyCallback  callback,
+                                                     gpointer             user_data);
+void       um_identity_manager_sign_identity_out_finish (UmIdentityManager *identity_manager,
+                                                         GAsyncResult       *result,
+                                                         GError            **error);
+char      *um_identity_manager_name_identity    (UmIdentityManager *identity_manager,
+                                                 UmIdentity        *identity);
+
+G_END_DECLS
+
+#endif /* __UM_IDENTITY_MANAGER_H__ */
diff --git a/panels/user-accounts/um-identity.c b/panels/user-accounts/um-identity.c
new file mode 100644
index 0000000..abd0107
--- /dev/null
+++ b/panels/user-accounts/um-identity.c
@@ -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.
+ */
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include "um-identity.h"
+
+G_DEFINE_INTERFACE (UmIdentity, um_identity, G_TYPE_OBJECT);
+
+static void
+um_identity_default_init (UmIdentityInterface *interface)
+{
+}
+
+GQuark
+um_identity_error_quark (void)
+{
+        static GQuark error_quark = 0;
+
+        if (error_quark == 0) {
+                error_quark = g_quark_from_static_string ("um-identity-error");
+        }
+
+        return error_quark;
+}
+
+const char *
+um_identity_get_identifier (UmIdentity *self)
+{
+        g_return_val_if_fail (UM_IDENTITY_GET_IFACE (self)->get_identifier, NULL);
+        return UM_IDENTITY_GET_IFACE (self)->get_identifier (self);
+}
+
+gboolean
+um_identity_is_signed_in (UmIdentity *self)
+{
+        g_return_val_if_fail (UM_IDENTITY_GET_IFACE (self)->is_signed_in, FALSE);
+        return UM_IDENTITY_GET_IFACE (self)->is_signed_in (self);
+}
diff --git a/panels/user-accounts/um-identity.h b/panels/user-accounts/um-identity.h
new file mode 100644
index 0000000..0a40775
--- /dev/null
+++ b/panels/user-accounts/um-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 __UM_IDENTITY_H__
+#define __UM_IDENTITY_H__
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define UM_TYPE_IDENTITY             (um_identity_get_type ())
+#define UM_IDENTITY(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), UM_TYPE_IDENTITY, UmIdentity))
+#define UM_IDENTITY_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), UM_TYPE_IDENTITY, UmIdentityInterface))
+#define UM_IS_IDENTITY(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), UM_TYPE_IDENTITY))
+#define UM_IDENTITY_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE((obj), UM_TYPE_IDENTITY, UmIdentityInterface))
+#define UM_IDENTITY_ERROR            (um_identity_error_quark ())
+
+typedef struct _UmIdentity          UmIdentity;
+typedef struct _UmIdentityInterface UmIdentityInterface;
+typedef enum   _UmIdentityError     UmIdentityError;
+
+struct _UmIdentityInterface
+{
+        GTypeInterface base_interface;
+
+        const char * (* get_identifier)  (UmIdentity *identity);
+        gboolean     (* is_signed_in)    (UmIdentity *identity);
+};
+
+enum _UmIdentityError {
+        UM_IDENTITY_ERROR_VERIFYING,
+        UM_IDENTITY_ERROR_ERASING
+};
+
+GType       um_identity_get_type         (void);
+GQuark      um_identity_error_quark      (void);
+
+const char *um_identity_get_identifier   (UmIdentity *identity);
+gboolean    um_identity_is_signed_in     (UmIdentity *identity);
+
+G_END_DECLS
+
+#endif /* __UM_IDENTITY_H__ */



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