[gnome-online-accounts/wip/modules: 11/12] imap-smtp: Split it into a loadable module



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

    imap-smtp: 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

 configure.ac                         |    1 +
 src/goabackend/Makefile.am           |   20 +++++++++++++++-
 src/goabackend/goaimapsmtpmodule.c   |   43 ++++++++++++++++++++++++++++++++++
 src/goabackend/goaimapsmtpprovider.c |   36 ++++++++++++----------------
 src/goabackend/goaimapsmtpprovider.h |    5 ++-
 src/goabackend/goaprovider.c         |    4 ---
 6 files changed, 81 insertions(+), 28 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 5176176..1f9e8cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,6 +228,7 @@ AC_ARG_ENABLE([imap-smtp],
 if test "$enable_imap_smtp" != "no"; then
   AC_DEFINE(GOA_IMAP_SMTP_ENABLED, 1, [Enable IMAP/SMTP data provider])
 fi
+AM_CONDITIONAL(BUILD_IMAP_SMTP, [test x$enable_imap_smtp != xno])
 
 # ownCloud
 AC_ARG_ENABLE([owncloud],
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index 9fa13b6..cb5faa0 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -81,7 +81,6 @@ libgoa_backend_1_0_la_SOURCES =                                               \
        goamailclient.h                 goamailclient.c                 \
        goaoauthprovider.h              goaoauthprovider.c              \
        goaoauth2provider.h             goaoauth2provider.c             \
-       goaimapsmtpprovider.h           goaimapsmtpprovider.c           \
        goayahooprovider.h              goayahooprovider.c              \
        goatelepathyfactory.h           goatelepathyfactory.c           \
        goatelepathyprovider.h          goatelepathyprovider.c          \
@@ -186,6 +185,25 @@ libgoagoogle_la_LIBADD =                                   \
 libgoagoogle_la_LDFLAGS = $(module_flags)
 endif
 
+if BUILD_IMAP_SMTP
+goamodule_LTLIBRARIES += libgoaimapsmtp.la
+libgoaimapsmtp_la_SOURCES =                                    \
+       goaimapsmtpmodule.c                                     \
+       goaimapsmtpprovider.c                                   \
+       goaimapsmtpprovider.h                                   \
+       $(NULL)
+libgoaimapsmtp_la_CFLAGS =                                     \
+       $(GLIB_CFLAGS)                                          \
+       $(GTK_CFLAGS)                                           \
+       $(NULL)
+libgoaimapsmtp_la_LIBADD =                                     \
+       $(builddir)/libgoa-backend-1.0.la                       \
+       $(GLIB_LIBS)                                            \
+       $(GTK_LIBS)                                             \
+       $(NULL)
+libgoaimapsmtp_la_LDFLAGS = $(module_flags)
+endif
+
 if BUILD_KERBEROS
 libgoa_backend_1_0_la_SOURCES +=                                       \
        goakerberosprovider.h           goakerberosprovider.c
diff --git a/src/goabackend/goaimapsmtpmodule.c b/src/goabackend/goaimapsmtpmodule.c
new file mode 100644
index 0000000..73284ce
--- /dev/null
+++ b/src/goabackend/goaimapsmtpmodule.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 "goaimapsmtpprovider.h"
+#include "goaprovider.h"
+#include "goaprovider-priv.h"
+
+void
+g_io_module_load (GIOModule *module)
+{
+  goa_imap_smtp_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/goaimapsmtpprovider.c b/src/goabackend/goaimapsmtpprovider.c
index 4a6a025..905e6e3 100644
--- a/src/goabackend/goaimapsmtpprovider.c
+++ b/src/goabackend/goaimapsmtpprovider.c
@@ -28,15 +28,8 @@
 #include "goasmtpauth.h"
 #include "goautils.h"
 
-/**
- * GoaImapSmtpProvider:
- *
- * The #GoaImapSmtpProvider structure contains only private data and should
- * only be accessed using the provided API.
- */
 struct _GoaImapSmtpProvider
 {
-  /*< private >*/
   GoaProvider parent_instance;
 };
 
@@ -47,20 +40,7 @@ struct _GoaImapSmtpProviderClass
   GoaProviderClass parent_class;
 };
 
-/**
- * SECTION:goaimapsmtpprovider
- * @title: GoaImapSmtpProvider
- * @short_description: A provider for IMAP and SMTP servers
- *
- * #GoaImapSmtpProvider is used to access IMAP and SMTP mail servers.
- */
-
-G_DEFINE_TYPE_WITH_CODE (GoaImapSmtpProvider, goa_imap_smtp_provider, GOA_TYPE_PROVIDER,
-                         goa_provider_ensure_extension_points_registered ();
-                         g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME,
-                                                        g_define_type_id,
-                                                        "imap_smtp",
-                                                        0));
+G_DEFINE_DYNAMIC_TYPE (GoaImapSmtpProvider, goa_imap_smtp_provider, GOA_TYPE_PROVIDER);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
@@ -1585,6 +1565,11 @@ goa_imap_smtp_provider_init (GoaImapSmtpProvider *provider)
 }
 
 static void
+goa_imap_smtp_provider_class_finalize (GoaImapSmtpProviderClass *klass)
+{
+}
+
+static void
 goa_imap_smtp_provider_class_init (GoaImapSmtpProviderClass *klass)
 {
   GoaProviderClass *provider_class;
@@ -1661,3 +1646,12 @@ on_handle_get_password (GoaPasswordBased      *interface,
   g_object_unref (provider);
   return TRUE; /* invocation was handled */
 }
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+void
+goa_imap_smtp_provider_register (GIOModule *module)
+{
+  goa_imap_smtp_provider_register_type (G_TYPE_MODULE (module));
+  g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME, GOA_TYPE_IMAP_SMTP_PROVIDER, 
"imap_smtp", 0);
+}
diff --git a/src/goabackend/goaimapsmtpprovider.h b/src/goabackend/goaimapsmtpprovider.h
index 3da5da2..17555f1 100644
--- a/src/goabackend/goaimapsmtpprovider.h
+++ b/src/goabackend/goaimapsmtpprovider.h
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /*
- * Copyright (C) 2011, 2013 Red Hat, Inc.
+ * Copyright (C) 2011, 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
@@ -23,7 +23,7 @@
 #ifndef __GOA_IMAP_SMTP_PROVIDER_H__
 #define __GOA_IMAP_SMTP_PROVIDER_H__
 
-#include <glib-object.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
 typedef struct _GoaImapSmtpProvider GoaImapSmtpProvider;
 
 GType goa_imap_smtp_provider_get_type (void) G_GNUC_CONST;
+void  goa_imap_smtp_provider_register (GIOModule *module);
 
 G_END_DECLS
 
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 1b643fb..6402348 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -23,7 +23,6 @@
 #include "goaprovider.h"
 #include "goaprovider-priv.h"
 #include "goaproviderfactory.h"
-#include "goaimapsmtpprovider.h"
 #include "goayahooprovider.h"
 #include "goatelepathyfactory.h"
 
@@ -761,9 +760,6 @@ ensure_builtins_loaded (void)
        * important because it affects the order in which they are
        * returned by goa_provider_get_all.
        */
-#ifdef GOA_IMAP_SMTP_ENABLED
-      type = GOA_TYPE_IMAP_SMTP_PROVIDER;
-#endif
 #ifdef GOA_KERBEROS_ENABLED
       type = GOA_TYPE_KERBEROS_PROVIDER;
 #endif


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