From: Dmitriy Paliy <dmitriy.paliy@nokia.com>
To: linux-bluetooth@vger.kernel.org
Cc: Dmitriy Paliy <dmitriy.paliy@nokia.com>
Subject: [PATCH 5/6] Add update phonebook_create_cache
Date: Wed, 24 Nov 2010 17:07:15 +0200 [thread overview]
Message-ID: <1290611236-25656-6-git-send-email-dmitriy.paliy@nokia.com> (raw)
In-Reply-To: <1290611236-25656-1-git-send-email-dmitriy.paliy@nokia.com>
Add phonebook_create_cache updated function prototype to return void
pointer to backend specific request and error code. All backend
handlers updated accordingly (phonebook-tracker.c,
phonebook-dummy.c, and phonebook-ebook.c).
In PBAP vobject_list_open and vobject_vcard_open are updated to
store pointer to phonebook request. IRMC is not modified.
Phonebook request is stored and canceled only for tracker.
---
plugins/pbap.c | 14 +++++++++-----
plugins/phonebook-dummy.c | 16 ++++++++++------
plugins/phonebook-ebook.c | 20 ++++++++++++++------
plugins/phonebook-tracker.c | 16 ++++++++--------
plugins/phonebook.h | 4 ++--
5 files changed, 43 insertions(+), 27 deletions(-)
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 40bda69..e0df444 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -759,6 +759,7 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
{
struct pbap_session *pbap = context;
int ret = 0;
+ void *request = NULL;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -788,14 +789,17 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
goto done;
}
- ret = phonebook_create_cache(name,
- cache_entry_notify, cache_ready_notify, pbap);
+ request = phonebook_create_cache(name,
+ cache_entry_notify, cache_ready_notify, pbap, &ret);
if (ret < 0)
goto fail;
done:
- return vobject_create(pbap, NULL);
+ if (err)
+ *err = ret;
+
+ return vobject_create(pbap, request);
fail:
if (err)
@@ -827,8 +831,8 @@ static void *vobject_vcard_open(const char *name, int oflag, mode_t mode,
if (pbap->cache.valid == FALSE) {
pbap->find_handle = handle;
- ret = phonebook_create_cache(pbap->folder, cache_entry_notify,
- cache_entry_done, pbap);
+ request = phonebook_create_cache(pbap->folder,
+ cache_entry_notify, cache_entry_done, pbap, &ret);
goto done;
}
diff --git a/plugins/phonebook-dummy.c b/plugins/phonebook-dummy.c
index 7a963b6..a269ea8 100644
--- a/plugins/phonebook-dummy.c
+++ b/plugins/phonebook-dummy.c
@@ -528,8 +528,8 @@ void *phonebook_get_entry(const char *folder, const char *id,
return NULL;
}
-int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
- phonebook_cache_ready_cb ready_cb, void *user_data)
+void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
+ phonebook_cache_ready_cb ready_cb, void *user_data, int *err)
{
struct cache_query *query;
char *foldername;
@@ -540,9 +540,10 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
g_free(foldername);
if (dp == NULL) {
- int err = errno;
- DBG("opendir(): %s(%d)", strerror(err), err);
- return -ENOENT;
+ DBG("opendir(): %s(%d)", strerror(errno), errno);
+ if (err)
+ *err = -ENOENT;
+ return NULL;
}
query = g_new0(struct cache_query, 1);
@@ -553,5 +554,8 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, create_cache, query,
query_free);
- return 0;
+ if (err)
+ *err = 0;
+
+ return NULL;
}
diff --git a/plugins/phonebook-ebook.c b/plugins/phonebook-ebook.c
index 2515bb0..5d7f624 100644
--- a/plugins/phonebook-ebook.c
+++ b/plugins/phonebook-ebook.c
@@ -459,15 +459,18 @@ void *phonebook_get_entry(const char *folder, const char *id,
return NULL;
}
-int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
- phonebook_cache_ready_cb ready_cb, void *user_data)
+void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
+ phonebook_cache_ready_cb ready_cb, void *user_data, int *err)
{
struct cache_query *data;
EBookQuery *query;
gboolean ret;
- if (g_strcmp0("/telecom/pb", name) != 0)
- return -ENOENT;
+ if (g_strcmp0("/telecom/pb", name) != 0) {
+ if (err)
+ *err = -ENOENT;
+ return NULL;
+ }
query = e_book_query_any_field_contains("");
@@ -480,8 +483,13 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
e_book_query_unref(query);
if (ret != FALSE) {
g_free(data);
- return -EFAULT;
+ if (err)
+ *err = -EFAULT;
+ return NULL;
}
- return 0;
+ if (err)
+ *err = 0;
+
+ return NULL;
}
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 142e799..cd2ff31 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -1880,25 +1880,25 @@ void *phonebook_get_entry(const char *folder, const char *id,
return call;
}
-int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
- phonebook_cache_ready_cb ready_cb, void *user_data)
+void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
+ phonebook_cache_ready_cb ready_cb, void *user_data, int *err)
{
struct cache_data *cache;
const char *query;
- int ret;
DBG("name %s", name);
query = folder2query(name);
- if (query == NULL)
- return -ENOENT;
+ if (query == NULL) {
+ if (err)
+ *err = -ENOENT;
+ return NULL;
+ }
cache = g_new0(struct cache_data, 1);
cache->entry_cb = entry_cb;
cache->ready_cb = ready_cb;
cache->user_data = user_data;
- query_tracker(query, 7, add_to_cache, cache, &ret);
-
- return ret;
+ return query_tracker(query, 7, add_to_cache, cache, err);
}
diff --git a/plugins/phonebook.h b/plugins/phonebook.h
index 5342841..b6ae5a8 100644
--- a/plugins/phonebook.h
+++ b/plugins/phonebook.h
@@ -105,8 +105,8 @@ void *phonebook_get_entry(const char *folder, const char *id,
* Cache will store only the necessary information required to reply to
* PullvCardListing request and verify if a given contact belongs to the source.
*/
-int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
- phonebook_cache_ready_cb ready_cb, void *user_data);
+void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
+ phonebook_cache_ready_cb ready_cb, void *user_data, int *err);
/*
* Function used to cancel pending request to backend and free resources
--
1.7.0.4
next prev parent reply other threads:[~2010-11-24 15:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 15:07 [PATCH 0/6 v2] Cancel pending phonebook request Dmitriy Paliy
2010-11-24 15:07 ` [PATCH 1/6] Add phonebook_req_cancel prototype Dmitriy Paliy
2010-11-24 15:07 ` [PATCH 2/6] Add phonebook_req_cancel to tracker Dmitriy Paliy
2010-11-24 15:07 ` [PATCH 3/6] Add update phonebook_pull Dmitriy Paliy
2010-11-24 15:07 ` [PATCH 4/6] Add update phonebook_get_entry Dmitriy Paliy
2010-11-24 15:07 ` Dmitriy Paliy [this message]
2010-11-24 15:07 ` [PATCH 6/6] Code clean-up: lines longer 80 symbols removed 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=1290611236-25656-6-git-send-email-dmitriy.paliy@nokia.com \
--to=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;
as well as URLs for NNTP newsgroup(s).