rhodes 1.5.5 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (529) hide show
  1. data/CHANGELOG +5 -0
  2. data/Manifest.txt +214 -32
  3. data/Rakefile +33 -10
  4. data/bin/upgrade-rhodes-app +0 -1
  5. data/lib/build/compileERB/bb.rb +2 -2
  6. data/lib/build/compileERB/default.rb +7 -5
  7. data/lib/build/jake.rb +1 -1
  8. data/lib/extensions/digest-md5/ext.yml +1 -1
  9. data/lib/extensions/digest-md5/ext/Rakefile +35 -36
  10. data/lib/extensions/digest-md5/ext/build.bat +1 -0
  11. data/lib/extensions/digest-md5/ext/digest-md5.vcproj +203 -0
  12. data/lib/extensions/digest-sha1/ext.yml +1 -1
  13. data/lib/extensions/digest/ext.yml +1 -1
  14. data/lib/extensions/digest/ext/Rakefile +35 -39
  15. data/lib/extensions/digest/ext/build.bat +1 -2
  16. data/lib/extensions/digest/ext/digest.vcproj +203 -0
  17. data/lib/framework/rho/render.rb +79 -22
  18. data/lib/framework/rho/rho.rb +294 -56
  19. data/lib/framework/rho/rhoapplication.rb +10 -0
  20. data/lib/framework/rho/rhofsconnector.rb +2 -6
  21. data/lib/framework/rho/rhoutils.rb +56 -14
  22. data/lib/framework/rho/rhoviewhelpers.rb +2 -0
  23. data/lib/framework/rhodes.rb +2 -2
  24. data/lib/framework/rhom/rhom.rb +42 -15
  25. data/lib/framework/rhom/rhom_db_adapter.rb +165 -159
  26. data/lib/framework/rhom/rhom_object.rb +0 -1
  27. data/lib/framework/rhom/rhom_object_factory.rb +343 -166
  28. data/lib/framework/rhom/rhom_source.rb +28 -15
  29. data/lib/framework/version.rb +2 -2
  30. data/lib/rhodes.rb +2 -2
  31. data/platform/android/Rhodes/AndroidManifest.xml +2 -2
  32. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +39 -44
  33. data/platform/android/Rhodes/jni/include/JNIRhodes.h +1 -1
  34. data/platform/android/Rhodes/jni/include/details/rhojava.inc +23 -20
  35. data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_RhoMenu.h +61 -0
  36. data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_Rhodes.h +16 -0
  37. data/platform/android/Rhodes/jni/include/jni/com_rhomobile_rhodes_alert_Alert.h +21 -0
  38. data/platform/android/Rhodes/jni/include/sslimpl.h +1 -1
  39. data/platform/android/Rhodes/jni/src/alert.cpp +32 -5
  40. data/platform/android/Rhodes/jni/src/callbacks.cpp +51 -21
  41. data/platform/android/Rhodes/jni/src/mapview.cpp +3 -8
  42. data/platform/android/Rhodes/jni/src/menu.cpp +70 -0
  43. data/platform/android/Rhodes/jni/src/navbar.cpp +16 -0
  44. data/platform/android/Rhodes/jni/src/rhodes.cpp +37 -0
  45. data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -3
  46. data/platform/android/Rhodes/jni/src/webview.cpp +21 -7
  47. data/platform/android/Rhodes/res/drawable/alert_alert.png +0 -0
  48. data/platform/android/Rhodes/res/drawable/alert_info.png +0 -0
  49. data/platform/android/Rhodes/res/drawable/alert_question.png +0 -0
  50. data/platform/android/Rhodes/res/drawable/camera.png +0 -0
  51. data/platform/android/Rhodes/res/layout/camera.xml +18 -3
  52. data/platform/android/Rhodes/res/menu/options.xml +0 -10
  53. data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +5 -10
  54. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +12 -0
  55. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhoMenu.java +105 -0
  56. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +157 -122
  57. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +7 -58
  58. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +16 -0
  59. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +220 -17
  60. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/Camera.java +22 -4
  61. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +44 -25
  62. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +10 -0
  63. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +3 -0
  64. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +10 -21
  65. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +15 -12
  66. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +44 -0
  67. data/platform/android/Rhodes/src/com/rhomobile/rhodes/socket/SSLImpl.java +47 -3
  68. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +13 -6
  69. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/TelUriHandler.java +11 -5
  70. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/UriHandler.java +1 -4
  71. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/VideoUriHandler.java +61 -0
  72. data/platform/android/build/RhodesSRC_build.files +3 -0
  73. data/platform/android/build/android.rake +173 -60
  74. data/platform/android/build/androidcommon.rb +1 -2
  75. data/platform/android/build/librhocommon_build.files +5 -0
  76. data/platform/android/build/librhodes_build.files +2 -0
  77. data/platform/android/build/libruby_build.files +2 -1
  78. data/platform/bb/Hsqldb/Hsqldb.jdp +0 -3
  79. data/platform/bb/Hsqldb/src/com/rho/db/FileUtilBB.java +1 -1
  80. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +16 -1
  81. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBRowResult.java +5 -0
  82. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBStorage.java +25 -4
  83. data/platform/bb/Hsqldb/src/com/rho/db/Journal.java +1 -1
  84. data/platform/bb/Hsqldb/src/com/rho/file/FileAccessBB.java +0 -1
  85. data/platform/bb/Hsqldb/src/j2me/math/Number.java +6 -3
  86. data/platform/bb/Hsqldb/src/org/hsqldb/CompiledStatementExecutor.java +2 -1
  87. data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +1 -0
  88. data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +1 -0
  89. data/platform/bb/Hsqldb/src/org/hsqldb/Result.java +2 -0
  90. data/platform/bb/Hsqldb/src/org/hsqldb/Select.java +12 -6
  91. data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +19 -12
  92. data/platform/bb/Hsqldb/src/org/hsqldb/Table.java +10 -4
  93. data/platform/bb/Hsqldb/src/org/hsqldb/Token.java +10 -2
  94. data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +3 -3
  95. data/platform/bb/Hsqldb/src/org/hsqldb/lib/java/JavaSystem.java +1 -1
  96. data/platform/bb/Hsqldb/src/org/hsqldb/persist/HsqlProperties.java +2 -1
  97. data/platform/bb/Hsqldb/src/org/hsqldb/persist/ScaledRAFile.java +1 -1
  98. data/platform/bb/Hsqldb/src/org/hsqldb/scriptio/ScriptReaderText.java +1 -1
  99. data/platform/bb/Hsqldb/src/org/hsqldb/scriptio/ScriptWriterBase.java +1 -1
  100. data/platform/bb/RubyVM/RubyVM.jdp +9 -10
  101. data/platform/bb/build/RubyVM_build.files +9 -7
  102. data/platform/bb/build/bb.rake +13 -3
  103. data/platform/bb/build/hsqldb_build.files +0 -2
  104. data/platform/bb/build/rhodes_build.files +5 -2
  105. data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +8 -0
  106. data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +154 -0
  107. data/platform/bb/rhodes/platform/5.0/com/rho/RhoMainScreen.java +8 -0
  108. data/platform/bb/rhodes/platform/common/com/rho/BrowserAdapter5.java +28 -0
  109. data/platform/bb/rhodes/rhodes.jdp +12 -7
  110. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +331 -0
  111. data/platform/bb/rhodes/src/com/rho/BrowserAdapter5.java +28 -0
  112. data/platform/bb/rhodes/src/com/rho/IBrowserAdapter.java +10 -0
  113. data/platform/bb/rhodes/src/com/rho/RhoMainScreen.java +4 -0
  114. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +2 -4
  115. data/platform/bb/rhodes/src/com/rho/{Jsr75File.java → file/Jsr75File.java} +83 -36
  116. data/platform/bb/{Hsqldb → rhodes}/src/com/rho/file/Jsr75RAFileImpl.java +0 -1
  117. data/platform/bb/{Hsqldb → rhodes}/src/com/rho/file/PersistRAFileImpl.java +0 -2
  118. data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +8 -10
  119. data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +1 -1
  120. data/platform/bb/rhodes/src/com/rho/rubyext/GeoLocation.java +39 -0
  121. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +63 -2
  122. data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +100 -0
  123. data/platform/bb/rhodes/src/rhomobile/LogScreen.java +1 -1
  124. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +13 -1
  125. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +138 -492
  126. data/platform/bb/rhodes/src/rhomobile/SecondaryResourceFetchThread.java +11 -2
  127. data/platform/bb/rhodes/src/rhomobile/Utilities.java +14 -10
  128. data/platform/bb/rhodes/src/rhomobile/camera/CameraScreen.java +5 -14
  129. data/platform/bb/rhodes/src/rhomobile/camera/ImageBrowserScreen.java +1 -1
  130. data/platform/bb/rhodes/src/rhomobile/mapview/GoogleMapField.java +2 -2
  131. data/platform/iphone/Classes/AppManager/AppManager.m +37 -14
  132. data/platform/iphone/Classes/Camera/PickImageDelegate.h +15 -4
  133. data/platform/iphone/Classes/Camera/PickImageDelegate.m +53 -50
  134. data/platform/iphone/Classes/DateTimePicker.h +17 -0
  135. data/platform/iphone/Classes/DateTimePicker.m +35 -0
  136. data/platform/iphone/Classes/GeoLocation/LocationController.m +2 -3
  137. data/platform/iphone/Classes/LogOptionsController.m +3 -2
  138. data/platform/iphone/Classes/LogViewController.m +4 -2
  139. data/platform/iphone/Classes/MapView/GoogleGeocoder.m +12 -20
  140. data/platform/iphone/Classes/MapView/MapAnnotation.h +9 -13
  141. data/platform/iphone/Classes/MapView/MapAnnotation.m +17 -65
  142. data/platform/iphone/Classes/MapView/MapViewController.h +1 -7
  143. data/platform/iphone/Classes/MapView/MapViewController.m +51 -25
  144. data/platform/iphone/Classes/NativeBar.h +0 -12
  145. data/platform/iphone/Classes/NativeBar.m +121 -2
  146. data/platform/iphone/Classes/NavBar.h +16 -0
  147. data/platform/iphone/Classes/NavBar.m +115 -0
  148. data/platform/iphone/Classes/RhoAlert.h +19 -0
  149. data/platform/iphone/Classes/RhoAlert.m +258 -0
  150. data/platform/iphone/Classes/RhoDelegate.m +1 -0
  151. data/platform/iphone/Classes/RhoMainView.h +33 -0
  152. data/platform/iphone/Classes/Rhodes.h +56 -0
  153. data/platform/iphone/Classes/Rhodes.m +533 -0
  154. data/platform/iphone/Classes/RingtoneManager.h +17 -0
  155. data/platform/iphone/Classes/RingtoneManager.m +73 -0
  156. data/platform/iphone/Classes/SimpleMainView.h +30 -0
  157. data/platform/iphone/Classes/SimpleMainView.m +380 -0
  158. data/platform/iphone/Classes/TabbedMainView.h +24 -0
  159. data/platform/iphone/Classes/TabbedMainView.m +202 -0
  160. data/platform/iphone/Classes/WebView.m +123 -0
  161. data/platform/iphone/Classes/rho/net/NetRequestImpl.m +2 -2
  162. data/platform/iphone/Classes/rho/net/sslimpl.cpp +13 -1
  163. data/platform/iphone/Classes/rho/net/sslimpl.h +1 -1
  164. data/platform/iphone/Info.plist +1 -1
  165. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +44 -0
  166. data/platform/iphone/main.m +1 -2
  167. data/platform/iphone/rbuild/iphone.rake +8 -16
  168. data/platform/iphone/rhoextlib/dosyscall.c +1 -1
  169. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +6 -4
  170. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +12 -0
  171. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +97 -62
  172. data/platform/iphone/rhosynclib/rhosynclib.xcodeproj/project.pbxproj +12 -0
  173. data/platform/osx/Rhodes Launcher/launch.rb +14 -21
  174. data/platform/shared/common/AppMenu.cpp +122 -0
  175. data/platform/shared/common/AppMenu.h +46 -0
  176. data/platform/shared/common/PosixThreadImpl.cpp +1 -1
  177. data/platform/shared/common/RhoConf.cpp +27 -2
  178. data/platform/shared/common/RhoConf.h +5 -0
  179. data/platform/shared/common/RhoFilePath.h +21 -0
  180. data/platform/shared/common/RhoStd.h +44 -5
  181. data/platform/shared/common/RhoTime.h +20 -7
  182. data/platform/shared/common/RhodesApp.cpp +236 -177
  183. data/platform/shared/common/RhodesApp.h +36 -13
  184. data/platform/shared/common/SplashScreen.cpp +2 -2
  185. data/platform/shared/common/StringConverter.h +10 -11
  186. data/platform/shared/common/rhoparams.c +0 -6
  187. data/platform/shared/curl/lib/rhossl.c +3 -2
  188. data/platform/shared/curl/lib/url.c +0 -5
  189. data/platform/shared/db/DBAdapter.cpp +304 -81
  190. data/platform/shared/db/DBAdapter.h +24 -7
  191. data/platform/shared/db/DBAttrManager.cpp +83 -30
  192. data/platform/shared/db/DBAttrManager.h +6 -0
  193. data/platform/shared/db/DBResult.h +15 -4
  194. data/platform/shared/json/JSONIterator.cpp +100 -3
  195. data/platform/shared/json/JSONIterator.h +28 -3
  196. data/platform/shared/net/AsyncHttp.cpp +25 -22
  197. data/platform/shared/net/AsyncHttp.h +10 -6
  198. data/platform/shared/net/CURLNetRequest.cpp +115 -36
  199. data/platform/shared/net/CURLNetRequest.h +6 -0
  200. data/platform/shared/net/HttpServer.cpp +6 -4
  201. data/platform/shared/net/HttpServer.h +0 -1
  202. data/platform/shared/net/INetRequest.h +19 -3
  203. data/platform/shared/net/URI.cpp +2 -2
  204. data/platform/shared/net/ssl.cpp +2 -2
  205. data/platform/shared/net/ssl.h +2 -2
  206. data/platform/shared/ruby/ext/alert/alert.i +14 -2
  207. data/platform/shared/ruby/ext/alert/alert_wrap.c +40 -20
  208. data/platform/shared/ruby/ext/asynchttp/asynchttp.i +8 -8
  209. data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +112 -16
  210. data/platform/shared/ruby/ext/geolocation/geolocation.i +16 -12
  211. data/platform/shared/ruby/ext/geolocation/geolocation_wrap.c +481 -125
  212. data/platform/shared/ruby/ext/navbar/navbar.i +20 -0
  213. data/platform/shared/ruby/ext/navbar/navbar_wrap.c +1859 -0
  214. data/platform/shared/ruby/ext/rho/extensions.c +1 -1
  215. data/platform/shared/ruby/ext/rho/rhoruby.c +32 -2
  216. data/platform/shared/ruby/ext/rho/rhoruby.h +7 -2
  217. data/platform/shared/ruby/ext/rhoconf/rhoconf.i +4 -0
  218. data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +31 -0
  219. data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +188 -3226
  220. data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -25
  221. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +96 -104
  222. data/platform/shared/ruby/ext/system/system.i +12 -0
  223. data/platform/shared/ruby/ext/system/system_wrap.c +101 -7
  224. data/platform/shared/ruby/ext/webview/webview.i +20 -15
  225. data/platform/shared/ruby/ext/webview/webview_wrap.c +42 -16
  226. data/platform/shared/ruby/thread_pthread.c +4 -4
  227. data/platform/shared/ruby/thread_win32.c +4 -4
  228. data/platform/shared/ruby/wince/io_wce.c +0 -1
  229. data/platform/shared/rubyJVM/src/com/rho/FilePath.java +18 -2
  230. data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +1 -0
  231. data/platform/shared/rubyJVM/src/com/rho/Properties.java +9 -0
  232. data/platform/shared/rubyJVM/src/com/rho/RhoClassFactory.java +2 -3
  233. data/platform/shared/rubyJVM/src/com/rho/RhoConf.java +47 -8
  234. data/platform/shared/rubyJVM/src/com/rho/RhoLogConf.java +1 -0
  235. data/platform/shared/rubyJVM/src/com/rho/RhoLogFileSink.java +1 -0
  236. data/platform/shared/rubyJVM/src/com/rho/RhoRuby.java +43 -5
  237. data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +98 -3
  238. data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +460 -175
  239. data/platform/shared/rubyJVM/src/com/rho/db/DBAttrManager.java +81 -33
  240. data/platform/shared/rubyJVM/src/com/rho/db/IDBCallback.java +3 -5
  241. data/platform/shared/rubyJVM/src/com/rho/db/IDBResult.java +2 -0
  242. data/platform/shared/rubyJVM/src/com/rho/db/IDBStorage.java +2 -0
  243. data/platform/shared/rubyJVM/src/com/rho/{IFile.java → file/IFile.java} +1 -1
  244. data/platform/shared/rubyJVM/src/com/rho/{IFileAccess.java → file/IFileAccess.java} +1 -1
  245. data/platform/shared/rubyJVM/src/com/rho/{IRAFile.java → file/IRAFile.java} +1 -1
  246. data/platform/{bb/Hsqldb/src/com/rho/db → shared/rubyJVM/src/com/rho/file}/RandomAccessFile.java +1 -2
  247. data/platform/shared/rubyJVM/src/com/rho/{SimpleFile.java → file/SimpleFile.java} +5 -1
  248. data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +23 -18
  249. data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +167 -250
  250. data/platform/shared/rubyJVM/src/com/rho/net/RhoConnection.java +100 -30
  251. data/platform/shared/rubyJVM/src/com/rho/net/URI.java +0 -1
  252. data/platform/shared/rubyJVM/src/com/rho/sync/ClientRegister.java +30 -33
  253. data/platform/shared/rubyJVM/src/com/rho/sync/ISyncProtocol.java +20 -0
  254. data/platform/shared/rubyJVM/src/com/rho/sync/JSONEntry.java +5 -0
  255. data/platform/shared/rubyJVM/src/com/rho/sync/JSONStructIterator.java +74 -0
  256. data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +486 -257
  257. data/platform/shared/rubyJVM/src/com/rho/sync/SyncNotify.java +89 -58
  258. data/platform/shared/rubyJVM/src/com/rho/sync/SyncProtocol_3.java +79 -0
  259. data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +634 -495
  260. data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +74 -90
  261. data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubySymbol_Methods.java +1 -0
  262. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyThread.java +6 -0
  263. data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyRuntime.java +6 -2
  264. data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubySymbol.java +17 -1
  265. data/platform/shared/rubyJVM/src/com/xruby/runtime/lang/RubyValue.java +1 -0
  266. data/platform/shared/rubyJVM/src/org/json/me/JSONObject.java +3 -0
  267. data/platform/shared/rubyext/GeoLocation.cpp +23 -0
  268. data/platform/shared/rubyext/GeoLocation.h +2 -0
  269. data/platform/shared/rubyext/RhoRuby.cpp +31 -0
  270. data/platform/shared/rubyext/RhoRuby.h +32 -0
  271. data/platform/shared/rubyext/System.cpp +14 -3
  272. data/platform/shared/rubyext/WebView.h +21 -0
  273. data/platform/shared/sync/ClientRegister.cpp +23 -28
  274. data/platform/shared/sync/ClientRegister.h +6 -2
  275. data/platform/shared/sync/ISyncProtocol.h +29 -0
  276. data/platform/shared/sync/SyncEngine.cpp +450 -190
  277. data/platform/shared/sync/SyncEngine.h +28 -38
  278. data/platform/shared/sync/SyncNotify.cpp +43 -41
  279. data/platform/shared/sync/SyncNotify.h +7 -7
  280. data/platform/shared/sync/SyncProtocol_3.h +86 -0
  281. data/platform/shared/sync/SyncSource.cpp +535 -371
  282. data/platform/shared/sync/SyncSource.h +48 -55
  283. data/platform/shared/sync/SyncThread.cpp +59 -103
  284. data/platform/shared/sync/SyncThread.h +10 -23
  285. data/platform/shared/unzip/unzip.cpp +3 -2
  286. data/platform/shared/unzip/unzip.h +5 -1
  287. data/platform/shared/wtl80/include/atlapp.h +10 -10
  288. data/platform/wm/RhoLib/RhoLib.vcproj +32 -0
  289. data/platform/wm/build/build_inf.js +40 -3
  290. data/platform/wm/build/wm.rake +95 -9
  291. data/platform/wm/rhodes/Alert.cpp +4 -0
  292. data/platform/wm/rhodes/DateTimePicker.cpp +183 -0
  293. data/platform/wm/rhodes/DateTimePicker.h +100 -0
  294. data/platform/wm/rhodes/MainWindow.cpp +222 -209
  295. data/platform/wm/rhodes/MainWindow.h +28 -35
  296. data/platform/wm/rhodes/Rhodes.cpp +20 -60
  297. data/platform/wm/rhodes/Rhodes.rc +41 -7
  298. data/platform/wm/rhodes/Utils.cpp +65 -0
  299. data/platform/wm/rhodes/Utils.h +9 -0
  300. data/platform/wm/rhodes/camera/Camera.cpp +2 -2
  301. data/platform/wm/rhodes/menubar.cpp +2 -33
  302. data/platform/wm/rhodes/menubar.h +0 -14
  303. data/platform/wm/rhodes/resource.h +13 -11
  304. data/platform/wm/rhodes/rho/net/NetRequest.cpp +16 -35
  305. data/platform/wm/rhodes/rho/net/NetRequest.h +8 -2
  306. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +264 -46
  307. data/platform/wm/rhodes/rho/net/NetRequestImpl.h +14 -4
  308. data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.cpp +1 -1
  309. data/platform/wm/rhodes/rho/rubyext/GeoLocationImpl.h +1 -1
  310. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +77 -4
  311. data/platform/wm/rhodes/rho/rubyext/WebView.cpp +63 -0
  312. data/platform/wm/rhodes/rhodes.vcproj +20 -66
  313. data/platform/wm/rhodes/stdafx.h +22 -0
  314. data/platform/wm/rubylib/rubylib.vcproj +4 -0
  315. data/platform/wm/syncengine/syncengine.vcproj +8 -0
  316. data/platform/wm/tools/detool.sln +66 -0
  317. data/platform/wm/tools/detool/DEMComInterface.tlb +0 -0
  318. data/platform/wm/tools/detool/ReadMe.txt +33 -0
  319. data/platform/wm/tools/detool/detool.cpp +559 -0
  320. data/platform/wm/tools/detool/detool.h +5 -0
  321. data/platform/wm/tools/detool/detool.vcproj +233 -0
  322. data/platform/wm/tools/detool/stdafx.cpp +8 -0
  323. data/platform/wm/tools/detool/stdafx.h +15 -0
  324. data/platform/wm/tools/detool/targetver.h +24 -0
  325. data/platform/wm/tools/rhosetup/ReadMe.txt +41 -0
  326. data/platform/wm/tools/rhosetup/rhosetup.cpp +52 -0
  327. data/platform/wm/tools/rhosetup/rhosetup.vcproj +641 -0
  328. data/platform/wm/tools/rhosetup/stdafx.cpp +8 -0
  329. data/platform/wm/tools/rhosetup/stdafx.h +59 -0
  330. data/rakefile.rb +33 -10
  331. data/res/build-tools/db/syncdb.schema +25 -23
  332. data/res/build-tools/db/syncdb.triggers +1 -1
  333. data/res/build-tools/detool.exe +0 -0
  334. data/res/build-tools/rhosetup.dll +0 -0
  335. data/res/generators/rhogen.rb +27 -22
  336. data/res/generators/templates/application/app/Settings/controller.rb +3 -1
  337. data/res/generators/templates/application/app/Settings/home.bb.erb +17 -0
  338. data/res/generators/templates/application/app/Settings/home.erb +21 -12
  339. data/res/generators/templates/application/app/Settings/index.bb.erb +32 -0
  340. data/res/generators/templates/application/app/Settings/index.erb +44 -15
  341. data/res/generators/templates/application/app/Settings/login.bb.erb +35 -0
  342. data/res/generators/templates/application/app/Settings/login.erb +29 -30
  343. data/res/generators/templates/application/app/Settings/reset.bb.erb +15 -0
  344. data/res/generators/templates/application/app/Settings/reset.erb +16 -13
  345. data/res/generators/templates/application/app/Settings/wait.bb.erb +3 -0
  346. data/res/generators/templates/application/app/Settings/wait.erb +4 -4
  347. data/res/generators/templates/application/app/application.rb +8 -0
  348. data/res/generators/templates/application/app/helpers/browser_helper.rb +13 -0
  349. data/res/generators/templates/application/app/index.bb.erb +26 -0
  350. data/res/generators/templates/application/app/index.erb +21 -12
  351. data/res/generators/templates/application/app/layout.erb +9 -11
  352. data/res/generators/templates/application/public/css/android.css +285 -0
  353. data/res/generators/templates/application/public/css/blackberry.css +85 -78
  354. data/res/generators/templates/application/public/css/iphone.css +286 -296
  355. data/res/generators/templates/application/public/css/webkit.css +34 -0
  356. data/res/generators/templates/application/public/css/windows_mobile.css +208 -0
  357. data/res/generators/templates/application/public/icons/Read me first - license.txt +14 -0
  358. data/res/generators/templates/application/public/icons/about.png +0 -0
  359. data/res/generators/templates/application/public/icons/airplane.png +0 -0
  360. data/res/generators/templates/application/public/icons/baby.png +0 -0
  361. data/res/generators/templates/application/public/icons/badge.png +0 -0
  362. data/res/generators/templates/application/public/icons/bandaid.png +0 -0
  363. data/res/generators/templates/application/public/icons/bar-chart.png +0 -0
  364. data/res/generators/templates/application/public/icons/battery.png +0 -0
  365. data/res/generators/templates/application/public/icons/beaker.png +0 -0
  366. data/res/generators/templates/application/public/icons/beaker2.png +0 -0
  367. data/res/generators/templates/application/public/icons/beermug.png +0 -0
  368. data/res/generators/templates/application/public/icons/bird.png +0 -0
  369. data/res/generators/templates/application/public/icons/book.png +0 -0
  370. data/res/generators/templates/application/public/icons/bookmark.png +0 -0
  371. data/res/generators/templates/application/public/icons/brightness.png +0 -0
  372. data/res/generators/templates/application/public/icons/bug.png +0 -0
  373. data/res/generators/templates/application/public/icons/cabinet.png +0 -0
  374. data/res/generators/templates/application/public/icons/calendar.png +0 -0
  375. data/res/generators/templates/application/public/icons/camera.png +0 -0
  376. data/res/generators/templates/application/public/icons/changeName.rb +22 -0
  377. data/res/generators/templates/application/public/icons/chat2.png +0 -0
  378. data/res/generators/templates/application/public/icons/chicken.png +0 -0
  379. data/res/generators/templates/application/public/icons/clock.png +0 -0
  380. data/res/generators/templates/application/public/icons/cloud.png +0 -0
  381. data/res/generators/templates/application/public/icons/coffee.png +0 -0
  382. data/res/generators/templates/application/public/icons/compass.png +0 -0
  383. data/res/generators/templates/application/public/icons/contrast.png +0 -0
  384. data/res/generators/templates/application/public/icons/dashboard.png +0 -0
  385. data/res/generators/templates/application/public/icons/display.png +0 -0
  386. data/res/generators/templates/application/public/icons/dogpaw.png +0 -0
  387. data/res/generators/templates/application/public/icons/download.png +0 -0
  388. data/res/generators/templates/application/public/icons/dumbbell.png +0 -0
  389. data/res/generators/templates/application/public/icons/ekg.png +0 -0
  390. data/res/generators/templates/application/public/icons/envelope.png +0 -0
  391. data/res/generators/templates/application/public/icons/equalizer.png +0 -0
  392. data/res/generators/templates/application/public/icons/eye.png +0 -0
  393. data/res/generators/templates/application/public/icons/film-roll.png +0 -0
  394. data/res/generators/templates/application/public/icons/flag.png +0 -0
  395. data/res/generators/templates/application/public/icons/fork-and-knife.png +0 -0
  396. data/res/generators/templates/application/public/icons/fuel.png +0 -0
  397. data/res/generators/templates/application/public/icons/gameplan.png +0 -0
  398. data/res/generators/templates/application/public/icons/gear.png +0 -0
  399. data/res/generators/templates/application/public/icons/gear2.png +0 -0
  400. data/res/generators/templates/application/public/icons/gift.png +0 -0
  401. data/res/generators/templates/application/public/icons/heart.png +0 -0
  402. data/res/generators/templates/application/public/icons/house.png +0 -0
  403. data/res/generators/templates/application/public/icons/inbox.png +0 -0
  404. data/res/generators/templates/application/public/icons/index-cards.png +0 -0
  405. data/res/generators/templates/application/public/icons/iphone.png +0 -0
  406. data/res/generators/templates/application/public/icons/ipod.png +0 -0
  407. data/res/generators/templates/application/public/icons/key.png +0 -0
  408. data/res/generators/templates/application/public/icons/lifebuoy.png +0 -0
  409. data/res/generators/templates/application/public/icons/lightbulb.png +0 -0
  410. data/res/generators/templates/application/public/icons/line-chart.png +0 -0
  411. data/res/generators/templates/application/public/icons/location.png +0 -0
  412. data/res/generators/templates/application/public/icons/lock.png +0 -0
  413. data/res/generators/templates/application/public/icons/loopback.png +0 -0
  414. data/res/generators/templates/application/public/icons/magnifying-glass.png +0 -0
  415. data/res/generators/templates/application/public/icons/map-marker.png +0 -0
  416. data/res/generators/templates/application/public/icons/map.png +0 -0
  417. data/res/generators/templates/application/public/icons/medical-bag.png +0 -0
  418. data/res/generators/templates/application/public/icons/medical.png +0 -0
  419. data/res/generators/templates/application/public/icons/microphone.png +0 -0
  420. data/res/generators/templates/application/public/icons/movie1.png +0 -0
  421. data/res/generators/templates/application/public/icons/movie2.png +0 -0
  422. data/res/generators/templates/application/public/icons/network.png +0 -0
  423. data/res/generators/templates/application/public/icons/note.png +0 -0
  424. data/res/generators/templates/application/public/icons/outlet.png +0 -0
  425. data/res/generators/templates/application/public/icons/palette.png +0 -0
  426. data/res/generators/templates/application/public/icons/paperclip.png +0 -0
  427. data/res/generators/templates/application/public/icons/phone.png +0 -0
  428. data/res/generators/templates/application/public/icons/photos.png +0 -0
  429. data/res/generators/templates/application/public/icons/piano.png +0 -0
  430. data/res/generators/templates/application/public/icons/picture-frame.png +0 -0
  431. data/res/generators/templates/application/public/icons/pill.png +0 -0
  432. data/res/generators/templates/application/public/icons/pin.png +0 -0
  433. data/res/generators/templates/application/public/icons/pinetree.png +0 -0
  434. data/res/generators/templates/application/public/icons/planet.png +0 -0
  435. data/res/generators/templates/application/public/icons/puzzle.png +0 -0
  436. data/res/generators/templates/application/public/icons/radar.png +0 -0
  437. data/res/generators/templates/application/public/icons/redo.png +0 -0
  438. data/res/generators/templates/application/public/icons/refresh.png +0 -0
  439. data/res/generators/templates/application/public/icons/runner.png +0 -0
  440. data/res/generators/templates/application/public/icons/shoebox.png +0 -0
  441. data/res/generators/templates/application/public/icons/shopping-bag.png +0 -0
  442. data/res/generators/templates/application/public/icons/shopping-cart.png +0 -0
  443. data/res/generators/templates/application/public/icons/shuffle.png +0 -0
  444. data/res/generators/templates/application/public/icons/signpost.png +0 -0
  445. data/res/generators/templates/application/public/icons/skull-n-crossbones.png +0 -0
  446. data/res/generators/templates/application/public/icons/skull.png +0 -0
  447. data/res/generators/templates/application/public/icons/sliders.png +0 -0
  448. data/res/generators/templates/application/public/icons/spraycan.png +0 -0
  449. data/res/generators/templates/application/public/icons/squiggle.png +0 -0
  450. data/res/generators/templates/application/public/icons/star.png +0 -0
  451. data/res/generators/templates/application/public/icons/stopwatch.png +0 -0
  452. data/res/generators/templates/application/public/icons/suitcase.png +0 -0
  453. data/res/generators/templates/application/public/icons/tag.png +0 -0
  454. data/res/generators/templates/application/public/icons/tags.png +0 -0
  455. data/res/generators/templates/application/public/icons/target.png +0 -0
  456. data/res/generators/templates/application/public/icons/testtube.png +0 -0
  457. data/res/generators/templates/application/public/icons/thermometer.png +0 -0
  458. data/res/generators/templates/application/public/icons/toolbox.png +0 -0
  459. data/res/generators/templates/application/public/icons/trophy.png +0 -0
  460. data/res/generators/templates/application/public/icons/tshirt.png +0 -0
  461. data/res/generators/templates/application/public/icons/tv.png +0 -0
  462. data/res/generators/templates/application/public/icons/umbrella.png +0 -0
  463. data/res/generators/templates/application/public/icons/walk.png +0 -0
  464. data/res/generators/templates/application/public/icons/weather.png +0 -0
  465. data/res/generators/templates/application/public/icons/widescreen.png +0 -0
  466. data/res/generators/templates/application/public/icons/wineglass.png +0 -0
  467. data/res/generators/templates/application/public/icons/zap.png +0 -0
  468. data/res/generators/templates/application/public/images/android/btn_check_off.png +0 -0
  469. data/res/generators/templates/application/public/images/android/btn_check_on.png +0 -0
  470. data/res/generators/templates/application/public/images/android/btn_radio_off.png +0 -0
  471. data/res/generators/templates/application/public/images/android/btn_radio_on.png +0 -0
  472. data/res/generators/templates/application/public/images/android/ic_menu_more.png +0 -0
  473. data/res/generators/templates/application/public/images/iphone/disclosure.png +0 -0
  474. data/res/generators/templates/application/public/images/iphone/disclosure_detail.png +0 -0
  475. data/res/generators/templates/application/public/images/iphone/radiobutton.png +0 -0
  476. data/res/generators/templates/application/public/images/iphone/select.png +0 -0
  477. data/res/generators/templates/application/public/images/iphone/switch.png +0 -0
  478. data/res/generators/templates/application/public/images/listArrow.png +0 -0
  479. data/res/generators/templates/application/public/images/listArrowDown.png +0 -0
  480. data/res/generators/templates/model/controller.rb +2 -0
  481. data/res/generators/templates/model/edit.bb.erb +24 -0
  482. data/res/generators/templates/model/edit.erb +21 -25
  483. data/res/generators/templates/model/index.bb.erb +21 -0
  484. data/res/generators/templates/model/index.erb +28 -14
  485. data/res/generators/templates/model/new.bb.erb +24 -0
  486. data/res/generators/templates/model/new.erb +20 -20
  487. data/res/generators/templates/model/show.bb.erb +21 -0
  488. data/res/generators/templates/model/show.erb +15 -15
  489. data/rhobuild.yml +37 -0
  490. data/rhodes.gemspec +1 -1
  491. data/spec/framework_spec/app/Account/config.rb +57 -1
  492. data/spec/framework_spec/app/Case/config.rb +1 -1
  493. data/spec/framework_spec/app/Customer/config.rb +1 -1
  494. data/spec/framework_spec/app/Product/config.rb +15 -1
  495. data/spec/framework_spec/app/spec/fixtures/object_values.txt +90 -90
  496. data/spec/framework_spec/app/spec/pagination/fixtures/object_values.txt +91 -91
  497. data/spec/framework_spec/app/spec/rho_spec.rb +1 -1
  498. data/spec/framework_spec/app/spec/rhom_object_spec.rb +47 -28
  499. data/spec/framework_spec/app/spec/rhom_spec.rb +8 -8
  500. data/spec/framework_spec/app/spec/spec_helper.rb +13 -5
  501. data/spec/framework_spec/app/spec_runner.rb +5 -4
  502. data/spec/framework_spec/public/css/base.css +0 -1
  503. data/spec/framework_spec/public/css/iphone.css +0 -1
  504. data/spec/framework_spec/rhoconfig.txt +3 -1
  505. metadata +220 -37
  506. data/platform/bb/rhodes/src/rhomobile/WebView.java +0 -90
  507. data/platform/iphone/Classes/BarItem.h +0 -27
  508. data/platform/iphone/Classes/BarItem.m +0 -32
  509. data/platform/iphone/Classes/JSString.h +0 -12
  510. data/platform/iphone/Classes/JSString.m +0 -7
  511. data/platform/iphone/Classes/RhoRunnerAppDelegate.h +0 -48
  512. data/platform/iphone/Classes/RhoRunnerAppDelegate.m +0 -617
  513. data/platform/iphone/Classes/Server/ServerHost.h +0 -81
  514. data/platform/iphone/Classes/Server/ServerHost.m +0 -597
  515. data/platform/iphone/Classes/Server/WebViewUrl.h +0 -13
  516. data/platform/iphone/Classes/Server/WebViewUrl.m +0 -8
  517. data/platform/iphone/Classes/TabBarDelegate.h +0 -39
  518. data/platform/iphone/Classes/TabBarDelegate.m +0 -151
  519. data/platform/iphone/Classes/Utils/unzip.cpp +0 -4328
  520. data/platform/iphone/Classes/Utils/unzip.h +0 -234
  521. data/platform/iphone/Classes/WebViewController.h +0 -59
  522. data/platform/iphone/Classes/WebViewController.m +0 -472
  523. data/platform/wm/rhodes/GetURLDialog.cpp +0 -64
  524. data/platform/wm/rhodes/GetURLDialog.h +0 -39
  525. data/res/generators/templates/application/public/css/base.css +0 -39
  526. data/res/generators/templates/application/public/css/rho.css +0 -3
  527. data/res/generators/templates/application/public/css/xhtml.css +0 -114
  528. data/spec/framework_spec/app/Question/config.rb +0 -3
  529. data/spec/generator_spec/source_generator_spec.rb +0 -27
@@ -6,12 +6,10 @@
6
6
  #include "common/RhoThread.h"
7
7
  #include "net/INetRequest.h"
8
8
  #include "common/IRhoClassFactory.h"
9
- #if defined(RHO_HTTPD_COMMON_IMPL)
10
9
  #include "net/HttpServer.h"
11
- #endif
12
10
  #include "rubyext/GeoLocation.h"
13
11
  #include "SplashScreen.h"
14
-
12
+ #include "AppMenu.h"
15
13
  #undef DEFAULT_LOGCATEGORY
16
14
  #define DEFAULT_LOGCATEGORY "RhodesApp"
17
15
 
@@ -35,25 +33,27 @@ private:
35
33
  common::CAutoPtr<net::INetRequest> m_NetRequest;
36
34
 
37
35
  String m_strListeningPorts;
38
- #if !defined(RHO_HTTPD_COMMON_IMPL)
39
- struct shttpd_ctx * m_shttpdCtx;
40
- #else
41
36
  common::CAutoPtr<net::CHttpServer> m_httpServer;
42
- #endif
43
- String m_strRhoRootPath, m_strLoadingPagePath, m_strLoadingPngPath, m_strBlobsDirPath;
37
+ String m_strRhoRootPath, m_strLoadingPagePath, m_strLoadingPngPath, m_strBlobsDirPath, m_strDBDirPath;
44
38
  String m_strHomeUrl, m_strStartUrl, m_strOptionsUrl, m_strRhobundleReloadUrl, m_strFirstStartUrl;
45
39
  String m_strRhoMessage;
46
40
 
47
41
  int m_currentTabIndex;
48
42
  String m_currentUrls[5];
49
43
 
50
- common::CMutex m_mxViewMenuItems;
51
- Hashtable<String,String> m_hashViewMenuItems;
52
44
  String m_strAppBackUrl;
53
45
  Vector<ICallbackObject*> m_arCallbackObjects;
54
46
  rubyext::CGeoLocation m_oGeoLocation;
55
47
  CSplashScreen m_oSplashScreen;
56
48
 
49
+ common::CMutex m_mxPushCallback;
50
+ String m_strPushCallback, m_strPushCallbackParams;
51
+
52
+ common::CMutex m_mxScreenRotationCallback;
53
+ String m_strScreenRotationCallback, m_strScreenRotationCallbackParams;
54
+
55
+ CAppMenu m_oAppMenu;
56
+
57
57
  public:
58
58
  ~CRhodesApp(void);
59
59
 
@@ -66,6 +66,7 @@ public:
66
66
  String canonicalizeRhoUrl(const String& strUrl) ;
67
67
  void keepLastVisitedUrl(String strUrl);
68
68
  void navigateToUrl( const String& strUrl);
69
+ void navigateBack();
69
70
 
70
71
  const String& getRhobundleReloadUrl();
71
72
  const String& getStartUrl();
@@ -77,17 +78,20 @@ public:
77
78
  const String& getLoadingPngPath(){return m_strLoadingPngPath;}
78
79
  const String& getLoadingPagePath(){return m_strLoadingPagePath; }
79
80
  const String& getBlobsDirPath(){return m_strBlobsDirPath; }
81
+ const String& getDBDirPath(){return m_strDBDirPath; }
82
+ String resolveDBFilesPath(const String& strFilePath);
80
83
  const String& getRhoRootPath(){return m_strRhoRootPath;}
81
84
 
82
85
  const String& getAppBackUrl(){return m_strAppBackUrl;}
86
+ void setAppBackUrl(const String& url);
83
87
 
84
88
  void callCameraCallback(String strCallbackUrl, const String& strImagePath, const String& strError, boolean bCancel );
85
89
  void callDateTimeCallback(String strCallbackUrl, long lDateTime, const char* szData, int bCancel );
86
90
  void callAppActiveCallback(boolean bActive);
91
+ void callPopupCallback(String strCallbackUrl, const String &id, const String &title);
87
92
 
88
- void setViewMenu(unsigned long valMenu);
89
- void addViewMenuItem( const String& strLabel, const String& strLink );
90
-
93
+ CAppMenu& getAppMenu (void) { return m_oAppMenu; }
94
+
91
95
  boolean sendLog();
92
96
 
93
97
  String addCallbackObject(ICallbackObject* pCallbackObject, String strName);
@@ -99,6 +103,15 @@ public:
99
103
  CSplashScreen& getSplashScreen(){return m_oSplashScreen;}
100
104
 
101
105
  void runCallbackInThread(const String& strCallback, const String& strBody);
106
+
107
+ void setPushNotification(String strUrl, String strParams );
108
+ boolean callPushCallback(String strData);
109
+
110
+ void setScreenRotationNotification(String strUrl, String strParams);
111
+ void callScreenRotationCallback(int width, int height, int degrees);
112
+
113
+ void loadUrl(String url);
114
+
102
115
  private:
103
116
  virtual void run();
104
117
 
@@ -140,6 +153,8 @@ void rho_http_redirect(void* httpContext, const char* szUrl);
140
153
  void rho_http_senderror(void* httpContext, int nError, const char* szMsg);
141
154
  void rho_http_sendresponse(void* httpContext, const char* szBody);
142
155
  int rho_http_snprintf(char *buf, size_t buflen, const char *fmt, ...);
156
+
157
+ void rho_rhodesapp_navigate_back();
143
158
 
144
159
  char* rho_http_normalizeurl(const char* szUrl);
145
160
  void rho_http_free(void* data);
@@ -152,6 +167,12 @@ unsigned long rho_rhodesapp_GetCallbackObject(int nIndex);
152
167
 
153
168
  void rho_rhodesapp_setViewMenu(unsigned long valMenu);
154
169
  const char* rho_rhodesapp_getappbackurl();
170
+
171
+ int rho_rhodesapp_callPushCallback(const char* szData);
172
+
173
+ void rho_rhodesapp_callScreenRotationCallback(int width, int height, int degrees);
174
+ void rho_rhodesapp_callPopupCallback(const char *strCallbackUrl, const char *id, const char *title);
175
+
155
176
  int rho_conf_send_log();
156
177
 
157
178
  int rho_base64_encode(const char *src, int srclen, char *dst);
@@ -159,6 +180,8 @@ int rho_base64_decode(const char *src, int srclen, char *dst);
159
180
 
160
181
  void rho_net_request(const char *url);
161
182
 
183
+ void rho_rhodesapp_load_url(const char *url);
184
+
162
185
  #ifdef __cplusplus
163
186
  };
164
187
  #endif //__cplusplus
@@ -44,7 +44,7 @@ void CSplashScreen::init()
44
44
  CTokenizer stringtokenizer(strSplash, ";");
45
45
  while (stringtokenizer.hasMoreTokens()) {
46
46
  String tok = stringtokenizer.nextToken();
47
- tok = trim(tok);
47
+ tok = String_trim(tok);
48
48
  if (tok.length() == 0) {
49
49
  continue;
50
50
  }
@@ -55,7 +55,7 @@ void CSplashScreen::init()
55
55
  if (nEq>=0)
56
56
  {
57
57
  String val = tok.substr(nEq+1);
58
- val = trim(val);
58
+ val = String_trim(val);
59
59
  if ( val.length() > 0 )
60
60
  convertFromStringA( val.c_str(), m_nDelay );
61
61
  }
@@ -11,10 +11,10 @@ namespace common{
11
11
  #define convertFromString convertFromStringA
12
12
  #define convertToString convertToStringA
13
13
  #endif
14
-
14
+ */
15
15
  template<typename T> inline void convertFromStringW( const wchar_t* szValue, T& value ){ value = szValue; }
16
16
  template<typename T> inline StringW convertToStringW( const T& value ){ return value; }
17
- */
17
+
18
18
 
19
19
  template<typename T> inline void convertFromStringA( const char* szValue, T& value ){ value = szValue; }
20
20
  template<typename T> inline String convertToStringA( const T& value ){ return value; }
@@ -70,7 +70,7 @@ inline StringW convertToStringW( const String& str )
70
70
 
71
71
  /*template<> inline void convertFromStringA<StringW>( const char* szValue, StringW& value ){ value = StringW(szValue); }
72
72
  template<> inline String convertToStringA<StringW>( const StringW& value ){ return String(value); }
73
-
73
+ */
74
74
  #define CONVERT_TYPE_W( Type, Fmt ) \
75
75
  template<> inline void convertFromStringW<Type>( const wchar_t* szValue, Type& value )\
76
76
  { swscanf( szValue, Fmt, &value ); }\
@@ -80,7 +80,6 @@ template<> inline StringW convertToStringW<Type>( const Type& value )\
80
80
  swprintf( buf, Fmt, value );\
81
81
  return StringW(buf);\
82
82
  }
83
- */
84
83
 
85
84
  #define CONVERT_TYPE_A( Type, Fmt ) \
86
85
  template<> inline void convertFromStringA<Type>( const char* szValue, Type& value )\
@@ -91,21 +90,21 @@ template<> inline String convertToStringA<Type>( const Type& value )\
91
90
  sprintf( buf, Fmt, value );\
92
91
  return String(buf);\
93
92
  }
94
- /*
93
+
94
+ #if defined(OS_WINDOWS) || defined (OS_WINCE)
95
95
  CONVERT_TYPE_W( unsigned int, L"%u" );
96
96
  CONVERT_TYPE_W( int, L"%d" );
97
- CONVERT_TYPE_W( unsigned long, L"%u" );
97
+ CONVERT_TYPE_W( unsigned long, L"%lu" );
98
98
  CONVERT_TYPE_W( long, L"%d" );
99
- CONVERT_TYPE_W( wchar_t, L"%c" );
99
+ CONVERT_TYPE_W( wchar_t, L"%lc" );
100
100
  CONVERT_TYPE_W( char, L"%c" );
101
101
  CONVERT_TYPE_W( unsigned char, L"%c" );
102
- CONVERT_TYPE_W( short, L"%d" );
102
+ CONVERT_TYPE_W( short, L"%hd" );
103
103
  //CONVERT_TYPE_W( unsigned short, _T("%u") );
104
104
  CONVERT_TYPE_W( bool, L"%d" );
105
105
  CONVERT_TYPE_W( float, L"%f" );
106
- CONVERT_TYPE_W( double, L"%f" );
107
- */
108
-
106
+ CONVERT_TYPE_W( double, L"%lf" );
107
+ #endif
109
108
  CONVERT_TYPE_A( unsigned int, "%u" );
110
109
  CONVERT_TYPE_A( int, "%d" );
111
110
  CONVERT_TYPE_A( unsigned long, "%lu" );
@@ -1,16 +1,10 @@
1
1
  #include "common/rhoparams.h"
2
-
3
2
  #include "common/RhoPort.h"
4
3
 
5
- #include "logging/RhoLog.h"
6
-
7
4
  #ifdef __cplusplus
8
5
  extern "C" {
9
6
  #endif
10
7
 
11
- #undef DEFAULT_LOGCATEGORY
12
- #define DEFAULT_LOGCATEGORY "Alert"
13
-
14
8
  rho_param *rho_param_str(char *s)
15
9
  {
16
10
  rho_param *ret = (rho_param *)malloc(sizeof(rho_param));
@@ -59,7 +59,7 @@
59
59
 
60
60
  extern void * rho_ssl_create_storage();
61
61
  extern void rho_ssl_free_storage(void *);
62
- extern CURLcode rho_ssl_connect(int sockfd, int nonblocking, int *done, void *storage);
62
+ extern CURLcode rho_ssl_connect(int sockfd, int nonblocking, int *done, int ssl_verify_peer, void *storage);
63
63
  extern void rho_ssl_shutdown(void *storage);
64
64
  extern ssize_t rho_ssl_send(const void *mem, size_t len, void *storage);
65
65
  extern ssize_t rho_ssl_recv(char *buf, size_t size, int *wouldblock, void *storage);
@@ -84,6 +84,7 @@ static CURLcode rhossl_connect_common(struct connectdata *conn, int sockindex,
84
84
  {
85
85
  curl_socket_t sockfd = conn->sock[sockindex];
86
86
  struct ssl_connect_data *connssl = &conn->ssl[sockindex];
87
+ struct ssl_config_data *config = &conn->ssl_config;
87
88
  CURLcode retcode;
88
89
 
89
90
  if (connssl->state == ssl_connection_complete)
@@ -92,7 +93,7 @@ static CURLcode rhossl_connect_common(struct connectdata *conn, int sockindex,
92
93
  connssl->storage = rho_ssl_create_storage();
93
94
 
94
95
  int idone = *done;
95
- retcode = rho_ssl_connect(sockfd, nonblocking, &idone, connssl->storage);
96
+ retcode = rho_ssl_connect(sockfd, nonblocking, &idone, config->verifypeer, connssl->storage);
96
97
  if (retcode)
97
98
  return retcode;
98
99
 
@@ -698,12 +698,7 @@ CURLcode Curl_init_userdefined(struct UserDefined *set)
698
698
  * libcurl 7.10 introduced SSL verification *by default*! This needs to be
699
699
  * switched off unless wanted.
700
700
  */
701
- #ifdef OS_ANDROID
702
- /* TODO: implement binding with system CA storage and rollback this setting to default */
703
- set->ssl.verifypeer = FALSE;
704
- #else
705
701
  set->ssl.verifypeer = TRUE;
706
- #endif
707
702
  set->ssl.verifyhost = 2;
708
703
  set->ssh_auth_types = CURLSSH_AUTH_DEFAULT; /* defaults to any auth
709
704
  type */
@@ -10,6 +10,7 @@
10
10
  namespace rho{
11
11
  namespace db{
12
12
  IMPLEMENT_LOGCLASS(CDBAdapter,"DB");
13
+ HashtablePtr<String,CDBAdapter*> CDBAdapter::m_mapDBPartitions;
13
14
 
14
15
  using namespace rho::common;
15
16
 
@@ -21,19 +22,27 @@ static int onDBBusy(void* data,int nTry)
21
22
 
22
23
  void SyncBlob_DeleteCallback(sqlite3_context* dbContext, int nArgs, sqlite3_value** ppArgs)
23
24
  {
24
- char* type = NULL;
25
- if ( nArgs < 4 )
25
+ if ( nArgs < 3 )
26
26
  return;
27
27
 
28
- type = (char*)sqlite3_value_text(*(ppArgs+1));
29
- if ( type && strcmp(type,"blob.file") == 0 )
28
+ CDBAttrManager& attrMgr = CDBAdapter::getDBByHandle(sqlite3_context_db_handle(dbContext)).getAttrMgr();
29
+
30
+ char* szAttrName = (char*)sqlite3_value_text(*(ppArgs+2));
31
+ int nSrcID = sqlite3_value_int(*(ppArgs+1));
32
+ if ( attrMgr.isBlobAttr(nSrcID, szAttrName) )
30
33
  {
31
- String strFilePath = RHODESAPP().getRhoRootPath()+ "apps";
32
- strFilePath += (char*)sqlite3_value_text(*(ppArgs));
34
+ String strFilePath = RHODESAPP().resolveDBFilesPath((char*)sqlite3_value_text(*(ppArgs)));
33
35
  CRhoFile::deleteFile(strFilePath.c_str());
34
36
  }
35
37
 
36
- sync::CSyncThread::getDBAdapter().getAttrMgr().remove( sqlite3_value_int(*(ppArgs+2)), (char*)sqlite3_value_text(*(ppArgs+3)) );
38
+ attrMgr.remove( nSrcID, szAttrName );
39
+ }
40
+
41
+ void SyncBlob_DeleteSchemaCallback(sqlite3_context* dbContext, int nArgs, sqlite3_value** ppArgs)
42
+ {
43
+ CDBAttrManager& attrMgr = CDBAdapter::getDBByHandle(sqlite3_context_db_handle(dbContext)).getAttrMgr();
44
+ //TODO: SyncBlob_DeleteSchemaCallback
45
+ //TODO: add to reset - set callback
37
46
  }
38
47
 
39
48
  void SyncBlob_InsertCallback(sqlite3_context* dbContext, int nArgs, sqlite3_value** ppArgs)
@@ -41,7 +50,7 @@ void SyncBlob_InsertCallback(sqlite3_context* dbContext, int nArgs, sqlite3_valu
41
50
  if ( nArgs < 2 )
42
51
  return;
43
52
 
44
- sync::CSyncThread::getDBAdapter().getAttrMgr().add( sqlite3_value_int(*(ppArgs)), (char*)sqlite3_value_text(*(ppArgs+1)) );
53
+ CDBAdapter::getDBByHandle(sqlite3_context_db_handle(dbContext)).getAttrMgr().add( sqlite3_value_int(*(ppArgs)), (char*)sqlite3_value_text(*(ppArgs+1)) );
45
54
  }
46
55
 
47
56
  boolean CDBAdapter::checkDbError(int rc)
@@ -96,8 +105,11 @@ void CDBAdapter::open (String strDbPath, String strVer, boolean bTemp)
96
105
  if ( !bExist )
97
106
  createSchema();
98
107
 
99
- sqlite3_create_function( m_dbHandle, "rhoOnDeleteObjectRecord", 4, SQLITE_ANY, 0,
108
+ sqlite3_create_function( m_dbHandle, "rhoOnDeleteObjectRecord", 3, SQLITE_ANY, 0,
100
109
  SyncBlob_DeleteCallback, 0, 0 );
110
+ sqlite3_create_function( m_dbHandle, "rhoOnDeleteRecord", 1, SQLITE_ANY, 0,
111
+ SyncBlob_DeleteSchemaCallback, 0, 0 );
112
+
101
113
  sqlite3_create_function( m_dbHandle, "rhoOnInsertObjectRecord", 2, SQLITE_ANY, 0,
102
114
  SyncBlob_InsertCallback, 0, 0 );
103
115
 
@@ -287,7 +299,33 @@ sqlite3_stmt* CDBAdapter::createInsertStatement(rho::db::CDBResult& res, const S
287
299
  return stInsert;
288
300
  }
289
301
 
290
- void CDBAdapter::destroy_table(String strTable)
302
+ static boolean destroyTableName(String tableName, const rho::Vector<rho::String>& arIncludeTables, const rho::Vector<rho::String>& arExcludeTables )
303
+ {
304
+ int i;
305
+ for (i = 0; i < (int)arExcludeTables.size(); i++ )
306
+ {
307
+ if ( arExcludeTables.elementAt(i).compare(tableName) == 0 )
308
+ return false;
309
+ }
310
+
311
+ for (i = 0; i < (int)arIncludeTables.size(); i++ )
312
+ {
313
+ if ( arIncludeTables.elementAt(i).compare(tableName) == 0 )
314
+ return true;
315
+ }
316
+
317
+ return arIncludeTables.size()==0;
318
+ }
319
+
320
+ boolean CDBAdapter::isTableExist(String strTableName)
321
+ {
322
+ Vector<String> vecTables;
323
+
324
+ DBResult( res , executeSQL( "SELECT name FROM sqlite_master WHERE type='table' AND name=?", strTableName.c_str() ) );
325
+ return !res.isEnd();
326
+ }
327
+
328
+ void CDBAdapter::destroy_tables(const rho::Vector<rho::String>& arIncludeTables, const rho::Vector<rho::String>& arExcludeTables)
291
329
  {
292
330
  getAttrMgr().reset(*this);
293
331
  CFilePath oFilePath(m_strDbPath);
@@ -311,7 +349,7 @@ void CDBAdapter::destroy_table(String strTable)
311
349
  for ( int i = 0; i < (int)vecTables.size(); i++ )
312
350
  {
313
351
  String tableName = vecTables.elementAt(i);
314
- if ( tableName.compare(strTable)==0 )
352
+ if (destroyTableName(tableName, arIncludeTables, arExcludeTables) )
315
353
  continue;
316
354
 
317
355
  String strSelect = "SELECT * from " + tableName;
@@ -344,10 +382,11 @@ void CDBAdapter::destroy_table(String strTable)
344
382
  open( dbOldName, m_strDbVer, false );
345
383
  }
346
384
 
347
- void CDBAdapter::setInitialSyncDB(String fDataName)
385
+ void CDBAdapter::setBulkSyncDB(String fDataName)
348
386
  {
349
387
  CDBAdapter db;
350
388
  db.open( fDataName, m_strDbVer, true );
389
+ db.createTriggers();
351
390
 
352
391
  db.startTransaction();
353
392
 
@@ -370,13 +409,26 @@ void CDBAdapter::setInitialSyncDB(String fDataName)
370
409
  }
371
410
  //copy sources
372
411
  {
373
- DBResult( res, executeSQL("SELECT name, source_url,priority,session from sources") );
412
+ String tableName = "sources";
413
+ String strSelect = "SELECT * from " + tableName;
414
+ DBResult( res , executeSQL( strSelect.c_str() ) );
415
+ String strInsert = "";
416
+ int rc = 0;
374
417
  for ( ; !res.isEnd(); res.next() )
375
418
  {
376
- String strName = res.getStringByIdx(0);
377
-
378
- db.executeSQL("UPDATE sources SET source_url=?,priority=?,session=? where name=?",
379
- res.getStringByIdx(1), res.getIntByIdx(2), res.getStringByIdx(3), strName );
419
+ String strName = res.getStringByIdx(1);
420
+ DBResult( res2, db.executeSQL("SELECT name from sources where name=?", strName) );
421
+ if (!res2.isEnd())
422
+ continue;
423
+
424
+ sqlite3_stmt* stInsert = createInsertStatement(res, tableName, db, strInsert);
425
+
426
+ if (stInsert)
427
+ {
428
+ rc = sqlite3_step(stInsert);
429
+ checkDbError(rc);
430
+ sqlite3_finalize(stInsert);
431
+ }
380
432
  }
381
433
  }
382
434
 
@@ -393,95 +445,71 @@ void CDBAdapter::setInitialSyncDB(String fDataName)
393
445
  open( dbOldName, m_strDbVer, false );
394
446
  }
395
447
 
396
- /*
397
- static const char* g_szDbSchema =
398
- "CREATE TABLE client_info ("
399
- " client_id VARCHAR(255) PRIMARY KEY,"
400
- " token VARCHAR(255) default NULL,"
401
- " token_sent int default 0,"
402
- " reset int default 0,"
403
- " port VARCHAR(10) default NULL,"
404
- " last_sync_success VARCHAR(100) default NULL);"
405
- "CREATE TABLE object_values ("
406
- " id INTEGER PRIMARY KEY,"
407
- " source_id int default NULL,"
408
- " attrib varchar(255) default NULL,"
409
- " object varchar(255) default NULL,"
410
- " value text default NULL,"
411
- " attrib_type varchar(255) default NULL);"
412
- "CREATE TABLE changed_values ("
413
- " id INTEGER PRIMARY KEY,"
414
- " source_id int default NULL,"
415
- " attrib varchar(255) default NULL,"
416
- " object varchar(255) default NULL,"
417
- " value text default NULL,"
418
- " attrib_type varchar(255) default NULL,"
419
- " update_type varchar(255) default NULL,"
420
- " sent int default 0,"
421
- " main_id INTEGER default 0);"
422
- "CREATE TABLE sources ("
423
- //" id INTEGER PRIMARY KEY,"
424
- " source_url VARCHAR(255) PRIMARY KEY,"
425
- " source_id int,"
426
- " name VARCHAR(255) default NULL,"
427
- " token INTEGER default NULL,"
428
- " priority INTEGER,"
429
- " session VARCHAR(255) default NULL,"
430
- " last_updated int default 0,"
431
- " last_inserted_size int default 0,"
432
- " last_deleted_size int default 0,"
433
- " last_sync_duration int default 0,"
434
- " last_sync_success int default 0,"
435
- " backend_refresh_time int default 0,"
436
- " source_attribs varchar default NULL);"
437
- //"CREATE INDEX by_attrib_utype on object_values (attrib,update_type);"
438
- //"CREATE INDEX by_src_type ON object_values (source_id, attrib_type, object);"
439
- //"CREATE INDEX by_src_utype on object_values (source_id,update_type);"
440
- //"CREATE INDEX by_type ON object_values (attrib_type);"
441
- "CREATE INDEX by_src_id on object_values (source_id);"
442
- "CREATE UNIQUE INDEX by_src_object ON object_values (object, attrib, source_id);"
443
- "CREATE INDEX by_src_value ON object_values (attrib, source_id, value);"
444
- "CREATE TRIGGER rhodeleteTrigger BEFORE DELETE ON object_values FOR EACH ROW "
445
- "BEGIN "
446
- "SELECT rhoOnDeleteObjectRecord(OLD.value, OLD.attrib_type, OLD.source_id, OLD.attrib );"
447
- "END;"
448
- ";"
449
- "CREATE TRIGGER rhoinsertTrigger AFTER INSERT ON object_values FOR EACH ROW "
450
- "BEGIN "
451
- "SELECT rhoOnInsertObjectRecord( NEW.source_id, NEW.attrib );"
452
- "END;"
453
- ";";
454
- */
455
-
456
448
  void CDBAdapter::createSchema()
457
449
  {
458
450
  char* errmsg = 0;
459
451
  CFilePath oPath(m_strDbPath);
460
452
 
461
- String strSqlScript, strSqlTriggers;
453
+ String strSqlScript;
462
454
  CRhoFile::loadTextFile(oPath.changeBaseName("syncdb.schema").c_str(), strSqlScript);
463
- CRhoFile::loadTextFile(oPath.changeBaseName("syncdb.triggers").c_str(), strSqlTriggers);
464
455
 
465
456
  if ( strSqlScript.length() == 0 )
466
457
  {
467
458
  LOG(ERROR)+"createSchema failed. Cannot read schema file: " + strSqlScript;
468
459
  return;
469
460
  }
461
+
462
+ int rc = sqlite3_exec(m_dbHandle, strSqlScript.c_str(), NULL, NULL, &errmsg);
463
+
464
+ if ( rc != SQLITE_OK )
465
+ LOG(ERROR)+"createSchema failed. Error code: " + rc + ";Message: " + (errmsg ? errmsg : "");
466
+
467
+ if ( errmsg )
468
+ sqlite3_free(errmsg);
469
+
470
+ if ( rc == SQLITE_OK )
471
+ createTriggers();
472
+ }
473
+
474
+ void CDBAdapter::createTriggers()
475
+ {
476
+ char* errmsg = 0;
477
+ CFilePath oPath(m_strDbPath);
478
+
479
+ String strSqlTriggers;
480
+ CRhoFile::loadTextFile(oPath.changeBaseName("syncdb.triggers").c_str(), strSqlTriggers);
481
+
470
482
  if ( strSqlTriggers.length() == 0 )
471
483
  {
472
484
  LOG(ERROR)+"createSchema failed. Cannot read triggers file: " + strSqlTriggers;
473
485
  return;
474
486
  }
475
487
 
476
- int rc = sqlite3_exec(m_dbHandle, (strSqlScript+strSqlTriggers).c_str(), NULL, NULL, &errmsg);
488
+ int rc = sqlite3_exec(m_dbHandle, strSqlTriggers.c_str(), NULL, NULL, &errmsg);
477
489
 
478
490
  if ( rc != SQLITE_OK )
479
- LOG(ERROR)+"createSchema failed. Error code: " + rc + ";Message: " + (errmsg ? errmsg : "");
491
+ LOG(ERROR)+"createTriggers failed. Error code: " + rc + ";Message: " + (errmsg ? errmsg : "");
480
492
 
481
493
  if ( errmsg )
482
494
  sqlite3_free(errmsg);
483
495
  }
484
496
 
497
+ void CDBAdapter::createDeleteTrigger(const String& strTable)
498
+ {
499
+ String strTrigger = String("CREATE TRIGGER rhodeleteSchemaTrigger BEFORE DELETE ON ") + strTable + " FOR EACH ROW "
500
+ " BEGIN "
501
+ " SELECT rhoOnDeleteRecord( OLD );"
502
+ " END;"
503
+ ";";
504
+ char* errmsg = 0;
505
+ //TODO: createDeleteTrigger
506
+ /* int rc = sqlite3_exec(m_dbHandle, strTrigger.c_str(), NULL, NULL, &errmsg);
507
+
508
+ if ( rc != SQLITE_OK )
509
+ LOG(ERROR)+"createTriggers failed. Error code: " + rc + ";Message: " + (errmsg ? errmsg : "");
510
+ */
511
+ }
512
+
485
513
  void CDBAdapter::close()
486
514
  {
487
515
  for (Hashtable<String,sqlite3_stmt*>::iterator it = m_mapStatements.begin(); it != m_mapStatements.end(); ++it )
@@ -496,6 +524,22 @@ void CDBAdapter::close()
496
524
  m_strDbPath = String();
497
525
  }
498
526
 
527
+ int CDBAdapter::prepareSqlStatement(const char* szSql, int nByte, sqlite3_stmt **ppStmt)
528
+ {
529
+ int rc = SQLITE_OK;
530
+ sqlite3_stmt* st = m_mapStatements.get(szSql);
531
+ if ( st != null )
532
+ *ppStmt = st;
533
+ else
534
+ {
535
+ rc = sqlite3_prepare_v2(m_dbHandle, szSql, nByte, ppStmt, NULL);
536
+ if ( rc == SQLITE_OK )
537
+ m_mapStatements.put(szSql, st);
538
+ }
539
+
540
+ return rc;
541
+ }
542
+
499
543
  DBResultPtr CDBAdapter::prepareStatement( const char* szSt )
500
544
  {
501
545
  if ( m_dbHandle == null )
@@ -522,6 +566,31 @@ DBResultPtr CDBAdapter::prepareStatement( const char* szSt )
522
566
  return res;
523
567
  }
524
568
 
569
+ DBResultPtr CDBAdapter::executeSQLReportNonUniqueEx( const char* szSt, Vector<String>& arValues )
570
+ {
571
+ DBResultPtr res = prepareStatement(szSt);
572
+ if ( res->getStatement() == null )
573
+ return res;
574
+
575
+ for (int i = 0; i < (int)arValues.size(); i++ )
576
+ bind(res->getStatement(), i+1, arValues.elementAt(i));
577
+
578
+ res->setReportNonUnique(true);
579
+ return executeStatement(res);
580
+ }
581
+
582
+ DBResultPtr CDBAdapter::executeSQLEx( const char* szSt, Vector<String>& arValues)
583
+ {
584
+ DBResultPtr res = prepareStatement(szSt);
585
+ if ( res->getStatement() == null )
586
+ return res;
587
+
588
+ for (int i = 0; i < (int)arValues.size(); i++ )
589
+ bind(res->getStatement(), i+1, arValues.elementAt(i));
590
+
591
+ return executeStatement(res);
592
+ }
593
+
525
594
  DBResultPtr CDBAdapter::executeSQL( const char* szSt)
526
595
  {
527
596
  DBResultPtr res = prepareStatement(szSt);
@@ -611,7 +680,161 @@ void CDBAdapter::rollback()
611
680
  Unlock();
612
681
  }
613
682
 
683
+ /*static*/ void CDBAdapter::closeAll()
684
+ {
685
+ for (Hashtable<String,CDBAdapter*>::iterator it = m_mapDBPartitions.begin(); it != m_mapDBPartitions.end(); ++it )
686
+ it->second->close();
687
+ }
688
+
689
+ /*static*/ void CDBAdapter::initAttrManager()
690
+ {
691
+ for (Hashtable<String,CDBAdapter*>::iterator it = m_mapDBPartitions.begin(); it != m_mapDBPartitions.end(); ++it )
692
+ it->second->getAttrMgr().loadBlobAttrs(*(it->second));
693
+ }
694
+
695
+ /*static*/ CDBAdapter& CDBAdapter::getUserDB()
696
+ {
697
+ return *getDBPartitions().get("user");
698
+ }
699
+
700
+ /*static*/ CDBAdapter& CDBAdapter::getDB(const char* szPartition)
701
+ {
702
+ return *getDBPartitions().get(szPartition);
703
+ }
704
+
705
+ /*static*/ boolean CDBAdapter::isAnyInsideTransaction()
706
+ {
707
+ for (Hashtable<String,CDBAdapter*>::iterator it = m_mapDBPartitions.begin(); it != m_mapDBPartitions.end(); ++it )
708
+ {
709
+ if ( it->second->isInsideTransaction() )
710
+ return true;
711
+ }
712
+
713
+ return false;
714
+ }
715
+
716
+ /*static*/ db::CDBAdapter& CDBAdapter::getDBByHandle(sqlite3* db)
717
+ {
718
+ for (Hashtable<String,CDBAdapter*>::iterator it = m_mapDBPartitions.begin(); it != m_mapDBPartitions.end(); ++it )
719
+ {
720
+ if ( it->second->getDbHandle() == db )
721
+ return *(it->second);
722
+ }
723
+
724
+ return *getDBPartitions().get("user");
725
+ }
726
+
727
+ }
728
+ }
729
+
730
+ extern "C" {
731
+ using namespace rho::db;
732
+
733
+ int rho_db_open(const char* szDBPath, const char* szDBPartition, void** ppDB)
734
+ {
735
+ CFilePath oPath(szDBPath);
736
+
737
+ CDBAdapter* pDB = CDBAdapter::getDBPartitions().get(szDBPartition);
738
+ if ( !pDB )
739
+ {
740
+ pDB = new CDBAdapter();
741
+ CDBAdapter::getDBPartitions().put(szDBPartition, pDB);
742
+ }
743
+
744
+ rho::String strVer = RhoRuby_getRhoDBVersion();
745
+ pDB->open(szDBPath,strVer, false);
746
+
747
+ *ppDB = pDB;
748
+ return 0;
749
+ }
750
+
751
+ int rho_db_startTransaction(void* pDB)
752
+ {
753
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
754
+ db.startTransaction();
755
+
756
+ //TODO: get error code from DBException
757
+ return 0;
758
+ }
759
+
760
+ int rho_db_commitTransaction(void* pDB)
761
+ {
762
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
763
+ db.endTransaction();
764
+ //TODO: get error code from DBException
765
+ return 0;
766
+ }
767
+
768
+ int rho_db_rollbackTransaction(void* pDB)
769
+ {
770
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
771
+ db.rollback();
772
+ //TODO: get error code from DBException
773
+ return 0;
774
+ }
775
+
776
+ int rho_db_is_ui_waitfordb(void* pDB)
777
+ {
778
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
779
+ return db.isUIWaitDB() ? 1 :0;
780
+ }
781
+
782
+ extern "C" void
783
+ string_iter(const char* szVal, void* par)
784
+ {
785
+ rho::Vector<rho::String>& ar = *((rho::Vector<rho::String>*)(par));
786
+ ar.addElement(szVal);
787
+ }
788
+
789
+ int rho_db_destroy_tables(void* pDB, unsigned long arInclude, unsigned long arExclude)
790
+ {
791
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
792
+
793
+ rho::Vector<rho::String> arIncludeTables;
794
+ rho_ruby_enum_strary(arInclude, string_iter, &arIncludeTables);
795
+
796
+ rho::Vector<rho::String> arExcludeTables;
797
+ rho_ruby_enum_strary(arExclude, string_iter, &arExcludeTables);
798
+
799
+ db.destroy_tables(arIncludeTables,arExcludeTables);
800
+ return 0;
801
+ }
802
+
803
+ void* rho_db_get_handle(void* pDB)
804
+ {
805
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
806
+ return db.getDbHandle();
807
+ }
808
+
809
+ int rho_db_prepare_statement(void* pDB, const char* szSql, int nByte, sqlite3_stmt **ppStmt)
810
+ {
811
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
812
+ return db.prepareSqlStatement(szSql, nByte, ppStmt);
813
+ }
814
+
815
+ void rho_db_lock(void* pDB)
816
+ {
817
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
818
+ db.Lock();
614
819
  }
820
+
821
+ void rho_db_unlock(void* pDB)
822
+ {
823
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
824
+ db.Unlock();
825
+ }
826
+
827
+ int rho_db_is_table_exist(void* pDB, const char* szTableName)
828
+ {
829
+ rho::db::CDBAdapter& db = *((rho::db::CDBAdapter*)pDB);
830
+ return db.isTableExist(szTableName) ? 1 : 0;
831
+ }
832
+
833
+ void rho_db_init_attr_manager()
834
+ {
835
+ rho::db::CDBAdapter::initAttrManager();
836
+ }
837
+
615
838
  }
616
839
 
617
840
  namespace rho{