Example #1
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;
	gboolean ret;

	if (g_strcmp0("/telecom/pb", name) != 0) {
		if (err)
			*err = -ENOENT;
		return NULL;
	}

	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;

	ret = e_book_async_get_contacts(ebook, query, cache_cb, data);
	e_book_query_unref(query);
	if (ret != FALSE) {
		g_free(data);
		if (err)
			*err = -EFAULT;
		return NULL;
	}

	if (err)
		*err = 0;

	return data;
}
Example #2
0
static void
eds_receive_book_cb (EBook         *client,
		     EBookStatus    status,
		     gpointer       user_data)
{
	PlannerPlugin *plugin;
	EBookQuery    *query;
	AsyncQuery    *async_query;
	const gchar   *search;
	const gchar   *uid;
	const gchar   *book_uri;
	GtkListStore  *model;

	async_query = user_data;
	plugin = async_query->plugin;
	search = async_query->search;
	uid = async_query->uid;
	model = GTK_LIST_STORE (plugin->priv->resources_model);

	gtk_list_store_clear (model);
	g_free (async_query);

	book_uri = e_book_get_uri (client);

	if (eds_query_cancelled (plugin, uid)) {
		g_message ("Open book query cancelled: %s (%s)", book_uri, uid);
		gtk_widget_set_sensitive (glade_xml_get_widget (plugin->priv->glade,
								"search_box"), TRUE);
		eds_plugin_busy (plugin, FALSE);
		return;
	}

	if (status != E_BOOK_ERROR_OK) {
		g_warning ("Problems opening: %s", book_uri);
		gtk_widget_set_sensitive (glade_xml_get_widget (plugin->priv->glade,
								"search_box"), TRUE);
		eds_plugin_busy (plugin, FALSE);
		return;
	}

	g_message ("Looking the book: %s", book_uri);
	plugin->priv->books = g_list_append (plugin->priv->books, client);

	async_query = g_new0 (AsyncQuery, 1);
	g_free (plugin->priv->current_query_id);
	plugin->priv->current_query_id = e_uid_new ();
	async_query->uid = plugin->priv->current_query_id;
	async_query->plugin = plugin;

	query = e_book_query_any_field_contains (search);
	e_book_async_get_contacts (client, query,
				   eds_receive_contacts_cb,
				   (gpointer) async_query);

	eds_plugin_busy (plugin, TRUE);
	e_book_query_unref (query);
}
Example #3
0
int phonebook_pull_read(void *request)
{
	struct query_context *data = request;
	EBookQuery *query;

	if (!data)
		return -ENOENT;

	query = e_book_query_any_field_contains("");
	e_book_async_get_contacts(ebook, query, ebookpull_cb, data);

	e_book_query_unref(query);

	return 0;
}