From 352a849348816cca2b7c5b0b87d27677d1d5bf48 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Thu, 18 Mar 2010 14:51:25 -0300 Subject: [PATCH] obexd: Add support for PBAP operations to the back-ends --- obexd/plugins/pbap.c | 23 +++++++++++++++-------- obexd/plugins/phonebook-dummy.c | 12 ++++++++++++ obexd/plugins/phonebook-ebook.c | 12 ++++++++++++ obexd/plugins/phonebook.h | 6 ++++++ 4 files changed, 45 insertions(+), 8 deletions(-) diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index fc0eabeeb..f72a7f7fd 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -401,6 +401,8 @@ static gpointer vobject_open(const char *name, int oflag, mode_t mode, gpointer context, size_t *size, int *err) { struct pbap_session *pbap = context; + const gchar *type = obex_get_type(pbap->os); + phonebook_cb cb; int ret; if (oflag != O_RDONLY) { @@ -408,16 +410,21 @@ static gpointer vobject_open(const char *name, int oflag, mode_t mode, goto fail; } - /* - * Zero means that the PCE wants to know the number of used indexes in - * the phone book of interest. PSE shall ignore all other application - * parameter that may be present in the request. - */ if (pbap->params->maxlistcount == 0) - ret = phonebook_pull(name, pbap->params, - phonebook_size_result, pbap); + cb = phonebook_size_result; else - ret = phonebook_pull(name, pbap->params, query_result, pbap); + cb = query_result; + + if (g_strcmp0(type, "x-bt/phonebook") == 0) + ret = phonebook_pull(name, pbap->params, cb, pbap); + else if (g_strcmp0(type, "x-bt/vcard-listing") == 0) + ret = phonebook_list(name, pbap->params, cb, pbap); + else if (g_strcmp0(type, "x-bt/vcard") == 0) + ret = phonebook_get_entry(name, pbap->params, query_result, pbap); + else { + ret = -EINVAL; + goto fail; + } if (ret < 0) goto fail; diff --git a/obexd/plugins/phonebook-dummy.c b/obexd/plugins/phonebook-dummy.c index 8bff79dd4..b44bb94b7 100644 --- a/obexd/plugins/phonebook-dummy.c +++ b/obexd/plugins/phonebook-dummy.c @@ -84,3 +84,15 @@ int phonebook_pull(const gchar *name, const struct apparam_field *params, dummy_result, dummy, g_free); return 0; } + +int phonebook_get_entry(const gchar *name, const struct apparam_field *params, + phonebook_cb cb, gpointer user_data) +{ + return -1; +} + +int phonebook_list(const gchar *name, const struct apparam_field *params, + phonebook_cb cb, gpointer user_data) +{ + return -1; +} diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index f36180d94..a31f8e07c 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -261,3 +261,15 @@ gint phonebook_pull(const gchar *name, const struct apparam_field *params, return 0; } + +int phonebook_get_entry(const gchar *name, const struct apparam_field *params, + phonebook_cb cb, gpointer user_data) +{ + return -1; +} + +int phonebook_list(const gchar *name, const struct apparam_field *params, + phonebook_cb cb, gpointer user_data) +{ + return -1; +} diff --git a/obexd/plugins/phonebook.h b/obexd/plugins/phonebook.h index 9eaf09511..b0878fb34 100644 --- a/obexd/plugins/phonebook.h +++ b/obexd/plugins/phonebook.h @@ -47,3 +47,9 @@ int phonebook_set_folder(const gchar *current_folder, int phonebook_pull(const gchar *name, const struct apparam_field *params, phonebook_cb cb, gpointer user_data); + +int phonebook_get_entry(const gchar *name, const struct apparam_field *params, + phonebook_cb cb, gpointer user_data); + +int phonebook_list(const gchar *name, const struct apparam_field *params, + phonebook_cb cb, gpointer user_data); -- 2.47.3