diff options
author | Lixin Yue <L.X.YUE@motorola.com> | 2010-03-02 17:21:09 +0800 |
---|---|---|
committer | Jaikumar Ganesh <jaikumar@google.com> | 2010-03-16 09:59:06 -0700 |
commit | 8258ebdf128ef70a96fcaaa294167e39f1b5e94e (patch) | |
tree | 1d70bdb46454d38e381397c48645a941a327c0ae /obex | |
parent | 2c62f5f433292f40550de5f7ba24b1f03d659edc (diff) | |
download | frameworks_base-8258ebdf128ef70a96fcaaa294167e39f1b5e94e.zip frameworks_base-8258ebdf128ef70a96fcaaa294167e39f1b5e94e.tar.gz frameworks_base-8258ebdf128ef70a96fcaaa294167e39f1b5e94e.tar.bz2 |
Add ABORT support to Obex lib
Diffstat (limited to 'obex')
-rw-r--r-- | obex/javax/obex/ServerRequestHandler.java | 7 | ||||
-rw-r--r-- | obex/javax/obex/ServerSession.java | 32 |
2 files changed, 39 insertions, 0 deletions
diff --git a/obex/javax/obex/ServerRequestHandler.java b/obex/javax/obex/ServerRequestHandler.java index d93e5b6..0882572 100644 --- a/obex/javax/obex/ServerRequestHandler.java +++ b/obex/javax/obex/ServerRequestHandler.java @@ -197,6 +197,13 @@ public class ServerRequestHandler { } /** + * Called when a ABORT request is received. + */ + public int onAbort(HeaderSet request, HeaderSet reply) { + return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; + } + + /** * Called when a PUT request is received. * <P> * If this method is not implemented by the class that extends this class, diff --git a/obex/javax/obex/ServerSession.java b/obex/javax/obex/ServerSession.java index 503d440..a4b9759 100644 --- a/obex/javax/obex/ServerSession.java +++ b/obex/javax/obex/ServerSession.java @@ -115,6 +115,9 @@ public final class ServerSession extends ObexSession implements Runnable { case ObexHelper.OBEX_OPCODE_SETPATH: handleSetPathRequest(); break; + case ObexHelper.OBEX_OPCODE_ABORT: + handleAbortRequest(); + break; case -1: done = true; @@ -145,6 +148,35 @@ public final class ServerSession extends ObexSession implements Runnable { } /** + * Handles a ABORT request from a client. This method will read the rest of + * the request from the client. Assuming the request is valid, it will + * create a <code>HeaderSet</code> object to pass to the + * <code>ServerRequestHandler</code> object. After the handler processes the + * request, this method will create a reply message to send to the server. + * + * @throws IOException if an error occurred at the transport layer + */ + private void handleAbortRequest() throws IOException { + int code = ResponseCodes.OBEX_HTTP_OK; + HeaderSet request = new HeaderSet(); + HeaderSet reply = new HeaderSet(); + + int length = mInput.read(); + length = (length << 8) + mInput.read(); + if (length > ObexHelper.MAX_PACKET_SIZE_INT) { + code = ResponseCodes.OBEX_HTTP_REQ_TOO_LARGE; + } else { + for (int i = 3; i < length; i++) { + mInput.read(); + } + code = mListener.onAbort(request, reply); + Log.v(TAG, "onAbort request handler return value- " + code); + code = validateResponseCode(code); + } + sendResponse(code, null); + } + + /** * Handles a PUT request from a client. This method will provide a * <code>ServerOperation</code> object to the request handler. The * <code>ServerOperation</code> object will handle the rest of the request. |