2011-06-02 13:23:18

by Slawomir Bochenski

[permalink] [raw]
Subject: [PATCH 0/5] Renewed new missed calls handling

This patch series implements working means of sending application
parameters header before body while still using OpenOBEX body header
streaming, utilizing it in PBAP plugin.

First patch reverts changes that were meant to do the same, however did not
provide any change to what was being sent.


2011-06-07 09:10:33

by Slawomir Bochenski

[permalink] [raw]
Subject: Re: [PATCH 4/5] Add function for starting body streaming later

On Fri, Jun 3, 2011 at 9:40 AM, Luiz Augusto von Dentz
<[email protected]> wrote:
> What about doing this directly on obex_write_stream, so that whenever
> we read the first time an OBEX_HRD_BODY data we do start streaming? If
> that is possible this also means that we don't really need .get to
> return this boolean stream since we gonna start the stream on demand
> when the data returned is OBEX_HRD_BODY.

Yes, it is also possible. It's just a bit trickier. I'm working on
this now, so I should be able to send new patch set soon.

--
Slawomir Bochenski

2011-06-03 07:40:58

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH 4/5] Add function for starting body streaming later

Hi,

On Thu, Jun 2, 2011 at 4:23 PM, Slawomir Bochenski <[email protected]> wrote:
> PBAP and MAP profiles presents a requirement that in case of multi-packet
> responses, application parameter header shall be send in the first
> packet.
>
> Starting body streaming in OpenOBEX adds body header immediately and
> queues any other added header for sending after the streaming is
> finished. Thus to get the possibility to comply to this requirement and
> still be able to use streaming mode function to start streaming later in
> time is added.
> ---
> ?src/obex.c | ? 27 +++++++++++++++++++++++++++
> ?src/obex.h | ? ?1 +
> ?2 files changed, 28 insertions(+), 0 deletions(-)
>
> diff --git a/src/obex.c b/src/obex.c
> index 643b942..097f278 100644
> --- a/src/obex.c
> +++ b/src/obex.c
> @@ -1420,6 +1420,33 @@ int obex_aparam_write(struct obex_session *os,
> ? ? ? ? ? ? ? ? ? ? ? ?OBEX_HDR_APPARAM, hd, size, 0);
> ?}
>
> +void obex_start_streaming(struct obex_session *os, obex_object_t *obj)
> +{
> + ? ? ? obex_headerdata_t hd;
> + ? ? ? int err;
> +
> + ? ? ? os->driver->set_io_watch(os->object, NULL, NULL);
> +
> + ? ? ? hd.bs = NULL;
> + ? ? ? OBEX_ObjectAddHeader(os->obex, obj, OBEX_HDR_BODY,
> + ? ? ? ? ? ? ? ? ? ? ? hd, 0, OBEX_FL_STREAM_START);
> +
> + ? ? ? err = obex_write_stream(os, os->obex, obj);
> +
> + ? ? ? if (err == -EAGAIN) {
> + ? ? ? ? ? ? ? /* Just to be double sure */
> + ? ? ? ? ? ? ? OBEX_SuspendRequest(os->obex, obj);
> + ? ? ? ? ? ? ? os->obj = obj;
> + ? ? ? ? ? ? ? os->driver->set_io_watch(os->object, handle_async_io,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? os);
> + ? ? ? } else if (err < 0) {
> + ? ? ? ? ? ? ? os_set_response(obj, err);
> + ? ? ? } else {
> + ? ? ? ? ? ? ? /* Request has been suspended in cmd_get */
> + ? ? ? ? ? ? ? OBEX_ResumeRequest(os->obex);
> + ? ? ? }
> +}
> +
> ?int memncmp0(const void *a, size_t na, const void *b, size_t nb)
> ?{
> ? ? ? ?if (na != nb)
> diff --git a/src/obex.h b/src/obex.h
> index 94274c2..64b4cdc 100644
> --- a/src/obex.h
> +++ b/src/obex.h
> @@ -64,6 +64,7 @@ int obex_aparam_write(struct obex_session *os, obex_object_t *obj,
>
> ?const char *obex_option_root_folder(void);
> ?gboolean obex_option_symlinks(void);
> +void obex_start_streaming(struct obex_session *os, obex_object_t *obj);
>
> ?/* Just a thin wrapper around memcmp to deal with NULL values */
> ?int memncmp0(const void *a, size_t na, const void *b, size_t nb);

What about doing this directly on obex_write_stream, so that whenever
we read the first time an OBEX_HRD_BODY data we do start streaming? If
that is possible this also means that we don't really need .get to
return this boolean stream since we gonna start the stream on demand
when the data returned is OBEX_HRD_BODY.

--
Luiz Augusto von Dentz
Computer Engineer

2011-06-02 13:23:23

by Slawomir Bochenski

[permalink] [raw]
Subject: [PATCH 5/5] Send new missed calls count in first packet

This fixes the order in which OBEX headers were sent in case of PBAP
session to comply to PBAP specification, ch. 6.2.2. This is achieved by
telling pbap_get caller to not to start OpenOBEX streaming mode and then
starting it later, after sending appropriate application parameters
header. It also utilizes preexistent obex_aparam_write function.
---
plugins/pbap.c | 27 +++++++++++++++++----------
1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/plugins/pbap.c b/plugins/pbap.c
index 84661cc..21ae278 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -142,12 +142,14 @@ struct pbap_session {
uint32_t find_handle;
struct cache cache;
struct pbap_object *obj;
+ struct obex_session *obex_session;
+ obex_object_t *obex_obj;
+ gboolean needstart;
};

struct pbap_object {
GString *buffer;
GByteArray *aparams;
- gboolean firstpacket;
gboolean lastpart;
struct pbap_session *session;
void *request;
@@ -315,14 +317,20 @@ static void query_result(const char *buffer, size_t bufsize, int vcards,
if (missed > 0) {
DBG("missed %d", missed);

- pbap->obj->firstpacket = TRUE;
-
pbap->obj->aparams = g_byte_array_new();
pbap->obj->aparams = append_aparam_header(pbap->obj->aparams,
NEWMISSEDCALLS_TAG, &missed);
+ obex_aparam_write(pbap->obex_session, pbap->obex_obj,
+ pbap->obj->aparams->data,
+ pbap->obj->aparams->len);
+
}

- obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
+ if (pbap->needstart) {
+ obex_start_streaming(pbap->obex_session, pbap->obex_obj);
+ pbap->needstart = FALSE;
+ } else
+ obex_object_set_io_flags(pbap->obj, G_IO_IN, 0);
}

static void cache_entry_notify(const char *id, uint32_t handle,
@@ -655,6 +663,8 @@ static int pbap_get(struct obex_session *os, obex_object_t *obj,
}

pbap->params = params;
+ pbap->obex_session = os;
+ pbap->obex_obj = obj;

if (strcmp(type, PHONEBOOK_TYPE) == 0) {
/* Always contains the absolute path */
@@ -663,7 +673,9 @@ static int pbap_get(struct obex_session *os, obex_object_t *obj,
else
path = g_build_filename("/", name, NULL);

- *stream = (params->maxlistcount == 0 ? FALSE : TRUE);
+ *stream = FALSE;
+ if (params->maxlistcount)
+ pbap->needstart = TRUE;
} else if (strcmp(type, VCARDLISTING_TYPE) == 0) {
/* Always relative */
if (!name || strlen(name) == 0)
@@ -983,11 +995,6 @@ static ssize_t vobject_pull_read(void *object, void *buf, size_t count,
/* PhoneBookSize */
*hi = OBEX_HDR_APPARAM;
return array_read(obj->aparams, buf, count);
- } else if (obj->firstpacket) {
- /* NewMissedCalls */
- *hi = OBEX_HDR_APPARAM;
- obj->firstpacket = FALSE;
- return array_read(obj->aparams, buf, count);
} else {
/* Stream data */
*hi = OBEX_HDR_BODY;
--
1.7.4.1


2011-06-02 13:23:22

by Slawomir Bochenski

[permalink] [raw]
Subject: [PATCH 4/5] Add function for starting body streaming later

PBAP and MAP profiles presents a requirement that in case of multi-packet
responses, application parameter header shall be send in the first
packet.

Starting body streaming in OpenOBEX adds body header immediately and
queues any other added header for sending after the streaming is
finished. Thus to get the possibility to comply to this requirement and
still be able to use streaming mode function to start streaming later in
time is added.
---
src/obex.c | 27 +++++++++++++++++++++++++++
src/obex.h | 1 +
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/obex.c b/src/obex.c
index 643b942..097f278 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -1420,6 +1420,33 @@ int obex_aparam_write(struct obex_session *os,
OBEX_HDR_APPARAM, hd, size, 0);
}

+void obex_start_streaming(struct obex_session *os, obex_object_t *obj)
+{
+ obex_headerdata_t hd;
+ int err;
+
+ os->driver->set_io_watch(os->object, NULL, NULL);
+
+ hd.bs = NULL;
+ OBEX_ObjectAddHeader(os->obex, obj, OBEX_HDR_BODY,
+ hd, 0, OBEX_FL_STREAM_START);
+
+ err = obex_write_stream(os, os->obex, obj);
+
+ if (err == -EAGAIN) {
+ /* Just to be double sure */
+ OBEX_SuspendRequest(os->obex, obj);
+ os->obj = obj;
+ os->driver->set_io_watch(os->object, handle_async_io,
+ os);
+ } else if (err < 0) {
+ os_set_response(obj, err);
+ } else {
+ /* Request has been suspended in cmd_get */
+ OBEX_ResumeRequest(os->obex);
+ }
+}
+
int memncmp0(const void *a, size_t na, const void *b, size_t nb)
{
if (na != nb)
diff --git a/src/obex.h b/src/obex.h
index 94274c2..64b4cdc 100644
--- a/src/obex.h
+++ b/src/obex.h
@@ -64,6 +64,7 @@ int obex_aparam_write(struct obex_session *os, obex_object_t *obj,

const char *obex_option_root_folder(void);
gboolean obex_option_symlinks(void);
+void obex_start_streaming(struct obex_session *os, obex_object_t *obj);

/* Just a thin wrapper around memcmp to deal with NULL values */
int memncmp0(const void *a, size_t na, const void *b, size_t nb);
--
1.7.4.1


2011-06-02 13:23:21

by Slawomir Bochenski

[permalink] [raw]
Subject: [PATCH 3/5] Simplify counting new missed calls

This replaces parsing missed calls listing that was used to get the
number of missed calls that have been unread with a simple SPARQL query.

Previous code was trying to deal with misbehaviour of other tools
operating on call history entries but still was failing in some
cases. Those other tools should be fixed instead of doing workarounds in
obexd code.
---
plugins/phonebook-tracker.c | 106 +++++++++----------------------------------
1 files changed, 22 insertions(+), 84 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 37e6440..ec9aa2c 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -49,7 +49,6 @@
#define ADDR_FIELD_AMOUNT 7
#define PULL_QUERY_COL_AMOUNT 23
#define COUNT_QUERY_COL_AMOUNT 1
-#define NEW_MISSED_CALLS_COL_AMOUNT 3

#define COL_PHONE_AFF 0 /* work/home phone numbers */
#define COL_FULL_NAME 1
@@ -403,42 +402,16 @@ CALLS_CONSTRAINTS(CONSTRAINT) \
"}" \
"}"

-#define NEW_MISSED_CALLS_LIST \
- "SELECT ?c " \
- "nco:phoneNumber(?h) " \
- "nmo:isRead(?call) " \
- "WHERE { " \
- "{" \
- "?c a nco:Contact . " \
- "?c nco:hasPhoneNumber ?h . " \
- "?call a nmo:Call ; " \
- "nmo:from ?c ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered false ." \
- "}UNION{" \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?h . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered false ." \
- "?c a nco:PersonContact . " \
- "?c nco:hasPhoneNumber ?h . " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?h . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered false ." \
- "?c a nco:PersonContact . " \
- "?c nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?no . " \
- "?h maemo:localPhoneNumber ?num . " \
- "?no maemo:localPhoneNumber ?num . " \
- "} " \
- "} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call)) " \
- "LIMIT 40"
+#define NEW_MISSED_CALLS_COUNT_QUERY \
+ "SELECT COUNT(?call) WHERE {" \
+ "?c a nco:Contact ;" \
+ "nco:hasPhoneNumber ?h ." \
+ "?call a nmo:Call ;" \
+ "nmo:isSent false ;" \
+ "nmo:from ?c ;" \
+ "nmo:isAnswered false ;" \
+ "nmo:isRead false ." \
+ "}"

typedef int (*reply_list_foreach_t) (const char **reply, int num_fields,
void *user_data);
@@ -464,7 +437,6 @@ struct phonebook_data {
gboolean vcardentry;
const struct apparam_field *params;
GSList *contacts;
- GSList *numbers;
phonebook_cache_ready_cb ready_cb;
phonebook_entry_cb entry_cb;
int newmissedcalls;
@@ -1422,31 +1394,6 @@ done:
return path;
}

-static gboolean find_checked_number(GSList *numbers, const char *number)
-{
- GSList *l;
-
- for (l = numbers; l; l = l->next) {
- GString *ph_num = l->data;
- if (g_strcmp0(ph_num->str, number) == 0)
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void gstring_free_helper(gpointer data, gpointer user_data)
-{
- g_string_free(data, TRUE);
-}
-
-static void free_data_numbers(struct phonebook_data *data)
-{
- g_slist_foreach(data->numbers, gstring_free_helper, NULL);
- g_slist_free(data->numbers);
- data->numbers = NULL;
-}
-
static int pull_newmissedcalls(const char **reply, int num_fields,
void *user_data)
{
@@ -1454,29 +1401,21 @@ static int pull_newmissedcalls(const char **reply, int num_fields,
reply_list_foreach_t pull_cb;
int col_amount, err;
const char *query;
+ int nmissed;

- if (num_fields < 0 || reply == NULL)
- goto done;
+ if (num_fields < 0) {
+ data->cb(NULL, 0, num_fields, 0, TRUE, data->user_data);

- if (!find_checked_number(data->numbers, reply[1])) {
- if (g_strcmp0(reply[2], "false") == 0)
- data->newmissedcalls++;
- else {
- GString *number = g_string_new(reply[1]);
- data->numbers = g_slist_prepend(data->numbers,
- number);
- }
+ return -EINTR;
}

- return 0;
-
-done:
- DBG("newmissedcalls %d", data->newmissedcalls);
- free_data_numbers(data);
+ if (reply != NULL) {
+ nmissed = atoi(reply[0]);
+ data->newmissedcalls =
+ nmissed <= UINT8_MAX ? nmissed : UINT8_MAX;
+ DBG("newmissedcalls %d", data->newmissedcalls);

- if (num_fields < 0) {
- data->cb(NULL, 0, num_fields, 0, TRUE, data->user_data);
- return -EINTR;
+ return 0;
}

if (data->params->maxlistcount == 0) {
@@ -1514,7 +1453,6 @@ void phonebook_req_finalize(void *request)
g_object_unref(data->query_canc);
}

- free_data_numbers(data);
free_data_contacts(data);
g_free(data->req_name);
g_free(data);
@@ -1558,8 +1496,8 @@ int phonebook_pull_read(void *request)
/* new missed calls amount should be counted only once - it
* will be done during generating first part of results of
* missed calls history */
- query = NEW_MISSED_CALLS_LIST;
- col_amount = NEW_MISSED_CALLS_COL_AMOUNT;
+ query = NEW_MISSED_CALLS_COUNT_QUERY;
+ col_amount = COUNT_QUERY_COL_AMOUNT;
pull_cb = pull_newmissedcalls;
} else if (data->params->maxlistcount == 0) {
query = name2count_query(data->req_name);
--
1.7.4.1


2011-06-02 13:23:20

by Slawomir Bochenski

[permalink] [raw]
Subject: [PATCH 2/5] Send new missed calls count once

Change introduced by commit b0619290e4128bb583268bfbfbb66de9a30ecf7c
prevented calling count query multiple times when getting the phone book
in parts. However value of newmissedcalls was kept between calls to
phonebook_pull_read() resulting in adding application parameters header
multiple times.
---
plugins/phonebook-tracker.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 1022d3a..37e6440 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -1551,6 +1551,8 @@ int phonebook_pull_read(void *request)
if (!data)
return -ENOENT;

+ data->newmissedcalls = 0;
+
if (g_strcmp0(data->req_name,"/telecom/mch.vcf") == 0 &&
data->tracker_index == 0) {
/* new missed calls amount should be counted only once - it
--
1.7.4.1


2011-06-02 13:23:19

by Slawomir Bochenski

[permalink] [raw]
Subject: [PATCH 1/5] Revert API changes to mime driver read function

This reverts parts of commit e0b3283e20ba885018010a6a8ae49b7c313958e8. API
changes introduced before were meant to guarantee required PBAP functionality
of sending application parameters header in first packet of multi-packet
response.

However OBEX_FL_FIT_ONE_PACKET does not serve this purpose - it is for making
sure that all headers will fit fully into one packet (thus FIT_ONE_PACKET),
returning error from OBEX_ObjectAddHeader() when this is not the case.

Starting the body header streaming adds body header immediately to the outgoing
queue, waiting for more data. Any attempts to OBEX_ObjectAddHeader() different
than those with hi == OBEX_HDR_DATA and OBEX_FL_STREAM_DATA present in flags,
will add new header after currently streamed body and it will be processed
after ending streaming with OBEX_FL_STREAM_DATAEND. Also in this case data is
memcpy'd, so no reason for any additional write_offset counting.
---
plugins/filesystem.c | 16 +++-------------
plugins/irmc.c | 6 +-----
plugins/mas.c | 4 +---
plugins/pbap.c | 19 +++----------------
plugins/syncevolution.c | 6 +-----
src/mimetype.h | 3 +--
src/obex-priv.h | 1 -
src/obex.c | 15 +++++----------
8 files changed, 15 insertions(+), 55 deletions(-)

diff --git a/plugins/filesystem.c b/plugins/filesystem.c
index 7bfe673..b4ff556 100644
--- a/plugins/filesystem.c
+++ b/plugins/filesystem.c
@@ -210,7 +210,7 @@ static int filesystem_close(void *object)
}

static ssize_t filesystem_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+ uint8_t *hi)
{
ssize_t ret;

@@ -218,9 +218,6 @@ static ssize_t filesystem_read(void *object, void *buf, size_t count,
if (ret < 0)
return -errno;

- if (flags)
- *flags = 0;
-
*hi = OBEX_HDR_BODY;

return ret;
@@ -502,24 +499,17 @@ ssize_t string_read(void *object, void *buf, size_t count)
return len;
}

-static ssize_t folder_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+static ssize_t folder_read(void *object, void *buf, size_t count, uint8_t *hi)
{
- if (flags)
- *flags = 0;
-
*hi = OBEX_HDR_BODY;
return string_read(object, buf, count);
}

static ssize_t capability_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+ uint8_t *hi)
{
struct capability_object *obj = object;

- if (flags)
- *flags = 0;
-
*hi = OBEX_HDR_BODY;

if (obj->buffer)
diff --git a/plugins/irmc.c b/plugins/irmc.c
index 2cf673c..83bb156 100644
--- a/plugins/irmc.c
+++ b/plugins/irmc.c
@@ -463,8 +463,7 @@ static int irmc_close(void *object)
return 0;
}

-static ssize_t irmc_read(void *object, void *buf, size_t count, uint8_t *hi,
- unsigned int *flags)
+static ssize_t irmc_read(void *object, void *buf, size_t count, uint8_t *hi)
{
struct irmc_session *irmc = object;
int len;
@@ -473,9 +472,6 @@ static ssize_t irmc_read(void *object, void *buf, size_t count, uint8_t *hi,
if (!irmc->buffer)
return -EAGAIN;

- if (flags)
- *flags = 0;
-
*hi = OBEX_HDR_BODY;
len = string_read(irmc->buffer, buf, count);
DBG("returning %d bytes", len);
diff --git a/plugins/mas.c b/plugins/mas.c
index a84b8fd..9d65fbc 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -215,13 +215,11 @@ static ssize_t any_write(void *object, const void *buf, size_t count)
return count;
}

-static ssize_t any_read(void *obj, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+static ssize_t any_read(void *obj, void *buf, size_t count, uint8_t *hi)
{
DBG("");

*hi = OBEX_HDR_BODY;
- *flags = 0;

return 0;
}
diff --git a/plugins/pbap.c b/plugins/pbap.c
index 61e7e42..84661cc 100644
--- a/plugins/pbap.c
+++ b/plugins/pbap.c
@@ -967,7 +967,7 @@ static ssize_t array_read(GByteArray *array, void *buf, size_t count)
}

static ssize_t vobject_pull_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+ uint8_t *hi)
{
struct pbap_object *obj = object;
struct pbap_session *pbap = obj->session;
@@ -982,22 +982,15 @@ static ssize_t vobject_pull_read(void *object, void *buf, size_t count,
if (pbap->params->maxlistcount == 0) {
/* PhoneBookSize */
*hi = OBEX_HDR_APPARAM;
- if (flags)
- *flags = 0;
return array_read(obj->aparams, buf, count);
} else if (obj->firstpacket) {
/* NewMissedCalls */
*hi = OBEX_HDR_APPARAM;
obj->firstpacket = FALSE;
- if (flags)
- *flags = OBEX_FL_FIT_ONE_PACKET;
return array_read(obj->aparams, buf, count);
} else {
/* Stream data */
*hi = OBEX_HDR_BODY;
- if (flags)
- *flags = 0;
-
len = string_read(obj->buffer, buf, count);
if (len == 0 && !obj->lastpart) {
/* in case when buffer is empty and we know that more
@@ -1016,7 +1009,7 @@ static ssize_t vobject_pull_read(void *object, void *buf, size_t count,
}

static ssize_t vobject_list_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+ uint8_t *hi)
{
struct pbap_object *obj = object;
struct pbap_session *pbap = obj->session;
@@ -1028,9 +1021,6 @@ static ssize_t vobject_list_read(void *object, void *buf, size_t count,
if (!pbap->cache.valid)
return -EAGAIN;

- if (flags)
- *flags = 0;
-
if (pbap->params->maxlistcount == 0) {
*hi = OBEX_HDR_APPARAM;
return array_read(obj->aparams, buf, count);
@@ -1041,7 +1031,7 @@ static ssize_t vobject_list_read(void *object, void *buf, size_t count,
}

static ssize_t vobject_vcard_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+ uint8_t *hi)
{
struct pbap_object *obj = object;

@@ -1050,9 +1040,6 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count,
if (!obj->buffer)
return -EAGAIN;

- if (flags)
- *flags = 0;
-
*hi = OBEX_HDR_BODY;
return string_read(obj->buffer, buf, count);
}
diff --git a/plugins/syncevolution.c b/plugins/syncevolution.c
index a000b36..8041df6 100644
--- a/plugins/syncevolution.c
+++ b/plugins/syncevolution.c
@@ -331,8 +331,7 @@ done:
return 0;
}

-static ssize_t synce_read(void *object, void *buf, size_t count,
- uint8_t *hi, unsigned int *flags)
+static ssize_t synce_read(void *object, void *buf, size_t count, uint8_t *hi)
{
struct synce_context *context = object;
DBusConnection *conn;
@@ -343,9 +342,6 @@ static ssize_t synce_read(void *object, void *buf, size_t count,
gboolean authenticate;
DBusPendingCall *call;

- if (flags)
- *flags = 0;
-
if (context->buffer) {
*hi = OBEX_HDR_BODY;
return string_read(context->buffer, buf, count);
diff --git a/src/mimetype.h b/src/mimetype.h
index 5bf741c..8472684 100644
--- a/src/mimetype.h
+++ b/src/mimetype.h
@@ -33,8 +33,7 @@ struct obex_mime_type_driver {
void *(*open) (const char *name, int oflag, mode_t mode,
void *driver_data, size_t *size, int *err);
int (*close) (void *object);
- ssize_t (*read) (void *object, void *buf, size_t count, uint8_t *hi,
- unsigned int *flags);
+ ssize_t (*read) (void *object, void *buf, size_t count, uint8_t *hi);
ssize_t (*write) (void *object, const void *buf, size_t count);
int (*flush) (void *object);
int (*remove) (const char *name);
diff --git a/src/obex-priv.h b/src/obex-priv.h
index 2a22f38..0806a56 100644
--- a/src/obex-priv.h
+++ b/src/obex-priv.h
@@ -46,7 +46,6 @@ struct obex_session {
obex_object_t *obj;
struct obex_mime_type_driver *driver;
gboolean finished;
- uint16_t write_offset;
};

int obex_session_start(GIOChannel *io, uint16_t tx_mtu, uint16_t rx_mtu,
diff --git a/src/obex.c b/src/obex.c
index caba2fb..643b942 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -643,13 +643,10 @@ static int obex_write_stream(struct obex_session *os,

len = MIN(os->size - os->offset, os->tx_mtu);
ptr = os->buf + os->offset;
- flags = 0;
goto add_header;
}

- ptr = os->buf + os->write_offset;
- len = os->driver->read(os->object, ptr, os->tx_mtu - os->write_offset,
- &hi, &flags);
+ len = os->driver->read(os->object, os->buf, os->tx_mtu, &hi);
if (len < 0) {
error("read(): %s (%zd)", strerror(-len), -len);
if (len == -EAGAIN)
@@ -662,15 +659,18 @@ static int obex_write_stream(struct obex_session *os,
return len;
}

+ ptr = os->buf;
+
add_header:

hd.bs = ptr;

switch (hi) {
case OBEX_HDR_BODY:
- flags |= len ? OBEX_FL_STREAM_DATA : OBEX_FL_STREAM_DATAEND;
+ flags = len ? OBEX_FL_STREAM_DATA : OBEX_FL_STREAM_DATAEND;
break;
case OBEX_HDR_APPARAM:
+ flags = 0;
break;
default:
error("read(): unkown header type %u", hi);
@@ -684,11 +684,6 @@ add_header:
os->buf = NULL;
}

- if (flags & OBEX_FL_FIT_ONE_PACKET)
- os->write_offset += len;
- else
- os->write_offset = 0;
-
os->offset += len;

return 0;
--
1.7.4.1