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 |
} |