Hi, On Mon, Oct 11, 2010 at 10:24 AM, Hendrik Sattler <p...@hendrik-sattler.de> wrote: > 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()
I will going to fix this one too. >> + 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); > } Well, but for general error or cancel without the actual object I guess CancelRequest would be the API of choice. > 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() :-/ You mean OBEX_ResumeRequest take the response, 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 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. Regards, -- Luiz Augusto von Dentz Computer Engineer ------------------------------------------------------------------------------ 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