pidgin/pidgin

Fix the gevolution plugin.
release-2.x.y
7 months ago, Gary Kramlich
a2a16969a8fa
Parents a3d5a106c3dc
Children 132d17234930
Fix the gevolution plugin.

This pulls the patches from PIDGIN-15353 (Ed Catmur) and
https://bugs.gentoo.org/526644 (Lars Wendler) to fix everything.

Testing Done:
Loaded the plugin and verified that configuration worked. I don't have any good accounts to actually sync with evolution so I didn't try that part but gentoo has been carrying the patch from PIDGIN-15353 for very long time.

Bugs closed: PIDGIN-15353

Reviewed at https://reviews.imfreedom.org/r/610/
--- a/COPYRIGHT Fri Apr 09 23:53:08 2021 -0500
+++ b/COPYRIGHT Fri Apr 09 23:53:13 2021 -0500
@@ -98,6 +98,7 @@
Michael Carlson
Rodrigo Tobar Carrizo
Keegan Carruthers-Smith
+Ed Catmur
Ludovico Cavedon
Steve Cavilia
Julien Cegarra
--- a/configure.ac Fri Apr 09 23:53:08 2021 -0500
+++ b/configure.ac Fri Apr 09 23:53:13 2021 -0500
@@ -355,7 +355,7 @@
AC_ARG_ENABLE(gevolution,
[AC_HELP_STRING([--enable-gevolution],
[compile with the Evolution plugin])],
- enable_gevolution="$enableval", enable_gevolution="no")
+ enable_gevolution="$enableval", enable_gevolution="yes")
AC_ARG_ENABLE(cap,
[AC_HELP_STRING([--enable-cap],
[compile with Contact Availability Prediction plugin])],
@@ -529,18 +529,10 @@
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 evolution-data-server-1.2 < 3.6"
+ 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"
- ], [
- enable_gevolution="no"
- ])
- 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)
@@ -548,7 +540,7 @@
else
if test "x$force_deps" = "xyes" ; then
AC_MSG_ERROR([
-Evolution development headers not found (libebook, libedata-book, evolution-data-server < 3.6).
+Evolution development headers not found (libebook, libedata-book, evolution-data-server >= 3.6).
Use --disable-gevolution if you do not need it.
])
fi
--- a/pidgin/plugins/gevolution/add_buddy_dialog.c Fri Apr 09 23:53:08 2021 -0500
+++ b/pidgin/plugins/gevolution/add_buddy_dialog.c Fri Apr 09 23:53:13 2021 -0500
@@ -227,8 +227,7 @@
}
static void
-populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uri)
-{
+populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uid) {
EBookQuery *query;
EBook *book;
gboolean status;
@@ -250,8 +249,7 @@
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);
@@ -328,16 +326,17 @@
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))
+ 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
--- a/pidgin/plugins/gevolution/assoc-buddy.c Fri Apr 09 23:53:08 2021 -0500
+++ b/pidgin/plugins/gevolution/assoc-buddy.c Fri Apr 09 23:53:13 2021 -0500
@@ -130,8 +130,7 @@
}
static void
-populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uri)
-{
+populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uid) {
EBook *book;
EBookQuery *query;
const char *prpl_id;
@@ -154,8 +153,7 @@
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);
@@ -241,16 +239,17 @@
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))
+ 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
--- a/pidgin/plugins/gevolution/eds-utils.c Fri Apr 09 23:53:08 2021 -0500
+++ b/pidgin/plugins/gevolution/eds-utils.c Fri Apr 09 23:53:13 2021 -0500
@@ -52,9 +52,9 @@
void
gevo_addrbooks_model_populate(GtkTreeModel *model)
{
- ESourceList *addressbooks;
+ ESourceRegistry *registry;
GError *err = NULL;
- GSList *groups, *g;
+ GList *sources, *s;
GtkTreeIter iter;
GtkListStore *list;
@@ -63,89 +63,81 @@
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.\n");
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, _("None"),
+ ADDRBOOK_COLUMN_UID, NULL,
+ -1);
- groups = e_source_list_peek_groups(addressbooks);
-
- if (groups == NULL)
- {
- gtk_list_store_append(list, &iter);
- gtk_list_store_set(list, &iter,
- ADDRBOOK_COLUMN_NAME, _("None"),
- ADDRBOOK_COLUMN_URI, NULL,
- -1);
+ g_clear_error(&err);
return;
}
- for (g = groups; g != NULL; g = g->next)
- {
- GSList *sources, *s;
-
- sources = e_source_group_peek_sources(g->data);
+ sources = e_source_registry_list_sources(registry,
+ E_SOURCE_EXTENSION_ADDRESS_BOOK);
- for (s = sources; s != NULL; s = s->next)
- {
- ESource *source = E_SOURCE(s->data);
-
- g_object_ref(source);
+ 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);
- 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);
- }
+ return;
}
- g_object_unref(addressbooks);
+ 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_get_display_name(source),
+ ADDRBOOK_COLUMN_UID, e_source_get_uid(source),
+ -1);
+ }
+
+ 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);
+ "Error retrieving addressbook: %s\n", err->message);
g_error_free(err);
return NULL;
}
status = e_book_get_contacts(book, query, &cards, NULL);
- if (!status)
- {
+ if(!status) {
purple_debug_error("evolution", "Error %d in getting card list\n",
- status);
+ status);
g_object_unref(book);
return NULL;
}
g_object_unref(book);
- if (cards != NULL)
- {
+ if(cards != NULL) {
EContact *contact = E_CONTACT(cards->data);
GList *cards2 = cards->next;
- if (cards2 != NULL)
- {
+ if(cards2 != NULL) {
/* Break off the first contact and free the rest. */
cards->next = NULL;
cards2->prev = NULL;
@@ -172,75 +164,63 @@
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(buddy->account, buddy);
- if (protocol_field == 0)
+ if(protocol_field == 0) {
return NULL;
+ }
- if (query != NULL)
- {
+ if(query != NULL) {
EBookQuery *queries[2];
queries[0] = query;
queries[1] = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, buddy->name);
- if (queries[1] == NULL)
- {
+ if(queries[1] == NULL) {
purple_debug_error("evolution", "Error in creating protocol query\n");
e_book_query_unref(query);
return NULL;
}
full_query = e_book_query_and(2, queries, TRUE);
- }
- else
- {
+ } else {
full_query = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, buddy->name);
- if (full_query == NULL)
- {
+ if(full_query == NULL) {
purple_debug_error("evolution", "Error in creating protocol query\n");
return NULL;
}
}
- 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.\n");
e_book_query_unref(full_query);
- if (err != NULL)
+ if(err != NULL) {
g_error_free(err);
- return NULL;
- }
-
- groups = e_source_list_peek_groups(addressbooks);
- if (groups == NULL)
- {
- g_object_unref(addressbooks);
- e_book_query_unref(full_query);
+ }
return NULL;
}
- 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;
- }
+ sources = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK);
+
+ 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;
}
}
- g_object_unref(addressbooks);
+ g_object_unref(registry);
+ g_list_free_full(sources, g_object_unref);
e_book_query_unref(full_query);
return NULL;
}
--- a/pidgin/plugins/gevolution/gevo-util.c Fri Apr 09 23:53:08 2021 -0500
+++ b/pidgin/plugins/gevolution/gevo-util.c Fri Apr 09 23:53:13 2021 -0500
@@ -120,26 +120,51 @@
}
gboolean
-gevo_load_addressbook(const gchar* uri, EBook **book, GError **error)
-{
+gevo_load_addressbook(const gchar* uid, EBook **book, GError **error) {
gboolean result = FALSE;
+ ESourceRegistry *registry;
+ ESource *source;
g_return_val_if_fail(book != NULL, FALSE);
- if (uri == NULL)
- *book = e_book_new_system_addressbook(error);
- else
- *book = e_book_new_from_uri(uri, error);
+ registry = e_source_registry_new_sync(NULL, error);
+
+ if(!registry) {
+ return FALSE;
+ }
+
+ if(uid == NULL) {
+ source = e_source_registry_ref_default_address_book(registry);
+ } else {
+ source = e_source_registry_ref_source(registry, uid);
+ }
+
+ g_object_unref(registry);
+
+ result = gevo_load_addressbook_from_source(source, book, error);
- if (*book == NULL)
+ g_object_unref(source);
+
+ return result;
+}
+
+gboolean
+gevo_load_addressbook_from_source(ESource *source, EBook **book,
+ GError **error)
+{
+ gboolean result = FALSE;
+
+ *book = e_book_new(source, error);
+
+ if(*book == NULL) {
return FALSE;
+ }
*error = NULL;
result = e_book_open(*book, FALSE, error);
- if (!result && *book != NULL)
- {
+ if(!result && *book != NULL) {
g_object_unref(*book);
*book = NULL;
}
--- a/pidgin/plugins/gevolution/gevolution.h Fri Apr 09 23:53:08 2021 -0500
+++ b/pidgin/plugins/gevolution/gevolution.h Fri Apr 09 23:53:13 2021 -0500
@@ -25,12 +25,12 @@
# include "config.h"
#endif
-#include <libebook/e-book.h>
+#include <libebook/libebook.h>
enum
{
ADDRBOOK_COLUMN_NAME,
- ADDRBOOK_COLUMN_URI,
+ ADDRBOOK_COLUMN_UID,
NUM_ADDRBOOK_COLUMNS
};
@@ -123,7 +123,8 @@
EContactField gevo_prpl_get_field(PurpleAccount *account, PurpleBuddy *buddy);
gboolean gevo_prpl_is_supported(PurpleAccount *account, PurpleBuddy *buddy);
-gboolean gevo_load_addressbook(const gchar *uri, EBook **book, GError **error);
+gboolean gevo_load_addressbook(const gchar *uid, EBook **book, GError **error);
+gboolean gevo_load_addressbook_from_source(ESource *source, EBook **book, GError **error);
char *gevo_get_email_for_buddy(PurpleBuddy *buddy);
GevoAssociateBuddyDialog *gevo_associate_buddy_dialog_new(PurpleBuddy *buddy);