From: Luiz Augusto von Dentz <luiz.dentz-...@nokia.com>

Make use of last response set if nice is TRUE, so that applications can
set a proper error when canceling a suspended requests.
---
 lib/obex.c      |    2 +-
 lib/obex_main.c |   13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index 00f90d7..29723ec 100644
--- a/lib/obex.c
+++ b/lib/obex.c
@@ -521,7 +521,7 @@ int CALLAPI OBEX_Request(obex_t *self, obex_object_t 
*object)
        Cancel an ongoing operation.
        \param self OBEX handle
        \param nice If true an OBEX Abort will be sent if beeing client
-       or OBEX_RSP_UNAUTHORIZED as reponse if beeing server.
+       or respond with an error if beeing server.
        \return -1 on error
  */
 LIB_SYMBOL
diff --git a/lib/obex_main.c b/lib/obex_main.c
index d38a711..0a72c14 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
@@ -358,7 +358,18 @@ int obex_cancelrequest(obex_t *self, int nice)
                if (object == NULL)
                        return -1;
 
-               obex_object_setcmd(object, OBEX_CMD_ABORT, OBEX_CMD_ABORT);
+               if (self->mode == MODE_SRV) {
+                       /* Do not send continue */
+                       if (self->object->opcode != OBEX_RSP_CONTINUE)
+                               obex_object_setrsp(object, self->object->opcode,
+                                                       
self->object->lastopcode);
+                       else
+                               obex_object_setrsp(object,
+                                               OBEX_RSP_INTERNAL_SERVER_ERROR,
+                                               OBEX_RSP_INTERNAL_SERVER_ERROR);
+               } else
+                       obex_object_setcmd(object, OBEX_CMD_ABORT,
+                                                       OBEX_CMD_ABORT);
 
                if (obex_object_send(self, object, TRUE, TRUE) < 0) {
                        obex_object_delete(object);
-- 
1.7.1


------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to