rhodes 3.2.3 → 3.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +10 -0
- data/Rakefile +153 -46
- data/doc/build.txt +261 -102
- data/doc/configuration.txt +5 -2
- data/doc/device-caps.txt +134 -23
- data/doc/extensions.txt +922 -69
- data/doc/generator.txt +96 -39
- data/doc/install.txt +35 -19
- data/doc/jqt-jqm-transition.txt +17 -1
- data/doc/rhom.txt +23 -2
- data/doc/rhostudio-eclipse.txt +49 -0
- data/doc/rhostudio-test-plan.txt +440 -0
- data/doc/simulator.txt +1 -1
- data/doc/synchronization.txt +40 -1
- data/lib/build/jake.rb +108 -7
- data/lib/extensions/barcode/ext/barcode/platform/android/Rakefile +0 -35
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Barcode.xcodeproj/project.pbxproj +8 -2
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeCallbackHelper.mm +195 -195
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeViewController.m +6 -0
- data/lib/extensions/barcode/ext/barcode/platform/iphone/Rakefile +5 -0
- data/lib/extensions/barcode/ext/barcode/shared/ruby/barcode_wrap.c +64 -20
- data/lib/extensions/debugger/CHANGELOG +3 -0
- data/lib/extensions/debugger/debugger.rb +26 -21
- data/lib/extensions/digest-md5/ext/Rakefile +5 -5
- data/lib/extensions/digest-md5/ext/build +10 -1
- data/lib/extensions/digest-md5/ext/defs.h +19 -0
- data/lib/extensions/digest-md5/ext/digest-md5.vcproj +317 -9
- data/lib/extensions/digest-md5/ext/iphone/Dmd5.xcodeproj/project.pbxproj +290 -0
- data/lib/extensions/digest-md5/ext/iphone/Dmd5_Prefix.pch +7 -0
- data/lib/extensions/digest-md5/ext/iphone/Rakefile +79 -0
- data/lib/extensions/digest-sha1/ext/Rakefile +5 -5
- data/lib/extensions/digest-sha1/ext/build +10 -1
- data/lib/extensions/digest-sha1/ext/defs.h +19 -0
- data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +317 -9
- data/lib/extensions/digest-sha1/ext/iphone/Dsha1.xcodeproj/project.pbxproj +278 -0
- data/lib/extensions/digest-sha1/ext/iphone/Dsha1_Prefix.pch +7 -0
- data/lib/extensions/digest-sha1/ext/iphone/Rakefile +79 -0
- data/lib/extensions/digest/ext/Rakefile +5 -5
- data/lib/extensions/digest/ext/build +10 -1
- data/lib/extensions/digest/ext/digest.vcproj +317 -9
- data/lib/extensions/digest/ext/iphone/Digest.xcodeproj/project.pbxproj +270 -0
- data/lib/extensions/digest/ext/iphone/Digest_Prefix.pch +7 -0
- data/lib/extensions/digest/ext/iphone/Rakefile +79 -0
- data/lib/extensions/esri/ext/esri/platform/iphone/ESRI.xcodeproj/project.pbxproj +10 -2
- data/lib/extensions/esri/ext/esri/platform/iphone/Rakefile +6 -0
- data/lib/extensions/fcntl/ext/Rakefile +5 -5
- data/lib/extensions/fcntl/ext/build +9 -1
- data/lib/extensions/fcntl/ext/iphone/Fcntl.xcodeproj/project.pbxproj +262 -0
- data/lib/extensions/fcntl/ext/iphone/Fcntl_Prefix.pch +7 -0
- data/lib/extensions/fcntl/ext/iphone/Rakefile +79 -0
- data/lib/extensions/net-http/net/http.rb +9 -7
- data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +64 -20
- data/lib/extensions/rhoxml/rexml/document.rb +3 -2
- data/lib/extensions/rhoxml/rexml/instruction.rb +70 -0
- data/lib/framework/builtinME.rb +9 -0
- data/lib/framework/date/format.rb +1 -1
- data/lib/framework/dateME.rb +19 -2
- data/lib/framework/rho/rho.rb +15 -4
- data/lib/framework/rho/rhoapplication.rb +1 -0
- data/lib/framework/rho/rhocontact.rb +10 -27
- data/lib/framework/rho/rhoevent_c.rb +8 -2
- data/lib/framework/rho/rhosupport.rb +25 -0
- data/lib/framework/rhodes.rb +1 -1
- data/lib/framework/rhoframework.rb +15 -0
- data/lib/framework/rholang/localization_simplified.rb +8 -10
- data/lib/framework/rhom/rhom_object_factory.rb +8 -2
- data/lib/framework/version.rb +1 -1
- data/lib/rhodes.rb +1 -1
- data/platform/android/Rhodes/jni/Application.mk +2 -1
- data/platform/android/Rhodes/jni/include/rhodes.h +9 -0
- data/platform/android/Rhodes/jni/src/callbacks.cpp +31 -1
- data/platform/android/Rhodes/jni/src/event.cpp +75 -31
- data/platform/android/Rhodes/jni/src/nativeview.cpp +1 -1
- data/platform/android/Rhodes/jni/src/phonebook.cpp +73 -9
- data/platform/android/Rhodes/jni/src/rhodes.cpp +21 -0
- data/platform/android/Rhodes/jni/src/rhodesapp.cpp +16 -24
- data/platform/android/Rhodes/jni/src/signature.cpp +27 -1
- data/platform/android/Rhodes/{default.properties → project.properties} +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +14 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +14 -12
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +38 -115
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +69 -52
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +9 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraNewService.java +21 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraOldService.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraSemiService.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraService.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +38 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/Event.java +212 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +82 -125
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +2 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +39 -19
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +106 -136
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +26 -25
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +1 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality.java +40 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality01.java +47 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality02.java +33 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality03.java +33 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality04.java +34 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality05.java +75 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality06.java +34 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality07.java +34 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality08.java +44 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality09.java +34 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality10.java +34 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionalityManager.java +73 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +57 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessor.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +322 -76
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +11 -6
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +5 -5
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +2 -1
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +125 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsOld.java +2 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/WebView.java +16 -0
- data/platform/android/build/RhodesSRC_build.files +14 -0
- data/platform/android/build/android.rake +149 -147
- data/platform/android/build/android_tools.rb +58 -0
- data/platform/android/build/librhocommon_build.files +1 -0
- data/platform/android/build/libruby_build.files +3 -0
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +11 -1
- data/platform/bb/RubyVM/src/com/rho/db/DBAdapter.java +11 -5
- data/platform/bb/RubyVM/src/com/rho/db/DBAttrManager.java +3 -2
- data/platform/bb/RubyVM/src/com/rho/file/RhoFile.java +2 -0
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +20 -8
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +9 -6
- data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +45 -18
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +1 -2
- data/platform/bb/build/bb.rake +84 -70
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +106 -14
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +1 -1
- data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +108 -16
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +10 -5
- data/platform/bb/rhodes/src/rhomobile/camera/CameraScreen.java +21 -4
- data/platform/bb/rhodes/src/rhomobile/mapview/Annotation.java +17 -0
- data/platform/bb/rhodes/src/rhomobile/mapview/MapView.java +8 -5
- data/platform/bb/rhodes/src/rhomobile/mapview/MapViewScreen.java +3 -1
- data/platform/iphone/Classes/AppManager/AppManager.m +15 -3
- data/platform/iphone/Classes/Event/Event.m +45 -2
- data/platform/iphone/Classes/MapView/MapViewController.m +8 -4
- data/platform/iphone/Classes/Phonebook/phonebook.m +30 -7
- data/platform/iphone/Classes/Rhodes.h +11 -1
- data/platform/iphone/Classes/Rhodes.m +141 -9
- data/platform/iphone/Classes/Signature/SignatureDelegate.m +27 -1
- data/platform/iphone/Classes/SimpleMainView.h +1 -0
- data/platform/iphone/Classes/SimpleMainView.m +4 -0
- data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +31 -1
- data/platform/iphone/curl/curl.xcodeproj/project.pbxproj +10 -0
- data/platform/iphone/rbuild/iphone.rake +33 -6
- data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +10 -2
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +22 -2
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +14 -0
- data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +10 -0
- data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Info.plist +1 -1
- data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/MacOS/RhoSimulator +0 -0
- data/platform/osx/build/osx.rake +58 -7
- data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +427 -69
- data/platform/shared/RhoConnectClient/RhoConnectClient.h +21 -2
- data/platform/shared/common/Android.mk +2 -1
- data/platform/shared/common/AutoPointer.h +23 -0
- data/platform/shared/common/BundleManager.cpp +333 -0
- data/platform/shared/common/RhoFile.cpp +206 -23
- data/platform/shared/common/RhoFile.h +14 -4
- data/platform/shared/common/RhoFilePath.h +18 -0
- data/platform/shared/common/RhoStd.h +11 -1
- data/platform/shared/common/RhoThread.h +4 -1
- data/platform/shared/common/RhodesApp.cpp +31 -8
- data/platform/shared/common/RhodesApp.h +14 -0
- data/platform/shared/common/RhodesAppBase.cpp +6 -6
- data/platform/shared/common/RhodesAppBase.h +1 -1
- data/platform/shared/common/emml.h +34 -0
- data/platform/shared/common/iphone/RhoFileImpl.m +30 -2
- data/platform/shared/common/map/BaseMapEngine.cpp +3 -3
- data/platform/shared/common/map/GeocodingMapEngine.cpp +205 -14
- data/platform/shared/common/map/GeocodingMapEngine.h +25 -2
- data/platform/shared/common/map/MapEngine.cpp +24 -2
- data/platform/shared/common/map/MapEngine.h +23 -12
- data/platform/shared/common/phonebook/PhonebookParams.cpp +99 -0
- data/platform/shared/common/phonebook/PhonebookParams.h +52 -0
- data/platform/shared/common/rhoparams.cpp +14 -0
- data/platform/shared/common/rhoparams.h +1 -0
- data/platform/shared/db/DBAdapter.cpp +43 -24
- data/platform/shared/db/DBAdapter.h +6 -1
- data/platform/shared/db/DBAttrManager.cpp +50 -1
- data/platform/shared/logging/RhoLog.h +3 -0
- data/platform/shared/logging/RhoLogSink.cpp +5 -1
- data/platform/shared/net/CURLNetRequest.cpp +2 -0
- data/platform/shared/qt/rhodes/QtMainWindow.cpp +14 -1
- data/platform/shared/qt/rhodes/impl/PhonebookImpl.cpp +2 -2
- data/platform/shared/qt/rhodes/impl/RhoFileImpl.cpp +1 -1
- data/platform/shared/qt/rhodes/impl/SignatureImpl.cpp +14 -2
- data/platform/shared/qt/rhodes/impl/SystemImpl.cpp +16 -2
- data/platform/shared/qt/rhodes/main.cpp +28 -0
- data/platform/shared/qt/rhodes/rhodes.pro +3 -0
- data/platform/shared/qt/rholib/rholib.pro +2 -1
- data/platform/shared/qt/rubylib/rubylib.pro +2 -1
- data/platform/shared/ruby/Android.mk +3 -0
- data/platform/shared/ruby/class.c +7 -0
- data/platform/shared/ruby/compile.c +18 -10
- data/platform/shared/ruby/encdb.h +18 -8
- data/platform/shared/ruby/eval.c +108 -2
- data/platform/shared/ruby/ext/alert/alert_wrap.c +64 -20
- data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +64 -20
- data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +67 -23
- data/platform/shared/ruby/ext/calendar/calendar_wrap.c +64 -20
- data/platform/shared/ruby/ext/calendar/event_wrap.c +64 -20
- data/platform/shared/ruby/ext/camera/camera_wrap.c +64 -20
- data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +64 -20
- data/platform/shared/ruby/ext/geolocation/geolocation.i +16 -0
- data/platform/shared/ruby/ext/geolocation/geolocation_wrap.c +127 -26
- data/platform/shared/ruby/ext/mapview/mapview_wrap.c +64 -20
- data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +65 -21
- data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +64 -20
- data/platform/shared/ruby/ext/navbar/navbar_wrap.c +64 -20
- data/platform/shared/ruby/ext/phonebook/phonebook.i +7 -7
- data/platform/shared/ruby/ext/phonebook/phonebook_wrap.c +95 -120
- data/platform/shared/ruby/ext/rho/rhoruby.c +4 -4
- data/platform/shared/ruby/ext/rho/rhoruby.h +2 -0
- data/platform/shared/ruby/ext/rho/rhosupport.c +39 -6
- data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +65 -21
- data/platform/shared/ruby/ext/ringtones/ringtones_wrap.c +64 -20
- data/platform/shared/ruby/ext/signature/signature.i +37 -5
- data/platform/shared/ruby/ext/signature/signature_wrap.c +274 -45
- data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +65 -21
- data/platform/shared/ruby/ext/system/system.i +14 -2
- data/platform/shared/ruby/ext/system/system_wrap.c +146 -25
- data/platform/shared/ruby/ext/webview/webview_wrap.c +65 -21
- data/platform/shared/ruby/include/ruby/ruby.h +15 -4
- data/platform/shared/ruby/inits.c +1 -0
- data/platform/shared/ruby/io.c +13 -3
- data/platform/shared/ruby/win32/win32.c +3 -3
- data/platform/shared/ruby/wince/io_wce.c +2 -2
- data/platform/shared/rubyext/System.cpp +9 -5
- data/platform/shared/sync/ClientRegister.cpp +18 -8
- data/platform/shared/sync/SyncEngine.cpp +25 -11
- data/platform/shared/sync/SyncEngine.h +2 -0
- data/platform/shared/sync/SyncSource.cpp +40 -15
- data/platform/shared/sync/SyncSource.h +3 -2
- data/platform/shared/sync/SyncThread.cpp +9 -4
- data/platform/shared/sync/SyncThread.h +3 -1
- data/platform/symbian/build/symbian.rake +14 -9
- data/platform/symbian/rhodes/rhodes.pro +11 -8
- data/platform/symbian/rhodes/src/phonebook/ruby_phonebook.cpp +2 -2
- data/platform/symbian/rubylib/rubylib.pro +3 -0
- data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
- data/platform/wm/RhoLib/RhoLib.vcproj +315 -2
- data/platform/wm/build/build_inf.js +235 -187
- data/platform/wm/build/wm.rake +388 -233
- data/platform/wm/rhodes.sln +56 -0
- data/platform/wm/rhodes/MainWindow.cpp +139 -77
- data/platform/wm/rhodes/MainWindow.h +27 -22
- data/platform/wm/rhodes/MapView/{Graphics.cpp → Bitmap.cpp} +15 -253
- data/platform/wm/rhodes/MapView/Bitmap.h +86 -0
- data/platform/wm/rhodes/MapView/MapViewManager.cpp +7 -2
- data/platform/wm/rhodes/MapView/MapViewManager.h +1 -1
- data/platform/wm/rhodes/MapView/Win32Graphics.cpp +263 -0
- data/platform/wm/rhodes/MapView/Win32Graphics.h +133 -0
- data/platform/wm/rhodes/MapView/WmGraphics.cpp +291 -0
- data/platform/wm/rhodes/MapView/{Graphics.h → WmGraphics.h} +14 -56
- data/platform/wm/rhodes/Rhodes.cpp +128 -32
- data/platform/wm/rhodes/Rhodes.rc +6 -2
- data/platform/wm/rhodes/camera/Camera.cpp +1 -0
- data/platform/wm/rhodes/phonebook/phonebook.cpp +2 -2
- data/platform/wm/rhodes/phonebook/phonebook.h +2 -2
- data/platform/wm/rhodes/resource.h +3 -2
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +6 -0
- data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +4 -0
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.cpp +675 -0
- data/platform/wm/rhodes/rho/rubyext/RhoSignature.h +123 -0
- data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +12 -2
- data/platform/wm/rhodes/rhodes.vcproj +2732 -1113
- data/platform/wm/rhodes/simulator/MainWindowQt.h +1 -1
- data/platform/wm/rhodes/stdafx.h +1 -0
- data/platform/wm/rhoelements.sln +118 -62
- data/platform/wm/rubylib/rubylib.vcproj +345 -16
- data/platform/wm/sqlite3/sqlite3.vcproj +305 -0
- data/platform/wm/syncengine/syncengine.vcproj +309 -0
- data/platform/wm/tools/detool/LogServer.cpp +19 -2
- data/platform/wm/tools/detool/detool.cpp +131 -6
- data/platform/wm/tools/detool/detool.vcproj +3 -1
- data/platform/wm/tools/detool/stdafx.h +1 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Libraries/Builtins/RangeOps.cs +589 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Builtins/RubyEncoding.cs +678 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyExceptionData.cs +271 -0
- data/platform/wp7/IronRuby/Languages/Ruby/Ruby/Runtime/RubyUtils.cs +31 -1
- data/platform/wp7/IronRuby/bin/Silverlight3Release/IronRuby.Libraries.dll +0 -0
- data/platform/wp7/IronRuby/bin/Silverlight3Release/IronRuby.dll +0 -0
- data/platform/wp7/RhoRubyLib/common/RhoStd.cs +6 -0
- data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +16 -2
- data/platform/wp7/RhoRubyLib/net/NetRequest.cs +2 -0
- data/platform/wp7/RhoRubyLib/rubyext/RhoSyncEngine.cs +1 -2
- data/platform/wp7/RhoRubyLib/sync/SyncEngine.cs +13 -10
- data/platform/wp7/RhoRubyLib/sync/SyncSource.cs +30 -8
- data/platform/wp7/build/wp.rake +5 -0
- data/rakefile.rb +153 -46
- data/res/build-tools/detool.exe +0 -0
- data/res/build-tools/swig_patch/Lib/ruby/rubyerrors.swg +155 -0
- data/res/build-tools/swig_patch/Lib/ruby/rubyhead.swg +158 -0
- data/res/build-tools/swig_patch/Lib/ruby/rubyiterators.swg +932 -0
- data/res/build-tools/swig_patch/Lib/ruby/rubyrun.swg +448 -0
- data/res/build-tools/swig_patch/Lib/ruby/rubystdfunctors.swg +162 -0
- data/res/build-tools/swig_patch/Lib/ruby/rubytracking.swg +159 -0
- data/res/build-tools/swig_patch/Lib/ruby/std_basic_string.i +97 -0
- data/res/build-tools/swig_patch/Lib/ruby/std_map.i +418 -0
- data/res/build-tools/swig_patch/Lib/ruby/std_multimap.i +227 -0
- data/res/build-tools/swig_patch/Lib/swiginit.swg +269 -0
- data/res/build-tools/swig_patch/README +7 -0
- data/res/generators/templates/application/app/Settings/controller.rb +42 -1
- data/res/generators/templates/application/app/Settings/wait.erb +1 -1
- data/res/generators/templates/application/app/application.rb +1 -1
- data/res/generators/templates/application/app/layout.erb +8 -8
- data/res/generators/templates/application/build.yml +0 -1
- data/res/generators/templates/application/public/css/android.css +6 -0
- data/res/generators/templates/application/public/css/blackberry.css +6 -0
- data/res/generators/templates/application/public/css/iphone.css +6 -0
- data/res/generators/templates/application/public/css/jqmobile-patch.css +14 -0
- data/res/generators/templates/application/public/jqmobile/images/ajax-loader.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-18-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-18-white.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-36-black.png +0 -0
- data/res/generators/templates/application/public/jqmobile/images/icons-36-white.png +0 -0
- data/res/generators/templates/application/public/jqmobile/{jquery.mobile-1.0rc1.css → jquery.mobile-1.0.css} +452 -354
- data/res/generators/templates/application/public/jqmobile/{jquery.mobile-1.0rc1.js → jquery.mobile-1.0.js} +629 -442
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.min.css +2 -0
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0.min.js +172 -0
- data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.0.css +714 -0
- data/res/generators/templates/application/public/jqmobile/jquery.mobile.structure-1.0.min.css +2 -0
- data/res/generators/templates/application/public/js/jqmobile-patch.js +136 -7
- data/res/generators/templates/extension/app/MontanaTest/controller.rb +20 -20
- data/res/generators/templates/extension/app/MontanaTest/index.erb +17 -17
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/iphone/Montana.xcodeproj/project.pbxproj +8 -2
- data/res/generators/templates/extension/extensions/montana/ext/montana/platform/iphone/Rakefile +5 -0
- data/res/generators/templates/extension/extensions/montana/ext/montana/shared/ruby/montana_wrap.c +64 -20
- data/rhomobile-debug.gemspec +1 -1
- data/spec/framework_spec/app/layout.erb +1 -1
- data/spec/framework_spec/app/spec/core/rational/Rational_spec.rb +1 -1
- data/spec/framework_spec/app/spec/library/stringio/shared/each_char.rb +6 -2
- data/spec/framework_spec/app/spec/shared/rational/{Rational.rb → rational_main.rb} +0 -0
- data/spec/framework_spec/build.yml +0 -3
- data/spec/perfomance_spec/app/Benchmark/controller.rb +1 -1
- data/spec/perfomance_spec/app/layout.erb +1 -1
- data/spec/phone_spec/app/BlobTest_s/blob_test_s.rb +13 -0
- data/spec/phone_spec/app/BlobTest_s/test.png +0 -0
- data/spec/phone_spec/app/BlobTest_s/test2.png +0 -0
- data/spec/phone_spec/app/spec/blobsync_spec.rb +27 -15
- data/spec/phone_spec/app/spec/date_spec.rb +27 -1
- data/spec/phone_spec/app/spec/rho_spec.rb +6 -0
- data/spec/phone_spec/app/spec/rhom_object_spec.rb +64 -26
- data/spec/phone_spec/app/spec/syncengine_spec.rb +28 -7
- data/spec/phone_spec/app/spec/uri_spec.rb +4 -4
- data/spec/phone_spec/app/spec_runner.rb +4 -2
- data/spec/phone_spec/build.yml +7 -9
- data/spec/phone_spec/rhoconfig.txt +1 -0
- data/version +1 -1
- metadata +75 -22
- data/Manifest.txt +0 -7853
- data/platform/wm/rhodes/rhoelements/RhoWKBrowserEngine.cpp +0 -384
- data/platform/wm/rhodes/rhoelements/RhoWKBrowserEngine.h +0 -41
- data/platform/wm/rhodes/signature/Signature.cpp +0 -396
- data/platform/wm/rhodes/signature/Signature.h +0 -84
- data/platform/wm/rubylib/rubylib.vcproj.VLAD.Vladimir.user +0 -429
- data/platform/wm/sqlite3/sqlite3.vcproj.VLAD.Vladimir.user +0 -429
- data/platform/wm/syncengine/syncengine.vcproj.VLAD.Vladimir.user +0 -429
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0rc1.min.css +0 -12
- data/res/generators/templates/application/public/jqmobile/jquery.mobile-1.0rc1.min.js +0 -170
- data/rhomobile-debug-1.0.5.gem +0 -0
data/doc/configuration.txt
CHANGED
@@ -33,9 +33,12 @@ List of supported capabilities:
|
|
33
33
|
|
34
34
|
### RhoGallery Security Token
|
35
35
|
|
36
|
-
To restrict access to the application it could be built with a security token. Specify security token in the build.yml and build application. Application built with security token can be started only if you provide this token as a parameter.
|
36
|
+
To restrict access to the application it could be built with a security token. Specify security token in the build.yml and build application. Application built with security token can be started in normal mode only if you provide this token as a parameter.
|
37
|
+
If you do not specify correct security token in start params, application will close on start by default. If you want do something instead of exit (for example show special message or run application in limited mode etc.) you can define another start_path for your application in "rhoconfig.txt":
|
37
38
|
|
38
|
-
|
39
|
+
invalid_security_token_start_path = '/app/InvalidSecurityTokenStartPage'
|
40
|
+
|
41
|
+
Specify security token in build.yml:
|
39
42
|
|
40
43
|
security_token: 123
|
41
44
|
|
data/doc/device-caps.txt
CHANGED
@@ -56,6 +56,8 @@ Properties:
|
|
56
56
|
* ppi_y - vertical PPI (Pixels Per Inch)
|
57
57
|
* has_network - is device connected to the network
|
58
58
|
* phone_number - device phone number
|
59
|
+
* device_owner_email - primary email of phone owner (works only on Android)
|
60
|
+
* device_owner_device_owner_name - name(account name) of phone owner (works only on Android)
|
59
61
|
* device_id - returns device ID which may be used to receive push messages. This is not phone device id, this is PUSH device id - you should register you phone for PUSH before get this parameter. Read [Push Notification documentation](device-caps#push-notifications) about it. On iPhone it may be empty right after application started while Rhodes registers to receive PUSH notifications; you should wait till it become non-empty.
|
60
62
|
* phone_id - returns hardware based id. It depends on capabilities configured for an application and has to remain same even across application uninstall/install.
|
61
63
|
* full_browser - is full browser in the WebView control on Blackberry (see [here](#blackberry-browser-support) for more details)
|
@@ -198,7 +200,31 @@ Get the distance between two points in miles
|
|
198
200
|
:::ruby
|
199
201
|
GeoLocation.haversine_distance(
|
200
202
|
latitude1, longitude1, latitude2, longitude2)
|
203
|
+
|
204
|
+
Get coordinates for adress string :
|
205
|
+
|
206
|
+
:::ruby
|
207
|
+
GeoLocation.do_geocoding({:adress => adress_string}, url_for(:action => :on_geocoding_callback))
|
208
|
+
|
209
|
+
In callback :
|
210
|
+
* status - "ok" or "error"
|
211
|
+
* latitude - latitude
|
212
|
+
* longitude - longitude
|
213
|
+
* description - description of issue when status == "error"
|
214
|
+
|
215
|
+
Get nearest adress for coordinates :
|
216
|
+
|
217
|
+
:::ruby
|
218
|
+
GeoLocation.do_geocoding({:latitude => latitude, :longitude => longitude}, url_for(:action => :on_geocoding_callback))
|
201
219
|
|
220
|
+
In callback :
|
221
|
+
* status - "ok" or "error"
|
222
|
+
* adress - nearest adress string
|
223
|
+
* latitude - latitude of founded adress
|
224
|
+
* longitude - longitude of founded adress
|
225
|
+
* description - description of issue when status == "error"
|
226
|
+
|
227
|
+
|
202
228
|
#### Testing GeoLocation
|
203
229
|
|
204
230
|
While developing your application on Windows Mobile emulator, you may find [FakeGPS](http://msdn.microsoft.com/en-us/library/bb158722.aspx) utility useful.
|
@@ -242,7 +268,7 @@ Callback points to the `geo_callback` in the Settings controller.rb:
|
|
242
268
|
if !GeoLocation.known_position?
|
243
269
|
# wait till GPS receiver acquire position
|
244
270
|
GeoLocation.set_notification( url_for(:action => :geo_callback), "")
|
245
|
-
redirect wait
|
271
|
+
redirect url_for :action => :wait
|
246
272
|
else
|
247
273
|
# show position
|
248
274
|
render
|
@@ -277,10 +303,34 @@ To allow read/modify personal information and contacts enable the pim capability
|
|
277
303
|
|
278
304
|
The following methods are available in the RhoContact class:
|
279
305
|
|
280
|
-
Return hash of hashes of
|
306
|
+
Return hash of hashes of contacts stored in the phonebook (index):
|
281
307
|
:::ruby
|
282
308
|
Rho::RhoContact.find(:all)
|
283
309
|
|
310
|
+
On some platforms an extended Rho::RhoContact.find routine is implemented
|
311
|
+
:::ruby
|
312
|
+
Rho::RhoContact.find(:all, params)
|
313
|
+
Rho::RhoContact.find(:first, params)
|
314
|
+
Rho::RhoContact.find(:count, params)
|
315
|
+
|
316
|
+
Currently the extended functionality is available at Android and iOS
|
317
|
+
|
318
|
+
* :all - get all contacts as usual
|
319
|
+
* :first - find first contact from list
|
320
|
+
* :count - returns count of contacts
|
321
|
+
|
322
|
+
For these selectors an additional params hash may be used. The next keys and values are recognized in additional params:
|
323
|
+
|
324
|
+
* :per_page - max count if contacts returned by find
|
325
|
+
* :offset - offset from begin of contacts' list
|
326
|
+
These two parameters are used to paginate contacts list. If used with :count exact number of returned contacts can be determined (for example for last page).
|
327
|
+
|
328
|
+
The next parameters are available at Android only:
|
329
|
+
* :select - list of contact properties have to be selected from phonebook (Use it to enchance query performance)
|
330
|
+
* :conditions - hash of conditions to query contacts. Look for more details below.
|
331
|
+
|
332
|
+
**NOTE: It is allowed to pass additional params hash at all platforms. Platforms that has no extended functionality will just skip these**
|
333
|
+
|
284
334
|
Return hash of all properties of the contact identified by the provided id (show):
|
285
335
|
:::ruby
|
286
336
|
Rho::RhoContact.find(@params['id'])
|
@@ -330,24 +380,13 @@ Home pages:
|
|
330
380
|
|
331
381
|
### Android
|
332
382
|
|
333
|
-
|
334
|
-
In addition to common usage described above it is allowed to pass additional parameter values:
|
383
|
+
**NOTE: In most cases the result of RhoContact::find query may return more contact properties then defined in :select**
|
335
384
|
|
336
|
-
|
337
|
-
* :first - find first contact from list
|
338
|
-
* :count - returns count of contacts
|
339
|
-
|
340
|
-
For these selectors an additional params hash may be used. The next keys and values are recognized in additional params:
|
341
|
-
|
342
|
-
* :per_page - max count if contacts returned by find
|
343
|
-
* :offset - offset from begin of contacts' list
|
344
|
-
These two parameters are used to paginate contacts list. If used with :count exact number of returned contacts can be determined (for example for last page).
|
345
|
-
* :select - list of contact properties have to be selected from phonebook (Use it to enchance query performance)
|
346
|
-
|
347
|
-
On Android the nexts contact properties are supported (every of them may be used in :select list):
|
385
|
+
On Android the next contact properties are supported (every of them may be used in :select list):
|
348
386
|
|
349
387
|
General:
|
350
388
|
"id", "display_name", "first_name", "last_name"
|
389
|
+
The "display_name" is always filled by Android even if "first_name" and "last_name" are both empty. In this case email or phone number may be used.
|
351
390
|
|
352
391
|
Phone numbers:
|
353
392
|
"mobile_number", "home_number", "business_number"
|
@@ -358,7 +397,38 @@ E-mails:
|
|
358
397
|
Company:
|
359
398
|
"company_name"
|
360
399
|
|
361
|
-
|
400
|
+
#### Conditions
|
401
|
+
|
402
|
+
:conditions parameter is a hash of conditions. Keys of the hash are contact property selectors (condition to be applied to) and values are conditions itself.
|
403
|
+
The next property selectors are defined:
|
404
|
+
- :phone
|
405
|
+
- :email
|
406
|
+
A property selector has no one-to-one relation to a single contact property like mobile_phone or email_address. Selectors are mapped to whole property group like all phones or all emails (support for several emails may be implemented in future).
|
407
|
+
Condition like
|
408
|
+
:::ruby
|
409
|
+
{:phone => 'not_nil'}
|
410
|
+
will select all contacts which has at least one phone.
|
411
|
+
The next conditions are currently suported:
|
412
|
+
- 'not_nil'
|
413
|
+
- 'is_nil'
|
414
|
+
|
415
|
+
**NOTE: It may be useful to sort received contacts (espessially if paginated). Contacts is ordered by 'display_name' column and then splitted for pages. Unfortunately the order inside page is lost while passing the list to ruby**
|
416
|
+
|
417
|
+
:::ruby
|
418
|
+
@count = Rho::RhoContact.find(:count, :conditions => {:phone => 'not_nil'})
|
419
|
+
if @params['offset']
|
420
|
+
@offset = @params['offset'].to_i
|
421
|
+
else
|
422
|
+
@offset = 0;
|
423
|
+
end
|
424
|
+
@contacts = Rho::RhoContact.find(:all, :per_page => 10, :offset => @offset, :select => ["id", "display_name", "mobile_number"], :conditions => {:phone => 'not_nil'})
|
425
|
+
@contacts = {} unless @contacts
|
426
|
+
@contacts = @contacts.sort do |x,y|
|
427
|
+
res = 1 if x[1]['display_name'].nil?
|
428
|
+
res = -1 if y[1]['display_name'].nil?
|
429
|
+
res = x[1]['display_name'] <=> y[1]['display_name'] unless res
|
430
|
+
res
|
431
|
+
end
|
362
432
|
|
363
433
|
### Sample
|
364
434
|
For examples on how to use the API provided by this class, see the view and controller in the /app/Contacts folder in the [System API Samples application](http://github.com/rhomobile/rhodes-system-api-samples/tree/master/app/Contacts/controller.rb).
|
@@ -422,7 +492,38 @@ On iPhone and Android additional event properties are supported. These are:
|
|
422
492
|
"canceled", "organizer", "attendees", "last_modified",
|
423
493
|
|
424
494
|
Recurrence properties:
|
425
|
-
"recurrence", "frequency"('daily', 'weekly', 'monthly', 'yearly'), "interval"
|
495
|
+
"recurrence", "frequency"('daily', 'weekly', 'monthly', 'yearly'), "interval", "count", "end_date"
|
496
|
+
"count" and "end" rucurrence properties are mutual exclusive. "end" is date/time beyond last event occurence but within same day.
|
497
|
+
|
498
|
+
### Recurrence properties
|
499
|
+
Recurrence properties are groupped in separate hash stored as single event property (event[Rho::RhoEvent::RECURRENCE]).
|
500
|
+
|
501
|
+
### Names of properties
|
502
|
+
There are helper constants defined in Rho::RhoEvent which can be used to address event values and as predefined set of values (for frequency):
|
503
|
+
* ID
|
504
|
+
* TITLE
|
505
|
+
* CANCELED
|
506
|
+
* ORGANIZER
|
507
|
+
* START_DATE
|
508
|
+
* END_DATE
|
509
|
+
* LAST_MODIFIED
|
510
|
+
* LOCATION
|
511
|
+
* NOTES
|
512
|
+
* PRIVACY
|
513
|
+
* REMINDER
|
514
|
+
* RECURRENCE
|
515
|
+
* RECURRENCE_FREQUENCY
|
516
|
+
* RECURRENCE_FREQUENCY_DAILY
|
517
|
+
* RECURRENCE_FREQUENCY_WEEKLY
|
518
|
+
* RECURRENCE_FREQUENCY_MONTHLY
|
519
|
+
* RECURRENCE_FREQUENCY_YEARLY
|
520
|
+
* RECURRENCE_INTERVAL
|
521
|
+
* RECURRENCE_COUNT
|
522
|
+
* RECURRENCE_END
|
523
|
+
* RECURRENCE_DAYOFMONTH
|
524
|
+
* RECURRENCE_MONTHS
|
525
|
+
* RECURRENCE_DAYS
|
526
|
+
|
426
527
|
|
427
528
|
### Sample
|
428
529
|
For examples on how to use the API provided by this class, see the view and controller in the /app/Calendar folder in the [System API Samples application](http://github.com/rhomobile/rhodes-system-api-samples/tree/master/app/Calendar/controller.rb).
|
@@ -510,9 +611,14 @@ For barcode recognition we use Zbar library (iPhone, and Windows Mobile platform
|
|
510
611
|
|
511
612
|
**NOTE: We are very sorry, but we are removed ZBar source code from our project by ZBar license requirements. For build Barcode extension for WM, you should download ZBar sources from http://zbar.sourceforge.net/ and copy to [rhodes root]/lib/extensions/barcode/ext/barcode/shared/zbar/zbar/ folder "include" and "zbar" folders from ZBar sources. Also you should fix ZBar sources for building by Microsoft Visual Studio (move define of inner function variables to begin of functions, etc.). See detailed instructon in [Rhodes root]/lib/extensions/barcode/ext/barcode/shared/zbar/zbar/README.TXT
|
512
613
|
|
513
|
-
On Android now supported real-time barcode recognizing:
|
614
|
+
On Android and iOS (not supported on iPhone 2G and iPhone 3G !) now supported real-time barcode recognizing (second parameter is hash with options):
|
615
|
+
:::ruby
|
616
|
+
Barcode.take_barcode(url_for(:action => :take_callback), {})
|
617
|
+
|
618
|
+
On Android also you can use front camera for take_barcode :
|
514
619
|
:::ruby
|
515
|
-
Barcode.take_barcode(url_for
|
620
|
+
Barcode.take_barcode(url_for(:action => :take_callback), {:camera => 'front'})
|
621
|
+
|
516
622
|
This code open special UI for real-time barcode recognizing from camera. If any barcode found recognizing stopped and user can select - confirm recognizing barcode or continue recognizig. If user confirmed or cancelled the callback will be called.
|
517
623
|
In callback:
|
518
624
|
* "status" - "ok" or "cancel"
|
@@ -1182,7 +1288,7 @@ NOTE: in order to use it on Android, you need to install Google Add-on API and r
|
|
1182
1288
|
{:street_address => "Cupertino, CA 95014", :title => "Cupertino", :subtitle => "zip: 95014",
|
1183
1289
|
:url => "/app/GeoLocation/show?city=Cupertino"},
|
1184
1290
|
{:street_address => "Santa Clara, CA 95051", :title => "Santa Clara", :subtitle => "zip: 95051",
|
1185
|
-
:url => "/app/GeoLocation/show?city=Santa%20Clara"}]
|
1291
|
+
:url => "/app/GeoLocation/show?city=Santa%20Clara", :pass_location => true}]
|
1186
1292
|
}
|
1187
1293
|
MapView.create map_params
|
1188
1294
|
|
@@ -1227,6 +1333,7 @@ Annotations - array of map annotation objects (list of pins on the map). Annotat
|
|
1227
1333
|
* image - image file name
|
1228
1334
|
* image_x_offset - int horizontal coordinate of image anchor (ancor point placed to annotation point on map) . Set to image width/2 for center
|
1229
1335
|
* image_y_offset - int vertical coordinate of image anchor (ancor point placed to annotation point on map). Set image height/2 for center
|
1336
|
+
* pass_location - then true, location coordinates added to url in the format: latitude=xx.xxx&longitude=xx.xxx
|
1230
1337
|
|
1231
1338
|
Enable file caching for map tiles - file cache can use for offline map browsing:
|
1232
1339
|
:::ruby
|
@@ -1296,7 +1403,7 @@ See GeoLocation/controller.rb of [system API sample application](http://github.c
|
|
1296
1403
|
### Platform notes
|
1297
1404
|
|
1298
1405
|
#### Blackberry
|
1299
|
-
Only read from files are supported
|
1406
|
+
Only read from files are supported.
|
1300
1407
|
|
1301
1408
|
Simulator files folder (4.6 and bigger) - `<sdk root>/components/simulator/sdcard/rho/<appname>`
|
1302
1409
|
|
@@ -1481,7 +1588,11 @@ Blackberry 5.0 and above has new BrowserField class, which support javascript, a
|
|
1481
1588
|
|
1482
1589
|
WebView.execute_js is also supported in this mode.
|
1483
1590
|
|
1484
|
-
NOTE: on Blackberry
|
1591
|
+
NOTE: on Blackberry 6.0 and above it is recommended to use full browser mode. Because overwise some UI elements like combobox is not selectable by trackball:
|
1592
|
+
|
1593
|
+
# use full browser only on BB 6.0 and above
|
1594
|
+
use_bb_full_browser=6
|
1595
|
+
|
1485
1596
|
|
1486
1597
|
### Blackberry full browser
|
1487
1598
|
|
data/doc/extensions.txt
CHANGED
@@ -329,58 +329,528 @@ NOTE: Once again, it should be mentioned that not all libraries are guaranteed t
|
|
329
329
|
|
330
330
|
## Native Extensions
|
331
331
|
|
332
|
-
Starting from 2.0, Rhodes
|
332
|
+
Starting from 2.0, Rhodes supports native extensions for Android, iPhone, WM and BlackBerry platforms. Native extensions are extensions written in the native language for the platform (C/C++/ObjC for iPhone, C/C++/Java for Android, C/C++ for WM, Java for Blackberry).
|
333
333
|
|
334
|
-
|
334
|
+
## Generating a Native Extension Template
|
335
335
|
|
336
|
-
|
336
|
+
The rhogen extension command allows you to create a native extension template for your Rhodes application. This template contains build scripts, projects, and native source code for the functions calc_summ and native_process_string, which you can use as templates to create your own native extension functions.
|
337
337
|
|
338
|
-
|
339
|
-
libraries: ["ext-name"]
|
338
|
+
Before you use the rhogen extension command, you must have or you must create a Rhodes application from which you will call the native extension. You can [generate a Rhodes application](generator) from the command line or from RhoStudio.
|
340
339
|
|
341
|
-
|
340
|
+
Then, on the command line, navigate to the main folder in your Rhodes application. Run the following command:
|
342
341
|
|
343
|
-
|
342
|
+
:::term
|
343
|
+
rhogen extension yourextension
|
344
|
+
|
345
|
+
where `yourextension` is the name you want to use for your native extension.
|
346
|
+
|
347
|
+
This command will create two folders in your application folder:
|
348
|
+
* `yourextensionTest`, which contains a test controller and page for the generated native extension.
|
349
|
+
* `extensions`, which contains the generated native extension source code for the iPhone, Android, Windows Mobile, and Blackberry platforms.
|
350
|
+
|
351
|
+
### Understanding the Generated Native Extension Test Implementation
|
352
|
+
|
353
|
+
In your applications `app` folder is a folder named `yourextensionTest`. It contains two files that have a test implementation of the generated native extension example functions:
|
354
|
+
|
355
|
+
* controller.rb - An example of application controller code with execution of the generated extension code.
|
356
|
+
* index.erb - A page that executes the application controller.
|
357
|
+
|
358
|
+
The controller.rb is a simple Ruby controller file that calls the generated native extension functions of calc_summ and process_string. It has a function, run_test, that calls the calc_summ native function to calculate a sum, then uses an Alert popup to show the sum via the process_string native function.
|
359
|
+
|
360
|
+
:::ruby
|
361
|
+
require 'rho/rhocontroller'
|
362
|
+
require 'yourextension'
|
363
|
+
|
364
|
+
class YourextensionTestController < Rho::RhoController
|
365
|
+
@layout = :simplelayout
|
366
|
+
|
367
|
+
def index
|
368
|
+
render :back => '/app'
|
369
|
+
end
|
370
|
+
|
371
|
+
def run_test
|
372
|
+
sum = Yourextension.calc_summ(3,7)
|
373
|
+
Alert.show_popup YourextensionModule::YourextensionStringHelper::process_string('test')+sum.to_s
|
374
|
+
render :action => :index, :back => '/app'
|
375
|
+
end
|
376
|
+
|
377
|
+
end
|
378
|
+
|
379
|
+
The index.erb provides a page where you can click a link to run the run_test function.
|
380
|
+
|
381
|
+
:::html
|
382
|
+
<h3>Yourextension Extension Test</h3>
|
383
|
+
<div>
|
384
|
+
<%= link_to '[Run Yourextension test]', { :action => :run_test }%><br/>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
## Understanding the Generated Native Extension Code
|
388
|
+
|
389
|
+
The extensions folder has the following contents.
|
390
|
+
|
391
|
+
:::term
|
392
|
+
yourextension - A folder named for your extension.
|
393
|
+
|
394
|
+
ext.yml - The native extension configuration file. It contains the library name, java entry point (class name for BB), C entry point, etc.
|
395
|
+
|
396
|
+
yourextension.rb - The extension Ruby code. This file contains Ruby classes that you wish to execute from your native code; it has the generated Ruby class YourextensionStringHelper.
|
397
|
+
|
398
|
+
All files named in this folder will be added to build extent "ext" folder and file.
|
399
|
+
|
400
|
+
ext - The folder with the extension sources for the native build.
|
401
|
+
|
402
|
+
build - A unix based build script (for Mac OS).
|
403
|
+
|
404
|
+
build.bat - A Windows based build script (for MS Windows).
|
405
|
+
|
406
|
+
<yourextension> - The folder containing the shared and platform folders.
|
407
|
+
|
408
|
+
shared - The folder with the shared code (this is used by all platforms except Blackberry). Contains the interface for the native extension.
|
409
|
+
|
410
|
+
platform - The folder with the platform dependent code, This contains the native extension code for your platform, which you will rewrite for your native extension.
|
411
|
+
|
412
|
+
To create your native extension, you will rewrite code within:
|
413
|
+
* the `shared` folder, which contains the interface for your native extension.
|
414
|
+
* the `platform` folder, which contains the source code for your native extension.
|
415
|
+
|
416
|
+
## Rewriting the Generated Native Extension Interface Code
|
344
417
|
|
345
|
-
|
418
|
+
The `shared` folder, within `extensions/yourextension/ext/yourextension`, contains the interface code for your native extension that is used by all platforms except for Blackberry. It contains the following folders and files.
|
346
419
|
|
347
|
-
|
420
|
+
:::term
|
421
|
+
ruby - The folder with the native-Ruby code wrapper. We use SWIG to generate the C wrapper code from the Ruby interface file.
|
422
|
+
|
423
|
+
yourextension.i - The Ruby interface declaration for native code
|
424
|
+
|
425
|
+
<yourextension_wrap.c - wrapper code for *.i file generated by SWIG
|
426
|
+
|
427
|
+
src - folder with native shared native code
|
348
428
|
|
349
|
-
|
350
|
-
* RHO_PLATFORM - mobile platform current build for. Possible values are 'iphone', 'android' and 'wm'
|
351
|
-
* RHO_ROOT - point to the rhodes installation root folder (directory where rhobuild.yml located)
|
352
|
-
* TEMP_FILES_DIR - you can use it for temporary files
|
429
|
+
yourextension.c - C file with main extension initialization function (native entry point) - also execute Ruby wrapper initialization code.
|
353
430
|
|
354
|
-
|
431
|
+
You need to:
|
432
|
+
|
433
|
+
* Rewrite the Interface file, yourextension.i, by changing the generated native extension function names to your native extension function names.
|
355
434
|
|
356
|
-
*
|
357
|
-
|
435
|
+
* Regenerate the wrapper file, yourextension_wrap.c, by running the SWIG command on the rewritten Interface file: `swig -ruby yourextension.i`.
|
436
|
+
|
437
|
+
Here is the yourextension.i file that is generated by the rhogen extension command. You would replace the calc_summ and native_string_process interfaces with interfaces for your native extension functions.
|
438
|
+
|
439
|
+
:::ruby
|
440
|
+
/* yourextension.i */
|
441
|
+
%module Yourextension
|
442
|
+
%{
|
443
|
+
#include "ruby/ext/rho/rhoruby.h"
|
444
|
+
|
445
|
+
extern VALUE yourextension_native_process_string(const char* str);
|
446
|
+
extern int yourextension_calc_summ(int x, int y);
|
447
|
+
|
448
|
+
#define native_process_string yourextension_native_process_string
|
449
|
+
#define calc_summ yourextension_calc_summ
|
450
|
+
|
451
|
+
%}
|
452
|
+
|
453
|
+
extern VALUE native_process_string(const char* str);
|
454
|
+
extern int calc_summ(int x, int y);
|
455
|
+
|
456
|
+
Suppose you generated code for a native extension that you named Accelerometer. You would have a file named Accelerometer.i that contains the references to the process_string and calc_summ functions that are generated by rhogen; you would replace these references with the references to your native extension code for Accelerometer. You would start with this code:
|
457
|
+
|
458
|
+
:::ruby
|
459
|
+
/* accelerometer.i */
|
460
|
+
%module Accelerometer
|
461
|
+
%{
|
462
|
+
#include "ruby/ext/rho/rhoruby.h"
|
463
|
+
|
464
|
+
extern VALUE accelerometer_native_process_string(const char* str);
|
465
|
+
extern int accelerometer_calc_summ(int x, int y);
|
466
|
+
|
467
|
+
#define native_process_string accelerometer_native_process_string
|
468
|
+
#define calc_summ accelerometer_calc_summ
|
469
|
+
|
470
|
+
%}
|
471
|
+
|
472
|
+
extern VALUE native_process_string(const char* str);
|
473
|
+
extern int calc_summ(int x, int y);
|
474
|
+
|
475
|
+
In this Accelerometer example, the native extensions are a start function and a get_readings function. You would rewrite the accelerometer.i as follows, replacing the generated functions of calc_summ and native_process_string with your start and get_readings functions.
|
476
|
+
|
477
|
+
:::ruby
|
478
|
+
/* accelerometer.i */
|
479
|
+
%module Accelerometer
|
480
|
+
%{
|
481
|
+
#include "ruby/ext/rho/rhoruby.h"
|
482
|
+
|
483
|
+
extern void accelerometer_get_readings(double *x, double *y, double *z);
|
484
|
+
extern void accelerometer_start(void);
|
485
|
+
|
486
|
+
#define get_readings accelerometer_get_readings
|
487
|
+
#define start accelerometer_start
|
488
|
+
|
489
|
+
%}
|
490
|
+
|
491
|
+
extern void get_readings(double *OUTPUT, double *OUTPUT, double *OUTPUT);
|
492
|
+
extern void start(void);
|
493
|
+
|
494
|
+
## Rewriting the Generated Native Extension Source Code for iPhone
|
495
|
+
|
496
|
+
The iPhone generated native extension code is contained in the following structure.
|
497
|
+
|
498
|
+
:::term
|
499
|
+
iphone - folder with iPhone native extension code
|
500
|
+
|
501
|
+
Rakefile - The build script for the iPhone platform.
|
502
|
+
|
503
|
+
yourextension.xcodeproj - The Xcode project file of iPhone specific code.
|
504
|
+
|
505
|
+
Classes - a folder with the iPhone native extension source code.
|
506
|
+
yourextension.h - header file
|
507
|
+
yourextension.m - iPhone specific code (implementation of native function declared in Ruby wrapper).
|
508
|
+
|
509
|
+
To create native extensions for the iPhone platform:
|
510
|
+
|
511
|
+
* Rewrite the generated Objective C files in the Classes folder, yourextension.h and yourextension.M, to implement your native extension.
|
512
|
+
* Add any new Objective C files that you create to the Xcode project for this native extension.
|
513
|
+
|
514
|
+
### Rewriting the Native Extension Objective C Header File
|
515
|
+
|
516
|
+
If you generate an Accelerometer native extension, you get the following header file (accelerometer.h) for the iPhone.
|
517
|
+
|
518
|
+
:::cplusplus
|
519
|
+
#import <UIKit/UIKit.h>
|
520
|
+
#import <Foundation/Foundation.h>
|
521
|
+
|
522
|
+
You could rewrite this header file to look like this for an accelerometer.
|
523
|
+
|
524
|
+
:::cplusplus
|
525
|
+
#import <UIKit/UIKit.h>
|
526
|
+
|
527
|
+
@interface Accel : UIViewController<UIAccelerometerDelegate>
|
528
|
+
{
|
529
|
+
}
|
530
|
+
|
531
|
+
- (void)start;
|
532
|
+
|
533
|
+
@end
|
534
|
+
|
535
|
+
### Rewriting the Native Extension Objective C Manifest File
|
536
|
+
|
537
|
+
If you generate an Accelerometer native extension, you get the following manifest file (accelerometer.m) for the iPhone.
|
538
|
+
|
539
|
+
:::cplusplus
|
540
|
+
#import "Accelerometer.h"
|
541
|
+
|
542
|
+
#include "ruby/ext/rho/rhoruby.h"
|
543
|
+
|
544
|
+
VALUE accelerometer_native_process_string(const char* str) {
|
545
|
+
|
546
|
+
NSString* os_string = @"<iOS>";
|
547
|
+
|
548
|
+
NSString* result_string = [os_string stringByAppendingString:[NSString stringWithUTF8String:str]];
|
549
|
+
result_string = [result_string stringByAppendingString:os_string];
|
550
|
+
|
551
|
+
VALUE result = rho_ruby_create_string([result_string UTF8String]);
|
552
|
+
|
553
|
+
return result;
|
554
|
+
}
|
555
|
+
|
556
|
+
int accelerometer_calc_summ(int x, int y) {
|
557
|
+
return (x+y);
|
558
|
+
}
|
559
|
+
|
560
|
+
You can rewrite the accelerometer.m file as follows to access the iPhone accelerometer functionality. Replace the stub code for accelerometer_native_process_string and accelerometer_calc_summ with your code: in this case, with native functions start and get_readings.
|
561
|
+
|
562
|
+
:::cplusplus
|
563
|
+
#import "Accelerometer.h"
|
564
|
+
|
565
|
+
// store the acceleration values
|
566
|
+
double gx,gy,gz;
|
567
|
+
|
568
|
+
// Reference this Objective C class.
|
569
|
+
Accel *accel;
|
570
|
+
@implementation Accel
|
571
|
+
|
572
|
+
-(void)start
|
573
|
+
{
|
574
|
+
// Initialize the accelerometer variables.
|
575
|
+
gx = gy = gz = 0;
|
576
|
+
// Set the update interval.
|
577
|
+
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:0.025];
|
578
|
+
// Set the delegate to this class, so the iPhone accelerometer will
|
579
|
+
// call you back on the delegate method.
|
580
|
+
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
|
581
|
+
}
|
582
|
+
|
583
|
+
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
|
584
|
+
// Get the accelerometer values from the iPhone.
|
585
|
+
{
|
586
|
+
gx = acceleration.x;
|
587
|
+
gy = acceleration.y;
|
588
|
+
gz = acceleration.z;
|
589
|
+
}
|
590
|
+
|
591
|
+
@end
|
592
|
+
|
593
|
+
// This C function interfaces with the Objective C start function.
|
594
|
+
void accelerometer_start(void) {
|
595
|
+
// make sure we can only start this method once
|
596
|
+
static bool started = false;
|
597
|
+
if(!started) {
|
598
|
+
// Initialize the Objective C accelerometer class.
|
599
|
+
accel = [[Accel alloc] init];
|
600
|
+
// Start the accelerometer readings.
|
601
|
+
[accel start];
|
602
|
+
started = true;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
|
606
|
+
// This C function allows us to get the readings from the accelerometer so
|
607
|
+
// they can be returned to the Ruby code.
|
608
|
+
void accelerometer_get_readings(double *x, double *y, double *z) {
|
609
|
+
*x = gx;
|
610
|
+
*y = gy;
|
611
|
+
*z = gz;
|
612
|
+
}
|
613
|
+
|
614
|
+
### Adding New Files to the Xcode Project
|
615
|
+
|
616
|
+
If you create any new files for your native extension, you must add them to the Xcode project. In Xcode, open yourextension.xcodeproj. Then add the new files to this project.
|
617
|
+
|
618
|
+
## Rewriting the Generated Native Extension Source Code for Android
|
619
|
+
|
620
|
+
The Android generated native extension code is contained in the following structure.
|
621
|
+
|
622
|
+
:::term
|
623
|
+
android - folder with Android specific code
|
624
|
+
Rakefile - build script for Android platform
|
625
|
+
ext_build.files - list of java files should be compiled
|
626
|
+
jni - folder with Android native code
|
627
|
+
src
|
628
|
+
yourextension.cpp - native Android code with implementation of native function declared in Ruby wrapper
|
629
|
+
src - folder with Java Android code
|
630
|
+
com
|
631
|
+
yourextension
|
632
|
+
yourextension.java - Android java code
|
633
|
+
|
634
|
+
### Rewrite the Generated Android Native Extension Java File
|
635
|
+
|
636
|
+
The folder in extensions/yourextension/ext/yourextension/platform/android/src contains a generated Java file, yourextension.java. This file contains the native extension code for the process_string function. Rewrite this code to reference your native extension function.
|
637
|
+
|
638
|
+
:::java
|
639
|
+
package com.yourextension;
|
640
|
+
|
641
|
+
public class Yourextension {
|
642
|
+
|
643
|
+
public static String processString(String str) {
|
644
|
+
return "<Android>" + str + "<Android>";
|
645
|
+
}
|
646
|
+
}
|
647
|
+
|
648
|
+
### Rewrite the Generated Android C++ Native Extension
|
649
|
+
|
650
|
+
Rewrite the C++ file for your native extension. This is where you implement the C function that is declared in the Interface file. You would also implement any Android native C++ code here.
|
651
|
+
|
652
|
+
The generated C++ file for Android, yourextension.cpp (within the folder extensions/yourextension/ext/yourextension/platform/android/jni/src) contains the C interfaces for the native_process_string function and the calc_summ functions. Rewrite that code for the interfaces for your native extension functions: rename the functions to match yours, redo their argument lists, etc.
|
653
|
+
|
654
|
+
:::cplusplus
|
655
|
+
#include <rhodes.h>
|
656
|
+
#include "rubyext/WebView.h"
|
657
|
+
#include <stdlib.h>
|
658
|
+
#include "ruby/ext/rho/rhoruby.h"
|
659
|
+
|
660
|
+
extern "C" VALUE yourextension_native_process_string(const char* str) {
|
661
|
+
|
662
|
+
JNIEnv *env = jnienv();
|
663
|
+
jclass cls = rho_find_class(env, "com/yourextension/Yourextension");
|
664
|
+
if (!cls) return rho_ruby_get_NIL();;
|
665
|
+
jmethodID mid = env->GetStaticMethodID( cls, "processString", "(Ljava/lang/String;)Ljava/lang/String;");
|
666
|
+
if (!mid) return rho_ruby_get_NIL();;
|
667
|
+
jstring objStr = env->NewStringUTF(str);
|
668
|
+
jstring jstr = (jstring)env->CallStaticObjectMethod(cls, mid, objStr);
|
669
|
+
env->DeleteLocalRef(objStr);
|
670
|
+
const char* buf = env->GetStringUTFChars(jstr,0);
|
671
|
+
VALUE result = rho_ruby_create_string(buf);
|
672
|
+
env->ReleaseStringUTFChars(jstr, buf);
|
673
|
+
return result;
|
674
|
+
}
|
675
|
+
|
676
|
+
extern "C" int yourextension_calc_summ(int x, int y) {
|
677
|
+
return (x+y);
|
678
|
+
}
|
679
|
+
|
680
|
+
### Add New C++ Files to Rakefile
|
681
|
+
|
682
|
+
You can code new C++ files; place them in the extensions/yourextension/ext/yourextension/platform/android/jni/src/ folder (the same folder containing yourextension.cpp). If you add new C++ files, add their file names to the list of C++ files in the Rakefile, which is in the folder extensions/yourextension/ext/yourextension/platform/android.
|
683
|
+
|
684
|
+
In the Rakefile, there is a section coded as follows:
|
358
685
|
|
359
|
-
|
686
|
+
:::term
|
687
|
+
task :all => :config do
|
688
|
+
|
689
|
+
src_files = []
|
690
|
+
|
691
|
+
src_files << $yourextensiondir + '/ext/yourextension/platform/android/jni/src/yourextension.cpp'
|
692
|
+
src_files << $yourextensiondir + '/ext/yourextension/shared/ruby/yourextension_wrap.c'
|
693
|
+
src_files << $yourextensiondir + '/ext/yourextension/shared/src/yourextension.c'
|
694
|
+
|
695
|
+
# build native part
|
696
|
+
build_extension('Yourextension', $arch, src_files)
|
697
|
+
|
698
|
+
# java part will be built automatically (java files should be listed in ext_build.files and ext.yml should be configured)
|
699
|
+
|
700
|
+
end
|
701
|
+
|
702
|
+
Add a src_files line for every new .cpp file that you add to your native extension project, such as:
|
703
|
+
|
704
|
+
:::term
|
705
|
+
src_files << $yourextensiondir + '/ext/yourextension/platform/android/jni/src/yournewfile.cpp'
|
706
|
+
|
707
|
+
### Add New Java Files to ext_build.files
|
708
|
+
|
709
|
+
You can code new Java files for your native extension; if you do so, place them in the extensions/yourextension/ext/yourextension/platform/android/src folder (the same folder containing yourextension.java). Then add that file to the list of Java files in ext_build.files, which is in the folder extensions/yourextension/ext/yourextension/platform/android.
|
710
|
+
|
711
|
+
This sample listing of ext_build.files shows that it already lists the generated native extenstion Java file.
|
712
|
+
|
713
|
+
:::term
|
714
|
+
ext/yourextension/platform/android/src/com/yourextension/Yourextension.java
|
715
|
+
|
716
|
+
## Rewriting the Generated Native Extension Source Code for Windows Mobile
|
717
|
+
|
718
|
+
The Windows Mobile generated native extension code is contained in the following structure.
|
719
|
+
|
720
|
+
:::term
|
721
|
+
wm - folder with Windows Mobile specific code
|
722
|
+
Rakefile - build script for WM platform
|
723
|
+
<yourextension>.vcproj - Microsoft Visual Studio project file for the Windows Mobile native extension
|
724
|
+
src - folder with WM specific sources
|
725
|
+
<yourextension>_wm.h - header file
|
726
|
+
<yourextension>_wm.cpp - native code with implementation of native function declared in Ruby wrapper
|
727
|
+
|
728
|
+
### Rewrite the Generated Native Extension C++ Files
|
729
|
+
|
730
|
+
You will find the implementations of the Windows Mobile version of the native_process_string and the calc_summ functions in the files yourextension_wm.h and yourextension_wm.cpp, which are in the folder extensions/yourextension/ext/yourextension/platform/wm/src. Rewrite these files for your native extension functions: rename the functions to match yours, redo the argument lists, implement your native extension functionality, etc.
|
731
|
+
|
732
|
+
Sample listing of yourextension_wm.cpp:
|
733
|
+
|
734
|
+
:::cplusplus
|
735
|
+
#include <common/RhodesApp.h>
|
736
|
+
#include <logging/RhoLogConf.h>
|
737
|
+
#include <stdlib.h>
|
738
|
+
#include <windows.h>
|
739
|
+
#include <commctrl.h>
|
740
|
+
#include <RhoNativeViewManager.h>
|
741
|
+
#include "rubyext/WebView.h"
|
742
|
+
#include "ruby/ext/rho/rhoruby.h"
|
743
|
+
#include "yourextension_wm.h"
|
744
|
+
|
745
|
+
extern "C" VALUE yourextension_native_process_string(const char* str) {
|
746
|
+
|
747
|
+
const char block[] = "<WM>";
|
748
|
+
char* buf = NULL;
|
749
|
+
buf = (char*)malloc(strlen(str) + strlen(block)*2 + 1);
|
750
|
+
strcpy(buf, block);
|
751
|
+
strcat(buf, str);
|
752
|
+
strcat(buf, block);
|
753
|
+
VALUE result = rho_ruby_create_string(buf);
|
754
|
+
free(buf);
|
755
|
+
return result;
|
756
|
+
}
|
757
|
+
|
758
|
+
extern "C" int yourextension_calc_summ(int x, int y) {
|
759
|
+
return (x+y);
|
760
|
+
}
|
761
|
+
|
762
|
+
### Adding New Files to the Visual Studio Project
|
763
|
+
|
764
|
+
If you create any new C++ files for your native extension, save them in the same location as the generated C++ file yourextension_wm.cpp, in extensions/yourextension/ext/yourextension/platform/wm/src.
|
765
|
+
|
766
|
+
Open the Visual Studio project for your native extension: yourextension_wm.vcproj in extensions/yourextension/ext/yourextension/platform/wm. Add any new C++ files to this project.
|
767
|
+
|
768
|
+
## Rewriting the Generated Native Extension Source Code for Blackberry
|
769
|
+
|
770
|
+
The Blackberry generated native extension code is contained in the following structure.
|
771
|
+
|
772
|
+
:::term
|
773
|
+
bb - folder with Blackberry specific code
|
774
|
+
|
775
|
+
Rakefile - build script for BB platform
|
776
|
+
|
777
|
+
<yourextension>.files - list of Java files to be compiled
|
360
778
|
|
361
|
-
|
779
|
+
<yourextension>.jdp - Eclipse project (not required for a rake script build)
|
362
780
|
|
363
|
-
|
781
|
+
src - folder with BB specific Java sources
|
782
|
+
com
|
783
|
+
<yourextension>
|
784
|
+
<yourextension>.java - BB platform entry point class with implementation and registration of Ruby functions
|
364
785
|
|
365
|
-
|
366
|
-
* SDKROOT - path to the root of the used SDK - 3.0, 3.1 etc (iPhone build)
|
367
|
-
* ARCHS - cpu architecture used to build extension - i386, armv6 etc (iPhone build)
|
368
|
-
* XCODEBUILD - contain fullname of xcodebuild (iPhone build)
|
369
|
-
* CONFIGURATION - "Debug"/"Release" (iPhone build)
|
370
|
-
* SDK_NAME - name of SDK - need for build of xcodeproject (iPhone build)
|
786
|
+
Note: You do not use the Interface file or SWIG with Blackberry. But you will rewrite the generated native extension Java file.
|
371
787
|
|
372
|
-
|
788
|
+
### Rewrite the Generated Native Extension Java File
|
373
789
|
|
374
|
-
|
375
|
-
* JAVAC_EXE - javac.exe full path (BB build)
|
376
|
-
* JDE_HOME - JDE home full path (BB build)
|
377
|
-
* JAR_EXE - jar.exe full path (BB build)
|
378
|
-
* RUBYVM_JAR - full name of RubyVM.jar file (need for compilation) (BB build)
|
379
|
-
* BB_SDK_VERSION - version of BB SDK
|
790
|
+
First, rewrite the Public functions, renaming them and changing the arguments for your native extension.
|
380
791
|
|
381
|
-
|
792
|
+
:::java
|
793
|
+
public String doProcessString( String str ) {
|
794
|
+
return "<BB>" + str + "<BB>";
|
795
|
+
}
|
796
|
+
|
797
|
+
public int doCalcSumm( int x, int y ) {
|
798
|
+
return (x+y);
|
799
|
+
}
|
800
|
+
|
801
|
+
Then, in the void run() method, rewrite the native_process_string and the calc_summ methods declared in the YourextensionClass.getSingletonClass().
|
802
|
+
|
803
|
+
## Creating Your Native Extension Without the Generator
|
804
|
+
|
805
|
+
You can also create a native extension without using the rhogen extension command. This means you will need to write the entire extension (source code, interface file, build scripts, etc.) from scratch.
|
806
|
+
|
807
|
+
In your Rhodes application folder, create a folder called "extensions". This is the folder that will contain all your native extesion code for your Rhodes application. Within the "extensions" folder, create a folder named for the extension that you are creating, such as "accelerometer". An example path for a Rhodes application named "accel" would be `accel/extensions/accelerometer`. And in that folder, create a folder called "ext."
|
808
|
+
|
809
|
+
### Create Your Extensions Configuration File
|
810
|
+
|
811
|
+
In the folder named for your extension, such as `accel/extensions/accelerometer`, create a file named ext.yml.
|
812
|
+
|
813
|
+
In this file, you have two lines to define your initialization function and your libraries. Here is an example for an accelerometer extension.
|
814
|
+
|
815
|
+
entry: Init_Accelerometer
|
816
|
+
|
817
|
+
libraries: [ "accelerometer" ]
|
818
|
+
|
819
|
+
The first line names the function that is the entry point into your extension; the function is named Init_Your-extension-name. This function is called when your Rhodes application starts, so it will contain all your initialization code for your extension.
|
820
|
+
|
821
|
+
The second line is the name of your library extension that holds your binary extensions that are compiled and integrated into your Ruby code. It is named after the name of your extension folder; in this example, it is named accelerometer.
|
822
|
+
|
823
|
+
You can have more that one library, in which case you would separate the libraries with commas:
|
382
824
|
|
383
|
-
|
825
|
+
libraries: [ "extension1", "extension2" ]
|
826
|
+
|
827
|
+
For Android, add the following parameters to your ext.yml file.
|
828
|
+
|
829
|
+
* android_rhodes_activity_listener - Java class name implemented interface com.rhomobile.rhodes.RhodesActivityListener (used for attach to main Rhodes application activity)
|
830
|
+
* android_manifest_changes - filename with Android manifest items (in format of Android manifest) 0 this file will join to main AndroidManifest.xml of application
|
831
|
+
* android_resources_addons - folder with any additional files for add to main application build folder (can contain any resources, layouts, etc.)
|
832
|
+
* android_additional_sources_list - filename with list of *.java files for building with main Rhodes application package.
|
833
|
+
|
834
|
+
<table border="1">
|
835
|
+
<tr>
|
836
|
+
<td><code>android_rhodes_activity_listener</code></td>
|
837
|
+
<td>Java class name implemented interface com.rhomobile.rhodes.RhodesActivityListener (used for attach to main Rhodes application activity)</td>
|
838
|
+
</tr>
|
839
|
+
<tr>
|
840
|
+
<td><code>android_manifest_changes</code></td>
|
841
|
+
<td>filename with Android manifest items (in format of Android manifest) 0 this file will join to main AndroidManifest.xml of application</td>
|
842
|
+
</tr>
|
843
|
+
<tr>
|
844
|
+
<td><code>android_resources_addons</code></td>
|
845
|
+
<td>folder with any additional files for add to main application build folder (can contain any resources, layouts, etc.)</td>
|
846
|
+
</tr>
|
847
|
+
<tr>
|
848
|
+
<td><code>android_additional_sources_list</code></td>
|
849
|
+
<td>filename with list of *.java files for building with main Rhodes application package</td>
|
850
|
+
</tr>
|
851
|
+
</table>
|
852
|
+
|
853
|
+
Here is an example of an ext.yml file for an NFC extension. This example is taken from the Rhodes installation, located at [Rhodes root]/lib/extensions/Nfc.
|
384
854
|
|
385
855
|
entry: Init_Nfc
|
386
856
|
android_rhodes_activity_listener: com.rhomobile.nfc.Nfc
|
@@ -389,24 +859,412 @@ In your "ext.yml" file add new parameters :
|
|
389
859
|
android_additional_sources_list: ext/nfc/platform/android/ext_build.files
|
390
860
|
libraries: ["Nfc"]
|
391
861
|
|
392
|
-
|
393
|
-
* android_rhodes_activity_listener - Java class name implemented interface com.rhomobile.rhodes.RhodesActivityListener (used for attach to main Rhodes application activity)
|
394
|
-
* android_manifest_changes - filename with Android manifest items (in format of Android manifest) 0 this file will join to main AndroidManifest.xml of application
|
395
|
-
* android_resources_addons - folder with any additional files for add to main application build folder (can contain any resources, layouts, etc.)
|
396
|
-
* android_additional_sources_list - filename with list of *.java files for building with main Rhodes application package.
|
862
|
+
### Create Your Build Script
|
397
863
|
|
398
|
-
|
864
|
+
In the "ext" folder, such as `accel/extensions/accelerometer/ext`, you will create your build scripts and your native extension code.
|
399
865
|
|
400
|
-
|
866
|
+
Create a build script file. Name this file `build` for Macintosh and `build.bat` for Windows. This file executes a rake file that contains all your compiling commands for your extension. (You can instead put your compiling commands in the build file, but this chapter uses the Rakefile method.)
|
401
867
|
|
402
|
-
|
403
|
-
**NOTE: We recommend use new android_additional_sources_list parameter from ext.yml config - just prepare file with list of your java files for build and setup that parameter.
|
868
|
+
When running on Linux and Macintosh, make sure the build files are executable.
|
404
869
|
|
405
|
-
|
870
|
+
For the Macintosh, the build file contains:
|
406
871
|
|
407
|
-
|
872
|
+
#!/bin/sh
|
873
|
+
|
874
|
+
rake
|
875
|
+
|
876
|
+
For Windows, the build.bat file contains:
|
877
|
+
|
878
|
+
rake --trace
|
879
|
+
|
880
|
+
The above build scripts execute a Rakefile script which you create: this Rakefile compiles your extension code and produces the libraries. When Rhodes creates the final binary for your application, it will search for and link with the library that was generated for your extension. For an extension called `accelerometer`, the build script for iPhone and Android should be name the library `libaccelerometer.a`; for Windows, it should be named `accelerometer.lib`. The build script (in this case, in the Rakefile) should place the library in the folder named by TARGET_TEMP_DIR.
|
881
|
+
|
882
|
+
**NOTE: You do not need to use a rakefile. You can put your compiling commands in the build or build.bat scripts. The only requirement is that you have a file named build and that it is executable.
|
883
|
+
|
884
|
+
## Environment Variables Used in the Build Script
|
885
|
+
|
886
|
+
Before you build the build script (in this case, a Rakefile), you should be aware of the environmental variables that you can use in the script. These variables give you the path to the Rhodes root and information about your application platform. In the example used here, the Rakefile for the iPhone accelerometer uses several of these variables.
|
887
|
+
|
888
|
+
The following environment variables are used by all the platforms.
|
889
|
+
|
890
|
+
<table border="1">
|
891
|
+
<tr>
|
892
|
+
<td><code>TARGET_TEMP_DIR</code></td>
|
893
|
+
<td>Location to put your compiled library</td>
|
894
|
+
</tr>
|
895
|
+
<tr>
|
896
|
+
<td><code>RHO_PLATFORM</code></td>
|
897
|
+
<td>mobile platform fot this application build. Possible values are 'iphone', 'android' and 'wm'</td>
|
898
|
+
</tr>
|
899
|
+
<tr>
|
900
|
+
<td><code>RHO_ROOT</code></td>
|
901
|
+
<td>point to the Rhodes installation root folder (the directory where rhobuild.yml is located)</td>
|
902
|
+
</tr>
|
903
|
+
<tr>
|
904
|
+
<td><code>TEMP_FILES_DIR</code></td>
|
905
|
+
<td>used for temporay files</td>
|
906
|
+
</tr>
|
907
|
+
</table>
|
908
|
+
|
909
|
+
The following environment variables are available for Android.
|
910
|
+
|
911
|
+
<table border="1">
|
912
|
+
<tr>
|
913
|
+
<td><code>ANDROID_NDK</code></td>
|
914
|
+
<td>path to the Android NDK used by Rhodes</td>
|
915
|
+
</tr>
|
916
|
+
<tr>
|
917
|
+
<td><code>ANDROID_API_LEVEL</code></td>
|
918
|
+
<td>Android API level used by Rhodes</td>
|
919
|
+
</tr>
|
920
|
+
</table>
|
921
|
+
|
922
|
+
The following environment variables are available for Windows Mobile.
|
923
|
+
|
924
|
+
<table border="1">
|
925
|
+
<tr>
|
926
|
+
<td><code>VCBUILD</code></td>
|
927
|
+
<td>path to the vcbuild application in the Microsoft Visual Studio installation</td>
|
928
|
+
</tr>
|
929
|
+
</table>
|
930
|
+
|
931
|
+
The following environment variables are available for iPhone.
|
932
|
+
|
933
|
+
<table border="1">
|
934
|
+
<tr>
|
935
|
+
<td><code>PLATFORM_DEVELOPER_BIN_DIR</code></td>
|
936
|
+
<td>path to the platform developer bin directory</td>
|
937
|
+
</tr>
|
938
|
+
<tr>
|
939
|
+
<td><code>SDKROOT</code></td>
|
940
|
+
<td>path to the root of the used SDK - 3.0, 3.1</td>
|
941
|
+
</tr>
|
942
|
+
<tr>
|
943
|
+
<td><code>ARCHS</code></td>
|
944
|
+
<td>path to the platform developer bin directory</td>
|
945
|
+
</tr>
|
946
|
+
<tr>
|
947
|
+
<td><code>XCODEBUILD</code></td>
|
948
|
+
<td>contains the full name of the xcodebuild</td>
|
949
|
+
</tr>
|
950
|
+
<tr>
|
951
|
+
<td><code>CONFIGURATION</code></td>
|
952
|
+
<td>"Debug" or "Release"</td>
|
953
|
+
</tr>
|
954
|
+
<tr>
|
955
|
+
<td><code>SDK_NAME</code></td>
|
956
|
+
<td>name of SDK - need for build of xcodeproject</td>
|
957
|
+
</tr>
|
958
|
+
</table>
|
959
|
+
|
960
|
+
The following environment variables are available for Blackberry.
|
961
|
+
|
962
|
+
<table border="1">
|
963
|
+
<tr>
|
964
|
+
<td><code>JAVA_EXE</code></td>
|
965
|
+
<td>java.exe full path</td>
|
966
|
+
</tr>
|
967
|
+
<tr>
|
968
|
+
<td><code>JAVAC_EXE</code></td>
|
969
|
+
<td>javac.exe full path</td>
|
970
|
+
</tr>
|
971
|
+
<tr>
|
972
|
+
<td><code>JDE_HOME</code></td>
|
973
|
+
<td>JDE home full path</td>
|
974
|
+
</tr>
|
975
|
+
<tr>
|
976
|
+
<td><code>JAR_EXE</code></td>
|
977
|
+
<td>jar.exe full path</td>
|
978
|
+
</tr>
|
979
|
+
<tr>
|
980
|
+
<td><code>RUBYVM_JAR</code></td>
|
981
|
+
<td>full name of RubyVM.jar file (needed for compilation)</td>
|
982
|
+
</tr>
|
983
|
+
<tr>
|
984
|
+
<td><code>BB_SDK_VERSION</code></td>
|
985
|
+
<td>version of Blackberry SDK</td>
|
986
|
+
</tr>
|
987
|
+
</table>
|
988
|
+
|
989
|
+
### Creating the Rakefile Script
|
990
|
+
|
991
|
+
The code listing below is a Rakefile for an iPhone accelerometer native extension. Most of this code you can use for all platforms. Comments are included to tell you where you would substitute code for your specific platform.
|
992
|
+
|
993
|
+
The sections that you write specifically for your platform are:
|
994
|
+
|
995
|
+
* Clean file types specific to your platform.
|
996
|
+
* Set platform-specific arguments when compiling the .c files.
|
997
|
+
* Compile code specific for your platform (such as objective C for iphone).
|
998
|
+
* Build the linking command for your platform.
|
999
|
+
|
1000
|
+
For other platforms, you can use the Rakefile in the digest extension, which is located in your Rhodes folder: `<rhodes>/lib/extensions/digest/ext/Rakefile`.
|
1001
|
+
|
1002
|
+
:::term
|
1003
|
+
require 'fileutils'
|
1004
|
+
|
1005
|
+
def build_extension(name, arch)
|
1006
|
+
objects = []
|
1007
|
+
mkdir_p $tempdir unless File.exists? $tempdir
|
1008
|
+
|
1009
|
+
Dir.glob("*.o").each { |f| rm_rf f }
|
1010
|
+
|
1011
|
+
# *** IPHONE SPECIFIC: remove any leftover .a files
|
1012
|
+
Dir.glob("*.a").each { |f| rm_rf f }
|
1013
|
+
rm_rf "accelerometer_wrap.c"
|
1014
|
+
|
1015
|
+
#swig
|
1016
|
+
Dir.glob("*.i").each do |f|
|
1017
|
+
puts "swig -ruby #{f}"
|
1018
|
+
puts `swig -ruby #{f}`
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
# compile the .c files
|
1022
|
+
Dir.glob("*.c").each do |f|
|
1023
|
+
objname = File.join( $tempdir, File.basename( f.gsub(/\.c$/, '.o') ) )
|
1024
|
+
objects << objname
|
1025
|
+
|
1026
|
+
args = []
|
1027
|
+
args << "-I."
|
1028
|
+
args << "-I#{$rootdir}/platform/shared/ruby/include"
|
1029
|
+
args << "-I#{$rootdir}/platform/shared"
|
1030
|
+
|
1031
|
+
if ENV['RHO_PLATFORM'] == 'android'
|
1032
|
+
|
1033
|
+
# *** IPHONE SPECIFIC: set arguments (and execute the compile command)
|
1034
|
+
elsif ENV['RHO_PLATFORM'] == 'iphone'
|
1035
|
+
# get iPhone specific ruby files
|
1036
|
+
args << "-I#{$rootdir}/platform/shared/ruby/iphone"
|
1037
|
+
# set some flags for Xcode
|
1038
|
+
args << "-D_XOPEN_SOURCE"
|
1039
|
+
args << "-D_DARWIN_C_SOURCE"
|
1040
|
+
# isysroot sets the root sdk of where the gcc compiler will pick up
|
1041
|
+
# the libraries, such as the UIKit library
|
1042
|
+
args << "-isysroot #{$sdkroot}"
|
1043
|
+
args << "-fno-common"
|
1044
|
+
# set the architecture and optimization level
|
1045
|
+
args << "-arch #{arch}"
|
1046
|
+
args << "-O2"
|
1047
|
+
# give the object name
|
1048
|
+
args << "-o #{objname}"
|
1049
|
+
args << "-c"
|
1050
|
+
args << f
|
1051
|
+
# build up the command
|
1052
|
+
cmdline = $gccbin + ' ' + args.join(' ')
|
1053
|
+
puts cmdline
|
1054
|
+
# and execute the command
|
1055
|
+
puts `#{cmdline}`
|
1056
|
+
exit unless $? == 0
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
# *** IPHONE SPECIFIC: compile all the .m objective c files
|
1061
|
+
if ENV['RHO_PLATFORM'] == 'iphone'
|
1062
|
+
# add all the .m files to the list of objects
|
1063
|
+
Dir.glob("*.m").each do |f|
|
1064
|
+
objname = File.join( $tempdir, File.basename( f.gsub(/\.m$/, '.o') ) )
|
1065
|
+
objects << objname
|
1066
|
+
|
1067
|
+
args = []
|
1068
|
+
args << "-x objective-c"
|
1069
|
+
# add the specific flags needed to build for iPhone
|
1070
|
+
args << "-arch #{arch}"
|
1071
|
+
args << "-pipe -std=c99 -Wno-trigraphs -fpascal-strings -O0 -Wreturn-type -Wunused-variable"
|
1072
|
+
args << "-isysroot #{$sdkroot}"
|
1073
|
+
args << "-D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 "
|
1074
|
+
args << "-fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch"
|
1075
|
+
args << "-I."
|
1076
|
+
args << "-o #{objname}"
|
1077
|
+
args << "-c"
|
1078
|
+
args << f
|
1079
|
+
cmdline = $gccbin + ' ' + args.join(' ')
|
1080
|
+
puts cmdline
|
1081
|
+
puts `#{cmdline}`
|
1082
|
+
exit unless $? == 0
|
1083
|
+
end
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
mkdir_p $targetdir unless File.exist? $targetdir
|
1087
|
+
|
1088
|
+
if ENV['RHO_PLATFORM'] == 'android'
|
1089
|
+
|
1090
|
+
# *** IPHONE SPECIFIC: check to see that the linking code exists
|
1091
|
+
elsif ENV['RHO_PLATFORM'] == 'iphone'
|
1092
|
+
args = []
|
1093
|
+
# build up the command line
|
1094
|
+
args << 'rcs'
|
1095
|
+
# put the output into targetdir and call it libaccelerometer.a
|
1096
|
+
args << File.join( $targetdir, 'lib' + name + '.a' )
|
1097
|
+
# give it list of objects compiles in previous steps
|
1098
|
+
args += objects
|
1099
|
+
cmdline = $arbin + ' ' + args.join(' ')
|
1100
|
+
# execute the linking command
|
1101
|
+
puts cmdline
|
1102
|
+
puts `#{cmdline}`
|
1103
|
+
exit unless $? == 0
|
1104
|
+
|
1105
|
+
elsif ENV['RHO_PLATFORM'] == 'wm'
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
namespace "build" do
|
1111
|
+
task :config do
|
1112
|
+
$targetdir = ENV['TARGET_TEMP_DIR']
|
1113
|
+
raise "TARGET_TEMP_DIR is not set" if $targetdir.nil?
|
1114
|
+
$tempdir = ENV['TEMP_FILES_DIR']
|
1115
|
+
raise "TEMP_FILES_DIR is not set" if $tempdir.nil?
|
1116
|
+
$rootdir = ENV['RHO_ROOT']
|
1117
|
+
raise "RHO_ROOT is not set" if $rootdir.nil?
|
1118
|
+
|
1119
|
+
if ENV['RHO_PLATFORM'] == 'android'
|
1120
|
+
elsif ENV['RHO_PLATFORM'] == 'wm'
|
1121
|
+
|
1122
|
+
# *** IPHONE SPECIFIC: set the iPhone specific environment variables
|
1123
|
+
elsif ENV['RHO_PLATFORM'] == 'iphone'
|
1124
|
+
$bindir = ENV['PLATFORM_DEVELOPER_BIN_DIR']
|
1125
|
+
raise "PLATFORM_DEVELOPER_BIN_DIR is not set" if $bindir.nil?
|
1126
|
+
$sdkroot = ENV['SDKROOT']
|
1127
|
+
raise "SDKROOT is not set" if $sdkroot.nil?
|
1128
|
+
$arch = ENV['ARCHS']
|
1129
|
+
raise "ARCHS is not set" if $arch.nil?
|
1130
|
+
$gccbin = $bindir + '/gcc-4.2'
|
1131
|
+
$arbin = $bindir + '/ar'
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
task :all => :config do
|
1137
|
+
build_extension('accelerometer', $arch)
|
1138
|
+
end
|
1139
|
+
end
|
1140
|
+
|
1141
|
+
task :default => "build:all"
|
1142
|
+
|
1143
|
+
### Adding Your Extension to build.yml
|
1144
|
+
|
1145
|
+
Edit your application's build.yml to add the extension name to the list of extensions. For example, if your extension is named accelerometer, have this line in your build.yml file:
|
1146
|
+
|
1147
|
+
extensions: ["accelerometer"]
|
1148
|
+
|
1149
|
+
### Writing Your Extension Code
|
1150
|
+
|
1151
|
+
In the folder named for your extension, such as `accel/extensions/accelerometer`, in the ext folder, create your native extension code. For your iPhone extension, write your header and manifest files in Objectve C.
|
1152
|
+
|
1153
|
+
For the accelerometer example, the header file, Accel.h, imports the iOS libraries your extension needs (in the case of the iPhone accelerometer, the UIKit library). And it defines the class to perform the extension's functionality. (The documentation to perform the accelerometer functionality can be found on the iPhone developer portal.) In this case, we have a class named Accel that implements the UIViewController delegate, and the class has one method: start.
|
1154
|
+
|
1155
|
+
:::cplusplus
|
1156
|
+
#import <UIKit/UIKit.h>
|
1157
|
+
|
1158
|
+
@interface Accel : UIViewController<UIAccelerometerDelegate>
|
1159
|
+
{
|
1160
|
+
}
|
1161
|
+
|
1162
|
+
- (void)start;
|
1163
|
+
|
1164
|
+
@end
|
1165
|
+
|
1166
|
+
The manifest file, Accel.m, contains the Objective C code to perform the accelerometer functionality.
|
1167
|
+
|
1168
|
+
Because Rhodes is written in C, and the Ruby implementation is in C, this manifest file must also expose a C interface to the Objective C code. This accelerometer example has the start and get_reading C functions to do that.
|
1169
|
+
|
1170
|
+
:::cplusplus
|
1171
|
+
#import "accel.h"
|
1172
|
+
|
1173
|
+
// store the acceleration values
|
1174
|
+
double gx,gy,gz;
|
1175
|
+
// Reference this Objective C class.
|
1176
|
+
Accel *accel;
|
1177
|
+
@implementation Accel
|
1178
|
+
|
1179
|
+
-(void)start
|
1180
|
+
{
|
1181
|
+
// Initialize the accelerometer variables.
|
1182
|
+
gx = gy = gz = 0;
|
1183
|
+
// Set the update interval.
|
1184
|
+
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:0.025];
|
1185
|
+
// Set the delegate to this class, so the iPhone accelerometer will
|
1186
|
+
// call you back on the delegate method.
|
1187
|
+
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
|
1188
|
+
}
|
1189
|
+
|
1190
|
+
-(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
|
1191
|
+
// Get the accelerometer values from the iPhone.
|
1192
|
+
{
|
1193
|
+
gx = acceleration.x;
|
1194
|
+
gy = acceleration.y;
|
1195
|
+
gz = acceleration.z;
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
@end
|
1199
|
+
|
1200
|
+
// This C function interfaces with the Objective C start function.
|
1201
|
+
void start(void) {
|
1202
|
+
// make sure we can only start this method once
|
1203
|
+
static bool started = false;
|
1204
|
+
if(!started) {
|
1205
|
+
// Initialize the Objective C accelerometer class.
|
1206
|
+
accel = [[Accel alloc] init];
|
1207
|
+
// Start the accelerometer readings.
|
1208
|
+
[accel start];
|
1209
|
+
started = true;
|
1210
|
+
}
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
// This C function allows us to get the readings from the accelerometer so
|
1214
|
+
// they can be returned to the Ruby code.
|
1215
|
+
void get_readings(double *x, double *y, double *z) {
|
1216
|
+
*x = gx;
|
1217
|
+
*y = gy;
|
1218
|
+
*z = gz;
|
1219
|
+
}
|
1220
|
+
|
1221
|
+
### Writing the Interface File
|
1222
|
+
|
1223
|
+
Now we need to have an interface file that SWIG uses to create a Ruby object which will make the functions in the platform-specific code be available to the Ruby virtual machine.
|
1224
|
+
|
1225
|
+
As is referenced in the Rakefile, this is done with SWIG. You write an interface (.i) file which has the same name as the extension. This will interface with the C functions in the platform-specific code, and get the proper ruby . Here is the code for the iPhone accelerometer example.
|
1226
|
+
|
1227
|
+
:::ruby
|
1228
|
+
%module Accelerometer
|
1229
|
+
%{
|
1230
|
+
extern void get_readings(double *x, double *y, double *z);
|
1231
|
+
extern void start(void);
|
1232
|
+
%}
|
1233
|
+
extern void start(void);
|
1234
|
+
extern void get_readings(double *OUTPUT, double *OUTPUT, double *OUTPUT);
|
1235
|
+
|
1236
|
+
Remember that the iPhone .m Objective C file has C functions to get readings from the accelerometer: void get_readings. It also has a start function to initialize the accelerometer class. These are the C function referenced in the interface file.
|
1237
|
+
|
1238
|
+
### Building the Application
|
1239
|
+
|
1240
|
+
Build your application as usual. It will call the build script for your extension and, if this script finishes successfully, produce the needed libraries into TARGET_TEMP_DIR and link extension libraries into the final binary.
|
1241
|
+
|
1242
|
+
## Platform Notes
|
1243
|
+
|
1244
|
+
### Using Resources
|
1245
|
+
|
1246
|
+
If you want to use any resources in your code, use com.rhomobile.rhodes.R instead of just R. This will make all resources (include your additonal resources) accessible from this R file.
|
1247
|
+
|
1248
|
+
### Calling JNI Functions
|
1249
|
+
|
1250
|
+
If you need to call JNI functions from your native code, you need to retrieve the `JNIEnv *env` variable. To get it, include the file `RHO_ROOT/platform/android/Rhodes/jni/include/rhodes.h` in your C/C++ files. The global function `JNIEnv *jnienv()` is defined in this file, so use it anywhere when `JNIEnv *` needed.
|
1251
|
+
|
1252
|
+
### Using Java Code in Native Extension
|
1253
|
+
|
1254
|
+
If your native extension uses Java code, your build script should create file ext_build.files in the TARGET_TEMP_DIR. This file should contain java source file names (full names, with path) - one by line. Rhodes will include all of them to the final build.
|
1255
|
+
|
1256
|
+
**NOTE: We recommend you use new android_additional_sources_list parameter from ext.yml config - just prepare file with list of your java files for build and set up that parameter.
|
1257
|
+
|
1258
|
+
### Using Prebuilt Libraries (jars)
|
1259
|
+
|
1260
|
+
If your native extension uses prebuilt libraries (jars), your build script must copy all such jar files to the TARGET_TEMP_DIR. The jar files must have the extension '.jar'. Rhodes will include these files in the final build.
|
1261
|
+
|
1262
|
+
### Creating Native Threads
|
1263
|
+
|
1264
|
+
If your native extension creates a native thread (using pthread_create, for example), this thread should be attached to the JVM so that it can call Java methods from its context. Do this by using rho_nativethread_start/rho_nativethread_end functions, called at the start/end of your thread routine.
|
408
1265
|
|
409
1266
|
Example:
|
1267
|
+
|
410
1268
|
:::cpp
|
411
1269
|
void *thread_routine(void *arg)
|
412
1270
|
{
|
@@ -416,29 +1274,24 @@ Example:
|
|
416
1274
|
return NULL;
|
417
1275
|
}
|
418
1276
|
|
419
|
-
Otherwise, if thread was not attached to the JVM, no JNI calls should be performed in its context (it will cause crash).
|
1277
|
+
Otherwise, if the thread was not attached to the JVM, no JNI calls should be performed in its context (it will cause your application to crash).
|
420
1278
|
|
421
|
-
|
1279
|
+
### Providing Additional DLLs for Windows Mobile
|
422
1280
|
|
423
|
-
|
1281
|
+
If your application needs additional DLLs, put them in the TARGET_TEMP_DIR. The Rhodes build scripts will detect them and include them in the final binary automatically.
|
424
1282
|
|
425
|
-
|
1283
|
+
### Registering Your Classes and Methods with Blackberry
|
426
1284
|
|
427
|
-
|
1285
|
+
As with the other platforms, you create a build script (build.bat) Similar to other platfrom you should prepare build.bat where you should prepare <your Extension name>.jar file and place it to TARGET_TEMP_DIR
|
428
1286
|
|
429
|
-
|
430
|
-
|
431
|
-
BlackBerry Notes:
|
432
|
-
|
433
|
-
Similar to other platfrom you should prepare build.bat where you should prepare <your Extension name>.jar file and place it to TARGET_TEMP_DIR
|
434
|
-
In your "ext.yml" file add new parameter with full name of you class supported Runnable interface, see example:
|
1287
|
+
In your "ext.yml" file, add a parameter with the full name of your class supported runnable interface. For example, you might use this for a Barcode extension:
|
435
1288
|
|
436
1289
|
entry: Init_Barcode
|
437
1290
|
javaentry: com.rho.rubyext.BarcodeRecognizer
|
438
1291
|
libraries: ["Barcode"]
|
439
1292
|
|
440
|
-
In run() method of this class
|
441
|
-
|
1293
|
+
In the run() method of this class, register your classes and methods in RubyVM. Here is an example of registering for a barcode extension.
|
1294
|
+
|
442
1295
|
:::java
|
443
1296
|
package com.rho.rubyext;
|
444
1297
|
|
@@ -467,15 +1320,15 @@ Example of registration:
|
|
467
1320
|
|
468
1321
|
}
|
469
1322
|
|
470
|
-
Examples
|
1323
|
+
## Other Examples
|
471
1324
|
|
472
|
-
You can use Barcode extension as an example of native extension for all supported platforms.
|
1325
|
+
You can use teh Barcode extension as an example of native extension for all teh supported platforms. The code for the Barcode native extension is [here on Github](https://github.com/rhomobile/rhodes/tree/master/lib/extensions/barcode/).
|
473
1326
|
|
474
|
-
|
1327
|
+
Another example of the native extension is the Rainbow native extension in the Rhodes System Api Samples. The code for the Rainbow native extension is [here on Github](https://github.com/rhomobile/rhodes-system-api-samples/tree/master/extensions/rainbow/).
|
475
1328
|
|
476
1329
|
## Native View Extensions
|
477
1330
|
|
478
|
-
The Native View interface
|
1331
|
+
The Native View interface allows developers to implement a custom native view and seamlessly integrate it into the Rhodes framework. (This is currently only supported on iPhone; Android, WM and Blackberry is coming soon).
|
479
1332
|
|
480
1333
|
To access implemented view navigate to a url where url schema is the register type name of your view:
|
481
1334
|
|
@@ -498,7 +1351,7 @@ To provide custom native view native extension should implement NativeViewFactor
|
|
498
1351
|
public:
|
499
1352
|
// that function must return native object provided view functionality :
|
500
1353
|
// UIView* for iPhone
|
501
|
-
// jobject for Android -
|
1354
|
+
// jobject for Android - jobject must be android.view.View class type
|
502
1355
|
// HWND for Windows Mobile
|
503
1356
|
virtual void* getView() = 0;
|
504
1357
|
// Used by Rhodes to pass path?query_string#anchor to the view
|
@@ -536,17 +1389,17 @@ To provide custom native view native extension should implement NativeViewFactor
|
|
536
1389
|
};
|
537
1390
|
|
538
1391
|
### Sample
|
539
|
-
See [Rhodes-System-Api-Samples](http://github.com/rhomobile/rhodes-system-api-samples) for details of how to implement and use native view interface. This sample implements a "rainbow_view" native view; you should add rainbow to the list of extensions to include it to the application.
|
1392
|
+
See [Rhodes-System-Api-Samples](http://github.com/rhomobile/rhodes-system-api-samples) for details of how to implement and use the native view interface. This sample implements a "rainbow_view" native view; you should add rainbow to the list of extensions to include it to the application.
|
540
1393
|
|
541
1394
|
See [/app/NativeView/controller.rb](http://github.com/rhomobile/rhodes-system-api-samples/blob/master/app/NativeView/controller.rb) and [/app/NativeView/index.erb](http://github.com/rhomobile/rhodes-system-api-samples/blob/master/app/NativeView/index.erb) for details how to call native view from your controller.
|
542
1395
|
|
543
|
-
** NOTE: Windows Mobile: Visual Studio 2005 has issues with long paths. If you have problems with building rainbow extension, move rhodes folder to shorter path. **
|
1396
|
+
** NOTE: Windows Mobile: Visual Studio 2005 has issues with long paths. If you have problems with building rainbow extension, move your rhodes folder to a shorter path. **
|
544
1397
|
|
545
|
-
* To navigate to rainbow view in your controller
|
1398
|
+
* To navigate to rainbow view in your controller, call `WebView.navigate('rainbow_view:red')`. In your url schema indicates view type you want to open and rest of the url (red) passed to the after it was created.
|
546
1399
|
|
547
1400
|
* To pass parameters to created view you may call WebView.navigate again: `WebView.navigate('rainbow_view:green')`. In your native code you may pass parameters to the native view by calling `pNativeView->navigate(url)` where pNativeView is an instance of native view created by the `RhoNativeViewManager` using registered factory.
|
548
1401
|
|
549
|
-
* To close view you created
|
1402
|
+
* To close the view you created, navigate to any other url.
|
550
1403
|
|
551
1404
|
See [/extensions/rainbow](http://github.com/rhomobile/rhodes-system-api-samples/tree/master/extensions/rainbow/) for implementation of the "rainbow" native view.
|
552
1405
|
|
@@ -567,7 +1420,7 @@ This sample extension uses functionality provided by Rhodes framework and theref
|
|
567
1420
|
* [$(RHO_ROOT)/platform/shared/common/RhodesApp.h](http://github.com/rhomobile/rhodes/blob/master/platform/shared/common/RhodesApp.h)
|
568
1421
|
* [$(RHO_ROOT)/platform/shared/rubyext/WebView.h](http://github.com/rhomobile/rhodes/blob/master/platform/shared/rubyext/WebView.h)
|
569
1422
|
|
570
|
-
Make sure following
|
1423
|
+
Make sure the following folders are added to your compiler include path:
|
571
1424
|
|
572
1425
|
* [$(RHO_ROOT)/platform/shared/rubyext](http://github.com/rhomobile/rhodes/tree/master/platform/shared/rubyext/)
|
573
1426
|
* [$(RHO_ROOT)/platform/shared/ruby/include](http://github.com/rhomobile/rhodes/tree/master/platform/shared/ruby/include/)
|
@@ -583,5 +1436,5 @@ Examples of how to use the url_for_nativeview method:
|
|
583
1436
|
|
584
1437
|
|
585
1438
|
## Using LineaSDK in Rhodes (with using special Linea native extension)
|
586
|
-
Please see documentation : [LineaSDK as native extension in Rhodes applications](linea)
|
587
1439
|
|
1440
|
+
Please see the documentation at [LineaSDK as native extension in Rhodes applications](linea).
|