Linux bluetooth development
 help / color / mirror / Atom feed
From: Dmitriy Paliy <dmitriy.paliy@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Dmitriy Paliy <dmitriy.paliy@nokia.com>
Subject: [PATCH 1/3 v3] Unified ebook data structures
Date: Wed,  8 Dec 2010 23:15:54 +0200	[thread overview]
Message-ID: <1291842956-8610-2-git-send-email-dmitriy.paliy@nokia.com> (raw)
In-Reply-To: <1291842956-8610-1-git-send-email-dmitriy.paliy@nokia.com>

Query data structures are unified in phonebook-ebook.c to have a
unique identifier for ebook async operation. Purpose of this
modification is next commit where pending async operation can be
cancelled.
---
 plugins/phonebook-ebook.c |   36 ++++++++++++++++--------------------
 1 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/plugins/phonebook-ebook.c b/plugins/phonebook-ebook.c
index 073ff33..b9d297a 100644
--- a/plugins/phonebook-ebook.c
+++ b/plugins/phonebook-ebook.c
@@ -45,13 +45,9 @@
 #define QUERY_NAME "(contains \"given_name\" \"%s\")"
 #define QUERY_PHONE "(contains \"phone\" \"%s\")"
 
-struct contacts_query {
+struct context_query {
 	const struct apparam_field *params;
-	phonebook_cb cb;
-	void *user_data;
-};
-
-struct cache_query {
+	phonebook_cb contacts_cb;
 	phonebook_entry_cb entry_cb;
 	phonebook_cache_ready_cb ready_cb;
 	void *user_data;
@@ -141,7 +137,7 @@ static char *evcard_to_string(EVCard *evcard, unsigned int format,
 static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts,
 							void *user_data)
 {
-	struct contacts_query *data = user_data;
+	struct context_query *data = user_data;
 	GString *string = g_string_new("");
 	unsigned int count = 0, maxcount;
 	GList *l;
@@ -182,7 +178,7 @@ static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts,
 
 
 done:
-	data->cb(string->str, string->len, count, 0, data->user_data);
+	data->contacts_cb(string->str, string->len, count, 0, data->user_data);
 
 	g_string_free(string, TRUE);
 	g_free(data);
@@ -191,14 +187,14 @@ done:
 static void ebook_entry_cb(EBook *book, EBookStatus estatus,
 			EContact *contact, void *user_data)
 {
-	struct contacts_query *data = user_data;
+	struct context_query *data = user_data;
 	EVCard *evcard;
 	char *vcard;
 	size_t len;
 
 	if (estatus != E_BOOK_ERROR_OK) {
 		error("E-Book query failed: status %d", estatus);
-		data->cb(NULL, 0, 1, 0, data->user_data);
+		data->contacts_cb(NULL, 0, 1, 0, data->user_data);
 		g_free(data);
 		return;
 	}
@@ -210,7 +206,7 @@ static void ebook_entry_cb(EBook *book, EBookStatus estatus,
 
 	len = vcard ? strlen(vcard) : 0;
 
-	data->cb(vcard, len, 1, 0, data->user_data);
+	data->contacts_cb(vcard, len, 1, 0, data->user_data);
 
 	g_free(vcard);
 	g_free(data);
@@ -249,7 +245,7 @@ static char *evcard_name_attribute_to_string(EVCard *evcard)
 static void cache_cb(EBook *book, EBookStatus estatus, GList *contacts,
 							void *user_data)
 {
-	struct cache_query *data = user_data;
+	struct context_query *data = user_data;
 	GList *l;
 
 	if (estatus != E_BOOK_ERROR_OK) {
@@ -411,13 +407,13 @@ done:
 int phonebook_pull(const char *name, const struct apparam_field *params,
 					phonebook_cb cb, void *user_data)
 {
-	struct contacts_query *data;
+	struct context_query *data;
 	EBookQuery *query;
 
 	query = e_book_query_any_field_contains("");
 
-	data = g_new0(struct contacts_query, 1);
-	data->cb = cb;
+	data = g_new0(struct context_query, 1);
+	data->contacts_cb = cb;
 	data->params = params;
 	data->user_data = user_data;
 
@@ -432,10 +428,10 @@ int phonebook_get_entry(const char *folder, const char *id,
 					const struct apparam_field *params,
 					phonebook_cb cb, void *user_data)
 {
-	struct contacts_query *data;
+	struct context_query *data;
 
-	data = g_new0(struct contacts_query, 1);
-	data->cb = cb;
+	data = g_new0(struct context_query, 1);
+	data->contacts_cb = cb;
 	data->params = params;
 	data->user_data = user_data;
 
@@ -450,7 +446,7 @@ int phonebook_get_entry(const char *folder, const char *id,
 int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 			phonebook_cache_ready_cb ready_cb, void *user_data)
 {
-	struct cache_query *data;
+	struct context_query *data;
 	EBookQuery *query;
 	gboolean ret;
 
@@ -459,7 +455,7 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 
 	query = e_book_query_any_field_contains("");
 
-	data = g_new0(struct cache_query, 1);
+	data = g_new0(struct context_query, 1);
 	data->entry_cb = entry_cb;
 	data->ready_cb = ready_cb;
 	data->user_data = user_data;
-- 
1.7.0.4


  reply	other threads:[~2010-12-08 21:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08 21:15 [PATCH 0/3 v3] Cancel pending phonebook request Dmitriy Paliy
2010-12-08 21:15 ` Dmitriy Paliy [this message]
2010-12-08 21:15 ` [PATCH 2/3 v3] Add handing of backend pending request Dmitriy Paliy
2010-12-08 21:15 ` [PATCH 3/3 v3] Code clean-up: long, empty lines, indentation Dmitriy Paliy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291842956-8610-2-git-send-email-dmitriy.paliy@nokia.com \
    --to=dmitriy.paliy@gmail.com \
    --cc=dmitriy.paliy@nokia.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox