From 4b6976656806ed7e9303c5b3893156388b25f2bc Mon Sep 17 00:00:00 2001 From: Slawomir Bochenski Date: Wed, 13 Jul 2011 14:01:18 +0200 Subject: [PATCH] obexd: Remove *hi from mime driver read() This removes possibility of setting header type in mime driver read() function as the functionality of adding different header types is now supported by get_next_header(). --- obexd/plugins/filesystem.c | 13 +++---------- obexd/plugins/irmc.c | 3 +-- obexd/plugins/mas.c | 4 +--- obexd/plugins/pbap.c | 14 +++----------- obexd/plugins/pcsuite.c | 4 +--- obexd/plugins/syncevolution.c | 6 ++---- obexd/src/mimetype.h | 2 +- obexd/src/obex.c | 27 ++++++++------------------- 8 files changed, 20 insertions(+), 53 deletions(-) diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 4d611de28..041cca65d 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -210,8 +210,7 @@ static int filesystem_close(void *object) return 0; } -static ssize_t filesystem_read(void *object, void *buf, size_t count, - uint8_t *hi) +static ssize_t filesystem_read(void *object, void *buf, size_t count) { ssize_t ret; @@ -219,8 +218,6 @@ static ssize_t filesystem_read(void *object, void *buf, size_t count, if (ret < 0) return -errno; - *hi = OBEX_HDR_BODY; - return ret; } @@ -593,19 +590,15 @@ 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) +static ssize_t folder_read(void *object, void *buf, size_t count) { - *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) +static ssize_t capability_read(void *object, void *buf, size_t count) { struct capability_object *obj = object; - *hi = OBEX_HDR_BODY; - if (obj->buffer) return string_read(obj->buffer, buf, count); diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index cc0b9dbf7..0fb92be82 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -462,7 +462,7 @@ static int irmc_close(void *object) return 0; } -static ssize_t irmc_read(void *object, void *buf, size_t count, uint8_t *hi) +static ssize_t irmc_read(void *object, void *buf, size_t count) { struct irmc_session *irmc = object; int len; @@ -471,7 +471,6 @@ static ssize_t irmc_read(void *object, void *buf, size_t count, uint8_t *hi) if (!irmc->buffer) return -EAGAIN; - *hi = OBEX_HDR_BODY; len = string_read(irmc->buffer, buf, count); DBG("returning %d bytes", len); return len; diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index 08e47a240..0ef8c812c 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -222,12 +222,10 @@ 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) +static ssize_t any_read(void *obj, void *buf, size_t count) { DBG(""); - *hi = OBEX_HDR_BODY; - return 0; } diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index b230218d7..5455cceb3 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -978,8 +978,7 @@ static ssize_t vobject_pull_get_next_header(void *object, void *buf, size_t mtu, return 0; } -static ssize_t vobject_pull_read(void *object, void *buf, size_t count, - uint8_t *hi) +static ssize_t vobject_pull_read(void *object, void *buf, size_t count) { struct pbap_object *obj = object; struct pbap_session *pbap = obj->session; @@ -994,8 +993,6 @@ static ssize_t vobject_pull_read(void *object, void *buf, size_t count, if (pbap->params->maxlistcount == 0) return -ENOSTR; - *hi = OBEX_HDR_BODY; - len = string_read(obj->buffer, buf, count); if (len == 0 && !obj->lastpart) { /* in case when buffer is empty and we know that more @@ -1030,8 +1027,7 @@ static ssize_t vobject_list_get_next_header(void *object, void *buf, size_t mtu, return 0; } -static ssize_t vobject_list_read(void *object, void *buf, size_t count, - uint8_t *hi) +static ssize_t vobject_list_read(void *object, void *buf, size_t count) { struct pbap_object *obj = object; struct pbap_session *pbap = obj->session; @@ -1042,13 +1038,10 @@ static ssize_t vobject_list_read(void *object, void *buf, size_t count, if (pbap->params->maxlistcount == 0) return -ENOSTR; - *hi = OBEX_HDR_BODY; - return string_read(obj->buffer, buf, count); } -static ssize_t vobject_vcard_read(void *object, void *buf, size_t count, - uint8_t *hi) +static ssize_t vobject_vcard_read(void *object, void *buf, size_t count) { struct pbap_object *obj = object; @@ -1057,7 +1050,6 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count, if (!obj->buffer) return -EAGAIN; - *hi = OBEX_HDR_BODY; return string_read(obj->buffer, buf, count); } diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index 9b9337244..5276ed9ef 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -428,13 +428,11 @@ static int backup_close(void *object) return 0; } -static ssize_t backup_read(void *object, void *buf, size_t count, uint8_t *hi) +static ssize_t backup_read(void *object, void *buf, size_t count) { struct backup_object *obj = object; ssize_t ret = 0; - *hi = OBEX_HDR_BODY; - if (obj->pending_call) { DBG("cmd = %s, IN WAITING STAGE", obj->cmd); return -EAGAIN; diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index 77c1bd681..7a7866943 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -328,7 +328,7 @@ done: return 0; } -static ssize_t synce_read(void *object, void *buf, size_t count, uint8_t *hi) +static ssize_t synce_read(void *object, void *buf, size_t count) { struct synce_context *context = object; DBusConnection *conn; @@ -339,10 +339,8 @@ static ssize_t synce_read(void *object, void *buf, size_t count, uint8_t *hi) gboolean authenticate; DBusPendingCall *call; - if (context->buffer) { - *hi = OBEX_HDR_BODY; + if (context->buffer) return string_read(context->buffer, buf, count); - } conn = obex_dbus_get_connection(); if (conn == NULL) diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 3426caca0..79529b890 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -35,7 +35,7 @@ struct obex_mime_type_driver { int (*close) (void *object); ssize_t (*get_next_header)(void *object, void *buf, size_t mtu, uint8_t *hi); - ssize_t (*read) (void *object, void *buf, size_t count, uint8_t *hi); + ssize_t (*read) (void *object, void *buf, size_t count); ssize_t (*write) (void *object, const void *buf, size_t count); int (*flush) (void *object); int (*copy) (const char *name, const char *destname); diff --git a/obexd/src/obex.c b/obexd/src/obex.c index b4f37141b..49a110d3b 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -635,8 +635,6 @@ static int obex_write_stream(struct obex_session *os, { obex_headerdata_t hd; ssize_t len; - unsigned int flags; - uint8_t hi; DBG("name=%s type=%s tx_mtu=%d file=%p", os->name ? os->name : "", os->type ? os->type : "", @@ -648,7 +646,7 @@ static int obex_write_stream(struct obex_session *os, if (os->object == NULL) return -EIO; - len = os->driver->read(os->object, os->buf, os->tx_mtu, &hi); + len = os->driver->read(os->object, os->buf, os->tx_mtu); if (len < 0) { error("read(): %s (%zd)", strerror(-len), -len); if (len == -EAGAIN) @@ -670,27 +668,18 @@ static int obex_write_stream(struct obex_session *os, os->streaming = TRUE; } - hd.bs = os->buf; - - switch (hi) { - case OBEX_HDR_BODY: - 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); - return -EIO; - } - - OBEX_ObjectAddHeader(obex, obj, hi, hd, len, flags); - if (len == 0) { + hd.bs = NULL; + OBEX_ObjectAddHeader(obex, obj, OBEX_HDR_BODY, hd, 0, + OBEX_FL_STREAM_DATAEND); g_free(os->buf); os->buf = NULL; } + hd.bs = os->buf; + OBEX_ObjectAddHeader(obex, obj, OBEX_HDR_BODY, hd, len, + OBEX_FL_STREAM_DATA); + return 0; } -- 2.47.3