Loading obex/Android.mk 0 → 100644 +9 −0 Original line number Diff line number Diff line LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_MODULE:= javax.obex include $(BUILD_JAVA_LIBRARY) obex/javax/obex/ApplicationParameter.java +14 −9 Original line number Diff line number Diff line Loading @@ -32,12 +32,14 @@ package javax.obex; public class ApplicationParameter { private int max_length_ini = 1000; /** * @hide */ public final class ApplicationParameter { private byte[] b_array; private int length; private int max_length = 1000; public static class TRIPLET_TAGID { public static final byte ORDER_TAGID = 0x01; Loading @@ -46,7 +48,8 @@ public class ApplicationParameter { public static final byte SEARCH_ATTRIBUTE_TAGID = 0x03; public static final byte MAXLISTCOUNT_TAGID = 0x04;//if equals to "0", PSE only reply number of contacts // if equals to "0", PSE only reply number of contacts public static final byte MAXLISTCOUNT_TAGID = 0x04; public static final byte LISTSTARTOFFSET_TAGID = 0x05; Loading @@ -54,9 +57,11 @@ public class ApplicationParameter { public static final byte FORMAT_TAGID = 0x07; public static final byte PHONEBOOKSIZE_TAGID = 0x08;//only used if max list count = 0 // only used if max list count = 0 public static final byte PHONEBOOKSIZE_TAGID = 0x08; public static final byte NEWMISSEDCALLS_TAGID = 0x09;//only used in "mch" in response // only used in "mch" in response public static final byte NEWMISSEDCALLS_TAGID = 0x09; } public static class TRIPLET_VALUE { Loading Loading @@ -110,16 +115,16 @@ public class ApplicationParameter { } */ public ApplicationParameter() { b_array = new byte[max_length_ini]; b_array = new byte[max_length]; length = 0; } public void addAPPHeader(byte tag, byte len, byte[] value) { if ((length + len + 2) > max_length_ini) { if ((length + len + 2) > max_length) { byte[] array_tmp = new byte[length + 4 * len]; System.arraycopy(b_array, 0, array_tmp, 0, length); b_array = array_tmp; max_length_ini = length + 4 * len; max_length = length + 4 * len; } b_array[length++] = tag; b_array[length++] = len; Loading obex/javax/obex/Authenticator.java +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ package javax.obex; * <code>ServerRequestHandler</code> that failed authentication. The * connection is <B>not</B> closed if authentication failed. * * @version 0.3 November 28, 2008 * @hide */ public interface Authenticator { Loading obex/javax/obex/BaseStream.java +6 −6 Original line number Diff line number Diff line Loading @@ -32,20 +32,20 @@ package javax.obex; import java.io.*; import java.io.IOException; /** * This interface defines the methods needed by a parent that uses the * PrivateInputStream and PrivateOutputStream objects defined in this package. * * @version 0.3 November 28, 2008 * @hide */ public interface BaseStream { /** * Verifies that this object is still open. * * @exception IOException if the object is closed * @throws IOException if the object is closed */ public void ensureOpen() throws IOException; Loading @@ -53,7 +53,7 @@ public interface BaseStream { * Verifies that additional information may be sent. In other words, the * operation is not done. * * @exception IOException if the operation is completed * @throws IOException if the operation is completed */ public void ensureNotDone() throws IOException; Loading @@ -67,7 +67,7 @@ public interface BaseStream { * @return <code>true</code> if the operation was completed; * <code>false</code> if no operation took place * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException; Loading @@ -77,7 +77,7 @@ public interface BaseStream { * @param inStream <code>true</code> if the input stream is closed; * <code>false</code> if the output stream is closed * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public void streamClosed(boolean inStream) throws IOException; } obex/javax/obex/ClientOperation.java +52 −52 Original line number Diff line number Diff line Loading @@ -43,9 +43,9 @@ import java.io.ByteArrayOutputStream; * This class implements the <code>Operation</code> interface. It will read * and write data via puts and gets. * * @version 0.3 November 28, 2008 * @hide */ public class ClientOperation implements Operation, BaseStream { public final class ClientOperation implements Operation, BaseStream { /** * Defines the basic packet length used by OBEX. Event OBEX packet has the Loading Loading @@ -99,7 +99,7 @@ public class ClientOperation implements Operation, BaseStream { * @param type <code>true</code> if this is a get request; * <code>false</code. if this is a put request * * @exception IOExcpetion if the an IO error occured * @throws IOExcpetion if the an IO error occured */ public ClientOperation(InputStream in, int maxSize, ClientSession p, HeaderSet header, boolean type) throws IOException { Loading Loading @@ -152,7 +152,7 @@ public class ClientOperation implements Operation, BaseStream { * corresponding input and output streams will be closed along with this * object. * * @exception IOException if the transaction has already ended or if an * @throws IOException if the transaction has already ended or if an * OBEX server called this method */ public synchronized void abort() throws IOException { Loading @@ -163,12 +163,12 @@ public class ClientOperation implements Operation, BaseStream { // } //no compatible with sun-ri if ((isDone) && (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE)) { if ((isDone) && (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE)) { throw new IOException("Operation has already ended"); } exceptionMessage = "Operation aborted"; if ((!isDone) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { if ((!isDone) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { isDone = true; /* * Since we are not sending any headers or returning any headers then Loading @@ -192,7 +192,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return the response code retrieved from the server * * @exception IOException if an error occurred in the transport layer during * @throws IOException if an error occurred in the transport layer during * the transaction; if this method is called on a <code>HeaderSet</code> * object created by calling <code>createHeaderSet</code> in a * <code>ClientSession</code> object Loading @@ -200,7 +200,7 @@ public class ClientOperation implements Operation, BaseStream { public synchronized int getResponseCode() throws IOException { //avoid dup validateConnection if ((replyHeaders.responseCode == -1) || (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { || (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { validateConnection(); } Loading Loading @@ -259,7 +259,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an input stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public InputStream openInputStream() throws IOException { // TODO: this mode is not set yet. Loading Loading @@ -290,7 +290,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an input stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public DataInputStream openDataInputStream() throws IOException { return new DataInputStream(openInputStream()); Loading @@ -301,7 +301,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an output stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public OutputStream openOutputStream() throws IOException { // TODO: this mode is not set yet. Loading Loading @@ -332,7 +332,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an output stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public DataOutputStream openDataOutputStream() throws IOException { return new DataOutputStream(openOutputStream()); Loading @@ -341,7 +341,7 @@ public class ClientOperation implements Operation, BaseStream { /** * Closes the connection and ends the transaction * * @exception IOException if the operation has already ended or is closed * @throws IOException if the operation has already ended or is closed */ public void close() throws IOException { isClosed = true; Loading @@ -357,7 +357,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return the headers received during this <code>Operation</code> * * @exception IOException if this <code>Operation</code> has been closed * @throws IOException if this <code>Operation</code> has been closed */ public HeaderSet getReceivedHeaders() throws IOException { ensureOpen(); Loading @@ -371,13 +371,13 @@ public class ClientOperation implements Operation, BaseStream { * * @param headers the headers to send in the next message * * @exception IOException if this <code>Operation</code> has been closed * @throws IOException if this <code>Operation</code> has been closed * or the transaction has ended and no further messages will be exchanged * * @exception IllegalArgumentException if <code>headers</code> was not created * @throws IllegalArgumentException if <code>headers</code> was not created * by a call to <code>ServerRequestHandler.createHeaderSet()</code> * * @exception NullPointerException if <code>headers</code> is <code>null</code> * @throws NullPointerException if <code>headers</code> is <code>null</code> */ public void sendHeaders(HeaderSet headers) throws IOException { ensureOpen(); Loading @@ -404,14 +404,14 @@ public class ClientOperation implements Operation, BaseStream { * @return <code>true</code> if the transaction should end; * <code>false</code> if the transaction should not end * * @exception IOException if an IO error occurred * @throws IOException if an IO error occurred */ private boolean readResponse() throws IOException { replyHeaders.responseCode = socketInput.read(); int packetLength = socketInput.read(); packetLength = (packetLength << 8) + socketInput.read(); if (packetLength > OBEXConstants.MAX_PACKET_SIZE_INT) { if (packetLength > ObexHelper.MAX_PACKET_SIZE_INT) { if (exceptionMessage != null) { abort(); } Loading @@ -425,7 +425,7 @@ public class ClientOperation implements Operation, BaseStream { if (readLength != dataLength) { throw new IOException("Received a packet without data as decalred length"); } byte[] body = OBEXHelper.updateHeaderSet(replyHeaders, data); byte[] body = ObexHelper.updateHeaderSet(replyHeaders, data); if (body != null) { privateInput.writeBytes(body, 1); Loading @@ -442,7 +442,7 @@ public class ClientOperation implements Operation, BaseStream { } } if (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { return true; } else { return false; Loading @@ -453,7 +453,7 @@ public class ClientOperation implements Operation, BaseStream { * Verifies that additional information may be sent. In other words, the * operation is not done. * * @exception IOException if the operation is completed * @throws IOException if the operation is completed */ public void ensureNotDone() throws IOException { if (isDone) { Loading @@ -464,7 +464,7 @@ public class ClientOperation implements Operation, BaseStream { /** * Verifies that the connection is open and no exceptions should be thrown. * * @exception IOException if an exception needs to be thrown * @throws IOException if an exception needs to be thrown */ public void ensureOpen() throws IOException { parent.ensureOpen(); Loading @@ -480,7 +480,7 @@ public class ClientOperation implements Operation, BaseStream { /** * Verifies that the connection is open and the proper data has been read. * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ private void validateConnection() throws IOException { ensureOpen(); Loading @@ -499,13 +499,13 @@ public class ClientOperation implements Operation, BaseStream { * @return <code>true</code> if there is more data to send; * <code>false</code> if there is no more data to send * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ protected boolean sendRequest(int type) throws IOException { boolean returnValue = false; ByteArrayOutputStream out = new ByteArrayOutputStream(); int bodyLength = -1; byte[] headerArray = OBEXHelper.createHeader(requestHeaders, true); byte[] headerArray = ObexHelper.createHeader(requestHeaders, true); if (privateOutput != null) { bodyLength = privateOutput.size(); } Loading @@ -525,7 +525,7 @@ public class ClientOperation implements Operation, BaseStream { while (end != headerArray.length) { //split the headerArray end = OBEXHelper.findHeaderEnd(headerArray, start, maxPacketSize end = ObexHelper.findHeaderEnd(headerArray, start, maxPacketSize - BASE_PACKET_LENGTH); // can not split if (end == -1) { Loading @@ -551,7 +551,7 @@ public class ClientOperation implements Operation, BaseStream { return false; } if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { return false; } Loading Loading @@ -642,7 +642,7 @@ public class ClientOperation implements Operation, BaseStream { * initial request. If the response takes more then one packet, a thread * will be started to handle additional requests * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ private synchronized void startProcessing() throws IOException { Loading @@ -653,33 +653,33 @@ public class ClientOperation implements Operation, BaseStream { if (isGet) { if (!isDone) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x03); } if (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { parent.sendRequest(0x83, null, replyHeaders, privateInput); } if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } } } else { if (!isDone) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x02); } } if (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { parent.sendRequest(0x82, null, replyHeaders, privateInput); } if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } } Loading @@ -692,7 +692,7 @@ public class ClientOperation implements Operation, BaseStream { * empty packet or not send anything if there is no data to send * @param inStream <code>true</code> if the stream is input stream or * is output stream * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException { Loading @@ -704,7 +704,7 @@ public class ClientOperation implements Operation, BaseStream { /* * Determine if that was not the last packet in the operation */ if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } Loading @@ -727,7 +727,7 @@ public class ClientOperation implements Operation, BaseStream { if ((!inStream) && (!isDone)) { // to deal with outputstream in put operation if (replyHeaders.responseCode == -1) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; } sendRequest(0x02); return true; Loading @@ -749,7 +749,7 @@ public class ClientOperation implements Operation, BaseStream { * @param inStream <code>true</code> if the input stream is closed; * <code>false</code> if the output stream is closed * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public void streamClosed(boolean inStream) throws IOException { if (!isGet) { Loading @@ -759,16 +759,16 @@ public class ClientOperation implements Operation, BaseStream { boolean more = true; if ((privateOutput != null) && (privateOutput.size() <= 0)) { byte[] headerArray = OBEXHelper.createHeader(requestHeaders, false); byte[] headerArray = ObexHelper.createHeader(requestHeaders, false); if (headerArray.length <= 0) more = false; } // If have not sent any data so send all now if (replyHeaders.responseCode == -1) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; } while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x02); } Loading @@ -777,7 +777,7 @@ public class ClientOperation implements Operation, BaseStream { * only have a single reply to send. so we don't need the while * loop. */ while (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { while (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { sendRequest(0x82); } Loading @@ -794,15 +794,15 @@ public class ClientOperation implements Operation, BaseStream { // Have not sent any data so send it all now if (replyHeaders.responseCode == -1) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; } while (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { while (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { if (!sendRequest(0x83)) { break; } } while (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { while (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { parent.sendRequest(0x83, null, replyHeaders, privateInput); } isDone = true; Loading @@ -813,7 +813,7 @@ public class ClientOperation implements Operation, BaseStream { boolean more = true; if ((privateOutput != null) && (privateOutput.size() <= 0)) { byte[] headerArray = OBEXHelper.createHeader(requestHeaders, false); byte[] headerArray = ObexHelper.createHeader(requestHeaders, false); if (headerArray.length <= 0) more = false; } Loading @@ -824,13 +824,13 @@ public class ClientOperation implements Operation, BaseStream { if ((privateOutput != null) && (privateOutput.size() <= 0)) more = false; replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x03); } sendRequest(0x83); // parent.sendRequest(0x83, null, replyHeaders, privateInput); if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } Loading Loading
obex/Android.mk 0 → 100644 +9 −0 Original line number Diff line number Diff line LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_MODULE:= javax.obex include $(BUILD_JAVA_LIBRARY)
obex/javax/obex/ApplicationParameter.java +14 −9 Original line number Diff line number Diff line Loading @@ -32,12 +32,14 @@ package javax.obex; public class ApplicationParameter { private int max_length_ini = 1000; /** * @hide */ public final class ApplicationParameter { private byte[] b_array; private int length; private int max_length = 1000; public static class TRIPLET_TAGID { public static final byte ORDER_TAGID = 0x01; Loading @@ -46,7 +48,8 @@ public class ApplicationParameter { public static final byte SEARCH_ATTRIBUTE_TAGID = 0x03; public static final byte MAXLISTCOUNT_TAGID = 0x04;//if equals to "0", PSE only reply number of contacts // if equals to "0", PSE only reply number of contacts public static final byte MAXLISTCOUNT_TAGID = 0x04; public static final byte LISTSTARTOFFSET_TAGID = 0x05; Loading @@ -54,9 +57,11 @@ public class ApplicationParameter { public static final byte FORMAT_TAGID = 0x07; public static final byte PHONEBOOKSIZE_TAGID = 0x08;//only used if max list count = 0 // only used if max list count = 0 public static final byte PHONEBOOKSIZE_TAGID = 0x08; public static final byte NEWMISSEDCALLS_TAGID = 0x09;//only used in "mch" in response // only used in "mch" in response public static final byte NEWMISSEDCALLS_TAGID = 0x09; } public static class TRIPLET_VALUE { Loading Loading @@ -110,16 +115,16 @@ public class ApplicationParameter { } */ public ApplicationParameter() { b_array = new byte[max_length_ini]; b_array = new byte[max_length]; length = 0; } public void addAPPHeader(byte tag, byte len, byte[] value) { if ((length + len + 2) > max_length_ini) { if ((length + len + 2) > max_length) { byte[] array_tmp = new byte[length + 4 * len]; System.arraycopy(b_array, 0, array_tmp, 0, length); b_array = array_tmp; max_length_ini = length + 4 * len; max_length = length + 4 * len; } b_array[length++] = tag; b_array[length++] = len; Loading
obex/javax/obex/Authenticator.java +1 −1 Original line number Diff line number Diff line Loading @@ -81,7 +81,7 @@ package javax.obex; * <code>ServerRequestHandler</code> that failed authentication. The * connection is <B>not</B> closed if authentication failed. * * @version 0.3 November 28, 2008 * @hide */ public interface Authenticator { Loading
obex/javax/obex/BaseStream.java +6 −6 Original line number Diff line number Diff line Loading @@ -32,20 +32,20 @@ package javax.obex; import java.io.*; import java.io.IOException; /** * This interface defines the methods needed by a parent that uses the * PrivateInputStream and PrivateOutputStream objects defined in this package. * * @version 0.3 November 28, 2008 * @hide */ public interface BaseStream { /** * Verifies that this object is still open. * * @exception IOException if the object is closed * @throws IOException if the object is closed */ public void ensureOpen() throws IOException; Loading @@ -53,7 +53,7 @@ public interface BaseStream { * Verifies that additional information may be sent. In other words, the * operation is not done. * * @exception IOException if the operation is completed * @throws IOException if the operation is completed */ public void ensureNotDone() throws IOException; Loading @@ -67,7 +67,7 @@ public interface BaseStream { * @return <code>true</code> if the operation was completed; * <code>false</code> if no operation took place * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException; Loading @@ -77,7 +77,7 @@ public interface BaseStream { * @param inStream <code>true</code> if the input stream is closed; * <code>false</code> if the output stream is closed * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public void streamClosed(boolean inStream) throws IOException; }
obex/javax/obex/ClientOperation.java +52 −52 Original line number Diff line number Diff line Loading @@ -43,9 +43,9 @@ import java.io.ByteArrayOutputStream; * This class implements the <code>Operation</code> interface. It will read * and write data via puts and gets. * * @version 0.3 November 28, 2008 * @hide */ public class ClientOperation implements Operation, BaseStream { public final class ClientOperation implements Operation, BaseStream { /** * Defines the basic packet length used by OBEX. Event OBEX packet has the Loading Loading @@ -99,7 +99,7 @@ public class ClientOperation implements Operation, BaseStream { * @param type <code>true</code> if this is a get request; * <code>false</code. if this is a put request * * @exception IOExcpetion if the an IO error occured * @throws IOExcpetion if the an IO error occured */ public ClientOperation(InputStream in, int maxSize, ClientSession p, HeaderSet header, boolean type) throws IOException { Loading Loading @@ -152,7 +152,7 @@ public class ClientOperation implements Operation, BaseStream { * corresponding input and output streams will be closed along with this * object. * * @exception IOException if the transaction has already ended or if an * @throws IOException if the transaction has already ended or if an * OBEX server called this method */ public synchronized void abort() throws IOException { Loading @@ -163,12 +163,12 @@ public class ClientOperation implements Operation, BaseStream { // } //no compatible with sun-ri if ((isDone) && (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE)) { if ((isDone) && (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE)) { throw new IOException("Operation has already ended"); } exceptionMessage = "Operation aborted"; if ((!isDone) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { if ((!isDone) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { isDone = true; /* * Since we are not sending any headers or returning any headers then Loading @@ -192,7 +192,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return the response code retrieved from the server * * @exception IOException if an error occurred in the transport layer during * @throws IOException if an error occurred in the transport layer during * the transaction; if this method is called on a <code>HeaderSet</code> * object created by calling <code>createHeaderSet</code> in a * <code>ClientSession</code> object Loading @@ -200,7 +200,7 @@ public class ClientOperation implements Operation, BaseStream { public synchronized int getResponseCode() throws IOException { //avoid dup validateConnection if ((replyHeaders.responseCode == -1) || (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { || (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { validateConnection(); } Loading Loading @@ -259,7 +259,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an input stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public InputStream openInputStream() throws IOException { // TODO: this mode is not set yet. Loading Loading @@ -290,7 +290,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an input stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public DataInputStream openDataInputStream() throws IOException { return new DataInputStream(openInputStream()); Loading @@ -301,7 +301,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an output stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public OutputStream openOutputStream() throws IOException { // TODO: this mode is not set yet. Loading Loading @@ -332,7 +332,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return an output stream * * @exception IOException if an I/O error occurs * @throws IOException if an I/O error occurs */ public DataOutputStream openDataOutputStream() throws IOException { return new DataOutputStream(openOutputStream()); Loading @@ -341,7 +341,7 @@ public class ClientOperation implements Operation, BaseStream { /** * Closes the connection and ends the transaction * * @exception IOException if the operation has already ended or is closed * @throws IOException if the operation has already ended or is closed */ public void close() throws IOException { isClosed = true; Loading @@ -357,7 +357,7 @@ public class ClientOperation implements Operation, BaseStream { * * @return the headers received during this <code>Operation</code> * * @exception IOException if this <code>Operation</code> has been closed * @throws IOException if this <code>Operation</code> has been closed */ public HeaderSet getReceivedHeaders() throws IOException { ensureOpen(); Loading @@ -371,13 +371,13 @@ public class ClientOperation implements Operation, BaseStream { * * @param headers the headers to send in the next message * * @exception IOException if this <code>Operation</code> has been closed * @throws IOException if this <code>Operation</code> has been closed * or the transaction has ended and no further messages will be exchanged * * @exception IllegalArgumentException if <code>headers</code> was not created * @throws IllegalArgumentException if <code>headers</code> was not created * by a call to <code>ServerRequestHandler.createHeaderSet()</code> * * @exception NullPointerException if <code>headers</code> is <code>null</code> * @throws NullPointerException if <code>headers</code> is <code>null</code> */ public void sendHeaders(HeaderSet headers) throws IOException { ensureOpen(); Loading @@ -404,14 +404,14 @@ public class ClientOperation implements Operation, BaseStream { * @return <code>true</code> if the transaction should end; * <code>false</code> if the transaction should not end * * @exception IOException if an IO error occurred * @throws IOException if an IO error occurred */ private boolean readResponse() throws IOException { replyHeaders.responseCode = socketInput.read(); int packetLength = socketInput.read(); packetLength = (packetLength << 8) + socketInput.read(); if (packetLength > OBEXConstants.MAX_PACKET_SIZE_INT) { if (packetLength > ObexHelper.MAX_PACKET_SIZE_INT) { if (exceptionMessage != null) { abort(); } Loading @@ -425,7 +425,7 @@ public class ClientOperation implements Operation, BaseStream { if (readLength != dataLength) { throw new IOException("Received a packet without data as decalred length"); } byte[] body = OBEXHelper.updateHeaderSet(replyHeaders, data); byte[] body = ObexHelper.updateHeaderSet(replyHeaders, data); if (body != null) { privateInput.writeBytes(body, 1); Loading @@ -442,7 +442,7 @@ public class ClientOperation implements Operation, BaseStream { } } if (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { return true; } else { return false; Loading @@ -453,7 +453,7 @@ public class ClientOperation implements Operation, BaseStream { * Verifies that additional information may be sent. In other words, the * operation is not done. * * @exception IOException if the operation is completed * @throws IOException if the operation is completed */ public void ensureNotDone() throws IOException { if (isDone) { Loading @@ -464,7 +464,7 @@ public class ClientOperation implements Operation, BaseStream { /** * Verifies that the connection is open and no exceptions should be thrown. * * @exception IOException if an exception needs to be thrown * @throws IOException if an exception needs to be thrown */ public void ensureOpen() throws IOException { parent.ensureOpen(); Loading @@ -480,7 +480,7 @@ public class ClientOperation implements Operation, BaseStream { /** * Verifies that the connection is open and the proper data has been read. * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ private void validateConnection() throws IOException { ensureOpen(); Loading @@ -499,13 +499,13 @@ public class ClientOperation implements Operation, BaseStream { * @return <code>true</code> if there is more data to send; * <code>false</code> if there is no more data to send * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ protected boolean sendRequest(int type) throws IOException { boolean returnValue = false; ByteArrayOutputStream out = new ByteArrayOutputStream(); int bodyLength = -1; byte[] headerArray = OBEXHelper.createHeader(requestHeaders, true); byte[] headerArray = ObexHelper.createHeader(requestHeaders, true); if (privateOutput != null) { bodyLength = privateOutput.size(); } Loading @@ -525,7 +525,7 @@ public class ClientOperation implements Operation, BaseStream { while (end != headerArray.length) { //split the headerArray end = OBEXHelper.findHeaderEnd(headerArray, start, maxPacketSize end = ObexHelper.findHeaderEnd(headerArray, start, maxPacketSize - BASE_PACKET_LENGTH); // can not split if (end == -1) { Loading @@ -551,7 +551,7 @@ public class ClientOperation implements Operation, BaseStream { return false; } if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { return false; } Loading Loading @@ -642,7 +642,7 @@ public class ClientOperation implements Operation, BaseStream { * initial request. If the response takes more then one packet, a thread * will be started to handle additional requests * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ private synchronized void startProcessing() throws IOException { Loading @@ -653,33 +653,33 @@ public class ClientOperation implements Operation, BaseStream { if (isGet) { if (!isDone) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x03); } if (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { parent.sendRequest(0x83, null, replyHeaders, privateInput); } if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } } } else { if (!isDone) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x02); } } if (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { parent.sendRequest(0x82, null, replyHeaders, privateInput); } if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } } Loading @@ -692,7 +692,7 @@ public class ClientOperation implements Operation, BaseStream { * empty packet or not send anything if there is no data to send * @param inStream <code>true</code> if the stream is input stream or * is output stream * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public synchronized boolean continueOperation(boolean sendEmpty, boolean inStream) throws IOException { Loading @@ -704,7 +704,7 @@ public class ClientOperation implements Operation, BaseStream { /* * Determine if that was not the last packet in the operation */ if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } Loading @@ -727,7 +727,7 @@ public class ClientOperation implements Operation, BaseStream { if ((!inStream) && (!isDone)) { // to deal with outputstream in put operation if (replyHeaders.responseCode == -1) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; } sendRequest(0x02); return true; Loading @@ -749,7 +749,7 @@ public class ClientOperation implements Operation, BaseStream { * @param inStream <code>true</code> if the input stream is closed; * <code>false</code> if the output stream is closed * * @exception IOException if an IO error occurs * @throws IOException if an IO error occurs */ public void streamClosed(boolean inStream) throws IOException { if (!isGet) { Loading @@ -759,16 +759,16 @@ public class ClientOperation implements Operation, BaseStream { boolean more = true; if ((privateOutput != null) && (privateOutput.size() <= 0)) { byte[] headerArray = OBEXHelper.createHeader(requestHeaders, false); byte[] headerArray = ObexHelper.createHeader(requestHeaders, false); if (headerArray.length <= 0) more = false; } // If have not sent any data so send all now if (replyHeaders.responseCode == -1) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; } while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x02); } Loading @@ -777,7 +777,7 @@ public class ClientOperation implements Operation, BaseStream { * only have a single reply to send. so we don't need the while * loop. */ while (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { while (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { sendRequest(0x82); } Loading @@ -794,15 +794,15 @@ public class ClientOperation implements Operation, BaseStream { // Have not sent any data so send it all now if (replyHeaders.responseCode == -1) { replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; } while (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { while (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { if (!sendRequest(0x83)) { break; } } while (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE) { while (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE) { parent.sendRequest(0x83, null, replyHeaders, privateInput); } isDone = true; Loading @@ -813,7 +813,7 @@ public class ClientOperation implements Operation, BaseStream { boolean more = true; if ((privateOutput != null) && (privateOutput.size() <= 0)) { byte[] headerArray = OBEXHelper.createHeader(requestHeaders, false); byte[] headerArray = ObexHelper.createHeader(requestHeaders, false); if (headerArray.length <= 0) more = false; } Loading @@ -824,13 +824,13 @@ public class ClientOperation implements Operation, BaseStream { if ((privateOutput != null) && (privateOutput.size() <= 0)) more = false; replyHeaders.responseCode = OBEXConstants.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == OBEXConstants.OBEX_HTTP_CONTINUE)) { replyHeaders.responseCode = ObexHelper.OBEX_HTTP_CONTINUE; while ((more) && (replyHeaders.responseCode == ObexHelper.OBEX_HTTP_CONTINUE)) { more = sendRequest(0x03); } sendRequest(0x83); // parent.sendRequest(0x83, null, replyHeaders, privateInput); if (replyHeaders.responseCode != OBEXConstants.OBEX_HTTP_CONTINUE) { if (replyHeaders.responseCode != ObexHelper.OBEX_HTTP_CONTINUE) { isDone = true; } Loading