rhodes 2.0.0.beta2 → 2.0.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (306) hide show
  1. data/LICENSE +2 -0
  2. data/Manifest.txt +27 -148
  3. data/Rakefile +49 -3
  4. data/lib/framework/builtinME.rb +6 -0
  5. data/lib/framework/rho/render.rb +13 -8
  6. data/lib/framework/rho/rho.rb +97 -43
  7. data/lib/framework/rho/rhoapplication.rb +8 -3
  8. data/lib/framework/rho/rhocontroller.rb +1 -1
  9. data/lib/framework/rhodes-framework.rb +1 -1
  10. data/lib/framework/rhodes.rb +1 -1
  11. data/lib/framework/rhoframework.rb +7 -22
  12. data/lib/framework/rhofsconnector.rb +1 -1
  13. data/lib/framework/rholang/localization_simplified.rb +2 -2
  14. data/lib/framework/rhom/rhom.rb +1 -0
  15. data/lib/framework/rhom/rhom_db_adapter.rb +2 -2
  16. data/lib/framework/rhom/rhom_model.rb +98 -0
  17. data/lib/framework/rhom/rhom_object_factory.rb +13 -12
  18. data/lib/rhodes.rb +1 -1
  19. data/platform/android/Rhodes/jni/include/{JNIRhodes.h → rhodes/JNIRhodes.h} +3 -54
  20. data/platform/android/Rhodes/jni/include/{RhoClassFactory.h → rhodes/RhoClassFactory.h} +0 -0
  21. data/platform/android/Rhodes/jni/include/{SystemInfoImpl.h → rhodes/SystemInfoImpl.h} +0 -0
  22. data/platform/android/Rhodes/jni/include/{details → rhodes/details}/rhojava.inc +1 -0
  23. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Logger.h +0 -0
  24. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoConf.h +0 -0
  25. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoLogConf.h +0 -0
  26. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_RhoMenu.h +0 -0
  27. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_Rhodes.h +0 -0
  28. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_SplashScreen.h +0 -0
  29. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_alert_Alert.h +0 -0
  30. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_camera_Camera.h +0 -0
  31. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_datetime_DateTimePicker.h +0 -0
  32. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_geolocation_GeoLocationImpl.h +0 -0
  33. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_RhoSocketImpl.h +0 -0
  34. data/platform/android/Rhodes/jni/include/{jni → rhodes/jni}/com_rhomobile_rhodes_socket_SSLImpl.h +0 -0
  35. data/platform/android/Rhodes/jni/include/{sslimpl.h → rhodes/sslimpl.h} +0 -0
  36. data/platform/android/Rhodes/jni/include/rhodes.h +59 -0
  37. data/platform/android/Rhodes/jni/src/RhoClassFactory.cpp +3 -3
  38. data/platform/android/Rhodes/jni/src/alert.cpp +2 -2
  39. data/platform/android/Rhodes/jni/src/callbacks.cpp +4 -3
  40. data/platform/android/Rhodes/jni/src/camera.cpp +2 -2
  41. data/platform/android/Rhodes/jni/src/datetimepicker.cpp +2 -2
  42. data/platform/android/Rhodes/jni/src/geolocation.cpp +2 -2
  43. data/platform/android/Rhodes/jni/src/logconf.cpp +2 -2
  44. data/platform/android/Rhodes/jni/src/logger.cpp +2 -2
  45. data/platform/android/Rhodes/jni/src/mapview.cpp +1 -1
  46. data/platform/android/Rhodes/jni/src/menu.cpp +2 -2
  47. data/platform/android/Rhodes/jni/src/nativebar.cpp +1 -1
  48. data/platform/android/Rhodes/jni/src/navbar.cpp +17 -3
  49. data/platform/android/Rhodes/jni/src/phonebook.cpp +1 -1
  50. data/platform/android/Rhodes/jni/src/rhoconf.cpp +2 -2
  51. data/platform/android/Rhodes/jni/src/rhodes.cpp +3 -3
  52. data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
  53. data/platform/android/Rhodes/jni/src/socketimpl.cpp +2 -2
  54. data/platform/android/Rhodes/jni/src/splashscreen.cpp +2 -2
  55. data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -3
  56. data/platform/android/Rhodes/jni/src/syncengine.cpp +2 -2
  57. data/platform/android/Rhodes/jni/src/webview.cpp +15 -12
  58. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeLibraries.java +11 -0
  59. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NavBar.java +52 -0
  60. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -2
  61. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +26 -28
  62. data/platform/android/build/RhodesSRC_build.files +21 -20
  63. data/platform/android/build/android.rake +69 -24
  64. data/platform/android/build/androidcommon.rb +17 -12
  65. data/platform/bb/build/bb.rake +23 -21
  66. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +5 -2
  67. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +6 -1
  68. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +9 -1
  69. data/platform/bb/rhodes/src/com/rho/rubyext/WebView.java +31 -2
  70. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +17 -6
  71. data/platform/bb/rhodes/src/rhomobile/Utilities.java +6 -0
  72. data/platform/iphone/Classes/AppManager/AppManager.m +16 -4
  73. data/platform/iphone/Classes/DateTime.h +5 -6
  74. data/platform/iphone/Classes/DateTimePicker.m +4 -18
  75. data/platform/iphone/Classes/DateTimePickerDelegate.h +7 -9
  76. data/platform/iphone/Classes/DateTimePickerDelegate.m +141 -152
  77. data/platform/iphone/Classes/Rhodes.h +6 -1
  78. data/platform/iphone/Classes/Rhodes.m +17 -43
  79. data/platform/iphone/Classes/SimpleMainView.h +1 -1
  80. data/platform/iphone/Classes/SimpleMainView.m +54 -4
  81. data/platform/iphone/Classes/WebView.m +17 -0
  82. data/platform/iphone/rbuild/iphone.rake +1 -0
  83. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +0 -45
  84. data/platform/shared/common/PosixThreadImpl.cpp +8 -0
  85. data/platform/shared/common/PosixThreadImpl.h +1 -0
  86. data/platform/shared/common/RhoThread.cpp +1 -0
  87. data/platform/shared/common/RhoThread.h +4 -2
  88. data/platform/shared/curl/include/curl/curl.h +4 -0
  89. data/platform/shared/db/DBAdapter.cpp +47 -60
  90. data/platform/shared/db/DBAdapter.h +6 -2
  91. data/platform/shared/net/AsyncHttp.cpp +27 -11
  92. data/platform/shared/net/AsyncHttp.h +3 -1
  93. data/platform/shared/net/CURLNetRequest.cpp +11 -10
  94. data/platform/shared/net/CURLNetRequest.h +6 -4
  95. data/platform/shared/net/HttpServer.cpp +11 -6
  96. data/platform/shared/ruby/ext/asynchttp/asynchttp.i +2 -2
  97. data/platform/shared/ruby/ext/asynchttp/asynchttp_wrap.c +22 -11
  98. data/platform/shared/ruby/ext/rho/rhoruby.c +2 -2
  99. data/platform/shared/ruby/ext/rho/rhosupport.c +23 -3
  100. data/platform/shared/ruby/ext/webview/webview.i +4 -0
  101. data/platform/shared/ruby/ext/webview/webview_wrap.c +39 -0
  102. data/platform/shared/ruby/re.c +8 -0
  103. data/platform/shared/ruby/string.c +1 -1
  104. data/platform/shared/rubyJVM/src/com/rho/IRhoRubyHelper.java +1 -0
  105. data/platform/shared/rubyJVM/src/com/rho/RhoClassFactory.java +6 -1
  106. data/platform/shared/rubyJVM/src/com/rho/RhoThread.java +3 -0
  107. data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +34 -0
  108. data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +40 -53
  109. data/platform/shared/rubyJVM/src/com/rho/net/AsyncHttp.java +32 -15
  110. data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +31 -17
  111. data/platform/shared/rubyJVM/src/com/rho/net/RhoConnection.java +3 -0
  112. data/platform/shared/rubyJVM/src/com/rho/sync/JSONArrayIterator.java +17 -0
  113. data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +158 -137
  114. data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +18 -17
  115. data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +10 -2
  116. data/platform/shared/rubyJVM/src/com/xruby/GeneratedMethods/RubyFile_Methods.java +6 -0
  117. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyFile.java +18 -3
  118. data/platform/shared/rubyJVM/src/j2me/io/File.java +37 -9
  119. data/platform/shared/sqlite/sqlite3.c +14613 -13016
  120. data/platform/shared/sqlite/sqlite3.h +1461 -1499
  121. data/platform/shared/sqlite/sqlite3ext.h +0 -2
  122. data/platform/shared/sync/ClientRegister.cpp +3 -3
  123. data/platform/shared/sync/ClientRegister.h +2 -1
  124. data/platform/shared/sync/SyncEngine.cpp +20 -8
  125. data/platform/shared/sync/SyncSource.cpp +12 -12
  126. data/platform/shared/sync/SyncSource.h +4 -4
  127. data/platform/shared/sync/SyncThread.cpp +8 -1
  128. data/platform/shared/tcmalloc/rhomem.h +3 -0
  129. data/platform/shared/tcmalloc/tcmalloc_.cpp +11 -0
  130. data/platform/wm/rhodes/Alert.cpp +148 -101
  131. data/platform/wm/rhodes/Alert.h +4 -1
  132. data/platform/wm/rhodes/AppManager.cpp +212 -72
  133. data/platform/wm/rhodes/AppManager.h +24 -3
  134. data/platform/wm/rhodes/DateTimePicker.cpp +23 -11
  135. data/platform/wm/rhodes/DateTimePicker.h +16 -5
  136. data/platform/wm/rhodes/MainWindow.cpp +22 -7
  137. data/platform/wm/rhodes/OkCancelModalDialog.h +63 -0
  138. data/platform/wm/rhodes/Rhodes.cpp +29 -17
  139. data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +128 -4
  140. data/platform/wm/rhodes/phonebook/NativeAddressBook.h +33 -3
  141. data/platform/wm/rhodes/resource.h +1 -1
  142. data/platform/wm/rhodes/rho/common/RhoClassFactory.cpp +5 -0
  143. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +136 -102
  144. data/platform/wm/rhodes/rho/net/NetRequestImpl.h +12 -5
  145. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +24 -10
  146. data/platform/wm/rhodes/rho/rubyext/WebView.cpp +6 -0
  147. data/platform/wm/rhodes/rhodes.vcproj +4 -0
  148. data/platform/wm/tools/detool/detool.cpp +17 -4
  149. data/rakefile.rb +49 -3
  150. data/res/build-tools/db/syncdb.schema +2 -2
  151. data/res/build-tools/detool.exe +0 -0
  152. data/res/generators/rhogen.rb +10 -10
  153. data/res/generators/templates/application/app/helpers/browser_helper.rb +9 -4
  154. data/res/generators/templates/application/app/index.bb.erb +5 -5
  155. data/res/generators/templates/application/build.yml +1 -0
  156. data/res/generators/templates/application/public/css/android.css +10 -8
  157. data/res/generators/templates/application/public/css/blackberry.css +40 -31
  158. data/res/generators/templates/application/public/css/iphone.css +4 -4
  159. data/res/generators/templates/application/public/css/webkit.css +7 -0
  160. data/res/generators/templates/application/public/css/windows_mobile.css +31 -27
  161. data/res/generators/templates/application/rhoconfig.txt +2 -2
  162. data/res/generators/templates/model/edit.bb.erb +2 -2
  163. data/res/generators/templates/model/index.bb.erb +6 -4
  164. data/res/generators/templates/model/model.rb +2 -1
  165. data/res/generators/templates/model/new.bb.erb +2 -2
  166. data/res/generators/templates/model/show.bb.erb +2 -2
  167. data/rhobuild.yml +37 -0
  168. data/rhodes.gemspec +1 -1
  169. data/spec/framework_spec/app/Account/account.rb +7 -0
  170. data/spec/framework_spec/app/Case/case.rb +6 -0
  171. data/spec/framework_spec/app/Customer/customer.rb +6 -0
  172. data/spec/framework_spec/app/Product/product.rb +9 -0
  173. data/spec/framework_spec/app/spec/rhom_object_spec.rb +1 -1
  174. data/spec/framework_spec/app/spec/syncengine_spec.rb +2 -1
  175. metadata +45 -151
  176. data/lib/build/manifest/createAppManifest.rb +0 -18
  177. data/lib/build/tasks/android.rake +0 -317
  178. data/lib/build/tasks/blackberry.rake +0 -355
  179. data/lib/build/tasks/common.rake +0 -62
  180. data/lib/build/tasks/iphone.rake +0 -108
  181. data/lib/build/tasks/linux.rake +0 -81
  182. data/lib/build/tasks/rhodes-build.rb +0 -11
  183. data/lib/build/tasks/rspec.rake +0 -20
  184. data/lib/build/tasks/symbian.rake +0 -202
  185. data/lib/build/tasks/wm.rake +0 -166
  186. data/lib/framework/ServeME.rb +0 -7
  187. data/platform/bb/build/MANIFEST.MF +0 -12
  188. data/platform/iphone/Classes/DateTimePicker.h +0 -17
  189. data/res/generators/templates/application/public/icons/Read me first - license.txt +0 -14
  190. data/res/generators/templates/application/public/icons/about.png +0 -0
  191. data/res/generators/templates/application/public/icons/airplane.png +0 -0
  192. data/res/generators/templates/application/public/icons/baby.png +0 -0
  193. data/res/generators/templates/application/public/icons/badge.png +0 -0
  194. data/res/generators/templates/application/public/icons/bandaid.png +0 -0
  195. data/res/generators/templates/application/public/icons/bar-chart.png +0 -0
  196. data/res/generators/templates/application/public/icons/battery.png +0 -0
  197. data/res/generators/templates/application/public/icons/beaker.png +0 -0
  198. data/res/generators/templates/application/public/icons/beaker2.png +0 -0
  199. data/res/generators/templates/application/public/icons/beermug.png +0 -0
  200. data/res/generators/templates/application/public/icons/bird.png +0 -0
  201. data/res/generators/templates/application/public/icons/book.png +0 -0
  202. data/res/generators/templates/application/public/icons/bookmark.png +0 -0
  203. data/res/generators/templates/application/public/icons/brightness.png +0 -0
  204. data/res/generators/templates/application/public/icons/bug.png +0 -0
  205. data/res/generators/templates/application/public/icons/cabinet.png +0 -0
  206. data/res/generators/templates/application/public/icons/calendar.png +0 -0
  207. data/res/generators/templates/application/public/icons/camera.png +0 -0
  208. data/res/generators/templates/application/public/icons/changeName.rb +0 -22
  209. data/res/generators/templates/application/public/icons/chat2.png +0 -0
  210. data/res/generators/templates/application/public/icons/chicken.png +0 -0
  211. data/res/generators/templates/application/public/icons/clock.png +0 -0
  212. data/res/generators/templates/application/public/icons/cloud.png +0 -0
  213. data/res/generators/templates/application/public/icons/coffee.png +0 -0
  214. data/res/generators/templates/application/public/icons/compass.png +0 -0
  215. data/res/generators/templates/application/public/icons/contrast.png +0 -0
  216. data/res/generators/templates/application/public/icons/dashboard.png +0 -0
  217. data/res/generators/templates/application/public/icons/display.png +0 -0
  218. data/res/generators/templates/application/public/icons/dogpaw.png +0 -0
  219. data/res/generators/templates/application/public/icons/download.png +0 -0
  220. data/res/generators/templates/application/public/icons/dumbbell.png +0 -0
  221. data/res/generators/templates/application/public/icons/ekg.png +0 -0
  222. data/res/generators/templates/application/public/icons/envelope.png +0 -0
  223. data/res/generators/templates/application/public/icons/equalizer.png +0 -0
  224. data/res/generators/templates/application/public/icons/eye.png +0 -0
  225. data/res/generators/templates/application/public/icons/film-roll.png +0 -0
  226. data/res/generators/templates/application/public/icons/flag.png +0 -0
  227. data/res/generators/templates/application/public/icons/fork-and-knife.png +0 -0
  228. data/res/generators/templates/application/public/icons/fuel.png +0 -0
  229. data/res/generators/templates/application/public/icons/gameplan.png +0 -0
  230. data/res/generators/templates/application/public/icons/gear.png +0 -0
  231. data/res/generators/templates/application/public/icons/gear2.png +0 -0
  232. data/res/generators/templates/application/public/icons/gift.png +0 -0
  233. data/res/generators/templates/application/public/icons/heart.png +0 -0
  234. data/res/generators/templates/application/public/icons/house.png +0 -0
  235. data/res/generators/templates/application/public/icons/inbox.png +0 -0
  236. data/res/generators/templates/application/public/icons/index-cards.png +0 -0
  237. data/res/generators/templates/application/public/icons/iphone.png +0 -0
  238. data/res/generators/templates/application/public/icons/ipod.png +0 -0
  239. data/res/generators/templates/application/public/icons/key.png +0 -0
  240. data/res/generators/templates/application/public/icons/lifebuoy.png +0 -0
  241. data/res/generators/templates/application/public/icons/lightbulb.png +0 -0
  242. data/res/generators/templates/application/public/icons/line-chart.png +0 -0
  243. data/res/generators/templates/application/public/icons/location.png +0 -0
  244. data/res/generators/templates/application/public/icons/lock.png +0 -0
  245. data/res/generators/templates/application/public/icons/loopback.png +0 -0
  246. data/res/generators/templates/application/public/icons/magnifying-glass.png +0 -0
  247. data/res/generators/templates/application/public/icons/map-marker.png +0 -0
  248. data/res/generators/templates/application/public/icons/map.png +0 -0
  249. data/res/generators/templates/application/public/icons/medical-bag.png +0 -0
  250. data/res/generators/templates/application/public/icons/medical.png +0 -0
  251. data/res/generators/templates/application/public/icons/microphone.png +0 -0
  252. data/res/generators/templates/application/public/icons/movie1.png +0 -0
  253. data/res/generators/templates/application/public/icons/movie2.png +0 -0
  254. data/res/generators/templates/application/public/icons/network.png +0 -0
  255. data/res/generators/templates/application/public/icons/note.png +0 -0
  256. data/res/generators/templates/application/public/icons/outlet.png +0 -0
  257. data/res/generators/templates/application/public/icons/palette.png +0 -0
  258. data/res/generators/templates/application/public/icons/paperclip.png +0 -0
  259. data/res/generators/templates/application/public/icons/phone.png +0 -0
  260. data/res/generators/templates/application/public/icons/photos.png +0 -0
  261. data/res/generators/templates/application/public/icons/piano.png +0 -0
  262. data/res/generators/templates/application/public/icons/picture-frame.png +0 -0
  263. data/res/generators/templates/application/public/icons/pill.png +0 -0
  264. data/res/generators/templates/application/public/icons/pin.png +0 -0
  265. data/res/generators/templates/application/public/icons/pinetree.png +0 -0
  266. data/res/generators/templates/application/public/icons/planet.png +0 -0
  267. data/res/generators/templates/application/public/icons/puzzle.png +0 -0
  268. data/res/generators/templates/application/public/icons/radar.png +0 -0
  269. data/res/generators/templates/application/public/icons/redo.png +0 -0
  270. data/res/generators/templates/application/public/icons/refresh.png +0 -0
  271. data/res/generators/templates/application/public/icons/runner.png +0 -0
  272. data/res/generators/templates/application/public/icons/shoebox.png +0 -0
  273. data/res/generators/templates/application/public/icons/shopping-bag.png +0 -0
  274. data/res/generators/templates/application/public/icons/shopping-cart.png +0 -0
  275. data/res/generators/templates/application/public/icons/shuffle.png +0 -0
  276. data/res/generators/templates/application/public/icons/signpost.png +0 -0
  277. data/res/generators/templates/application/public/icons/skull-n-crossbones.png +0 -0
  278. data/res/generators/templates/application/public/icons/skull.png +0 -0
  279. data/res/generators/templates/application/public/icons/sliders.png +0 -0
  280. data/res/generators/templates/application/public/icons/spraycan.png +0 -0
  281. data/res/generators/templates/application/public/icons/squiggle.png +0 -0
  282. data/res/generators/templates/application/public/icons/star.png +0 -0
  283. data/res/generators/templates/application/public/icons/stopwatch.png +0 -0
  284. data/res/generators/templates/application/public/icons/suitcase.png +0 -0
  285. data/res/generators/templates/application/public/icons/tag.png +0 -0
  286. data/res/generators/templates/application/public/icons/tags.png +0 -0
  287. data/res/generators/templates/application/public/icons/target.png +0 -0
  288. data/res/generators/templates/application/public/icons/testtube.png +0 -0
  289. data/res/generators/templates/application/public/icons/thermometer.png +0 -0
  290. data/res/generators/templates/application/public/icons/toolbox.png +0 -0
  291. data/res/generators/templates/application/public/icons/trophy.png +0 -0
  292. data/res/generators/templates/application/public/icons/tshirt.png +0 -0
  293. data/res/generators/templates/application/public/icons/tv.png +0 -0
  294. data/res/generators/templates/application/public/icons/umbrella.png +0 -0
  295. data/res/generators/templates/application/public/icons/walk.png +0 -0
  296. data/res/generators/templates/application/public/icons/weather.png +0 -0
  297. data/res/generators/templates/application/public/icons/widescreen.png +0 -0
  298. data/res/generators/templates/application/public/icons/wineglass.png +0 -0
  299. data/res/generators/templates/application/public/icons/zap.png +0 -0
  300. data/res/generators/templates/application/public/js/jquery-1.2.6.min.js +0 -32
  301. data/res/generators/templates/model/config.rb +0 -3
  302. data/res/generators/templates/spec/app/spec/webview_spec.rb +0 -5
  303. data/spec/framework_spec/app/Account/config.rb +0 -59
  304. data/spec/framework_spec/app/Case/config.rb +0 -3
  305. data/spec/framework_spec/app/Customer/config.rb +0 -3
  306. data/spec/framework_spec/app/Product/config.rb +0 -17
@@ -14,8 +14,6 @@
14
14
  ** an SQLite instance. Shared libraries that intend to be loaded
15
15
  ** as extensions by SQLite should #include this file instead of
16
16
  ** sqlite3.h.
17
- **
18
- ** @(#) $Id: sqlite3ext.h,v 1.25 2008/10/12 00:27:54 shane Exp $
19
17
  */
20
18
  #ifndef _SQLITE3EXT_H_
21
19
  #define _SQLITE3EXT_H_
@@ -23,13 +23,13 @@ CClientRegister* CClientRegister::m_pInstance = 0;
23
23
  return m_pInstance;
24
24
  }
25
25
 
26
- /*static void CClientRegister::Destroy()
26
+ /*static*/ void CClientRegister::Destroy()
27
27
  {
28
28
  if ( m_pInstance )
29
29
  delete m_pInstance;
30
30
 
31
31
  m_pInstance = 0;
32
- }*/
32
+ }
33
33
 
34
34
  CClientRegister::CClientRegister(common::IRhoClassFactory* factory,const char* device_pin) : CRhoThread(factory)
35
35
  {
@@ -56,7 +56,7 @@ CClientRegister::~CClientRegister()
56
56
  void CClientRegister::run()
57
57
  {
58
58
  LOG(INFO)+"ClientRegister start";
59
- while(true)
59
+ while(!isStopped())
60
60
  {
61
61
  if ( CSyncThread::getInstance() != null )
62
62
  {
@@ -28,7 +28,7 @@ class CClientRegister : public common::CRhoThread
28
28
  unsigned int m_nPollInterval;
29
29
  public:
30
30
  static CClientRegister* Create(common::IRhoClassFactory* factory,const char* device_pin);
31
- //static void Destroy();
31
+ static void Destroy();
32
32
  static CClientRegister* getInstance() { return m_pInstance; }
33
33
 
34
34
  virtual void run();
@@ -55,6 +55,7 @@ extern "C" {
55
55
  #endif //__cplusplus
56
56
 
57
57
  void rho_clientregister_create(const char* szDevicePin);
58
+ void rho_clientregister_destroy();
58
59
 
59
60
  #ifdef __cplusplus
60
61
  };
@@ -140,10 +140,10 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
140
140
  CSyncSource* pSrc = findSourceByName(arSources.elementAt(i));
141
141
  if ( pSrc != null )
142
142
  {
143
- strQuery += "&sources[][name]=" + pSrc->getName();
143
+ strQuery += "&source[][name]=" + pSrc->getName();
144
144
 
145
145
  if ( !pSrc->isTokenFromDB() && pSrc->getToken() > 1 )
146
- strQuery += "&sources[][token]=" + convertToStringA(pSrc->getToken());
146
+ strQuery += "&source[][token]=" + convertToStringA(pSrc->getToken());
147
147
  }
148
148
  }
149
149
 
@@ -212,7 +212,12 @@ void CSyncEngine::doSearch(rho::Vector<rho::String>& arSources, String strParams
212
212
  }
213
213
 
214
214
  if ( isContinueSync() )
215
- getNotify().fireSyncNotification(null, true, RhoRuby.ERR_NONE, RhoRuby.getMessageText("sync_completed"));
215
+ {
216
+ CSyncSource& src = *m_sources.elementAt(getStartSource());
217
+ src.m_bIsSearch = true;
218
+
219
+ getNotify().fireSyncNotification(&src, true, RhoRuby.ERR_NONE, RhoRuby.getMessageText("sync_completed"));
220
+ }
216
221
  else if ( nErrCode != 0 )
217
222
  {
218
223
  CSyncSource& src = *m_sources.elementAt(getStartSource());
@@ -298,7 +303,7 @@ void CSyncEngine::loadAllSources()
298
303
  m_sources.clear();
299
304
  m_arPartitions.clear();
300
305
 
301
- DBResult( res, getUserDB().executeSQL("SELECT source_id,sync_type,name, partition from sources ORDER BY priority") );
306
+ DBResult( res, getUserDB().executeSQL("SELECT source_id,sync_type,name, partition from sources ORDER BY sync_priority") );
302
307
  for ( ; !res.isEnd(); res.next() )
303
308
  {
304
309
  String strShouldSync = res.getStringByIdx(1);
@@ -372,7 +377,7 @@ boolean CSyncEngine::resetClientIDByNet(const String& strClientID)//throws Excep
372
377
 
373
378
  NetResponse( resp, getNet().pullData(getProtocol().getClientResetUrl(strClientID), this) );
374
379
 
375
- /* processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"priority\":\"0\","
380
+ /* processServerSources("{\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"sync_priority\":\"0\","
376
381
  "\"schema_version\":\"7.0\",\"schema\":{"
377
382
  "\"columns\":[\'brand\',\'created_at\',\'name\',\'price\',\'quantity\',\'sku\',\'updated_at\']"*/
378
383
  /* "\"sql\":\"CREATE TABLE Product ( "
@@ -409,7 +414,7 @@ String CSyncEngine::requestClientIDByNet()
409
414
  {
410
415
  const char* szData = resp.getCharData();
411
416
  /*
412
- "{\"client\":{\"client_id\":\"vasy\"},\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"priority\":\"0\","
417
+ "{\"client\":{\"client_id\":\"vasy\"},\"server_sources\":[{\"name\":\"Product\",\"partition\":\"application\",\"source_id\":\"2\",\"sync_priority\":\"0\","
413
418
  "\"schema\":{\"version\":\"1.0\","
414
419
  "\"sql\":\"CREATE TABLE Product ( "
415
420
  "brand varchar default NULL,"
@@ -441,6 +446,8 @@ String CSyncEngine::requestClientIDByNet()
441
446
 
442
447
  void CSyncEngine::doBulkSync()//throws Exception
443
448
  {
449
+ // processServerSources(String("{\"partition\":\"") + "application" + "\"}");
450
+
444
451
  if ( !RHOCONF().isExist("bulksync_state") )
445
452
  return;
446
453
 
@@ -517,9 +524,13 @@ void CSyncEngine::loadBulkPartition(const String& strPartition )
517
524
 
518
525
  getNotify().fireBulkSyncNotification(false, "download", strPartition, RhoRuby.ERR_NONE);
519
526
 
520
- String fDataName = makeBulkDataFileName(/*"data/bbook/bbook_1264475432.data"*/strDataUrl, dbPartition.getDBPath(), "");//, "_bulk");
527
+ String fDataName = makeBulkDataFileName(strDataUrl, dbPartition.getDBPath(), "");
521
528
  String strZip = ".rzip";
522
- String strSqlDataUrl = /*"http://204.236.220.203/data/bbook/bbook_1264475432.data" + strZip;*/getHostFromUrl(serverUrl) + strDataUrl+strZip;
529
+ String hostName = getHostFromUrl(serverUrl);
530
+ if (hostName.c_str()[hostName.length()-1] == '/') {
531
+ hostName = hostName.substr(0,hostName.length()-1);
532
+ }
533
+ String strSqlDataUrl = hostName + strDataUrl+strZip;
523
534
  LOG(INFO) + "Bulk sync: download data from server: " + strSqlDataUrl;
524
535
  {
525
536
  NetResponse( resp1, getNet().pullFile(strSqlDataUrl, fDataName+strZip, this, null) );
@@ -551,6 +562,7 @@ void CSyncEngine::loadBulkPartition(const String& strPartition )
551
562
  getNotify().fireBulkSyncNotification(false, "change_db", strPartition, RhoRuby.ERR_NONE);
552
563
 
553
564
  dbPartition.setBulkSyncDB(fDataName);
565
+ processServerSources(String("{\"partition\":\"") + strPartition + "\"}");
554
566
 
555
567
  LOG(INFO) + "Bulk sync: end change db";
556
568
  getNotify().fireBulkSyncNotification(false, "", strPartition, RhoRuby.ERR_NONE);
@@ -66,7 +66,7 @@ CSyncSource::CSyncSource(int id, const String& strName, const String& strSyncTyp
66
66
  m_nErrCode = RhoRuby.ERR_NONE;
67
67
  m_bIsSearch = false;
68
68
 
69
- DBResult( res, db.executeSQL("SELECT token,links from sources WHERE source_id=?", m_nID) );
69
+ DBResult( res, db.executeSQL("SELECT token,associations from sources WHERE source_id=?", m_nID) );
70
70
  if ( !res.isEnd() )
71
71
  {
72
72
  m_token = res.getUInt64ByIdx(0);
@@ -78,15 +78,15 @@ CSyncSource::CSyncSource(int id, const String& strName, const String& strSyncTyp
78
78
  }
79
79
 
80
80
  m_bSchemaSource = db.isTableExist(m_strName);
81
- parseLinks(res.getStringByIdx(1));
81
+ parseAssociations(res.getStringByIdx(1));
82
82
  }
83
83
 
84
- void CSyncSource::parseLinks(const String& strLinks)
84
+ void CSyncSource::parseAssociations(const String& strAssociations)
85
85
  {
86
- if (strLinks.length() == 0 )
86
+ if (strAssociations.length() == 0 )
87
87
  return;
88
88
 
89
- CTokenizer oTokenizer( strLinks, "," );
89
+ CTokenizer oTokenizer( strAssociations, "," );
90
90
 
91
91
  String strSrcName = "";
92
92
  while (oTokenizer.hasMoreTokens())
@@ -97,7 +97,7 @@ void CSyncSource::parseLinks(const String& strLinks)
97
97
 
98
98
  if ( strSrcName.length() > 0 )
99
99
  {
100
- m_hashLinks.put(strSrcName, tok);
100
+ m_hashAssociations.put(strSrcName, tok);
101
101
  strSrcName = "";
102
102
  }else
103
103
  strSrcName = tok;
@@ -529,17 +529,17 @@ void CSyncSource::processSyncCommand(const String& strCmd, CJSONEntry oCmdEntry)
529
529
  }
530
530
  }
531
531
 
532
- void CSyncSource::processLinks(const String& strOldObject, const String& strNewObject)
532
+ void CSyncSource::processAssociations(const String& strOldObject, const String& strNewObject)
533
533
  {
534
- for ( Hashtable<String,String>::iterator it = m_hashLinks.begin(); it != m_hashLinks.end(); ++it )
534
+ for ( Hashtable<String,String>::iterator it = m_hashAssociations.begin(); it != m_hashAssociations.end(); ++it )
535
535
  {
536
536
  CSyncSource* pSrc = getSync().findSourceByName(it->first);
537
537
  if ( pSrc != null )
538
- pSrc->updateLink(strOldObject, strNewObject, it->second);
538
+ pSrc->updateAssociation(strOldObject, strNewObject, it->second);
539
539
  }
540
540
  }
541
541
 
542
- void CSyncSource::updateLink(const String& strOldObject, const String& strNewObject, const String& strAttrib)
542
+ void CSyncSource::updateAssociation(const String& strOldObject, const String& strNewObject, const String& strAttrib)
543
543
  {
544
544
  if ( m_bSchemaSource )
545
545
  {
@@ -672,7 +672,7 @@ void CSyncSource::processServerCmd_Ver3_Schema(const String& strCmd, const Strin
672
672
  }else if ( strCmd.compare("links") == 0 )
673
673
  {
674
674
  String strValue = attrIter.getCurString();
675
- processLinks(strObject, strValue);
675
+ processAssociations(strObject, strValue);
676
676
 
677
677
  String strSqlUpdate = "UPDATE ";
678
678
  strSqlUpdate += getName() + " SET object=? WHERE object=?";
@@ -766,7 +766,7 @@ void CSyncSource::processServerCmd_Ver3(const String& strCmd, const String& strO
766
766
  m_nDeleted++;
767
767
  }else if ( strCmd.compare("links") == 0 )
768
768
  {
769
- processLinks(strObject, oAttrValue.m_strValue);
769
+ processAssociations(strObject, oAttrValue.m_strValue);
770
770
 
771
771
  getDB().executeSQL("UPDATE object_values SET object=? where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
772
772
  getDB().executeSQL("UPDATE changed_values SET object=?,sent=3 where object=? and source_id=?", oAttrValue.m_strValue, strObject, getID() );
@@ -52,7 +52,7 @@ class CSyncSource
52
52
  int m_nRefreshTime;
53
53
  int m_nProgressStep;
54
54
  boolean m_bSchemaSource;
55
- Hashtable<String,String> m_hashLinks;
55
+ Hashtable<String,String> m_hashAssociations;
56
56
  VectorPtr<net::CMultipartItem*> m_arMultipartItems;
57
57
  Vector<String> m_arBlobAttrs;
58
58
 
@@ -121,9 +121,9 @@ public:
121
121
 
122
122
  void processServerCmd_Ver3_Schema(const String& strCmd, const String& strObject, json::CJSONStructIterator& attrIter);//throws Exception
123
123
 
124
- void parseLinks(const String& strLinks);
125
- void processLinks(const String& strOldObject, const String& strNewObject);
126
- void updateLink(const String& strOldObject, const String& strNewObject, const String& strAttrib);
124
+ void parseAssociations(const String& strAssociations);
125
+ void processAssociations(const String& strOldObject, const String& strNewObject);
126
+ void updateAssociation(const String& strOldObject, const String& strNewObject, const String& strAttrib);
127
127
  private:
128
128
  CSyncEngine& getSync(){ return m_syncEngine; }
129
129
  CSyncNotify& getNotify();
@@ -299,7 +299,14 @@ void rho_sync_set_pollinterval(int nInterval)
299
299
 
300
300
  void rho_sync_set_syncserver(char* syncserver)
301
301
  {
302
- CSyncThread::getSyncEngine().setSyncServer(syncserver);
302
+ rho_sync_stop();
303
+
304
+ CSyncThread::getSyncEngine().setSyncServer(syncserver);
305
+
306
+ if ( syncserver && *syncserver )
307
+ CSyncThread::getInstance()->start(CSyncThread::epLow);
308
+ else
309
+ CSyncThread::getInstance()->stop(SYNC_WAIT_BEFOREKILL_SECONDS);
303
310
  }
304
311
 
305
312
  void rho_sync_login(const char *name, const char *password, const char* callback)
@@ -33,6 +33,7 @@ void * rho_calloc(size_t num, size_t size);
33
33
  size_t rho_msize(void *);
34
34
  void * rho_realloc(void *, size_t);
35
35
  char * rho_strdup(const char *);
36
+ wchar_t * rho_wcsdup(const wchar_t * str);
36
37
  void sys_free(void *);
37
38
  #ifdef __cplusplus
38
39
  }
@@ -45,6 +46,7 @@ void sys_free(void *);
45
46
  #undef realloc
46
47
  #undef strdup
47
48
  #undef _strdup
49
+ #undef _wcsdup
48
50
 
49
51
  //#define _recalloc(p, n, s) rho_realloc(p, n*s)
50
52
  #define free(p) rho_free(p)
@@ -55,6 +57,7 @@ void sys_free(void *);
55
57
 
56
58
  #define strdup(s) rho_strdup(s)
57
59
  #define _strdup(s) rho_strdup(s)
60
+ #define _wcsdup(s) rho_wcsdup(s)
58
61
 
59
62
  #ifndef __SYMBIAN32__
60
63
 
@@ -1041,6 +1041,17 @@ char * rho_strdup(const char * str)
1041
1041
  return tmp;
1042
1042
  }
1043
1043
 
1044
+ wchar_t * rho_wcsdup(const wchar_t * str)
1045
+ {
1046
+ wchar_t *tmp;
1047
+ int len = (wcslen(str) + 1)*sizeof(wchar_t);
1048
+
1049
+ tmp = (wchar_t*)do_malloc(len);
1050
+ memcpy(tmp, str, len);
1051
+
1052
+ return tmp;
1053
+ }
1054
+
1044
1055
  #ifdef MALLOC_STAT
1045
1056
  void do_malloc_stats() {
1046
1057
  PrintStats(2);
@@ -70,132 +70,127 @@ void CAlertDialog::DoInitControls()
70
70
 
71
71
  LRESULT CAlertDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL&bHandled)
72
72
  {
73
+
73
74
  #define MAX(i, j) ((i) > (j) ? (i) : (j))
75
+ #define MIN(i, j) ((i) < (j) ? (i) : (j))
76
+
77
+ const int GAP = 12; //space around dialog
78
+ const int INDENT = 14; //for dialog items
74
79
 
75
- const int GAP = 10; //space around dialog
76
- const int INDENT = 8; //for dialog items
77
- const unsigned int iconHeight = 42;
78
- //space around label on buttons.
79
- const int btnHIndent = 12; //horizontal
80
- const int btnVIndent = 8; //vertical
81
80
  #ifdef OS_WINCE
82
81
  unsigned int maxWidth = GetSystemMetrics(SM_CXSCREEN) - (GAP * 2);
83
82
  unsigned int maxHeight = GetSystemMetrics(SM_CYSCREEN) - (GAP * 2);
84
83
  #else
85
- unsigned int maxWidth = CMainWindow::getScreenWidth() - (GAP * 2);
86
- unsigned int maxHeight = CMainWindow::getScreenWidth() - (GAP * 2);
84
+ int maxWidth = CMainWindow::getScreenWidth() - (GAP * 2);
85
+ int maxHeight = CMainWindow::getScreenWidth() - (GAP * 2);
87
86
  #endif
88
- unsigned int msgWidth = 0, msgHeight = 0;
87
+ int xBorderWidth = GetSystemMetrics(SM_CXEDGE);
88
+ int yBorderWidth = GetSystemMetrics(SM_CYEDGE);
89
89
  CClientDC dc(m_hWnd);
90
90
  TEXTMETRIC tm = { 0 };
91
- RECT dlgRect, iconRect = {0 }, msgRect = { 0 }, buttonsRect = { 0 };
92
- RECT rect = {0}; POINT point = { 0 };
93
- #ifdef OS_WINCE
94
- int iconId = 0;
95
- #else
96
- LPWSTR iconId = NULL;
97
- #endif
91
+ RECT rect = {0}, dlgRect, iconRect = {0 }, msgRect = { 0 }, buttonsRect = { 0 };
98
92
 
99
93
  GetClientRect(&dlgRect);
100
- LOG(INFO) + "dlgRect: " + dlgRect.left + " " + dlgRect.top + " " + dlgRect.right + " " + dlgRect.bottom;
101
94
 
102
- /**
103
- * Icon.
104
- */
105
- #ifdef OS_WINCE
106
- if (m_icon == "alert")
107
- iconId = MB_ICONWARNING;
108
- else if (m_icon == "question")
109
- iconId = MB_ICONQUESTION;
110
- else if (m_icon == "info")
111
- iconId = MB_ICONINFORMATION;
112
- #else
113
- if (m_icon == "alert")
114
- iconId = IDI_WARNING;
115
- else if (m_icon == "question")
116
- iconId = IDI_QUESTION;
117
- else if (m_icon == "info")
118
- iconId = IDI_INFORMATION;
119
- #endif
120
-
121
- //if icon has predefined type - try to load it from system resources.
122
- if (iconId != 0) {
123
- #ifdef OS_WINCE
124
- HMODULE hGWES = LoadLibraryEx( L"gwes.exe", NULL, LOAD_LIBRARY_AS_DATAFILE );
125
- HICON hIcon = LoadIcon(hGWES, MAKEINTRESOURCE(iconId));
126
- #else
127
- HICON hIcon = LoadIcon(NULL, iconId);
128
- #endif
95
+ /***************************************************************************
96
+ Icon.
97
+ ***************************************************************************/
98
+ HICON hIcon = loadIcon();
99
+ if (hIcon == NULL) {
100
+ LOG(ERROR) + "Failed to load icon";
101
+ } else {
102
+ iconRect.left = INDENT;
103
+ iconRect.top = INDENT;
104
+ iconRect.right = iconRect.left + GetSystemMetrics(SM_CXICON);
105
+ iconRect.bottom = iconRect.top + GetSystemMetrics(SM_CYICON);
106
+
107
+ m_iconCtrl.Create(m_hWnd, iconRect, NULL, WS_CHILD | WS_VISIBLE | SS_ICON);
108
+ m_iconCtrl.SetIcon(hIcon);
109
+ }
110
+ int iconHeight = iconRect.bottom - iconRect.top;
111
+ int iconWidth = iconRect.left - iconRect.right;
129
112
 
130
- if (hIcon == NULL) {
131
- LOG(ERROR) + "Failed to load icon";
132
- } else {
133
- iconRect.left = INDENT;
134
- iconRect.top = INDENT;
135
- iconRect.right = iconRect.left + iconHeight;
136
- iconRect.bottom = iconRect.top + iconHeight;
113
+ /***************************************************************************
114
+ Message.
115
+ ***************************************************************************/
116
+ GetClientRect(&dlgRect);
137
117
 
138
- m_iconCtrl.Create(m_hWnd, iconRect, NULL, WS_CHILD | WS_VISIBLE | SS_ICON);
118
+ //create control
119
+ m_messageCtrl.Create(m_hWnd, CWindow::rcDefault, NULL, WS_CHILD | WS_VISIBLE);
139
120
 
140
- if (m_iconCtrl.SetIcon(hIcon) == NULL)
141
- LOG(INFO) + "Failed to set icon";
142
- }
143
- }
121
+ //change control font to normal
122
+ HFONT hFont = m_messageCtrl.GetFont();
123
+ LOGFONT fontAttributes = { 0 };
124
+ ::GetObject(hFont, sizeof(fontAttributes), &fontAttributes);
125
+ fontAttributes.lfWeight = FW_NORMAL;
126
+ hFont = CreateFontIndirect(&fontAttributes);
127
+ m_messageCtrl.SetFont(hFont);
144
128
 
145
- /**
146
- * Message.
147
- */
148
- GetClientRect(&dlgRect);
129
+
130
+ //get text metrics
149
131
  dc.GetTextMetrics(&tm);
150
-
151
- msgWidth = m_message.length() * tm.tmAveCharWidth + (2 * INDENT);
152
- msgHeight = (tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading);
153
- point.x = iconRect.right; point.y = iconRect.top;
132
+
133
+ int msgWidth = m_message.length() * (tm.tmAveCharWidth * 1.3) + (2 * INDENT);
134
+ int msgHeight = tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading;
154
135
 
155
136
  int desiredDlgWidth = iconRect.right + msgWidth + (INDENT * 2);
156
137
 
157
- //if ((desiredDlgWidth > (dlgRect.right - dlgRect.left))) { //adjust dialog window
158
- if ( m_buttons.size() != 0 ) {
159
- if ((point.x + msgWidth) > maxWidth) {
160
- msgWidth = maxWidth - iconRect.right;
138
+ //if desired widht is bigger than current - make dialog window bigger
139
+ if (desiredDlgWidth > (dlgRect.right - dlgRect.left)) {
140
+ // if desired width is bigger than maximum width
141
+ // - recalculate dialog window with wrapped text
142
+ if (desiredDlgWidth >= maxWidth) {
143
+ msgWidth = maxWidth - (iconRect.right + INDENT*2 + xBorderWidth*2);
161
144
  msgHeight = (((m_message.length() * tm.tmAveCharWidth) / msgWidth) + 1)
162
145
  * (tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading);
163
- desiredDlgWidth = iconRect.right + msgWidth + (INDENT * 2);
164
- } else {
165
- msgHeight = tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading;
166
- }
167
-
168
- if (m_buttons.size() == 0) {
169
- MoveWindow(GAP, GAP,
170
- desiredDlgWidth + 13 + INDENT,
171
- MAX((unsigned int )iconRect.bottom, msgHeight) + msgHeight + GetSystemMetrics(SM_CYCAPTION) + INDENT);
172
- } else {
173
- MoveWindow(GAP, GAP,
174
- desiredDlgWidth + 13 + INDENT,
175
- MAX((unsigned int )iconRect.bottom, msgHeight) + GetSystemMetrics(SM_CYCAPTION) + INDENT +
176
- (tm.tmHeight + btnVIndent + INDENT * 2)); //reserved place for buttons
146
+ desiredDlgWidth = maxWidth;
177
147
  }
148
+
149
+ MoveWindow(0, 0, desiredDlgWidth,
150
+ MAX(iconRect.bottom, msgHeight) + GetSystemMetrics(SM_CYCAPTION) + INDENT + yBorderWidth * 2);
151
+ } else {
152
+ //TODO: centering message
178
153
  }
179
-
180
- msgRect.left = iconRect.right + INDENT;
181
- msgRect.top = iconRect.top;
182
- msgRect.right = iconRect.right + msgWidth + 2 * INDENT + INDENT * 2;
183
- msgRect.bottom = msgRect.top + msgHeight;
184
-
185
- //LOG(DEBUG) + " msgWidth: " + msgWidth;
186
- //LOG(DEBUG) + " msgRect: " + msgRect.left + " " + msgRect.top + " " + msgRect.right + " " + msgRect.bottom;
187
-
188
- m_messageCtrl.Create(m_hWnd, msgRect, NULL, WS_CHILD | WS_VISIBLE);
154
+
189
155
  m_messageCtrl.SetWindowText(convertToStringW(m_message).c_str());
156
+
157
+ LOG(INFO) + "iconHeight msgHeight " + iconHeight + " "+ msgHeight;
158
+
159
+ if (iconHeight > msgHeight) {
160
+ msgRect.left = iconRect.right + INDENT;
161
+ msgRect.top = iconRect.top + (iconHeight - msgHeight)/2;
162
+ msgRect.right = msgRect.left + msgWidth;
163
+ msgRect.bottom = msgRect.top + msgHeight;
164
+ //center message on icon
165
+ m_messageCtrl.MoveWindow(iconRect.right + INDENT, iconRect.top + (iconHeight - msgHeight)/2, msgWidth, msgHeight);
166
+ } else {
167
+ msgRect.left = iconRect.right + INDENT;
168
+ msgRect.top = iconRect.top;
169
+ msgRect.right = msgRect.left + msgWidth;
170
+ msgRect.bottom = msgRect.top + msgHeight;
171
+ m_messageCtrl.MoveWindow(iconRect.right + INDENT, iconRect.top, msgWidth, msgHeight);
172
+ //center icon on message
173
+ if (hIcon) {
174
+ m_iconCtrl.MoveWindow(INDENT, iconRect.top + (msgHeight - iconHeight)/2, iconWidth, iconHeight);
175
+ m_iconCtrl.SetIcon(hIcon);
176
+ }
177
+ }
190
178
 
191
179
  //for Wait dailog text should be centered
192
180
  if (m_buttons.size() == 0) {
193
181
  m_messageCtrl.CenterWindow();
194
182
  }
195
183
 
196
- /**
197
- * Buttons.
198
- */
184
+ /***************************************************************************
185
+ Buttons.
186
+ ***************************************************************************/
187
+
188
+ GetClientRect(&dlgRect);
189
+
190
+ //space around label on buttons.
191
+ const int btnHIndent = 12; //horizontal
192
+ const int btnVIndent = 8; //vertical
193
+
199
194
  int btnsNum = m_buttons.size();
200
195
  int btnsWidth = 0, btnsHeight =tm.tmHeight + btnVIndent;
201
196
 
@@ -203,21 +198,22 @@ LRESULT CAlertDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lP
203
198
  btnsWidth += (itr->m_title.length() * tm.tmAveCharWidth) + btnHIndent + (INDENT * 2);
204
199
  }
205
200
 
201
+ POINT point;
206
202
  point.x = INDENT, point.y = (iconHeight > msgHeight ? point.y = iconHeight + 6 : msgHeight + 2) + INDENT;
207
203
 
208
204
  unsigned int btnWidth = 0, btnHeight = 0;
205
+ btnHeight = tm.tmHeight + btnVIndent;
206
+
207
+ //if (iconHeight + msgHeight + INDENT + btnHeight + INDENT > dlgRect.) {
208
+ //}
209
+
209
210
  for (Vector<CustomButton>::iterator itr = m_buttons.begin(); itr != m_buttons.end(); ++itr) {
210
211
  btnWidth = (itr->m_title.length() * tm.tmAveCharWidth) + btnHIndent;
211
- btnHeight = tm.tmHeight + btnVIndent;
212
212
 
213
213
  RECT rc = {point.x, point.y, point.x + btnWidth, point.y + btnHeight};
214
214
  itr->Create(m_hWnd, rc,
215
215
  convertToStringW(itr->m_title).c_str(),
216
- WS_CHILD | WS_VISIBLE
217
- #if defined(OS_WINDOWS)
218
- | BS_DEFPUSHBUTTON
219
- #endif
220
- , 0,
216
+ WS_CHILD | WS_VISIBLE, 0,
221
217
  itr->m_numId);
222
218
 
223
219
  point.x += btnWidth + INDENT;
@@ -228,6 +224,7 @@ LRESULT CAlertDialog::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lP
228
224
  return bHandled = FALSE;
229
225
 
230
226
  #undef MAX
227
+ #undef MIN
231
228
  }
232
229
 
233
230
  bool CAlertDialog::findButton(int id, CustomButton &btn)
@@ -254,6 +251,56 @@ LRESULT CAlertDialog::OnAlertDialogButton (WORD /*wNotifyCode*/, WORD wID, HWND
254
251
  return 0;
255
252
  }
256
253
 
254
+ HICON CAlertDialog::loadIcon()
255
+ {
256
+ HICON hIcon = NULL;
257
+
258
+ struct iconTable_s {
259
+ String name;
260
+ #ifdef OS_WINCE
261
+ int id;
262
+ #else
263
+ LPWSTR id;
264
+ #endif
265
+ } iconTable[] = {
266
+ #ifdef OS_WINCE
267
+ { "alert", MB_ICONWARNING },
268
+ { "question", MB_ICONQUESTION },
269
+ { "info", MB_ICONINFORMATION }
270
+ #else
271
+ { "alert", IDI_WARNING },
272
+ { "question", IDI_QUESTION },
273
+ { "info", IDI_INFORMATION }
274
+ #endif
275
+ };
276
+
277
+ #ifdef OS_WINCE
278
+ int iconId = 0;
279
+ #else
280
+ LPWSTR iconId = NULL;
281
+ #endif
282
+
283
+ for (int i = 0; i < (sizeof(iconTable)/sizeof(iconTable[0])); i++)
284
+ {
285
+ LOG(ERROR) + "ICON == " + iconTable[i].name;
286
+ if (iconTable[i].name == m_icon)
287
+ iconId = iconTable[i].id;
288
+ }
289
+
290
+ if (iconId != 0)
291
+ {
292
+ #ifdef OS_WINCE
293
+ HMODULE hGWES = LoadLibraryEx( L"gwes.exe", NULL, LOAD_LIBRARY_AS_DATAFILE );
294
+ hIcon = LoadIcon(hGWES, MAKEINTRESOURCE(iconId));
295
+ #else
296
+ hIcon = LoadIcon(NULL, iconId);
297
+ #endif
298
+ }
299
+ //TODO: if icon has predefined type - try to load it from system resources.
300
+
301
+ return hIcon;
302
+ }
303
+
257
304
  /**
258
305
  ********************************************************************************
259
306
  * CAlert members.
@@ -75,10 +75,12 @@ public:
75
75
 
76
76
  bool findButton(int id, CustomButton &button);
77
77
 
78
- public:
79
78
  LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL&bHandled);
80
79
  LRESULT OnAlertDialogButton (WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
81
80
 
81
+ private:
82
+ HICON loadIcon(void);
83
+
82
84
  private:
83
85
  String m_title;
84
86
  String m_message;
@@ -90,6 +92,7 @@ private:
90
92
  Vector<CustomButton> m_buttons;
91
93
  };
92
94
 
95
+
93
96
  class CAlert {
94
97
  DEFINE_LOGCLASS;
95
98
  public: