rhodes 2.1.0 → 2.2.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +7 -0
- data/README.textile +4 -5
- data/Rakefile +8 -1
- data/lib/build/jake.rb +22 -16
- data/lib/extensions/rhoxml/rexml/cdata.rb +67 -0
- data/lib/extensions/rhoxml/rexml/document.rb +2 -116
- data/lib/extensions/rhoxml/rexml/element.rb +1 -1
- data/lib/extensions/rhoxml/rexml/text.rb +117 -0
- data/lib/framework/rho/render.rb +19 -11
- data/lib/framework/rho/rho.rb +17 -10
- data/lib/framework/rho/rhobluetooth.rb +103 -0
- data/lib/framework/rho/rhocontroller.rb +2 -0
- data/lib/framework/rho/rhoevent.rb +43 -0
- data/lib/framework/rho/rhoevent_bb.rb +80 -0
- data/lib/framework/rho/rhoevent_c.rb +47 -0
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/rhom/rhom_db_adapter.rb +2 -1
- data/lib/framework/rhom/rhom_model.rb +9 -3
- data/lib/framework/rhom/rhom_object_factory.rb +46 -22
- data/lib/framework/rhom/rhom_source.rb +12 -10
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/AndroidManifest.xml +23 -2
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +54 -38
- data/platform/android/Rhodes/jni/include/rhodes.h +3 -0
- data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +2 -2
- data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +4 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +16 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_bluetooth_RhoBluetoothManager.h +21 -0
- data/platform/android/Rhodes/jni/src/bluetooth.cpp +169 -0
- data/platform/android/Rhodes/jni/src/callbacks.cpp +10 -0
- data/platform/android/Rhodes/jni/src/event.cpp +429 -0
- data/platform/android/Rhodes/jni/src/fileapi.cpp +51 -1
- data/platform/android/Rhodes/jni/src/rhodes.cpp +16 -0
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -0
- data/platform/android/Rhodes/res/layout/bt_device_list.xml +42 -0
- data/platform/android/Rhodes/res/layout/bt_device_name.xml +7 -0
- data/platform/android/Rhodes/res/values/strings.xml +8 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +14 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +2 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Push.java +7 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +58 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +53 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +144 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/IRhoBluetoothManager.java +66 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothDeviceListActivity.java +201 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +139 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +401 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerOld.java +136 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothSession.java +457 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/UUIDHelper.java +71 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +12 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/Event.java +19 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +261 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +4 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +10 -2
- data/platform/android/build/RhodesSRC_build.files +33 -22
- data/platform/android/build/android.rake +198 -27
- data/platform/android/build/librhodes_build.files +3 -1
- data/platform/android/build/libruby_build.files +4 -1
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +2 -2
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBRowResult.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +7 -4
- data/platform/bb/Hsqldb/src/org/hsqldb/Like.java +3 -3
- data/platform/bb/Hsqldb/src/org/hsqldb/Table.java +3 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +1 -1
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +108 -1
- data/platform/bb/RubyVM/src/com/rho/RhoLogConf.java +7 -1
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +7 -4
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +7 -1
- data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +21 -23
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +19 -10
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +8 -0
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +3 -0
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +14 -17
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFile.java +7 -5
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +2 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyRuntime.java +10 -1
- data/platform/bb/RubyVM/src/j2me/io/File.java +7 -6
- data/platform/bb/build/RubyVM_build.files +412 -412
- data/platform/bb/build/bb.rake +42 -18
- data/platform/bb/build/hsqldb_build.files +151 -151
- data/platform/bb/build/rhodes_build.files +44 -40
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +2 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +237 -0
- data/platform/bb/rhodes/platform/common/com/rho/RhodesApplicationPlatform.java +14 -0
- data/platform/bb/rhodes/rhodes.jdp +6 -1
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +7 -1
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +14 -0
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +62 -76
- data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +660 -0
- data/platform/bb/rhodes/src/{rhomobile → com/rho/rubyext}/RhoPhonebook.java +95 -38
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +22 -1
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +26 -6
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +21 -7
- data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothManager.java +528 -0
- data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothPort.java +281 -0
- data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothScreen.java +119 -0
- data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +2 -2
- data/platform/iphone/Classes/AppManager/AppManager.m +70 -7
- data/platform/iphone/Classes/Bluetooth/Bluetooth.h +72 -0
- data/platform/iphone/Classes/Bluetooth/Bluetooth.m +414 -0
- data/platform/iphone/Classes/Event/Event.h +12 -0
- data/platform/iphone/Classes/Event/Event.m +300 -0
- data/platform/iphone/Classes/LogOptionsController.h +2 -1
- data/platform/iphone/Classes/LogOptionsController.m +1 -1
- data/platform/iphone/Classes/LogViewController.h +2 -1
- data/platform/iphone/Classes/MapView/MapViewController.h +2 -1
- data/platform/iphone/Classes/RhoViewController.h +16 -0
- data/platform/iphone/Classes/RhoViewController.m +20 -0
- data/platform/iphone/Classes/Rhodes.h +12 -0
- data/platform/iphone/Classes/Rhodes.m +34 -6
- data/platform/iphone/Classes/Signature/SignatureViewController.h +2 -2
- data/platform/iphone/Classes/Signature/SignatureViewController.m +0 -10
- data/platform/iphone/Classes/SimpleMainView.h +2 -2
- data/platform/iphone/Classes/SimpleMainView.m +5 -14
- data/platform/iphone/Classes/SplashViewController.h +2 -2
- data/platform/iphone/Classes/TabbedMainView.h +2 -2
- data/platform/iphone/Classes/TabbedMainView.m +5 -10
- data/platform/iphone/Info.plist +5 -5
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +39 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +47 -4
- data/platform/osx/Rhodes Debugger/NoodleLineNumberView.m +3 -2
- data/platform/shared/common/AutoPointer.h +3 -0
- data/platform/shared/common/RhoConf.cpp +2 -1
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhoTime.h +3 -3
- data/platform/shared/common/RhodesApp.cpp +75 -23
- data/platform/shared/common/RhodesApp.h +4 -0
- data/platform/shared/common/RhodesAppBase.h +2 -0
- data/platform/shared/common/ThreadQueue.cpp +23 -18
- data/platform/shared/common/ThreadQueue.h +2 -0
- data/platform/shared/db/res/db/syncdb.schema +39 -39
- data/platform/shared/logging/RhoLogConf.cpp +58 -3
- data/platform/shared/logging/RhoLogConf.h +3 -1
- data/platform/shared/net/CURLNetRequest.cpp +17 -6
- data/platform/shared/net/HttpServer.cpp +125 -25
- data/platform/shared/net/HttpServer.h +4 -3
- data/platform/shared/ruby/ext/bluetooth/bluetooth.i +56 -0
- data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +2563 -0
- data/platform/shared/ruby/ext/calendar/calendar.i +28 -0
- data/platform/shared/ruby/ext/calendar/calendar_wrap.c +2251 -0
- data/platform/shared/ruby/ext/calendar/event.h +41 -0
- data/platform/shared/ruby/ext/calendar/event.i +28 -0
- data/platform/shared/ruby/ext/calendar/event_wrap.c +2151 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +103 -3
- data/platform/shared/ruby/ext/rho/rhoruby.h +16 -2
- data/platform/shared/ruby/ext/rhoconf/rhoconf.i +12 -0
- data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +101 -0
- data/platform/shared/ruby/ext/system/system.i +14 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +2568 -2208
- data/platform/shared/ruby/main.c +8 -0
- data/platform/shared/rubyext/GeoLocation.cpp +6 -3
- data/platform/shared/rubyext/System.cpp +14 -0
- data/platform/shared/sync/SyncEngine.cpp +9 -1
- data/platform/shared/sync/SyncNotify.cpp +16 -8
- data/platform/shared/sync/SyncNotify.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +7 -12
- data/platform/shared/sync/SyncThread.h +5 -3
- data/platform/wm/build/wm.rake +7 -1
- data/platform/wm/rhodes/Alert.cpp +1 -1
- data/platform/wm/rhodes/MainWindow.cpp +28 -0
- data/platform/wm/rhodes/MainWindow.h +9 -0
- data/platform/wm/rhodes/OutlookApp.cpp +72 -0
- data/platform/wm/rhodes/OutlookApp.h +22 -0
- data/platform/wm/rhodes/Rhodes.cpp +8 -0
- data/platform/wm/rhodes/Rhodes.rc +31 -0
- data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1274 -0
- data/platform/wm/rhodes/bluetooth/Bluetooth.h +321 -0
- data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +37 -70
- data/platform/wm/rhodes/phonebook/NativeAddressBook.h +0 -4
- data/platform/wm/rhodes/resource.h +8 -1
- data/platform/wm/rhodes/rho/net/NetRequest.cpp +4 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +6 -4
- data/platform/wm/rhodes/rho/rubyext/calendar.cpp +487 -0
- data/platform/wm/rhodes/rhodes.vcproj +28 -11
- data/platform/wm/rhodes/stdafx.h +1 -0
- data/platform/wm/rubylib/rubylib.vcproj +32 -0
- data/rakefile.rb +8 -1
- data/res/generators/templates/application/Rakefile +1 -1
- data/res/generators/templates/application/app/layout.erb +4 -1
- data/res/generators/templates/application/build.yml +0 -1
- data/res/generators/templates/application/public/css/iphone.css +2 -2
- data/res/generators/templates/application/public/jqtouch/jqtouch-iphone.css +9 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.css +1 -5
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +3 -2
- data/rhodes.gemspec +1 -1
- data/spec/perfomance_spec/app/Benchmark/benchmark.rb +4 -0
- data/spec/perfomance_spec/app/Benchmark/bulk_results.erb +13 -0
- data/spec/perfomance_spec/app/Benchmark/controller.rb +178 -0
- data/spec/perfomance_spec/app/Benchmark/create_results.erb +13 -0
- data/spec/perfomance_spec/app/Benchmark/customers.erb +35 -0
- data/spec/perfomance_spec/app/Benchmark/index.erb +9 -0
- data/spec/perfomance_spec/app/Benchmark/products.erb +25 -0
- data/spec/perfomance_spec/app/Benchmark/search_results.erb +13 -0
- data/spec/perfomance_spec/app/Customer/customer.rb +6 -0
- data/spec/perfomance_spec/app/Perftest/index.erb +5 -0
- data/spec/perfomance_spec/app/Product/index.erb +25 -0
- data/spec/perfomance_spec/app/Product/product.rb +6 -0
- data/spec/perfomance_spec/app/helpers/application_helper.rb +126 -0
- data/spec/perfomance_spec/app/helpers/browser_helper.rb +18 -0
- data/spec/perfomance_spec/rhoconfig.txt +1 -1
- data/spec/phone_spec/app/Account_s/account_s.rb +5 -2
- data/spec/phone_spec/app/Case/case.rb +1 -0
- data/spec/phone_spec/app/Case_s/case_s.rb +2 -0
- data/spec/phone_spec/app/Data/perftest.json +35 -0
- data/spec/phone_spec/app/Data/testCDATA.xml +11 -0
- data/spec/phone_spec/app/Product/product.rb +1 -1
- data/spec/phone_spec/app/{Spec → spec}/asynchttp_spec.rb +66 -17
- data/spec/phone_spec/app/{Spec → spec}/barcode_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/blobsync_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/bsearch_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/bulksync_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/contacts_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/crypt_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/date_spec.rb +0 -0
- data/spec/phone_spec/app/spec/events_spec.rb +199 -0
- data/spec/phone_spec/app/{Spec → spec}/fixtures/client_info.txt +0 -0
- data/spec/phone_spec/app/{Spec → spec}/fixtures/object_values.txt +0 -0
- data/spec/phone_spec/app/{Spec → spec}/json_spec.rb +11 -2
- data/spec/phone_spec/app/{Spec → spec}/mapview_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/nativebar_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/navbar_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/pagination/fixtures/object_values.txt +0 -0
- data/spec/phone_spec/app/{Spec → spec}/rho_controller_spec.rb +5 -0
- data/spec/phone_spec/app/{Spec → spec}/rho_spec.rb +48 -0
- data/spec/phone_spec/app/{Spec → spec}/rhofile_spec.rb +9 -6
- data/spec/phone_spec/app/{Spec → spec}/rhom_object_spec.rb +188 -9
- data/spec/phone_spec/app/{Spec → spec}/syncengine_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/xml_spec.rb +15 -0
- data/spec/phone_spec/app/{Spec → spec}/xruby_spec.rb +0 -0
- data/spec/phone_spec/app/spec_runner.rb +4 -1
- data/spec/phone_spec/build.yml +2 -1
- metadata +95 -31
- data/platform/bb/rhodes/platform/5.0/com/rho/RhoMainScreen.java +0 -36
- data/platform/bb/rhodes/platform/6.0/com/rho/BrowserAdapter5.java +0 -155
- data/platform/bb/rhodes/platform/6.0/com/rho/RhoMainScreen.java +0 -36
@@ -0,0 +1,281 @@
|
|
1
|
+
package rhomobile.bluetooth;
|
2
|
+
|
3
|
+
import java.io.IOException;
|
4
|
+
|
5
|
+
import net.rim.device.api.bluetooth.BluetoothSerialPort;
|
6
|
+
import net.rim.device.api.bluetooth.BluetoothSerialPortInfo;
|
7
|
+
import net.rim.device.api.bluetooth.BluetoothSerialPortListener;
|
8
|
+
import net.rim.device.api.ui.component.Status;
|
9
|
+
import net.rim.device.api.util.DataBuffer;
|
10
|
+
|
11
|
+
public class BluetoothPort implements BluetoothSerialPortListener {
|
12
|
+
|
13
|
+
public interface BluetoothPortListener {
|
14
|
+
public void onBluetoothPortDisconnect();
|
15
|
+
public void onBluetoothPortError();
|
16
|
+
public void onBluetoothPortDataReceived();
|
17
|
+
public void onBluetoothPortConnected(boolean success);
|
18
|
+
}
|
19
|
+
|
20
|
+
private BluetoothSerialPort mPort;
|
21
|
+
private static boolean mIsDataSent = true;
|
22
|
+
private DataBuffer mWritedData;
|
23
|
+
private DataBuffer mReadedData;
|
24
|
+
private BluetoothPortListener mListener = null;
|
25
|
+
private byte[] _receiveBuffer = new byte[1024];
|
26
|
+
private String mConnectedDeviceName = "";
|
27
|
+
|
28
|
+
private ConnectionListenThread mListenThread = null;
|
29
|
+
|
30
|
+
private class ConnectionListenThread extends Thread {
|
31
|
+
private BluetoothPort Port;
|
32
|
+
private byte[] data;
|
33
|
+
public ConnectionListenThread(BluetoothPort port) {
|
34
|
+
Port = port;
|
35
|
+
data = new byte[1];
|
36
|
+
}
|
37
|
+
|
38
|
+
public void run() {
|
39
|
+
while (true) {
|
40
|
+
try {
|
41
|
+
sleep(50);
|
42
|
+
}
|
43
|
+
catch (Exception e) {
|
44
|
+
|
45
|
+
}
|
46
|
+
try {
|
47
|
+
if (Port.mPort != null) {
|
48
|
+
int readed = Port.mPort.read(data, 0, 1);
|
49
|
+
if (readed > 0) {
|
50
|
+
mReadedData.writeByteArray(data, 0, 1);
|
51
|
+
}
|
52
|
+
// ok
|
53
|
+
Port.deviceConnected(true);
|
54
|
+
Port.mListenThread = null;
|
55
|
+
BluetoothManager.getInstance().closeBluetoothScreenSilent();
|
56
|
+
interrupt();
|
57
|
+
}
|
58
|
+
}
|
59
|
+
catch (Exception e) {
|
60
|
+
// port not ready
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
public void disconnect() {
|
70
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.disconnect()");
|
71
|
+
if (mPort != null) {
|
72
|
+
mPort.disconnect();
|
73
|
+
mPort.close();
|
74
|
+
//mListener.onBluetoothPortDisconnect();
|
75
|
+
}
|
76
|
+
else {
|
77
|
+
mListener.onBluetoothPortError();
|
78
|
+
}
|
79
|
+
if (mListenThread != null) {
|
80
|
+
mListenThread.interrupt();
|
81
|
+
mListenThread = null;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
public int getStatus() {
|
86
|
+
return mReadedData.getArrayLength();
|
87
|
+
}
|
88
|
+
|
89
|
+
public byte[] readData() {
|
90
|
+
byte[] data = null;
|
91
|
+
synchronized(mReadedData) {
|
92
|
+
data = mReadedData.toArray();
|
93
|
+
mReadedData.reset();
|
94
|
+
}
|
95
|
+
return data;
|
96
|
+
}
|
97
|
+
|
98
|
+
public void writeData(byte[] data) {
|
99
|
+
synchronized(mWritedData)
|
100
|
+
{
|
101
|
+
mWritedData.write(data, 0, data.length);
|
102
|
+
}
|
103
|
+
// Call sendData to send the data.
|
104
|
+
sendData();
|
105
|
+
}
|
106
|
+
|
107
|
+
public String getConnectedDeviceName() {
|
108
|
+
return mConnectedDeviceName;
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
public void startListenThread() {
|
113
|
+
//mListenThread = new ConnectionListenThread(this);
|
114
|
+
//mListenThread.start();
|
115
|
+
//deviceConnected(true);
|
116
|
+
}
|
117
|
+
|
118
|
+
public BluetoothPort(BluetoothSerialPortInfo info, BluetoothPortListener listener)
|
119
|
+
{
|
120
|
+
// Fill a 1k array with the a character.
|
121
|
+
//Arrays.fill(_receiveBuffer, (byte)'a');
|
122
|
+
|
123
|
+
// Initialize the buffers.
|
124
|
+
//_data = new StringBuffer();
|
125
|
+
|
126
|
+
mReadedData = new DataBuffer();
|
127
|
+
mWritedData = new DataBuffer();
|
128
|
+
|
129
|
+
mListener = listener;
|
130
|
+
|
131
|
+
try
|
132
|
+
{
|
133
|
+
if(info == null)
|
134
|
+
{
|
135
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.BluetoothPort() server init");
|
136
|
+
// Open a port to listen for incoming connections.
|
137
|
+
mPort = new BluetoothSerialPort(BluetoothSerialPort.DEFAULT_UUID, "btspp", BluetoothSerialPort.BAUD_9600, BluetoothSerialPort.DATA_FORMAT_PARITY_NONE | BluetoothSerialPort.DATA_FORMAT_STOP_BITS_1 | BluetoothSerialPort.DATA_FORMAT_DATA_BITS_8, BluetoothSerialPort.FLOW_CONTROL_NONE, 1024, 1024, this);
|
138
|
+
mConnectedDeviceName = "unknown";//mPort.toString();
|
139
|
+
}
|
140
|
+
else
|
141
|
+
{
|
142
|
+
// Connect to the selected device.
|
143
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.BluetoothPort() client init");
|
144
|
+
mPort = new BluetoothSerialPort(info, BluetoothSerialPort.BAUD_9600, BluetoothSerialPort.DATA_FORMAT_PARITY_NONE | BluetoothSerialPort.DATA_FORMAT_STOP_BITS_1 | BluetoothSerialPort.DATA_FORMAT_DATA_BITS_8, BluetoothSerialPort.FLOW_CONTROL_NONE, 1024, 1024, this);
|
145
|
+
mConnectedDeviceName = info.getDeviceName();
|
146
|
+
}
|
147
|
+
}
|
148
|
+
catch(IOException ex)
|
149
|
+
{
|
150
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.BluetoothPort() ERROR!");
|
151
|
+
mListener.onBluetoothPortError();
|
152
|
+
//Status.show("Error: " + ex.getMessage());
|
153
|
+
}
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
// Invoked when a connection is established.
|
158
|
+
public void deviceConnected(boolean success)
|
159
|
+
{
|
160
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.deviceConnected("+String.valueOf(success)+")");
|
161
|
+
if (success) {
|
162
|
+
}
|
163
|
+
mListener.onBluetoothPortConnected(success);
|
164
|
+
}
|
165
|
+
|
166
|
+
// Invoked when a connection is closed.
|
167
|
+
public void deviceDisconnected()
|
168
|
+
{
|
169
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.deviceDisconnected()");
|
170
|
+
mListener.onBluetoothPortDisconnect();
|
171
|
+
}
|
172
|
+
|
173
|
+
// Invoked when the drt state changes.
|
174
|
+
public void dtrStateChange(boolean high)
|
175
|
+
{
|
176
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.dtrStateChange("+String.valueOf(high)+")");
|
177
|
+
//Status.show("DTR: " + high);
|
178
|
+
}
|
179
|
+
|
180
|
+
// Invoked when data has been received.
|
181
|
+
public void dataReceived(int length)
|
182
|
+
{
|
183
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.dataReceived("+String.valueOf(length)+")");
|
184
|
+
int len;
|
185
|
+
try
|
186
|
+
{
|
187
|
+
// Read the data that arrived.
|
188
|
+
if((len = mPort.read(_receiveBuffer, 0, length == -1 ? _receiveBuffer.length : length)) != 0)
|
189
|
+
{
|
190
|
+
// If loopback is enabled write the data back.
|
191
|
+
if(len == 1 && _receiveBuffer[0] == '\r')
|
192
|
+
{
|
193
|
+
_receiveBuffer[1] = '\n';
|
194
|
+
++len;
|
195
|
+
}
|
196
|
+
|
197
|
+
// Update the screen with the new data that arrived.
|
198
|
+
synchronized (mReadedData) {
|
199
|
+
mReadedData.writeByteArray(_receiveBuffer, 0, len);
|
200
|
+
}
|
201
|
+
mListener.onBluetoothPortDataReceived();
|
202
|
+
}
|
203
|
+
} catch(IOException ioex)
|
204
|
+
{
|
205
|
+
// Catch and re-throw the exception.
|
206
|
+
// throw new RuntimeException(ioex.toString());
|
207
|
+
mListener.onBluetoothPortError();
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
// Invoked after all data in the buffer has been sent.
|
212
|
+
public void dataSent()
|
213
|
+
{
|
214
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.dataSent()");
|
215
|
+
// Set the _dataSent flag to true to allow more data to be written.
|
216
|
+
mIsDataSent = true;
|
217
|
+
|
218
|
+
// Call sendData in case there is data waiting to be sent.
|
219
|
+
sendData();
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
// Sends the data currently in the DataBuffer.
|
224
|
+
private void sendData()
|
225
|
+
{
|
226
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.sendData()");
|
227
|
+
// Ensure we have data to send.
|
228
|
+
synchronized (mWritedData) {
|
229
|
+
if (mWritedData.getArrayLength() > 0)
|
230
|
+
{
|
231
|
+
// Ensure the last write call has resulted in the sending of the data
|
232
|
+
// prior to calling write again. Calling write in sequence without waiting
|
233
|
+
// for the data to be sent can overwrite existing requests and result in
|
234
|
+
// data loss.
|
235
|
+
if (mIsDataSent)
|
236
|
+
{
|
237
|
+
try
|
238
|
+
{
|
239
|
+
// Set the _dataSent flag to false so we don't send any more
|
240
|
+
// data until it has been verified that this data was sent.
|
241
|
+
mIsDataSent = false;
|
242
|
+
|
243
|
+
// Write out the data in the DataBuffer and reset the DataBuffer.
|
244
|
+
mPort.write(mWritedData.getArray(), 0, mWritedData.getArrayLength());
|
245
|
+
mWritedData.reset();
|
246
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.sendData() data was sended");
|
247
|
+
}
|
248
|
+
catch (IOException ioex)
|
249
|
+
{
|
250
|
+
// Reset _dataSent to true so we can attempt another data write.
|
251
|
+
mIsDataSent = true;
|
252
|
+
//System.out.println("Failed to write data. Exception: " + ioex.toString());
|
253
|
+
BluetoothManager.rhoLogError("BluetoothPort.sendData() ERROR during send data");
|
254
|
+
mListener.onBluetoothPortError();
|
255
|
+
}
|
256
|
+
}
|
257
|
+
else
|
258
|
+
{
|
259
|
+
BluetoothManager.rhoLogInfo("BluetoothPort.sendData() data can not send now - wait");
|
260
|
+
//System.out.println("Can't send data right now, data will be sent after dataSent notify call.");
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
}
|
@@ -0,0 +1,119 @@
|
|
1
|
+
package rhomobile.bluetooth;
|
2
|
+
|
3
|
+
import net.rim.device.api.ui.DrawStyle;
|
4
|
+
import net.rim.device.api.ui.Field;
|
5
|
+
import net.rim.device.api.ui.component.LabelField;
|
6
|
+
import net.rim.device.api.ui.component.SeparatorField;
|
7
|
+
import net.rim.device.api.ui.container.MainScreen;
|
8
|
+
|
9
|
+
public class BluetoothScreen extends MainScreen {
|
10
|
+
|
11
|
+
public static int BLUETOOTH_SCREEN_TYPE_CLIENT = 1;
|
12
|
+
public static int BLUETOOTH_SCREEN_TYPE_SERVER = 2;
|
13
|
+
public static int BLUETOOTH_SCREEN_TYPE_UNSUPPORTED = 3;
|
14
|
+
|
15
|
+
public interface BluetoothScreenCallback {
|
16
|
+
void onBluetoothScreenCancel();
|
17
|
+
void onBluetoothScreenSelect(int index);
|
18
|
+
}
|
19
|
+
|
20
|
+
private static String TITLE = "Bluetooth";
|
21
|
+
private static String SELECT_DEVICE = "Please select device to connect :";
|
22
|
+
private static String WAIT_FOR_CONNECT = "Waiting for a connection ...";
|
23
|
+
private static String NO_DEVICES = "There are no paired devices for connect !";
|
24
|
+
private static String UNSUPPORTED = "Bluetooth is not supported on this BlackBerry or simulator.";
|
25
|
+
|
26
|
+
|
27
|
+
private BluetoothScreenCallback mCallback;
|
28
|
+
private LabelField[] mFields;
|
29
|
+
private boolean mIsClosedBySelect = false;
|
30
|
+
|
31
|
+
|
32
|
+
public BluetoothScreen(int type, String[] devices, BluetoothScreenCallback callback) {
|
33
|
+
BluetoothManager.rhoLogInfo("BluetoothScreen()");
|
34
|
+
mCallback = callback;
|
35
|
+
mFields = new LabelField[0];
|
36
|
+
setTitle(TITLE);
|
37
|
+
if (type == BLUETOOTH_SCREEN_TYPE_UNSUPPORTED) {
|
38
|
+
BluetoothManager.rhoLogInfo(" TYPE_UNSUPPORTED");
|
39
|
+
add(new LabelField(UNSUPPORTED));
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
if (type == BLUETOOTH_SCREEN_TYPE_SERVER) {
|
43
|
+
BluetoothManager.rhoLogInfo(" TYPE_SERVER");
|
44
|
+
add(new LabelField(WAIT_FOR_CONNECT));
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
if (type == BLUETOOTH_SCREEN_TYPE_CLIENT) {
|
48
|
+
BluetoothManager.rhoLogInfo(" TYPE_CLIENT");
|
49
|
+
if (devices.length <= 0) {
|
50
|
+
add(new LabelField(NO_DEVICES));
|
51
|
+
BluetoothManager.rhoLogInfo(" NO_DEVICES");
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
add(new LabelField(SELECT_DEVICE));
|
56
|
+
add(new SeparatorField());
|
57
|
+
int i;
|
58
|
+
mFields = new LabelField[devices.length];
|
59
|
+
for (i = 0; i < devices.length; i++) {
|
60
|
+
LabelField lg = new LabelField(devices[i], Field.FOCUSABLE | Field.USE_ALL_WIDTH);
|
61
|
+
BluetoothManager.rhoLogInfo(" DEVICE["+String.valueOf(i)+"]="+devices[i]);
|
62
|
+
mFields[i] = lg;
|
63
|
+
add(lg);
|
64
|
+
}
|
65
|
+
add(new SeparatorField());
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Overrides Screen.invokeAction(). Handles a trackball click and provides
|
71
|
+
* identical behavior to an ENTER keypress event.
|
72
|
+
*
|
73
|
+
* @see net.rim.device.api.ui#invokeAction(int)
|
74
|
+
*/
|
75
|
+
public boolean invokeAction(int action)
|
76
|
+
{
|
77
|
+
switch(action)
|
78
|
+
{
|
79
|
+
case ACTION_INVOKE: // Trackball click.
|
80
|
+
int i;
|
81
|
+
for (i = 0; i < mFields.length; i++) {
|
82
|
+
if (mFields[i].isFocus()) {
|
83
|
+
if (mCallback != null) {
|
84
|
+
mCallback.onBluetoothScreenSelect(i);
|
85
|
+
mIsClosedBySelect = true;
|
86
|
+
BluetoothManager.rhoPopScreen(this);
|
87
|
+
}
|
88
|
+
return true; // We've consumed the event.
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return super.invokeAction(action);
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Called when the main screen (and thus, the application) closes. Removes
|
97
|
+
* this screen as a low memory listener, and commits the order list to the
|
98
|
+
* persistent store.
|
99
|
+
*
|
100
|
+
* @see net.rim.device.api.ui.Screen#onClose()
|
101
|
+
*/
|
102
|
+
public boolean onClose()
|
103
|
+
{
|
104
|
+
if (mCallback != null) {
|
105
|
+
if (!mIsClosedBySelect) {
|
106
|
+
mCallback.onBluetoothScreenCancel();
|
107
|
+
}
|
108
|
+
}
|
109
|
+
mIsClosedBySelect = false;
|
110
|
+
return super.onClose();
|
111
|
+
}
|
112
|
+
|
113
|
+
public void closeSilent() {
|
114
|
+
mIsClosedBySelect = true;
|
115
|
+
BluetoothManager.rhoPopScreen(this);
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
}
|
@@ -26,8 +26,8 @@ public class CameraFilesListener implements FileSystemJournalListener {
|
|
26
26
|
private Hashtable _exists;
|
27
27
|
|
28
28
|
private final String[] _folders = {
|
29
|
-
"file
|
30
|
-
"file
|
29
|
+
"file:///store/home/user/pictures/",
|
30
|
+
"file:///sdcard/blackberry/pictures/"
|
31
31
|
};
|
32
32
|
|
33
33
|
public CameraFilesListener(CameraScreen screen) {
|
@@ -83,8 +83,9 @@ static bool UnzipApplication(const char* appRoot, const void* zipbuf, unsigned i
|
|
83
83
|
}
|
84
84
|
|
85
85
|
if (!remove && dir) {
|
86
|
+
NSError *error;
|
86
87
|
if (![fileManager fileExistsAtPath:target])
|
87
|
-
[fileManager createDirectoryAtPath:target attributes:nil];
|
88
|
+
[fileManager createDirectoryAtPath:target withIntermediateDirectories:YES attributes:nil error:&error];
|
88
89
|
|
89
90
|
NSDirectoryEnumerator *enumerator = [fileManager enumeratorAtPath:source];
|
90
91
|
NSString *child;
|
@@ -107,6 +108,8 @@ static bool UnzipApplication(const char* appRoot, const void* zipbuf, unsigned i
|
|
107
108
|
}
|
108
109
|
|
109
110
|
- (BOOL)isContentsEqual:(NSFileManager*)fileManager first:(NSString*)filePath1 second:(NSString*)filePath2 {
|
111
|
+
NSLog(@"filePath1: %@", filePath1);
|
112
|
+
NSLog(@"filePath2: %@", filePath2);
|
110
113
|
if (![fileManager fileExistsAtPath:filePath1] || ![fileManager fileExistsAtPath:filePath2])
|
111
114
|
return NO;
|
112
115
|
|
@@ -125,6 +128,8 @@ static bool UnzipApplication(const char* appRoot, const void* zipbuf, unsigned i
|
|
125
128
|
*/
|
126
129
|
- (void) configure {
|
127
130
|
|
131
|
+
#define RHO_DONT_COPY_ON_START
|
132
|
+
|
128
133
|
NSFileManager *fileManager = [NSFileManager defaultManager];
|
129
134
|
|
130
135
|
NSString *bundleRoot = [[NSBundle mainBundle] resourcePath];
|
@@ -132,7 +137,9 @@ static bool UnzipApplication(const char* appRoot, const void* zipbuf, unsigned i
|
|
132
137
|
|
133
138
|
NSString *filePathNew = [bundleRoot stringByAppendingPathComponent:@"name"];
|
134
139
|
NSString *filePathOld = [rhoRoot stringByAppendingPathComponent:@"name"];
|
140
|
+
#ifndef RHO_DONT_COPY_ON_START
|
135
141
|
BOOL hasOldName = [fileManager fileExistsAtPath:filePathOld];
|
142
|
+
#endif
|
136
143
|
BOOL nameChanged = ![self isContentsEqual:fileManager first:filePathNew second:filePathOld];
|
137
144
|
|
138
145
|
BOOL contentChanged;
|
@@ -144,18 +151,67 @@ static bool UnzipApplication(const char* appRoot, const void* zipbuf, unsigned i
|
|
144
151
|
|
145
152
|
contentChanged = ![self isContentsEqual:fileManager first:filePathNew second:filePathOld];
|
146
153
|
}
|
147
|
-
|
148
|
-
|
154
|
+
|
155
|
+
if (contentChanged) {
|
156
|
+
#ifdef RHO_DONT_COPY_ON_START
|
157
|
+
NSError *error;
|
158
|
+
// Create symlink to "lib"
|
159
|
+
NSString *src = [bundleRoot stringByAppendingPathComponent:@"lib"];
|
160
|
+
NSLog(@"src: %@", src);
|
161
|
+
NSString *dst = [rhoRoot stringByAppendingPathComponent:@"lib"];
|
162
|
+
NSLog(@"dst: %@", dst);
|
163
|
+
[fileManager removeItemAtPath:dst error:&error];
|
164
|
+
[fileManager createSymbolicLinkAtPath:dst withDestinationPath:src error:&error];
|
165
|
+
|
166
|
+
NSString *dirs[] = {@"apps", @"db"};
|
167
|
+
for (int i = 0, lim = sizeof(dirs)/sizeof(dirs[0]); i < lim; ++i) {
|
168
|
+
// Create directory
|
169
|
+
src = [bundleRoot stringByAppendingPathComponent:dirs[i]];
|
170
|
+
NSLog(@"src: %@", src);
|
171
|
+
dst = [rhoRoot stringByAppendingPathComponent:dirs[i]];
|
172
|
+
NSLog(@"dst: %@", dst);
|
173
|
+
if (![fileManager fileExistsAtPath:dst])
|
174
|
+
[fileManager createDirectoryAtPath:dst withIntermediateDirectories:YES attributes:nil error:&error];
|
175
|
+
|
176
|
+
// And make symlinks from its content
|
177
|
+
NSArray *subelements = [fileManager contentsOfDirectoryAtPath:src error:&error];
|
178
|
+
for (int i = 0, lim = [subelements count]; i < lim; ++i) {
|
179
|
+
NSString *child = [subelements objectAtIndex:i];
|
180
|
+
NSString *fchild = [src stringByAppendingPathComponent:child];
|
181
|
+
NSLog(@"src: %@", fchild);
|
182
|
+
NSString *target = [dst stringByAppendingPathComponent:child];
|
183
|
+
NSLog(@"dst: %@", target);
|
184
|
+
[fileManager removeItemAtPath:target error:&error];
|
185
|
+
if ([child isEqualToString:@"rhoconfig.txt"])
|
186
|
+
[fileManager copyItemAtPath:fchild toPath:target error:&error];
|
187
|
+
else
|
188
|
+
[fileManager createSymbolicLinkAtPath:target withDestinationPath:fchild error:&error];
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
// Finally, copy "hash" and "name" files
|
193
|
+
NSString *items[] = {@"hash", @"name"};
|
194
|
+
for (int i = 0, lim = sizeof(items)/sizeof(items[0]); i < lim; ++i) {
|
195
|
+
NSString *src = [bundleRoot stringByAppendingPathComponent:items[i]];
|
196
|
+
NSLog(@"src: %@", src);
|
197
|
+
NSString *dst = [rhoRoot stringByAppendingPathComponent:items[i]];
|
198
|
+
NSLog(@"dst: %@", dst);
|
199
|
+
[fileManager removeItemAtPath:dst error:&error];
|
200
|
+
[fileManager copyItemAtPath:src toPath:dst error:&error];
|
201
|
+
}
|
202
|
+
#else
|
149
203
|
NSString *dirs[] = {@"apps", @"lib", @"db", @"hash", @"name"};
|
150
204
|
for (int i = 0, lim = sizeof(dirs)/sizeof(dirs[0]); i < lim; ++i) {
|
151
205
|
BOOL remove = nameChanged;
|
152
206
|
if ([dirs[i] isEqualToString:@"db"] && !hasOldName)
|
153
207
|
remove = NO;
|
154
|
-
[
|
155
|
-
|
156
|
-
|
157
|
-
|
208
|
+
NSString *src = [bundleRoot stringByAppendingPathComponent:dirs[i]];
|
209
|
+
NSLog(@"src: %@", src);
|
210
|
+
NSString *dst = [rhoRoot stringByAppendingPathComponent:dirs[i]];
|
211
|
+
NSLog(@"dst: %@", dst);
|
212
|
+
[self copyFromMainBundle:fileManager fromPath:src toPath:dst remove:remove];
|
158
213
|
}
|
214
|
+
#endif
|
159
215
|
}
|
160
216
|
|
161
217
|
rho_logconf_Init(rho_native_rhopath());
|
@@ -200,6 +256,13 @@ int rho_sys_get_screen_height()
|
|
200
256
|
return rect.size.height;
|
201
257
|
}
|
202
258
|
|
259
|
+
int rho_sys_set_sleeping(int sleeping)
|
260
|
+
{
|
261
|
+
int ret = [[UIApplication sharedApplication] isIdleTimerDisabled] ? 0 : 1;
|
262
|
+
[[UIApplication sharedApplication] setIdleTimerDisabled: (!sleeping ? YES : NO)];
|
263
|
+
return ret;
|
264
|
+
}
|
265
|
+
|
203
266
|
extern VALUE rho_sys_has_network();
|
204
267
|
|
205
268
|
// http://www.apple.com/iphone/specs.html
|