diff --git a/src/javax/bluetooth/DeviceClass.java b/src/javax/bluetooth/DeviceClass.java new file mode 100644 index 00000000..cd33d267 --- /dev/null +++ b/src/javax/bluetooth/DeviceClass.java @@ -0,0 +1,30 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +public class DeviceClass +{ + + public DeviceClass(int record) { System.out.println("DeviceClass record:" + record); } + + public int getMajorDeviceClass() { return 0x200; } + + public int getMinorDeviceClass() { return 0x04; } + + public int getServiceClasses() { return 0x22000 | 0x100000; } + +} diff --git a/src/javax/bluetooth/DiscoveryAgent.java b/src/javax/bluetooth/DiscoveryAgent.java new file mode 100644 index 00000000..d951ffe0 --- /dev/null +++ b/src/javax/bluetooth/DiscoveryAgent.java @@ -0,0 +1,44 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +public class DiscoveryAgent +{ + + public static final int CACHED = 0x00; + + public static final int GIAC = 0x9E8B33; + + public static final int LIAC = 0x9E8B00; + + public static final int NOT_DISCOVERABLE = 0x00; + + public static final int PREKNOWN = 0x01; + + public boolean cancelInquiry(DiscoveryListener listener) { return false; } + + public boolean cancelServiceSearch(int transID) { return false; } + + public RemoteDevice[] retrieveDevices(int option) { return null; } + + public int searchServices(int[] attrSet, UUID[] uuidSet, RemoteDevice btDev, DiscoveryListener discListener) { return 0; } + + public String selectService(UUID uuid, int security, boolean master) { return null; } + + public boolean startInquiry(int accessCode, DiscoveryListener listener) { return false; } + +} diff --git a/src/javax/bluetooth/DiscoveryListener.java b/src/javax/bluetooth/DiscoveryListener.java new file mode 100644 index 00000000..3071074c --- /dev/null +++ b/src/javax/bluetooth/DiscoveryListener.java @@ -0,0 +1,46 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +public interface DiscoveryListener +{ + + static final int INQUIRY_COMPLETED = 0x00; + + static final int INQUIRY_ERROR = 0x07; + + static final int INQUIRY_TERMINATED = 0x05; + + static final int SERVICE_SEARCH_COMPLETED = 0x01; + + static final int SERVICE_SEARCH_DEVICE_NOT_REACHABLE = 0x06; + + static final int SERVICE_SEARCH_ERROR = 0x03; + + static final int SERVICE_SEARCH_NO_RECORDS = 0x04; + + static final int SERVICE_SEARCH_TERMINATED = 0x02; + + void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod); + + void inquiryCompleted(int discType); + + void servicesDiscovered(int transID, ServiceRecord[] servRecord); + + void serviceSearchCompleted(int transID, int respCode); + +} diff --git a/src/javax/bluetooth/L2CAPConnection.java b/src/javax/bluetooth/L2CAPConnection.java new file mode 100644 index 00000000..0ccb456d --- /dev/null +++ b/src/javax/bluetooth/L2CAPConnection.java @@ -0,0 +1,41 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +import java.io.IOException; +import java.io.InterruptedIOException; + +import javax.microedition.io.Connection; + +public interface L2CAPConnection extends Connection +{ + + static final int DEFAULT_MTU = 0x02A0; + + static final int MINIMUM_MTU = 0x30; + + int getTransmitMTU() throws IOException; + + int getReceiveMTU() throws IOException; + + void send(byte[] data) throws IOException, NullPointerException; + + int receive(byte[] inBuf) throws IOException, NullPointerException, InterruptedIOException; + + boolean ready() throws IOException; + +} diff --git a/src/javax/bluetooth/L2CAPConnectionNotifier.java b/src/javax/bluetooth/L2CAPConnectionNotifier.java new file mode 100644 index 00000000..bd77216f --- /dev/null +++ b/src/javax/bluetooth/L2CAPConnectionNotifier.java @@ -0,0 +1,28 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +import java.io.IOException; + +import javax.microedition.io.Connection; + +public interface L2CAPConnectionNotifier extends Connection +{ + + L2CAPConnection acceptAndOpen() throws IOException, ServiceRegistrationException, BluetoothStateException; + +} diff --git a/src/javax/bluetooth/LocalDevice.java b/src/javax/bluetooth/LocalDevice.java new file mode 100644 index 00000000..ee47a464 --- /dev/null +++ b/src/javax/bluetooth/LocalDevice.java @@ -0,0 +1,74 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +import javax.microedition.io.Connection; + +import java.util.Hashtable; + +import javax.obex.SessionNotifier; + +public class LocalDevice +{ + + private static LocalDevice locDevc; + + private static DiscoveryAgent disAgnt; + + private static DeviceClass devcCls; + + private static ServiceRecord srvcRcd; + + private static Hashtable properties = new Hashtable(); + + static + { /* We won't have functional Bluetooth yet */ + properties.put("bluetooth.api.version", "0.0"); + properties.put("bluetooth.master.switch", "false"); + properties.put("bluetooth.sd.attr.retrievable.max", "0"); + properties.put("bluetooth.connected.devices.max", "0"); + properties.put("bluetooth.l2cap.receiveMTU.max", "0"); + properties.put("bluetooth.sd.trans.max", "0"); + properties.put("bluetooth.connected.inquiry.scan", "false"); + properties.put("bluetooth.connected.page.scan", "false"); + properties.put("bluetooth.connected.inquiry", "false"); + properties.put("bluetooth.connected.page", "false"); + } + + public static String getBluetoothAddress() throws BluetoothStateException { return "000000000000"; } + + public static DeviceClass getDeviceClass() { return devcCls; } + + public static int getDiscoverable() { return DiscoveryAgent.NOT_DISCOVERABLE; } + + public static DiscoveryAgent getDiscoveryAgent() { return disAgnt; } + + public static String getFriendlyName() { return "noDevice"; } + + public static LocalDevice getLocalDevice() throws BluetoothStateException { return locDevc; } + + public static String getProperty(String property) { return properties.get(property); } + + public static ServiceRecord getRecord(Connection notifier) throws IllegalArgumentException, NullPointerException { return srvcRcd; } + + public static boolean isPowerOn() { return false; } + + public static boolean setDiscoverable(int mode) throws IllegalArgumentException, BluetoothStateException { return false; } + + public static void updateRecord(ServiceRecord srvRecord) throws NullPointerException, IllegalArgumentException, ServiceRegistrationException { } + +} diff --git a/src/javax/bluetooth/UUID.java b/src/javax/bluetooth/UUID.java new file mode 100644 index 00000000..59ab1102 --- /dev/null +++ b/src/javax/bluetooth/UUID.java @@ -0,0 +1,83 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.bluetooth; + +public class UUID +{ + + private static final long[] baseUUID = { 0x0000_0000L, 0x0000_1000L, 0x8000_0080L, 0x5F9B_34FBL }; + + private long[] UUIDval = { 0x0000_0000L, 0x0000_0000L, 0x0000_0000L, 0x0000_0000L }; + + + public UUID(long uuidValue) throws IllegalArgumentException + { + if (uuidValue < 0L || uuidValue > 0xffffffffL) { throw new IllegalArgumentException("Invalid UUID Value, must be between 0 an (2^32)-1"); } + else + { + UUIDval[0] = uuidValue; + UUIDval[1] = baseUUID[1]; + UUIDval[2] = baseUUID[2]; + UUIDval[3] = baseUUID[3]; + } + } + + public UUID(String uuidValue, boolean shortUUID) throws IllegalArgumentException, NullPointerException, NumberFormatException + { + int length = uuidValue.length(); + + if(length == 0 || length > 32 || (shortUUID && length > 8) ) + { + throw new IllegalArgumentException("Received an UUID with invalid length."); + } + + if (shortUUID) + { + String formattedUuidValue = String.format("%1$" + 8 + "s", uuidValue).replace(' ', '0'); + UUIDval[0] = Long.parseUnsignedLong(formattedUuidValue, 16); + UUIDval[1] = baseUUID[1]; + UUIDval[2] = baseUUID[2]; + UUIDval[3] = baseUUID[3]; + } + else + { + String formattedUuidValue = String.format("%1$" + 32 + "s", uuidValue).replace(' ', '0'); + UUIDval[0] = Long.parseUnsignedLong(formattedUuidValue.substring(0, 8), 16); + UUIDval[1] = Long.parseUnsignedLong(formattedUuidValue.substring(8, 16), 16); + UUIDval[2] = Long.parseUnsignedLong(formattedUuidValue.substring(16, 24), 16); + UUIDval[3] = Long.parseUnsignedLong(formattedUuidValue.substring(24, 32), 16); + } + } + + @Override + public boolean equals(Object value) + { + if (value == null || (value instanceof UUID) == false) { return false; } + + return ((UUID)value).toString().equals(this.toString()); + } + + @Override + public int hashCode() { return (int)(UUIDval[0] & 0xFFFFFFFF); } + + @Override + public String toString() + { + String uuidString = String.format("%08X", UUIDval[0]) + String.format("%08X", UUIDval[1]) + String.format("%08X", UUIDval[2]) + String.format("%08X", UUIDval[3]); + return uuidString.replaceFirst("^0+", ""); + } +} diff --git a/src/javax/microedition/io/file/ConnectionClosedException.java b/src/javax/microedition/io/file/ConnectionClosedException.java new file mode 100644 index 00000000..45b6ffc8 --- /dev/null +++ b/src/javax/microedition/io/file/ConnectionClosedException.java @@ -0,0 +1,26 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.io.file; + +public class ConnectionClosedException extends RuntimeException +{ + + public ConnectionClosedException() { } + + public ConnectionClosedException(String detailMessage) { System.out.println("ConnectionClosedException: " + detailMessage); } + +} diff --git a/src/javax/microedition/io/file/FileConnection.java b/src/javax/microedition/io/file/FileConnection.java new file mode 100644 index 00000000..f1e7b8ae --- /dev/null +++ b/src/javax/microedition/io/file/FileConnection.java @@ -0,0 +1,97 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.io.file; + +import java.io.IOException; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Enumeration; + +import javax.microedition.io.StreamConnection; + +public interface FileConnection extends StreamConnection +{ + + long availableSize() throws SecurityException, IllegalModeException, ConnectionClosedException; + + boolean canRead() throws SecurityException, IllegalModeException, ConnectionClosedException; + + boolean canWrite() throws SecurityException, IllegalModeException, ConnectionClosedException; + + void create() throws IOException, SecurityException, IllegalModeException; + + void delete() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + long directorySize(boolean includeSubDirs) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + boolean exists() throws SecurityException, IllegalModeException, ConnectionClosedException; + + long fileSize() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + String getName(); + + String getPath(); + + String getURL(); + + boolean isDirectory() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + boolean isHidden() throws SecurityException, IllegalModeException, ConnectionClosedException; + + boolean isOpen(); + + long lastModified() throws SecurityException, IllegalModeException, ConnectionClosedException; + + Enumeration list() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + Enumeration list(String filter, boolean includeHidden) throws NullPointerException, IllegalArgumentException, IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + void mkdir() throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + @Override + DataInputStream openDataInputStream() throws SecurityException, IllegalModeException; + + @Override + DataOutputStream openDataOutputStream() throws SecurityException, IllegalModeException; + + @Override + InputStream openInputStream() throws SecurityException, IllegalModeException; + + @Override + OutputStream openOutputStream() throws SecurityException, IllegalModeException; + + OutputStream openOutputStream(long byteOffset) throws IOException, SecurityException, IllegalModeException, IllegalArgumentException; + + void rename(String newName) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException, NullPointerException, IllegalArgumentException; + + void setFileConnection(String fileName) throws IOException, SecurityException, NullPointerException, IllegalArgumentException; + + void setHidden(boolean hidden) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + void setReadable(boolean readable) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + void setWritable(boolean writable) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException; + + long totalSize() throws SecurityException, IllegalModeException, ConnectionClosedException; + + void truncate(long byteOffset) throws IOException, SecurityException, IllegalModeException, ConnectionClosedException, IllegalArgumentException; + + long usedSize() throws SecurityException, IllegalModeException, ConnectionClosedException; + +} diff --git a/src/javax/microedition/io/file/FileSystemListener.java b/src/javax/microedition/io/file/FileSystemListener.java new file mode 100644 index 00000000..ca3d50f2 --- /dev/null +++ b/src/javax/microedition/io/file/FileSystemListener.java @@ -0,0 +1,28 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.io.file; + +public interface FileSystemListener +{ + + static final int ROOT_ADDED = 0; + + static final int ROOT_REMOVED = 1; + + void rootChanged(int state, String rootName) throws NullPointerException, IllegalArgumentException; + +} diff --git a/src/javax/microedition/io/file/FileSystemRegistry.java b/src/javax/microedition/io/file/FileSystemRegistry.java new file mode 100644 index 00000000..655fff87 --- /dev/null +++ b/src/javax/microedition/io/file/FileSystemRegistry.java @@ -0,0 +1,34 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.io.file; + +import java.util.Enumeration; + +public class FileSystemRegistry extends Object +{ + + Enumeration roots; /* A zero-length Enumeration to be used below */ + + /* Returns true if the fileSystemListener was added. */ + public static boolean addFileSystemListener(FileSystemListener listener) throws SecurityException, NullPointerException { return false; } + + public Enumeration listRoots() { return roots; }; /*If no roots are found, or it's not supported, return a zero-len enum*/ + + /* Returns true if the fileSystemListener was removed. */ + public static boolean removeFileSystemListener(FileSystemListener listener) throws NullPointerException { return false; }; + +} diff --git a/src/javax/microedition/io/file/IllegalModeException.java b/src/javax/microedition/io/file/IllegalModeException.java new file mode 100644 index 00000000..1d2973a6 --- /dev/null +++ b/src/javax/microedition/io/file/IllegalModeException.java @@ -0,0 +1,26 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.microedition.io.file; + +public class IllegalModeException extends RuntimeException +{ + + public IllegalModeException() { } + + public IllegalModeException(String detailMessage) { System.out.println("IllegalModeException: " + detailMessage); } + +} diff --git a/src/javax/obex/Authenticator.java b/src/javax/obex/Authenticator.java new file mode 100644 index 00000000..43d1b1da --- /dev/null +++ b/src/javax/obex/Authenticator.java @@ -0,0 +1,26 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +public interface Authenticator +{ + + PasswordAuthentication onAuthenticationChallenge(String description, boolean isUserIdRequired, boolean isFullAccess); + + byte[] onAuthenticationResponse(byte[] userName); + +} diff --git a/src/javax/obex/ClientSession.java b/src/javax/obex/ClientSession.java new file mode 100644 index 00000000..d1bafb16 --- /dev/null +++ b/src/javax/obex/ClientSession.java @@ -0,0 +1,46 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +import java.io.IOException; + +import javax.microedition.io.Connection; + +public interface ClientSession extends Connection +{ + + void setAuthenticator(Authenticator auth) throws NullPointerException; + + HeaderSet createHeaderSet(); + + void setConnectionID(long id) throws IllegalArgumentException ; + + long getConnectionID(); + + HeaderSet connect(HeaderSet headers) throws IOException, IllegalArgumentException; + + HeaderSet disconnect(HeaderSet headers) throws IOException, IllegalArgumentException; + + HeaderSet setPath(HeaderSet headers, boolean backup, boolean create) throws IOException, IllegalArgumentException; + + HeaderSet delete(HeaderSet headers) throws IOException, IllegalArgumentException; + + Operation get(HeaderSet headers) throws IOException, IllegalArgumentException; + + Operation put(HeaderSet headers) throws IOException, IllegalArgumentException; + +} diff --git a/src/javax/obex/HeaderSet.java b/src/javax/obex/HeaderSet.java new file mode 100644 index 00000000..edda0290 --- /dev/null +++ b/src/javax/obex/HeaderSet.java @@ -0,0 +1,58 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +import java.io.IOException; + +public interface HeaderSet +{ + + static final int COUNT = 0xC0; + + static final int NAME = 0x01; + + static final int TYPE = 0x42; + + static final int LENGTH = 0xC3; + + static final int TIME_ISO_8601 = 0x44; + + static final int TIME_4_BYTE = 0xC4; + + static final int DESCRIPTION = 0x05; + + static final int TARGET = 0x46; + + static final int HTTP = 0x47; + + static final int WHO = 0x4A; + + static final int OBJECT_CLASS = 0x4F; + + static final int APPLICATION_PARAMETER = 0x4C; + + void setHeader(int headerID, Object headerValue) throws IllegalArgumentException; + + Object getHeader(int headerID) throws IllegalArgumentException, IOException; + + int[] getHeaderList() throws IOException; + + void createAuthenticationChallenge(java.lang.String realm, boolean userID, boolean access); + + int getResponseCode() throws IOException; + +} diff --git a/src/javax/obex/Operation.java b/src/javax/obex/Operation.java new file mode 100644 index 00000000..053c8d36 --- /dev/null +++ b/src/javax/obex/Operation.java @@ -0,0 +1,34 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +import java.io.IOException; + +import javax.microedition.io.Connection; + +public interface Operation extends Connection +{ + + void abort() throws IOException; + + HeaderSet getReceivedHeaders() throws IOException; + + void sendHeaders(HeaderSet headers) throws IOException, NullPointerException, IllegalArgumentException; + + int getResponseCode() throws IOException; + +} diff --git a/src/javax/obex/PasswordAuthentication.java b/src/javax/obex/PasswordAuthentication.java new file mode 100644 index 00000000..49461778 --- /dev/null +++ b/src/javax/obex/PasswordAuthentication.java @@ -0,0 +1,34 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +public class PasswordAuthentication extends Object +{ + + byte[] name, pass; + + public PasswordAuthentication(byte[] userName, byte[] password) throws NullPointerException + { + name = userName; + pass = password; + } + + public byte[] getUserName() { return name; } + + public byte[] getPassword() { return pass; } + +} diff --git a/src/javax/obex/ResponseCodes.java b/src/javax/obex/ResponseCodes.java new file mode 100644 index 00000000..b01693b0 --- /dev/null +++ b/src/javax/obex/ResponseCodes.java @@ -0,0 +1,96 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +public class ResponseCodes extends Object +{ + + public static final int OBEX_HTTP_OK = 0xA0; + + public static final int OBEX_HTTP_CREATED = 0xA1; + + public static final int OBEX_HTTP_ACCEPTED = 0xA2; + + public static final int OBEX_HTTP_NOT_AUTHORITATIVE = 0xA3; + + public static final int OBEX_HTTP_NO_CONTENT = 0xA4; + + public static final int OBEX_HTTP_RESET = 0xA5; + + public static final int OBEX_HTTP_PARTIAL = 0xA6; + + public static final int OBEX_HTTP_MULT_CHOICE = 0xB0; + + public static final int OBEX_HTTP_MOVED_PERM = 0xB1; + + public static final int OBEX_HTTP_MOVED_TEMP = 0xB2; + + public static final int OBEX_HTTP_SEE_OTHER = 0xB3; + + public static final int OBEX_HTTP_NOT_MODIFIED = 0xB4; + + public static final int OBEX_HTTP_USE_PROXY = 0xB5; + + public static final int OBEX_HTTP_BAD_REQUEST = 0xC0; + + public static final int OBEX_HTTP_UNAUTHORIZED = 0xC1; + + public static final int OBEX_HTTP_PAYMENT_REQUIRED = 0xC2; + + public static final int OBEX_HTTP_FORBIDDEN = 0xC3; + + public static final int OBEX_HTTP_NOT_FOUND = 0xC4; + + public static final int OBEX_HTTP_BAD_METHOD = 0xC5; + + public static final int OBEX_HTTP_NOT_ACCEPTABLE = 0xC6; + + public static final int OBEX_HTTP_PROXY_AUTH = 0xC7; + + public static final int OBEX_HTTP_TIMEOUT = 0xC8; + + public static final int OBEX_HTTP_CONFLICT = 0xC9; + + public static final int OBEX_HTTP_GONE = 0xCA; + + public static final int OBEX_HTTP_LENGTH_REQUIRED = 0xCB; + + public static final int OBEX_HTTP_PRECON_FAILED = 0xCC; + + public static final int OBEX_HTTP_ENTITY_TOO_LARGE = 0xCD; + + public static final int OBEX_HTTP_REQ_TOO_LARGE = 0xCE; + + public static final int OBEX_HTTP_UNSUPPORTED_TYPE = 0xCF; + + public static final int OBEX_HTTP_INTERNAL_ERROR = 0xD0; + + public static final int OBEX_HTTP_NOT_IMPLEMENTED = 0xD1; + + public static final int OBEX_HTTP_BAD_GATEWAY = 0xD2; + + public static final int OBEX_HTTP_UNAVAILABLE = 0xD3; + + public static final int OBEX_HTTP_GATEWAY_TIMEOUT = 0xD4; + + public static final int OBEX_HTTP_VERSION = 0xD5; + + public static final int OBEX_DATABASE_FULL = 0xE0; + + public static final int OBEX_DATABASE_LOCKED = 0xE1; + +} diff --git a/src/javax/obex/ServerRequestHandler.java b/src/javax/obex/ServerRequestHandler.java new file mode 100644 index 00000000..dd4eefbe --- /dev/null +++ b/src/javax/obex/ServerRequestHandler.java @@ -0,0 +1,44 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +public class ServerRequestHandler extends Object +{ + + private long connectionID = -1; + + protected ServerRequestHandler() { this.connectionID = -1; }; + + public final HeaderSet createHeaderSet() { return null; } + + public void setConnectionID(long id) throws IllegalArgumentException { } + + public long getConnectionID() { return this.connectionID; } + + public int onConnect(HeaderSet request, HeaderSet reply) { return ResponseCodes.OBEX_HTTP_OK; } + + public void onDisconnect(HeaderSet request, HeaderSet reply) { } + + public int onSetPath(HeaderSet request, HeaderSet reply, boolean backup, boolean create) { return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; } + + public int onDelete(HeaderSet request, HeaderSet reply) { return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; } + + public int onPut(Operation op) { return ResponseCodes.OBEX_HTTP_NOT_IMPLEMENTED; } + + public void onAuthenticationFailure(byte[] userName) { } + +} diff --git a/src/javax/obex/SessionNotifier.java b/src/javax/obex/SessionNotifier.java new file mode 100644 index 00000000..dd365a9b --- /dev/null +++ b/src/javax/obex/SessionNotifier.java @@ -0,0 +1,30 @@ +/* + This file is part of FreeJ2ME. + + FreeJ2ME is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FreeJ2ME is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FreeJ2ME. If not, see http://www.gnu.org/licenses/ +*/ +package javax.obex; + +import java.io.IOException; + +import javax.microedition.io.Connection; + +public interface SessionNotifier extends Connection +{ + + Connection acceptAndOpen(ServerRequestHandler handler) throws IOException, NullPointerException; + + Connection acceptAndOpen(ServerRequestHandler handler, Authenticator auth) throws IOException, NullPointerException; + +}