[gnome-online-accounts/wip/modules: 13/13] kerberos: Split it into a loadable module



commit fe21ad712118880884beb6e58fadb83c6eb8c90b
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Apr 29 15:59:56 2014 +0200

    kerberos: Split it into a loadable module
    
    The markup comments for documentation have been removed because they
    were unused and useless.
    
    Fixes: https://bugzilla.gnome.org/729173

 src/daemon/goadaemon.c               |   19 ++++++++++----
 src/goabackend/Makefile.am           |   22 ++++++++++++++---
 src/goabackend/goakerberosmodule.c   |   43 ++++++++++++++++++++++++++++++++++
 src/goabackend/goakerberosprovider.c |   36 +++++++++++-----------------
 src/goabackend/goakerberosprovider.h |    5 ++-
 src/goabackend/goaprovider.c         |    7 -----
 6 files changed, 91 insertions(+), 41 deletions(-)
---
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index 94da46c..04baa3b 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -181,6 +181,7 @@ goa_daemon_init (GoaDaemon *daemon)
   gchar *path;
 #ifdef GOA_KERBEROS_ENABLED
   GError *error = NULL;
+  GoaProvider *provider;
 #endif
 
   /* this will force associating errors in the GOA_ERROR error domain
@@ -228,13 +229,19 @@ goa_daemon_init (GoaDaemon *daemon)
   g_dbus_object_manager_server_set_connection (daemon->object_manager, daemon->connection);
 
 #ifdef GOA_KERBEROS_ENABLED
-  daemon->identity_service = goa_identity_service_new ();
-  if (!goa_identity_service_activate (daemon->identity_service,
-                                      &error))
+  provider = goa_provider_get_for_provider_type ("kerberos");
+  if (provider != NULL)
     {
-      g_warning ("Error activating identity service: %s", error->message);
-      g_error_free (error);
-      g_clear_object (&daemon->identity_service);
+      daemon->identity_service = goa_identity_service_new ();
+      if (!goa_identity_service_activate (daemon->identity_service,
+                                          &error))
+        {
+          g_warning ("Error activating identity service: %s", error->message);
+          g_error_free (error);
+          g_clear_object (&daemon->identity_service);
+        }
+
+      g_object_unref (provider);
     }
 #endif
 }
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index d0f6274..5014998 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -204,8 +204,24 @@ libgoaimapsmtp_la_LDFLAGS = $(module_flags)
 endif
 
 if BUILD_KERBEROS
-libgoa_backend_1_0_la_SOURCES +=                                       \
-       goakerberosprovider.h           goakerberosprovider.c
+goamodule_LTLIBRARIES += libgoakerberos.la
+libgoakerberos_la_SOURCES =                                    \
+       goakerberosmodule.c                                     \
+       goakerberosprovider.c                                   \
+       goakerberosprovider.h                                   \
+       $(NULL)
+libgoakerberos_la_CFLAGS =                                     \
+       $(GCR_CFLAGS)                                           \
+       $(GLIB_CFLAGS)                                          \
+       $(GTK_CFLAGS)                                           \
+       $(NULL)
+libgoakerberos_la_LIBADD =                                     \
+       $(builddir)/libgoa-backend-1.0.la                       \
+       $(GCR_LIBS)                                             \
+       $(GLIB_LIBS)                                            \
+       $(GTK_LIBS)                                             \
+       $(NULL)
+libgoakerberos_la_LDFLAGS = $(module_flags)
 endif
 
 if BUILD_OWNCLOUD
@@ -307,7 +323,6 @@ endif
 libgoa_backend_1_0_la_CFLAGS =                                 \
        $(WEBKIT_GTK_CFLAGS)                                    \
        $(JSON_GLIB_CFLAGS)                                     \
-       $(GCR_CFLAGS)                                           \
        $(GLIB_CFLAGS)                                          \
        $(GTK_CFLAGS)                                           \
        $(REST_CFLAGS)                                          \
@@ -322,7 +337,6 @@ libgoa_backend_1_0_la_LIBADD =                                      \
        $(top_builddir)/src/goa/libgoa-1.0.la                   \
        $(WEBKIT_GTK_LIBS)                                      \
        $(JSON_GLIB_LIBS)                                       \
-       $(GCR_LIBS)                                             \
        $(GLIB_LIBS)                                            \
        $(GTK_LIBS)                                             \
        $(REST_LIBS)                                            \
diff --git a/src/goabackend/goakerberosmodule.c b/src/goabackend/goakerberosmodule.c
new file mode 100644
index 0000000..d143b30
--- /dev/null
+++ b/src/goabackend/goakerberosmodule.c
@@ -0,0 +1,43 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright (C) 2014 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+
+#include "goakerberosprovider.h"
+#include "goaprovider.h"
+#include "goaprovider-priv.h"
+
+void
+g_io_module_load (GIOModule *module)
+{
+  goa_kerberos_provider_register (module);
+}
+
+void
+g_io_module_unload (GIOModule *module)
+{
+}
+
+gchar **
+g_io_module_query (void)
+{
+  gchar *extension_points[] = {GOA_PROVIDER_EXTENSION_POINT_NAME, NULL};
+  return g_strdupv (extension_points);
+}
diff --git a/src/goabackend/goakerberosprovider.c b/src/goabackend/goakerberosprovider.c
index 7fe2229..3293cab 100644
--- a/src/goabackend/goakerberosprovider.c
+++ b/src/goabackend/goakerberosprovider.c
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /*
- * Copyright (C) 2012, 2013 Red Hat, Inc.
+ * Copyright (C) 2012, 2013, 2014 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -31,15 +31,8 @@
 
 #include "org.freedesktop.realmd.h"
 
-/**
- * GoaKerberosProvider:
- *
- * The #GoaKerberosProvider structure contains only private request and should
- * only be accessed using the provided API.
- */
 struct _GoaKerberosProvider
 {
-  /*< private >*/
   GoaProvider parent_instance;
   GoaIdentityServiceManager *identity_manager;
   GDBusObjectManager *object_manager;
@@ -52,20 +45,7 @@ struct _GoaKerberosProviderClass
   GoaProviderClass parent_class;
 };
 
-/**
- * SECTION:goakerberosprovider
- * @title: GoaKerberosProvider
- * @short_description: A provider for enterprise identity servers
- *
- * #GoaKerberosProvider is used to access enterprise identity servers.
- */
-
-G_DEFINE_TYPE_WITH_CODE (GoaKerberosProvider, goa_kerberos_provider, GOA_TYPE_PROVIDER,
-                         goa_provider_ensure_extension_points_registered ();
-                         g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME,
-                                                         g_define_type_id,
-                                                         "kerberos",
-                                                         0));
+G_DEFINE_DYNAMIC_TYPE (GoaKerberosProvider, goa_kerberos_provider, GOA_TYPE_PROVIDER);
 
 static const gchar *
 get_provider_type (GoaProvider *provider)
@@ -1916,6 +1896,11 @@ goa_kerberos_provider_init (GoaKerberosProvider *provider)
 }
 
 static void
+goa_kerberos_provider_class_finalize (GoaKerberosProviderClass *klass)
+{
+}
+
+static void
 goa_kerberos_provider_class_init (GoaKerberosProviderClass *kerberos_class)
 {
   GoaProviderClass *provider_class;
@@ -1931,3 +1916,10 @@ goa_kerberos_provider_class_init (GoaKerberosProviderClass *kerberos_class)
   provider_class->show_account               = show_account;
   provider_class->ensure_credentials_sync    = ensure_credentials_sync;
 }
+
+void
+goa_kerberos_provider_register (GIOModule *module)
+{
+  goa_kerberos_provider_register_type (G_TYPE_MODULE (module));
+  g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME, GOA_TYPE_KERBEROS_PROVIDER, "kerberos", 
0);
+}
diff --git a/src/goabackend/goakerberosprovider.h b/src/goabackend/goakerberosprovider.h
index 1254ee1..7240696 100644
--- a/src/goabackend/goakerberosprovider.h
+++ b/src/goabackend/goakerberosprovider.h
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012, 2014 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -23,7 +23,7 @@
 #ifndef __GOA_KERBEROS_PROVIDER_H__
 #define __GOA_KERBEROS_PROVIDER_H__
 
-#include <glib-object.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
 typedef struct _GoaKerberosProvider GoaKerberosProvider;
 
 GType goa_kerberos_provider_get_type (void) G_GNUC_CONST;
+void  goa_kerberos_provider_register (GIOModule *module);
 
 G_END_DECLS
 
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 25e5a4f..1b38a37 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -25,10 +25,6 @@
 #include "goaproviderfactory.h"
 #include "goatelepathyfactory.h"
 
-#ifdef GOA_KERBEROS_ENABLED
-#include "goakerberosprovider.h"
-#endif
-
 #include "goautils.h"
 
 /**
@@ -759,9 +755,6 @@ ensure_builtins_loaded (void)
        * important because it affects the order in which they are
        * returned by goa_provider_get_all.
        */
-#ifdef GOA_KERBEROS_ENABLED
-      type = GOA_TYPE_KERBEROS_PROVIDER;
-#endif
 #ifdef GOA_TELEPATHY_ENABLED
       type = GOA_TYPE_TELEPATHY_FACTORY;
 #endif


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