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



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

    wip: users: Add rough outline of identity manager interface

 panels/user-accounts/Makefile.am                   |    4 +
 panels/user-accounts/data/user-accounts-dialog.ui  |   39 +++++-
 panels/user-accounts/um-identity-manager-private.h |   41 ++++++
 panels/user-accounts/um-identity-manager.c         |  143 +++++++++++++++++++
 panels/user-accounts/um-identity-manager.h         |  109 ++++++++++++++
 panels/user-accounts/um-identity.c                 |   57 ++++++++
 panels/user-accounts/um-identity.h                 |   58 ++++++++
 panels/user-accounts/um-user-panel.c               |  150 +++++++++++++++++++-
 8 files changed, 596 insertions(+), 5 deletions(-)
---
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index 2907f01..ce52837 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -25,6 +25,10 @@ endif
 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/data/user-accounts-dialog.ui b/panels/user-accounts/data/user-accounts-dialog.ui
index b4a5cc8..af48148 100644
--- a/panels/user-accounts/data/user-accounts-dialog.ui
+++ b/panels/user-accounts/data/user-accounts-dialog.ui
@@ -274,6 +274,37 @@
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkLabel" id="accessible-realms-label">
+                            <property name="visible">False</property>
+                            <property name="xalign">1</property>
+                            <property name="label" translatable="yes">Accessible Realms</property>
+                            <style>
+                              <class name="dim-label"/>
+                            </style>
+                          </object>
+                          <packing>
+                            <property name="top_attach">6</property>
+                            <property name="bottom_attach">7</property>
+                            <property name="x_options">GTK_FILL</property>
+                            <property name="y_options">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="accessible-realms-vbox">
+                            <property name="visible">False</property>
+                            <child>
+                              <placeholder/>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="right_attach">2</property>
+                            <property name="top_attach">6</property>
+                            <property name="bottom_attach">7</property>
+                            <property name="y_options">0</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkLabel" id="autologin-label">
                             <property name="visible">True</property>
                             <property name="xalign">1</property>
@@ -285,8 +316,8 @@
                             </style>
                           </object>
                           <packing>
-                            <property name="top_attach">5</property>
-                            <property name="bottom_attach">6</property>
+                            <property name="top_attach">7</property>
+                            <property name="bottom_attach">8</property>
                             <property name="x_options">GTK_FILL</property>
                             <property name="y_options">0</property>
                           </packing>
@@ -311,8 +342,8 @@
                           <packing>
                             <property name="left_attach">1</property>
                             <property name="right_attach">2</property>
-                            <property name="top_attach">5</property>
-                            <property name="bottom_attach">6</property>
+                            <property name="top_attach">7</property>
+                            <property name="bottom_attach">8</property>
                             <property name="y_options">0</property>
                           </packing>
                         </child>
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..3a3ac03
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager-private.h
@@ -0,0 +1,41 @@
+/* -*- 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);
+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..22e28c5
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager.c
@@ -0,0 +1,143 @@
+/* -*- 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,
+        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);
+}
+
+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)
+{
+        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)
+{
+        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)
+{
+        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)
+{
+        UM_IDENTITY_MANAGER_GET_IFACE (self)->sign_identity_out_finish (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);
+}
+
+void
+_um_identity_manager_emit_identity_expired (UmIdentityManager *self,
+                                            UmIdentity        *identity)
+{
+        g_signal_emit (G_OBJECT (self), signals[IDENTITY_EXPIRED], 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..5f34a16
--- /dev/null
+++ b/panels/user-accounts/um-identity-manager.h
@@ -0,0 +1,109 @@
+/* -*- 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);
+
+        /* 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..e8e250b
--- /dev/null
+++ b/panels/user-accounts/um-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 "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)
+{
+        return UM_IDENTITY_GET_IFACE (self)->get_identifier (self);
+}
+
+gboolean
+um_identity_is_signed_in (UmIdentity *self)
+{
+        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..3e44d8c
--- /dev/null
+++ b/panels/user-accounts/um-identity.h
@@ -0,0 +1,58 @@
+/* -*- 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);
+};
+
+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__ */
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index c4777ab..a53c0b6 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -41,8 +41,11 @@
 
 #include "um-user.h"
 #include "um-user-manager.h"
+#include "um-identity-manager.h"
+#include "um-kerberos-identity-manager.h"
 
 #include "cc-strength-bar.h"
+
 #include "um-editable-button.h"
 #include "um-editable-combo.h"
 
@@ -68,6 +71,7 @@ struct _UmUserPanelPrivate {
         GPermission *permission;
         GtkWidget *language_chooser;
 
+        UmIdentityManager *identity_manager;
         UmAccountDialog *account_dialog;
         UmPasswordDialog *password_dialog;
         UmPhotoDialog *photo_dialog;
@@ -1232,6 +1236,150 @@ setup_main_window (UmUserPanelPrivate *d)
 }
 
 static void
+add_accessible_realm_for_identity (UmUserPanelPrivate *d,
+                                   UmIdentity         *identity)
+{
+        GtkWidget *hbox;
+        char *name;
+        GtkWidget *label, *button;
+        GtkWidget *vbox;
+
+        hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        name = um_identity_manager_name_identity (d->identity_manager,
+                                                  identity);
+        label = gtk_label_new (name);
+        g_free (name);
+        gtk_container_add (GTK_CONTAINER (hbox), label);
+
+        button = gtk_button_new_with_label (_("Sign Out"));
+        gtk_container_add (GTK_CONTAINER (hbox), button);
+        gtk_widget_show_all (hbox);
+
+        g_object_set_data (G_OBJECT (identity),
+                           "accessible-realm-hbox",
+                           hbox);
+
+        vbox = get_widget (d, "accessible-realms-vbox");
+
+        gtk_container_add (GTK_CONTAINER (vbox), hbox);
+        gtk_widget_show (vbox);
+
+        label = get_widget (d, "accessible-realms-label");
+        gtk_widget_show (label);
+}
+
+static void
+remove_accessible_realm_for_identity (UmUserPanelPrivate *d,
+                                      UmIdentity         *identity)
+{
+        GtkWidget *hbox;
+        GtkWidget *vbox;
+
+        hbox = g_object_get_data (G_OBJECT (identity),
+                                 "accessible-realm-hbox");
+
+        if (hbox != NULL) {
+                g_assert (GTK_IS_WIDGET (hbox));
+
+                gtk_widget_destroy (hbox);
+        }
+
+        vbox = get_widget (d, "accessible-realms-vbox");
+
+        if (vbox != NULL) {
+                GList *children;
+
+                children = gtk_container_get_children (GTK_CONTAINER (vbox));
+
+                if (children == NULL) {
+                        GtkWidget *label;
+
+                        gtk_widget_hide (vbox);
+                        label = get_widget (d, "accessible-realms-label");
+                        gtk_widget_hide (label);
+                } else {
+                        g_list_free (children);
+
+                }
+        }
+}
+
+static void
+on_identity_added (UmIdentityManager *manager,
+                   UmIdentity        *identity,
+                   gpointer           user_data)
+{
+        UmUserPanelPrivate *d = user_data;
+
+        add_accessible_realm_for_identity (d, identity);
+}
+
+static void
+on_identity_removed (UmIdentityManager *manager,
+                     UmIdentity        *identity,
+                     gpointer           user_data)
+{
+        UmUserPanelPrivate *d = user_data;
+
+        remove_accessible_realm_for_identity (d, identity);
+}
+
+static void
+on_identities_listed (UmIdentityManager *manager,
+                      GAsyncResult      *result,
+                      gpointer           user_data)
+{
+        UmUserPanelPrivate *d = user_data;
+        GError *error = NULL;
+        GList *identities, *node;
+
+        g_signal_connect (manager,
+                          "identity-added",
+                          G_CALLBACK (on_identity_added),
+                          d);
+
+        g_signal_connect (manager,
+                          "identity-removed",
+                          G_CALLBACK (on_identity_removed),
+                          d);
+
+        identities = um_identity_manager_list_identities_finish (manager,
+                                                                 result,
+                                                                 &error);
+
+        if (identities == NULL) {
+                if (error != NULL) {
+                        g_warning ("UmUserPanel: Could not list identities: %s",
+                                   error->message);
+                        g_error_free (error);
+                }
+
+                gtk_widget_hide (get_widget (d, "accessible-realms-vbox"));
+                return;
+        }
+
+        node = identities;
+        while (node != NULL) {
+                UmIdentity *identity = UM_IDENTITY (node->data);
+
+                add_accessible_realm_for_identity (d, identity);
+
+                node = node->next;
+        }
+}
+
+static void
+setup_identity_manager (UmUserPanelPrivate *d)
+{
+        d->identity_manager = um_kerberos_identity_manager_new ();
+        um_identity_manager_list_identities (d->identity_manager,
+                                             NULL,
+                                             (GAsyncReadyCallback)
+                                             on_identities_listed,
+                                             d);
+}
+
+static void
 um_user_panel_init (UmUserPanel *self)
 {
         UmUserPanelPrivate *d;
@@ -1264,7 +1412,7 @@ um_user_panel_init (UmUserPanel *self)
                 g_error_free (error);
                 return;
         }
-
+        setup_identity_manager (d);
         setup_main_window (d);
         d->account_dialog = um_account_dialog_new ();
         d->password_dialog = um_password_dialog_new ();



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