* Re: [PATCH v2] Change obex_service_driver put() signature
From: Johan Hedberg @ 2010-12-09 8:47 UTC (permalink / raw)
To: Slawomir Bochenski; +Cc: linux-bluetooth
In-Reply-To: <1291878480-14865-1-git-send-email-lkslawek@gmail.com>
Hi Slawek,
On Thu, Dec 09, 2010, Slawomir Bochenski wrote:
> This API change is needed for implementing Message Access Profile, as
> MAP uses application parameters in puts also (for example
> SetMessageStatus function, see MAP specification, chapter 5.7) and in
> order to access application parameters headers, access to obex object
> is required.
> ---
> plugins/ftp.c | 3 ++-
> plugins/opp.c | 3 ++-
> plugins/syncevolution.c | 3 ++-
> src/obex.c | 2 +-
> src/service.h | 3 ++-
> 5 files changed, 9 insertions(+), 5 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v7] Bluetooth: btwilink driver
From: Pavan Savoy @ 2010-12-09 7:47 UTC (permalink / raw)
To: Vitaly Wool, Gustavo F. Padovan; +Cc: marcel, linux-bluetooth, linux-kernel
In-Reply-To: <AANLkTimJiHhkwb-0PQqc6n3wJwx2WPterQqMCXqzce8z@mail.gmail.com>
Gustavo,
On Tue, Dec 7, 2010 at 3:05 AM, Vitaly Wool <vitalywool@gmail.com> wrote:
> Hi Gustavo,
>
> On Mon, Dec 6, 2010 at 10:23 PM, Gustavo F. Padovan
> <padovan@profusion.mobi> wrote:
>
>> Can't you differentiate Bluetooth data in a generic way, withou looking =
if it
>> is ACL, SCO or HCI EVENT? That done, you can just accumulate in a buffer=
all
>> the Bluetooth data you received in that stream then send it to Bluetooth
>> driver after finish that stream processing.
>
> I'm afraid he can't do this because he needs to route events to the
> appropriate entity (BT/FM/GPS). I'm not sure how it can be done
> without analyzing the incoming packet.
Think of TI-ST driver as a extension to the HCI-H4 driver or HCI-LL
with FM and GPS being the additional protocols, and more protocols
coming in future...
So some driver has to have a knowledge of the protocols which are on chip.
the basic arch can be found @ http://omappedia.org/wiki/Wilink_ST
As Vitaly rightly pointed out, the TI-ST driver needs to peek into all
the protocol's data be it BT, FM or GPS to assemble fragmented data
(say ACL data coming out of TTY in 2 fragments) or fragment multiple
protocol data (say HCI-Event + FM Channel 8 event data)....
Note: we include even the FM and GPS headers to understand protocol
frames, but they lack a standard unlike Bluetooth...
Since there lacks a generic way to differentiate BT, FM or GPS data at
TI-ST driver layer, please suggest what can be done ...
> Thanks,
> =C2=A0 Vitaly
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* [PATCH v2] Change obex_service_driver put() signature
From: Slawomir Bochenski @ 2010-12-09 7:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Slawomir Bochenski
This API change is needed for implementing Message Access Profile, as
MAP uses application parameters in puts also (for example
SetMessageStatus function, see MAP specification, chapter 5.7) and in
order to access application parameters headers, access to obex object
is required.
---
plugins/ftp.c | 3 ++-
plugins/opp.c | 3 ++-
plugins/syncevolution.c | 3 ++-
src/obex.c | 2 +-
src/service.h | 3 ++-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/plugins/ftp.c b/plugins/ftp.c
index 91c77a3..a952f64 100644
--- a/plugins/ftp.c
+++ b/plugins/ftp.c
@@ -258,7 +258,8 @@ static int ftp_chkput(struct obex_session *os, void *user_data)
return ret;
}
-static int ftp_put(struct obex_session *os, void *user_data)
+static int ftp_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
struct ftp_session *ftp = user_data;
const char *name = obex_get_name(os);
diff --git a/plugins/opp.c b/plugins/opp.c
index 05f944f..17c4356 100644
--- a/plugins/opp.c
+++ b/plugins/opp.c
@@ -155,7 +155,8 @@ skip_auth:
return ret;
}
-static int opp_put(struct obex_session *os, void *user_data)
+static int opp_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
const char *name = obex_get_name(os);
const char *folder = obex_get_root_folder(os);
diff --git a/plugins/syncevolution.c b/plugins/syncevolution.c
index bf436a9..8041df6 100644
--- a/plugins/syncevolution.c
+++ b/plugins/syncevolution.c
@@ -243,7 +243,8 @@ failed:
return NULL;
}
-static int synce_put(struct obex_session *os, void *user_data)
+static int synce_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
return 0;
}
diff --git a/src/obex.c b/src/obex.c
index 6d4430d..1649cd0 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -1089,7 +1089,7 @@ static void cmd_put(struct obex_session *os, obex_t *obex, obex_object_t *obj)
return;
}
- err = os->service->put(os, os->service_data);
+ err = os->service->put(os, obj, os->service_data);
if (err < 0)
os_set_response(obj, err);
}
diff --git a/src/service.h b/src/service.h
index 1726c43..a844885 100644
--- a/src/service.h
+++ b/src/service.h
@@ -34,7 +34,8 @@ struct obex_service_driver {
void (*progress) (struct obex_session *os, void *user_data);
int (*get) (struct obex_session *os, obex_object_t *obj,
gboolean *stream, void *user_data);
- int (*put) (struct obex_session *os, void *user_data);
+ int (*put) (struct obex_session *os, obex_object_t *obj,
+ void *user_data);
int (*chkput) (struct obex_session *os, void *user_data);
int (*setpath) (struct obex_session *os, obex_object_t *obj,
void *user_data);
--
1.7.1
^ permalink raw reply related
* compat-wireless-2.6.37-rc5 released
From: Luis R. Rodriguez @ 2010-12-09 0:15 UTC (permalink / raw)
To: linux-wireless; +Cc: linux-kernel, linux-bluetooth
We're closing in on the 2.6.37 release, now at rc5, so I'll start
making two releases, a vanilla release and one which has more stuff.
For now I'll just suck in all pending stable patches (all patches
marked with Cc: stable@kernel.org on linux-next.git, not only
Atheros', everyone's). This is:
pending-stable/0001-cfg80211-pass-the-reg-hint-initiator-to-helpers.patch
pending-stable/0002-cfg80211-fix-allowing-country-IEs-for-WIPHY_FLAG_STR.patch
pending-stable/0003-cfg80211-fix-disabling-channels-based-on-hints.patch
pending-stable/0004-ath9k_hw-fix-potential-spurious-tx-error-bit-interpr.patch
pending-stable/0005-ath9k-simplify-hw-reset-locking.patch
pending-stable/0006-ath9k-move-the-PCU-lock-to-the-sc-structure.patch
pending-stable/0007-ath9k-content-DMA-start-stop-through-the-PCU-lock.patch
pending-stable/0008-ath9k_hw-Fix-XPABIAS-level-configuration-for-AR9003.patch
pending-stable/0009-ath9k-Fix-bug-in-delimiter-padding-computation.patch
pending-stable/0010-ath9k-Disable-SWBA-interrupt-on-remove_interface.patch
pending-stable/0011-mac80211-Fix-STA-disconnect-due-to-MIC-failure.patch
pending-stable/0012-ath9k-Fix-STA-disconnect-issue-due-to-received-MIC-f.patch
pending-stable/0013-ath9k-Fix-bug-in-reading-input-gpio-state-for-ar9003.patch
pending-stable/0014-ath9k_hw-fix-endian-issues-with-CTLs-on-AR9003.patch
You can find the vanilla [1] and extra pending-stable [2] releass on
the stable download page [3] along with the respective ChangeLog of
all:
* The kernel components
* compat-wireless
* compat
In later releases we will have to consider if we want to cherry pick
anything extra or leave them as is. These few patches seem tempting to
suck in:
01-ath9k-OTP.patch
03-ath9k-no-aggr-VO.patch
04-mac80211-no-aggr-VO.patch
05-ath9k-Reintroduce-modparam-to-enable-btcoex.patch
06-ath9k_hw-fix-A-MPDU-key-search-issues-on-AR9003.patch
Particularly it is now known AR9003 devices will only ship with OTP
so.. it seems to make sense to actually disable AR9003 on 36 and even
37 and only have it available with the OTP patch and above EEPROM
fixes. I'm inclined to just disregard all these and just let us get
AR9003 from 2.6.38.... but we already have users of AR9003 coming up
so this can't wait in practice now. This now goes compile-tested and
fixed for 2.6.31.
[1] http://www.orbit-lab.org/kernel/compat-wireless-2.6-stable/v2.6.37/compat-wireless-2.6.37-rc5-2.tar.bz2
[2] http://www.orbit-lab.org/kernel/compat-wireless-2.6-stable/v2.6.37/compat-wireless-2.6.37-rc5-2-s.tar.bz2
[3] http://wireless.kernel.org/en/users/Download/stable
[4] http://www.orbit-lab.org/kernel/compat-wireless-2.6-stable/v2.6.37/ChangeLog-2.6.37-wireless
Luis
^ permalink raw reply
* [PATCH 3/3 v3] Code clean-up: long, empty lines, indentation
From: Dmitriy Paliy @ 2010-12-08 21:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1291842956-8610-1-git-send-email-dmitriy.paliy@nokia.com>
Lines longer 80 symbols and empty lines removed. Indentation in
generate_response function corrected.
---
plugins/pbap.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/plugins/pbap.c b/plugins/pbap.c
index a8e1ec6..5121685 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -273,8 +273,8 @@ static void query_result(const char *buffer, size_t bufsize, int vcards,
if (!pbap->obj->buffer)
pbap->obj->buffer = g_string_new_len(buffer, bufsize);
else
- pbap->obj->buffer = g_string_append_len(pbap->obj->buffer, buffer,
- bufsize);
+ pbap->obj->buffer = g_string_append_len(pbap->obj->buffer,
+ buffer, bufsize);
obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
}
@@ -418,9 +418,8 @@ static int generate_response(void *user_data)
* only the reference for the "real" cache entry.
*/
sorted = sort_entries(pbap->cache.entries, pbap->params->order,
- pbap->params->searchattrib,
- (const char *) pbap->params->searchval);
-
+ pbap->params->searchattrib,
+ (const char *) pbap->params->searchval);
if (sorted == NULL)
return -ENOENT;
@@ -431,12 +430,12 @@ static int generate_response(void *user_data)
for (; l && max; l = l->next, max--) {
const struct cache_entry *entry = l->data;
- g_string_append_printf(pbap->obj->buffer, VCARD_LISTING_ELEMENT,
- entry->handle, entry->name);
+ g_string_append_printf(pbap->obj->buffer,
+ VCARD_LISTING_ELEMENT, entry->handle, entry->name);
}
- pbap->obj->buffer = g_string_append(pbap->obj->buffer, VCARD_LISTING_END);
-
+ pbap->obj->buffer = g_string_append(pbap->obj->buffer,
+ VCARD_LISTING_END);
g_slist_free(sorted);
return 0;
--
1.7.0.4
^ permalink raw reply related
* [PATCH 2/3 v3] Add handing of backend pending request
From: Dmitriy Paliy @ 2010-12-08 21:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1291842956-8610-1-git-send-email-dmitriy.paliy@nokia.com>
Add phonebook_req_cancel function prototype in phonebook.h to cancel
pending request if it is not completed, and to unref pointer to pending
request if such is applicable.
It does the following, depending on phonebook backend:
- for phonebook-tracker.c backend driver, it cancels pending DBus call,
- for phonebook-dummy.c, it removes GSource with a given id,
- for phonebook-ebook.c, it cancels last, still running, asynchronous
operation.
The following modifcations are donein the code. Phonebook request
pointer is added in PBAP object and IRMC session data to provide
reference for pending call. Phonebook callbacks are updated in PBAP
and IRMC to unref request upon completion and clear pointers, if such
is applicable.
PBAP and IRMC are updated to cancel pending request, if any, when OBEX
object is closed.
Phonebook_pull, phonebook_get_entry, phonebook_create_cache functions
are updated to return void pointer to backend specific request and error
code. All backend drivers updated accordingly to the modified API, which
are phonebook-tracker.c, phonebook-dummy.c, and phonebook-ebook.c, to be
specific.
In phonebook-tracker.c, query_tracker is updated to return pending DBus
call request. Allocated pending_reply and phonebook_data are destroyed
after call is unrefed. For this purpose new query_free_data function is
created.
Call is unrefed either if request succeeded or in phonebook_req_cancel
if terminated.
Such fix prevents obexd crash on unexpected OBEX session close. E.g.,
OBEX session is closed before reply comes from phonebook backend. In
that case, both session and object are destroyed, and dereferencing of
object in associated callback function causes crash.
---
plugins/irmc.c | 27 ++++++++---
plugins/pbap.c | 69 ++++++++++++++++++++------
plugins/phonebook-dummy.c | 70 +++++++++++++++++++--------
plugins/phonebook-ebook.c | 95 +++++++++++++++++++++++++++++-------
plugins/phonebook-tracker.c | 113 ++++++++++++++++++++++++++++++++----------
plugins/phonebook.h | 17 ++++--
6 files changed, 296 insertions(+), 95 deletions(-)
diff --git a/plugins/irmc.c b/plugins/irmc.c
index f7ad33b..ede5554 100644
--- a/plugins/irmc.c
+++ b/plugins/irmc.c
@@ -110,6 +110,7 @@ struct irmc_session {
char did[DID_LEN];
char manu[DID_LEN];
char model[DID_LEN];
+ void *request;
};
#define IRMC_TARGET_SIZE 9
@@ -139,6 +140,11 @@ static void phonebook_size_result(const char *buffer, size_t bufsize,
DBG("vcards %d", vcards);
irmc->params->maxlistcount = vcards;
+
+ if (irmc->request) {
+ phonebook_req_cancel(irmc->request);
+ irmc->request = NULL;
+ }
}
static void query_result(const char *buffer, size_t bufsize, int vcards,
@@ -149,6 +155,11 @@ static void query_result(const char *buffer, size_t bufsize, int vcards,
DBG("bufsize %zu vcards %d missed %d", bufsize, vcards, missed);
+ if (irmc->request) {
+ phonebook_req_cancel(irmc->request);
+ irmc->request = NULL;
+ }
+
/* first add a 'owner' vcard */
if (!irmc->buffer)
irmc->buffer = g_string_new(owner_vcard);
@@ -210,11 +221,8 @@ static void *irmc_connect(struct obex_session *os, int *err)
param->maxlistcount = 0; /* to count the number of vcards... */
param->filter = 0x200085; /* UID TEL N VERSION */
irmc->params = param;
- phonebook_pull("telecom/pb.vcf", irmc->params, phonebook_size_result,
- irmc);
-
- if (err)
- *err = 0;
+ irmc->request = phonebook_pull("telecom/pb.vcf", irmc->params,
+ phonebook_size_result, irmc, err);
return irmc;
}
@@ -298,8 +306,8 @@ static void *irmc_open_pb(const char *name, struct irmc_session *irmc,
if (!g_strcmp0(name, ".vcf")) {
/* how can we tell if the vcard count call already finished? */
- ret = phonebook_pull("telecom/pb.vcf", irmc->params,
- query_result, irmc);
+ irmc->request = phonebook_pull("telecom/pb.vcf", irmc->params,
+ query_result, irmc, &ret);
if (ret < 0) {
DBG("phonebook_pull failed...");
goto fail;
@@ -435,6 +443,11 @@ static int irmc_close(void *object)
irmc->buffer = NULL;
}
+ if (irmc->request) {
+ phonebook_req_cancel(irmc->request);
+ irmc->request = NULL;
+ }
+
return 0;
}
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 4086227..a8e1ec6 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -147,6 +147,7 @@ struct pbap_session {
struct pbap_object {
GString *buffer;
struct pbap_session *session;
+ void *request;
};
static const uint8_t PBAP_TARGET[TARGET_SIZE] = {
@@ -231,6 +232,11 @@ static void phonebook_size_result(const char *buffer, size_t bufsize,
struct aparam_header *hdr = (struct aparam_header *) aparam;
uint16_t phonebooksize;
+ if (pbap->obj->request) {
+ phonebook_req_cancel(pbap->obj->request);
+ pbap->obj->request = NULL;
+ }
+
if (vcards < 0)
vcards = 0;
@@ -254,6 +260,11 @@ static void query_result(const char *buffer, size_t bufsize, int vcards,
DBG("");
+ if (pbap->obj->request) {
+ phonebook_req_cancel(pbap->obj->request);
+ pbap->obj->request = NULL;
+ }
+
if (vcards <= 0) {
obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT);
return;
@@ -466,8 +477,11 @@ static void cache_entry_done(void *user_data)
return;
}
- ret = phonebook_get_entry(pbap->folder, id, pbap->params,
- query_result, pbap);
+ /* Unref previous request, associated data will be freed. */
+ phonebook_req_cancel(pbap->obj->request);
+ /* Get new pointer to pending call. */
+ pbap->obj->request = phonebook_get_entry(pbap->folder, id,
+ pbap->params, query_result, pbap, &ret);
if (ret < 0)
obex_object_set_io_flags(pbap->obj, G_IO_ERR, ret);
}
@@ -709,13 +723,15 @@ static struct obex_service_driver pbap = {
.chkput = pbap_chkput
};
-static struct pbap_object *vobject_create(struct pbap_session *pbap)
+static struct pbap_object *vobject_create(struct pbap_session *pbap,
+ void *request)
{
struct pbap_object *obj;
obj = g_new0(struct pbap_object, 1);
obj->session = pbap;
pbap->obj = obj;
+ obj->request = request;
return obj;
}
@@ -726,6 +742,7 @@ static void *vobject_pull_open(const char *name, int oflag, mode_t mode,
struct pbap_session *pbap = context;
phonebook_cb cb;
int ret;
+ void *request;
DBG("name %s context %p maxlistcount %d", name, context,
pbap->params->maxlistcount);
@@ -745,11 +762,15 @@ static void *vobject_pull_open(const char *name, int oflag, mode_t mode,
else
cb = query_result;
- ret = phonebook_pull(name, pbap->params, cb, pbap);
+ request = phonebook_pull(name, pbap->params, cb, pbap, &ret);
+
if (ret < 0)
goto fail;
- return vobject_create(pbap);
+ if (err)
+ *err = 0;
+
+ return vobject_create(pbap, request);
fail:
if (err)
@@ -770,6 +791,11 @@ static int vobject_close(void *object)
if (obj->buffer)
g_string_free(obj->buffer, TRUE);
+ if (obj->request) {
+ phonebook_req_cancel(obj->request);
+ obj->request = NULL;
+ }
+
g_free(obj);
return 0;
@@ -781,6 +807,7 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
struct pbap_session *pbap = context;
struct pbap_object *obj = NULL;
int ret;
+ void *request;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -796,13 +823,19 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
/* PullvCardListing always get the contacts from the cache */
- obj = vobject_create(pbap);
-
- if (pbap->cache.valid)
+ if (pbap->cache.valid) {
+ obj = vobject_create(pbap, NULL);
ret = generate_response(pbap);
- else
- ret = phonebook_create_cache(name, cache_entry_notify,
- cache_ready_notify, pbap);
+ } else {
+ request = phonebook_create_cache(name, cache_entry_notify,
+ cache_ready_notify, pbap, &ret);
+ /*
+ * This is not to do memory allocation since if request
+ * fails, then memory is freed when object is closed below.
+ */
+ if (ret == 0)
+ obj = vobject_create(pbap, request);
+ }
if (ret < 0)
goto fail;
@@ -828,6 +861,7 @@ static void *vobject_vcard_open(const char *name, int oflag, mode_t mode,
const char *id;
uint32_t handle;
int ret;
+ void *request;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -843,8 +877,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;
}
@@ -854,14 +888,17 @@ static void *vobject_vcard_open(const char *name, int oflag, mode_t mode,
goto fail;
}
- ret = phonebook_get_entry(pbap->folder, id, pbap->params, query_result,
- pbap);
+ request = phonebook_get_entry(pbap->folder, id, pbap->params,
+ query_result, pbap, &ret);
done:
if (ret < 0)
goto fail;
- return vobject_create(pbap);
+ if (err)
+ *err = 0;
+
+ return vobject_create(pbap, request);
fail:
if (err)
diff --git a/plugins/phonebook-dummy.c b/plugins/phonebook-dummy.c
index 7c549fa..efb1430 100644
--- a/plugins/phonebook-dummy.c
+++ b/plugins/phonebook-dummy.c
@@ -447,11 +447,19 @@ done:
return relative;
}
-int phonebook_pull(const char *name, const struct apparam_field *params,
- phonebook_cb cb, void *user_data)
+void phonebook_req_cancel(void *request)
+{
+ guint id = GPOINTER_TO_INT(request);
+
+ g_source_remove(id);
+}
+
+void *phonebook_pull(const char *name, const struct apparam_field *params,
+ phonebook_cb cb, void *user_data, int *err)
{
struct dummy_data *dummy;
char *filename, *folder;
+ guint ret;
/*
* Main phonebook objects will be created dinamically based on the
@@ -463,14 +471,18 @@ int phonebook_pull(const char *name, const struct apparam_field *params,
if (!g_str_has_suffix(filename, ".vcf")) {
g_free(filename);
- return -EBADR;
+ if (err)
+ *err = -EBADR;
+ return NULL;
}
folder = g_strndup(filename, strlen(filename) - 4);
g_free(filename);
if (!is_dir(folder)) {
g_free(folder);
- return -ENOENT;
+ if (err)
+ *err = -ENOENT;
+ return NULL;
}
dummy = g_new0(struct dummy_data, 1);
@@ -480,26 +492,32 @@ int phonebook_pull(const char *name, const struct apparam_field *params,
dummy->folder = folder;
dummy->fd = -1;
- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, read_dir, dummy, dummy_free);
+ ret = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, read_dir, dummy,
+ dummy_free);
- return 0;
+ if (err)
+ *err = 0;
+
+ return GINT_TO_POINTER(ret);
}
-int phonebook_get_entry(const char *folder, const char *id,
- const struct apparam_field *params,
- phonebook_cb cb, void *user_data)
+void *phonebook_get_entry(const char *folder, const char *id,
+ const struct apparam_field *params, phonebook_cb cb,
+ void *user_data, int *err)
{
struct dummy_data *dummy;
char *filename;
int fd;
+ guint ret;
filename = g_build_filename(root_folder, folder, id, NULL);
fd = open(filename, O_RDONLY);
if (fd < 0) {
- int err = errno;
- DBG("open(): %s(%d)", strerror(err), err);
- return -ENOENT;
+ DBG("open(): %s(%d)", strerror(errno), errno);
+ if (err)
+ *err = -ENOENT;
+ return NULL;
}
dummy = g_new0(struct dummy_data, 1);
@@ -508,26 +526,32 @@ int phonebook_get_entry(const char *folder, const char *id,
dummy->apparams = params;
dummy->fd = fd;
- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, read_entry, dummy, dummy_free);
+ ret = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, read_entry, dummy,
+ dummy_free);
- return 0;
+ if (err)
+ *err = 0;
+
+ return GINT_TO_POINTER(ret);
}
-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;
DIR *dp;
+ guint ret;
foldername = g_build_filename(root_folder, name, NULL);
dp = opendir(foldername);
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);
@@ -536,7 +560,11 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
query->user_data = user_data;
query->dp = dp;
- g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, create_cache, query,
+ ret = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, create_cache, query,
query_free);
- return 0;
+
+ if (err)
+ *err = 0;
+
+ return GINT_TO_POINTER(ret);
}
diff --git a/plugins/phonebook-ebook.c b/plugins/phonebook-ebook.c
index b9d297a..c079de7 100644
--- a/plugins/phonebook-ebook.c
+++ b/plugins/phonebook-ebook.c
@@ -46,6 +46,7 @@
#define QUERY_PHONE "(contains \"phone\" \"%s\")"
struct context_query {
+ gboolean completed;
const struct apparam_field *params;
phonebook_cb contacts_cb;
phonebook_entry_cb entry_cb;
@@ -142,6 +143,11 @@ static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts,
unsigned int count = 0, maxcount;
GList *l;
+ if (estatus == E_BOOK_ERROR_CANCELLED) {
+ error("E-Book operation was cancelled: status %d", estatus);
+ goto fail;
+ }
+
if (estatus != E_BOOK_ERROR_OK) {
error("E-Book query failed: status %d", estatus);
goto done;
@@ -178,10 +184,14 @@ static void ebookpull_cb(EBook *book, EBookStatus estatus, GList *contacts,
done:
+ data->completed = TRUE;
data->contacts_cb(string->str, string->len, count, 0, data->user_data);
+fail:
g_string_free(string, TRUE);
- g_free(data);
+
+ if (data->completed)
+ g_free(data);
}
static void ebook_entry_cb(EBook *book, EBookStatus estatus,
@@ -192,11 +202,17 @@ static void ebook_entry_cb(EBook *book, EBookStatus estatus,
char *vcard;
size_t len;
+ if (estatus == E_BOOK_ERROR_CANCELLED) {
+ error("E-Book operation was cancelled: status %d", estatus);
+ goto fail;
+ }
+
+ data->completed = TRUE;
+
if (estatus != E_BOOK_ERROR_OK) {
error("E-Book query failed: status %d", estatus);
data->contacts_cb(NULL, 0, 1, 0, data->user_data);
- g_free(data);
- return;
+ goto fail;
}
evcard = E_VCARD(contact);
@@ -209,7 +225,10 @@ static void ebook_entry_cb(EBook *book, EBookStatus estatus,
data->contacts_cb(vcard, len, 1, 0, data->user_data);
g_free(vcard);
- g_free(data);
+
+fail:
+ if (data->completed)
+ g_free(data);
}
static char *evcard_name_attribute_to_string(EVCard *evcard)
@@ -248,6 +267,13 @@ static void cache_cb(EBook *book, EBookStatus estatus, GList *contacts,
struct context_query *data = user_data;
GList *l;
+ if (estatus == E_BOOK_ERROR_CANCELLED) {
+ error("E-Book operation was cancelled: status %d", estatus);
+ goto fail;
+ }
+
+ data->completed = TRUE;
+
if (estatus != E_BOOK_ERROR_OK) {
error("E-Book query failed: status %d", estatus);
goto done;
@@ -285,6 +311,10 @@ static void cache_cb(EBook *book, EBookStatus estatus, GList *contacts,
}
done:
data->ready_cb(data->user_data);
+
+fail:
+ if (data->completed)
+ g_free(data);
}
int phonebook_init(void)
@@ -404,8 +434,21 @@ done:
return fullname;
}
-int phonebook_pull(const char *name, const struct apparam_field *params,
- phonebook_cb cb, void *user_data)
+void phonebook_req_cancel(void *request)
+{
+ struct context_query *data = request;
+
+ if (!data)
+ return;
+
+ if (!data->completed) {
+ data->completed = TRUE;
+ e_book_cancel_async_op(ebook, NULL);
+ }
+}
+
+void *phonebook_pull(const char *name, const struct apparam_field *params,
+ phonebook_cb cb, void *user_data, int *err)
{
struct context_query *data;
EBookQuery *query;
@@ -421,12 +464,15 @@ int phonebook_pull(const char *name, const struct apparam_field *params,
e_book_query_unref(query);
- return 0;
+ if (err)
+ *err = 0;
+
+ return data;
}
-int phonebook_get_entry(const char *folder, const char *id,
- const struct apparam_field *params,
- phonebook_cb cb, void *user_data)
+void *phonebook_get_entry(const char *folder, const char *id,
+ const struct apparam_field *params,
+ phonebook_cb cb, void *user_data, int *err)
{
struct context_query *data;
@@ -437,21 +483,29 @@ int phonebook_get_entry(const char *folder, const char *id,
if (e_book_async_get_contact(ebook, id, ebook_entry_cb, data)) {
g_free(data);
- return -ENOENT;
+ if (err)
+ *err = -ENOENT;
+ return NULL;
}
- return 0;
+ if (err)
+ *err = 0;
+
+ return data;
}
-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 context_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("");
@@ -464,8 +518,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 data;
}
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index cdc1008..92299a0 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -807,6 +807,7 @@ struct pending_reply {
reply_list_foreach_t callback;
void *user_data;
int num_fields;
+ GDestroyNotify destroy;
};
struct contact_data {
@@ -996,11 +997,30 @@ done:
pending->callback(NULL, err, pending->user_data);
dbus_message_unref(reply);
+
+ /*
+ * pending data is freed in query_free_data after call is unreffed.
+ * Same holds for pending->user_data which is not freed in callback
+ * but in query_free_data.
+ */
+}
+
+static void query_free_data(void *user_data)
+{
+ struct pending_reply *pending = user_data;
+
+ if (!pending)
+ return;
+
+ if (pending->destroy)
+ pending->destroy(pending->user_data);
+
g_free(pending);
}
-static int query_tracker(const char *query, int num_fields,
- reply_list_foreach_t callback, void *user_data)
+static DBusPendingCall *query_tracker(const char *query, int num_fields,
+ reply_list_foreach_t callback, void *user_data,
+ GDestroyNotify destroy, int *err)
{
struct pending_reply *pending;
DBusPendingCall *call;
@@ -1020,19 +1040,27 @@ static int query_tracker(const char *query, int num_fields,
-1) == FALSE) {
error("Could not send dbus message");
dbus_message_unref(msg);
- return -EPERM;
+ if (err)
+ *err = -EPERM;
+ /* user_data is freed otherwise only if call was sent */
+ g_free(user_data);
+ return NULL;
}
pending = g_new0(struct pending_reply, 1);
pending->callback = callback;
pending->user_data = user_data;
pending->num_fields = num_fields;
+ pending->destroy = destroy;
- dbus_pending_call_set_notify(call, query_reply, pending, NULL);
- dbus_pending_call_unref(call);
+ dbus_pending_call_set_notify(call, query_reply, pending,
+ query_free_data);
dbus_message_unref(msg);
- return 0;
+ if (err)
+ *err = 0;
+
+ return call;
}
static char *iso8601_utc_to_localtime(const char *datetime)
@@ -1245,7 +1273,7 @@ static void pull_contacts_size(char **reply, int num_fields, void *user_data)
if (num_fields < 0) {
data->cb(NULL, 0, num_fields, 0, data->user_data);
- goto fail;
+ return;
}
if (reply != NULL) {
@@ -1255,8 +1283,11 @@ static void pull_contacts_size(char **reply, int num_fields, void *user_data)
data->cb(NULL, 0, data->index, 0, data->user_data);
-fail:
- g_free(data);
+ /*
+ * phonebook_data is freed in query_free_data after call is unreffed.
+ * It is accessible by pointer from data (pending) associated to call.
+ * Useful in cases when call was terminated.
+ */
}
static void add_affiliation(char **field, const char *value)
@@ -1482,9 +1513,14 @@ done:
g_string_free(vcards, TRUE);
fail:
g_slist_free(data->contacts);
- g_free(data);
g_free(temp_id);
temp_id = NULL;
+
+ /*
+ * phonebook_data is freed in query_free_data after call is unreffed.
+ * It is accessible by pointer from data (pending) associated to call.
+ * Useful in cases when call was terminated.
+ */
}
static void add_to_cache(char **reply, int num_fields, void *user_data)
@@ -1529,7 +1565,11 @@ done:
if (num_fields <= 0)
cache->ready_cb(cache->user_data);
- g_free(cache);
+ /*
+ * cache is freed in query_free_data after call is unreffed.
+ * It is accessible by pointer from data (pending) associated to call.
+ * Useful in cases when call was terminated.
+ */
}
int phonebook_init(void)
@@ -1617,8 +1657,20 @@ done:
return path;
}
-int phonebook_pull(const char *name, const struct apparam_field *params,
- phonebook_cb cb, void *user_data)
+void phonebook_req_cancel(void *request)
+{
+ struct DBusPendingCall *call = request;
+
+ DBG("");
+
+ if (!dbus_pending_call_get_completed(call))
+ dbus_pending_call_cancel(call);
+
+ dbus_pending_call_unref(call);
+}
+
+void *phonebook_pull(const char *name, const struct apparam_field *params,
+ phonebook_cb cb, void *user_data, int *err)
{
struct phonebook_data *data;
const char *query;
@@ -1637,24 +1689,27 @@ int phonebook_pull(const char *name, const struct apparam_field *params,
pull_cb = pull_contacts;
}
- if (query == NULL)
- return -ENOENT;
+ if (query == NULL) {
+ if (err)
+ *err = -ENOENT;
+ return NULL;
+ }
data = g_new0(struct phonebook_data, 1);
data->params = params;
data->user_data = user_data;
data->cb = cb;
- return query_tracker(query, col_amount, pull_cb, data);
+ return query_tracker(query, col_amount, pull_cb, data, g_free, err);
}
-int phonebook_get_entry(const char *folder, const char *id,
- const struct apparam_field *params,
- phonebook_cb cb, void *user_data)
+void *phonebook_get_entry(const char *folder, const char *id,
+ const struct apparam_field *params,
+ phonebook_cb cb, void *user_data, int *err)
{
struct phonebook_data *data;
char *query;
- int ret;
+ DBusPendingCall *call;
DBG("folder %s id %s", folder, id);
@@ -1672,15 +1727,16 @@ int phonebook_get_entry(const char *folder, const char *id,
query = g_strdup_printf(CONTACTS_OTHER_QUERY_FROM_URI,
id, id, id);
- ret = query_tracker(query, PULL_QUERY_COL_AMOUNT, pull_contacts, data);
+ call = query_tracker(query, PULL_QUERY_COL_AMOUNT, pull_contacts,
+ data, g_free, err);
g_free(query);
- return ret;
+ 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;
@@ -1688,13 +1744,16 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
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;
- return query_tracker(query, 7, add_to_cache, cache);
+ return query_tracker(query, 7, add_to_cache, cache, g_free, err);
}
diff --git a/plugins/phonebook.h b/plugins/phonebook.h
index d7cfa46..687feb8 100644
--- a/plugins/phonebook.h
+++ b/plugins/phonebook.h
@@ -86,8 +86,8 @@ char *phonebook_set_folder(const char *current_folder,
* entries of a given folder. The back-end MUST return only the content based
* on the application parameters requested by the client.
*/
-int phonebook_pull(const char *name, const struct apparam_field *params,
- phonebook_cb cb, void *user_data);
+void *phonebook_pull(const char *name, const struct apparam_field *params,
+ phonebook_cb cb, void *user_data, int *err);
/*
* Function used to retrieve a contact from the backend. Only contacts
@@ -95,9 +95,9 @@ int phonebook_pull(const char *name, const struct apparam_field *params,
* return only the content based on the application parameters requested
* by the client.
*/
-int phonebook_get_entry(const char *folder, const char *id,
+void *phonebook_get_entry(const char *folder, const char *id,
const struct apparam_field *params,
- phonebook_cb cb, void *user_data);
+ phonebook_cb cb, void *user_data, int *err);
/*
* PBAP core will keep the contacts cache per folder. SetPhoneBook or
@@ -105,5 +105,10 @@ int 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);
+
+/*
+ * Cancels pending call to phonebook backend.
+ */
+void phonebook_req_cancel(void *request);
--
1.7.0.4
^ permalink raw reply related
* [PATCH 1/3 v3] Unified ebook data structures
From: Dmitriy Paliy @ 2010-12-08 21:15 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
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
^ permalink raw reply related
* [PATCH 0/3 v3] Cancel pending phonebook request
From: Dmitriy Paliy @ 2010-12-08 21:15 UTC (permalink / raw)
To: linux-bluetooth
Hi,
This is updated version of patch to handle pending phonebook
request and to cancel it if OBEX session is terminated.
Additionally to previous submission, it containts updates for
phonebook-dummy.c and phonebook-ebook.c backend drivers. Therefore,
it is highly encouraged for those who exploit them to provide
feedback.
Also, code for tracker was significantly improved.
BR,
Dmitriy
^ permalink raw reply
* Re: [PATCH 1/7] Fix coding styling issues in src/error.c
From: Johan Hedberg @ 2010-12-08 20:58 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1291839961-14940-1-git-send-email-padovan@profusion.mobi>
Hi Gustavo,
On Wed, Dec 08, 2010, Gustavo F. Padovan wrote:
> ---
> src/error.c | 26 +++++++++-----------------
> 1 files changed, 9 insertions(+), 17 deletions(-)
Thanks! All seven patches have been pushed upstream.
Johan
^ permalink raw reply
* [PATCH 7/7] Add btd_error_already_connected()
From: Gustavo F. Padovan @ 2010-12-08 20:26 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-6-git-send-email-padovan@profusion.mobi>
---
audio/device.c | 4 +---
audio/headset.c | 8 ++------
audio/sink.c | 4 +---
audio/source.c | 4 +---
input/device.c | 8 +-------
network/connection.c | 2 +-
src/error.c | 6 ++++++
src/error.h | 1 +
8 files changed, 14 insertions(+), 23 deletions(-)
diff --git a/audio/device.c b/audio/device.c
index 6e005a5..fe7aed4 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -521,9 +521,7 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
if (priv->state == AUDIO_STATE_CONNECTING)
return btd_error_in_progress(msg);
else if (priv->state == AUDIO_STATE_CONNECTED)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Already Connected");
+ return btd_error_already_connected(msg);
dev->auto_connect = TRUE;
diff --git a/audio/headset.c b/audio/headset.c
index 8402789..3d584e0 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1697,9 +1697,7 @@ static DBusMessage *hs_connect(DBusConnection *conn, DBusMessage *msg,
if (hs->state == HEADSET_STATE_CONNECTING)
return btd_error_in_progress(msg);
else if (hs->state > HEADSET_STATE_CONNECTING)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Already Connected");
+ return btd_error_already_connected(msg);
if (hs->hfp_handle && !ag.telephony_ready)
return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
@@ -1806,9 +1804,7 @@ static DBusMessage *hs_play(DBusConnection *conn, DBusMessage *msg,
}
return btd_error_busy(msg);
case HEADSET_STATE_PLAYING:
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
case HEADSET_STATE_CONNECTED:
default:
break;
diff --git a/audio/sink.c b/audio/sink.c
index 37ba8c0..176a4ed 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -442,9 +442,7 @@ static DBusMessage *sink_connect(DBusConnection *conn,
return btd_error_busy(msg);
if (sink->stream_state >= AVDTP_STATE_OPEN)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
if (!sink_setup_stream(sink, NULL))
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
diff --git a/audio/source.c b/audio/source.c
index 9b9dab7..c106eaa 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -393,9 +393,7 @@ static DBusMessage *source_connect(DBusConnection *conn,
return btd_error_busy(msg);
if (source->stream_state >= AVDTP_STATE_OPEN)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
if (!source_setup_stream(source, NULL))
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
diff --git a/input/device.c b/input/device.c
index 3c3f9fd..dee943b 100644
--- a/input/device.c
+++ b/input/device.c
@@ -315,12 +315,6 @@ failed:
return FALSE;
}
-static inline DBusMessage *already_connected(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
- "Already connected to a device");
-}
-
static inline DBusMessage *connection_attempt_failed(DBusMessage *msg,
const char *err)
{
@@ -937,7 +931,7 @@ static DBusMessage *input_device_connect(DBusConnection *conn,
return btd_error_in_progress(msg);
if (is_connected(iconn))
- return already_connected(msg);
+ return btd_error_already_connected(msg);
iconn->pending_connect = dbus_message_ref(msg);
fake = iconn->fake;
diff --git a/network/connection.c b/network/connection.c
index a652b98..89c38d8 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -396,7 +396,7 @@ static DBusMessage *connection_connect(DBusConnection *conn,
return btd_error_not_supported(msg);
if (nc->state != DISCONNECTED)
- return already_connected(msg);
+ return btd_error_already_connected(msg);
nc->io = bt_io_connect(BT_IO_L2CAP, connect_cb, nc,
NULL, &err,
diff --git a/src/error.c b/src/error.c
index 0d33fb5..e1f0598 100644
--- a/src/error.c
+++ b/src/error.c
@@ -79,6 +79,12 @@ DBusMessage *btd_error_not_connected(DBusMessage *msg)
"Not Connected");
}
+DBusMessage *btd_error_already_connected(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
+ "Already Connected");
+}
+
DBusMessage *btd_error_in_progress(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress",
diff --git a/src/error.h b/src/error.h
index a7028bd..9d80fa0 100644
--- a/src/error.h
+++ b/src/error.h
@@ -35,6 +35,7 @@ DBusMessage *btd_error_busy(DBusMessage *msg);
DBusMessage *btd_error_already_exists(DBusMessage *msg);
DBusMessage *btd_error_not_supported(DBusMessage *msg);
DBusMessage *btd_error_not_connected(DBusMessage *msg);
+DBusMessage *btd_error_already_connected(DBusMessage *msg);
DBusMessage *btd_error_not_available(DBusMessage *msg);
DBusMessage *btd_error_in_progress(DBusMessage *msg);
DBusMessage *btd_error_does_not_exist(DBusMessage *msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 6/7] convert error to btd_error_not_supported()
From: Gustavo F. Padovan @ 2010-12-08 20:26 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-5-git-send-email-padovan@profusion.mobi>
---
input/device.c | 8 +-------
network/connection.c | 2 +-
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/input/device.c b/input/device.c
index f7f96be..3c3f9fd 100644
--- a/input/device.c
+++ b/input/device.c
@@ -315,12 +315,6 @@ failed:
return FALSE;
}
-static inline DBusMessage *not_supported(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Not supported");
-}
-
static inline DBusMessage *already_connected(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
@@ -937,7 +931,7 @@ static DBusMessage *input_device_connect(DBusConnection *conn,
iconn = find_connection(idev->connections, "HID");
if (!iconn)
- return not_supported(msg);
+ return btd_error_not_supported(msg);
if (iconn->pending_connect)
return btd_error_in_progress(msg);
diff --git a/network/connection.c b/network/connection.c
index d24d96c..a652b98 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -393,7 +393,7 @@ static DBusMessage *connection_connect(DBusConnection *conn,
id = bnep_service_id(svc);
nc = find_connection(peer->connections, id);
if (!nc)
- return not_supported(msg);
+ return btd_error_not_supported(msg);
if (nc->state != DISCONNECTED)
return already_connected(msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 5/7] convert error to btd_error_not_connected()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-4-git-send-email-padovan@profusion.mobi>
---
network/connection.c | 8 +-------
serial/port.c | 2 +-
src/device.c | 4 +---
3 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/network/connection.c b/network/connection.c
index 37a7511..d24d96c 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -123,12 +123,6 @@ static inline DBusMessage *already_connected(DBusMessage *msg)
"Device already connected");
}
-static inline DBusMessage *not_connected(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Device not connected");
-}
-
static inline DBusMessage *not_permited(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
@@ -460,7 +454,7 @@ static DBusMessage *connection_disconnect(DBusConnection *conn,
return connection_cancel(conn, msg, nc);
}
- return not_connected(msg);
+ return btd_error_not_connected(msg);
}
static DBusMessage *connection_get_properties(DBusConnection *conn,
diff --git a/serial/port.c b/serial/port.c
index 1d0bfc1..0d1e600 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -533,7 +533,7 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
return btd_error_does_not_exist(msg);
if (!port->listener_id)
- return failed(msg, "Not connected");
+ return btd_error_not_connected(msg);
owner = dbus_message_get_sender(port->msg);
caller = dbus_message_get_sender(msg);
diff --git a/src/device.c b/src/device.c
index cc8131b..91b9d23 100644
--- a/src/device.c
+++ b/src/device.c
@@ -799,9 +799,7 @@ static DBusMessage *disconnect(DBusConnection *conn, DBusMessage *msg,
struct btd_device *device = user_data;
if (!device->handle)
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".NotConnected",
- "Device is not connected");
+ return btd_error_not_connected(msg);
device_request_disconnect(device, msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 4/7] convert error to btd_error_busy()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-3-git-send-email-padovan@profusion.mobi>
---
audio/source.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/audio/source.c b/audio/source.c
index a6fd8e7..9b9dab7 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -425,8 +425,7 @@ static DBusMessage *source_disconnect(DBusConnection *conn,
return btd_error_not_connected(msg);
if (source->connect || source->disconnect)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "%s", strerror(EBUSY));
+ return btd_error_busy(msg);
if (source->stream_state < AVDTP_STATE_OPEN) {
DBusMessage *reply = dbus_message_new_method_return(msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 3/7] convert errors to btd_error_does_not_exist()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-2-git-send-email-padovan@profusion.mobi>
---
audio/gateway.c | 4 +---
audio/media.c | 3 +--
plugins/service.c | 2 +-
src/device.c | 4 +---
4 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 7aec623..05b9ff7 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -522,9 +522,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
return btd_error_invalid_args(msg);
if (strcmp(gw->agent->path, path) != 0)
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".Failed",
- "Unknown object path");
+ return btd_error_does_not_exist(msg);
g_dbus_remove_watch(device->conn, gw->agent->watch);
diff --git a/audio/media.c b/audio/media.c
index b893231..0e6ccc9 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -351,8 +351,7 @@ static DBusMessage *unregister_endpoint(DBusConnection *conn, DBusMessage *msg,
endpoint = media_adapter_find_endpoint(adapter, sender, path, NULL);
if (endpoint == NULL)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Endpoint not registered");
+ return btd_error_does_not_exist(msg);
media_endpoint_remove(endpoint);
diff --git a/plugins/service.c b/plugins/service.c
index 5267671..a442d53 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -600,7 +600,7 @@ static DBusMessage *request_authorization(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
if (find_pending_by_sender(serv_adapter, sender))
- return failed(msg);
+ return btd_error_does_not_exist(msg);
user_record = find_record(serv_adapter, handle, sender);
if (!user_record) {
diff --git a/src/device.c b/src/device.c
index 1b8d581..cc8131b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -723,9 +723,7 @@ static DBusMessage *cancel_discover(DBusConnection *conn,
const char *requestor;
if (!device->browse)
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".Failed",
- "No pending discovery");
+ return btd_error_does_not_exist(msg);
if (!dbus_message_is_method_call(device->browse->msg, DEVICE_INTERFACE,
"DiscoverServices"))
--
1.7.3.2
^ permalink raw reply related
* [PATCH 2/7] convert errors to btd_error_not_authorized()
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1291839961-14940-1-git-send-email-padovan@profusion.mobi>
---
audio/gateway.c | 3 +--
audio/transport.c | 8 ++++----
network/connection.c | 2 +-
serial/port.c | 2 +-
serial/proxy.c | 4 ++--
5 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 93c4301..7aec623 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -514,8 +514,7 @@ static DBusMessage *unregister_agent(DBusConnection *conn,
goto done;
if (strcmp(gw->agent->name, dbus_message_get_sender(msg)) != 0)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "Permission denied");
+ return btd_error_not_authorized(msg);
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_OBJECT_PATH, &path,
diff --git a/audio/transport.c b/audio/transport.c
index 48af0ea..e2ee400 100644
--- a/audio/transport.c
+++ b/audio/transport.c
@@ -443,10 +443,10 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg,
owner = media_transport_find_owner(transport, sender);
if (owner != NULL)
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
if (media_transport_acquire(transport, accesstype) == FALSE)
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
owner = media_owner_create(transport, msg, accesstype);
req = g_new0(struct acquire_request, 1);
@@ -476,7 +476,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
owner = media_transport_find_owner(transport, sender);
if (owner == NULL)
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
if (g_strcmp0(owner->accesstype, accesstype) == 0)
media_owner_remove(owner);
@@ -484,7 +484,7 @@ static DBusMessage *release(DBusConnection *conn, DBusMessage *msg,
media_transport_release(transport, accesstype);
g_strdelimit(owner->accesstype, accesstype, ' ');
} else
- return error_failed(msg, strerror(EPERM));
+ return btd_error_not_authorized(msg);
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
}
diff --git a/network/connection.c b/network/connection.c
index 7380cbe..37a7511 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -438,7 +438,7 @@ static DBusMessage *connection_cancel(DBusConnection *conn,
const char *caller = dbus_message_get_sender(msg);
if (!g_str_equal(owner, caller))
- return not_permited(msg);
+ return btd_error_not_authorized(msg);
connection_destroy(conn, nc);
diff --git a/serial/port.c b/serial/port.c
index add8ae0..1d0bfc1 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -538,7 +538,7 @@ static DBusMessage *port_disconnect(DBusConnection *conn,
owner = dbus_message_get_sender(port->msg);
caller = dbus_message_get_sender(msg);
if (!g_str_equal(owner, caller))
- return failed(msg, "Operation not permited");
+ return btd_error_not_authorized(msg);
port_release(port);
diff --git a/serial/proxy.c b/serial/proxy.c
index 778deb0..c779c4e 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -728,7 +728,7 @@ static DBusMessage *proxy_set_serial_params(DBusConnection *conn,
/* Don't allow change TTY settings if it is open */
if (prx->local)
- return failed(msg, "Not allowed");
+ return btd_error_not_authorized(msg);
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_STRING, &ratestr,
@@ -1112,7 +1112,7 @@ static DBusMessage *remove_proxy(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
if (g_strcmp0(prx->owner, sender) != 0)
- return failed(msg, "Permission denied");
+ return btd_error_not_authorized(msg);
unregister_proxy(prx);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 1/7] Fix coding styling issues in src/error.c
From: Gustavo F. Padovan @ 2010-12-08 20:25 UTC (permalink / raw)
To: linux-bluetooth
---
src/error.c | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/src/error.c b/src/error.c
index 3c09567..0d33fb5 100644
--- a/src/error.c
+++ b/src/error.c
@@ -51,8 +51,7 @@ DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
DBusMessage *btd_error_invalid_args(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".InvalidArguments",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments",
"Invalid arguments in method call");
}
@@ -64,49 +63,42 @@ DBusMessage *btd_error_busy(DBusMessage *msg)
DBusMessage *btd_error_already_exists(DBusMessage *msg)
{
- return g_dbus_create_error(msg,
- ERROR_INTERFACE ".AlreadyExists",
- "Already Exists");
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyExists",
+ "Already Exists");
}
DBusMessage *btd_error_not_supported(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotSupported",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotSupported",
"Operation is not supported");
}
DBusMessage *btd_error_not_connected(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotConnected",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotConnected",
"Not Connected");
}
DBusMessage *btd_error_in_progress(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".InProgress",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress",
"In Progress");
}
DBusMessage *btd_error_not_available(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotAvailable",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable",
"Operation currently not available");
}
DBusMessage *btd_error_does_not_exist(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".DoesNotExist",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist",
"Does Not Exist");
}
DBusMessage *btd_error_not_authorized(DBusMessage *msg)
{
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".NotAuthorized",
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAuthorized",
"Operation Not Authorized");
}
--
1.7.3.2
^ permalink raw reply related
* Re: [PATCH 1/1] bluetooth: add NULL pointer check in hci
From: Gustavo F. Padovan @ 2010-12-08 15:26 UTC (permalink / raw)
To: Jun Nie; +Cc: Vinicius Costa Gomes, Brian Gix, linux-bluetooth
In-Reply-To: <AANLkTinN3R4q-YA=4jweveB4LfE9S2SwhCK2xXYORw6W@mail.gmail.com>
Hi Jun,
* Jun Nie <niej0001@gmail.com> [2010-12-08 13:46:34 +0800]:
> From e729eda3b2cfae501c704e2eb39e07aa1b8607f0 Mon Sep 17 00:00:00 2001
> From: Jun Nie <njun@marvell.com>
> Date: Tue, 7 Dec 2010 14:03:38 +0800
> Subject: [PATCH] bluetooth: add NULL pointer check in hci
>
> If we fail to find a hci device pointer in hci_uart, don't try
> to deref the NULL one we do have.
>
> Signed-off-by: Jun Nie <njun@marvell.com>
> ---
> drivers/bluetooth/hci_ldisc.c | 6 ++++--
> 1 files changed, 4 insertions(+), 2 deletions(-)
Patch is applied now, thanks.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: [PATCH] Changed obex_service_driver put() signature.
From: Johan Hedberg @ 2010-12-08 15:18 UTC (permalink / raw)
To: Slawomir Bochenski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikzUraZ9ac5qf9ePG8YKo0Sx0B2YZoKz8HoRTmn@mail.gmail.com>
Hi,
On Wed, Dec 08, 2010, Slawomir Bochenski wrote:
> This API change is needed for implementing Message Access Profile, as
> MAP uses application parameters in puts also (for example
> SetMessageStatus function, see MAP specification, chapter 5.7) and in
> order to access application parameters headers access to obex object
> is required.
>
> ---
> plugins/ftp.c | 3 ++-
> plugins/opp.c | 3 ++-
> plugins/syncevolution.c | 3 ++-
> src/obex.c | 2 +-
> src/service.h | 3 ++-
> 5 files changed, 9 insertions(+), 5 deletions(-)
The patch looks good, but I can't apply it with git am. I get the
following:
fatal: corrupt patch at line 14
Patch failed at 0001 Changed obex_service_driver put() signature.
Could you try recreating it with git format-patch and resending with git
send-email? Thanks.
Btw, summary line should start with "Change ..." instead of "Changed
..." and it shouldn't end with a .
Johan
^ permalink raw reply
* Re: [PATCH 1/3] Add support for stat files bigger than 2GB on 32-bit systems
From: Johan Hedberg @ 2010-12-08 15:15 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1291821222-18990-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Wed, Dec 08, 2010, Luiz Augusto von Dentz wrote:
> From stat documentation:
>
> "(stat()) path refers to a file whose size cannot be represented in the
> type off_t. This can occur when an application compiled on a 32-bit
> platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size
> exceeds (2<<31)-1 bits."
>
> To fix this now size header is omitted when the file is over 32-bit, but
> it is able to transfer it by using 64-bit variables. In addition to that
> folder-listing now should report such big sizes properly.
> ---
> acinclude.m4 | 2 +-
> client/transfer.c | 5 +++--
> plugins/filesystem.c | 7 ++++---
> src/obex-priv.h | 6 +++---
> src/obex.c | 7 ++++---
> 5 files changed, 15 insertions(+), 12 deletions(-)
Thanks. The patch has been pushed upstream.
Johan
^ permalink raw reply
* [PATCH 1/3] Add support for stat files bigger than 2GB on 32-bit systems
From: Luiz Augusto von Dentz @ 2010-12-08 15:13 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>From stat documentation:
"(stat()) path refers to a file whose size cannot be represented in the
type off_t. This can occur when an application compiled on a 32-bit
platform without -D_FILE_OFFSET_BITS=64 calls stat() on a file whose size
exceeds (2<<31)-1 bits."
To fix this now size header is omitted when the file is over 32-bit, but
it is able to transfer it by using 64-bit variables. In addition to that
folder-listing now should report such big sizes properly.
---
acinclude.m4 | 2 +-
client/transfer.c | 5 +++--
plugins/filesystem.c | 7 ++++---
src/obex-priv.h | 6 +++---
src/obex.c | 7 ++++---
5 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/acinclude.m4 b/acinclude.m4
index 4594073..3d1f511 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -12,7 +12,7 @@ AC_DEFUN([AC_PROG_CC_PIE], [
AC_DEFUN([COMPILER_FLAGS], [
if (test "${CFLAGS}" = ""); then
- CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2"
+ CFLAGS="-Wall -O2 -D_FORTIFY_SOURCE=2 -D_FILE_OFFSET_BITS=64"
fi
if (test "$USE_MAINTAINER_MODE" = "yes"); then
CFLAGS+=" -Werror -Wextra"
diff --git a/client/transfer.c b/client/transfer.c
index 6eec513..fdcaa46 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -470,7 +470,7 @@ int transfer_put(struct transfer_data *transfer, transfer_callback_t func,
struct session_data *session = transfer->session;
gw_obex_xfer_cb_t cb;
struct stat st;
- int fd;
+ int fd, size;
if (transfer->xfer != NULL)
return -EALREADY;
@@ -497,8 +497,9 @@ int transfer_put(struct transfer_data *transfer, transfer_callback_t func,
cb = put_xfer_progress;
done:
+ size = transfer->size < UINT32_MAX ? transfer->size : 0;
transfer->xfer = gw_obex_put_async(session->obex, transfer->name,
- transfer->type, transfer->size,
+ transfer->type, size,
-1, NULL);
if (transfer->xfer == NULL)
return -ENOTCONN;
diff --git a/plugins/filesystem.c b/plugins/filesystem.c
index bb758ab..b4ff556 100644
--- a/plugins/filesystem.c
+++ b/plugins/filesystem.c
@@ -66,7 +66,7 @@
#define FL_PARENT_FOLDER_ELEMENT "<parent-folder/>" EOL_CHARS
-#define FL_FILE_ELEMENT "<file name=\"%s\" size=\"%lu\"" \
+#define FL_FILE_ELEMENT "<file name=\"%s\" size=\"%" PRIu64 "\"" \
" %s accessed=\"%s\" " \
"modified=\"%s\" created=\"%s\"/>" EOL_CHARS
@@ -121,8 +121,9 @@ static char *file_stat_line(char *filename, struct stat *fstat,
ret = g_strdup_printf(FL_FOLDER_ELEMENT, escaped, perm,
atime, mtime, ctime);
} else if (S_ISREG(fstat->st_mode))
- ret = g_strdup_printf(FL_FILE_ELEMENT, escaped, fstat->st_size,
- perm, atime, mtime, ctime);
+ ret = g_strdup_printf(FL_FILE_ELEMENT, escaped,
+ (uint64_t) fstat->st_size,
+ perm, atime, mtime, ctime);
g_free(escaped);
diff --git a/src/obex-priv.h b/src/obex-priv.h
index c9be1c5..0806a56 100644
--- a/src/obex-priv.h
+++ b/src/obex-priv.h
@@ -33,9 +33,9 @@ struct obex_session {
char *path;
time_t time;
uint8_t *buf;
- int32_t pending;
- int32_t offset;
- int32_t size;
+ int64_t pending;
+ int64_t offset;
+ int64_t size;
void *object;
gboolean aborted;
struct obex_service_driver *service;
diff --git a/src/obex.c b/src/obex.c
index 6d4430d..effb81e 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -590,7 +590,8 @@ static int obex_read_stream(struct obex_session *os, obex_t *obex,
/* only write if both object and driver are valid */
if (os->object == NULL || os->driver == NULL) {
- DBG("Stored %u bytes into temporary buffer", os->pending);
+ DBG("Stored %" PRIu64 " bytes into temporary buffer",
+ os->pending);
return 0;
}
@@ -796,7 +797,7 @@ static void cmd_get(struct obex_session *os, obex_t *obex, obex_object_t *obj)
if (err < 0)
goto done;
- if (os->size != OBJECT_SIZE_UNKNOWN) {
+ if (os->size != OBJECT_SIZE_UNKNOWN && os->size < UINT32_MAX) {
hd.bq4 = os->size;
OBEX_ObjectAddHeader(obex, obj,
OBEX_HDR_LENGTH, hd, 4, 0);
@@ -1005,7 +1006,7 @@ static gboolean check_put(obex_t *obex, obex_object_t *obj)
case OBEX_HDR_LENGTH:
os->size = hd.bq4;
- DBG("OBEX_HDR_LENGTH: %d", os->size);
+ DBG("OBEX_HDR_LENGTH: %" PRIu64, os->size);
break;
case OBEX_HDR_TIME:
os->time = parse_iso8610((const char *) hd.bs, hlen);
--
1.7.1
^ permalink raw reply related
* [PATCH] Changed obex_service_driver put() signature.
From: Slawomir Bochenski @ 2010-12-08 14:50 UTC (permalink / raw)
To: linux-bluetooth
This API change is needed for implementing Message Access Profile, as
MAP uses application parameters in puts also (for example
SetMessageStatus function, see MAP specification, chapter 5.7) and in
order to access application parameters headers access to obex object
is required.
---
plugins/ftp.c | 3 ++-
plugins/opp.c | 3 ++-
plugins/syncevolution.c | 3 ++-
src/obex.c | 2 +-
src/service.h | 3 ++-
5 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/plugins/ftp.c b/plugins/ftp.c
index 91c77a3..a952f64 100644
--- a/plugins/ftp.c
+++ b/plugins/ftp.c
@@ -258,7 +258,8 @@ static int ftp_chkput(struct obex_session *os,
void *user_data)
return ret;
}
-static int ftp_put(struct obex_session *os, void *user_data)
+static int ftp_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
struct ftp_session *ftp = user_data;
const char *name = obex_get_name(os);
diff --git a/plugins/opp.c b/plugins/opp.c
index 05f944f..17c4356 100644
--- a/plugins/opp.c
+++ b/plugins/opp.c
@@ -155,7 +155,8 @@ skip_auth:
return ret;
}
-static int opp_put(struct obex_session *os, void *user_data)
+static int opp_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
const char *name = obex_get_name(os);
const char *folder = obex_get_root_folder(os);
diff --git a/plugins/syncevolution.c b/plugins/syncevolution.c
index bf436a9..8041df6 100644
--- a/plugins/syncevolution.c
+++ b/plugins/syncevolution.c
@@ -243,7 +243,8 @@ failed:
return NULL;
}
-static int synce_put(struct obex_session *os, void *user_data)
+static int synce_put(struct obex_session *os, obex_object_t *obj,
+ void *user_data)
{
return 0;
}
diff --git a/src/obex.c b/src/obex.c
index 6d4430d..1649cd0 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -1089,7 +1089,7 @@ static void cmd_put(struct obex_session *os,
obex_t *obex, obex_object_t *obj)
return;
}
- err = os->service->put(os, os->service_data);
+ err = os->service->put(os, obj, os->service_data);
if (err < 0)
os_set_response(obj, err);
}
diff --git a/src/service.h b/src/service.h
index 1726c43..a844885 100644
--- a/src/service.h
+++ b/src/service.h
@@ -34,7 +34,8 @@ struct obex_service_driver {
void (*progress) (struct obex_session *os, void *user_data);
int (*get) (struct obex_session *os, obex_object_t *obj,
gboolean *stream, void *user_data);
- int (*put) (struct obex_session *os, void *user_data);
+ int (*put) (struct obex_session *os, obex_object_t *obj,
+ void *user_data);
int (*chkput) (struct obex_session *os, void *user_data);
int (*setpath) (struct obex_session *os, obex_object_t *obj,
void *user_data);
--
Slawomir Bochenski
^ permalink raw reply related
* Re: [PATCH v2] Fix regression causing crash in 3-way calling
From: Johan Hedberg @ 2010-12-08 12:54 UTC (permalink / raw)
To: Dmitriy Paliy; +Cc: linux-bluetooth
In-Reply-To: <1291809471-806-2-git-send-email-dmitriy.paliy@nokia.com>
Hi Dmitriy,
On Wed, Dec 08, 2010, Dmitriy Paliy wrote:
> Fix obexd crash in 3-way calling scenario. Crash happens when there
> is redialed second incoming call. Cache for the PBAP session is
> already created at that moment, but PBAP object is destroyed. Crash
> happens when object is dereferenced in vobject_list_open.
>
> Therefore, PBAP object has to be created before any attempt to write
> cached data to buffer associated to this object.
>
> However, cache_ready_notify function, which is invoked in
> vobject_vcard_open for valid cache case, sends also PBAP object data
> via callback function to obex.c and written to OBEX stream as GET
> response in handle_async_io handler function.
>
> A new response is sent to OBEX stream after cache_ready_notify exists
> to vobject_list_open function, which is callback function for
> obex_mime_type_driver. Such leads to undefined befavior. Therefore,
> cache_ready_notify is splitted in two cache_ready_notify and
> generate_response functions.
>
> generate_response fills data to buffer and returns error, if any,
> while cache_ready_notify notifies OBEX core to write this data to
> stream.
>
> In order to avoid writing to stream twice, cache_ready_notify is
> replaced by generate_response in vobject_list_open. As a result,
> PBAP buffer data is generated from existing cache and sent to
> stream upon start of OBEX stream after vobject_list_open exits.
> ---
> plugins/pbap.c | 98 +++++++++++++++++++++++++++++++-------------------------
> 1 files changed, 54 insertions(+), 44 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 5/9] mfd: Add UART support for the ST-Ericsson CG2900.
From: Arnd Bergmann @ 2010-12-08 12:51 UTC (permalink / raw)
To: Par-Gunnar Hjalmdahl
Cc: Pavan Savoy, Vitaly Wool, Alan Cox, linus.walleij,
linux-bluetooth, linux-kernel, Marcel Holtmann
In-Reply-To: <AANLkTi=B4wT5SbN2qyyO5RZd7qMnkZXHpB6d=RTQeRtX@mail.gmail.com>
On Wednesday 08 December 2010, Par-Gunnar Hjalmdahl wrote:
> > Marcel did previously suggest a bus-driver sort of a structure, where
> > the transport are sort of adapter drivers, the data interpretation
> > logic like splitting HCI-events, FM CH-8 packets all fall into the
> > algos drivers and the actual Bluetooth driver or GPS or FM-V4L2
> > drivers falling into the client/protocol drivers....
>
> What the cg2900 driver has now turned into is almost like the
> cg2900_core acting as a bus, identifying which chip is connected and
> choosing correct chip driver from this. This cg2900_core module should
> not contain any vendor specific code. When identified, the chip driver
> then uses MFD to setup channels according to the functionality it
> supports (one MFD device per H4 channel). It's hard to explain
> everything of the new architecture here. I would like you to check the
> new patch set I'm trying hard to create at the moment. I will try to
> get it out on Friday, but it's hard to promise anything (there is a
> lot of work to do with it). There you could then see if it is
> something you could consider useful.
It sounds really good, I'm looking forward to your new patch set!
If it's generic enough to replace the ti-st code, that would be a
clear sign that you are on the right track ;-)
I'm not asking to fix their code yourself, but it might be good to
look at it and see if it would work.
Arnd
^ permalink raw reply
* Re: [PATCH 5/9] mfd: Add UART support for the ST-Ericsson CG2900.
From: Par-Gunnar Hjalmdahl @ 2010-12-08 12:21 UTC (permalink / raw)
To: Pavan Savoy
Cc: Arnd Bergmann, Vitaly Wool, Alan Cox, linus.walleij,
linux-bluetooth, linux-kernel, Marcel Holtmann
In-Reply-To: <AANLkTimCKK9NAiXD4wsCkJt8bsy_exYEBWdb1+M6+NOE@mail.gmail.com>
Hi Pavan et al,
2010/12/8 Pavan Savoy <pavan_savoy@sify.com>:
> On Tue, Dec 7, 2010 at 4:37 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Monday 06 December 2010 22:24:34 Vitaly Wool wrote:
>>> On Mon, Dec 6, 2010 at 5:54 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>>>
>>> >> But I was trying to make a different point here. On a basic level,
>>> >> there's this cg2000 chip from STE that does BT, FM and GPS. There's
>>> >> the chip from TI that does BT, FM and GPS, and there's the Broadcom
>>> >> chip that does BT+FM. They all use HCI to access the other functions
>>> >> of the combo chip and they do it in a really simiar way, with the
>>> >> differences mostly in power management techniques. So I think it's
>>> >> quite sensible to have some kind of framework that is suitable for
>>> >> such devices.
>>> >
>>> > Yes, I agree 100% in principle. I could not find the code that
>>> > Broadcom/TI FM and GPS stuff so far, can you point us to that?
>>>
>>> Sure, the TI "shared transport" code is mostly at drivers/misc/ti-st.
>>>
>>> Some Broadcom BCM43xx chips work in a similar way AFAIK but I'm not
>>> sure about the mainline support for those.
>>
>> Ah, it had not occured to me to look in drivers/misc. Looking at the
>> code over there, it becomes much clearer what your point is. Evidently
>> the ti-st driver implements a line discipline similar to, but conflictin=
g
>> with hci_ldisc, and it has its own copy of the hci_ll code.
>>
>> I guess this is exactly what we're trying to avoid having with the
>> cg2900 code ;-).
>>
>>> > The cg2900 solution for this was to use MFD (plus another layer
>>> > in the posted version, but that will go away I assume). Using
>>> > MFD is not the only possibility here, but I could not see anything
>>> > wrong with it either. Do you think we can move them all over to
>>> > use MFD infrastructure?
>>>
>>> I guess so but it's probably more of a detail than what I'm up to now :=
)
>>
>> Agreed.
>>
>>> >> But generally speaking, isn't a line discipline/driver attached to a
>>> >> tty? We can use dumb tty for e. g. SPI and still be able to use
>>> >> hci_ll, right?
>>> >
>>> > I suggested that as well, but the point was made that this would
>>> > add an unnecessary indirection for the SPI case, which is not
>>> > really much like a serial port. It's certainly possible to do it
>>> > like you say, but if we add a way to register the high-level
>>> > protocols with an HCI-like multi-function device, we could
>>> > also do it in a way that does not rely on tty-ldisc but keeps it
>>> > as one of the options.
>>>
>>> I actually don't think it's such a big indirection, I prefer to think
>>> of it more as of the abstraction layer. If not use this, are we going
>>> to have direct SPI device drivers? I'm afraid we might end up with a
>>> huge duplication of code in that case.
>>
>> The question is how it should be modeled in a better way than today.
>>
>> I believe we already agree it should be something like
>>
>> =A0 bt =A0 ti-radio =A0 =A0st-e-radio =A0 =A0ti-gps =A0 st-e-gps =A0broa=
dcom-radio ...
>> =A0 | =A0 =A0 =A0 =A0 | =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0 =A0| =
=A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0 |
>> =A0 +---------+----------+---------+--+----------+----------+---------+
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0common-hci-module
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0|
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0+-----------+-----------+
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A0 =A0 =A0| =A0 =A0 =
=A0 | =A0 =A0 =A0|
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0serial =A0 =A0spi =A0 =A0 i2c =A0=
=A0...
>
> Yes, this sort of architecture would certainly help...
> However, I suppose the most common question as one of you stated above
> was how can the channel -ID and other factors such as offset-header
> packet format be generalized?
>
> As in over here, will the common-hci-module work fine, If say ti-radio
> says he is expecting packets starting from id-8 which is of length 10?
> and also work for st-e-radio which would say expecting data from id-6
> with 15 max bytes?
> Answering this I suppose would solve a lot of our problems....
>
> Marcel did previously suggest a bus-driver sort of a structure, where
> the transport are sort of adapter drivers, the data interpretation
> logic like splitting HCI-events, FM CH-8 packets all fall into the
> algos drivers and the actual Bluetooth driver or GPS or FM-V4L2
> drivers falling into the client/protocol drivers....
>
What the cg2900 driver has now turned into is almost like the
cg2900_core acting as a bus, identifying which chip is connected and
choosing correct chip driver from this. This cg2900_core module should
not contain any vendor specific code. When identified, the chip driver
then uses MFD to setup channels according to the functionality it
supports (one MFD device per H4 channel). It's hard to explain
everything of the new architecture here. I would like you to check the
new patch set I'm trying hard to create at the moment. I will try to
get it out on Friday, but it's hard to promise anything (there is a
lot of work to do with it). There you could then see if it is
something you could consider useful.
/P-G
>
>
>> Any objections to this?
>>
>> If you agree, I think we should discuss the alternatives for the common
>> module. I think you are saying we should make the common module a single
>> ldisc doing the multiplexing and have all transports register as ttys in=
to
>> it, right?
>>
>> What we discussed before was to split it into multiple modules, one for
>> the tty ldisc and one for the common code, and then have the spi/i2c/...
>> drivers feed into the common multiplexer without going through tty.
>>
>> I don't currently see a significant advantage or disadvantage with eithe=
r
>> approach.
>>
>> =A0 =A0 =A0 =A0Arnd
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoot=
h" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
>>
>
^ permalink raw reply
* [PATCH v2] Fix regression causing crash in 3-way calling
From: Dmitriy Paliy @ 2010-12-08 11:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1291809471-806-1-git-send-email-dmitriy.paliy@nokia.com>
Fix obexd crash in 3-way calling scenario. Crash happens when there
is redialed second incoming call. Cache for the PBAP session is
already created at that moment, but PBAP object is destroyed. Crash
happens when object is dereferenced in vobject_list_open.
Therefore, PBAP object has to be created before any attempt to write
cached data to buffer associated to this object.
However, cache_ready_notify function, which is invoked in
vobject_vcard_open for valid cache case, sends also PBAP object data
via callback function to obex.c and written to OBEX stream as GET
response in handle_async_io handler function.
A new response is sent to OBEX stream after cache_ready_notify exists
to vobject_list_open function, which is callback function for
obex_mime_type_driver. Such leads to undefined befavior. Therefore,
cache_ready_notify is splitted in two cache_ready_notify and
generate_response functions.
generate_response fills data to buffer and returns error, if any,
while cache_ready_notify notifies OBEX core to write this data to
stream.
In order to avoid writing to stream twice, cache_ready_notify is
replaced by generate_response in vobject_list_open. As a result,
PBAP buffer data is generated from existing cache and sent to
stream upon start of OBEX stream after vobject_list_open exits.
---
plugins/pbap.c | 98 +++++++++++++++++++++++++++++++-------------------------
1 files changed, 54 insertions(+), 44 deletions(-)
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 1a7d001..4086227 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -378,7 +378,7 @@ static GSList *sort_entries(GSList *l, uint8_t order, uint8_t search_attrib,
return sorted;
}
-static void cache_ready_notify(void *user_data)
+static int generate_response(void *user_data)
{
struct pbap_session *pbap = user_data;
GSList *sorted;
@@ -398,7 +398,8 @@ static void cache_ready_notify(void *user_data)
memcpy(hdr->val, &size, sizeof(size));
pbap->obj->buffer = g_string_new_len(aparam, sizeof(aparam));
- goto done;
+
+ return 0;
}
/*
@@ -409,11 +410,8 @@ static void cache_ready_notify(void *user_data)
pbap->params->searchattrib,
(const char *) pbap->params->searchval);
- if (sorted == NULL) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_ERR, -ENOENT);
- return;
- }
+ if (sorted == NULL)
+ return -ENOENT;
/* Computing offset considering first entry of the phonebook */
l = g_slist_nth(sorted, pbap->params->liststartoffset);
@@ -430,11 +428,25 @@ static void cache_ready_notify(void *user_data)
g_slist_free(sorted);
-done:
- if (!pbap->cache.valid) {
- pbap->cache.valid = TRUE;
- obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
+ return 0;
+}
+
+static void cache_ready_notify(void *user_data)
+{
+ struct pbap_session *pbap = user_data;
+ int err;
+
+ DBG("");
+
+ pbap->cache.valid = TRUE;
+
+ err = generate_response(pbap);
+ if (err < 0) {
+ obex_object_set_io_flags(pbap->obj, G_IO_ERR, err);
+ return;
}
+
+ obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
}
static void cache_entry_done(void *user_data)
@@ -746,10 +758,28 @@ fail:
return NULL;
}
+static int vobject_close(void *object)
+{
+ struct pbap_object *obj = object;
+
+ DBG("");
+
+ if (obj->session)
+ obj->session->obj = NULL;
+
+ if (obj->buffer)
+ g_string_free(obj->buffer, TRUE);
+
+ g_free(obj);
+
+ return 0;
+}
+
static void *vobject_list_open(const char *name, int oflag, mode_t mode,
void *context, size_t *size, int *err)
{
struct pbap_session *pbap = context;
+ struct pbap_object *obj = NULL;
int ret;
DBG("name %s context %p valid %d", name, context, pbap->cache.valid);
@@ -766,30 +796,25 @@ static void *vobject_list_open(const char *name, int oflag, mode_t mode,
/* PullvCardListing always get the contacts from the cache */
- if (pbap->cache.valid) {
- /*
- * Valid cache and empty buffer mean that cache was already
- * created within a single session, but no data is available.
- */
- if (!pbap->obj->buffer) {
- ret = -ENOENT;
- goto fail;
- }
-
- cache_ready_notify(pbap);
- goto done;
- }
-
- ret = phonebook_create_cache(name,
- cache_entry_notify, cache_ready_notify, pbap);
+ obj = vobject_create(pbap);
+ if (pbap->cache.valid)
+ ret = generate_response(pbap);
+ else
+ ret = phonebook_create_cache(name, cache_entry_notify,
+ cache_ready_notify, pbap);
if (ret < 0)
goto fail;
-done:
- return vobject_create(pbap);
+ if (err)
+ *err = 0;
+
+ return obj;
fail:
+ if (obj)
+ vobject_close(obj);
+
if (err)
*err = ret;
@@ -902,21 +927,6 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count,
return string_read(obj->buffer, buf, count);
}
-static int vobject_close(void *object)
-{
- struct pbap_object *obj = object;
-
- if (obj->session)
- obj->session->obj = NULL;
-
- if (obj->buffer)
- g_string_free(obj->buffer, TRUE);
-
- g_free(obj);
-
- return 0;
-}
-
static struct obex_mime_type_driver mime_pull = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
--
1.7.0.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox