Am Donnerstag 18 Januar 2007 00:49 schrieb Bea Lam:
> This is a patch to add support for Put-Delete and Create-Empty
> operations. The specs define them like this (in 3.3.3.6): "A PUT
> operation with NO Body or End-of-Body header whatsoever should be
> treated as a delete request. Similarly, a PUT operation with an empty
> End-of-Body header request the recipient to create an empty object."
[...]
>                               } else if ((putFlags & 
> OBEX_FL_PUT_HAS_BODY_END_DATA) == 0 ) {
>                                       // end of body is empty
>                                       handleCreateRequest();
>                                       return;
>                               }

Is that really necessary as special case? An empty EOB header should result in 
a body of length 0. You create() a file, write() 0 bytes and close() it. This 
is a normal put, isn't it?
Removing any checks about length==0 should let that through. The application 
author needs no special knowledge, then.

Something equal goes for the a DELETE. Handling this in OBEX_EV_REQ is much 
too late if you use the streaming mechanism. There, you open the file in 
OBEX_EV_REQCHECK (that's where the other headers appear), so your flag must 
be present at that time, already.
But if you do that, you could use a new OBEX_CMD_DELETE instead and thus avoid 
any new methods.

The start is:
OBEX_EV_ACCEPTHINT, OBEX_CMD_CONNECT
OBEX_EV_REQHINT, OBEX_CMD_CONNECT
OBEX_EV_REQ, OBEX_CMD_CONNECT
OBEX_EV_REQDONE, OBEX_CMD_CONNECT
OBEX_EV_REQHINT, OBEX_CMD_PUT

Here, it is usually followed by:
OBEX_EV_REQCHECK, OBEX_CMD_PUT
OBEX_EV_PROGRESS, OBEX_CMD_PUT
OBEX_EV_STREAMAVAIL, OBEX_CMD_PUT *
[...]
OBEX_EV_REQ, OBEX_CMD_PUT

And finally:
OBEX_EV_REQDONE, OBEX_CMD_PUT
OBEX_EV_REQHINT, OBEX_CMD_DISCONNECT
OBEX_EV_REQ, OBEX_CMD_DISCONNECT
OBEX_EV_REQDONE, OBEX_CMD_DISCONNECT

You can sneak that in somewhere at the start of the middle part. However, 
naming the flag to what it means (not what it represents) is usually better, 
thus OBEX_FL_PUT_DELETE. I would still vote for an OBEX_CMD_DELETE, though,
and omitting the OBEX_CMD_PUT, if possible.

HS

[*]: yes, that actually has no OBEX_CMD_ associated to it but I consider this 
a bug.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Openobex-users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to