static void
print_all_emails (EBook *book)
{
	EBookQuery *query;

	query = e_book_query_field_exists (E_CONTACT_FULL_NAME);

	e_book_get_contacts_async (book, query, print_all_emails_cb, NULL);

	e_book_query_unref (query);
}
Example #2
0
int phonebook_pull_read(void *request)
{
	struct query_context *data = request;
	GSList *l;

	if (!data)
		return -ENOENT;

	for (l = data->ebooks; l != NULL; l = g_slist_next(l)) {
		EBook *ebook = l->data;

		if (e_book_is_opened(ebook) == FALSE)
			continue;

		if (e_book_get_contacts_async(ebook, data->query,
						ebookpull_cb, data) == TRUE)
			data->queued_calls++;
	}

	if (data->queued_calls == 0)
		return -ENOENT;

	return 0;
}
Example #3
0
void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
		phonebook_cache_ready_cb ready_cb, void *user_data, int *err)
{
	struct query_context *data;
	EBookQuery *query;
	GSList *l;
	EContact *me;
	EVCard *evcard;
	GError *gerr = NULL;
	EBook *eb;
	EVCardAttribute *attrib;
	char *uid, *tel, *cname;

	if (g_strcmp0(PB_CONTACTS_FOLDER, name) != 0) {
		if (err)
			*err = -ENOENT;

		return NULL;
	}

	DBG("");

	query = e_book_query_any_field_contains("");

	data = g_new0(struct query_context, 1);
	data->entry_cb = entry_cb;
	data->ready_cb = ready_cb;
	data->user_data = user_data;
	data->query = query;
	data->ebooks = open_ebooks();

	/* Add 0.vcf */
	if (e_book_get_self(&me, &eb, &gerr) == FALSE) {
		g_error_free(gerr);
		goto next;
	}

	evcard = E_VCARD(me);

	cname = evcard_name_attribute_to_string(evcard);
	if (!cname)
		cname = g_strdup("");

	attrib = e_vcard_get_attribute(evcard, EVC_UID);
	uid = e_vcard_attribute_get_value(attrib);
	if (!uid)
		uid = g_strdup("");

	attrib = e_vcard_get_attribute(evcard, EVC_TEL);
	if (attrib)
		tel =  e_vcard_attribute_get_value(attrib);
	else
		tel = g_strdup("");

	data->entry_cb(uid, 0, cname, NULL, tel, data->user_data);

	data->count++;

	g_free(cname);
	g_free(uid);
	g_free(tel);
	g_object_unref(eb);

next:
	for (l = data->ebooks; l != NULL; l = g_slist_next(l)) {
		EBook *ebook = l->data;

		if (e_book_is_opened(ebook) == FALSE)
			continue;

		if (e_book_get_contacts_async(ebook, query,
						cache_cb, data) == TRUE)
			data->queued_calls++;
	}

	if (err)
		*err = (data->queued_calls == 0 ? -ENOENT : 0);

	return data;
}