[gnome-online-accounts/wip/modules: 6/12] pocket: Split it into a loadable module



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

    pocket: 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         |   26 +++++++++++++++++++++-
 src/goabackend/goapocketmodule.c   |   43 ++++++++++++++++++++++++++++++++++++
 src/goabackend/goapocketprovider.c |   36 +++++++++++------------------
 src/goabackend/goapocketprovider.h |    5 ++-
 src/goabackend/goaprovider.c       |    4 ---
 6 files changed, 86 insertions(+), 29 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 455bea1..2d26ff1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -336,6 +336,7 @@ AC_DEFINE_UNQUOTED(GOA_POCKET_CLIENT_ID,
 if test "$enable_pocket" != "no"; then
   AC_DEFINE(GOA_POCKET_ENABLED, 1, [Enable Pocket data provider])
 fi
+AM_CONDITIONAL(BUILD_POCKET, [test x$enable_pocket != xno])
 
 # Kerberos
 AC_ARG_ENABLE([kerberos],
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index 2485a0e..c1601aa 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -87,7 +87,6 @@ libgoa_backend_1_0_la_SOURCES =                                               \
        goayahooprovider.h              goayahooprovider.c              \
        goatelepathyfactory.h           goatelepathyfactory.c           \
        goatelepathyprovider.h          goatelepathyprovider.c          \
-       goapocketprovider.h             goapocketprovider.c             \
        goautils.h                      goautils.c                      \
        goawebview.h                    goawebview.c                    \
        nautilus-floating-bar.h         nautilus-floating-bar.c         \
@@ -175,6 +174,31 @@ libgoa_backend_1_0_la_SOURCES +=                                   \
        goakerberosprovider.h           goakerberosprovider.c
 endif
 
+if BUILD_POCKET
+goamodule_LTLIBRARIES += libgoapocket.la
+libgoapocket_la_SOURCES =                                      \
+       goapocketmodule.c                                       \
+       goapocketprovider.c                                     \
+       goapocketprovider.h                                     \
+       $(NULL)
+libgoapocket_la_CFLAGS =                                       \
+       $(GLIB_CFLAGS)                                          \
+       $(GTK_CFLAGS)                                           \
+       $(JSON_GLIB_CFLAGS)                                     \
+       $(REST_CFLAGS)                                          \
+       $(WEBKIT_GTK_CFLAGS)                                    \
+       $(NULL)
+libgoapocket_la_LIBADD =                                       \
+       $(builddir)/libgoa-backend-1.0.la                       \
+       $(GLIB_LIBS)                                            \
+       $(GTK_LIBS)                                             \
+       $(JSON_GLIB_LIBS)                                       \
+       $(REST_LIBS)                                            \
+       $(WEBKIT_GTK_LIBS)                                      \
+       $(NULL)
+libgoapocket_la_LDFLAGS = $(module_flags)
+endif
+
 if BUILD_WINDOWS_LIVE
 goamodule_LTLIBRARIES += libgoawindowslive.la
 libgoawindowslive_la_SOURCES =                                 \
diff --git a/src/goabackend/goapocketmodule.c b/src/goabackend/goapocketmodule.c
new file mode 100644
index 0000000..b6a01a3
--- /dev/null
+++ b/src/goabackend/goapocketmodule.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 "goapocketprovider.h"
+#include "goaprovider.h"
+#include "goaprovider-priv.h"
+
+void
+g_io_module_load (GIOModule *module)
+{
+  goa_pocket_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/goapocketprovider.c b/src/goabackend/goapocketprovider.c
index dcb8035..9ebc445 100644
--- a/src/goabackend/goapocketprovider.c
+++ b/src/goabackend/goapocketprovider.c
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 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
@@ -30,15 +30,8 @@
 
 #define V3_OAUTH_AUTHORIZE_URL "https://getpocket.com/v3/oauth/authorize";
 
-/**
- * GoaPocketProvider:
- *
- * The #GoaPocketProvider structure contains only private data and should
- * only be accessed using the provided API.
- */
 struct _GoaPocketProvider
 {
-  /*< private >*/
   GoaOAuth2Provider parent_instance;
 
   /* request token as gathered from Step 2:
@@ -54,20 +47,7 @@ struct _GoaPocketProviderClass
   GoaOAuth2ProviderClass parent_class;
 };
 
-/**
- * SECTION:goapocketprovider
- * @title: GoaPocketProvider
- * @short_description: A provider for Pocket accounts
- *
- * #GoaPocketProvider is used for handling Pocket accounts.
- */
-
-G_DEFINE_TYPE_WITH_CODE (GoaPocketProvider, goa_pocket_provider, GOA_TYPE_OAUTH2_PROVIDER,
-                         goa_provider_ensure_extension_points_registered ();
-                         g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME,
-                                                         g_define_type_id,
-                                                         "pocket",
-                                                         0));
+G_DEFINE_DYNAMIC_TYPE (GoaPocketProvider, goa_pocket_provider, GOA_TYPE_OAUTH2_PROVIDER);
 
 /* ---------------------------------------------------------------------------------------------------- */
 
@@ -453,6 +433,11 @@ goa_pocket_provider_finalize (GObject *object)
 }
 
 static void
+goa_pocket_provider_class_finalize (GoaPocketProviderClass *klass)
+{
+}
+
+static void
 goa_pocket_provider_class_init (GoaPocketProviderClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -481,3 +466,10 @@ goa_pocket_provider_class_init (GoaPocketProviderClass *klass)
   oauth2_class->process_redirect_url      = process_redirect_url;
   oauth2_class->get_authentication_cookie = get_authentication_cookie;
 }
+
+void
+goa_pocket_provider_register (GIOModule *module)
+{
+  goa_pocket_provider_register_type (G_TYPE_MODULE (module));
+  g_io_extension_point_implement (GOA_PROVIDER_EXTENSION_POINT_NAME, GOA_TYPE_POCKET_PROVIDER, "pocket", 0);
+}
diff --git a/src/goabackend/goapocketprovider.h b/src/goabackend/goapocketprovider.h
index 2103205..25d2f2a 100644
--- a/src/goabackend/goapocketprovider.h
+++ b/src/goabackend/goapocketprovider.h
@@ -1,6 +1,6 @@
 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 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_POCKET_PROVIDER_H__
 #define __GOA_POCKET_PROVIDER_H__
 
-#include <glib-object.h>
+#include <gio/gio.h>
 
 G_BEGIN_DECLS
 
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
 typedef struct _GoaPocketProvider GoaPocketProvider;
 
 GType goa_pocket_provider_get_type (void) G_GNUC_CONST;
+void  goa_pocket_provider_register (GIOModule *module);
 
 G_END_DECLS
 
diff --git a/src/goabackend/goaprovider.c b/src/goabackend/goaprovider.c
index 82ed571..0f74c8a 100644
--- a/src/goabackend/goaprovider.c
+++ b/src/goabackend/goaprovider.c
@@ -28,7 +28,6 @@
 #include "goaowncloudprovider.h"
 #include "goayahooprovider.h"
 #include "goatelepathyfactory.h"
-#include "goapocketprovider.h"
 
 #ifdef GOA_KERBEROS_ENABLED
 #include "goakerberosprovider.h"
@@ -767,9 +766,6 @@ ensure_builtins_loaded (void)
 #ifdef GOA_OWNCLOUD_ENABLED
       type = GOA_TYPE_OWNCLOUD_PROVIDER;
 #endif
-#ifdef GOA_POCKET_ENABLED
-      type = GOA_TYPE_POCKET_PROVIDER;
-#endif
 #ifdef GOA_EXCHANGE_ENABLED
       type = GOA_TYPE_EXCHANGE_PROVIDER;
 #endif


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