Zitat von "Luiz Augusto von Dentz" <luiz.de...@gmail.com>:
> From: Luiz Augusto von Dentz <luiz.dentz-...@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
> @@ -520,8 +520,8 @@ 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
> @@ -358,7 +358,11 @@ 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->state & MODE_SRV)

This must be
   if (self->mode == MODE_SRV)

> +                     obex_object_setcmd(object, nice, nice);

And this should use
   obex_object_setrsp()

> +             else
> +                     obex_object_setcmd(object, OBEX_CMD_ABORT,
> +                                                     OBEX_CMD_ABORT);
>
>               if (obex_object_send(self, object, TRUE, TRUE) < 0) {
>                       obex_object_delete(object);

Generally, you may not want to do that in CancelRequest() after all  
but want a SetResponse() function that can use its current object:
LIB_SYMBOL
int CALLAPI OBEX_SetResponse(obex_t *self, uint8_t rsp, uint8_t lastrsp)
{
         obex_return_val_if_fail(self != NULL, -1);
         return obex_object_setrsp(self->object, rsp, lastrsp);
}


Would that help you in combination with OBEX_ResumeRequest?
It could also be a selective choice of object like in  
OBEX_SuspendRequest() and
OBEX_ObjectSetRsp() could be deprecated. It's funny that  
OBEX_ResumeRequest() doesn't have that like OBEX_SuspendRequest() :-/

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
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to