Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 434212
Collapse All | Expand All

(-)a/pidgin/plugins/gevolution/add_buddy_dialog.c (-5 / +5 lines)
Lines 227-233 add_ims(GevoAddBuddyDialog *dialog, EContact *contact, const char *name, Link Here
227
}
227
}
228
228
229
static void
229
static void
230
populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uri)
230
populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uid)
231
{
231
{
232
	EBookQuery *query;
232
	EBookQuery *query;
233
	EBook *book;
233
	EBook *book;
Lines 250-256 populate_treeview(GevoAddBuddyDialog *dialog, const gchar *uri) Link Here
250
250
251
	gtk_list_store_clear(dialog->model);
251
	gtk_list_store_clear(dialog->model);
252
252
253
	if (!gevo_load_addressbook(uri, &book, &err))
253
	if (!gevo_load_addressbook(uid, &book, &err))
254
	{
254
	{
255
		purple_debug_error("evolution",
255
		purple_debug_error("evolution",
256
						 "Error retrieving default addressbook: %s\n", err->message);
256
						 "Error retrieving default addressbook: %s\n", err->message);
Lines 333-348 static void Link Here
333
addrbook_change_cb(GtkComboBox *combo, GevoAddBuddyDialog *dialog)
333
addrbook_change_cb(GtkComboBox *combo, GevoAddBuddyDialog *dialog)
334
{
334
{
335
	GtkTreeIter iter;
335
	GtkTreeIter iter;
336
	const char *esource_uri;
336
	const char *esource_uid;
337
337
338
	if (!gtk_combo_box_get_active_iter(combo, &iter))
338
	if (!gtk_combo_box_get_active_iter(combo, &iter))
339
		return;
339
		return;
340
340
341
	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
341
	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
342
					   ADDRBOOK_COLUMN_URI, &esource_uri,
342
					   ADDRBOOK_COLUMN_UID, &esource_uid,
343
					   -1);
343
					   -1);
344
344
345
	populate_treeview(dialog, esource_uri);
345
	populate_treeview(dialog, esource_uid);
346
}
346
}
347
347
348
static void
348
static void
(-)a/pidgin/plugins/gevolution/assoc-buddy.c (-5 / +5 lines)
Lines 130-136 add_columns(GevoAssociateBuddyDialog *dialog) Link Here
130
}
130
}
131
131
132
static void
132
static void
133
populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uri)
133
populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uid)
134
{
134
{
135
	EBook *book;
135
	EBook *book;
136
	EBookQuery *query;
136
	EBookQuery *query;
Lines 154-160 populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uri) Link Here
154
154
155
	gtk_list_store_clear(dialog->model);
155
	gtk_list_store_clear(dialog->model);
156
156
157
	if (!gevo_load_addressbook(uri, &book, &err))
157
	if (!gevo_load_addressbook(uid, &book, &err))
158
	{
158
	{
159
		purple_debug_error("evolution",
159
		purple_debug_error("evolution",
160
						 "Error retrieving addressbook: %s\n", err->message);
160
						 "Error retrieving addressbook: %s\n", err->message);
Lines 241-256 static void Link Here
241
addrbook_change_cb(GtkComboBox *combo, GevoAssociateBuddyDialog *dialog)
241
addrbook_change_cb(GtkComboBox *combo, GevoAssociateBuddyDialog *dialog)
242
{
242
{
243
	GtkTreeIter iter;
243
	GtkTreeIter iter;
244
	const char *esource_uri;
244
	const char *esource_uid;
245
245
246
	if (!gtk_combo_box_get_active_iter(combo, &iter))
246
	if (!gtk_combo_box_get_active_iter(combo, &iter))
247
		return;
247
		return;
248
248
249
	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
249
	gtk_tree_model_get(GTK_TREE_MODEL(dialog->addrbooks), &iter,
250
					   ADDRBOOK_COLUMN_URI, &esource_uri,
250
					   ADDRBOOK_COLUMN_UID, &esource_uid,
251
					   -1);
251
					   -1);
252
252
253
	populate_treeview(dialog, esource_uri);
253
	populate_treeview(dialog, esource_uid);
254
}
254
}
255
255
256
static void
256
static void
(-)a/pidgin/plugins/gevolution/eds-utils.c (-47 / +38 lines)
Lines 52-60 gevo_addrbooks_model_unref(GtkTreeModel *model) Link Here
52
void
52
void
53
gevo_addrbooks_model_populate(GtkTreeModel *model)
53
gevo_addrbooks_model_populate(GtkTreeModel *model)
54
{
54
{
55
	ESourceList *addressbooks;
55
	ESourceRegistry *registry;
56
	GError *err = NULL;
56
	GError *err = NULL;
57
	GSList *groups, *g;
57
	GList *sources, *s;
58
	GtkTreeIter iter;
58
	GtkTreeIter iter;
59
	GtkListStore *list;
59
	GtkListStore *list;
60
60
Lines 63-69 gevo_addrbooks_model_populate(GtkTreeModel *model) Link Here
63
63
64
	list = GTK_LIST_STORE(model);
64
	list = GTK_LIST_STORE(model);
65
65
66
	if (!e_book_get_addressbooks(&addressbooks, &err))
66
	registry = e_source_registry_new_sync(NULL, &err);
67
68
	if (!registry)
67
	{
69
	{
68
		purple_debug_error("evolution",
70
		purple_debug_error("evolution",
69
						 "Unable to fetch list of address books.\n");
71
						 "Unable to fetch list of address books.\n");
Lines 71-127 gevo_addrbooks_model_populate(GtkTreeModel *model) Link Here
71
		gtk_list_store_append(list, &iter);
73
		gtk_list_store_append(list, &iter);
72
		gtk_list_store_set(list, &iter,
74
		gtk_list_store_set(list, &iter,
73
						   ADDRBOOK_COLUMN_NAME, _("None"),
75
						   ADDRBOOK_COLUMN_NAME, _("None"),
74
						   ADDRBOOK_COLUMN_URI,  NULL,
76
						   ADDRBOOK_COLUMN_UID,  NULL,
75
						   -1);
77
						   -1);
76
78
79
		g_clear_error(&err);
77
		return;
80
		return;
78
	}
81
	}
79
82
80
	groups = e_source_list_peek_groups(addressbooks);
83
	sources = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK);
81
84
82
	if (groups == NULL)
85
	if (sources == NULL)
83
	{
86
	{
87
		g_object_unref(registry);
84
		gtk_list_store_append(list, &iter);
88
		gtk_list_store_append(list, &iter);
85
		gtk_list_store_set(list, &iter,
89
		gtk_list_store_set(list, &iter,
86
						   ADDRBOOK_COLUMN_NAME, _("None"),
90
						   ADDRBOOK_COLUMN_NAME, _("None"),
87
						   ADDRBOOK_COLUMN_URI,  NULL,
91
						   ADDRBOOK_COLUMN_UID,  NULL,
88
						   -1);
92
						   -1);
89
93
90
		return;
94
		return;
91
	}
95
	}
92
96
93
	for (g = groups; g != NULL; g = g->next)
97
	for (s = sources; s != NULL; s = s->next)
94
	{
98
	{
95
		GSList *sources, *s;
99
		ESource *source = E_SOURCE(s->data);
96
97
		sources = e_source_group_peek_sources(g->data);
98
99
		for (s = sources; s != NULL; s = s->next)
100
		{
101
			ESource *source = E_SOURCE(s->data);
102
100
103
			g_object_ref(source);
101
		g_object_ref(source);
104
102
105
			gtk_list_store_append(list, &iter);
103
		gtk_list_store_append(list, &iter);
106
			gtk_list_store_set(list, &iter,
104
		gtk_list_store_set(list, &iter,
107
							   ADDRBOOK_COLUMN_NAME, e_source_peek_name(source),
105
						   ADDRBOOK_COLUMN_NAME, e_source_get_display_name(source),
108
							   ADDRBOOK_COLUMN_URI,  e_source_get_uri(source),
106
						   ADDRBOOK_COLUMN_UID,  e_source_get_uid(source),
109
							   -1);
107
						   -1);
110
		}
111
	}
108
	}
112
109
113
	g_object_unref(addressbooks);
110
	g_object_unref(registry);
111
	g_list_free_full(sources, g_object_unref);
114
}
112
}
115
113
116
static EContact *
114
static EContact *
117
gevo_run_query_in_uri(const gchar *uri, EBookQuery *query)
115
gevo_run_query_in_source(ESource *source, EBookQuery *query)
118
{
116
{
119
	EBook *book;
117
	EBook *book;
120
	gboolean status;
118
	gboolean status;
121
	GList *cards;
119
	GList *cards;
122
	GError *err = NULL;
120
	GError *err = NULL;
123
121
124
	if (!gevo_load_addressbook(uri, &book, &err))
122
	if (!gevo_load_addressbook_from_source(source, &book, &err))
125
	{
123
	{
126
		purple_debug_error("evolution",
124
		purple_debug_error("evolution",
127
						 "Error retrieving addressbook: %s\n", err->message);
125
						 "Error retrieving addressbook: %s\n", err->message);
Lines 172-181 gevo_run_query_in_uri(const gchar *uri, EBookQuery *query) Link Here
172
EContact *
170
EContact *
173
gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query)
171
gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query)
174
{
172
{
175
	ESourceList *addressbooks;
173
	ESourceRegistry *registry;
176
	GError *err = NULL;
174
	GError *err = NULL;
177
	EBookQuery *full_query;
175
	EBookQuery *full_query;
178
	GSList *groups, *g;
176
	GList *sources, *s;
179
	EContact *result;
177
	EContact *result;
180
	EContactField protocol_field = gevo_prpl_get_field(buddy->account, buddy);
178
	EContactField protocol_field = gevo_prpl_get_field(buddy->account, buddy);
181
179
Lines 207-213 gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query) Link Here
207
		}
205
		}
208
	}
206
	}
209
207
210
	if (!e_book_get_addressbooks(&addressbooks, &err))
208
	registry = e_source_registry_new_sync(NULL, &err);
209
210
	if (!registry)
211
	{
211
	{
212
		purple_debug_error("evolution",
212
		purple_debug_error("evolution",
213
						 "Unable to fetch list of address books.\n");
213
						 "Unable to fetch list of address books.\n");
Lines 217-246 gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query) Link Here
217
		return NULL;
217
		return NULL;
218
	}
218
	}
219
219
220
	groups = e_source_list_peek_groups(addressbooks);
220
	sources = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK);
221
	if (groups == NULL)
222
	{
223
		g_object_unref(addressbooks);
224
		e_book_query_unref(full_query);
225
		return NULL;
226
	}
227
221
228
	for (g = groups; g != NULL; g = g->next)
222
	for (s = sources; s != NULL; s = s->next)
229
	{
223
	{
230
		GSList *sources, *s;
224
		result = gevo_run_query_in_source(E_SOURCE(s->data), full_query);
231
		sources = e_source_group_peek_sources(g->data);
225
		if (result != NULL) {
232
		for (s = sources; s != NULL; s = s->next)
226
		    g_object_unref(registry);
233
		{
227
		    g_list_free_full(sources, g_object_unref);
234
			result = gevo_run_query_in_uri(e_source_get_uri(E_SOURCE(s->data)), full_query);
228
			e_book_query_unref(full_query);
235
			if (result != NULL) {
229
		    return result;
236
			    g_object_unref(addressbooks);
237
				e_book_query_unref(full_query);
238
			    return result;
239
			}
240
		}
230
		}
241
	}
231
	}
242
232
243
	g_object_unref(addressbooks);
233
	g_object_unref(registry);
234
	g_list_free_full(sources, g_object_unref);
244
	e_book_query_unref(full_query);
235
	e_book_query_unref(full_query);
245
	return NULL;
236
	return NULL;
246
}
237
}
(-)a/pidgin/plugins/gevolution/gevo-util.c (-4 / +27 lines)
Lines 124-139 gevo_prpl_is_supported(PurpleAccount *account, PurpleBuddy *buddy) Link Here
124
}
124
}
125
125
126
gboolean
126
gboolean
127
gevo_load_addressbook(const gchar* uri, EBook **book, GError **error)
127
gevo_load_addressbook(const gchar* uid, EBook **book, GError **error)
128
{
128
{
129
	gboolean result = FALSE;
129
	gboolean result = FALSE;
130
	ESourceRegistry *registry;
131
	ESource *source;
130
132
131
	g_return_val_if_fail(book != NULL, FALSE);
133
	g_return_val_if_fail(book != NULL, FALSE);
132
134
133
	if (uri == NULL)
135
	registry = e_source_registry_new_sync(NULL, error);
134
		*book = e_book_new_system_addressbook(error);
136
137
	if (!registry)
138
	    return FALSE;
139
140
	if (uid == NULL)
141
		source = e_source_registry_ref_default_address_book(registry);
135
	else
142
	else
136
		*book = e_book_new_from_uri(uri, error);
143
		source = e_source_registry_ref_source(registry, uid);
144
145
	g_object_unref(registry);
146
147
	result = gevo_load_addressbook_from_source(source, book, error);
148
149
	g_object_unref(source);
150
151
	return result;
152
}
153
154
gboolean
155
gevo_load_addressbook_from_source(ESource *source, EBook **book, GError **error)
156
{
157
	gboolean result = FALSE;
158
159
	*book = e_book_new(source, error);
137
160
138
	if (*book == NULL)
161
	if (*book == NULL)
139
		return FALSE;
162
		return FALSE;
(-)a/pidgin/plugins/gevolution/gevolution.h (-3 / +5 lines)
Lines 25-36 Link Here
25
# include "config.h"
25
# include "config.h"
26
#endif
26
#endif
27
27
28
#include <libebook/e-book.h>
28
#include <libebook/libebook.h>
29
29
30
enum
30
enum
31
{
31
{
32
	ADDRBOOK_COLUMN_NAME,
32
	ADDRBOOK_COLUMN_NAME,
33
	ADDRBOOK_COLUMN_URI,
33
	ADDRBOOK_COLUMN_UID,
34
	NUM_ADDRBOOK_COLUMNS
34
	NUM_ADDRBOOK_COLUMNS
35
};
35
};
36
36
Lines 123-129 GList *gevo_get_groups(void); Link Here
123
123
124
EContactField gevo_prpl_get_field(PurpleAccount *account, PurpleBuddy *buddy);
124
EContactField gevo_prpl_get_field(PurpleAccount *account, PurpleBuddy *buddy);
125
gboolean gevo_prpl_is_supported(PurpleAccount *account, PurpleBuddy *buddy);
125
gboolean gevo_prpl_is_supported(PurpleAccount *account, PurpleBuddy *buddy);
126
gboolean gevo_load_addressbook(const gchar *uri, EBook **book, GError **error);
126
gboolean gevo_load_addressbook(const gchar *uid, EBook **book, GError **error);
127
gboolean gevo_load_addressbook_from_source(ESource *source, EBook **book,
128
										   GError **error);
127
char *gevo_get_email_for_buddy(PurpleBuddy *buddy);
129
char *gevo_get_email_for_buddy(PurpleBuddy *buddy);
128
130
129
GevoAssociateBuddyDialog *gevo_associate_buddy_dialog_new(PurpleBuddy *buddy);
131
GevoAssociateBuddyDialog *gevo_associate_buddy_dialog_new(PurpleBuddy *buddy);

Return to bug 434212