[gnome-control-center/wip/user-identities: 2/3] users: Add rough outline of identity manager interface



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

    users: Add rough outline of identity manager interface

 panels/user-accounts/Makefile.am                   |    4 +
 panels/user-accounts/um-identity-manager-private.h |   39 ++++++
 panels/user-accounts/um-identity-manager.c         |  124 ++++++++++++++++++++
 panels/user-accounts/um-identity-manager.h         |   96 +++++++++++++++
 panels/user-accounts/um-identity.c                 |   59 +++++++++
 panels/user-accounts/um-identity.h                 |   56 +++++++++
 6 files changed, 378 insertions(+), 0 deletions(-)
---
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index 1bf2932..f517bb2 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -32,6 +32,10 @@ marshal.c: fprintd-marshal.list
 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..b3bd88d
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager-private.h
@@ -0,0 +1,39 @@
+/* -*- 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);
+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..d1469ff
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager.c
@@ -0,0 +1,124 @@
+/* -*- 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-manager.h"
+#include "um-identity-manager-private.h"
+
+enum {
+        IDENTITY_ADDED,
+        IDENTITY_REMOVED,
+        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 *iface)
+{
+      signals[IDENTITY_ADDED] = g_signal_new ("interface-removed",
+                                              G_TYPE_FROM_INTERFACE (iface),
+                                              G_SIGNAL_RUN_LAST,
+                                              G_STRUCT_OFFSET (GDBusObjectIface, interface_removed),
+                                              NULL, NULL, NULL,
+                                              G_TYPE_NONE, 1, UM_TYPE_IDENTITY);
+      signals[IDENTITY_REMOVED] = g_signal_new ("interface-removed",
+                                                G_TYPE_FROM_INTERFACE (iface),
+                                                G_SIGNAL_RUN_LAST,
+                                                G_STRUCT_OFFSET (GDBusObjectIface, interface_removed),
+                                                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)
+{
+        UM_IDENTITY_MANAGER_GET_IFACE (identity_manager)->list_identities (self,
+                                                                           cancellable,
+                                                                           callback);
+}
+
+void
+um_identity_manager_list_identities_finish (UmIdentityManager *identity_manager,
+                                            GAsyncResult       *result,
+                                            GError            **error)
+{
+        UM_IDENTITY_MANAGER_GET_IFACE (identity_manager)->list_identities_finish (self, result error);
+}
+
+void
+um_identity_manager_sign_identity_out (UmIdentityManager *self,
+                                       UmIdentity          *identity,
+                                       GCancellable        *cancellable,
+                                       GAsyncReadyCallback  callback);
+{
+        UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out (self, identity);
+}
+
+void
+um_identity_manager_sign_identity_out_finish (UmIdentityManager  *self,
+                                              GAsyncResult       *result,
+                                              GError            **error);
+{
+        UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out (self, result, error);
+}
+
+char *
+um_identity_manager_name_identity (UmIdentityManager *self,
+                                   UmIdentity        *identity)
+{
+        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);
+}
+
diff --git a/panels/user-accounts/um-identity-manager.h b/panels/user-accounts/um-identity-manager.h
new file mode 100644
index 0000000..733917a
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager.h
@@ -0,0 +1,96 @@
+/* -*- 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 "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);
+
+        /* Virtual Functions */
+        void      (* list_identities)        (UmIdentityManager   *identity_manager,
+                                              GCancellable        *cancellable,
+                                              GAsyncReadyCallback  callback);
+        void      (* list_identities_finish) (UmIdentityManager  *identity_manager,
+                                              GAsyncResult       *result,
+                                              GError            **error);
+
+        void      (* sign_identity_out)  (UmIdentityManager   *identity_manager,
+                                          UmIdentity          *identity,
+                                          GCancellable        *cancellable,
+                                          GAsyncReadyCallback  callback);
+        void      (* sign_identity_out_finish)  (UmIdentityManager  *identity_manager,
+                                                 GAsyncResult       *result,
+                                                 GError            **error);
+
+        char  *   (* name_identity)      (UmIdentityManager *identity_manager,
+                                          UmIdentity        *identity);
+};
+
+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);
+void       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);
+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..2046d0c
--- /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"
+#include "um-consolekit.h"
+#include "um-identityd.h"
+
+enum {
+        LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_INTERFACE (UmIdentity, um_identity, G_TYPE_OBJECT);
+
+static void
+um_identity_default_init (UmIdentityInterface *iface)
+{
+}
+
+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;
+}
+
+GList *
+um_identity_get_identifier (UmIdentity *self)
+{
+        return UM_IDENTITY_GET_IFACE (identity)->get_identifier (self);
+}
diff --git a/panels/user-accounts/um-identity.h b/panels/user-accounts/um-identity.h
new file mode 100644
index 0000000..0509d47
--- /dev/null
+++ b/panels/user-accounts/um-identity.h
@@ -0,0 +1,56 @@
+/* -*- 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);
+};
+
+GType       um_identity_get_type         (void);
+GQuark      um_identity_error_quark      (void);
+
+const char *um_identity_get_identifier  (UmIdentity *identity);
+
+G_END_DECLS
+
+#endif /* __UM_IDENTITY_H__ */



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