/pidgin/main: 82139d173179: Fix gevolution build with e-d-s >= 3...

Tomasz Wasilczyk twasilczyk at pidgin.im
Mon Feb 10 12:19:27 EST 2014


Changeset: 82139d17317943e83de26ba7560b4bb4e8e4912a
Author:	 Tomasz Wasilczyk <twasilczyk at pidgin.im>
Date:	 2014-02-10 18:19 +0100
Branch:	 default
URL: https://hg.pidgin.im/pidgin/main/rev/82139d173179

Description:

Fix gevolution build with e-d-s >= 3.6 and drop older versions. Fixes #15353

diffstat:

 ChangeLog                                    |    4 +-
 configure.ac                                 |   13 +--
 pidgin/plugins/gevolution/add_buddy_dialog.c |   12 +-
 pidgin/plugins/gevolution/assoc-buddy.c      |   12 +-
 pidgin/plugins/gevolution/eds-utils.c        |  112 +++++++++++---------------
 pidgin/plugins/gevolution/gevo-util.c        |   37 +++++++-
 pidgin/plugins/gevolution/gevolution.h       |   12 +-
 7 files changed, 96 insertions(+), 106 deletions(-)

diffs (truncated from 392 to 300 lines):

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,10 +8,12 @@ version 3.0.0 (??/??/????):
 	  support.  The default is 'auto', which will first look for 3.x
 	  development headers and then 2.x development headers.
 	* Add email notification in the docklet area. (Alexei) (#3571)
-	* Add a pref to select the type messages in conversation that triggers 
+	* Add a pref to select the type messages in conversation that triggers
 	  the docklet notification. (Momchil) (#12598)
 	* Complete support for receiving a limited amount of history when
 	  joining a room. (Kha) (#15458)
+	* Fix gevolution plugin to compile with e-d-s >= 3.6, older versions are
+	  not supported anymore. (#15353)
 
 	Finch:
 	* Support the conversation-extended signal for extending the
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -634,25 +634,14 @@ Use --disable-gtkspell if you do not nee
 	dnl # Check for stuff needed by the Evolution integration plugin.
 	dnl #######################################################################
 	if test "x$enable_gevolution" = "xyes"; then
-		evo_deps="libebook-1.2 libedata-book-1.2"
+		evo_deps="libebook-1.2 libedata-book-1.2 evolution-data-server-1.2 >= 3.6"
 		PKG_CHECK_MODULES(EVOLUTION_ADDRESSBOOK, $evo_deps, , [
 			enable_gevolution="no"
 		])
-		if test "x$enable_gevolution" = "xno"; then
-			evo_deps="libebook-1.0 libedata-book-1.0"
-			PKG_CHECK_MODULES(EVOLUTION_ADDRESSBOOK, $evo_deps, [
-				enable_gevolution="yes"
-			])
-		fi
 		if test "x$enable_gevolution" = "xyes"; then
 			AC_DEFINE(HAVE_EVOLUTION_ADDRESSBOOK, 1, [Define if we're using evolution addressbook.])
 			AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS)
 			AC_SUBST(EVOLUTION_ADDRESSBOOK_LIBS)
-
-			CPPFLAGS_save="$CPPFLAGS"
-			CPPFLAGS="$CPPFLAGS $EVOLUTION_ADDRESSBOOK_CFLAGS"
-			AC_CHECK_HEADER(libebook/libebook.h, [AC_DEFINE(HAVE_LIBEBOOK_H, 1, [Define if libebook is recent enough to contain libebook/libebook.h.])], [])
-			CPPFLAGS="$CPPFLAGS_save"
 		else
 			if test "x$force_deps" = "xyes" ; then
 				AC_MSG_ERROR([
diff --git a/pidgin/plugins/gevolution/add_buddy_dialog.c b/pidgin/plugins/gevolution/add_buddy_dialog.c
--- a/pidgin/plugins/gevolution/add_buddy_dialog.c
+++ b/pidgin/plugins/gevolution/add_buddy_dialog.c
@@ -227,7 +227,7 @@ add_ims(GevoAddBuddyDialog *dialog, ECon
 }
 
 static void
-populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uri)
+populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uid)
 {
 	EBookQuery *query;
 	EBook *book;
@@ -250,8 +250,7 @@ populate_treeview(GevoAddBuddyDialog *di
 
 	gtk_list_store_clear(dialog->model);
 
-	if (!gevo_load_addressbook(uri, &book, &err))
-	{
+	if (!gevo_load_addressbook(uid, &book, &err)) {
 		purple_debug_error("evolution",
 						 "Error retrieving default addressbook: %s\n", err->message);
 		g_error_free(err);
@@ -333,16 +332,15 @@ static void
 addrbook_change_cb(GtkComboBox *combo, GevoAddBuddyDialog *dialog)
 {
 	GtkTreeIter iter;
-	const char *esource_uri;
+	const char *esource_uid;
 
 	if (!gtk_combo_box_get_active_iter(combo, &iter))
 		return;
 
 	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
-					   ADDRBOOK_COLUMN_URI, &esource_uri,
-					   -1);
+		ADDRBOOK_COLUMN_UID, &esource_uid, -1);
 
-	populate_treeview(dialog, esource_uri);
+	populate_treeview(dialog, esource_uid);
 }
 
 static void
diff --git a/pidgin/plugins/gevolution/assoc-buddy.c b/pidgin/plugins/gevolution/assoc-buddy.c
--- a/pidgin/plugins/gevolution/assoc-buddy.c
+++ b/pidgin/plugins/gevolution/assoc-buddy.c
@@ -129,7 +129,7 @@ add_columns(GevoAssociateBuddyDialog *di
 }
 
 static void
-populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uri)
+populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uid)
 {
 	EBook *book;
 	EBookQuery *query;
@@ -152,8 +152,7 @@ populate_treeview(GevoAssociateBuddyDial
 
 	gtk_list_store_clear(dialog->model);
 
-	if (!gevo_load_addressbook(uri, &book, &err))
-	{
+	if (!gevo_load_addressbook(uid, &book, &err)) {
 		purple_debug_error("evolution",
 						 "Error retrieving addressbook: %s\n", err->message);
 		g_error_free(err);
@@ -239,16 +238,15 @@ static void
 addrbook_change_cb(GtkComboBox *combo, GevoAssociateBuddyDialog *dialog)
 {
 	GtkTreeIter iter;
-	const char *esource_uri;
+	const char *esource_uid;
 
 	if (!gtk_combo_box_get_active_iter(combo, &iter))
 		return;
 
 	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
-					   ADDRBOOK_COLUMN_URI, &esource_uri,
-					   -1);
+		ADDRBOOK_COLUMN_UID, &esource_uid, -1);
 
-	populate_treeview(dialog, esource_uri);
+	populate_treeview(dialog, esource_uid);
 }
 
 static void
diff --git a/pidgin/plugins/gevolution/eds-utils.c b/pidgin/plugins/gevolution/eds-utils.c
--- a/pidgin/plugins/gevolution/eds-utils.c
+++ b/pidgin/plugins/gevolution/eds-utils.c
@@ -51,9 +51,9 @@ gevo_addrbooks_model_unref(GtkTreeModel 
 void
 gevo_addrbooks_model_populate(GtkTreeModel *model)
 {
-	ESourceList *addressbooks;
+	ESourceRegistry *registry;
 	GError *err = NULL;
-	GSList *groups, *g;
+	GList *sources, *s;
 	GtkTreeIter iter;
 	GtkListStore *list;
 
@@ -62,66 +62,55 @@ gevo_addrbooks_model_populate(GtkTreeMod
 
 	list = GTK_LIST_STORE(model);
 
-	if (!e_book_get_addressbooks(&addressbooks, &err))
-	{
+	registry = e_source_registry_new_sync(NULL, &err);
+
+	if (!registry) {
 		purple_debug_error("evolution",
-						 "Unable to fetch list of address books.\n");
+			"Unable to fetch list of address books.");
 
 		gtk_list_store_append(list, &iter);
-		gtk_list_store_set(list, &iter,
-						   ADDRBOOK_COLUMN_NAME, _("None"),
-						   ADDRBOOK_COLUMN_URI,  NULL,
-						   -1);
+		gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, _("None"),
+			ADDRBOOK_COLUMN_UID, NULL, -1);
+
+		g_clear_error(&err);
+		return;
+	}
+
+	sources = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK);
+
+	if (sources == NULL) {
+		g_object_unref(registry);
+		gtk_list_store_append(list, &iter);
+		gtk_list_store_set(list, &iter, ADDRBOOK_COLUMN_NAME, _("None"),
+			ADDRBOOK_COLUMN_UID, NULL, -1);
 
 		return;
 	}
 
-	groups = e_source_list_peek_groups(addressbooks);
+	for (s = sources; s != NULL; s = s->next) {
+		ESource *source = E_SOURCE(s->data);
 
-	if (groups == NULL)
-	{
+		g_object_ref(source);
+
 		gtk_list_store_append(list, &iter);
 		gtk_list_store_set(list, &iter,
-						   ADDRBOOK_COLUMN_NAME, _("None"),
-						   ADDRBOOK_COLUMN_URI,  NULL,
-						   -1);
-
-		return;
+			ADDRBOOK_COLUMN_NAME, e_source_get_display_name(source),
+			ADDRBOOK_COLUMN_UID, e_source_get_uid(source), -1);
 	}
 
-	for (g = groups; g != NULL; g = g->next)
-	{
-		GSList *sources, *s;
-
-		sources = e_source_group_peek_sources(g->data);
-
-		for (s = sources; s != NULL; s = s->next)
-		{
-			ESource *source = E_SOURCE(s->data);
-
-			g_object_ref(source);
-
-			gtk_list_store_append(list, &iter);
-			gtk_list_store_set(list, &iter,
-							   ADDRBOOK_COLUMN_NAME, e_source_peek_name(source),
-							   ADDRBOOK_COLUMN_URI,  e_source_get_uri(source),
-							   -1);
-		}
-	}
-
-	g_object_unref(addressbooks);
+	g_object_unref(registry);
+	g_list_free_full(sources, g_object_unref);
 }
 
 static EContact *
-gevo_run_query_in_uri(const gchar *uri, EBookQuery *query)
+gevo_run_query_in_source(ESource *source, EBookQuery *query)
 {
 	EBook *book;
 	gboolean status;
 	GList *cards;
 	GError *err = NULL;
 
-	if (!gevo_load_addressbook(uri, &book, &err))
-	{
+	if (!gevo_load_addressbook_from_source(source, &book, &err)) {
 		purple_debug_error("evolution",
 						 "Error retrieving addressbook: %s\n", err->message);
 		g_error_free(err);
@@ -171,10 +160,10 @@ gevo_run_query_in_uri(const gchar *uri, 
 EContact *
 gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query)
 {
-	ESourceList *addressbooks;
+	ESourceRegistry *registry;
 	GError *err = NULL;
 	EBookQuery *full_query;
-	GSList *groups, *g;
+	GList *sources, *s;
 	EContact *result;
 	EContactField protocol_field =
 		gevo_prpl_get_field(purple_buddy_get_account(buddy), buddy);
@@ -209,8 +198,9 @@ gevo_search_buddy_in_contacts(PurpleBudd
 		}
 	}
 
-	if (!e_book_get_addressbooks(&addressbooks, &err))
-	{
+	registry = e_source_registry_new_sync(NULL, &err);
+
+	if (!registry) {
 		purple_debug_error("evolution",
 						 "Unable to fetch list of address books.\n");
 		e_book_query_unref(full_query);
@@ -219,30 +209,22 @@ gevo_search_buddy_in_contacts(PurpleBudd
 		return NULL;
 	}
 
-	groups = e_source_list_peek_groups(addressbooks);
-	if (groups == NULL)
-	{
-		g_object_unref(addressbooks);
-		e_book_query_unref(full_query);
-		return NULL;
-	}
+	sources = e_source_registry_list_sources(registry,
+		E_SOURCE_EXTENSION_ADDRESS_BOOK);
 
-	for (g = groups; g != NULL; g = g->next)
-	{
-		GSList *sources, *s;
-		sources = e_source_group_peek_sources(g->data);
-		for (s = sources; s != NULL; s = s->next)
-		{
-			result = gevo_run_query_in_uri(e_source_get_uri(E_SOURCE(s->data)), full_query);
-			if (result != NULL) {
-			    g_object_unref(addressbooks);
-				e_book_query_unref(full_query);
-			    return result;
-			}
+	for (s = sources; s != NULL; s = s->next) {
+		result = gevo_run_query_in_source(E_SOURCE(s->data),
+			full_query);
+		if (result != NULL) {
+			g_object_unref(registry);
+			g_list_free_full(sources, g_object_unref);
+			e_book_query_unref(full_query);
+			return result;



More information about the Commits mailing list