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
@@ -18,6 +18,9 @@ extern "C" int strnicmp( const char *s1, const char *s2, size_t count );
18
18
  namespace rho {
19
19
  namespace net {
20
20
  IMPLEMENT_LOGCLASS(CNetRequestImpl,"Net");
21
+ common::CMutex CNetRequestImpl::m_mxInternet;
22
+ HINTERNET CNetRequestImpl::m_hInternet;
23
+ HANDLE CNetRequestImpl::m_hWceConnMgrConnection;
21
24
 
22
25
  CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const String& strUrl,
23
26
  IRhoSession* oSession, Hashtable<String,String>* pHeaders, boolean sslVerifyPeer)
@@ -29,65 +32,57 @@ CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const
29
32
  m_pSession = oSession;
30
33
  m_sslVerifyPeer = sslVerifyPeer;
31
34
 
32
- pszErrFunction = NULL;
33
- hInet = NULL, hConnection = NULL, hRequest = NULL;
34
- memset(&uri, 0, sizeof(uri) );
35
+ m_pszErrFunction = NULL;
36
+ m_hConnection = NULL;
37
+ m_hRequest = NULL;
38
+ memset(&m_uri, 0, sizeof(m_uri) );
39
+
35
40
  m_strUrl = strUrl;
36
41
  CAtlStringW strUrlW(strUrl.c_str());
37
42
 
38
43
  LOG(INFO) + "Method: " + method + ";Url: " + strUrl;
39
44
  do
40
45
  {
41
- if ( !URI::isLocalHost(strUrl.c_str()) && !SetupInternetConnection(strUrlW) )
42
- {
43
- pszErrFunction = L"SetupInternetConnection";
46
+ if ( !initConnection(URI::isLocalHost(strUrl.c_str()), strUrlW) )
44
47
  break;
45
- }
46
-
47
- hInet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
48
- if ( !hInet )
49
- {
50
- pszErrFunction = L"InternetOpen";
51
- break;
52
- }
53
48
 
54
49
  DWORD dwUrlLength = 1024;
55
50
  CAtlStringW strCanonicalUrlW;
56
51
  if ( !InternetCanonicalizeUrl( strUrlW, strCanonicalUrlW.GetBuffer(dwUrlLength), &dwUrlLength, 0) )
57
52
  {
58
- pszErrFunction = _T("InternetCanonicalizeUrl");
53
+ m_pszErrFunction = _T("InternetCanonicalizeUrl");
59
54
  break;
60
55
  }
61
56
  strCanonicalUrlW.ReleaseBuffer();
62
57
 
63
- alloc_url_components( &uri, strCanonicalUrlW );
64
- if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &uri ) )
58
+ alloc_url_components( &m_uri, strCanonicalUrlW );
59
+ if( !InternetCrackUrl( strCanonicalUrlW, strCanonicalUrlW.GetLength(), 0, &m_uri ) )
65
60
  {
66
- pszErrFunction = L"InternetCrackUrl";
61
+ m_pszErrFunction = L"InternetCrackUrl";
67
62
  break;
68
63
  }
69
64
 
70
- hConnection = InternetConnect( hInet, uri.lpszHostName, uri.nPort, _T("anonymous"), NULL,
65
+ m_hConnection = InternetConnect( m_hInternet, m_uri.lpszHostName, m_uri.nPort, _T("anonymous"), NULL,
71
66
  INTERNET_SERVICE_HTTP, 0, 0 );
72
- if ( !hConnection )
67
+ if ( !m_hConnection )
73
68
  {
74
- pszErrFunction = L"InternetConnect";
69
+ m_pszErrFunction = L"InternetConnect";
75
70
  break;
76
71
  }
77
72
 
78
- strReqUrlW = uri.lpszUrlPath;
79
- strReqUrlW += uri.lpszExtraInfo;
73
+ m_strReqUrlW = m_uri.lpszUrlPath;
74
+ m_strReqUrlW += m_uri.lpszExtraInfo;
80
75
  DWORD dwFlags = INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_NO_COOKIES;
81
- if ( uri.lpszScheme && wcsicmp(uri.lpszScheme,L"https")==0)
76
+ if ( m_uri.lpszScheme && wcsicmp(m_uri.lpszScheme,L"https")==0)
82
77
  dwFlags |= INTERNET_FLAG_SECURE;
83
78
 
84
79
  if ( !m_sslVerifyPeer )
85
80
  dwFlags |= INTERNET_FLAG_IGNORE_CERT_CN_INVALID|INTERNET_FLAG_IGNORE_CERT_DATE_INVALID;
86
81
 
87
- hRequest = HttpOpenRequest( hConnection, CAtlStringW(method), strReqUrlW, NULL, NULL, NULL, dwFlags, NULL );
88
- if ( !hRequest )
82
+ m_hRequest = HttpOpenRequest( m_hConnection, CAtlStringW(method), m_strReqUrlW, NULL, NULL, NULL, dwFlags, NULL );
83
+ if ( !m_hRequest )
89
84
  {
90
- pszErrFunction = L"HttpOpenRequest";
85
+ m_pszErrFunction = L"HttpOpenRequest";
91
86
  break;
92
87
  }
93
88
 
@@ -99,8 +94,8 @@ CNetRequestImpl::CNetRequestImpl(CNetRequest* pParent, const char* method, const
99
94
  {
100
95
  String strHeader = "Cookie: " + strSession + "\r\n";
101
96
 
102
- if ( !HttpAddRequestHeaders( hRequest, common::convertToStringW(strHeader).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
103
- pszErrFunction = L"HttpAddRequestHeaders";
97
+ if ( !HttpAddRequestHeaders( m_hRequest, common::convertToStringW(strHeader).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
98
+ m_pszErrFunction = L"HttpAddRequestHeaders";
104
99
  }
105
100
  }
106
101
 
@@ -118,11 +113,11 @@ boolean CNetRequestImpl::checkSslCertError()
118
113
  {
119
114
  DWORD dwFlag;
120
115
  DWORD dwBuffLen = sizeof(dwFlag);
121
- InternetQueryOption (hRequest, INTERNET_OPTION_SECURITY_FLAGS,(LPVOID)&dwFlag, &dwBuffLen);
116
+ InternetQueryOption (m_hRequest, INTERNET_OPTION_SECURITY_FLAGS,(LPVOID)&dwFlag, &dwBuffLen);
122
117
  dwFlag |= (SECURITY_FLAG_IGNORE_UNKNOWN_CA
123
118
  | SECURITY_FLAG_IGNORE_CERT_CN_INVALID
124
119
  | SECURITY_FLAG_IGNORE_CERT_DATE_INVALID );
125
- InternetSetOption (hRequest, INTERNET_OPTION_SECURITY_FLAGS, &dwFlag, sizeof (dwFlag) );
120
+ InternetSetOption (m_hRequest, INTERNET_OPTION_SECURITY_FLAGS, &dwFlag, sizeof (dwFlag) );
126
121
  /*
127
122
  INTERNET_CERTIFICATE_INFO sInfo;
128
123
  DWORD dwSize = sizeof(sInfo);
@@ -162,26 +157,26 @@ CNetResponseImpl* CNetRequestImpl::sendString(const String& strBody)
162
157
  strHeaders += getBodyContentType().c_str();
163
158
  strHeaders += L"\r\n";
164
159
 
165
- if ( !HttpAddRequestHeaders( hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
160
+ if ( !HttpAddRequestHeaders( m_hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
166
161
  {
167
- pszErrFunction = L"HttpAddRequestHeaders";
162
+ m_pszErrFunction = L"HttpAddRequestHeaders";
168
163
  break;
169
164
  }
170
165
  }
171
166
  writeHeaders(m_pHeaders);
172
167
 
173
- if ( !HttpSendRequest( hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) )
168
+ if ( !HttpSendRequest( m_hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) )
174
169
  {
175
170
  if (checkSslCertError())
176
171
  {
177
- if ( !HttpSendRequest( hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) )
172
+ if ( !HttpSendRequest( m_hRequest, NULL, 0, const_cast<char*>(strBody.c_str()), strBody.length() ) )
178
173
  {
179
- pszErrFunction = L"HttpSendRequest";
174
+ m_pszErrFunction = L"HttpSendRequest";
180
175
  break;
181
176
  }
182
177
  }else
183
178
  {
184
- pszErrFunction = L"HttpSendRequest";
179
+ m_pszErrFunction = L"HttpSendRequest";
185
180
  break;
186
181
  }
187
182
  }
@@ -190,7 +185,7 @@ CNetResponseImpl* CNetRequestImpl::sendString(const String& strBody)
190
185
  if ( isError() )
191
186
  break;
192
187
 
193
- readInetFile(hRequest,pNetResp);
188
+ readInetFile(m_hRequest,pNetResp);
194
189
  }while(0);
195
190
 
196
191
  return pNetResp;
@@ -205,9 +200,9 @@ void CNetRequestImpl::writeHeaders(Hashtable<String,String>* pHeaders)
205
200
  for ( Hashtable<String,String>::iterator it = pHeaders->begin(); it != pHeaders->end(); ++it )
206
201
  strHeaders += it->first + ":" + it->second + "\r\n";
207
202
 
208
- if ( !HttpAddRequestHeaders( hRequest, common::convertToStringW(strHeaders).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
203
+ if ( !HttpAddRequestHeaders( m_hRequest, common::convertToStringW(strHeaders).c_str(), -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
209
204
  {
210
- pszErrFunction = L"HttpAddRequestHeaders";
205
+ m_pszErrFunction = L"HttpAddRequestHeaders";
211
206
  return;
212
207
  }
213
208
  }
@@ -220,18 +215,18 @@ boolean CNetRequestImpl::readHeaders(Hashtable<String,String>& oHeaders)
220
215
  CAtlStringW strHeaders;
221
216
  DWORD dwLen = 0;
222
217
  DWORD nIndex = 0;
223
- if( !HttpQueryInfo( hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, null, &dwLen, &nIndex) )
218
+ if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, null, &dwLen, &nIndex) )
224
219
  {
225
220
  DWORD dwErr = ::GetLastError();
226
221
  if ( dwErr != ERROR_INSUFFICIENT_BUFFER )
227
222
  {
228
- pszErrFunction = L"HttpQueryInfo";
223
+ m_pszErrFunction = L"HttpQueryInfo";
229
224
  return false;
230
225
  }
231
226
  }
232
- if( !HttpQueryInfo( hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, strHeaders.GetBuffer(dwLen), &dwLen, &nIndex) )
227
+ if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, strHeaders.GetBuffer(dwLen), &dwLen, &nIndex) )
233
228
  {
234
- pszErrFunction = L"HttpQueryInfo";
229
+ m_pszErrFunction = L"HttpQueryInfo";
235
230
  return false;
236
231
  }
237
232
  strHeaders.ReleaseBuffer();
@@ -264,7 +259,7 @@ String CNetRequestImpl::makeClientCookie()
264
259
  {
265
260
  CAtlStringW strCookie;
266
261
  DWORD dwLen = 0;
267
- if( !HttpQueryInfo( hRequest, HTTP_QUERY_SET_COOKIE, null, &dwLen, &nIndex) )
262
+ if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_SET_COOKIE, null, &dwLen, &nIndex) )
268
263
  {
269
264
  DWORD dwErr = ::GetLastError();
270
265
  if ( dwErr == ERROR_HTTP_HEADER_NOT_FOUND )
@@ -272,20 +267,20 @@ String CNetRequestImpl::makeClientCookie()
272
267
 
273
268
  if ( dwErr != ERROR_INSUFFICIENT_BUFFER )
274
269
  {
275
- pszErrFunction = L"HttpQueryInfo";
270
+ m_pszErrFunction = L"HttpQueryInfo";
276
271
  break;
277
272
  }
278
273
  }
279
- if( !HttpQueryInfo( hRequest, HTTP_QUERY_SET_COOKIE, strCookie.GetBuffer(dwLen), &dwLen, &nIndex) )
274
+ if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_SET_COOKIE, strCookie.GetBuffer(dwLen), &dwLen, &nIndex) )
280
275
  {
281
- pszErrFunction = L"HttpQueryInfo";
276
+ m_pszErrFunction = L"HttpQueryInfo";
282
277
  break;
283
278
  }
284
279
  strCookie.ReleaseBuffer();
285
280
 
286
281
  URI::parseCookie(common::convertToStringA(strCookie.GetString()).c_str(), cookie);
287
282
  }
288
- if (pszErrFunction)
283
+ if (m_pszErrFunction)
289
284
  return "";
290
285
 
291
286
  // if ( cookie.strAuth.length() > 0 || cookie.strSession.length() >0 )
@@ -300,9 +295,9 @@ void CNetRequestImpl::readResponse(CNetResponseImpl* pNetResp)
300
295
  wchar_t szHttpRes[10];
301
296
  DWORD nIndex = 0;
302
297
 
303
- if( !HttpQueryInfo( hRequest, HTTP_QUERY_STATUS_CODE, szHttpRes, &dwLen, &nIndex) )
298
+ if( !HttpQueryInfo( m_hRequest, HTTP_QUERY_STATUS_CODE, szHttpRes, &dwLen, &nIndex) )
304
299
  {
305
- pszErrFunction = L"HttpQueryInfo";
300
+ m_pszErrFunction = L"HttpQueryInfo";
306
301
  return;
307
302
  }
308
303
  int nCode = _wtoi(szHttpRes);
@@ -333,7 +328,7 @@ void CNetRequestImpl::readResponse(CNetResponseImpl* pNetResp)
333
328
  CNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile)
334
329
  {
335
330
  CNetResponseImpl* pNetResp = new CNetResponseImpl;
336
- const int nDownloadBufferSize = 1024*50;
331
+ const int nDownloadBufferSize = 1024*100;
337
332
  char* pDownloadBuffer = 0;
338
333
 
339
334
  do
@@ -351,25 +346,25 @@ CNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile)
351
346
  //strHeaders += common::convertToStringW(oFile.size()+30068032).c_str();
352
347
  strHeaders += "\r\n";
353
348
 
354
- if ( !HttpAddRequestHeaders( hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
349
+ if ( !HttpAddRequestHeaders( m_hRequest, strHeaders, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
355
350
  {
356
- pszErrFunction = L"HttpAddRequestHeaders";
351
+ m_pszErrFunction = L"HttpAddRequestHeaders";
357
352
  break;
358
353
  }
359
354
  }
360
355
 
361
- if ( !HttpSendRequest( hRequest, NULL, 0, NULL, 0 ) )
356
+ if ( !HttpSendRequest( m_hRequest, NULL, 0, NULL, 0 ) )
362
357
  {
363
358
  if (checkSslCertError())
364
359
  {
365
- if ( !HttpSendRequest( hRequest, NULL, 0, NULL, 0 ) )
360
+ if ( !HttpSendRequest( m_hRequest, NULL, 0, NULL, 0 ) )
366
361
  {
367
- pszErrFunction = L"HttpSendRequest";
362
+ m_pszErrFunction = L"HttpSendRequest";
368
363
  break;
369
364
  }
370
365
  }else
371
366
  {
372
- pszErrFunction = L"HttpSendRequest";
367
+ m_pszErrFunction = L"HttpSendRequest";
373
368
  break;
374
369
  }
375
370
  }
@@ -387,7 +382,7 @@ CNetResponseImpl* CNetRequestImpl::downloadFile(common::CRhoFile& oFile)
387
382
  if (!pDownloadBuffer)
388
383
  pDownloadBuffer = new char[nDownloadBufferSize];
389
384
 
390
- readInetFile(hRequest,pNetResp, &oFile, pDownloadBuffer, nDownloadBufferSize);
385
+ readInetFile(m_hRequest,pNetResp, &oFile, pDownloadBuffer, nDownloadBufferSize);
391
386
 
392
387
  }while(0);
393
388
 
@@ -469,9 +464,9 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
469
464
  if ( isError() )
470
465
  break;
471
466
 
472
- if ( !HttpAddRequestHeaders( hRequest, szMultipartContType, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
467
+ if ( !HttpAddRequestHeaders( m_hRequest, szMultipartContType, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE ) )
473
468
  {
474
- pszErrFunction = L"HttpAddRequestHeaders";
469
+ m_pszErrFunction = L"HttpAddRequestHeaders";
475
470
  break;
476
471
  }
477
472
 
@@ -480,18 +475,18 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
480
475
  BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS ); // Must be set or error will occur
481
476
  BufferIn.dwBufferTotal = processMultipartItems( arItems );
482
477
 
483
- if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, 0, 0))
478
+ if(!HttpSendRequestEx( m_hRequest, &BufferIn, NULL, 0, 0))
484
479
  {
485
480
  if (checkSslCertError())
486
481
  {
487
- if(!HttpSendRequestEx( hRequest, &BufferIn, NULL, 0, 0))
482
+ if(!HttpSendRequestEx( m_hRequest, &BufferIn, NULL, 0, 0))
488
483
  {
489
- pszErrFunction = L"HttpSendRequestEx";
484
+ m_pszErrFunction = L"HttpSendRequestEx";
490
485
  break;
491
486
  }
492
487
  }else
493
488
  {
494
- pszErrFunction = L"HttpSendRequestEx";
489
+ m_pszErrFunction = L"HttpSendRequestEx";
495
490
  break;
496
491
  }
497
492
  }
@@ -506,14 +501,14 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
506
501
  common::CRhoFile oFile;
507
502
  if ( !oFile.open(oItem.m_strFilePath.c_str(),common::CRhoFile::OpenReadOnly) )
508
503
  {
509
- pszErrFunction = L"InternetWriteFile";
504
+ m_pszErrFunction = L"InternetWriteFile";
510
505
  return pNetResp;
511
506
  }
512
507
  common::InputStream* bodyStream = oFile.getInputStream();
513
508
 
514
509
  if ( !internetWriteHeader( oItem.m_strDataPrefix.c_str(), "", "") )
515
510
  {
516
- pszErrFunction = L"InternetWriteFile";
511
+ m_pszErrFunction = L"InternetWriteFile";
517
512
  return pNetResp;
518
513
  }
519
514
 
@@ -529,9 +524,9 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
529
524
  nReaded = bodyStream->read(pBuf,0,dwBufSize);
530
525
  if ( nReaded > 0 )
531
526
  {
532
- if ( !InternetWriteFile( hRequest, pBuf, nReaded, &dwBytesWritten) )
527
+ if ( !InternetWriteFile( m_hRequest, pBuf, nReaded, &dwBytesWritten) )
533
528
  {
534
- pszErrFunction = L"InternetWriteFile";
529
+ m_pszErrFunction = L"InternetWriteFile";
535
530
  return pNetResp;
536
531
  }
537
532
  }
@@ -544,7 +539,7 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
544
539
  {
545
540
  if ( !internetWriteHeader( oItem.m_strDataPrefix.c_str(), oItem.m_strBody.c_str(), "") )
546
541
  {
547
- pszErrFunction = L"InternetWriteFile";
542
+ m_pszErrFunction = L"InternetWriteFile";
548
543
  return pNetResp;
549
544
  }
550
545
  }
@@ -553,13 +548,13 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
553
548
 
554
549
  if ( !internetWriteHeader( "", "", szMultipartPostfix) )
555
550
  {
556
- pszErrFunction = L"InternetWriteFile";
551
+ m_pszErrFunction = L"InternetWriteFile";
557
552
  return pNetResp;
558
553
  }
559
554
 
560
- if ( !HttpEndRequest(hRequest, NULL, 0, 0) )
555
+ if ( !HttpEndRequest(m_hRequest, NULL, 0, 0) )
561
556
  {
562
- pszErrFunction = L"HttpEndRequest";
557
+ m_pszErrFunction = L"HttpEndRequest";
563
558
  break;
564
559
  }
565
560
 
@@ -570,7 +565,7 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
570
565
  if ( isError() )
571
566
  break;
572
567
 
573
- readInetFile(hRequest,pNetResp);
568
+ readInetFile(m_hRequest,pNetResp);
574
569
 
575
570
  }while(0);
576
571
 
@@ -580,13 +575,13 @@ CNetResponseImpl* CNetRequestImpl::sendMultipartData(VectorPtr<CMultipartItem*>&
580
575
  bool CNetRequestImpl::internetWriteHeader( const char* szPrefix, const char* szBody, const char* szPrefixEnd)
581
576
  {
582
577
  DWORD dwBytesWritten = 0;
583
- if ( szPrefix && *szPrefix && !InternetWriteFile( hRequest, szPrefix, strlen(szPrefix), &dwBytesWritten) )
578
+ if ( szPrefix && *szPrefix && !InternetWriteFile( m_hRequest, szPrefix, strlen(szPrefix), &dwBytesWritten) )
584
579
  return false;
585
580
 
586
- if ( szBody && *szBody && !InternetWriteFile( hRequest, szBody, strlen(szBody), &dwBytesWritten) )
581
+ if ( szBody && *szBody && !InternetWriteFile( m_hRequest, szBody, strlen(szBody), &dwBytesWritten) )
587
582
  return false;
588
583
 
589
- if ( szPrefixEnd && *szPrefixEnd && !InternetWriteFile( hRequest, szPrefixEnd, strlen(szPrefixEnd), &dwBytesWritten) )
584
+ if ( szPrefixEnd && *szPrefixEnd && !InternetWriteFile( m_hRequest, szPrefixEnd, strlen(szPrefixEnd), &dwBytesWritten) )
590
585
  return false;
591
586
 
592
587
  return true;
@@ -596,8 +591,8 @@ void CNetRequestImpl::cancel()
596
591
  {
597
592
  m_bCancel = true;
598
593
 
599
- if ( hRequest )
600
- InternetCloseHandle(hRequest);
594
+ if ( m_hRequest )
595
+ InternetCloseHandle(m_hRequest);
601
596
  /* if ( hConnection )
602
597
  InternetCloseHandle(hConnection);
603
598
  if ( hInet )
@@ -610,23 +605,23 @@ void CNetRequestImpl::cancel()
610
605
 
611
606
  void CNetRequestImpl::close()
612
607
  {
613
- if (!m_bCancel && pszErrFunction)
614
- ErrorMessage(pszErrFunction);
608
+ if (!m_bCancel && m_pszErrFunction)
609
+ ErrorMessage(m_pszErrFunction);
615
610
 
616
- free_url_components(&uri);
611
+ free_url_components(&m_uri);
617
612
 
618
- if ( hRequest )
619
- InternetCloseHandle(hRequest);
620
- if ( hConnection )
621
- InternetCloseHandle(hConnection);
622
- if ( hInet )
623
- InternetCloseHandle(hInet);
613
+ if ( m_hRequest )
614
+ InternetCloseHandle(m_hRequest);
615
+ if ( m_hConnection )
616
+ InternetCloseHandle(m_hConnection);
617
+ // if ( hInet )
618
+ // InternetCloseHandle(hInet);
624
619
 
625
- memset(&uri, 0, sizeof(uri));
620
+ memset(&m_uri, 0, sizeof(m_uri));
626
621
 
627
- hRequest = 0;
628
- hConnection = 0;
629
- hInet = 0;
622
+ m_hRequest = 0;
623
+ m_hConnection = 0;
624
+ // hInet = 0;
630
625
  }
631
626
 
632
627
  CNetRequestImpl::~CNetRequestImpl()
@@ -644,7 +639,7 @@ void CNetRequestImpl::readInetFile( HINTERNET hRequest, CNetResponseImpl* pNetRe
644
639
  if (!pBuf)
645
640
  {
646
641
  if ( dwBufSize==0)
647
- dwBufSize=1024*4;
642
+ dwBufSize=1024*50;
648
643
 
649
644
  pBuf = (char*)malloc(dwBufSize);
650
645
  pBufToFree = pBuf;
@@ -660,7 +655,7 @@ void CNetRequestImpl::readInetFile( HINTERNET hRequest, CNetResponseImpl* pNetRe
660
655
  bRead = InternetReadFile(hRequest, pBuf, dwBufSize, &dwBytesRead);
661
656
  if ( !bRead )
662
657
  {
663
- pszErrFunction = L"InternetReadFile";
658
+ m_pszErrFunction = L"InternetReadFile";
664
659
  pNetResp->setResponseCode(408);
665
660
  break;
666
661
  }
@@ -764,27 +759,66 @@ void CNetRequestImpl::free_url_components(URL_COMPONENTS *uri)
764
759
  free(uri->lpszExtraInfo);
765
760
  }
766
761
 
762
+ bool CNetRequestImpl::initConnection(boolean bLocalHost, LPCTSTR url)
763
+ {
764
+ common::CMutexLock lock(m_mxInternet);
765
+
766
+ if (!bLocalHost)
767
+ {
768
+ if ( !SetupInternetConnection(url) )
769
+ return false;
770
+ }
771
+
772
+ if (m_hInternet)
773
+ return true;
774
+
775
+ m_hInternet = InternetOpen(_T("rhodes-wm"), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, NULL );
776
+ if ( !m_hInternet )
777
+ {
778
+ m_pszErrFunction = L"InternetOpen";
779
+ return false;
780
+ }
781
+
782
+ return true;
783
+ }
784
+
785
+ /*static*/void CNetRequestImpl::deinitConnection()
786
+ {
787
+ common::CMutexLock lock(m_mxInternet);
788
+
789
+ if (m_hInternet)
790
+ InternetCloseHandle(m_hInternet);
791
+ m_hInternet = NULL;
792
+
793
+ #if defined (_WIN32_WCE)
794
+ if ( m_hWceConnMgrConnection )
795
+ ConnMgrReleaseConnection(m_hWceConnMgrConnection, FALSE);
796
+
797
+ m_hWceConnMgrConnection = NULL;
798
+ #endif //_WIN32_WCE
799
+
800
+ }
801
+
767
802
  bool CNetRequestImpl::SetupInternetConnection(LPCTSTR url)
768
803
  {
769
804
  #if defined (_WIN32_WCE)
770
805
  int iNetwork;
771
806
  HRESULT hResult = E_FAIL;
772
807
  DWORD dwStatus;
773
- static HANDLE hConnection = NULL;
774
808
 
775
809
  // cleanup the old connection
776
- if(NULL != hConnection)
810
+ if(NULL != m_hWceConnMgrConnection)
777
811
  {
778
- hResult = ConnMgrConnectionStatus( hConnection, &dwStatus );
812
+ hResult = ConnMgrConnectionStatus( m_hWceConnMgrConnection, &dwStatus );
779
813
  if( SUCCEEDED(hResult) )
780
814
  {
781
815
  LOG(INFO) + "Internet connection exist, use it";
782
816
  if( dwStatus & CONNMGR_STATUS_CONNECTED )
783
817
  return true;
784
818
  }
785
- ConnMgrReleaseConnection(hConnection, FALSE);
819
+ ConnMgrReleaseConnection(m_hWceConnMgrConnection, FALSE);
786
820
  LOG(INFO) + "Internet connection droped, open new one";
787
- hConnection = NULL;
821
+ m_hWceConnMgrConnection = NULL;
788
822
  }
789
823
 
790
824
  // get the right network to connect to
@@ -810,17 +844,17 @@ bool CNetRequestImpl::SetupInternetConnection(LPCTSTR url)
810
844
  #endif
811
845
  ConnInfo.guidDestNet = pguid;
812
846
 
813
- hResult = ConnMgrEstablishConnection(&ConnInfo, &hConnection);
847
+ hResult = ConnMgrEstablishConnection(&ConnInfo, &m_hWceConnMgrConnection);
814
848
 
815
849
  // check to see if the attempt failed
816
850
  int count = 0;
817
851
  while(SUCCEEDED(hResult) && count++ < 60 )
818
852
  {
819
853
  LOG(INFO) + "Wait for connect (" + count + ")";
820
- DWORD dwResult = WaitForSingleObject(hConnection, 1000);
854
+ DWORD dwResult = WaitForSingleObject(m_hWceConnMgrConnection, 1000);
821
855
  if (dwResult == (WAIT_OBJECT_0))
822
856
  {
823
- hResult=ConnMgrConnectionStatus(hConnection,&dwStatus);
857
+ hResult=ConnMgrConnectionStatus(m_hWceConnMgrConnection,&dwStatus);
824
858
  if( SUCCEEDED(hResult) )
825
859
  {
826
860
  if( dwStatus & CONNMGR_STATUS_CONNECTED )
@@ -65,10 +65,15 @@ class CNetRequestImpl
65
65
  {
66
66
  DEFINE_LOGCLASS;
67
67
 
68
- LPCTSTR pszErrFunction;
69
- HINTERNET hInet, hConnection, hRequest;
70
- URL_COMPONENTS uri;
71
- CAtlStringW strReqUrlW;
68
+ static common::CMutex m_mxInternet;
69
+ static HINTERNET m_hInternet;
70
+ static HANDLE m_hWceConnMgrConnection;
71
+ HINTERNET m_hConnection, m_hRequest;
72
+
73
+ LPCTSTR m_pszErrFunction;
74
+
75
+ URL_COMPONENTS m_uri;
76
+ CAtlStringW m_strReqUrlW;
72
77
  String m_strUrl;
73
78
  CNetRequest* m_pParent;
74
79
  Hashtable<String,String>* m_pHeaders;
@@ -83,13 +88,14 @@ public :
83
88
 
84
89
  void close();
85
90
  void cancel();
86
- bool isError(){ return pszErrFunction!= null; }
91
+ bool isError(){ return m_pszErrFunction!= null; }
87
92
  CNetResponseImpl* sendString(const String& strBody);
88
93
 
89
94
  CNetResponseImpl* sendMultipartData(VectorPtr<CMultipartItem*>& arItems);
90
95
 
91
96
  CNetResponseImpl* downloadFile(common::CRhoFile& oFile);
92
97
 
98
+ static void deinitConnection();
93
99
  private:
94
100
  String makeClientCookie();
95
101
 
@@ -109,6 +115,7 @@ private:
109
115
 
110
116
  int processMultipartItems( VectorPtr<CMultipartItem*>& arItems );
111
117
 
118
+ bool initConnection(boolean bLocalHost, LPCTSTR url);
112
119
  };
113
120
 
114
121
  }
@@ -257,6 +257,16 @@ static double get_screen_ppi_y()
257
257
  return ret;
258
258
  }
259
259
 
260
+ VALUE rho_sys_get_locale()
261
+ {
262
+ wchar_t szLang[20];
263
+ int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SABBREVLANGNAME , szLang, sizeof(szLang)/sizeof(szLang[0]));
264
+ szLang[2] = 0;
265
+ wcslwr(szLang);
266
+
267
+ return rho_ruby_create_string(convertToStringA(szLang).c_str());
268
+ }
269
+
260
270
  int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
261
271
  {
262
272
  if (strcasecmp("has_camera",szPropName) == 0)
@@ -271,10 +281,24 @@ int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
271
281
  if (strcasecmp("ppi_y",szPropName) == 0)
272
282
  {*resValue = rho_ruby_create_double(get_screen_ppi_y()); return 1; }
273
283
 
284
+ if (strcasecmp("locale",szPropName) == 0)
285
+ {*resValue = rho_sys_get_locale(); return 1;}
286
+
287
+ if (strcasecmp("country",szPropName) == 0)
288
+ {
289
+ wchar_t szCountry[20];
290
+ int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SISO3166CTRYNAME , szCountry, sizeof(szCountry)/sizeof(szCountry[0]));
291
+ szCountry[2] = 0;
292
+
293
+ *resValue = rho_ruby_create_string(convertToStringA(szCountry).c_str());
294
+ return 1;
295
+ }
296
+
274
297
  if (strcasecmp("device_name",szPropName) == 0)
275
298
  {
276
299
  #ifdef OS_WINDOWS
277
300
  *resValue = rho_ruby_create_string("Win32");
301
+ return 1;
278
302
  #else
279
303
  HKEY hKey;
280
304
  if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Ident"),
@@ -315,16 +339,6 @@ int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
315
339
  return 0;
316
340
  }
317
341
 
318
- VALUE rho_sys_get_locale()
319
- {
320
- wchar_t szLang[20];
321
- int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SABBREVLANGNAME , szLang, 20);
322
- szLang[2] = 0;
323
- wcslwr(szLang);
324
-
325
- return rho_ruby_create_string(convertToStringA(szLang).c_str());
326
- }
327
-
328
342
  int rho_sys_get_screen_width()
329
343
  {
330
344
  #ifdef OS_WINCE
@@ -1,4 +1,5 @@
1
1
  #include "stdafx.h"
2
+ #include <wininet.h>
2
3
 
3
4
  #include "ruby/ext/rho/rhoruby.h"
4
5
  #include "rubyext/WebView.h"
@@ -57,6 +58,11 @@ void rho_webview_full_screen_mode(int enable)
57
58
  ::PostMessage( getMainWnd(), WM_COMMAND, ID_FULLSCREEN, (LPARAM)enable );
58
59
  }
59
60
 
61
+ void rho_webview_set_cookie(const char *url, const char *cookie)
62
+ {
63
+ ::InternetSetCookieA(url, NULL, cookie);
64
+ }
65
+
60
66
  }
61
67
 
62
68