diff options
| author | Eugen Dedu <Eugen.Dedu@pu-pm.univ-fcomte.fr> | 2012-06-07 14:17:11 (GMT) |
|---|---|---|
| committer | Eugen Dedu <Eugen.Dedu@pu-pm.univ-fcomte.fr> | 2012-06-07 14:17:11 (GMT) |
| commit | d84271d706408357d3ec8a36be4db7160e0823e4 (patch) | |
| tree | 9c1753fd6900cf7e523617eab00d901ad3d10777 | |
| parent | b8d20d6e29c5a3a6be70cb8cc6e3ce0d019c51cf (diff) | |
| download | ekiga-d84271d706408357d3ec8a36be4db7160e0823e4.zip ekiga-d84271d706408357d3ec8a36be4db7160e0823e4.tar.xz | |
Adapt to Evolution-Data-Server API changes in 3.5.3
Fixes bug 677383. The patch proposed was modified so that older eds
work too.
| -rw-r--r-- | plugins/evolution/evolution-book.cpp | 4 | ||||
| -rw-r--r-- | plugins/evolution/evolution-book.h | 5 | ||||
| -rw-r--r-- | plugins/evolution/evolution-contact.h | 5 | ||||
| -rw-r--r-- | plugins/evolution/evolution-source.cpp | 100 | ||||
| -rw-r--r-- | plugins/evolution/evolution-source.h | 15 |
5 files changed, 125 insertions, 4 deletions
diff --git a/plugins/evolution/evolution-book.cpp b/plugins/evolution/evolution-book.cpp index ad3cc18..e9e69e1 100644 --- a/plugins/evolution/evolution-book.cpp +++ b/plugins/evolution/evolution-book.cpp @@ -280,7 +280,11 @@ Evolution::Book::get_name () const source = e_book_get_source (book); if (source && E_IS_SOURCE (source)) +#if EDS_CHECK_VERSION(3,5,3) + result = e_source_get_display_name (source); +#else result = e_source_peek_name (source); +#endif return result; } diff --git a/plugins/evolution/evolution-book.h b/plugins/evolution/evolution-book.h index e49bcf8..8256eb0 100644 --- a/plugins/evolution/evolution-book.h +++ b/plugins/evolution/evolution-book.h @@ -38,7 +38,12 @@ #ifndef __EVOLUTION_BOOK_H__ #define __EVOLUTION_BOOK_H__ +#include <libedataserver/eds-version.h> +#if EDS_CHECK_VERSION(3,5,3) +#include <libebook/libebook.h> +#else #include <libebook/e-book.h> +#endif #include "filterable.h" #include "form.h" diff --git a/plugins/evolution/evolution-contact.h b/plugins/evolution/evolution-contact.h index addb4f1..fd18834 100644 --- a/plugins/evolution/evolution-contact.h +++ b/plugins/evolution/evolution-contact.h @@ -40,7 +40,12 @@ #include <map> +#include <libedataserver/eds-version.h> +#if EDS_CHECK_VERSION(3,5,3) +#include <libebook/libebook.h> +#else #include <libebook/e-book.h> +#endif #include "contact-core.h" #include "form.h" diff --git a/plugins/evolution/evolution-source.cpp b/plugins/evolution/evolution-source.cpp index 618c31f..e3854f4 100644 --- a/plugins/evolution/evolution-source.cpp +++ b/plugins/evolution/evolution-source.cpp @@ -39,8 +39,25 @@ #include "evolution-source.h" +#if EDS_CHECK_VERSION(3,5,3) +#else #define GCONF_PATH "/apps/evolution/addressbook/sources" +#endif +#if EDS_CHECK_VERSION(3,5,3) +static void +on_registry_source_added_c (ESourceRegistry */*registry*/, + ESource *source, + gpointer data) +{ + Evolution::Source *self = NULL; + + self = (Evolution::Source *)data; + + if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) + self->add_source (source); +} +#else static void on_source_list_group_added_c (ESourceList */*source_list*/, ESourceGroup *group, @@ -52,7 +69,19 @@ on_source_list_group_added_c (ESourceList */*source_list*/, self->add_group (group); } +#endif +#if EDS_CHECK_VERSION(3,5,3) +void +Evolution::Source::add_source (ESource *source) +{ + EBook *ebook = NULL; + ebook = e_book_new (source, NULL); + BookPtr book (new Evolution::Book (services, ebook)); + g_object_unref (ebook); + add_book (book); +} +#else void Evolution::Source::add_group (ESourceGroup *group) { @@ -87,7 +116,19 @@ Evolution::Source::add_group (ESourceGroup *group) add_book (book); } } +#endif +#if EDS_CHECK_VERSION(3,5,3) +static void +on_registry_source_removed_c (ESourceRegistry */*registry*/, + ESource *source, + gpointer data) +{ + Evolution::Source *self = (Evolution::Source *)data; + if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) + self->remove_source (source); +} +#else static void on_source_list_group_removed_c (ESourceList */*source_list*/, ESourceGroup *group, @@ -99,12 +140,17 @@ on_source_list_group_removed_c (ESourceList */*source_list*/, self->remove_group (group); } +#endif class remove_helper { public : +#if EDS_CHECK_VERSION(3,5,3) + remove_helper (ESource* source_): source(source_) +#else remove_helper (ESourceGroup* group_): group(group_) +#endif { ready (); } inline void ready () @@ -117,12 +163,15 @@ public : EBook *book_ebook = book->get_ebook (); ESource *book_source = e_book_get_source (book_ebook); +#if EDS_CHECK_VERSION(3,5,3) + if (e_source_equal (source, book_source)) { +#else ESourceGroup *book_group = e_source_peek_group (book_source); if (book_group == group) { - - book->removed (); - found = true; +#endif + book->removed (); + found = true; } } @@ -133,14 +182,24 @@ public : { return found; } private: +#if EDS_CHECK_VERSION(3,5,3) + ESource* source; +#else ESourceGroup* group; +#endif bool found; }; void +#if EDS_CHECK_VERSION(3,5,3) +Evolution::Source::remove_source (ESource *source) +{ + remove_helper helper (source); +#else Evolution::Source::remove_group (ESourceGroup *group) { remove_helper helper (group); +#endif do { @@ -153,6 +212,36 @@ Evolution::Source::remove_group (ESourceGroup *group) Evolution::Source::Source (Ekiga::ServiceCore &_services) : services(_services) { +#if EDS_CHECK_VERSION(3,5,3) + GList *list, *link; + const gchar *extension_name; + GError *error = NULL; + + /* XXX This blocks. Should it be created asynchronously? */ + registry = e_source_registry_new_sync (NULL, &error); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + return; + } + + extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK; + list = e_source_registry_list_sources (registry, extension_name); + + for (link = list; link != NULL; link = g_list_next (link)) { + ESource *source = E_SOURCE (link->data); + add_source (source); + } + + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); + + g_signal_connect (registry, "source-added", + G_CALLBACK (on_registry_source_added_c), this); + g_signal_connect (registry, "source-removed", + G_CALLBACK (on_registry_source_removed_c), this); +#else GSList *groups = NULL; ESourceGroup *group = NULL; @@ -170,11 +259,16 @@ Evolution::Source::Source (Ekiga::ServiceCore &_services) G_CALLBACK (on_source_list_group_added_c), this); g_signal_connect (source_list, "group-removed", G_CALLBACK (on_source_list_group_removed_c), this); +#endif } Evolution::Source::~Source () { +#if EDS_CHECK_VERSION(3,5,3) + g_object_unref (registry); +#else g_object_unref (source_list); +#endif } bool diff --git a/plugins/evolution/evolution-source.h b/plugins/evolution/evolution-source.h index 43c7072..db90b57 100644 --- a/plugins/evolution/evolution-source.h +++ b/plugins/evolution/evolution-source.h @@ -38,7 +38,12 @@ #ifndef __EVOLUTION_SOURCE_H__ #define __EVOLUTION_SOURCE_H__ +#include <libedataserver/eds-version.h> +#if EDS_CHECK_VERSION(3,5,3) +#include <libebook/libebook.h> +#else #include <libebook/e-book.h> +#endif #include "contact-core.h" #include "source-impl.h" @@ -75,14 +80,22 @@ namespace Evolution /* those should be private, but need to be called from C */ +#if EDS_CHECK_VERSION(3,5,3) + void add_source (ESource *source); + void remove_source (ESource *source); +#else void add_group (ESourceGroup *group); - void remove_group (ESourceGroup *group); +#endif private: Ekiga::ServiceCore &services; +#if EDS_CHECK_VERSION(3,5,3) + ESourceRegistry *registry; +#else ESourceList *source_list; +#endif }; /** |