LGPL Libraries
From Sw
[edit] Used Libraries
ScheduleWorld uses the BlueCove Java library.
In addition, ScheduleWorld has patched BlueCove. You can download the ScheduleWorld version of BlueCove here: bluecove-2.0.3-SNAPSHOT.jar
The code changes are as follows:
*** bluecove-bluez patch ***
Index: src/main/java/com/intel/bluetooth/BluetoothStackBlueZ.java
===================================================================
--- src/main/java/com/intel/bluetooth/BluetoothStackBlueZ.java
(revision 1965)
+++ src/main/java/com/intel/bluetooth/BluetoothStackBlueZ.java (working
copy)
@@ -139,7 +139,11 @@
// Used mainly in Unit Tests
static {
- NativeLibLoader.isAvailable("unix-java", UnixSocket.class);
+ try {
+ NativeLibLoader.isAvailable("unix-java",
UnixSocket.class);
+ } catch(Throwable t) {
+ NativeLibLoader.isAvailable("unix-java_x64",
UnixSocket.class);
+ }
//String sysName = System.getProperty("os.name");
//System.out.println("os.name:" + sysName);
try {
@@ -158,12 +162,12 @@
return BlueCoveImpl.STACK_BLUEZ;
}
- public native int getLibraryVersionNative();
+ public native int getLibraryVersion();
- public int getLibraryVersion() throws BluetoothStateException {
+ /*public int getLibraryVersion() throws BluetoothStateException {
DebugLog.debug("for breakpoint");
return BLUECOVE_DBUS_VERSION;
- }
+ }*/
public int detectBluetoothStack() {
DebugLog.debug("detectBluetoothStack()");
@@ -1192,6 +1196,11 @@
return false;
}
+ @Override
+ public boolean authenticateRemoteDevice(long address, String
passkey) throws IOException {
+ // TODO
+ return false;
+ }
@Override
public boolean l2Encrypt(long address, long handle, boolean on)
@@ -1200,7 +1209,6 @@
return false;
}
-
@Override
public boolean rfEncrypt(long address, long handle, boolean on)
throws IOException {
@@ -1208,4 +1216,4 @@
return false;
}
-}
\ No newline at end of file
+}
Index: src/main/c/BlueCoveBlueZ.c
===================================================================
--- src/main/c/BlueCoveBlueZ.c (revision 1965)
+++ src/main/c/BlueCoveBlueZ.c (working copy)
@@ -27,7 +27,7 @@
#include <bluetooth/sdp_lib.h>
-JNIEXPORT jint JNICALL
Java_com_intel_bluetooth_BluetoothStackBlueZ_getLibraryVersionNative
+JNIEXPORT jint JNICALL
Java_com_intel_bluetooth_BluetoothStackBlueZ_getLibraryVersion
(JNIEnv *env, jobject peer) {
return
com_intel_bluetooth_BluetoothStackBlueZ_BLUECOVE_DBUS_VERSION;
//return
com_intel_bluetooth_BluetoothStackBlueZ_NATIVE_LIBRARY_VERSION;
*** bluecove diff ***
Index: src/main/java/com/intel/bluetooth/NativeLibLoader.java
===================================================================
--- src/main/java/com/intel/bluetooth/NativeLibLoader.java
(revision 1964)
+++ src/main/java/com/intel/bluetooth/NativeLibLoader.java (working
copy)
@@ -175,6 +175,8 @@
return state.libraryAvailable;
}
+ System.err.println("Native Library libName:" + libName +
+ ", libFileName:" + libFileName);
String path = System.getProperty("bluecove.native.path");
if (path != null) {
if (!UtilsJavaSE.ibmJ9midp) {
@@ -206,15 +208,18 @@
System.err.println("Native Library " + libName +
" not available");
DebugLog.debug("java.library.path",
System.getProperty("java.library.path"));
}
+
state.triedToLoadAlredy = true;
return state.libraryAvailable;
}
private static boolean tryload(String name) {
try {
+ System.err.println("tryload() name:" + name);
System.loadLibrary(name);
- DebugLog.debug("Library loaded", name);
+ DebugLog.debug("successfully loaded", name);
} catch (Throwable e) {
+ e.printStackTrace();
DebugLog.error("Library " + name + " not loaded
", e);
return false;
}
@@ -240,7 +245,7 @@
return false;
}
System.load(f.getAbsolutePath());
- DebugLog.debug("Library loaded",
f.getAbsolutePath());
+ DebugLog.debug("Library success",
f.getAbsolutePath());
} catch (Throwable e) {
DebugLog.error("Can't load library from path " +
path, e);
return false;
@@ -260,6 +265,7 @@
}
private static boolean loadAsSystemResource(String libFileName,
Class stackClass) {
+ System.err.println("trying loadAsSystemResource():" +
libFileName);
InputStream is = null;
try {
ClassLoader clo = null;
@@ -277,13 +283,16 @@
is = clo.getResourceAsStream(libFileName);
}
} catch (Throwable e) {
+ System.err.println("Native Library " +
libFileName + " is not a Resource !");
DebugLog.error("Native Library " + libFileName +
" is not a Resource !");
return false;
}
if (is == null) {
DebugLog.error("Native Library " + libFileName +
" is not a Resource !");
+ System.err.println("Native Library " +
libFileName + " is not a Resource !");
return false;
}
+ System.err.println("Found inputstream for " + libFileName);
File fd = makeTempName(libFileName);
try {
if (!copy2File(is, fd)) {
@@ -303,12 +312,16 @@
}
// deleteOnExit(fd);
try {
+ System.err.println("trying System.load() using:" +
+ fd.getAbsolutePath());
System.load(fd.getAbsolutePath());
DebugLog.debug("Library loaded from", fd);
} catch (Throwable e) {
+ e.printStackTrace();
DebugLog.error("Can't load library file ", e);
return false;
}
+ System.err.println("loadAsSystemResource() success:" +
libFileName);
return true;
}
Index: src/main/java/com/intel/bluetooth/obex/OBEXClientOperationPut.java
===================================================================
--- src/main/java/com/intel/bluetooth/obex/OBEXClientOperationPut.java
(revision 1964)
+++ src/main/java/com/intel/bluetooth/obex/OBEXClientOperationPut.java
(working copy)
@@ -49,10 +49,17 @@
void started() throws IOException {
if ((!outputStreamOpened) && (!operationStarted)) {
- this.replyHeaders = session.deleteImp(sendHeaders);
- operationStarted = true;
+ //this.replyHeaders =
session.deleteImp(sendHeaders);
+ //operationStarted = true;
}
}
+
+ // The SyncML-Obex force a getResponse()/getOutputStream()
+ // process. If folks want the operation closed, then they
+ // must call operation.close().
+ public void readResponse() throws IOException {
+ startPutOperation();
+ }
private void startPutOperation() throws IOException {
operationStarted = true;
Index: src/main/java/com/intel/bluetooth/obex/OBEXClientOperationGet.java
===================================================================
--- src/main/java/com/intel/bluetooth/obex/OBEXClientOperationGet.java
(revision 1964)
+++ src/main/java/com/intel/bluetooth/obex/OBEXClientOperationGet.java
(working copy)
@@ -79,19 +79,35 @@
}
public void closeStream() throws IOException {
- this.operationInProgress = false;
- try {
- while (!isClosed() && (!finalBodyReceived) &&
(!errorReceived)) {
- receiveData(this.inputStream);
- }
- } finally {
- inputStream.close();
- }
+ //this.operationInProgress = false;
+ //try {
+ //while (!isClosed() && (!finalBodyReceived) &&
(!errorReceived)) {
+ //receiveData(this.inputStream);
+ //}
+ //} finally {
+ //inputStream.close();
+ //}
+ inputStream.close();
}
+//<<<<<<< .mine
+ // The SyncML-Obex force a getResponse()/getOutputStream()
+ // process. If folks want the operation closed, then they
+ // must call operation.close().
+ public void readResponse() throws IOException {
+ DebugLog.debug("readResponse()");
+ // nothing to do. any get we make already reads the response
+ // and populates replyHeaders.
+ //throw new IOException("This isn't supported for GET()");
+ //session.writeOperation(OBEXOperationCodes.GET,
OBEXHeaderSetImpl.toByteArray(sendHeaders));
+ }
+
+ /* (non-Javadoc)
+=======
/*
* (non-Javadoc)
*
+>>>>>>> .r1964
* @see javax.microedition.io.OutputConnection#openOutputStream()
*/
public OutputStream openOutputStream() throws IOException {
@@ -104,46 +120,68 @@
}
public void receiveData(OBEXOperationInputStream is) throws
IOException {
- session.writeOperation(OBEXOperationCodes.GET |
OBEXOperationCodes.FINAL_BIT, OBEXHeaderSetImpl
- .toByteArray(sendHeaders));
+ session.writeOperation(OBEXOperationCodes.GET |
OBEXOperationCodes.FINAL_BIT, OBEXHeaderSetImpl.toByteArray(sendHeaders));
byte[] b = session.readOperation();
HeaderSet dataHeaders =
OBEXHeaderSetImpl.readHeaders(b[0], b, 3);
- switch (dataHeaders.getResponseCode()) {
- case OBEXOperationCodes.OBEX_RESPONSE_CONTINUE:
- processData(dataHeaders, is);
- OBEXHeaderSetImpl.appendHeaders(replyHeaders,
dataHeaders);
- break;
- case OBEXOperationCodes.OBEX_RESPONSE_SUCCESS:
- finalBodyReceived = true;
- processData(dataHeaders, is);
- OBEXHeaderSetImpl.appendHeaders(replyHeaders,
dataHeaders);
- closeStream();
- break;
- default:
- errorReceived = true;
- throw new IOException("Operation error "
- +
OBEXUtils.toStringObexResponseCodes(dataHeaders.getResponseCode()));
- }
+//<<<<<<< .mine
+ processData(dataHeaders, is);
+//=======
+ //switch (dataHeaders.getResponseCode()) {
+ //case OBEXOperationCodes.OBEX_RESPONSE_CONTINUE:
+ //processData(dataHeaders, is);
+ //OBEXHeaderSetImpl.appendHeaders(replyHeaders,
dataHeaders);
+ //break;
+ //case OBEXOperationCodes.OBEX_RESPONSE_SUCCESS:
+ //finalBodyReceived = true;
+ //processData(dataHeaders, is);
+ //OBEXHeaderSetImpl.appendHeaders(replyHeaders,
dataHeaders);
+ //closeStream();
+ //break;
+ //default:
+ //errorReceived = true;
+ //throw new IOException("Operation error "
+ //+
OBEXUtils.toStringObexResponseCodes(dataHeaders.getResponseCode()));
+ //}
+//>>>>>>> .r1964
}
private boolean processData(HeaderSet requestHeaders,
OBEXOperationInputStream is) throws IOException {
- byte[] data = (byte[])
requestHeaders.getHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY);
- if (data != null) {
-
requestHeaders.setHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY, null);
- } else {
- data = (byte[])
requestHeaders.getHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY_END);
- if (data != null) {
- finalBodyReceived = true;
-
requestHeaders.setHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY_END, null);
- }
+//<<<<<<< .mine
+ boolean response = false;
+ byte[] data =
(byte[])requestHeaders.getHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY_END);
+ if (data == null) {
+ data =
(byte[])requestHeaders.getHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY);
+//=======
+ //byte[] data = (byte[])
requestHeaders.getHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY);
+ //if (data != null) {
+
//requestHeaders.setHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY, null);
+ //} else {
+ //data = (byte[])
requestHeaders.getHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY_END);
+ //if (data != null) {
+ //finalBodyReceived = true;
+
//requestHeaders.setHeader(OBEXHeaderSetImpl.OBEX_HDR_BODY_END, null);
+ //}
+//>>>>>>> .r1964
}
if ((data != null) && (data.length != 0)) {
DebugLog.debug("processData len", data.length);
is.appendData(data);
- return true;
+ response = true;
} else {
- return false;
+ response = false;
}
+ switch (requestHeaders.getResponseCode()) {
+ case OBEXOperationCodes.OBEX_RESPONSE_CONTINUE:
+ break;
+ case OBEXOperationCodes.OBEX_RESPONSE_SUCCESS:
+ replyHeaders = requestHeaders;
+ closeStream();
+ break;
+ default:
+ throw new IOException("Operation error " +
+
OBEXUtils.toStringObexResponseCodes(requestHeaders.getResponseCode()));
+ }
+ return response;
}
}
Index: src/main/java/com/intel/bluetooth/obex/OBEXClientOperation.java
===================================================================
--- src/main/java/com/intel/bluetooth/obex/OBEXClientOperation.java
(revision 1964)
+++ src/main/java/com/intel/bluetooth/obex/OBEXClientOperation.java
(working copy)
@@ -86,6 +86,8 @@
abstract void started() throws IOException;
+ abstract void readResponse() throws IOException;
+
abstract void closeStream() throws IOException;
protected void validateOperationIsOpen() throws IOException {
@@ -99,7 +101,8 @@
*/
public HeaderSet getReceivedHeaders() throws IOException {
validateOperationIsOpen();
- started();
+ //started();
+ readResponse();
return OBEXHeaderSetImpl.cloneHeaders(this.replyHeaders);
}
@@ -110,8 +113,10 @@
*/
public int getResponseCode() throws IOException {
validateOperationIsOpen();
- started();
- closeStream();
+ readResponse();
+ // No. SyncML-Obex MUST support getResponseCode() then
getOutputStream()
+ //started();
+ //closeStream();
return this.replyHeaders.getResponseCode();
}
@@ -120,10 +125,10 @@
throw new NullPointerException("headers are null");
}
OBEXHeaderSetImpl.validateCreatedHeaderSet(headers);
- validateOperationIsOpen();
+ /*validateOperationIsOpen();
if ((this.operationStarted) &&
(!this.operationInProgress)) {
throw new IOException("the transaction has
already ended");
- }
+ }*/
synchronized (lock) {
sendHeaders = headers;
sendHeadersLength =
OBEXHeaderSetImpl.toByteArray(sendHeaders).length;
Index: src/main/java/com/intel/bluetooth/obex/OBEXClientSessionImpl.java
===================================================================
--- src/main/java/com/intel/bluetooth/obex/OBEXClientSessionImpl.java
(revision 1964)
+++ src/main/java/com/intel/bluetooth/obex/OBEXClientSessionImpl.java
(working copy)
@@ -179,7 +179,8 @@
request[0] = (byte) ((backup ? 1 : 0) | (create ? 0 : 2));
request[1] = 0;
// DebugLog.debug("setPath b[3]", request[0]);
- writeOperation(OBEXOperationCodes.SETPATH |
OBEXOperationCodes.FINAL_BIT, request, OBEXHeaderSetImpl
+ //writeOperation(OBEXOperationCodes.SETPATH |
OBEXOperationCodes.FINAL_BIT, request, OBEXHeaderSetImpl
+ writeOperation(OBEXOperationCodes.SETPATH, request,
OBEXHeaderSetImpl
.toByteArray(headers));
byte[] b = readOperation();
@@ -190,6 +191,7 @@
validateCreatedHeaderSet(headers);
canStartOperation();
writeOperation(OBEXOperationCodes.GET |
OBEXOperationCodes.FINAL_BIT, OBEXHeaderSetImpl.toByteArray(headers));
+ //writeOperation(OBEXOperationCodes.GET,
OBEXHeaderSetImpl.toByteArray(headers));
byte[] b = readOperation();
HeaderSet replyHeaders =
OBEXHeaderSetImpl.readHeaders(b[0], b, 3);
DebugLog.debug0x("GET got reply",
replyHeaders.getResponseCode());

