Luiz Augusto von Dentz | 8 Oct 2010 14:58
Picon

[PATCH] Reuse nice as response for server in OBEX_CancelRequest

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

This make possible to cancel pending operation with a proper error
instead of always respond using OBEX_RSP_UNAUTHORIZED.
---
 lib/obex.c      |    4 ++--
 lib/obex_main.c |    6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/obex.c b/lib/obex.c
index 00f90d7..270b3ee 100644
--- a/lib/obex.c
+++ b/lib/obex.c
 <at>  <at>  -520,8 +520,8  <at>  <at>  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.
+	\param nice If true or > 0 an OBEX Abort will be sent if beeing client
+	or it will be used as reponse if beeing server.
 	\return -1 on error
  */
 LIB_SYMBOL
diff --git a/lib/obex_main.c b/lib/obex_main.c
index d38a711..c58b1be 100644
--- a/lib/obex_main.c
+++ b/lib/obex_main.c
 <at>  <at>  -358,7 +358,11  <at>  <at>  int obex_cancelrequest(obex_t *self, int nice)
 		if (object == NULL)
(Continue reading)

Hendrik Sattler | 8 Oct 2010 18:38
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Am Freitag 08 Oktober 2010, 14:58:31 schrieb Luiz Augusto von Dentz:
> From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
> 
> This make possible to cancel pending operation with a proper error
> instead of always respond using OBEX_RSP_UNAUTHORIZED.

Changing obex_cancelrequest() is not the right aproach for that. 
OBEX_CMD_ABORT is the only way to tell the other side that you want to cancel 
a request. What other command do you want to use?

HS

------------------------------------------------------------------------------
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
Hendrik Sattler | 9 Oct 2010 14:47
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Am Freitag 08 Oktober 2010, 18:38:51 schrieb Hendrik Sattler:
> Am Freitag 08 Oktober 2010, 14:58:31 schrieb Luiz Augusto von Dentz:
> > From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
> > 
> > This make possible to cancel pending operation with a proper error
> > instead of always respond using OBEX_RSP_UNAUTHORIZED.
> 
> Changing obex_cancelrequest() is not the right aproach for that.
> OBEX_CMD_ABORT is the only way to tell the other side that you want to
> cancel a request. What other command do you want to use?

What I mean: you are probably looking for OBEX_ObjectSetRsp(), don't you?

HS

------------------------------------------------------------------------------
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
Luiz Augusto von Dentz | 9 Oct 2010 16:20
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Hi,

On Fri, Oct 8, 2010 at 7:38 PM, Hendrik Sattler <post <at> hendrik-sattler.de> wrote:
> Am Freitag 08 Oktober 2010, 14:58:31 schrieb Luiz Augusto von Dentz:
>> From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
>>
>> This make possible to cancel pending operation with a proper error
>> instead of always respond using OBEX_RSP_UNAUTHORIZED.
>
> Changing obex_cancelrequest() is not the right aproach for that.
> OBEX_CMD_ABORT is the only way to tell the other side that you want to cancel
> a request. What other command do you want to use?

Not really, first we cannot respond with abort because it is a
response not a request, second OBEX_ObjectSetRsp doesn't work either
because we normally are in the middle of stream transfer. It could be
made by setting  OBEX_ObjectSetRsp and than cancel request so that we
mark the object->abort which are latter check on send, but if it is a
general error which is not related to the object itself I find it odd
to have to set the response via OBEX_ObjectSetRsp which takes the
object pointer, that why I opt for canceling it directly via cancel so
we can completely ignore whatever response is set on object, actually
if we decide not to use nice as response on server than
OBEX_CancelRequest is useless for servers which should always use
OBEX_ObjectSetRsp + OBEX_ResumeRequest instead (we still have to fix
it tough).

--

-- 
Luiz Augusto von Dentz
Computer Engineer
(Continue reading)

Hendrik Sattler | 9 Oct 2010 22:35
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Am Samstag 09 Oktober 2010, 16:20:03 schrieb Luiz Augusto von Dentz:
> On Fri, Oct 8, 2010 at 7:38 PM, Hendrik Sattler <post <at> hendrik-sattler.de> 
wrote:
> > Am Freitag 08 Oktober 2010, 14:58:31 schrieb Luiz Augusto von Dentz:
> >> From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
> >> 
> >> This make possible to cancel pending operation with a proper error
> >> instead of always respond using OBEX_RSP_UNAUTHORIZED.
> > 
> > Changing obex_cancelrequest() is not the right aproach for that.
> > OBEX_CMD_ABORT is the only way to tell the other side that you want to
> > cancel a request. What other command do you want to use?
> 
> Not really, first we cannot respond with abort because it is a
> response not a request, second OBEX_ObjectSetRsp doesn't work either
> because we normally are in the middle of stream transfer.

Especially with stream transfers, this is easy.  You get the 
OBEX_EV_STREAMAVAIL event and can react to it.
I see a problem in lib/obex_server.c when using buffered data mode 
(OBEX_EV_PROGRESS comes to late to set a different response) but that can be 
fixed.

> It could be
> made by setting  OBEX_ObjectSetRsp and than cancel request so that we
> mark the object->abort which are latter check on send, but if it is a
> general error which is not related to the object itself I find it odd
> to have to set the response via OBEX_ObjectSetRsp which takes the
> object pointer, that why I opt for canceling it directly via cancel so
> we can completely ignore whatever response is set on object, actually
(Continue reading)

Luiz Augusto von Dentz | 10 Oct 2010 12:30
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Hi,

On Sat, Oct 9, 2010 at 11:35 PM, Hendrik Sattler
<post <at> hendrik-sattler.de> wrote:
> Am Samstag 09 Oktober 2010, 16:20:03 schrieb Luiz Augusto von Dentz:
>> On Fri, Oct 8, 2010 at 7:38 PM, Hendrik Sattler <post <at> hendrik-sattler.de>
> wrote:
>> > Am Freitag 08 Oktober 2010, 14:58:31 schrieb Luiz Augusto von Dentz:
>> >> From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
>> >>
>> >> This make possible to cancel pending operation with a proper error
>> >> instead of always respond using OBEX_RSP_UNAUTHORIZED.
>> >
>> > Changing obex_cancelrequest() is not the right aproach for that.
>> > OBEX_CMD_ABORT is the only way to tell the other side that you want to
>> > cancel a request. What other command do you want to use?
>>
>> Not really, first we cannot respond with abort because it is a
>> response not a request, second OBEX_ObjectSetRsp doesn't work either
>> because we normally are in the middle of stream transfer.

Not really, OBEX_ObjectSetRsp makes no difference, once I call
OBEX_ResumeRequest it completely ignores the response set and got
ahead and ask for more data with OBEX_EV_STREAMAVAIL, with
OBEX_CancelRequest it should be possible to forcefully cancel any
suspend request without having to resume it and deal with more events.

> Especially with stream transfers, this is easy.  You get the
> OBEX_EV_STREAMAVAIL event and can react to it.
> I see a problem in lib/obex_server.c when using buffered data mode
(Continue reading)

Hendrik Sattler | 11 Oct 2010 09:24
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Zitat von "Luiz Augusto von Dentz" <luiz.dentz <at> gmail.com>:
> From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
>
> This make possible to cancel pending operation with a proper error
> instead of always respond using OBEX_RSP_UNAUTHORIZED.

Ok, I get your point, now :)
OTOH, what if 'nice' is not a negative response? Then, the function  
name 'cancel' is rather misleading.

> ---
>  lib/obex.c      |    4 ++--
>  lib/obex_main.c |    6 +++++-
>  2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/lib/obex.c b/lib/obex.c
> index 00f90d7..270b3ee 100644
> --- a/lib/obex.c
> +++ b/lib/obex.c
>  <at>  <at>  -520,8 +520,8  <at>  <at>  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.
> +	\param nice If true or > 0 an OBEX Abort will be sent if beeing client
> +	or it will be used as reponse if beeing server.
>  	\return -1 on error
>   */
(Continue reading)

Luiz Augusto von Dentz | 11 Oct 2010 09:58
Picon

[PATCH] Fix use of state as mode

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

Old code use to have just state member but now it is separated into state
and mode.
---
 lib/obex_object.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/obex_object.c b/lib/obex_object.c
index 502cd6c..ddbd93d 100644
--- a/lib/obex_object.c
+++ b/lib/obex_object.c
 <at>  <at>  -1067,9 +1067,9  <at>  <at>  int obex_object_resume(obex_t *self, obex_object_t *object)
 	if (object->first_packet_sent && !object->continue_received)
 		return 0;

-	if (self->state & MODE_SRV) {
+	if (self->mode == MODE_SRV) {
 		forcefinalbit = TRUE;
-		if ((self->state & ~MODE_SRV) == STATE_REC)
+		if (self->state == STATE_REC)
 			allowfinalcmd = FALSE;
 	}

--

-- 
1.7.1

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
(Continue reading)

Luiz Augusto von Dentz | 11 Oct 2010 11:02
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Hi,

On Mon, Oct 11, 2010 at 10:24 AM, Hendrik Sattler
<post <at> hendrik-sattler.de> wrote:
> Zitat von "Luiz Augusto von Dentz" <luiz.dentz <at> gmail.com>:
>>
>> From: Luiz Augusto von Dentz <luiz.dentz-von <at> nokia.com>
>>
>> This make possible to cancel pending operation with a proper error
>> instead of always respond using OBEX_RSP_UNAUTHORIZED.
>
> Ok, I get your point, now :)
> OTOH, what if 'nice' is not a negative response? Then, the function name
> 'cancel' is rather misleading.
>
>> ---
>>  lib/obex.c      |    4 ++--
>>  lib/obex_main.c |    6 +++++-
>>  2 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/obex.c b/lib/obex.c
>> index 00f90d7..270b3ee 100644
>> --- a/lib/obex.c
>> +++ b/lib/obex.c
>>  <at>  <at>  -520,8 +520,8  <at>  <at>  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
(Continue reading)

Hendrik Sattler | 11 Oct 2010 12:59
Picon

Re: [PATCH] Reuse nice as response for server in OBEX_CancelRequest

Zitat von "Luiz Augusto von Dentz" <luiz.dentz <at> gmail.com>:
> You mean OBEX_ResumeRequest take the response,

That's not what I meant. With OBEX_SuspendRequest(), you can choose  
the object to use, with OBEX_ResumeRequest(), it always is the current  
one.

> that could work but of
> course we will need to change the logic so that it doesn't always try
> to resume the stream, taking the object sound good to me. But note
> that OBEX_ObjectSetRsp is still needed when request are not suspended,
> so if I were to deprecated anything it would be

No, I meant to replace
   OBEX_ObjectSetRsp(object, rsp, lastrsp)
with
   OBEX_SetResponse(self, object-or-NULL, rsp, lastrsp)
so it matches the use-cases of SuspendRequest and ResumeRequest.

BTW:
There is no need for a new obex_object for a server, use the present  
one in your patch.
And then suddently, it is the same as an OBEX_SetResponse() (the  
actual sending is done in OBEX_ResumeRequest()).

> OBEX_ResumeRequest/OBEX_SuspendRequest/OBEX_CancelRequest making
> openobex to never respond/request automatically to requests/responses,
> or if this is too much to start with we can just make some API change
> so the user application can request to operate on asynchronous
> (MainLoop based) or synchronous (thread based) mode.
(Continue reading)


Gmane