[evolution-data-server] Bug 744718 - Provide backend specific extensions as public



commit abfc9387efb57fd2f4f5b75f2e2fd764410ee1a8
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 24 07:25:09 2015 +0100

    Bug 744718 - Provide backend specific extensions as public

 addressbook/backends/ldap/Makefile.am              |    2 -
 .../backends/ldap/e-book-backend-ldap-factory.c    |    2 -
 addressbook/backends/ldap/e-book-backend-ldap.c    |    3 +-
 calendar/backends/contacts/Makefile.am             |    2 -
 .../contacts/e-cal-backend-contacts-factory.c      |    2 -
 .../backends/contacts/e-cal-backend-contacts.c     |    3 +-
 calendar/backends/file/Makefile.am                 |    4 -
 .../backends/file/e-cal-backend-file-factory.c     |    2 -
 calendar/backends/file/e-cal-backend-file.c        |    3 +-
 calendar/backends/weather/Makefile.am              |    2 -
 .../weather/e-cal-backend-weather-factory.c        |    2 -
 calendar/backends/weather/e-cal-backend-weather.c  |    3 +-
 configure.ac                                       |    2 +-
 libedataserver/Makefile.am                         |    8 +
 .../e-source-contacts.c                            |   22 +--
 .../e-source-contacts.h                            |    7 +-
 libedataserver/e-source-enums.h                    |   73 +++++++++
 .../ldap => libedataserver}/e-source-ldap.c        |  164 +++++++++-----------
 .../ldap => libedataserver}/e-source-ldap.h        |   38 +----
 .../file => libedataserver}/e-source-local.c       |   21 +--
 .../file => libedataserver}/e-source-local.h       |    7 +-
 .../weather => libedataserver}/e-source-weather.c  |   47 +-----
 .../weather => libedataserver}/e-source-weather.h  |   19 +--
 libedataserver/e-source.c                          |    8 +
 libedataserver/libedataserver.h                    |    4 +
 25 files changed, 215 insertions(+), 235 deletions(-)
---
diff --git a/addressbook/backends/ldap/Makefile.am b/addressbook/backends/ldap/Makefile.am
index 03dbf90..b45f449 100644
--- a/addressbook/backends/ldap/Makefile.am
+++ b/addressbook/backends/ldap/Makefile.am
@@ -19,8 +19,6 @@ libebookbackendldap_la_SOURCES = \
        e-book-backend-ldap.c \
        e-book-backend-ldap.h \
        e-book-backend-ldap-factory.c \
-       e-source-ldap.c \
-       e-source-ldap.h \
        $(NULL)
 
 libebookbackendldap_la_LIBADD = \
diff --git a/addressbook/backends/ldap/e-book-backend-ldap-factory.c 
b/addressbook/backends/ldap/e-book-backend-ldap-factory.c
index e49e0c3..2d069a1 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap-factory.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap-factory.c
@@ -24,7 +24,6 @@
 #endif
 
 #include "e-book-backend-ldap.h"
-#include "e-source-ldap.h"
 
 #define FACTORY_NAME "ldap"
 
@@ -73,7 +72,6 @@ e_module_load (GTypeModule *type_module)
 {
        e_module = E_MODULE (type_module);
 
-       e_source_ldap_type_register (type_module);
        e_book_backend_ldap_factory_register_type (type_module);
 }
 
diff --git a/addressbook/backends/ldap/e-book-backend-ldap.c b/addressbook/backends/ldap/e-book-backend-ldap.c
index 559ebbf..0efe3e9 100644
--- a/addressbook/backends/ldap/e-book-backend-ldap.c
+++ b/addressbook/backends/ldap/e-book-backend-ldap.c
@@ -64,8 +64,9 @@
 
 #include <glib/gi18n-lib.h>
 
+#include <libedataserver/libedataserver.h>
+
 #include "e-book-backend-ldap.h"
-#include "e-source-ldap.h"
 
 /* this is broken currently, don't enable it */
 /*#define ENABLE_SASL_BINDS*/
diff --git a/calendar/backends/contacts/Makefile.am b/calendar/backends/contacts/Makefile.am
index 7f8e6dc..97d551c 100644
--- a/calendar/backends/contacts/Makefile.am
+++ b/calendar/backends/contacts/Makefile.am
@@ -21,8 +21,6 @@ libecalbackendcontacts_la_SOURCES = \
        e-cal-backend-contacts-factory.c \
        e-cal-backend-contacts.c \
        e-cal-backend-contacts.h \
-       e-source-contacts.c \
-       e-source-contacts.h \
        $(NULL)
 
 libecalbackendcontacts_la_LIBADD = \
diff --git a/calendar/backends/contacts/e-cal-backend-contacts-factory.c 
b/calendar/backends/contacts/e-cal-backend-contacts-factory.c
index 8592fb1..10b1eed 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts-factory.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts-factory.c
@@ -20,7 +20,6 @@
 #include <config.h>
 
 #include "e-cal-backend-contacts.h"
-#include "e-source-contacts.h"
 
 #define FACTORY_NAME "contacts"
 
@@ -71,7 +70,6 @@ e_module_load (GTypeModule *type_module)
 {
        e_module = E_MODULE (type_module);
 
-       e_source_contacts_type_register (type_module);
        e_cal_backend_contacts_events_factory_register_type (type_module);
 }
 
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c 
b/calendar/backends/contacts/e-cal-backend-contacts.c
index 2ab4b6b..bd25043 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -32,8 +32,7 @@
 #include <glib/gi18n-lib.h>
 
 #include <libebook/libebook.h>
-
-#include "e-source-contacts.h"
+#include <libedataserver/libedataserver.h>
 
 #define E_CAL_BACKEND_CONTACTS_GET_PRIVATE(obj) \
        (G_TYPE_INSTANCE_GET_PRIVATE \
diff --git a/calendar/backends/file/Makefile.am b/calendar/backends/file/Makefile.am
index 1803f3b..2e81022 100644
--- a/calendar/backends/file/Makefile.am
+++ b/calendar/backends/file/Makefile.am
@@ -26,8 +26,6 @@ libecalbackendfile_la_SOURCES = \
        e-cal-backend-file-todos.h \
        e-cal-backend-file.c \
        e-cal-backend-file.h \
-       e-source-local.c \
-       e-source-local.h \
        $(NULL)
 
 libecalbackendfile_la_LIBADD = \
@@ -46,8 +44,6 @@ libecalbackendfile_la_LDFLAGS = \
 
 test_interval_searches_SOURCES = \
        e-cal-backend-file.c \
-       e-source-local.c \
-       e-source-local.h \
        $(NULL)
 
 test_interval_searches_LDADD = \
diff --git a/calendar/backends/file/e-cal-backend-file-factory.c 
b/calendar/backends/file/e-cal-backend-file-factory.c
index f4be08f..04f5a60 100644
--- a/calendar/backends/file/e-cal-backend-file-factory.c
+++ b/calendar/backends/file/e-cal-backend-file-factory.c
@@ -22,7 +22,6 @@
 #include "e-cal-backend-file-events.h"
 #include "e-cal-backend-file-journal.h"
 #include "e-cal-backend-file-todos.h"
-#include "e-source-local.h"
 
 #define FACTORY_NAME "local"
 
@@ -138,7 +137,6 @@ e_module_load (GTypeModule *type_module)
 {
        e_module = E_MODULE (type_module);
 
-       e_source_local_type_register (type_module);
        e_cal_backend_file_events_factory_register_type (type_module);
        e_cal_backend_file_journal_factory_register_type (type_module);
        e_cal_backend_file_todos_factory_register_type (type_module);
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index e0b16a2..d60d07f 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -32,8 +32,9 @@
 #include <glib/gstdio.h>
 #include <glib/gi18n-lib.h>
 
+#include <libedataserver/libedataserver.h>
+
 #include "e-cal-backend-file-events.h"
-#include "e-source-local.h"
 
 #ifndef O_BINARY
 #define O_BINARY 0
diff --git a/calendar/backends/weather/Makefile.am b/calendar/backends/weather/Makefile.am
index f8abad5..55bce19 100644
--- a/calendar/backends/weather/Makefile.am
+++ b/calendar/backends/weather/Makefile.am
@@ -24,8 +24,6 @@ libecalbackendweather_la_SOURCES = \
        e-cal-backend-weather-factory.c \
        e-cal-backend-weather.c \
        e-cal-backend-weather.h \
-       e-source-weather.c \
-       e-source-weather.h \
        e-weather-source.c \
        e-weather-source.h \
        $(NULL)
diff --git a/calendar/backends/weather/e-cal-backend-weather-factory.c 
b/calendar/backends/weather/e-cal-backend-weather-factory.c
index 6f043e0..543426d 100644
--- a/calendar/backends/weather/e-cal-backend-weather-factory.c
+++ b/calendar/backends/weather/e-cal-backend-weather-factory.c
@@ -20,7 +20,6 @@
 #include <config.h>
 
 #include "e-cal-backend-weather.h"
-#include "e-source-weather.h"
 
 #define FACTORY_NAME "weather"
 
@@ -70,7 +69,6 @@ e_module_load (GTypeModule *type_module)
 {
        e_module = E_MODULE (type_module);
 
-       e_source_weather_type_register (type_module);
        e_cal_backend_weather_events_factory_register_type (type_module);
 }
 
diff --git a/calendar/backends/weather/e-cal-backend-weather.c 
b/calendar/backends/weather/e-cal-backend-weather.c
index 1875960..de3096b 100644
--- a/calendar/backends/weather/e-cal-backend-weather.c
+++ b/calendar/backends/weather/e-cal-backend-weather.c
@@ -21,8 +21,9 @@
 #include <glib/gi18n-lib.h>
 #include <string.h>
 
+#include <libedataserver/libedataserver.h>
+
 #include "e-cal-backend-weather.h"
-#include "e-source-weather.h"
 #include "e-weather-source.h"
 
 #define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
diff --git a/configure.ac b/configure.ac
index 27f6025..a4038a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ AC_SUBST(USER_PROMPTER_DBUS_SERVICE_NAME)
 dnl ******************************
 dnl Libtool versioning
 dnl ******************************
-LIBEDATASERVER_CURRENT=20
+LIBEDATASERVER_CURRENT=21
 LIBEDATASERVER_REVISION=0
 LIBEDATASERVER_AGE=0
 
diff --git a/libedataserver/Makefile.am b/libedataserver/Makefile.am
index e04eee8..c973f11 100644
--- a/libedataserver/Makefile.am
+++ b/libedataserver/Makefile.am
@@ -78,10 +78,13 @@ libedataserver_1_2_la_SOURCES = \
        e-source-calendar.c \
        e-source-camel.c \
        e-source-collection.c \
+       e-source-contacts.c \
        e-source-credentials-provider.c \
        e-source-credentials-provider-impl.c \
        e-source-credentials-provider-impl-password.c \
        e-source-goa.c \
+       e-source-ldap.c \
+       e-source-local.c \
        e-source-mail-account.c \
        e-source-mail-composition.c \
        e-source-mail-identity.c \
@@ -100,6 +103,7 @@ libedataserver_1_2_la_SOURCES = \
        e-source-selectable.c \
        e-source-smime.c \
        e-source-uoa.c \
+       e-source-weather.c \
        e-source-webdav.c \
        e-debug-log.c \
        e-time-utils.c \
@@ -164,6 +168,7 @@ libedataserverinclude_HEADERS = \
        e-source-calendar.h \
        e-source-camel.h \
        e-source-collection.h \
+       e-source-contacts.h \
        e-source-credentials-provider.h \
        e-source-credentials-provider-impl.h \
        e-source-credentials-provider-impl-password.h \
@@ -171,6 +176,8 @@ libedataserverinclude_HEADERS = \
        e-source-enumtypes.h \
        e-source-extension.h \
        e-source-goa.h \
+       e-source-ldap.h \
+       e-source-local.h \
        e-source-mail-account.h \
        e-source-mail-composition.h \
        e-source-mail-identity.h \
@@ -189,6 +196,7 @@ libedataserverinclude_HEADERS = \
        e-source-selectable.h \
        e-source-smime.h \
        e-source-uoa.h \
+       e-source-weather.h \
        e-source-webdav.h \
        e-debug-log.h \
        e-time-utils.h \
diff --git a/calendar/backends/contacts/e-source-contacts.c b/libedataserver/e-source-contacts.c
similarity index 91%
rename from calendar/backends/contacts/e-source-contacts.c
rename to libedataserver/e-source-contacts.c
index fae32db..85bbb77 100644
--- a/calendar/backends/contacts/e-source-contacts.c
+++ b/libedataserver/e-source-contacts.c
@@ -15,6 +15,12 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-source-address-book.h"
+
 #include "e-source-contacts.h"
 
 #define E_SOURCE_CONTACTS_GET_PRIVATE(obj) \
@@ -30,7 +36,7 @@ enum {
        PROP_INCLUDE_ME
 };
 
-G_DEFINE_DYNAMIC_TYPE (
+G_DEFINE_TYPE (
        ESourceContacts,
        e_source_contacts,
        E_TYPE_SOURCE_EXTENSION)
@@ -129,25 +135,11 @@ e_source_contacts_class_init (ESourceContactsClass *class)
 }
 
 static void
-e_source_contacts_class_finalize (ESourceContactsClass *class)
-{
-}
-
-static void
 e_source_contacts_init (ESourceContacts *extension)
 {
        extension->priv = E_SOURCE_CONTACTS_GET_PRIVATE (extension);
 }
 
-void
-e_source_contacts_type_register (GTypeModule *type_module)
-{
-       /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
-        *     function, so we have to wrap it with a public function in
-        *     order to register types from a separate compilation unit. */
-       e_source_contacts_register_type (type_module);
-}
-
 gboolean
 e_source_contacts_get_include_me (ESourceContacts *extension)
 {
diff --git a/calendar/backends/contacts/e-source-contacts.h b/libedataserver/e-source-contacts.h
similarity index 90%
rename from calendar/backends/contacts/e-source-contacts.h
rename to libedataserver/e-source-contacts.h
index d9bc587..ce5e849 100644
--- a/calendar/backends/contacts/e-source-contacts.h
+++ b/libedataserver/e-source-contacts.h
@@ -15,10 +15,14 @@
  *
  */
 
+#if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
+#error "Only <libedataserver/libedataserver.h> should be included directly."
+#endif
+
 #ifndef E_SOURCE_CONTACTS_H
 #define E_SOURCE_CONTACTS_H
 
-#include <libedataserver/libedataserver.h>
+#include <libedataserver/e-source-extension.h>
 
 /* Standard GObject macros */
 #define E_TYPE_SOURCE_CONTACTS \
@@ -57,7 +61,6 @@ struct _ESourceContactsClass {
 };
 
 GType          e_source_contacts_get_type      (void);
-void           e_source_contacts_type_register (GTypeModule *type_module);
 gboolean       e_source_contacts_get_include_me
                                                (ESourceContacts *extension);
 void           e_source_contacts_set_include_me
diff --git a/libedataserver/e-source-enums.h b/libedataserver/e-source-enums.h
index 49d636d..a13b578 100644
--- a/libedataserver/e-source-enums.h
+++ b/libedataserver/e-source-enums.h
@@ -167,4 +167,77 @@ typedef enum {
        E_SOURCE_CREDENTIALS_REASON_ERROR
 } ESourceCredentialsReason;
 
+/**
+ * ESourceLDAPAuthentication:
+ * @E_SOURCE_LDAP_AUTHENTICATION_NONE:
+ *   Use none authentication type.
+ * @E_SOURCE_LDAP_AUTHENTICATION_EMAIL:
+ *   Use an email address for authentication.
+ * @E_SOURCE_LDAP_AUTHENTICATION_BINDDN:
+ *   Use a bind DN for authentication.
+ *
+ * Defines authentication types for LDAP sources.
+ *
+ * Since: 3.18
+ **/
+typedef enum {
+       E_SOURCE_LDAP_AUTHENTICATION_NONE,
+       E_SOURCE_LDAP_AUTHENTICATION_EMAIL,
+       E_SOURCE_LDAP_AUTHENTICATION_BINDDN
+} ESourceLDAPAuthentication;
+
+/**
+ * ESourceLDAPScope:
+ * @E_SOURCE_LDAP_SCOPE_ONELEVEL:
+ *   One level search scope.
+ * @E_SOURCE_LDAP_SCOPE_SUBTREE:
+ *   Sub-tree search scope.
+ *
+ * Defines search scope for LDAP sources.
+ *
+ * Since: 3.18
+ **/
+typedef enum {
+       E_SOURCE_LDAP_SCOPE_ONELEVEL,
+       E_SOURCE_LDAP_SCOPE_SUBTREE
+} ESourceLDAPScope;
+
+/**
+ * ESourceLDAPSecurity:
+ * @E_SOURCE_LDAP_SECURITY_NONE:
+ *   Connect insecurely.
+ * @E_SOURCE_LDAP_SECURITY_LDAPS:
+ *   Connect using secure LDAP (LDAPS).
+ * @E_SOURCE_LDAP_SECURITY_STARTTLS:
+ *   Connect using STARTTLS.
+ *
+ * Defines what connection security should be used for LDAP sources.
+ *
+ * Since: 3.18
+ **/
+typedef enum {
+       E_SOURCE_LDAP_SECURITY_NONE,
+       E_SOURCE_LDAP_SECURITY_LDAPS,
+       E_SOURCE_LDAP_SECURITY_STARTTLS
+} ESourceLDAPSecurity;
+
+/**
+ * ESourceWeatherUnits:
+ * @E_SOURCE_WEATHER_UNITS_FAHRENHEIT:
+ *   Fahrenheit units
+ * @E_SOURCE_WEATHER_UNITS_CENTIGRADE:
+ *   Centigrade units
+ * @E_SOURCE_WEATHER_UNITS_KELVIN:
+ *   Kelvin units
+ *
+ * Units to be used in an #ESourceWeather extension.
+ *
+ * Since: 3.18
+ **/
+typedef enum {
+       E_SOURCE_WEATHER_UNITS_FAHRENHEIT = 0,
+       E_SOURCE_WEATHER_UNITS_CENTIGRADE,
+       E_SOURCE_WEATHER_UNITS_KELVIN
+} ESourceWeatherUnits;
+
 #endif /* E_SOURCE_ENUMS_H */
diff --git a/addressbook/backends/ldap/e-source-ldap.c b/libedataserver/e-source-ldap.c
similarity index 85%
rename from addressbook/backends/ldap/e-source-ldap.c
rename to libedataserver/e-source-ldap.c
index 7595a27..84a9f01 100644
--- a/addressbook/backends/ldap/e-source-ldap.c
+++ b/libedataserver/e-source-ldap.c
@@ -15,6 +15,14 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-source-authentication.h"
+#include "e-source-security.h"
+#include "e-source-enumtypes.h"
+
 #include "e-source-ldap.h"
 
 #include <ldap.h>
@@ -47,15 +55,74 @@ enum {
        PROP_SECURITY
 };
 
-static GType e_source_ldap_authentication_type = G_TYPE_INVALID;
-static GType e_source_ldap_scope_type = G_TYPE_INVALID;
-static GType e_source_ldap_security_type = G_TYPE_INVALID;
-
-G_DEFINE_DYNAMIC_TYPE (
+G_DEFINE_TYPE (
        ESourceLDAP,
        e_source_ldap,
        E_TYPE_SOURCE_EXTENSION)
 
+static struct ELDAPAuthMapping {
+       ESourceLDAPAuthentication value;
+       const gchar *nick;
+} ldap_auth_mapping[] = {
+       { E_SOURCE_LDAP_AUTHENTICATION_NONE, "none" },
+       { E_SOURCE_LDAP_AUTHENTICATION_EMAIL, "ldap/simple-email" },
+       { E_SOURCE_LDAP_AUTHENTICATION_BINDDN, "ldap/simple-binddn" }
+};
+
+static gboolean
+source_ldap_transform_auth_enum_nick_to_value (GBinding *binding,
+                                              const GValue *source_value,
+                                              GValue *target_value,
+                                              gpointer not_used)
+{
+       GEnumClass *enum_class;
+       const gchar *string;
+       gboolean success = FALSE;
+       gint ii;
+
+       enum_class = g_type_class_peek (G_VALUE_TYPE (target_value));
+       g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), FALSE);
+
+       string = g_value_get_string (source_value);
+
+       for (ii = 0; ii < G_N_ELEMENTS (ldap_auth_mapping); ii++) {
+               if (g_strcmp0 (ldap_auth_mapping[ii].nick, string) == 0) {
+                       g_value_set_enum (target_value, ldap_auth_mapping[ii].value);
+                       success = TRUE;
+                       break;
+               }
+       }
+
+       return success;
+}
+
+static gboolean
+source_ldap_transform_auth_enum_value_to_nick (GBinding *binding,
+                                              const GValue *source_value,
+                                              GValue *target_value,
+                                              gpointer not_used)
+{
+       GEnumClass *enum_class;
+       gint value;
+       gboolean success = FALSE;
+       gint ii;
+
+       enum_class = g_type_class_peek (G_VALUE_TYPE (source_value));
+       g_return_val_if_fail (G_IS_ENUM_CLASS (enum_class), FALSE);
+
+       value = g_value_get_enum (source_value);
+
+       for (ii = 0; ii < G_N_ELEMENTS (ldap_auth_mapping); ii++) {
+               if (value == ldap_auth_mapping[ii].value) {
+                       g_value_set_string (target_value, ldap_auth_mapping[ii].nick);
+                       success = TRUE;
+                       break;
+               }
+       }
+
+       return success;
+}
+
 static gboolean
 source_ldap_transform_enum_nick_to_value (GBinding *binding,
                                           const GValue *source_value,
@@ -255,8 +322,8 @@ source_ldap_constructed (GObject *object)
                this_extension, "authentication",
                G_BINDING_BIDIRECTIONAL |
                G_BINDING_SYNC_CREATE,
-               source_ldap_transform_enum_nick_to_value,
-               source_ldap_transform_enum_value_to_nick,
+               source_ldap_transform_auth_enum_nick_to_value,
+               source_ldap_transform_auth_enum_value_to_nick,
                NULL, (GDestroyNotify) NULL);
 
        extension_name = E_SOURCE_EXTENSION_SECURITY;
@@ -380,77 +447,12 @@ e_source_ldap_class_init (ESourceLDAPClass *class)
 }
 
 static void
-e_source_ldap_class_finalize (ESourceLDAPClass *class)
-{
-}
-
-static void
 e_source_ldap_init (ESourceLDAP *extension)
 {
        extension->priv = E_SOURCE_LDAP_GET_PRIVATE (extension);
        g_mutex_init (&extension->priv->property_lock);
 }
 
-void
-e_source_ldap_type_register (GTypeModule *type_module)
-{
-       static const GEnumValue e_source_ldap_authentication_values[] = {
-               { E_SOURCE_LDAP_AUTHENTICATION_NONE,
-                 "E_SOURCE_LDAP_AUTHENTICATION_NONE",
-                 "none" },
-               { E_SOURCE_LDAP_AUTHENTICATION_EMAIL,
-                 "E_SOURCE_LDAP_AUTHENTICATION_EMAIL",
-                 "ldap/simple-email" },
-               { E_SOURCE_LDAP_AUTHENTICATION_BINDDN,
-                 "E_SOURCE_LDAP_AUTHENTICATION_BINDDN",
-                 "ldap/simple-binddn" },
-               { 0, NULL, NULL }
-       };
-
-       static const GEnumValue e_source_ldap_scope_values[] = {
-               { E_SOURCE_LDAP_SCOPE_ONELEVEL,
-                 "E_SOURCE_LDAP_SCOPE_ONELEVEL",
-                 "onelevel" },
-               { E_SOURCE_LDAP_SCOPE_SUBTREE,
-                 "E_SOURCE_LDAP_SCOPE_SUBTREE",
-                 "subtree" },
-               { 0, NULL, NULL }
-       };
-
-       static const GEnumValue e_source_ldap_security_values[] = {
-               { E_SOURCE_LDAP_SECURITY_NONE,
-                 "E_SOURCE_LDAP_SECURITY_NONE",
-                 "none" },
-               { E_SOURCE_LDAP_SECURITY_LDAPS,
-                 "E_SOURCE_LDAP_SECURITY_LDAPS",
-                 "ldaps" },
-               { E_SOURCE_LDAP_SECURITY_STARTTLS,
-                 "E_SOURCE_LDAP_SECURITY_STARTTLS",
-                 "starttls" },
-               { 0, NULL, NULL }
-       };
-
-       e_source_ldap_authentication_type =
-               g_type_module_register_enum (
-               type_module, "ESourceLDAPAuthentication",
-               e_source_ldap_authentication_values);
-
-       e_source_ldap_scope_type =
-               g_type_module_register_enum (
-               type_module, "ESourceLDAPScope",
-               e_source_ldap_scope_values);
-
-       e_source_ldap_security_type =
-               g_type_module_register_enum (
-               type_module, "ESourceLDAPSecurity",
-               e_source_ldap_security_values);
-
-       /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
-        *     function, so we have to wrap it with a public function in
-        *     order to register types from a separate compilation unit. */
-       e_source_ldap_register_type (type_module);
-}
-
 ESourceLDAPAuthentication
 e_source_ldap_get_authentication (ESourceLDAP *extension)
 {
@@ -668,21 +670,3 @@ e_source_ldap_set_security (ESourceLDAP *extension,
 
        g_object_notify (G_OBJECT (extension), "security");
 }
-
-GType
-e_source_ldap_authentication_get_type (void)
-{
-       return e_source_ldap_authentication_type;
-}
-
-GType
-e_source_ldap_scope_get_type (void)
-{
-       return e_source_ldap_scope_type;
-}
-
-GType
-e_source_ldap_security_get_type (void)
-{
-       return e_source_ldap_security_type;
-}
diff --git a/addressbook/backends/ldap/e-source-ldap.h b/libedataserver/e-source-ldap.h
similarity index 77%
rename from addressbook/backends/ldap/e-source-ldap.h
rename to libedataserver/e-source-ldap.h
index c275a02..abf1766 100644
--- a/addressbook/backends/ldap/e-source-ldap.h
+++ b/libedataserver/e-source-ldap.h
@@ -15,10 +15,15 @@
  *
  */
 
+#if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
+#error "Only <libedataserver/libedataserver.h> should be included directly."
+#endif
+
 #ifndef E_SOURCE_LDAP_H
 #define E_SOURCE_LDAP_H
 
-#include <libedataserver/libedataserver.h>
+#include <libedataserver/e-source-extension.h>
+#include <libedataserver/e-source-enums.h>
 
 /* Standard GObject macros */
 #define E_TYPE_SOURCE_LDAP \
@@ -39,15 +44,6 @@
        (G_TYPE_INSTANCE_GET_CLASS \
        ((obj), E_TYPE_SOURCE_LDAP, ESourceLDAPClass))
 
-#define E_TYPE_SOURCE_LDAP_AUTHENTICATION \
-       (e_source_ldap_authentication_get_type ())
-
-#define E_TYPE_SOURCE_LDAP_SCOPE \
-       (e_source_ldap_scope_get_type ())
-
-#define E_TYPE_SOURCE_LDAP_SECURITY \
-       (e_source_ldap_security_get_type ())
-
 #define E_SOURCE_EXTENSION_LDAP_BACKEND "LDAP Backend"
 
 G_BEGIN_DECLS
@@ -65,25 +61,7 @@ struct _ESourceLDAPClass {
        ESourceExtensionClass parent_class;
 };
 
-typedef enum {
-       E_SOURCE_LDAP_AUTHENTICATION_NONE,
-       E_SOURCE_LDAP_AUTHENTICATION_EMAIL,
-       E_SOURCE_LDAP_AUTHENTICATION_BINDDN
-} ESourceLDAPAuthentication;
-
-typedef enum {
-       E_SOURCE_LDAP_SCOPE_ONELEVEL,
-       E_SOURCE_LDAP_SCOPE_SUBTREE
-} ESourceLDAPScope;
-
-typedef enum {
-       E_SOURCE_LDAP_SECURITY_NONE,
-       E_SOURCE_LDAP_SECURITY_LDAPS,
-       E_SOURCE_LDAP_SECURITY_STARTTLS
-} ESourceLDAPSecurity;
-
 GType          e_source_ldap_get_type          (void);
-void           e_source_ldap_type_register     (GTypeModule *type_module);
 ESourceLDAPAuthentication
                e_source_ldap_get_authentication
                                                (ESourceLDAP *extension);
@@ -113,10 +91,6 @@ ESourceLDAPSecurity
 void           e_source_ldap_set_security      (ESourceLDAP *extension,
                                                 ESourceLDAPSecurity security);
 
-GType          e_source_ldap_authentication_get_type   (void);
-GType          e_source_ldap_scope_get_type            (void);
-GType          e_source_ldap_security_get_type         (void);
-
 G_END_DECLS
 
 #endif /* E_SOURCE_LDAP_H */
diff --git a/calendar/backends/file/e-source-local.c b/libedataserver/e-source-local.c
similarity index 91%
rename from calendar/backends/file/e-source-local.c
rename to libedataserver/e-source-local.c
index 16db2b4..e65f5db 100644
--- a/calendar/backends/file/e-source-local.c
+++ b/libedataserver/e-source-local.c
@@ -15,6 +15,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include "e-source-local.h"
 
 #define E_SOURCE_LOCAL_GET_PRIVATE(obj) \
@@ -31,7 +35,7 @@ enum {
        PROP_CUSTOM_FILE
 };
 
-G_DEFINE_DYNAMIC_TYPE (
+G_DEFINE_TYPE (
        ESourceLocal,
        e_source_local,
        E_TYPE_SOURCE_EXTENSION)
@@ -131,26 +135,12 @@ e_source_local_class_init (ESourceLocalClass *class)
 }
 
 static void
-e_source_local_class_finalize (ESourceLocalClass *class)
-{
-}
-
-static void
 e_source_local_init (ESourceLocal *extension)
 {
        extension->priv = E_SOURCE_LOCAL_GET_PRIVATE (extension);
        g_mutex_init (&extension->priv->property_lock);
 }
 
-void
-e_source_local_type_register (GTypeModule *type_module)
-{
-       /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
-        *     function, so we have to wrap it with a public function in
-        *     order to register types from a separate compilation unit. */
-       e_source_local_register_type (type_module);
-}
-
 GFile *
 e_source_local_get_custom_file (ESourceLocal *extension)
 {
@@ -199,4 +189,3 @@ e_source_local_set_custom_file (ESourceLocal *extension,
 
        g_object_notify (G_OBJECT (extension), "custom-file");
 }
-
diff --git a/calendar/backends/file/e-source-local.h b/libedataserver/e-source-local.h
similarity index 90%
rename from calendar/backends/file/e-source-local.h
rename to libedataserver/e-source-local.h
index d22ae3d..1fc7a18 100644
--- a/calendar/backends/file/e-source-local.h
+++ b/libedataserver/e-source-local.h
@@ -15,10 +15,14 @@
  *
  */
 
+#if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
+#error "Only <libedataserver/libedataserver.h> should be included directly."
+#endif
+
 #ifndef E_SOURCE_LOCAL_H
 #define E_SOURCE_LOCAL_H
 
-#include <libedataserver/libedataserver.h>
+#include <libedataserver/e-source-extension.h>
 
 /* Standard GObject macros */
 #define E_TYPE_SOURCE_LOCAL \
@@ -57,7 +61,6 @@ struct _ESourceLocalClass {
 };
 
 GType          e_source_local_get_type         (void);
-void           e_source_local_type_register    (GTypeModule *type_module);
 GFile *                e_source_local_get_custom_file  (ESourceLocal *extension);
 GFile *                e_source_local_dup_custom_file  (ESourceLocal *extension);
 void           e_source_local_set_custom_file  (ESourceLocal *extension,
diff --git a/calendar/backends/weather/e-source-weather.c b/libedataserver/e-source-weather.c
similarity index 83%
rename from calendar/backends/weather/e-source-weather.c
rename to libedataserver/e-source-weather.c
index cbf5c5c..4788a7a 100644
--- a/calendar/backends/weather/e-source-weather.c
+++ b/libedataserver/e-source-weather.c
@@ -15,6 +15,11 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-source-enumtypes.h"
 #include "e-source-weather.h"
 
 #define E_SOURCE_WEATHER_GET_PRIVATE(obj) \
@@ -33,9 +38,7 @@ enum {
        PROP_UNITS
 };
 
-static GType e_source_weather_units_type = G_TYPE_INVALID;
-
-G_DEFINE_DYNAMIC_TYPE (
+G_DEFINE_TYPE (
        ESourceWeather,
        e_source_weather,
        E_TYPE_SOURCE_EXTENSION)
@@ -146,44 +149,12 @@ e_source_weather_class_init (ESourceWeatherClass *class)
 }
 
 static void
-e_source_weather_class_finalize (ESourceWeatherClass *class)
-{
-}
-
-static void
 e_source_weather_init (ESourceWeather *extension)
 {
        extension->priv = E_SOURCE_WEATHER_GET_PRIVATE (extension);
        g_mutex_init (&extension->priv->property_lock);
 }
 
-void
-e_source_weather_type_register (GTypeModule *type_module)
-{
-       static const GEnumValue e_source_weather_units_values[] = {
-               { E_SOURCE_WEATHER_UNITS_FAHRENHEIT,
-                 "E_SOURCE_WEATHER_UNITS_FAHRENHEIT",
-                 "fahrenheit" },
-               { E_SOURCE_WEATHER_UNITS_CENTIGRADE,
-                 "E_SOURCE_WEATHER_UNITS_CENTIGRADE",
-                 "centigrade" },
-               { E_SOURCE_WEATHER_UNITS_KELVIN,
-                 "E_SOURCE_WEATHER_UNITS_KELVIN",
-                 "kelvin" },
-               { 0, NULL, NULL }
-       };
-
-       e_source_weather_units_type =
-               g_type_module_register_enum (
-               type_module, "ESourceWeatherUnits",
-               e_source_weather_units_values);
-
-       /* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
-        *     function, so we have to wrap it with a public function in
-        *     order to register types from a separate compilation unit. */
-       e_source_weather_register_type (type_module);
-}
-
 const gchar *
 e_source_weather_get_location (ESourceWeather *extension)
 {
@@ -252,9 +223,3 @@ e_source_weather_set_units (ESourceWeather *extension,
 
        g_object_notify (G_OBJECT (extension), "units");
 }
-
-GType
-e_source_weather_units_get_type (void)
-{
-       return e_source_weather_units_type;
-}
diff --git a/calendar/backends/weather/e-source-weather.h b/libedataserver/e-source-weather.h
similarity index 85%
rename from calendar/backends/weather/e-source-weather.h
rename to libedataserver/e-source-weather.h
index dd950a6..ad16b72 100644
--- a/calendar/backends/weather/e-source-weather.h
+++ b/libedataserver/e-source-weather.h
@@ -15,10 +15,15 @@
  *
  */
 
+#if !defined (__LIBEDATASERVER_H_INSIDE__) && !defined (LIBEDATASERVER_COMPILATION)
+#error "Only <libedataserver/libedataserver.h> should be included directly."
+#endif
+
 #ifndef E_SOURCE_WEATHER_H
 #define E_SOURCE_WEATHER_H
 
-#include <libedataserver/libedataserver.h>
+#include <libedataserver/e-source-extension.h>
+#include <libedataserver/e-source-enums.h>
 
 /* Standard GObject macros */
 #define E_TYPE_SOURCE_WEATHER \
@@ -39,9 +44,6 @@
        (G_TYPE_INSTANCE_GET_CLASS \
        ((obj), E_TYPE_SOURCE_WEATHER, ESourceWeatherClass))
 
-#define E_TYPE_SOURCE_WEATHER_UNITS \
-       (e_source_weather_units_get_type ())
-
 #define E_SOURCE_EXTENSION_WEATHER_BACKEND "Weather Backend"
 
 G_BEGIN_DECLS
@@ -59,14 +61,7 @@ struct _ESourceWeatherClass {
        ESourceExtensionClass parent_class;
 };
 
-typedef enum {
-       E_SOURCE_WEATHER_UNITS_FAHRENHEIT = 0,
-       E_SOURCE_WEATHER_UNITS_CENTIGRADE,
-       E_SOURCE_WEATHER_UNITS_KELVIN
-} ESourceWeatherUnits;
-
 GType          e_source_weather_get_type       (void);
-void           e_source_weather_type_register  (GTypeModule *type_module);
 const gchar *  e_source_weather_get_location   (ESourceWeather *extension);
 gchar *                e_source_weather_dup_location   (ESourceWeather *extension);
 void           e_source_weather_set_location   (ESourceWeather *extension,
@@ -76,8 +71,6 @@ ESourceWeatherUnits
 void           e_source_weather_set_units      (ESourceWeather *extension,
                                                 ESourceWeatherUnits units);
 
-GType          e_source_weather_units_get_type         (void);
-
 G_END_DECLS
 
 #endif /* E_SOURCE_WEATHER_H */
diff --git a/libedataserver/e-source.c b/libedataserver/e-source.c
index 0106bd5..6fc740f 100644
--- a/libedataserver/e-source.c
+++ b/libedataserver/e-source.c
@@ -89,7 +89,10 @@
 #include "e-source-calendar.h"
 #include "e-source-camel.h"
 #include "e-source-collection.h"
+#include "e-source-contacts.h"
 #include "e-source-goa.h"
+#include "e-source-ldap.h"
+#include "e-source-local.h"
 #include "e-source-mail-account.h"
 #include "e-source-mail-composition.h"
 #include "e-source-mail-identity.h"
@@ -107,6 +110,7 @@
 #include "e-source-selectable.h"
 #include "e-source-smime.h"
 #include "e-source-uoa.h"
+#include "e-source-weather.h"
 #include "e-source-webdav.h"
 
 #define E_SOURCE_GET_PRIVATE(obj) \
@@ -2580,7 +2584,10 @@ e_source_class_init (ESourceClass *class)
        g_type_ensure (E_TYPE_SOURCE_AUTOCOMPLETE);
        g_type_ensure (E_TYPE_SOURCE_CALENDAR);
        g_type_ensure (E_TYPE_SOURCE_COLLECTION);
+       g_type_ensure (E_TYPE_SOURCE_CONTACTS);
        g_type_ensure (E_TYPE_SOURCE_GOA);
+       g_type_ensure (E_TYPE_SOURCE_LDAP);
+       g_type_ensure (E_TYPE_SOURCE_LOCAL);
        g_type_ensure (E_TYPE_SOURCE_MAIL_ACCOUNT);
        g_type_ensure (E_TYPE_SOURCE_MAIL_COMPOSITION);
        g_type_ensure (E_TYPE_SOURCE_MAIL_IDENTITY);
@@ -2600,6 +2607,7 @@ e_source_class_init (ESourceClass *class)
        g_type_ensure (E_TYPE_SOURCE_SMIME);
        g_type_ensure (E_TYPE_SOURCE_TASK_LIST);
        g_type_ensure (E_TYPE_SOURCE_UOA);
+       g_type_ensure (E_TYPE_SOURCE_WEATHER);
        g_type_ensure (E_TYPE_SOURCE_WEBDAV);
 }
 
diff --git a/libedataserver/libedataserver.h b/libedataserver/libedataserver.h
index 1e6a443..d299f4b 100644
--- a/libedataserver/libedataserver.h
+++ b/libedataserver/libedataserver.h
@@ -50,6 +50,7 @@
 #include <libedataserver/e-source-calendar.h>
 #include <libedataserver/e-source-camel.h>
 #include <libedataserver/e-source-collection.h>
+#include <libedataserver/e-source-contacts.h>
 #include <libedataserver/e-source-credentials-provider.h>
 #include <libedataserver/e-source-credentials-provider-impl.h>
 #include <libedataserver/e-source-credentials-provider-impl-password.h>
@@ -57,6 +58,8 @@
 #include <libedataserver/e-source-enumtypes.h>
 #include <libedataserver/e-source-extension.h>
 #include <libedataserver/e-source-goa.h>
+#include <libedataserver/e-source-ldap.h>
+#include <libedataserver/e-source-local.h>
 #include <libedataserver/e-source-mail-account.h>
 #include <libedataserver/e-source-mail-composition.h>
 #include <libedataserver/e-source-mail-identity.h>
@@ -76,6 +79,7 @@
 #include <libedataserver/e-source-smime.h>
 #include <libedataserver/e-source-uoa.h>
 #include <libedataserver/e-source-webdav.h>
+#include <libedataserver/e-source-weather.h>
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-time-utils.h>
 #include <libedataserver/e-uid.h>


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