rhodes 3.3.3.beta.4 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (497) hide show
  1. data/CHANGELOG +7 -5
  2. data/CREDITS +2215 -0
  3. data/Rakefile +225 -59
  4. data/bin/c2dm.rb +0 -0
  5. data/bin/get-rhodes-info.bat +0 -0
  6. data/bin/migrate-rhodes-app +0 -0
  7. data/bin/migrate-rhodes-app.bat +0 -0
  8. data/bin/rhodes +0 -0
  9. data/bin/rhodes-setup +0 -0
  10. data/bin/rhodes-setup.bat +0 -0
  11. data/bin/rhogen +0 -0
  12. data/bin/rhogen.bat +0 -0
  13. data/bin/set-rhodes-sdk +0 -0
  14. data/bin/set-rhodes-sdk.bat +0 -0
  15. data/bin/upgrade-rhodes-app +0 -0
  16. data/bin/upgrade-rhodes-app.bat +0 -0
  17. data/doc/build.txt +20 -9
  18. data/doc/configuration.txt +8 -8
  19. data/doc/connect-to-web-services.txt +1 -1
  20. data/doc/device-caps.txt +63 -26
  21. data/doc/extensions.txt +14 -2
  22. data/doc/install.txt +28 -19
  23. data/doc/introduction.txt +6 -3
  24. data/doc/jqt-jqm-transition.txt +10 -9
  25. data/doc/release.txt +5 -1
  26. data/doc/rhodes-command-line.txt +130 -0
  27. data/doc/rhom.txt +16 -11
  28. data/doc/rhostudio-eclipse.txt +3 -3
  29. data/doc/simulator.txt +28 -31
  30. data/doc/syncengine-ajax-api.txt +246 -0
  31. data/doc/synchronization.txt +21 -3
  32. data/doc/test-log-debug.txt +3 -1
  33. data/doc/ui.txt +16 -16
  34. data/ext/extconf.rb +8 -0
  35. data/lib/build/jake.rb +5 -5
  36. data/lib/extensions/barcode/ext/barcode/platform/android/Rakefile +9 -9
  37. data/lib/extensions/barcode/ext/barcode/platform/android/jni/src/barcode.cpp +81 -1
  38. data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/android/CaptureActivityHandler.java +6 -13
  39. data/lib/extensions/barcode/ext/barcode/platform/android/src/com/google/zxing/client/android/DecodeHandler.java +2 -6
  40. data/lib/extensions/barcode/ext/barcode/platform/android/src/com/rhomobile/barcode/Barcode.java +12 -1
  41. data/lib/extensions/barcode/ext/barcode/platform/bb/run.bat +0 -0
  42. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeCallbackHelper.h +2 -0
  43. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeCallbackHelper.mm +36 -0
  44. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeViewController.h +0 -0
  45. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/BarcodeViewController.m +15 -5
  46. data/lib/extensions/barcode/ext/barcode/platform/iphone/Classes/barcode.m +64 -1
  47. data/lib/extensions/barcode/ext/barcode/shared/ruby/barcode.i +35 -1
  48. data/lib/extensions/barcode/ext/barcode/shared/ruby/barcode_wrap.c +126 -2
  49. data/lib/extensions/barcode/ext/barcode/shared/src/zbar.c +18 -1
  50. data/lib/extensions/barcode/ext/build +0 -0
  51. data/lib/extensions/barcode/ext/build.bat +0 -0
  52. data/lib/extensions/digest-md5/ext/Rakefile +12 -10
  53. data/lib/extensions/digest-md5/ext/build +0 -0
  54. data/lib/extensions/digest-md5/ext/build.bat +0 -0
  55. data/lib/extensions/digest-md5/ext/digest-md5.sln +2 -2
  56. data/lib/extensions/digest-md5/ext/digest-md5.vcproj +41 -28
  57. data/lib/extensions/digest-sha1/ext/Rakefile +11 -10
  58. data/lib/extensions/digest-sha1/ext/build +0 -0
  59. data/lib/extensions/digest-sha1/ext/build.bat +0 -0
  60. data/lib/extensions/digest-sha1/ext/digest-sha1.sln +2 -2
  61. data/lib/extensions/digest-sha1/ext/digest-sha1.vcproj +41 -28
  62. data/lib/extensions/digest/ext/Rakefile +12 -11
  63. data/lib/extensions/digest/ext/build +0 -0
  64. data/lib/extensions/digest/ext/build.bat +0 -0
  65. data/lib/extensions/digest/ext/digest.sln +44 -0
  66. data/lib/extensions/digest/ext/digest.vcproj +40 -27
  67. data/lib/extensions/esri/ext/build +0 -0
  68. data/lib/extensions/esri/ext/build.bat +0 -0
  69. data/lib/extensions/fcntl/ext/Rakefile +10 -9
  70. data/lib/extensions/fcntl/ext/build +0 -0
  71. data/lib/extensions/fcntl/ext/build.bat +0 -0
  72. data/lib/extensions/fcntl/ext/fcntl.vcproj +1 -1
  73. data/lib/extensions/nfc/ext/build +0 -0
  74. data/lib/extensions/nfc/ext/build.bat +0 -0
  75. data/lib/extensions/nfc/ext/nfc/platform/android/Rakefile +11 -11
  76. data/lib/extensions/nfc/ext/nfc/platform/android/jni/src/nfc.cpp +0 -0
  77. data/lib/extensions/nfc/ext/nfc/platform/android/src/com/rhomobile/nfc/Nfc.java +12 -10
  78. data/lib/extensions/nfc/ext/nfc/shared/ruby/nfc_wrap.c +16 -9
  79. data/lib/extensions/pdf-writer/color.rb +145 -0
  80. data/lib/extensions/pdf-writer/color/cmyk.rb +279 -0
  81. data/lib/extensions/pdf-writer/color/css.rb +28 -0
  82. data/lib/extensions/pdf-writer/color/grayscale.rb +212 -0
  83. data/lib/extensions/pdf-writer/color/hsl.rb +221 -0
  84. data/lib/extensions/pdf-writer/color/palette.rb +16 -0
  85. data/lib/extensions/pdf-writer/color/palette/adobecolor.rb +272 -0
  86. data/lib/extensions/pdf-writer/color/palette/gimp.rb +116 -0
  87. data/lib/extensions/pdf-writer/color/palette/monocontrast.rb +180 -0
  88. data/lib/extensions/pdf-writer/color/rgb-colors.rb +355 -0
  89. data/lib/extensions/pdf-writer/color/rgb.rb +453 -0
  90. data/lib/extensions/pdf-writer/color/rgb/metallic.rb +43 -0
  91. data/lib/extensions/pdf-writer/color/yiq.rb +84 -0
  92. data/lib/extensions/pdf-writer/ext/LICENSES/color/Licence.txt +27 -0
  93. data/lib/extensions/pdf-writer/ext/LICENSES/color/README.txt +32 -0
  94. data/lib/extensions/pdf-writer/ext/LICENSES/pdf-writer/LICENCE +131 -0
  95. data/lib/extensions/pdf-writer/ext/LICENSES/pdf-writer/README +33 -0
  96. data/lib/extensions/pdf-writer/ext/LICENSES/transaction-simple/Licence.txt +25 -0
  97. data/lib/extensions/pdf-writer/ext/LICENSES/transaction-simple/Readme.txt +204 -0
  98. data/lib/extensions/pdf-writer/pdf/charts.rb +13 -0
  99. data/lib/extensions/pdf-writer/pdf/charts/stddev.rb +430 -0
  100. data/lib/extensions/pdf-writer/pdf/math.rb +108 -0
  101. data/lib/extensions/pdf-writer/pdf/quickref.rb +332 -0
  102. data/lib/extensions/pdf-writer/pdf/simpletable.rb +947 -0
  103. data/lib/extensions/pdf-writer/pdf/techbook.rb +901 -0
  104. data/lib/extensions/pdf-writer/pdf/writer.rb +2729 -0
  105. data/lib/extensions/pdf-writer/pdf/writer/arc4.rb +63 -0
  106. data/lib/extensions/pdf-writer/pdf/writer/fontmetrics.rb +203 -0
  107. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier-Bold.afm +342 -0
  108. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
  109. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier-Oblique.afm +342 -0
  110. data/lib/extensions/pdf-writer/pdf/writer/fonts/Courier.afm +342 -0
  111. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
  112. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
  113. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
  114. data/lib/extensions/pdf-writer/pdf/writer/fonts/Helvetica.afm +3051 -0
  115. data/lib/extensions/pdf-writer/pdf/writer/fonts/MustRead.html +19 -0
  116. data/lib/extensions/pdf-writer/pdf/writer/fonts/Symbol.afm +213 -0
  117. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-Bold.afm +2588 -0
  118. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
  119. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-Italic.afm +2667 -0
  120. data/lib/extensions/pdf-writer/pdf/writer/fonts/Times-Roman.afm +2419 -0
  121. data/lib/extensions/pdf-writer/pdf/writer/fonts/ZapfDingbats.afm +225 -0
  122. data/lib/extensions/pdf-writer/pdf/writer/graphics.rb +813 -0
  123. data/lib/extensions/pdf-writer/pdf/writer/graphics/imageinfo.rb +365 -0
  124. data/lib/extensions/pdf-writer/pdf/writer/lang.rb +43 -0
  125. data/lib/extensions/pdf-writer/pdf/writer/lang/en.rb +99 -0
  126. data/lib/extensions/pdf-writer/pdf/writer/object.rb +23 -0
  127. data/lib/extensions/pdf-writer/pdf/writer/object/action.rb +35 -0
  128. data/lib/extensions/pdf-writer/pdf/writer/object/annotation.rb +42 -0
  129. data/lib/extensions/pdf-writer/pdf/writer/object/catalog.rb +39 -0
  130. data/lib/extensions/pdf-writer/pdf/writer/object/contents.rb +65 -0
  131. data/lib/extensions/pdf-writer/pdf/writer/object/destination.rb +40 -0
  132. data/lib/extensions/pdf-writer/pdf/writer/object/encryption.rb +53 -0
  133. data/lib/extensions/pdf-writer/pdf/writer/object/font.rb +72 -0
  134. data/lib/extensions/pdf-writer/pdf/writer/object/fontdescriptor.rb +34 -0
  135. data/lib/extensions/pdf-writer/pdf/writer/object/fontencoding.rb +40 -0
  136. data/lib/extensions/pdf-writer/pdf/writer/object/image.rb +304 -0
  137. data/lib/extensions/pdf-writer/pdf/writer/object/info.rb +51 -0
  138. data/lib/extensions/pdf-writer/pdf/writer/object/outline.rb +30 -0
  139. data/lib/extensions/pdf-writer/pdf/writer/object/outlines.rb +30 -0
  140. data/lib/extensions/pdf-writer/pdf/writer/object/page.rb +195 -0
  141. data/lib/extensions/pdf-writer/pdf/writer/object/pages.rb +115 -0
  142. data/lib/extensions/pdf-writer/pdf/writer/object/procset.rb +46 -0
  143. data/lib/extensions/pdf-writer/pdf/writer/object/viewerpreferences.rb +74 -0
  144. data/lib/extensions/pdf-writer/pdf/writer/ohash.rb +58 -0
  145. data/lib/extensions/pdf-writer/pdf/writer/oreader.rb +25 -0
  146. data/lib/extensions/pdf-writer/pdf/writer/state.rb +48 -0
  147. data/lib/extensions/pdf-writer/pdf/writer/strokestyle.rb +138 -0
  148. data/lib/extensions/pdf-writer/transaction/simple.rb +486 -0
  149. data/lib/extensions/pdf-writer/transaction/simple/group.rb +146 -0
  150. data/lib/extensions/pdf-writer/transaction/simple/threadsafe.rb +68 -0
  151. data/lib/extensions/pdf-writer/transaction/simple/threadsafe/group.rb +36 -0
  152. data/lib/framework/builtinME.rb +0 -0
  153. data/lib/framework/dateOrig.rb +8 -2
  154. data/lib/framework/rational.rb +0 -0
  155. data/lib/framework/res/esri.wm.png +0 -0
  156. data/lib/framework/rho/rho.rb +6 -0
  157. data/lib/framework/rho/rhobluetooth.rb +0 -0
  158. data/lib/framework/rho/rhofsconnector.rb +0 -0
  159. data/lib/framework/rho/rhonativeviewmanager.rb +0 -0
  160. data/lib/framework/rhofsconnector.rb +0 -0
  161. data/lib/framework/rhom/rhom_object_factory.rb +8 -0
  162. data/lib/framework/rhomotoapi.rb +3 -2
  163. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +9 -1
  164. data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +1 -0
  165. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_file_RhoFileApi.h +26 -2
  166. data/platform/android/Rhodes/jni/src/callbacks.cpp +0 -5
  167. data/platform/android/Rhodes/jni/src/camera.cpp +1 -1
  168. data/platform/android/Rhodes/jni/src/fileapi.cpp +39 -19
  169. data/platform/android/Rhodes/jni/src/geolocation.cpp +3 -3
  170. data/platform/android/Rhodes/jni/src/mapview.cpp +206 -64
  171. data/platform/android/Rhodes/jni/src/nativeview.cpp +1 -1
  172. data/platform/android/Rhodes/jni/src/rhodes.cpp +13 -0
  173. data/platform/android/Rhodes/jni/src/rhodesapp.cpp +20 -0
  174. data/platform/android/Rhodes/jni/src/rhodessystem.cpp +36 -3
  175. data/platform/android/Rhodes/jni/src/signature.cpp +22 -2
  176. data/platform/android/Rhodes/res/drawable/alert_info.png +0 -0
  177. data/platform/android/Rhodes/res/drawable/esri.png +0 -0
  178. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +17 -16
  179. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Logger.java +4 -1
  180. data/platform/android/Rhodes/src/com/rhomobile/rhodes/MemoryInfoCollector.java +67 -0
  181. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +139 -114
  182. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +106 -13
  183. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +11 -3
  184. data/platform/android/Rhodes/src/com/rhomobile/rhodes/WebView.java +71 -16
  185. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraNewService.java +4 -1
  186. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/CameraSemiService.java +4 -1
  187. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/AbstractRhoExtension.java +22 -1
  188. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/Config.java +243 -0
  189. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtManager.java +19 -1
  190. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/IRhoExtension.java +9 -1
  191. data/platform/android/Rhodes/src/com/rhomobile/rhodes/{RhodesActivityListener.java → extmanager/IRhoListener.java} +16 -12
  192. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManager.java +63 -1
  193. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhoExtManagerImpl.java +239 -14
  194. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/RhodesStartupListeners.java +9 -0
  195. data/platform/android/Rhodes/src/com/rhomobile/rhodes/extmanager/WebkitExtension.java +53 -0
  196. data/platform/android/Rhodes/src/com/rhomobile/rhodes/file/RhoFileApi.java +27 -12
  197. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +124 -62
  198. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +49 -137
  199. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +84 -114
  200. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SplashScreen.java +75 -82
  201. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +3 -2
  202. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Callout.java +4 -0
  203. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapBitmapManager.java +124 -0
  204. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/MapView.java +232 -43
  205. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mapview/Request.java +193 -0
  206. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/IRhoCustomView.java +13 -0
  207. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +32 -23
  208. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java +74 -0
  209. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality.java +6 -7
  210. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality01.java +37 -0
  211. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality03.java +14 -1
  212. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality05.java +51 -38
  213. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality07.java +9 -1
  214. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionality08.java +48 -31
  215. data/platform/android/Rhodes/src/com/rhomobile/rhodes/osfunctionality/AndroidFunctionalityManager.java +15 -16
  216. data/platform/android/Rhodes/src/com/rhomobile/rhodes/signature/Signature.java +52 -15
  217. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/LocalFileHandler.java +20 -2
  218. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientOld.java +1 -0
  219. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/GoogleWebView.java +77 -34
  220. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/IRhoWebView.java +9 -0
  221. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebChromeClient.java +105 -0
  222. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebViewClient.java +1 -1
  223. data/platform/android/build/RhodesSRC_build.files +8 -7
  224. data/platform/android/build/android.rake +326 -216
  225. data/platform/android/build/androidcommon.rb +27 -13
  226. data/platform/bb/RubyVM/src/com/rho/file/SimpleFile.java +27 -1
  227. data/platform/bb/RubyVM/src/j2me/io/File.java +104 -38
  228. data/platform/bb/build/bb.rake +1 -0
  229. data/platform/bb/build/runRAPC.bat +0 -0
  230. data/platform/bb/rhodes/resources/background.png +0 -0
  231. data/platform/bb/rhodes/resources/esri.png +0 -0
  232. data/platform/bb/rhodes/resources/mappin.png +0 -0
  233. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +5 -1
  234. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +2 -2
  235. data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapField.java +0 -0
  236. data/platform/bb/rhodes/src/rhomobile/mapview/ESRIMapProvider.java +0 -0
  237. data/platform/bb/rhodes/src/rhomobile/mapview/GeoCoding.java +0 -0
  238. data/platform/bb/rhodes/src/rhomobile/mapview/GoogleGeoCoding.java +0 -0
  239. data/platform/bb/rhodes/src/rhomobile/mapview/MapTools.java +0 -0
  240. data/platform/iphone/Classes/AppManager/AppManager.m +7 -1
  241. data/platform/iphone/Classes/Camera/PickImageDelegate.h +9 -0
  242. data/platform/iphone/Classes/Camera/PickImageDelegate.m +75 -4
  243. data/platform/iphone/Classes/GeoLocation/LocationController.h +8 -2
  244. data/platform/iphone/Classes/GeoLocation/LocationController.m +74 -76
  245. data/platform/iphone/Classes/InitMemoryInfoCollector.h +33 -0
  246. data/platform/iphone/Classes/InitMemoryInfoCollector.mm +52 -0
  247. data/platform/iphone/Classes/NativeView/NVViewController.h +0 -0
  248. data/platform/iphone/Classes/NativeView/NVViewController.m +34 -2
  249. data/platform/iphone/Classes/Rhodes.m +22 -2
  250. data/platform/iphone/Classes/Signature/SignatureDelegate.m +19 -0
  251. data/platform/iphone/Classes/Signature/SignatureViewController.h +0 -0
  252. data/platform/iphone/Classes/Signature/SignatureViewController.m +0 -0
  253. data/platform/iphone/Classes/SimpleMainView.h +0 -0
  254. data/platform/iphone/Classes/SimpleMainView.m +3 -3
  255. data/platform/iphone/ESRI/BluePushpin.png +0 -0
  256. data/platform/iphone/ESRI/BluePushpin@2x.png +0 -0
  257. data/platform/iphone/ESRI/esri.png +0 -0
  258. data/platform/iphone/ESRI/esri@2x.png +0 -0
  259. data/platform/iphone/rbuild/iphone.rake +75 -7
  260. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +13 -4
  261. data/platform/linux/target/compiler/rubylinux +0 -0
  262. data/platform/mac/target/compiler/RubyMac +0 -0
  263. data/platform/osx/Rhodes Launcher/rhorunner.app/rhorunner b/data/platform/osx/Rhodes → Launcher/rhorunner.app/rhorunner +0 -0
  264. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore +0 -0
  265. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtGui.framework/Resources/qt_menu.nib/keyedobjects.nib +0 -0
  266. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui +0 -0
  267. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork +0 -0
  268. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/QtWebKit.framework/Versions/4/QtWebKit +0 -0
  269. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Info.plist +1 -1
  270. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/MacOS/RhoSimulator +0 -0
  271. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/accessible/libqtaccessiblewidgets.dylib +0 -0
  272. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqcorewlanbearer.dylib +0 -0
  273. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/bearer/libqgenericbearer.dylib +0 -0
  274. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqcncodecs.dylib +0 -0
  275. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqjpcodecs.dylib +0 -0
  276. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqkrcodecs.dylib +0 -0
  277. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/codecs/libqtwcodecs.dylib +0 -0
  278. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/graphicssystems/libqtracegraphicssystem.dylib +0 -0
  279. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqgif.dylib +0 -0
  280. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqico.dylib +0 -0
  281. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqjpeg.dylib +0 -0
  282. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqmng.dylib +0 -0
  283. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtga.dylib +0 -0
  284. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/imageformats/libqtiff.dylib +0 -0
  285. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_inspector.dylib +0 -0
  286. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/qmltooling/libqmldbg_tcp.dylib +0 -0
  287. data/platform/osx/build/osx.rake +6 -8
  288. data/platform/shared/RhoConnectClient/RhoConnectClient.cpp +165 -33
  289. data/platform/shared/RhoConnectClient/RhoConnectClient.h +10 -1
  290. data/platform/shared/common/BundleManager.cpp +27 -16
  291. data/platform/shared/common/ExtManager.h +15 -2
  292. data/platform/shared/common/RhoConf.cpp +17 -2
  293. data/platform/shared/common/RhoConf.h +3 -1
  294. data/platform/shared/common/RhoDefs.h +6 -6
  295. data/platform/shared/common/RhoFatalError.h +1 -1
  296. data/platform/shared/common/RhoFile.cpp +9 -9
  297. data/platform/shared/common/RhoFilePath.h +7 -3
  298. data/platform/shared/common/RhoPort.h +3 -3
  299. data/platform/shared/common/RhoSystem.h +1 -1
  300. data/platform/shared/common/RhodesApp.cpp +426 -26
  301. data/platform/shared/common/RhodesApp.h +11 -3
  302. data/platform/shared/common/RhodesAppBase.cpp +4 -1
  303. data/platform/shared/common/StringConverter.h +3 -3
  304. data/platform/shared/common/app_build_capabilities.h +8 -0
  305. data/platform/shared/common/map/BaseMapEngine.cpp +302 -21
  306. data/platform/shared/common/map/BaseMapEngine.h +132 -6
  307. data/platform/shared/common/map/ESRIMapEngine.cpp +2 -1
  308. data/platform/shared/common/map/GeocodingMapEngine.cpp +22 -4
  309. data/platform/shared/common/map/GeocodingMapEngine.h +40 -0
  310. data/platform/shared/common/map/GoogleMapEngine.cpp +13 -1
  311. data/platform/shared/common/map/MapEngine.h +7 -0
  312. data/platform/shared/common/map/OSMMapEngine.cpp +12 -1
  313. data/platform/shared/json/JSONIterator.cpp +1 -1
  314. data/platform/shared/json/RJSONTokener.c +2 -0
  315. data/platform/shared/json/config.h +3 -3
  316. data/platform/shared/logging/RhoLog.cpp +12 -3
  317. data/platform/shared/logging/RhoLog.h +2 -1
  318. data/platform/shared/logging/RhoLogConf.cpp +147 -11
  319. data/platform/shared/logging/RhoLogConf.h +39 -1
  320. data/platform/shared/logging/RhoLogSink.cpp +1 -1
  321. data/platform/shared/net/HttpServer.cpp +8 -4
  322. data/platform/shared/net/INetRequest.cpp +7 -0
  323. data/platform/shared/net/INetRequest.h +2 -0
  324. data/platform/shared/net/RawSocket.cpp +1 -1
  325. data/platform/shared/qt/pbxproj2pro.pl +0 -0
  326. data/platform/shared/qt/pro_vcproj_diff.pl +0 -0
  327. data/platform/shared/qt/rhodes/QtMainWindow.cpp +1 -1
  328. data/platform/shared/qt/rhodes/impl/RhoClassFactoryImpl.h +2 -2
  329. data/platform/shared/qt/rhodes/impl/RhoThreadImpl.cpp +2 -2
  330. data/platform/shared/qt/rhodes/impl/SystemImpl.cpp +11 -1
  331. data/platform/shared/qt/rhodes/main.cpp +5 -5
  332. data/platform/shared/ruby/ext/alert/alert_wrap.c +8 -8
  333. data/platform/shared/ruby/ext/bluetooth/bluetooth.i +0 -0
  334. data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +16 -9
  335. data/platform/shared/ruby/ext/camera/camera.i +2 -2
  336. data/platform/shared/ruby/ext/camera/camera_wrap.c +18 -3
  337. data/platform/shared/ruby/ext/datetimepicker/datetimepicker_wrap.c +37 -8
  338. data/platform/shared/ruby/ext/geolocation/geolocation_wrap.c +8 -8
  339. data/platform/shared/ruby/ext/mapview/mapview_wrap.c +16 -9
  340. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +16 -9
  341. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager.i +0 -0
  342. data/platform/shared/ruby/ext/nativeviewmanager/nativeviewmanager_wrap.c +16 -9
  343. data/platform/shared/ruby/ext/phonebook/phonebook_wrap.c +8 -1
  344. data/platform/shared/ruby/ext/rho/rhoruby.c +7 -1
  345. data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
  346. data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +16 -9
  347. data/platform/shared/ruby/ext/signature/signature.i +0 -0
  348. data/platform/shared/ruby/ext/signature/signature_wrap.c +9 -9
  349. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +16 -9
  350. data/platform/shared/ruby/ext/system/system_wrap.c +16 -9
  351. data/platform/shared/ruby/ext/webview/webview_wrap.c +16 -9
  352. data/platform/shared/ruby/gc.c +1 -0
  353. data/platform/shared/ruby/regint.h +6 -4
  354. data/platform/shared/ruby/vm.c +1 -0
  355. data/platform/shared/ruby/wince/wince.h +1 -1
  356. data/platform/shared/rubyext/System.cpp +1 -1
  357. data/platform/shared/shttpd/src/rdispatcher.c +3 -3
  358. data/platform/shared/shttpd/src/std_includes.h +1 -1
  359. data/platform/shared/sqlite/sqlite3.c +1 -0
  360. data/platform/shared/statistic/test/TestProfiling.cpp +1 -1
  361. data/platform/shared/stlport/build/lib/configure +0 -0
  362. data/platform/shared/stlport/build/lib/configure.bat +0 -0
  363. data/platform/shared/sync/SyncEngine.cpp +9 -12
  364. data/platform/shared/sync/SyncNotify.cpp +36 -3
  365. data/platform/shared/sync/SyncNotify.h +11 -4
  366. data/platform/shared/sync/SyncSource.cpp +32 -16
  367. data/platform/shared/sync/SyncSource.h +2 -3
  368. data/platform/shared/sync/SyncThread.cpp +13 -4
  369. data/platform/shared/sync/SyncThread.h +4 -0
  370. data/platform/shared/tcmalloc/page_heap.h +1 -1
  371. data/platform/shared/tcmalloc/rhomem.h +1 -1
  372. data/platform/shared/tcmalloc/windows/port.cpp +12 -3
  373. data/platform/shared/test/Tests.cpp +4 -4
  374. data/platform/shared/test/test_helper.cpp +4 -4
  375. data/platform/symbian/sqlite3/src/sqlite3.h +1 -1
  376. data/platform/win32/RhoSimulator/Microsoft.VC90.CRT.manifest +6 -0
  377. data/platform/win32/RhoSimulator/Microsoft.VC90.OpenMP.manifest +6 -0
  378. data/platform/win32/RhoSimulator/QtCore4.dll +0 -0
  379. data/platform/win32/RhoSimulator/QtGui4.dll +0 -0
  380. data/platform/win32/RhoSimulator/QtNetwork4.dll +0 -0
  381. data/platform/win32/RhoSimulator/QtWebKit4.dll +0 -0
  382. data/platform/win32/RhoSimulator/RhoSimulator.exe +0 -0
  383. data/platform/win32/RhoSimulator/imageformats/qgif4.dll +0 -0
  384. data/platform/win32/RhoSimulator/imageformats/qico4.dll +0 -0
  385. data/platform/win32/RhoSimulator/imageformats/qjpeg4.dll +0 -0
  386. data/platform/win32/RhoSimulator/imageformats/qmng4.dll +0 -0
  387. data/platform/win32/RhoSimulator/imageformats/qsvg4.dll +0 -0
  388. data/platform/win32/RhoSimulator/imageformats/qtiff4.dll +0 -0
  389. data/platform/win32/RhoSimulator/libeay32.dll +0 -0
  390. data/platform/win32/RhoSimulator/msvcm90.dll +0 -0
  391. data/platform/win32/RhoSimulator/msvcp90.dll +0 -0
  392. data/platform/win32/RhoSimulator/msvcr90.dll +0 -0
  393. data/platform/win32/RhoSimulator/phonon4.dll +0 -0
  394. data/platform/win32/RhoSimulator/ssleay32.dll +0 -0
  395. data/platform/win32/RhoSimulator/vcomp90.dll +0 -0
  396. data/platform/win32/target/replaceicon/replaceicon.exe +0 -0
  397. data/platform/win32/target/updateresstring/updateresstring.exe +0 -0
  398. data/platform/wm/RhoLib/RhoLib.vcproj +394 -69
  399. data/platform/wm/build/build_inf.js +83 -23
  400. data/platform/wm/build/wm.rake +127 -81
  401. data/platform/wm/rhodes.sln +6 -6
  402. data/platform/wm/rhodes/DateTimePicker.h +2 -2
  403. data/platform/wm/rhodes/IBrowserEngine.h +3 -0
  404. data/platform/wm/rhodes/IEBrowserEngine.cpp +34 -2
  405. data/platform/wm/rhodes/IEBrowserEngine.h +4 -1
  406. data/platform/wm/rhodes/LicenseStub.cpp +73 -0
  407. data/platform/{android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java → wm/rhodes/LogMemory.cpp} +32 -20
  408. data/platform/{android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettings.java → wm/rhodes/LogMemory.h} +11 -8
  409. data/platform/wm/rhodes/LogOptionsDlg.h +1 -1
  410. data/platform/wm/rhodes/LogView.cpp +10 -10
  411. data/platform/wm/rhodes/LogView.h +10 -10
  412. data/platform/wm/rhodes/MainWindow.cpp +431 -173
  413. data/platform/wm/rhodes/MainWindow.h +37 -19
  414. data/platform/wm/rhodes/MapView/MapViewManager.h +1 -1
  415. data/platform/wm/rhodes/OkCancelModalDialog.h +1 -1
  416. data/platform/wm/rhodes/Rhodes.cpp +210 -47
  417. data/platform/wm/rhodes/Rhodes.rc +38 -0
  418. data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +2 -2
  419. data/platform/wm/rhodes/bluetooth/Bluetooth.h +3 -3
  420. data/platform/wm/rhodes/camera/Camera.cpp +2 -1
  421. data/platform/wm/rhodes/camera/Camera.h +1 -1
  422. data/platform/wm/rhodes/resource.h +1 -1
  423. data/platform/wm/rhodes/rho/common/ExtManager.cpp +93 -5
  424. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +2 -2
  425. data/platform/wm/rhodes/rho/rubyext/NativeToolbar.cpp +2 -2
  426. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +13 -7
  427. data/platform/wm/rhodes/rhodes.vcproj +1409 -1008
  428. data/platform/wm/rhodes/simulator/MainWindowQt.h +1 -1
  429. data/platform/wm/rhodes/stdafx.h +2 -2
  430. data/platform/wm/rhoelements.sln +7 -9
  431. data/platform/wm/rubylib/rubylib.vcproj +62 -1
  432. data/platform/wm/sqlite3/sqlite3.vcproj +62 -1
  433. data/platform/wm/syncengine/syncengine.vcproj +62 -1
  434. data/platform/wm/tcmalloc/tcmalloc.vcproj +72 -53
  435. data/platform/wm/tools/detool/detool.cpp +1435 -1357
  436. data/platform/wp7/RhoRubyExtGen/GenerateInitializers.cmd +0 -0
  437. data/platform/wp7/RhoRubyLib/common/RhoLicense.cs +105 -0
  438. data/platform/wp7/RhoRubyLib/common/RhodesApp.cs +23 -5
  439. data/platform/wp7/RhoRubyLib/sync/SyncNotify.cs +5 -0
  440. data/platform/wp7/RhoRubyLib/views/RhoView.xaml.cs +22 -3
  441. data/platform/wp7/build/wp.rake +1 -0
  442. data/platform/wp7/rhodes/MainPage.xaml.cs +11 -0
  443. data/rakefile.rb +225 -59
  444. data/res/build-tools/7za.exe +0 -0
  445. data/res/build-tools/RhoAppRunner.exe +0 -0
  446. data/res/build-tools/RhoLogServer.exe +0 -0
  447. data/res/build-tools/RhoRuby.exe +0 -0
  448. data/res/build-tools/RubyMac +0 -0
  449. data/res/build-tools/detool.exe +0 -0
  450. data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +1 -1
  451. data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
  452. data/res/build-tools/iphonesim/build/Release/iphonesim_43 +0 -0
  453. data/res/build-tools/license_rc.dll +0 -0
  454. data/res/build-tools/make.exe +0 -0
  455. data/res/build-tools/rubylinux +0 -0
  456. data/res/build-tools/swig_patch/Lib/typemaps/fragments.swg +235 -0
  457. data/res/build-tools/wmdc_connect.exe +0 -0
  458. data/res/build-tools/wp7explorer.exe +0 -0
  459. data/res/generators/rhogen.rb +2 -2
  460. data/res/generators/templates/application/app/Settings/controller.rb +1 -1
  461. data/res/generators/templates/application/app/layout.erb +1 -1
  462. data/res/generators/templates/application/app/loading.png +0 -0
  463. data/res/generators/templates/application/public/css/re_webkit.css +736 -0
  464. data/res/generators/templates/application/public/css/windows_mobile.css +0 -0
  465. data/res/generators/templates/application/public/images/listArrow.png +0 -0
  466. data/res/generators/templates/application/public/jqmobile/images/ajax-loader.png +0 -0
  467. data/res/generators/templates/application/public/jqmobile/images/icons-18-black.png +0 -0
  468. data/res/generators/templates/application/public/jqmobile/images/icons-18-white.png +0 -0
  469. data/res/generators/templates/application/public/jqmobile/images/icons-36-black.png +0 -0
  470. data/res/generators/templates/application/public/jqmobile/images/icons-36-white.png +0 -0
  471. data/res/generators/templates/application/public/js/syncengine.js +409 -52
  472. data/res/generators/templates/extension/extensions/montana/ext/build +0 -0
  473. data/res/generators/templates/extension/extensions/montana/ext/build.bat +0 -0
  474. data/res/generators/templates/extension/extensions/montana/ext/montana/platform/android/Rakefile +10 -10
  475. data/res/generators/templates/spec/app/SpecRunner/controller.rb +2 -0
  476. data/res/libs/motorolalicence/android/MotorolaLicence.h +13 -0
  477. data/res/libs/motorolalicence/android/libMotorolaLicence.a +0 -0
  478. data/res/libs/motorolalicence/iphone/MotorolaLicence.h +13 -0
  479. data/res/libs/motorolalicence/iphone/libMotorolaLicence.a +0 -0
  480. data/rhodes.gemspec +1 -1
  481. data/spec/framework_spec/app/SpecRunner/controller.rb +2 -0
  482. data/spec/phone_spec/app/SpecRunner/controller.rb +2 -0
  483. data/version +1 -1
  484. metadata +487 -412
  485. data/Manifest.txt +0 -7960
  486. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivityStartupListeners.java +0 -12
  487. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +0 -52
  488. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsOld.java +0 -62
  489. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/Frameworks/phonon.framework/Versions/4/phonon +0 -0
  490. data/platform/osx/bin/RhoSimulator/RhoSimulator.app/Contents/PlugIns/phonon_backend/libphonon_qt7.dylib +0 -0
  491. data/platform/win32/RhoSimulator/Microsoft.VC80.CRT.manifest +0 -8
  492. data/platform/win32/RhoSimulator/Microsoft.VC80.OpenMP.manifest +0 -7
  493. data/platform/win32/RhoSimulator/msvcm80.dll +0 -0
  494. data/platform/win32/RhoSimulator/msvcp80.dll +0 -0
  495. data/platform/win32/RhoSimulator/msvcr80.dll +0 -0
  496. data/platform/win32/RhoSimulator/vcomp.dll +0 -0
  497. data/rhomobile-debug-1.0.6.gem +0 -0
@@ -1,769 +1,824 @@
1
- /*------------------------------------------------------------------------
2
- * (The MIT License)
3
- *
4
- * Copyright (c) 2008-2011 Rhomobile, Inc.
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- * THE SOFTWARE.
23
- *
24
- * http://rhomobile.com
25
- *------------------------------------------------------------------------*/
26
-
27
- #include "stdafx.h"
28
-
29
- #include <rapi.h>
30
- #include <strsafe.h>
31
-
32
- #include "detool.h"
33
- #include "LogServer.h"
34
-
35
- #define RHOSETUP_DLL "rhosetup.dll"
36
- #define RE2_RUNTIME TEXT("\\Program Files\\RhoElements2\\RhoElements2.exe")
37
-
38
- TCHAR *app_name = NULL;
39
-
40
- void checkMDEstart(HRESULT hr)
41
- {
42
- if (FAILED(hr)) {
43
- if (hr == REGDB_E_CLASSNOTREG) {
44
- printf ("Microsoft Device Emulator is too old or corrupted. Please update it.\n");
45
- printf ("You could get the latest version on:\n");
46
- printf ("http://www.microsoft.com/downloads/details.aspx?familyid=a6f6adaf-12e3-4b2f-a394-356e2c2fb114\n");
47
- } else {
48
- wprintf_s(L"Error: Unable to instantiate DeviceEmulatorManager. ErrorCode=0x%08X\n", hr);
49
- }
50
- }
51
- }
52
-
53
- DWORD WINAPI startDEM(LPVOID lpParam)
54
- {
55
- if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
56
- HRESULT hr = 0;
57
-
58
- CComPtr<IDeviceEmulatorManager> pDeviceEmulatorManager;
59
- hr = pDeviceEmulatorManager.CoCreateInstance(__uuidof(DeviceEmulatorManager));
60
- if (FAILED(hr)) {
61
- checkMDEstart(hr);
62
- ExitProcess(EXIT_FAILURE);
63
- return hr;
64
- }
65
-
66
- pDeviceEmulatorManager->ShowManagerUI(false);
67
- while (1) {
68
- Sleep(600 * 1000);
69
- }
70
- return hr;
71
- CoUninitialize();
72
- }
73
- return 0;
74
- }
75
-
76
- BOOL FindDevice(const CComBSTR& deviceIdentifier, IDeviceEmulatorManagerVMID** pDeviceVMID)
77
- {
78
- HRESULT hr;
79
-
80
- CComPtr<IDeviceEmulatorManager> pDeviceEmulatorManager;
81
- hr = pDeviceEmulatorManager.CoCreateInstance(__uuidof(DeviceEmulatorManager));
82
- if (FAILED(hr)) {
83
- wprintf(L"Error: Unable to instantiate DeviceEmulatorManager. ErrorCode=0x%08X\n", hr);
84
- return FALSE;
85
- }
86
-
87
- for (; SUCCEEDED(hr); (hr = pDeviceEmulatorManager->MoveNext()))
88
- {
89
- CComPtr<IEnumManagerSDKs> pSDKEnumerator;
90
-
91
- hr = pDeviceEmulatorManager->EnumerateSDKs(&pSDKEnumerator);
92
- if (FAILED(hr)) {
93
- continue;
94
- }
95
-
96
- for (; SUCCEEDED(hr); (hr = pSDKEnumerator->MoveNext())) {
97
- CComPtr<IEnumVMIDs> pDeviceEnumerator;
98
- hr = pSDKEnumerator->EnumerateVMIDs(&pDeviceEnumerator);
99
- if (FAILED(hr)) {
100
- continue;
101
- }
102
-
103
- for (; SUCCEEDED(hr); (hr = pDeviceEnumerator->MoveNext())) {
104
- CComBSTR deviceName;
105
- CComBSTR deviceVMID;
106
- CComPtr<IDeviceEmulatorManagerVMID> pDevice;
107
-
108
- hr = pDeviceEnumerator->GetVMID(&pDevice);
109
- if (FAILED(hr)) {
110
- continue;
111
- }
112
-
113
- hr = pDevice->get_Name(&deviceName);
114
- if (FAILED(hr)){
115
- continue;
116
- }
117
-
118
- hr = pDevice->get_VMID(&deviceVMID);
119
- if (FAILED(hr)){
120
- continue;
121
- }
122
-
123
- if (deviceIdentifier == deviceName || deviceIdentifier == deviceVMID){
124
- *pDeviceVMID = pDevice;
125
- (*pDeviceVMID)->AddRef();
126
- return TRUE;
127
- }
128
- }
129
- }
130
- }
131
-
132
- wprintf(L"Error: Unable to locate the device '%s'", deviceIdentifier);
133
- return FALSE;
134
- }
135
-
136
- bool emuConnect(const CComBSTR& deviceIdentifier)
137
- {
138
- CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
139
-
140
- BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
141
- if (bFound && pDevice){
142
- HRESULT hr = pDevice->Connect();
143
- if (!SUCCEEDED(hr)) {
144
- wprintf(L"Error: Operation Connect failed. Hr=0x%x\n", hr);
145
- return false;
146
- }
147
- return true;
148
- }
149
- return false;
150
- }
151
-
152
- bool emuBringToFront(const CComBSTR& deviceIdentifier)
153
- {
154
- CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
155
-
156
- BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
157
- if (bFound && pDevice){
158
- HRESULT hr = pDevice->BringToFront();
159
- if (!SUCCEEDED(hr)) {
160
- wprintf(L"Error: Operation BringToFront failed. Hr=0x%x\n", hr);
161
- return false;
162
- }
163
- return true;
164
- }
165
- return false;
166
- }
167
-
168
- bool emuCradle(const CComBSTR& deviceIdentifier)
169
- {
170
- CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
171
-
172
- BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
173
- if (bFound && pDevice){
174
- HRESULT hr = pDevice->Cradle();
175
- if (!SUCCEEDED(hr)) {
176
- wprintf(L"Error: Operation Cradle failed. Hr=0x%x\n", hr);
177
- return false;
178
- }
179
- return true;
180
- }
181
- return false;
182
- }
183
-
184
- bool emuUncradle(const CComBSTR& deviceIdentifier)
185
- {
186
- CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
187
-
188
- BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
189
-
190
- if (bFound && pDevice){
191
- HRESULT hr = pDevice->UnCradle();
192
- if (!SUCCEEDED(hr)) {
193
- wprintf(L"Error: Operation UnCradle failed. Hr=0x%x\n", hr);
194
- return false;
195
- }
196
- return true;
197
- }
198
-
199
- return false;
200
- }
201
-
202
- bool emuReset(const CComBSTR& deviceIdentifier)
203
- {
204
- CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
205
-
206
- BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
207
- if (bFound && pDevice){
208
- HRESULT hr = pDevice->Reset(TRUE);
209
- if (!SUCCEEDED(hr)) {
210
- wprintf(L"Error: Operation ResetEmulator failed. Hr=0x%x\n", hr);
211
- return false;
212
- }
213
- return true;
214
- }
215
- return false;
216
- }
217
-
218
- bool emuShutdown(const CComBSTR& deviceIdentifier)
219
- {
220
- CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
221
-
222
- BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
223
- if (bFound && pDevice){
224
- HRESULT hr = pDevice->Shutdown(FALSE);
225
- if (!SUCCEEDED(hr)) {
226
- wprintf(L"Error: Operation Shutdown failed. Hr=0x%x\n", hr);
227
- return false;
228
- }
229
- return true;
230
- }
231
- return false;
232
- }
233
-
234
- bool wceConnect (void)
235
- {
236
- HRESULT hRapiResult;
237
-
238
- //_tprintf( TEXT("Connecting to Windows CE..."));
239
- hRapiResult = CeRapiInit();
240
- if (FAILED(hRapiResult)) {
241
- _tprintf( TEXT("Failed\n"));
242
- return false;
243
- }
244
- //_tprintf( TEXT("Success\n"));
245
-
246
- return true;
247
-
248
- /*
249
- RAPIINIT riCopy = {sizeof(RAPIINIT), 0, 0};
250
- bool fInitialized = false;
251
- DWORD dwTimeOut = 5000;
252
-
253
- CeRapiUninit();
254
-
255
- hRapiResult = CeRapiInitEx(&riCopy);
256
-
257
- if (FAILED(hRapiResult)) {
258
- return false;
259
- }
260
-
261
- DWORD dwRapiInit = 0;
262
-
263
- dwRapiInit = WaitForSingleObject(
264
- riCopy.heRapiInit,
265
- dwTimeOut);
266
-
267
- if (WAIT_OBJECT_0 == dwRapiInit) {
268
- // heRapiInit signaled:
269
- // set return error code to return value of RAPI Init function
270
- hRapiResult = riCopy.hrRapiInit;
271
- } else if (WAIT_TIMEOUT == dwRapiInit) {
272
- // timed out: device is probably not connected
273
- // or not responding
274
- hRapiResult = HRESULT_FROM_WIN32(ERROR_TIMEOUT);
275
- } else {
276
- // WaitForSingleObject failed
277
- hRapiResult = HRESULT_FROM_WIN32(GetLastError());
278
- }
279
-
280
- if (FAILED(hRapiResult)) {
281
- CeRapiUninit();
282
- return false;
283
- }
284
- return true;
285
- */
286
- }
287
-
288
- void wceDisconnect(void)
289
- {
290
- //_tprintf( TEXT("Closing connection to Windows CE..."));
291
- CeRapiUninit();
292
- //_tprintf( TEXT("Done\n"));
293
- }
294
-
295
- #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
296
-
297
-
298
- bool wcePutFile(const char *host_file, const char *wce_file)
299
- {
300
- TCHAR tszSrcFile[MAX_PATH];
301
- WCHAR wszDestFile[MAX_PATH];
302
- BYTE buffer[5120];
303
- WIN32_FIND_DATA wfd;
304
- HRESULT hr;
305
- DWORD dwAttr, dwNumRead, dwNumWritten;
306
- HANDLE hSrc, hDest, hFind;
307
- int nResult;
308
-
309
- #ifdef UNICODE
310
- nResult = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
311
- host_file, strlen(host_file)+1,
312
- tszSrcFile, ARRAYSIZE(tszSrcFile));
313
- if(0 == nResult)
314
- return false;
315
- #else
316
- hr = StringCchCopy(tszSrcFile, ARRAYSIZE(tszSrcFile), argv[1]);
317
- if(FAILED(hr))
318
- return false;
319
- #endif
320
- nResult = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
321
- wce_file, strlen(wce_file)+1,
322
- wszDestFile, ARRAYSIZE(wszDestFile));
323
- if(0 == nResult)
324
- return false;
325
-
326
- hFind = FindFirstFile( tszSrcFile, &wfd);
327
- if (INVALID_HANDLE_VALUE == hFind) {
328
- _tprintf(TEXT("Host file does not exist\n"));
329
- return false;
330
- }
331
- FindClose( hFind);
332
- if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
333
- _tprintf( TEXT("Host file specifies a directory\n"));
334
- return false;
335
- }
336
-
337
- if (wceConnect()) {
338
- dwAttr = CeGetFileAttributes( wszDestFile);
339
- if (dwAttr & FILE_ATTRIBUTE_DIRECTORY) {
340
- hr = StringCchCatW(wszDestFile, ARRAYSIZE(wszDestFile), L"\\");
341
- if(FAILED(hr)) return false;
342
- #ifdef UNICODE
343
- hr = StringCchCatW(wszDestFile, ARRAYSIZE(wszDestFile), wfd.cFileName);
344
- if(FAILED(hr)) return false;
345
- #else
346
- nResult = MultiByteToWideChar(
347
- CP_ACP,
348
- MB_PRECOMPOSED,
349
- wfd.cFileName,
350
- strlen(wfd.cFileName)+1,
351
- wszDestFile+wcslen(wszDestFile),
352
- ARRAYSIZE(wszDestFile)-wcslen(wszDestFile));
353
- if(0 == nResult)
354
- {
355
- return 1;
356
- }
357
- #endif
358
- }
359
- hSrc = CreateFile(tszSrcFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
360
- if (INVALID_HANDLE_VALUE == hSrc) {
361
- _tprintf( TEXT("Unable to open host file\n"));
362
- return false;
363
- }
364
-
365
- hDest = CeCreateFile(wszDestFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
366
- if (INVALID_HANDLE_VALUE == hDest ) {
367
- _tprintf( TEXT("Unable to open target WinCE file\n"));
368
- return false;
369
- }
370
-
371
- //copy file
372
- do {
373
- if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
374
- if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
375
- _tprintf( TEXT("Error !!! Writing WinCE file\n"));
376
- goto FatalError;
377
- }
378
- } else {
379
- _tprintf( TEXT("Error !!! Reading host file\n"));
380
- goto FatalError;
381
- }
382
- _tprintf( TEXT("."));
383
- } while (dwNumRead);
384
- //_tprintf( TEXT("\n"));
385
-
386
- CeCloseHandle( hDest);
387
- CloseHandle (hSrc);
388
- }
389
- wceDisconnect();
390
- return true;
391
-
392
- FatalError:
393
- CeCloseHandle( hDest);
394
- CloseHandle (hSrc);
395
- wceDisconnect();
396
- return false;
397
- }
398
-
399
- bool wceRunProcess(const char *process, const char *args)
400
- {
401
- #ifndef UNICODE
402
- HRESULT hr;
403
- #endif
404
- PROCESS_INFORMATION pi;
405
- WCHAR wszProgram[MAX_PATH];
406
- WCHAR wszArgs[MAX_PATH];
407
-
408
- #ifdef UNICODE
409
- int nResult = 0;
410
- nResult = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, process, strlen(process)+1, wszProgram, ARRAYSIZE(wszProgram));
411
- if(0 == nResult) { return false;}
412
- if (args) {
413
- nResult = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, args, strlen(args)+1, wszArgs, ARRAYSIZE(wszArgs));
414
- if(0 == nResult)
415
- return false;
416
- }
417
- #else
418
- hr = StringCchCopy(wszProgram, ARRAYSIZE(wszProgram), argv[1]);
419
- if(FAILED(hr)) return true;
420
- #endif
421
- if (wceConnect()) {
422
- if (!CeCreateProcess(wszProgram, wszArgs, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) {
423
- _tprintf( TEXT("CreateProcess failed with Errorcode = %ld\n"), CeGetLastError());
424
- return false;
425
- }
426
- CeCloseHandle( pi.hProcess);
427
- CeCloseHandle( pi.hThread);
428
- }
429
- wceDisconnect();
430
- return true;
431
- }
432
- bool wceInvokeCabSetup(const char *wceload_params)
433
- {
434
- HRESULT hr = S_OK;
435
- WCHAR wszCabFile[MAX_PATH];
436
-
437
- //convert pathname
438
- int nResult = 0;
439
- int len = strlen(wceload_params)+1;
440
- nResult = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, wceload_params, len, wszCabFile, ARRAYSIZE(wszCabFile));
441
- if(0 == nResult)
442
- return false;
443
-
444
- wceConnect();
445
-
446
- DWORD dwInSize = sizeof(wszCabFile);
447
- DWORD dwOutSize = 0;
448
- BYTE *pInBuff = NULL;
449
-
450
- pInBuff = (BYTE *)LocalAlloc(LPTR, dwInSize);
451
- memcpy(pInBuff, &wszCabFile, dwInSize);
452
-
453
- hr = CeRapiInvoke(TEXT("\\rhosetup"), TEXT("rhoCabSetup"), dwInSize, pInBuff, &dwOutSize, NULL, NULL, 0);
454
- if(FAILED(hr)) {
455
- //printf("Failed to setup cab!\r\n");
456
- return false;
457
- }
458
- wceDisconnect();
459
-
460
- return true ;
461
- }
462
-
463
-
464
- #define EMU "Windows Mobile 6 Professional Emulator"
465
- //#define EMU "USA Windows Mobile 6.5 Professional Portrait QVGA Emulator"
466
-
467
- /**
468
- * detool emu "<emu_name|vmid>" "app-name" rhobundle_path exe_name
469
- * or
470
- * detool emucab "<emu_name|vmid>" app.cab "app-name"
471
- * or
472
- detool dev "app-name" rhobundle_path exe_name
473
- or
474
- * detool devcab app.cab "app-name"
475
- */
476
- void usage(void)
477
- {
478
- printf
479
- ("Rhodes deployment tool for Windows Mobile: \n \
480
- detool emu \"<emu_name|vmid>\" app.cab \"app-name\" \n \
481
- or \n \
482
- detool dev app.cab \"app-name\" \n"
483
- );
484
- }
485
- enum {
486
- DEPLOY_EMUCAB,
487
- DEPLOY_DEVCAB,
488
- DEPLOY_EMU,
489
- DEPLOY_DEV,
490
- DEPLOY_LOG,
491
- DEPLOY_DEV_WEBKIT,
492
- DEPLOY_EMU_WEBKIT
493
- };
494
-
495
- int copyExecutable (TCHAR *file_name, TCHAR *app_dir, bool use_re_runtime)
496
- {
497
- TCHAR exe_fullpath[MAX_PATH];
498
- int retval = 0;
499
- HANDLE hDest, hSrc;
500
- BYTE buffer[5120];
501
- DWORD dwNumRead, dwNumWritten;
502
-
503
- USES_CONVERSION;
504
-
505
- _tcscpy(exe_fullpath, app_dir);
506
- _tcscat(exe_fullpath, _T("\\"));
507
- _tcscat(exe_fullpath, app_name);
508
- _tcscat(exe_fullpath, (use_re_runtime ? _T(".lnk") : _T(".exe")));
509
-
510
- hSrc = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
511
- if (INVALID_HANDLE_VALUE == hSrc) {
512
- _tprintf( TEXT("Unable to open host file\n"));
513
- return EXIT_FAILURE;
514
- }
515
-
516
- hDest = CeCreateFile(exe_fullpath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
517
- if (INVALID_HANDLE_VALUE == hDest ) {
518
- _tprintf( TEXT("Unable to open target WinCE file\n"));
519
- return CeGetLastError();
520
- }
521
-
522
- do {
523
- if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
524
- if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
525
- _tprintf( TEXT("Error !!! Writing WinCE file\n"));
526
- goto copyFailure;
527
- }
528
- } else {
529
- _tprintf( TEXT("Error !!! Reading host file\n"));
530
- goto copyFailure;
531
- }
532
- _tprintf( TEXT("."));
533
- } while (dwNumRead);
534
- _tprintf( TEXT("\n"));
535
-
536
- CeCloseHandle( hDest);
537
- CloseHandle (hSrc);
538
-
539
- return EXIT_SUCCESS;
540
-
541
- copyFailure:
542
- CeCloseHandle( hDest);
543
- CloseHandle (hSrc);
544
- /*
545
-
546
- if (wcePutFile (T2A(file_name), T2A(exe_fullpath)))
547
- return EXIT_SUCCESS;
548
- */
549
- return EXIT_FAILURE;
550
- }
551
-
552
- int copyBundle (TCHAR *parent_dir, TCHAR *file, TCHAR *app_dir)
553
- {
554
- HANDLE fileHandle;
555
- WIN32_FIND_DATAW findData;
556
- //DWORD dwError;
557
- TCHAR new_app_item[MAX_PATH];
558
- TCHAR host_file[MAX_PATH];
559
- HANDLE hFind;
560
- CE_FIND_DATA wceFindData;
561
-
562
- USES_CONVERSION;
563
-
564
- TCHAR wildcard[MAX_PATH + 16];
565
- TCHAR fullpath[MAX_PATH];
566
-
567
- _tcscpy(fullpath, parent_dir);
568
- _tcscat(fullpath, _T("\\"));
569
- _tcscat(fullpath, file);
570
-
571
- //TODO: check for fullpath is a dir
572
-
573
- _tcscpy(wildcard, fullpath);
574
- _tcscat(wildcard, _T("\\*.*"));
575
-
576
- //wceConnect ();
577
-
578
- fileHandle = FindFirstFile(wildcard, &findData);
579
-
580
- if (fileHandle == INVALID_HANDLE_VALUE) {
581
- printf ("Failed to open file\n");
582
- wceDisconnect();
583
- return EXIT_FAILURE;
584
- }
585
-
586
- /*
587
- if (_tcscmp (_T("."), findData.cFileName) != 0 && _tcscmp (_T(".."), findData.cFileName) != 0) {
588
- printf("-- %s\n", T2A(findData.cFileName));
589
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
590
- copyBundle (fullpath, findData.cFileName, NULL);
591
- }
592
- }
593
- */
594
-
595
- HANDLE hDest, hSrc;
596
- BYTE buffer[5120];
597
- DWORD dwNumRead, dwNumWritten;
598
-
599
- while (FindNextFile(fileHandle, &findData)) {
600
- if (_tcscmp (_T("."), findData.cFileName) == 0 || _tcscmp (_T(".."), findData.cFileName) == 0)
601
- continue;
602
-
603
- _tcscpy(new_app_item, app_dir);
604
- _tcscat(new_app_item, _T("\\"));
605
- _tcscat(new_app_item, findData.cFileName);
606
-
607
- if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
608
- {
609
- //Check and create dir on device
610
- hFind = CeFindFirstFile(new_app_item, &wceFindData);
611
- if (INVALID_HANDLE_VALUE == hFind) {
612
- if (!CeCreateDirectory(new_app_item, NULL)) {
613
- _tprintf( TEXT("Create directory \"%s\" on device\n"), new_app_item);
614
- printf ("Failed to create new directory on device\n");
615
- return EXIT_FAILURE;
616
- }
617
- }
618
- FindClose( hFind);
619
-
620
- copyBundle (fullpath, findData.cFileName, new_app_item);
621
- }
622
- else
623
- {
624
- _tcscpy(host_file, fullpath);
625
- _tcscat(host_file, _T("\\"));
626
- _tcscat(host_file, findData.cFileName);
627
-
628
- _tprintf( TEXT("Copy file \"%s\" to device"), new_app_item);
629
-
630
- hSrc = CreateFile(host_file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
631
- if (INVALID_HANDLE_VALUE == hSrc) {
632
- _tprintf( TEXT("Unable to open host file\n"));
633
- return false;
634
- }
635
-
636
- hDest = CeCreateFile(new_app_item, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
637
- if (INVALID_HANDLE_VALUE == hDest ) {
638
- _tprintf( TEXT("Unable to open target WinCE file\n"));
639
- return false;
640
- }
641
-
642
- do {
643
- if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
644
- if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
645
- _tprintf( TEXT("Error !!! Writing WinCE file\n"));
646
- goto copyBundleFailure;
647
- }
648
- } else {
649
- _tprintf( TEXT("Error !!! Reading host file\n"));
650
- goto copyBundleFailure;
651
- }
652
- _tprintf( TEXT("."));
653
- } while (dwNumRead);
654
- _tprintf( TEXT("\n"));
655
-
656
- CeCloseHandle( hDest);
657
- CloseHandle (hSrc);
658
- /*
659
- if(!wcePutFile (T2A(host_file), T2A(new_app_item))) {
660
- printf("Failed to copy file.");
661
- return EXIT_FAILURE;
662
- }
663
- */
664
- }
665
-
666
- }
667
-
668
- return EXIT_SUCCESS;
669
-
670
- copyBundleFailure:
671
- CeCloseHandle( hDest);
672
- CloseHandle (hSrc);
673
- return EXIT_FAILURE;
674
- }
675
-
676
- void startLogServer( TCHAR * log_file, TCHAR* log_port )
677
- {
678
- // Declare and initialize variables
679
- WSADATA wsaData;
680
- int iResult;
681
- LogServer logSrv(log_file, log_port);
682
-
683
- // Initialize Winsock
684
- iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
685
- if (iResult != 0) {
686
- printf("WSAStartup failed: %d\n", iResult);
687
- return;
688
- }
689
-
690
- if (logSrv.init())
691
- {
692
- logSrv.run();
693
- }
694
-
695
- WSACleanup();
696
- }
697
-
698
- void simulateKeyInput (int vk, BOOL bExtended, BOOL doDown, BOOL doUp)
699
- {
700
- KEYBDINPUT kb = {0};
701
- INPUT Input = {0};
702
- if (doDown) {
703
- // generate down
704
- if (bExtended)
705
- kb.dwFlags = KEYEVENTF_EXTENDEDKEY;
706
- kb.wVk = vk;
707
- Input.type = INPUT_KEYBOARD;
708
- Input.ki = kb;
709
- ::SendInput(1,&Input,sizeof(Input));
710
- }
711
- if (doUp) {
712
- // generate up
713
- ::ZeroMemory(&kb,sizeof(KEYBDINPUT));
714
- ::ZeroMemory(&Input,sizeof(INPUT));
715
- kb.dwFlags = KEYEVENTF_KEYUP;
716
- if (bExtended)
717
- kb.dwFlags |= KEYEVENTF_EXTENDEDKEY;
718
- kb.wVk = vk;
719
- Input.type = INPUT_KEYBOARD;
720
- Input.ki = kb;
721
- ::SendInput(1,&Input,sizeof(Input));
722
- }
723
- }
724
-
725
- bool doUseWMDC() {
726
- OSVERSIONINFOW os_version;
727
- ZeroMemory(&os_version, sizeof(OSVERSIONINFO));
728
- os_version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
729
- ::GetVersionEx(&os_version);
730
- return (os_version.dwMajorVersion >= 6);
731
- }
732
-
733
- HWND findWMDCWindow() {
734
- return FindWindow(NULL, L"Windows Mobile Device Center");
735
- }
736
-
737
- void startWMDC() {
738
- if (doUseWMDC()) {
739
- if (findWMDCWindow() == 0) {
740
- _tprintf( TEXT("WMDC is not running. Starting WMDC...\n") );
741
- ::system("start %WINDIR%\\WindowsMobile\\wmdc.exe /show");
742
- ::Sleep(5000);
743
- }
744
- }
745
- }
746
-
747
- void connectWMDC() {
748
- if (doUseWMDC()) {
749
- HWND hwnd = findWMDCWindow();
750
- if (hwnd == 0) {
751
- _tprintf( TEXT("Cannot find WMDC window to establish network connection to device emulator.\n") );
752
- } else {
753
- ::SetForegroundWindow(hwnd);
754
- ::SetFocus(hwnd);
755
- ::LockSetForegroundWindow(LSFW_LOCK);
756
- ::Sleep(100);
757
- simulateKeyInput(VK_MENU, TRUE, TRUE, FALSE);
758
- ::Sleep(20);
759
- simulateKeyInput('C', FALSE, TRUE, TRUE);
760
- ::Sleep(20);
761
- simulateKeyInput(VK_MENU, TRUE, FALSE, TRUE);
762
- ::LockSetForegroundWindow(LSFW_UNLOCK);
763
- }
764
- }
765
- }
766
-
1
+ /*------------------------------------------------------------------------
2
+ * (The MIT License)
3
+ *
4
+ * Copyright (c) 2008-2011 Rhomobile, Inc.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in
14
+ * all copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ * THE SOFTWARE.
23
+ *
24
+ * http://rhomobile.com
25
+ *------------------------------------------------------------------------*/
26
+
27
+ #include "stdafx.h"
28
+
29
+ #include <rapi.h>
30
+ #include <strsafe.h>
31
+
32
+ #include "detool.h"
33
+ #include "LogServer.h"
34
+
35
+ #define RHOSETUP_DLL "rhosetup.dll"
36
+ #define RE2_RUNTIME TEXT("\\Program Files\\RhoElements\\RhoElements.exe")
37
+
38
+ TCHAR *app_name = NULL;
39
+
40
+ void checkMDEstart(HRESULT hr)
41
+ {
42
+ if (FAILED(hr)) {
43
+ if (hr == REGDB_E_CLASSNOTREG) {
44
+ printf ("Microsoft Device Emulator is too old or corrupted. Please update it.\n");
45
+ printf ("You could get the latest version on:\n");
46
+ printf ("http://www.microsoft.com/downloads/details.aspx?familyid=a6f6adaf-12e3-4b2f-a394-356e2c2fb114\n");
47
+ } else {
48
+ wprintf_s(L"Error: Unable to instantiate DeviceEmulatorManager. ErrorCode=0x%08X\n", hr);
49
+ }
50
+ }
51
+ }
52
+
53
+ DWORD WINAPI startDEM(LPVOID lpParam)
54
+ {
55
+ if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
56
+ HRESULT hr = 0;
57
+
58
+ CComPtr<IDeviceEmulatorManager> pDeviceEmulatorManager;
59
+ hr = pDeviceEmulatorManager.CoCreateInstance(__uuidof(DeviceEmulatorManager));
60
+ if (FAILED(hr)) {
61
+ checkMDEstart(hr);
62
+ ExitProcess(EXIT_FAILURE);
63
+ return hr;
64
+ }
65
+
66
+ pDeviceEmulatorManager->ShowManagerUI(false);
67
+ while (1) {
68
+ Sleep(600 * 1000);
69
+ }
70
+ return hr;
71
+ CoUninitialize();
72
+ }
73
+ return 0;
74
+ }
75
+
76
+ BOOL FindDevice(const CComBSTR& deviceIdentifier, IDeviceEmulatorManagerVMID** pDeviceVMID)
77
+ {
78
+ HRESULT hr;
79
+
80
+ CComPtr<IDeviceEmulatorManager> pDeviceEmulatorManager;
81
+ hr = pDeviceEmulatorManager.CoCreateInstance(__uuidof(DeviceEmulatorManager));
82
+ if (FAILED(hr)) {
83
+ wprintf(L"Error: Unable to instantiate DeviceEmulatorManager. ErrorCode=0x%08X\n", hr);
84
+ return FALSE;
85
+ }
86
+
87
+ for (; SUCCEEDED(hr); (hr = pDeviceEmulatorManager->MoveNext()))
88
+ {
89
+ CComPtr<IEnumManagerSDKs> pSDKEnumerator;
90
+
91
+ hr = pDeviceEmulatorManager->EnumerateSDKs(&pSDKEnumerator);
92
+ if (FAILED(hr)) {
93
+ continue;
94
+ }
95
+
96
+ for (; SUCCEEDED(hr); (hr = pSDKEnumerator->MoveNext())) {
97
+ CComPtr<IEnumVMIDs> pDeviceEnumerator;
98
+ hr = pSDKEnumerator->EnumerateVMIDs(&pDeviceEnumerator);
99
+ if (FAILED(hr)) {
100
+ continue;
101
+ }
102
+
103
+ for (; SUCCEEDED(hr); (hr = pDeviceEnumerator->MoveNext())) {
104
+ CComBSTR deviceName;
105
+ CComBSTR deviceVMID;
106
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice;
107
+
108
+ hr = pDeviceEnumerator->GetVMID(&pDevice);
109
+ if (FAILED(hr)) {
110
+ continue;
111
+ }
112
+
113
+ hr = pDevice->get_Name(&deviceName);
114
+ if (FAILED(hr)){
115
+ continue;
116
+ }
117
+
118
+ hr = pDevice->get_VMID(&deviceVMID);
119
+ if (FAILED(hr)){
120
+ continue;
121
+ }
122
+
123
+ if (deviceIdentifier == deviceName || deviceIdentifier == deviceVMID){
124
+ *pDeviceVMID = pDevice;
125
+ (*pDeviceVMID)->AddRef();
126
+ return TRUE;
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ wprintf(L"Error: Unable to locate the device '%s'", deviceIdentifier);
133
+ return FALSE;
134
+ }
135
+
136
+ bool emuConnect(const CComBSTR& deviceIdentifier)
137
+ {
138
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
139
+
140
+ BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
141
+ if (bFound && pDevice){
142
+ HRESULT hr = pDevice->Connect();
143
+ if (!SUCCEEDED(hr)) {
144
+ wprintf(L"Error: Operation Connect failed. Hr=0x%x\n", hr);
145
+ return false;
146
+ }
147
+ return true;
148
+ }
149
+ return false;
150
+ }
151
+
152
+ bool emuBringToFront(const CComBSTR& deviceIdentifier)
153
+ {
154
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
155
+
156
+ BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
157
+ if (bFound && pDevice){
158
+ HRESULT hr = pDevice->BringToFront();
159
+ if (!SUCCEEDED(hr)) {
160
+ wprintf(L"Error: Operation BringToFront failed. Hr=0x%x\n", hr);
161
+ return false;
162
+ }
163
+ return true;
164
+ }
165
+ return false;
166
+ }
167
+
168
+ bool emuCradle(const CComBSTR& deviceIdentifier)
169
+ {
170
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
171
+
172
+ BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
173
+ if (bFound && pDevice){
174
+ HRESULT hr = pDevice->Cradle();
175
+ if (!SUCCEEDED(hr)) {
176
+ wprintf(L"Error: Operation Cradle failed. Hr=0x%x\n", hr);
177
+ return false;
178
+ }
179
+ return true;
180
+ }
181
+ return false;
182
+ }
183
+
184
+ bool emuUncradle(const CComBSTR& deviceIdentifier)
185
+ {
186
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
187
+
188
+ BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
189
+
190
+ if (bFound && pDevice){
191
+ HRESULT hr = pDevice->UnCradle();
192
+ if (!SUCCEEDED(hr)) {
193
+ wprintf(L"Error: Operation UnCradle failed. Hr=0x%x\n", hr);
194
+ return false;
195
+ }
196
+ return true;
197
+ }
198
+
199
+ return false;
200
+ }
201
+
202
+ bool emuReset(const CComBSTR& deviceIdentifier)
203
+ {
204
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
205
+
206
+ BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
207
+ if (bFound && pDevice){
208
+ HRESULT hr = pDevice->Reset(TRUE);
209
+ if (!SUCCEEDED(hr)) {
210
+ wprintf(L"Error: Operation ResetEmulator failed. Hr=0x%x\n", hr);
211
+ return false;
212
+ }
213
+ return true;
214
+ }
215
+ return false;
216
+ }
217
+
218
+ bool emuShutdown(const CComBSTR& deviceIdentifier)
219
+ {
220
+ CComPtr<IDeviceEmulatorManagerVMID> pDevice = NULL;
221
+
222
+ BOOL bFound = FindDevice(deviceIdentifier, &pDevice);
223
+ if (bFound && pDevice){
224
+ HRESULT hr = pDevice->Shutdown(FALSE);
225
+ if (!SUCCEEDED(hr)) {
226
+ wprintf(L"Error: Operation Shutdown failed. Hr=0x%x\n", hr);
227
+ return false;
228
+ }
229
+ return true;
230
+ }
231
+ return false;
232
+ }
233
+
234
+ bool wceConnect (void)
235
+ {
236
+ HRESULT hRapiResult;
237
+
238
+ //_tprintf( TEXT("Connecting to Windows CE..."));
239
+ hRapiResult = CeRapiInit();
240
+ if (FAILED(hRapiResult)) {
241
+ _tprintf( TEXT("Failed\n"));
242
+ return false;
243
+ }
244
+ //_tprintf( TEXT("Success\n"));
245
+
246
+ return true;
247
+
248
+ /*
249
+ RAPIINIT riCopy = {sizeof(RAPIINIT), 0, 0};
250
+ bool fInitialized = false;
251
+ DWORD dwTimeOut = 5000;
252
+
253
+ CeRapiUninit();
254
+
255
+ hRapiResult = CeRapiInitEx(&riCopy);
256
+
257
+ if (FAILED(hRapiResult)) {
258
+ return false;
259
+ }
260
+
261
+ DWORD dwRapiInit = 0;
262
+
263
+ dwRapiInit = WaitForSingleObject(
264
+ riCopy.heRapiInit,
265
+ dwTimeOut);
266
+
267
+ if (WAIT_OBJECT_0 == dwRapiInit) {
268
+ // heRapiInit signaled:
269
+ // set return error code to return value of RAPI Init function
270
+ hRapiResult = riCopy.hrRapiInit;
271
+ } else if (WAIT_TIMEOUT == dwRapiInit) {
272
+ // timed out: device is probably not connected
273
+ // or not responding
274
+ hRapiResult = HRESULT_FROM_WIN32(ERROR_TIMEOUT);
275
+ } else {
276
+ // WaitForSingleObject failed
277
+ hRapiResult = HRESULT_FROM_WIN32(GetLastError());
278
+ }
279
+
280
+ if (FAILED(hRapiResult)) {
281
+ CeRapiUninit();
282
+ return false;
283
+ }
284
+ return true;
285
+ */
286
+ }
287
+
288
+ void wceDisconnect(void)
289
+ {
290
+ //_tprintf( TEXT("Closing connection to Windows CE..."));
291
+ CeRapiUninit();
292
+ //_tprintf( TEXT("Done\n"));
293
+ }
294
+
295
+ #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
296
+
297
+
298
+ bool wcePutFile(const char *host_file, const char *wce_file)
299
+ {
300
+ TCHAR tszSrcFile[MAX_PATH];
301
+ WCHAR wszDestFile[MAX_PATH];
302
+ BYTE buffer[5120];
303
+ WIN32_FIND_DATA wfd;
304
+ HRESULT hr;
305
+ DWORD dwAttr, dwNumRead, dwNumWritten;
306
+ HANDLE hSrc, hDest, hFind;
307
+ int nResult;
308
+
309
+ #ifdef UNICODE
310
+ nResult = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
311
+ host_file, strlen(host_file)+1,
312
+ tszSrcFile, ARRAYSIZE(tszSrcFile));
313
+ if(0 == nResult)
314
+ return false;
315
+ #else
316
+ hr = StringCchCopy(tszSrcFile, ARRAYSIZE(tszSrcFile), argv[1]);
317
+ if(FAILED(hr))
318
+ return false;
319
+ #endif
320
+ nResult = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
321
+ wce_file, strlen(wce_file)+1,
322
+ wszDestFile, ARRAYSIZE(wszDestFile));
323
+ if(0 == nResult)
324
+ return false;
325
+
326
+ hFind = FindFirstFile( tszSrcFile, &wfd);
327
+ if (INVALID_HANDLE_VALUE == hFind) {
328
+ _tprintf(TEXT("Host file does not exist\n"));
329
+ return false;
330
+ }
331
+ FindClose( hFind);
332
+ if (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
333
+ _tprintf( TEXT("Host file specifies a directory\n"));
334
+ return false;
335
+ }
336
+
337
+ if (wceConnect()) {
338
+ dwAttr = CeGetFileAttributes( wszDestFile);
339
+ if (dwAttr & FILE_ATTRIBUTE_DIRECTORY) {
340
+ hr = StringCchCatW(wszDestFile, ARRAYSIZE(wszDestFile), L"\\");
341
+ if(FAILED(hr)) return false;
342
+ #ifdef UNICODE
343
+ hr = StringCchCatW(wszDestFile, ARRAYSIZE(wszDestFile), wfd.cFileName);
344
+ if(FAILED(hr)) return false;
345
+ #else
346
+ nResult = MultiByteToWideChar(
347
+ CP_ACP,
348
+ MB_PRECOMPOSED,
349
+ wfd.cFileName,
350
+ strlen(wfd.cFileName)+1,
351
+ wszDestFile+wcslen(wszDestFile),
352
+ ARRAYSIZE(wszDestFile)-wcslen(wszDestFile));
353
+ if(0 == nResult)
354
+ {
355
+ return 1;
356
+ }
357
+ #endif
358
+ }
359
+ hSrc = CreateFile(tszSrcFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
360
+ if (INVALID_HANDLE_VALUE == hSrc) {
361
+ _tprintf( TEXT("Unable to open host file\n"));
362
+ return false;
363
+ }
364
+
365
+ hDest = CeCreateFile(wszDestFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
366
+ if (INVALID_HANDLE_VALUE == hDest ) {
367
+ _tprintf( TEXT("Unable to open target WinCE file\n"));
368
+ return false;
369
+ }
370
+
371
+ //copy file
372
+ do {
373
+ if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
374
+ if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
375
+ _tprintf( TEXT("Error !!! Writing WinCE file\n"));
376
+ goto FatalError;
377
+ }
378
+ } else {
379
+ _tprintf( TEXT("Error !!! Reading host file\n"));
380
+ goto FatalError;
381
+ }
382
+ _tprintf( TEXT("."));
383
+ } while (dwNumRead);
384
+ //_tprintf( TEXT("\n"));
385
+
386
+ CeCloseHandle( hDest);
387
+ CloseHandle (hSrc);
388
+ }
389
+ wceDisconnect();
390
+ return true;
391
+
392
+ FatalError:
393
+ CeCloseHandle( hDest);
394
+ CloseHandle (hSrc);
395
+ wceDisconnect();
396
+ return false;
397
+ }
398
+
399
+ bool wceRunProcess(const char *process, const char *args)
400
+ {
401
+ #ifndef UNICODE
402
+ HRESULT hr;
403
+ #endif
404
+ PROCESS_INFORMATION pi;
405
+ WCHAR wszProgram[MAX_PATH];
406
+ WCHAR wszArgs[MAX_PATH];
407
+
408
+ #ifdef UNICODE
409
+ int nResult = 0;
410
+ nResult = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, process, strlen(process)+1, wszProgram, ARRAYSIZE(wszProgram));
411
+ if(0 == nResult) { return false;}
412
+ if (args) {
413
+ nResult = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, args, strlen(args)+1, wszArgs, ARRAYSIZE(wszArgs));
414
+ if(0 == nResult)
415
+ return false;
416
+ }
417
+ #else
418
+ hr = StringCchCopy(wszProgram, ARRAYSIZE(wszProgram), argv[1]);
419
+ if(FAILED(hr)) return true;
420
+ #endif
421
+ if (wceConnect()) {
422
+ if (!CeCreateProcess(wszProgram, wszArgs, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) {
423
+ _tprintf( TEXT("CreateProcess failed with Errorcode = %ld\n"), CeGetLastError());
424
+ return false;
425
+ }
426
+ CeCloseHandle( pi.hProcess);
427
+ CeCloseHandle( pi.hThread);
428
+ }
429
+ wceDisconnect();
430
+ return true;
431
+ }
432
+ bool wceInvokeCabSetup(const char *wceload_params)
433
+ {
434
+ HRESULT hr = S_OK;
435
+ WCHAR wszCabFile[MAX_PATH];
436
+
437
+ //convert pathname
438
+ int nResult = 0;
439
+ int len = strlen(wceload_params)+1;
440
+ nResult = MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, wceload_params, len, wszCabFile, ARRAYSIZE(wszCabFile));
441
+ if(0 == nResult)
442
+ return false;
443
+
444
+ wceConnect();
445
+
446
+ DWORD dwInSize = sizeof(wszCabFile);
447
+ DWORD dwOutSize = 0;
448
+ BYTE *pInBuff = NULL;
449
+
450
+ pInBuff = (BYTE *)LocalAlloc(LPTR, dwInSize);
451
+ memcpy(pInBuff, &wszCabFile, dwInSize);
452
+
453
+ hr = CeRapiInvoke(TEXT("\\rhosetup"), TEXT("rhoCabSetup"), dwInSize, pInBuff, &dwOutSize, NULL, NULL, 0);
454
+ if(FAILED(hr)) {
455
+ //printf("Failed to setup cab!\r\n");
456
+ return false;
457
+ }
458
+ wceDisconnect();
459
+
460
+ return true ;
461
+ }
462
+
463
+
464
+ #define EMU "Windows Mobile 6 Professional Emulator"
465
+ //#define EMU "USA Windows Mobile 6.5 Professional Portrait QVGA Emulator"
466
+
467
+ /**
468
+ * detool emu "<emu_name|vmid>" "app-name" rhobundle_path exe_name
469
+ * or
470
+ * detool emucab "<emu_name|vmid>" app.cab "app-name"
471
+ * or
472
+ detool dev "app-name" rhobundle_path exe_name
473
+ or
474
+ * detool devcab app.cab "app-name"
475
+ */
476
+ void usage(void)
477
+ {
478
+ printf
479
+ ("Rhodes deployment tool for Windows Mobile: \n \
480
+ detool emu \"<emu_name|vmid>\" app.cab \"app-name\" \n \
481
+ or \n \
482
+ detool dev app.cab \"app-name\" \n"
483
+ );
484
+ }
485
+ enum {
486
+ DEPLOY_EMUCAB,
487
+ DEPLOY_DEVCAB,
488
+ DEPLOY_EMU,
489
+ DEPLOY_DEV,
490
+ DEPLOY_LOG,
491
+ DEPLOY_DEV_WEBKIT,
492
+ DEPLOY_EMU_WEBKIT
493
+ };
494
+
495
+ int copyExecutable (TCHAR *file_name, TCHAR *app_dir, bool use_shared_runtime)
496
+ {
497
+ TCHAR exe_fullpath[MAX_PATH];
498
+ int retval = 0;
499
+ HANDLE hDest, hSrc;
500
+ BYTE buffer[5120];
501
+ DWORD dwNumRead, dwNumWritten;
502
+
503
+ USES_CONVERSION;
504
+
505
+ _tcscpy(exe_fullpath, app_dir);
506
+ _tcscat(exe_fullpath, _T("\\"));
507
+ _tcscat(exe_fullpath, app_name);
508
+ _tcscat(exe_fullpath, (use_shared_runtime ? _T(".lnk") : _T(".exe")));
509
+
510
+ hSrc = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
511
+ if (INVALID_HANDLE_VALUE == hSrc) {
512
+ _tprintf( TEXT("Unable to open host file\n"));
513
+ return EXIT_FAILURE;
514
+ }
515
+
516
+ hDest = CeCreateFile(exe_fullpath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
517
+ if (INVALID_HANDLE_VALUE == hDest ) {
518
+ _tprintf( TEXT("Unable to open target WinCE file\n"));
519
+ return CeGetLastError();
520
+ }
521
+
522
+ do {
523
+ if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
524
+ if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
525
+ _tprintf( TEXT("Error !!! Writing WinCE file\n"));
526
+ goto copyFailure;
527
+ }
528
+ } else {
529
+ _tprintf( TEXT("Error !!! Reading host file\n"));
530
+ goto copyFailure;
531
+ }
532
+ _tprintf( TEXT("."));
533
+ } while (dwNumRead);
534
+ _tprintf( TEXT("\n"));
535
+
536
+ CeCloseHandle( hDest);
537
+ CloseHandle (hSrc);
538
+
539
+ return EXIT_SUCCESS;
540
+
541
+ copyFailure:
542
+ CeCloseHandle( hDest);
543
+ CloseHandle (hSrc);
544
+ /*
545
+
546
+ if (wcePutFile (T2A(file_name), T2A(exe_fullpath)))
547
+ return EXIT_SUCCESS;
548
+ */
549
+ return EXIT_FAILURE;
550
+ }
551
+
552
+ int copyBundle (TCHAR *parent_dir, TCHAR *file, TCHAR *app_dir)
553
+ {
554
+ HANDLE fileHandle;
555
+ WIN32_FIND_DATAW findData;
556
+ //DWORD dwError;
557
+ TCHAR new_app_item[MAX_PATH];
558
+ TCHAR host_file[MAX_PATH];
559
+ HANDLE hFind;
560
+ CE_FIND_DATA wceFindData;
561
+
562
+ USES_CONVERSION;
563
+
564
+ TCHAR wildcard[MAX_PATH + 16];
565
+ TCHAR fullpath[MAX_PATH];
566
+
567
+ _tcscpy(fullpath, parent_dir);
568
+ _tcscat(fullpath, _T("\\"));
569
+ _tcscat(fullpath, file);
570
+
571
+ //TODO: check for fullpath is a dir
572
+
573
+ _tcscpy(wildcard, fullpath);
574
+ _tcscat(wildcard, _T("\\*.*"));
575
+
576
+ //wceConnect ();
577
+
578
+ fileHandle = FindFirstFile(wildcard, &findData);
579
+
580
+ if (fileHandle == INVALID_HANDLE_VALUE) {
581
+ printf ("Failed to open file\n");
582
+ wceDisconnect();
583
+ return EXIT_FAILURE;
584
+ }
585
+
586
+ /*
587
+ if (_tcscmp (_T("."), findData.cFileName) != 0 && _tcscmp (_T(".."), findData.cFileName) != 0) {
588
+ printf("-- %s\n", T2A(findData.cFileName));
589
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
590
+ copyBundle (fullpath, findData.cFileName, NULL);
591
+ }
592
+ }
593
+ */
594
+
595
+ HANDLE hDest, hSrc;
596
+ BYTE buffer[5120];
597
+ DWORD dwNumRead, dwNumWritten;
598
+
599
+ while (FindNextFile(fileHandle, &findData)) {
600
+ if (_tcscmp (_T("."), findData.cFileName) == 0 || _tcscmp (_T(".."), findData.cFileName) == 0)
601
+ continue;
602
+
603
+ _tcscpy(new_app_item, app_dir);
604
+ _tcscat(new_app_item, _T("\\"));
605
+ _tcscat(new_app_item, findData.cFileName);
606
+
607
+ if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
608
+ {
609
+ //Check and create dir on device
610
+ hFind = CeFindFirstFile(new_app_item, &wceFindData);
611
+ if (INVALID_HANDLE_VALUE == hFind) {
612
+ if (!CeCreateDirectory(new_app_item, NULL)) {
613
+ _tprintf( TEXT("Create directory \"%s\" on device\n"), new_app_item);
614
+ printf ("Failed to create new directory on device\n");
615
+ return EXIT_FAILURE;
616
+ }
617
+ }
618
+ FindClose( hFind);
619
+
620
+ copyBundle (fullpath, findData.cFileName, new_app_item);
621
+ }
622
+ else
623
+ {
624
+ _tcscpy(host_file, fullpath);
625
+ _tcscat(host_file, _T("\\"));
626
+ _tcscat(host_file, findData.cFileName);
627
+
628
+ _tprintf( TEXT("Copy file \"%s\" to device"), new_app_item);
629
+
630
+ hSrc = CreateFile(host_file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
631
+ if (INVALID_HANDLE_VALUE == hSrc) {
632
+ _tprintf( TEXT("Unable to open host file\n"));
633
+ return false;
634
+ }
635
+
636
+ hDest = CeCreateFile(new_app_item, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
637
+ if (INVALID_HANDLE_VALUE == hDest ) {
638
+ _tprintf( TEXT("Unable to open target WinCE file\n"));
639
+ return false;
640
+ }
641
+
642
+ do {
643
+ if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
644
+ if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
645
+ _tprintf( TEXT("Error !!! Writing WinCE file\n"));
646
+ goto copyBundleFailure;
647
+ }
648
+ } else {
649
+ _tprintf( TEXT("Error !!! Reading host file\n"));
650
+ goto copyBundleFailure;
651
+ }
652
+ _tprintf( TEXT("."));
653
+ } while (dwNumRead);
654
+ _tprintf( TEXT("\n"));
655
+
656
+ CeCloseHandle( hDest);
657
+ CloseHandle (hSrc);
658
+ /*
659
+ if(!wcePutFile (T2A(host_file), T2A(new_app_item))) {
660
+ printf("Failed to copy file.");
661
+ return EXIT_FAILURE;
662
+ }
663
+ */
664
+ }
665
+
666
+ }
667
+
668
+ return EXIT_SUCCESS;
669
+
670
+ copyBundleFailure:
671
+ CeCloseHandle( hDest);
672
+ CloseHandle (hSrc);
673
+ return EXIT_FAILURE;
674
+ }
675
+
676
+ int copyLicenseDll (TCHAR *file_name, TCHAR *app_dir)
677
+ {
678
+ TCHAR fullpath[MAX_PATH];
679
+ int retval = 0;
680
+ HANDLE hDest, hSrc;
681
+ BYTE buffer[5120];
682
+ DWORD dwNumRead, dwNumWritten;
683
+
684
+ USES_CONVERSION;
685
+
686
+ _tcscpy(fullpath, app_dir);
687
+ _tcscat(fullpath, _T("\\license_rc.dll"));
688
+
689
+ hSrc = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
690
+ if (INVALID_HANDLE_VALUE == hSrc) {
691
+ _tprintf( TEXT("Unable to open host file\n"));
692
+ return EXIT_FAILURE;
693
+ }
694
+
695
+ hDest = CeCreateFile(fullpath, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
696
+ if (INVALID_HANDLE_VALUE == hDest ) {
697
+ _tprintf( TEXT("Unable to open target WinCE file\n"));
698
+ return CeGetLastError();
699
+ }
700
+
701
+ do {
702
+ if(ReadFile(hSrc, &buffer, sizeof(buffer), &dwNumRead, NULL)) {
703
+ if (!CeWriteFile(hDest, &buffer, dwNumRead, &dwNumWritten, NULL)) {
704
+ _tprintf( TEXT("Error !!! Writing WinCE file\n"));
705
+ goto copyFailure;
706
+ }
707
+ } else {
708
+ _tprintf( TEXT("Error !!! Reading host file\n"));
709
+ goto copyFailure;
710
+ }
711
+ _tprintf( TEXT("."));
712
+ } while (dwNumRead);
713
+ _tprintf( TEXT("\n"));
714
+
715
+ CeCloseHandle( hDest);
716
+ CloseHandle (hSrc);
717
+
718
+ return EXIT_SUCCESS;
719
+
720
+ copyFailure:
721
+ CeCloseHandle( hDest);
722
+ CloseHandle (hSrc);
723
+ /*
724
+
725
+ if (wcePutFile (T2A(file_name), T2A(exe_fullpath)))
726
+ return EXIT_SUCCESS;
727
+ */
728
+ return EXIT_FAILURE;
729
+ }
730
+
731
+ void startLogServer( TCHAR * log_file, TCHAR* log_port )
732
+ {
733
+ // Declare and initialize variables
734
+ WSADATA wsaData;
735
+ int iResult;
736
+ LogServer logSrv(log_file, log_port);
737
+
738
+ // Initialize Winsock
739
+ iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
740
+ if (iResult != 0) {
741
+ printf("WSAStartup failed: %d\n", iResult);
742
+ return;
743
+ }
744
+
745
+ if (logSrv.init())
746
+ {
747
+ logSrv.run();
748
+ }
749
+
750
+ WSACleanup();
751
+ }
752
+
753
+ void simulateKeyInput (int vk, BOOL bExtended, BOOL doDown, BOOL doUp)
754
+ {
755
+ KEYBDINPUT kb = {0};
756
+ INPUT Input = {0};
757
+ if (doDown) {
758
+ // generate down
759
+ if (bExtended)
760
+ kb.dwFlags = KEYEVENTF_EXTENDEDKEY;
761
+ kb.wVk = vk;
762
+ Input.type = INPUT_KEYBOARD;
763
+ Input.ki = kb;
764
+ ::SendInput(1,&Input,sizeof(Input));
765
+ }
766
+ if (doUp) {
767
+ // generate up
768
+ ::ZeroMemory(&kb,sizeof(KEYBDINPUT));
769
+ ::ZeroMemory(&Input,sizeof(INPUT));
770
+ kb.dwFlags = KEYEVENTF_KEYUP;
771
+ if (bExtended)
772
+ kb.dwFlags |= KEYEVENTF_EXTENDEDKEY;
773
+ kb.wVk = vk;
774
+ Input.type = INPUT_KEYBOARD;
775
+ Input.ki = kb;
776
+ ::SendInput(1,&Input,sizeof(Input));
777
+ }
778
+ }
779
+
780
+ bool doUseWMDC() {
781
+ OSVERSIONINFOW os_version;
782
+ ZeroMemory(&os_version, sizeof(OSVERSIONINFO));
783
+ os_version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
784
+ ::GetVersionEx(&os_version);
785
+ return (os_version.dwMajorVersion >= 6);
786
+ }
787
+
788
+ HWND findWMDCWindow() {
789
+ return FindWindow(NULL, L"Windows Mobile Device Center");
790
+ }
791
+
792
+ void startWMDC() {
793
+ if (doUseWMDC()) {
794
+ if (findWMDCWindow() == 0) {
795
+ _tprintf( TEXT("WMDC is not running. Starting WMDC...\n") );
796
+ ::system("start %WINDIR%\\WindowsMobile\\wmdc.exe /show");
797
+ ::Sleep(5000);
798
+ }
799
+ }
800
+ }
801
+
802
+ void connectWMDC() {
803
+ if (doUseWMDC()) {
804
+ HWND hwnd = findWMDCWindow();
805
+ if (hwnd == 0) {
806
+ _tprintf( TEXT("Cannot find WMDC window to establish network connection to device emulator.\n") );
807
+ } else {
808
+ ::SetForegroundWindow(hwnd);
809
+ ::SetFocus(hwnd);
810
+ ::LockSetForegroundWindow(LSFW_LOCK);
811
+ ::Sleep(100);
812
+ simulateKeyInput(VK_MENU, TRUE, TRUE, FALSE);
813
+ ::Sleep(20);
814
+ simulateKeyInput('C', FALSE, TRUE, TRUE);
815
+ ::Sleep(20);
816
+ simulateKeyInput(VK_MENU, TRUE, FALSE, TRUE);
817
+ ::LockSetForegroundWindow(LSFW_UNLOCK);
818
+ }
819
+ }
820
+ }
821
+
767
822
  bool str_ends_with(const TCHAR* str, const TCHAR* suffix)
768
823
  {
769
824
  if( str == NULL || suffix == NULL )
@@ -776,594 +831,617 @@ bool str_ends_with(const TCHAR* str, const TCHAR* suffix)
776
831
  return 0;
777
832
 
778
833
  return (_wcsnicmp( str + str_len - suffix_len, suffix, suffix_len ) == 0);
779
- }
780
-
781
- int _tmain(int argc, _TCHAR* argv[])
782
- {
783
- TCHAR *emu_name = NULL;
784
- TCHAR *cab_file = NULL;
785
- TCHAR *bundle_path = NULL;
786
- TCHAR *app_exe = NULL;
787
- TCHAR *log_file = NULL;
788
- TCHAR *log_port = NULL;
789
- TCHAR *src_path = NULL;
790
- TCHAR *dst_path = NULL;
791
- TCHAR params_buf[MAX_PATH + 16];
792
- //WIN32_FIND_DATAW findData;
793
- int new_copy = 0;
794
- int deploy_type;
795
- bool use_re_runtime = false;
796
-
797
- USES_CONVERSION;
798
-
799
- if (argc > 5) { //assuming that need to start emulator
800
- if (strcmp(T2A(argv[1]), "emu") == 0) {
801
- emu_name = argv[2];
802
- app_name = argv[3];
803
- bundle_path = argv[4];
804
- app_exe = argv[5];
805
- log_port = argv[6];
806
- deploy_type = DEPLOY_EMU;
807
- }
808
- if (strcmp(T2A(argv[1]), "emucab") == 0) {
809
- emu_name = argv[2];
810
- cab_file = argv[3];
811
- app_name = argv[4];
812
- //log_port = argv[5];
813
- if (strcmp(T2A(argv[5]), "1") == 0)
814
- use_re_runtime = true;
815
- deploy_type = DEPLOY_EMUCAB;
816
- }
817
-
818
- if (strcmp(T2A(argv[1]), "dev") == 0) {
819
- app_name = argv[2];
820
- bundle_path = argv[3];
821
- app_exe = argv[4];
822
- log_port = argv[5];
823
- deploy_type = DEPLOY_DEV;
824
- }
825
- } else if (argc == 5) { //assuming that need to deploy and start on device
826
- if (strcmp(T2A(argv[1]), "wk-emu") == 0) {
827
- deploy_type = DEPLOY_EMU_WEBKIT;
828
- emu_name = argv[2];
829
- src_path = argv[3];
830
- app_name = argv[4];
831
- }
832
- else {
833
- cab_file = argv[2];
834
- app_name = argv[3];
835
- //log_port = argv[4];
836
- if (strcmp(T2A(argv[4]), "1") == 0)
837
- use_re_runtime = true;
838
- deploy_type = DEPLOY_DEVCAB;
839
- }
840
- } else if (argc == 4) { // log
841
- if (strcmp(T2A(argv[1]), "log") == 0) {
842
- log_file = argv[2];
843
- log_port = argv[3];
844
- app_name = _T("");
845
- deploy_type = DEPLOY_LOG;
846
- }
847
- else if (strcmp(T2A(argv[1]), "wk-dev") == 0) {
848
- deploy_type = DEPLOY_DEV_WEBKIT;
849
- src_path = argv[2];
850
- app_name = argv[3];
851
- }
852
- }
853
- else {
854
- usage();
855
- return EXIT_FAILURE;
856
- }
857
- if ((!use_re_runtime) && app_exe)
858
- use_re_runtime = str_ends_with(app_exe, L".lnk");
859
-
860
- TCHAR app_dir[MAX_PATH];
861
- _tcscpy(app_dir, TEXT("\\Program Files\\"));
862
- _tcscat(app_dir, app_name);
863
- _tprintf( TEXT("%s\n"), app_dir);
864
-
865
- if (deploy_type == DEPLOY_EMU) {
866
- if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
867
- HANDLE hFind;
868
- CE_FIND_DATA findData;
869
-
870
- CreateThread(NULL, 0, startDEM, NULL, 0, NULL);
871
-
872
- _tprintf( TEXT("Starting emulator... "));
873
- if (!emuConnect (emu_name)) {
874
- _tprintf( TEXT("FAILED\n"));
875
- goto stop_emu_deploy;
876
- }
877
- _tprintf( TEXT("DONE\n"));
878
-
879
- _tprintf( TEXT("Cradle emulator... "));
880
- if(!emuCradle (emu_name)) {
881
- _tprintf( TEXT("FAILED\n"));
882
- goto stop_emu_deploy;
883
- }
884
- _tprintf( TEXT("DONE\n"));
885
-
886
- if (!wceConnect ()) {
887
- printf ("Failed to connect to remote device.\n");
888
- goto stop_emu_deploy;
889
- } else {
890
- // start Windows Mobile Device Center for network connectivity of the device emulator (if applicable)
891
- startWMDC();
892
-
893
- hFind = CeFindFirstFile(app_dir, &findData);
894
- if (INVALID_HANDLE_VALUE == hFind) {
895
- _tprintf( TEXT("Application directory on device was not found\n"));
896
-
897
- new_copy = 1;
898
-
899
- if (!CeCreateDirectory(app_dir, NULL)) {
900
- printf ("Failed to create app directory\n");
901
- goto stop_emu_deploy;
902
- }
903
- }
904
- FindClose( hFind);
905
-
906
- if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
907
- _tprintf( TEXT("Error: target directory is file\n"));
908
- goto stop_emu_deploy;
909
- }
910
-
911
-
912
- TCHAR remote_bundle_path[MAX_PATH];
913
-
914
- _tcscpy(remote_bundle_path, app_dir);
915
- _tcscat(remote_bundle_path, _T("\\rho"));
916
-
917
- hFind = CeFindFirstFile(remote_bundle_path, &findData);
918
- if (INVALID_HANDLE_VALUE == hFind) {
919
- _tprintf( TEXT("Bundle directory on device was not found\n"));
920
-
921
- if (!CeCreateDirectory(remote_bundle_path, NULL)) {
922
- printf ("Failed to create bundle directory\n");
923
- goto stop_emu_deploy;
924
- }
925
- }
926
- FindClose( hFind);
927
-
928
- int retval = copyExecutable (app_exe, app_dir, use_re_runtime);
929
- if (retval != EXIT_SUCCESS) {
930
- printf ("Failed to copy application executable\n");
931
- if (retval == 32) {
932
- printf ("Please, stop application on device and try again.\n");
933
- }
934
- goto stop_emu_deploy;
935
- }
936
-
937
- if (copyBundle(bundle_path, _T("/"), remote_bundle_path) == EXIT_FAILURE) {
938
- printf ("Failed to copy bundle\n");
939
- goto stop_emu_deploy;
940
- }
941
-
942
- // establish network connectivity of the device emulator from Windows Mobile Device Center (if applicable)
943
- connectWMDC();
944
-
945
- emuBringToFront(emu_name);
946
-
947
- _tprintf( TEXT("Starting application..."));
948
- TCHAR params[MAX_PATH];
949
- params[0] = 0;
950
- if (use_re_runtime) {
951
- _tcscpy(params_buf, RE2_RUNTIME);
952
- _tcscpy(params, _T("-approot='\\Program Files\\"));
953
- _tcscat(params, app_name);
954
- _tcscat(params, _T("'"));
955
- } else {
956
- _tcscpy(params_buf, TEXT("\\Program Files\\"));
957
- _tcscat(params_buf, app_name);
958
- _tcscat(params_buf, _T("\\"));
959
- _tcscat(params_buf, app_name);
960
- _tcscat(params_buf, _T(".exe"));
961
- }
962
- //_tcscpy(params, _T("-log="));
963
- //_tcscat(params, log_port);
964
- _tprintf( TEXT("%s %s\n"), params_buf, params);
965
-
966
- if(!wceRunProcess(T2A(params_buf), T2A(params))) {
967
- _tprintf( TEXT("FAILED\n"));
968
- goto stop_emu_deploy;
969
- }
970
- _tprintf( TEXT("DONE\n"));
971
-
972
- wceDisconnect();
973
- }
974
-
975
- CoUninitialize();
976
-
977
- ExitProcess(EXIT_SUCCESS);
978
- }
979
-
980
- // emu "Windows Mobile 6 Professional Emulator" RhodesApplication1 c:/android/runtime-rhostudio.product/RhodesApplication1/bin/RhoBundle "C:/Android/rhodes/platform/wm/bin/Windows Mobile 6 Professional SDK (ARMV4I)/rhodes/Release/RhodesApplication1.exe" 11000
981
- }
982
- if (deploy_type == DEPLOY_EMUCAB) {
983
- if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
984
- CreateThread(NULL, 0, startDEM, NULL, 0, NULL);
985
-
986
- _tprintf( TEXT("Starting emulator... "));
987
- if (!emuConnect (emu_name)) {
988
- _tprintf( TEXT("FAILED\n"));
989
- goto stop_emu_deploy;
990
- }
991
- _tprintf( TEXT("DONE\n"));
992
-
993
- _tprintf( TEXT("Cradle emulator... "));
994
- if(!emuCradle (emu_name)) {
995
- _tprintf( TEXT("FAILED\n"));
996
- goto stop_emu_deploy;
997
- }
998
- _tprintf( TEXT("DONE\n"));
999
-
1000
- // start Windows Mobile Device Center for network connectivity of the device emulator (if applicable)
1001
- startWMDC();
1002
-
1003
- _tprintf( TEXT("Loading cab file..."));
1004
- if (!wcePutFile (T2A(cab_file), "")) {
1005
- _tprintf( TEXT("FAILED\n"));
1006
- goto stop_emu_deploy;
1007
- }
1008
- _tprintf( TEXT("DONE\n"));
1009
-
1010
- _tprintf( TEXT("Loading utility dll..."));
1011
- if (!wcePutFile (RHOSETUP_DLL, "")) {
1012
- _tprintf( TEXT("FAILED\n"));
1013
- goto stop_emu_deploy;
1014
- }
1015
- _tprintf( TEXT("DONE\n"));
1016
-
1017
- _tprintf( TEXT("Setup application..."));
1018
-
1019
- //FIXME: rake gives pathname with unix-like '/' file separators,
1020
- //so if we want to use this tool outside of rake, we should remember this
1021
- //or check and convert cab_file
1022
- TCHAR *p = _tcsrchr (cab_file, '/');
1023
- if (p) p++;
1024
- _tcscpy(params_buf, TEXT("/noui "));
1025
- _tcscat(params_buf, p != NULL ? p : cab_file);
1026
-
1027
- if(!wceInvokeCabSetup(T2A(params_buf))) {
1028
- _tprintf( TEXT("FAILED\n"));
1029
- goto stop_emu_deploy;
1030
- }
1031
- _tprintf( TEXT("DONE\n"));
1032
-
1033
- // establish network connectivity of the device emulator from Windows Mobile Device Center (if applicable)
1034
- connectWMDC();
1035
-
1036
- emuBringToFront(emu_name);
1037
-
1038
- _tprintf( TEXT("Starting application..."));
1039
- TCHAR params[MAX_PATH];
1040
- params[0] = 0;
1041
- if (use_re_runtime) {
1042
- _tcscpy(params_buf, RE2_RUNTIME);
1043
- _tcscpy(params, _T("-approot='\\Program Files\\"));
1044
- _tcscat(params, app_name);
1045
- _tcscat(params, _T("'"));
1046
- } else {
1047
- _tcscpy(params_buf, TEXT("\\Program Files\\"));
1048
- _tcscat(params_buf, app_name);
1049
- _tcscat(params_buf, _T("\\"));
1050
- _tcscat(params_buf, app_name);
1051
- _tcscat(params_buf, _T(".exe"));
1052
- }
1053
- //_tcscat(params, _T("-log="));
1054
- //_tcscat(params, log_port);
1055
- _tprintf( TEXT("%s %s\n"), params_buf, params);
1056
-
1057
- if(!wceRunProcess(T2A(params_buf), T2A(params))) {
1058
- _tprintf( TEXT("FAILED\n"));
1059
- goto stop_emu_deploy;
1060
- }
1061
- _tprintf( TEXT("DONE\n"));
1062
-
1063
-
1064
- CoUninitialize();
1065
- ExitProcess(EXIT_SUCCESS);
1066
- stop_emu_deploy:
1067
- CoUninitialize();
1068
- ExitProcess(EXIT_FAILURE);
1069
- }
1070
- }
1071
-
1072
- if (deploy_type == DEPLOY_DEV) {
1073
- HANDLE hFind;
1074
- CE_FIND_DATA findData;
1075
-
1076
- _tprintf( TEXT("Searching for Windows CE device..."));
1077
-
1078
- HRESULT hRapiResult;
1079
- hRapiResult = CeRapiInit();
1080
- if (FAILED(hRapiResult)) {
1081
- _tprintf( TEXT("FAILED\n"));
1082
- return false;
1083
- }
1084
- _tprintf( TEXT("DONE\n"));
1085
-
1086
- startWMDC();
1087
-
1088
- hFind = CeFindFirstFile(app_dir, &findData);
1089
- if (INVALID_HANDLE_VALUE == hFind) {
1090
- _tprintf( TEXT("Application directory on device was not found\n"));
1091
-
1092
- new_copy = 1;
1093
-
1094
- if (!CeCreateDirectory(app_dir, NULL)) {
1095
- printf ("Failed to create app directory\n");
1096
- goto stop_emu_deploy;
1097
- }
1098
- }
1099
- FindClose( hFind);
1100
-
1101
- if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1102
- _tprintf( TEXT("Error: target directory is file\n"));
1103
- goto stop_emu_deploy;
1104
- }
1105
-
1106
-
1107
- TCHAR remote_bundle_path[MAX_PATH];
1108
-
1109
- _tcscpy(remote_bundle_path, app_dir);
1110
- _tcscat(remote_bundle_path, _T("\\rho"));
1111
-
1112
- hFind = CeFindFirstFile(remote_bundle_path, &findData);
1113
- if (INVALID_HANDLE_VALUE == hFind) {
1114
- _tprintf( TEXT("Bundle directory on device was not found\n"));
1115
-
1116
- if (!CeCreateDirectory(remote_bundle_path, NULL)) {
1117
- printf ("Failed to create bundle directory\n");
1118
- goto stop_emu_deploy;
1119
- }
1120
- }
1121
- FindClose( hFind);
1122
-
1123
- int retval = copyExecutable (app_exe, app_dir, use_re_runtime);
1124
- if (retval != EXIT_SUCCESS) {
1125
- printf ("Failed to copy application executable\n");
1126
- if (retval == 32) {
1127
- printf ("Please, stop application on device and try again.\n");
1128
- }
1129
- goto stop_emu_deploy;
1130
- }
1131
-
1132
- if (copyBundle(bundle_path, _T("/"), remote_bundle_path) == EXIT_FAILURE) {
1133
- printf ("Failed to copy bundle\n");
1134
- goto stop_emu_deploy;
1135
- }
1136
-
1137
- // establish network connectivity of the device from Windows Mobile Device Center (if applicable)
1138
- connectWMDC();
1139
-
1140
- Sleep(2 * 1000);
1141
-
1142
- _tprintf( TEXT("Starting application..."));
1143
- TCHAR params[MAX_PATH];
1144
- params[0] = 0;
1145
- if (use_re_runtime) {
1146
- _tcscpy(params_buf, RE2_RUNTIME);
1147
- _tcscpy(params, _T("-approot='\\Program Files\\"));
1148
- _tcscat(params, app_name);
1149
- _tcscat(params, _T("'"));
1150
- } else {
1151
- _tcscpy(params_buf, TEXT("\\Program Files\\"));
1152
- _tcscat(params_buf, app_name);
1153
- _tcscat(params_buf, _T("\\"));
1154
- _tcscat(params_buf, app_name);
1155
- _tcscat(params_buf, _T(".exe"));
1156
- }
1157
- //_tcscat(params, _T("-log="));
1158
- //_tcscat(params, log_port);
1159
- _tprintf( TEXT("%s %s\n"), params_buf, params);
1160
-
1161
- if(!wceRunProcess(T2A(params_buf), T2A(params))) {
1162
- _tprintf( TEXT("FAILED\n"));
1163
- goto stop_emu_deploy;
1164
- }
1165
- _tprintf( TEXT("DONE\n"));
1166
-
1167
- ExitProcess(EXIT_SUCCESS);
1168
- }
1169
-
1170
- if (deploy_type == DEPLOY_DEVCAB) {
1171
- _tprintf( TEXT("Searching for Windows CE device..."));
1172
-
1173
- HRESULT hRapiResult;
1174
- hRapiResult = CeRapiInit();
1175
- if (FAILED(hRapiResult)) {
1176
- _tprintf( TEXT("FAILED\n"));
1177
- return false;
1178
- }
1179
- _tprintf( TEXT("DONE\n"));
1180
-
1181
- startWMDC();
1182
-
1183
- _tprintf( TEXT("Loading cab file to device..."));
1184
- USES_CONVERSION;
1185
- if (!wcePutFile (T2A(cab_file), "")) {
1186
- _tprintf( TEXT("FAILED\n"));
1187
- goto stop_emu_deploy;
1188
- }
1189
- _tprintf( TEXT("DONE\n"));
1190
-
1191
- _tprintf( TEXT("Loading utility dll..."));
1192
- if (!wcePutFile (RHOSETUP_DLL, "")) {
1193
- _tprintf( TEXT("FAILED\n"));
1194
- goto stop_emu_deploy;
1195
- }
1196
- _tprintf( TEXT("DONE\n"));
1197
-
1198
- _tprintf( TEXT("Setup application..."));
1199
-
1200
- //FIXME: rake gives pathname with unix-like '/' file separators,
1201
- //so if we want to use this tool outside of rake, we should remember this
1202
- //or check and convert cab_file
1203
- TCHAR *p = _tcsrchr (cab_file, '/');
1204
- if (p) p++;
1205
- _tcscpy(params_buf, p != NULL ? p : cab_file);
1206
- //_tcscat(params_buf, p != NULL ? p : cab_file);
1207
-
1208
- if(!wceInvokeCabSetup(T2A(params_buf))) {
1209
- _tprintf( TEXT("FAILED\n"));
1210
-
1211
- _tprintf( TEXT("Starting installator GUI ..."));
1212
- if(!wceRunProcess ("\\windows\\wceload.exe", T2A(p != NULL ? p : cab_file))) {
1213
- _tprintf( TEXT("FAILED\n"));
1214
- ExitProcess(EXIT_FAILURE);
1215
- } else {
1216
- _tprintf( TEXT("DONE\n"));
1217
- _tprintf( TEXT("Please continue manually...\n"));
1218
- ExitProcess(EXIT_SUCCESS);
1219
- }
1220
-
1221
- goto stop_emu_deploy;
1222
- }
1223
- _tprintf( TEXT("DONE\n"));
1224
-
1225
- // establish network connectivity of the device from Windows Mobile Device Center (if applicable)
1226
- connectWMDC();
1227
-
1228
- _tprintf( TEXT("Starting application..."));
1229
- TCHAR params[MAX_PATH];
1230
- params[0] = 0;
1231
- if (use_re_runtime) {
1232
- _tcscpy(params_buf, RE2_RUNTIME);
1233
- _tcscpy(params, _T("-approot='\\Program Files\\"));
1234
- _tcscat(params, app_name);
1235
- _tcscat(params, _T("'"));
1236
- } else {
1237
- _tcscpy(params_buf, TEXT("\\Program Files\\"));
1238
- _tcscat(params_buf, app_name);
1239
- _tcscat(params_buf, _T("\\"));
1240
- _tcscat(params_buf, app_name);
1241
- _tcscat(params_buf, _T(".exe"));
1242
- }
1243
- //_tcscat(params, _T("-log="));
1244
- //_tcscat(params, log_port);
1245
- _tprintf( TEXT("%s %s\n"), params_buf, params);
1246
-
1247
- if(!wceRunProcess (T2A(params_buf), T2A(params))) {
1248
- _tprintf( TEXT("FAILED\n"));
1249
- goto stop_emu_deploy;
1250
- }
1251
- _tprintf( TEXT("DONE\n"));
1252
- }
1253
-
1254
- if (deploy_type == DEPLOY_LOG)
1255
- {
1256
- if (log_file != NULL) {
1257
- startLogServer(log_file, log_port);
1258
- }
1259
- }
1260
-
1261
- if (deploy_type == DEPLOY_DEV_WEBKIT)
1262
- {
1263
- HANDLE hFind;
1264
- CE_FIND_DATA findData;
1265
-
1266
- _tprintf( TEXT("Searching for Windows CE device..."));
1267
-
1268
- HRESULT hRapiResult;
1269
- hRapiResult = CeRapiInit();
1270
- if (FAILED(hRapiResult)) {
1271
- _tprintf( TEXT("FAILED\n"));
1272
- return false;
1273
- }
1274
- _tprintf( TEXT("DONE\n"));
1275
-
1276
- hFind = CeFindFirstFile(app_dir, &findData);
1277
- if (INVALID_HANDLE_VALUE == hFind) {
1278
- _tprintf( TEXT("Application directory on device was not found\n"));
1279
-
1280
- new_copy = 1;
1281
-
1282
- if (!CeCreateDirectory(app_dir, NULL)) {
1283
- printf ("Failed to create app directory\n");
1284
- goto stop_emu_deploy;
1285
- }
1286
- }
1287
- FindClose( hFind);
1288
-
1289
- if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1290
- _tprintf( TEXT("Error: target directory is file\n"));
1291
- goto stop_emu_deploy;
1292
- }
1293
-
1294
- _tprintf( TEXT("Load file to device..."));
1295
- USES_CONVERSION;
1296
- if (copyBundle(src_path, _T("/"), app_dir) == EXIT_FAILURE) {
1297
- printf ("Failed to copy bundle\n");
1298
- goto stop_emu_deploy;
1299
- }
1300
-
1301
- _tprintf( TEXT("DONE\n"));
1302
- }
1303
-
1304
- if (deploy_type == DEPLOY_EMU_WEBKIT)
1305
- {
1306
- //HANDLE hFind;
1307
- //CE_FIND_DATA findData;
1308
-
1309
- _tprintf( TEXT("Searching for Windows CE device..."));
1310
-
1311
- if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
1312
- {
1313
- HANDLE hFind;
1314
- CE_FIND_DATA findData;
1315
-
1316
- CreateThread(NULL, 0, startDEM, NULL, 0, NULL);
1317
-
1318
- _tprintf( TEXT("Starting emulator... "));
1319
- if (!emuConnect (emu_name)) {
1320
- _tprintf( TEXT("FAILED\n"));
1321
- goto stop_emu_deploy;
1322
- }
1323
- _tprintf( TEXT("DONE\n"));
1324
-
1325
- _tprintf( TEXT("Cradle emulator... "));
1326
- if(!emuCradle (emu_name)) {
1327
- _tprintf( TEXT("FAILED\n"));
1328
- goto stop_emu_deploy;
1329
- }
1330
- _tprintf( TEXT("DONE\n"));
1331
-
1332
- if (!wceConnect ()) {
1333
- printf ("Failed to connect to remote device.\n");
1334
- goto stop_emu_deploy;
1335
- } else {
1336
- hFind = CeFindFirstFile(app_dir, &findData);
1337
- if (INVALID_HANDLE_VALUE == hFind) {
1338
- _tprintf( TEXT("Application directory on device was not found\n"));
1339
-
1340
- new_copy = 1;
1341
-
1342
- if (!CeCreateDirectory(app_dir, NULL)) {
1343
- printf ("Failed to create app directory\n");
1344
- goto stop_emu_deploy;
1345
- }
1346
- }
1347
- FindClose( hFind);
1348
-
1349
- if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1350
- _tprintf( TEXT("Error: target directory is file\n"));
1351
- goto stop_emu_deploy;
1352
- }
1353
-
1354
- _tprintf( TEXT("Load files to device..."));
1355
- USES_CONVERSION;
1356
- if (copyBundle(src_path, _T("/"), app_dir) == EXIT_FAILURE) {
1357
- printf ("Failed to copy bundle\n");
1358
- goto stop_emu_deploy;
1359
- }
1360
-
1361
- _tprintf( TEXT("DONE\n"));
1362
-
1363
- emuBringToFront(emu_name);
1364
- }
1365
- }
1366
- }
1367
-
1368
- return EXIT_SUCCESS;
1369
- }
834
+ }
835
+
836
+ int _tmain(int argc, _TCHAR* argv[])
837
+ {
838
+ TCHAR *emu_name = NULL;
839
+ TCHAR *cab_file = NULL;
840
+ TCHAR *bundle_path = NULL;
841
+ TCHAR *app_exe = NULL;
842
+ TCHAR *log_file = NULL;
843
+ TCHAR *log_port = NULL;
844
+ TCHAR *src_path = NULL;
845
+ TCHAR *lcdll_path = NULL;
846
+ TCHAR *dst_path = NULL;
847
+ TCHAR params_buf[MAX_PATH + 16];
848
+ //WIN32_FIND_DATAW findData;
849
+ int new_copy = 0;
850
+ int deploy_type;
851
+ bool use_shared_runtime = false;
852
+
853
+ USES_CONVERSION;
854
+
855
+ if (argc > 5) { //assuming that need to start emulator
856
+ if (strcmp(T2A(argv[1]), "emu") == 0) {
857
+ emu_name = argv[2];
858
+ app_name = argv[3];
859
+ bundle_path = argv[4];
860
+ app_exe = argv[5];
861
+ log_port = argv[6];
862
+ lcdll_path = argv[7];
863
+ deploy_type = DEPLOY_EMU;
864
+ }
865
+ if (strcmp(T2A(argv[1]), "emucab") == 0) {
866
+ emu_name = argv[2];
867
+ cab_file = argv[3];
868
+ app_name = argv[4];
869
+ //log_port = argv[5];
870
+ if (strcmp(T2A(argv[5]), "1") == 0)
871
+ use_shared_runtime = true;
872
+ deploy_type = DEPLOY_EMUCAB;
873
+ }
874
+
875
+ if (strcmp(T2A(argv[1]), "dev") == 0) {
876
+ app_name = argv[2];
877
+ bundle_path = argv[3];
878
+ app_exe = argv[4];
879
+ log_port = argv[5];
880
+ lcdll_path = argv[6];
881
+ deploy_type = DEPLOY_DEV;
882
+ }
883
+ } else if (argc == 5) { //assuming that need to deploy and start on device
884
+ if (strcmp(T2A(argv[1]), "wk-emu") == 0) {
885
+ deploy_type = DEPLOY_EMU_WEBKIT;
886
+ emu_name = argv[2];
887
+ src_path = argv[3];
888
+ app_name = argv[4];
889
+ }
890
+ else {
891
+ cab_file = argv[2];
892
+ app_name = argv[3];
893
+ //log_port = argv[4];
894
+ if (strcmp(T2A(argv[4]), "1") == 0)
895
+ use_shared_runtime = true;
896
+ deploy_type = DEPLOY_DEVCAB;
897
+ }
898
+ } else if (argc == 4) { // log
899
+ if (strcmp(T2A(argv[1]), "log") == 0) {
900
+ log_file = argv[2];
901
+ log_port = argv[3];
902
+ app_name = _T("");
903
+ deploy_type = DEPLOY_LOG;
904
+ }
905
+ else if (strcmp(T2A(argv[1]), "wk-dev") == 0) {
906
+ deploy_type = DEPLOY_DEV_WEBKIT;
907
+ src_path = argv[2];
908
+ app_name = argv[3];
909
+ }
910
+ }
911
+ else {
912
+ usage();
913
+ return EXIT_FAILURE;
914
+ }
915
+ if ((!use_shared_runtime) && app_exe)
916
+ use_shared_runtime = str_ends_with(app_exe, L".lnk");
917
+
918
+ TCHAR app_dir[MAX_PATH];
919
+ _tcscpy(app_dir, TEXT("\\Program Files\\"));
920
+ _tcscat(app_dir, app_name);
921
+ _tprintf( TEXT("%s\n"), app_dir);
922
+
923
+ if (deploy_type == DEPLOY_EMU) {
924
+ if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
925
+ HANDLE hFind;
926
+ CE_FIND_DATA findData;
927
+
928
+ CreateThread(NULL, 0, startDEM, NULL, 0, NULL);
929
+
930
+ _tprintf( TEXT("Starting emulator... "));
931
+ if (!emuConnect (emu_name)) {
932
+ _tprintf( TEXT("FAILED\n"));
933
+ goto stop_emu_deploy;
934
+ }
935
+ _tprintf( TEXT("DONE\n"));
936
+
937
+ _tprintf( TEXT("Cradle emulator... "));
938
+ if(!emuCradle (emu_name)) {
939
+ _tprintf( TEXT("FAILED\n"));
940
+ goto stop_emu_deploy;
941
+ }
942
+ _tprintf( TEXT("DONE\n"));
943
+
944
+ if (!wceConnect ()) {
945
+ printf ("Failed to connect to remote device.\n");
946
+ goto stop_emu_deploy;
947
+ } else {
948
+ // start Windows Mobile Device Center for network connectivity of the device emulator (if applicable)
949
+ startWMDC();
950
+
951
+ hFind = CeFindFirstFile(app_dir, &findData);
952
+ if (INVALID_HANDLE_VALUE == hFind) {
953
+ _tprintf( TEXT("Application directory on device was not found\n"));
954
+
955
+ new_copy = 1;
956
+
957
+ if (!CeCreateDirectory(app_dir, NULL)) {
958
+ printf ("Failed to create app directory\n");
959
+ goto stop_emu_deploy;
960
+ }
961
+ }
962
+ FindClose( hFind);
963
+
964
+ if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
965
+ _tprintf( TEXT("Error: target directory is file\n"));
966
+ goto stop_emu_deploy;
967
+ }
968
+
969
+
970
+ TCHAR remote_bundle_path[MAX_PATH];
971
+
972
+ _tcscpy(remote_bundle_path, app_dir);
973
+ _tcscat(remote_bundle_path, _T("\\rho"));
974
+
975
+ hFind = CeFindFirstFile(remote_bundle_path, &findData);
976
+ if (INVALID_HANDLE_VALUE == hFind) {
977
+ _tprintf( TEXT("Bundle directory on device was not found\n"));
978
+
979
+ if (!CeCreateDirectory(remote_bundle_path, NULL)) {
980
+ printf ("Failed to create bundle directory\n");
981
+ goto stop_emu_deploy;
982
+ }
983
+ }
984
+ FindClose( hFind);
985
+
986
+ int retval = copyExecutable (app_exe, app_dir, use_shared_runtime);
987
+ if (retval != EXIT_SUCCESS) {
988
+ printf ("Failed to copy application executable\n");
989
+ if (retval == 32) {
990
+ printf ("Please, stop application on device and try again.\n");
991
+ }
992
+ goto stop_emu_deploy;
993
+ }
994
+
995
+ if(!use_shared_runtime)
996
+ retval = copyLicenseDll(lcdll_path, app_dir);
997
+ if (retval != EXIT_SUCCESS) {
998
+ printf ("Failed to copy license dll\n");
999
+ if (retval == 32) {
1000
+ printf ("Please, stop application on device and try again.\n");
1001
+ }
1002
+ goto stop_emu_deploy;
1003
+ }
1004
+
1005
+ if (copyBundle(bundle_path, _T("/"), remote_bundle_path) == EXIT_FAILURE) {
1006
+ printf ("Failed to copy bundle\n");
1007
+ goto stop_emu_deploy;
1008
+ }
1009
+
1010
+ // establish network connectivity of the device emulator from Windows Mobile Device Center (if applicable)
1011
+ connectWMDC();
1012
+
1013
+ emuBringToFront(emu_name);
1014
+
1015
+ _tprintf( TEXT("Starting application..."));
1016
+ TCHAR params[MAX_PATH];
1017
+ params[0] = 0;
1018
+ if (use_shared_runtime) {
1019
+ _tcscpy(params_buf, RE2_RUNTIME);
1020
+ _tcscpy(params, _T("-approot='\\Program Files\\"));
1021
+ _tcscat(params, app_name);
1022
+ _tcscat(params, _T("'"));
1023
+ } else {
1024
+ _tcscpy(params_buf, TEXT("\\Program Files\\"));
1025
+ _tcscat(params_buf, app_name);
1026
+ _tcscat(params_buf, _T("\\"));
1027
+ _tcscat(params_buf, app_name);
1028
+ _tcscat(params_buf, _T(".exe"));
1029
+ }
1030
+ //_tcscpy(params, _T("-log="));
1031
+ //_tcscat(params, log_port);
1032
+ _tprintf( TEXT("%s %s\n"), params_buf, params);
1033
+
1034
+ if(!wceRunProcess(T2A(params_buf), T2A(params))) {
1035
+ _tprintf( TEXT("FAILED\n"));
1036
+ goto stop_emu_deploy;
1037
+ }
1038
+ _tprintf( TEXT("DONE\n"));
1039
+
1040
+ wceDisconnect();
1041
+ }
1042
+
1043
+ CoUninitialize();
1044
+
1045
+ ExitProcess(EXIT_SUCCESS);
1046
+ }
1047
+
1048
+ // emu "Windows Mobile 6 Professional Emulator" RhodesApplication1 c:/android/runtime-rhostudio.product/RhodesApplication1/bin/RhoBundle "C:/Android/rhodes/platform/wm/bin/Windows Mobile 6 Professional SDK (ARMV4I)/rhodes/Release/RhodesApplication1.exe" 11000
1049
+ }
1050
+ if (deploy_type == DEPLOY_EMUCAB) {
1051
+ if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
1052
+ CreateThread(NULL, 0, startDEM, NULL, 0, NULL);
1053
+
1054
+ _tprintf( TEXT("Starting emulator... "));
1055
+ if (!emuConnect (emu_name)) {
1056
+ _tprintf( TEXT("FAILED\n"));
1057
+ goto stop_emu_deploy;
1058
+ }
1059
+ _tprintf( TEXT("DONE\n"));
1060
+
1061
+ _tprintf( TEXT("Cradle emulator... "));
1062
+ if(!emuCradle (emu_name)) {
1063
+ _tprintf( TEXT("FAILED\n"));
1064
+ goto stop_emu_deploy;
1065
+ }
1066
+ _tprintf( TEXT("DONE\n"));
1067
+
1068
+ // start Windows Mobile Device Center for network connectivity of the device emulator (if applicable)
1069
+ startWMDC();
1070
+
1071
+ _tprintf( TEXT("Loading cab file..."));
1072
+ if (!wcePutFile (T2A(cab_file), "")) {
1073
+ _tprintf( TEXT("FAILED\n"));
1074
+ goto stop_emu_deploy;
1075
+ }
1076
+ _tprintf( TEXT("DONE\n"));
1077
+
1078
+ _tprintf( TEXT("Loading utility dll..."));
1079
+ if (!wcePutFile (RHOSETUP_DLL, "")) {
1080
+ _tprintf( TEXT("FAILED\n"));
1081
+ goto stop_emu_deploy;
1082
+ }
1083
+ _tprintf( TEXT("DONE\n"));
1084
+
1085
+ _tprintf( TEXT("Setup application..."));
1086
+
1087
+ //FIXME: rake gives pathname with unix-like '/' file separators,
1088
+ //so if we want to use this tool outside of rake, we should remember this
1089
+ //or check and convert cab_file
1090
+ TCHAR *p = _tcsrchr (cab_file, '/');
1091
+ if (p) p++;
1092
+ _tcscpy(params_buf, TEXT("/noui "));
1093
+ _tcscat(params_buf, p != NULL ? p : cab_file);
1094
+
1095
+ if(!wceInvokeCabSetup(T2A(params_buf))) {
1096
+ _tprintf( TEXT("FAILED\n"));
1097
+ goto stop_emu_deploy;
1098
+ }
1099
+ _tprintf( TEXT("DONE\n"));
1100
+
1101
+ // establish network connectivity of the device emulator from Windows Mobile Device Center (if applicable)
1102
+ connectWMDC();
1103
+
1104
+ emuBringToFront(emu_name);
1105
+
1106
+ _tprintf( TEXT("Starting application..."));
1107
+ TCHAR params[MAX_PATH];
1108
+ params[0] = 0;
1109
+ if (use_shared_runtime) {
1110
+ _tcscpy(params_buf, RE2_RUNTIME);
1111
+ _tcscpy(params, _T("-approot='\\Program Files\\"));
1112
+ _tcscat(params, app_name);
1113
+ _tcscat(params, _T("'"));
1114
+ } else {
1115
+ _tcscpy(params_buf, TEXT("\\Program Files\\"));
1116
+ _tcscat(params_buf, app_name);
1117
+ _tcscat(params_buf, _T("\\"));
1118
+ _tcscat(params_buf, app_name);
1119
+ _tcscat(params_buf, _T(".exe"));
1120
+ }
1121
+ //_tcscat(params, _T("-log="));
1122
+ //_tcscat(params, log_port);
1123
+ _tprintf( TEXT("%s %s\n"), params_buf, params);
1124
+
1125
+ if(!wceRunProcess(T2A(params_buf), T2A(params))) {
1126
+ _tprintf( TEXT("FAILED\n"));
1127
+ goto stop_emu_deploy;
1128
+ }
1129
+ _tprintf( TEXT("DONE\n"));
1130
+
1131
+
1132
+ CoUninitialize();
1133
+ ExitProcess(EXIT_SUCCESS);
1134
+ stop_emu_deploy:
1135
+ CoUninitialize();
1136
+ ExitProcess(EXIT_FAILURE);
1137
+ }
1138
+ }
1139
+
1140
+ if (deploy_type == DEPLOY_DEV) {
1141
+ HANDLE hFind;
1142
+ CE_FIND_DATA findData;
1143
+
1144
+ _tprintf( TEXT("Searching for Windows CE device..."));
1145
+
1146
+ HRESULT hRapiResult;
1147
+ hRapiResult = CeRapiInit();
1148
+ if (FAILED(hRapiResult)) {
1149
+ _tprintf( TEXT("FAILED\n"));
1150
+ return false;
1151
+ }
1152
+ _tprintf( TEXT("DONE\n"));
1153
+
1154
+ startWMDC();
1155
+
1156
+ hFind = CeFindFirstFile(app_dir, &findData);
1157
+ if (INVALID_HANDLE_VALUE == hFind) {
1158
+ _tprintf( TEXT("Application directory on device was not found\n"));
1159
+
1160
+ new_copy = 1;
1161
+
1162
+ if (!CeCreateDirectory(app_dir, NULL)) {
1163
+ printf ("Failed to create app directory\n");
1164
+ goto stop_emu_deploy;
1165
+ }
1166
+ }
1167
+ FindClose( hFind);
1168
+
1169
+ if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1170
+ _tprintf( TEXT("Error: target directory is file\n"));
1171
+ goto stop_emu_deploy;
1172
+ }
1173
+
1174
+
1175
+ TCHAR remote_bundle_path[MAX_PATH];
1176
+
1177
+ _tcscpy(remote_bundle_path, app_dir);
1178
+ _tcscat(remote_bundle_path, _T("\\rho"));
1179
+
1180
+ hFind = CeFindFirstFile(remote_bundle_path, &findData);
1181
+ if (INVALID_HANDLE_VALUE == hFind) {
1182
+ _tprintf( TEXT("Bundle directory on device was not found\n"));
1183
+
1184
+ if (!CeCreateDirectory(remote_bundle_path, NULL)) {
1185
+ printf ("Failed to create bundle directory\n");
1186
+ goto stop_emu_deploy;
1187
+ }
1188
+ }
1189
+ FindClose( hFind);
1190
+
1191
+ int retval = copyExecutable (app_exe, app_dir, use_shared_runtime);
1192
+ if (retval != EXIT_SUCCESS) {
1193
+ printf ("Failed to copy application executable\n");
1194
+ if (retval == 32) {
1195
+ printf ("Please, stop application on device and try again.\n");
1196
+ }
1197
+ goto stop_emu_deploy;
1198
+ }
1199
+
1200
+ if(!use_shared_runtime)
1201
+ retval = copyLicenseDll(lcdll_path, app_dir);
1202
+ if (retval != EXIT_SUCCESS) {
1203
+ printf ("Failed to copy license dll\n");
1204
+ if (retval == 32) {
1205
+ printf ("Please, stop application on device and try again.\n");
1206
+ }
1207
+ goto stop_emu_deploy;
1208
+ }
1209
+
1210
+ if (copyBundle(bundle_path, _T("/"), remote_bundle_path) == EXIT_FAILURE) {
1211
+ printf ("Failed to copy bundle\n");
1212
+ goto stop_emu_deploy;
1213
+ }
1214
+
1215
+ // establish network connectivity of the device from Windows Mobile Device Center (if applicable)
1216
+ connectWMDC();
1217
+
1218
+ Sleep(2 * 1000);
1219
+
1220
+ _tprintf( TEXT("Starting application..."));
1221
+ TCHAR params[MAX_PATH];
1222
+ params[0] = 0;
1223
+ if (use_shared_runtime) {
1224
+ _tcscpy(params_buf, RE2_RUNTIME);
1225
+ _tcscpy(params, _T("-approot='\\Program Files\\"));
1226
+ _tcscat(params, app_name);
1227
+ _tcscat(params, _T("'"));
1228
+ } else {
1229
+ _tcscpy(params_buf, TEXT("\\Program Files\\"));
1230
+ _tcscat(params_buf, app_name);
1231
+ _tcscat(params_buf, _T("\\"));
1232
+ _tcscat(params_buf, app_name);
1233
+ _tcscat(params_buf, _T(".exe"));
1234
+ }
1235
+ //_tcscat(params, _T("-log="));
1236
+ //_tcscat(params, log_port);
1237
+ _tprintf( TEXT("%s %s\n"), params_buf, params);
1238
+
1239
+ if(!wceRunProcess(T2A(params_buf), T2A(params))) {
1240
+ _tprintf( TEXT("FAILED\n"));
1241
+ goto stop_emu_deploy;
1242
+ }
1243
+ _tprintf( TEXT("DONE\n"));
1244
+
1245
+ ExitProcess(EXIT_SUCCESS);
1246
+ }
1247
+
1248
+ if (deploy_type == DEPLOY_DEVCAB) {
1249
+ _tprintf( TEXT("Searching for Windows CE device..."));
1250
+
1251
+ HRESULT hRapiResult;
1252
+ hRapiResult = CeRapiInit();
1253
+ if (FAILED(hRapiResult)) {
1254
+ _tprintf( TEXT("FAILED\n"));
1255
+ return false;
1256
+ }
1257
+ _tprintf( TEXT("DONE\n"));
1258
+
1259
+ startWMDC();
1260
+
1261
+ _tprintf( TEXT("Loading cab file to device..."));
1262
+ USES_CONVERSION;
1263
+ if (!wcePutFile (T2A(cab_file), "")) {
1264
+ _tprintf( TEXT("FAILED\n"));
1265
+ goto stop_emu_deploy;
1266
+ }
1267
+ _tprintf( TEXT("DONE\n"));
1268
+
1269
+ _tprintf( TEXT("Loading utility dll..."));
1270
+ if (!wcePutFile (RHOSETUP_DLL, "")) {
1271
+ _tprintf( TEXT("FAILED\n"));
1272
+ goto stop_emu_deploy;
1273
+ }
1274
+ _tprintf( TEXT("DONE\n"));
1275
+
1276
+ _tprintf( TEXT("Setup application..."));
1277
+
1278
+ //FIXME: rake gives pathname with unix-like '/' file separators,
1279
+ //so if we want to use this tool outside of rake, we should remember this
1280
+ //or check and convert cab_file
1281
+ TCHAR *p = _tcsrchr (cab_file, '/');
1282
+ if (p) p++;
1283
+ _tcscpy(params_buf, p != NULL ? p : cab_file);
1284
+ //_tcscat(params_buf, p != NULL ? p : cab_file);
1285
+
1286
+ if(!wceInvokeCabSetup(T2A(params_buf))) {
1287
+ _tprintf( TEXT("FAILED\n"));
1288
+
1289
+ _tprintf( TEXT("Starting installator GUI ..."));
1290
+ if(!wceRunProcess ("\\windows\\wceload.exe", T2A(p != NULL ? p : cab_file))) {
1291
+ _tprintf( TEXT("FAILED\n"));
1292
+ ExitProcess(EXIT_FAILURE);
1293
+ } else {
1294
+ _tprintf( TEXT("DONE\n"));
1295
+ _tprintf( TEXT("Please continue manually...\n"));
1296
+ ExitProcess(EXIT_SUCCESS);
1297
+ }
1298
+
1299
+ goto stop_emu_deploy;
1300
+ }
1301
+ _tprintf( TEXT("DONE\n"));
1302
+
1303
+ // establish network connectivity of the device from Windows Mobile Device Center (if applicable)
1304
+ connectWMDC();
1305
+
1306
+ _tprintf( TEXT("Starting application..."));
1307
+ TCHAR params[MAX_PATH];
1308
+ params[0] = 0;
1309
+ if (use_shared_runtime) {
1310
+ _tcscpy(params_buf, RE2_RUNTIME);
1311
+ _tcscpy(params, _T("-approot='\\Program Files\\"));
1312
+ _tcscat(params, app_name);
1313
+ _tcscat(params, _T("'"));
1314
+ } else {
1315
+ _tcscpy(params_buf, TEXT("\\Program Files\\"));
1316
+ _tcscat(params_buf, app_name);
1317
+ _tcscat(params_buf, _T("\\"));
1318
+ _tcscat(params_buf, app_name);
1319
+ _tcscat(params_buf, _T(".exe"));
1320
+ }
1321
+ //_tcscat(params, _T("-log="));
1322
+ //_tcscat(params, log_port);
1323
+ _tprintf( TEXT("%s %s\n"), params_buf, params);
1324
+
1325
+ if(!wceRunProcess (T2A(params_buf), T2A(params))) {
1326
+ _tprintf( TEXT("FAILED\n"));
1327
+ goto stop_emu_deploy;
1328
+ }
1329
+ _tprintf( TEXT("DONE\n"));
1330
+ }
1331
+
1332
+ if (deploy_type == DEPLOY_LOG)
1333
+ {
1334
+ if (log_file != NULL) {
1335
+ startLogServer(log_file, log_port);
1336
+ }
1337
+ }
1338
+
1339
+ if (deploy_type == DEPLOY_DEV_WEBKIT)
1340
+ {
1341
+ HANDLE hFind;
1342
+ CE_FIND_DATA findData;
1343
+
1344
+ _tprintf( TEXT("Searching for Windows CE device..."));
1345
+
1346
+ HRESULT hRapiResult;
1347
+ hRapiResult = CeRapiInit();
1348
+ if (FAILED(hRapiResult)) {
1349
+ _tprintf( TEXT("FAILED\n"));
1350
+ return false;
1351
+ }
1352
+ _tprintf( TEXT("DONE\n"));
1353
+
1354
+ hFind = CeFindFirstFile(app_dir, &findData);
1355
+ if (INVALID_HANDLE_VALUE == hFind) {
1356
+ _tprintf( TEXT("Application directory on device was not found\n"));
1357
+
1358
+ new_copy = 1;
1359
+
1360
+ if (!CeCreateDirectory(app_dir, NULL)) {
1361
+ printf ("Failed to create app directory\n");
1362
+ goto stop_emu_deploy;
1363
+ }
1364
+ }
1365
+ FindClose( hFind);
1366
+
1367
+ if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1368
+ _tprintf( TEXT("Error: target directory is file\n"));
1369
+ goto stop_emu_deploy;
1370
+ }
1371
+
1372
+ _tprintf( TEXT("Load file to device..."));
1373
+ USES_CONVERSION;
1374
+ if (copyBundle(src_path, _T("/"), app_dir) == EXIT_FAILURE) {
1375
+ printf ("Failed to copy bundle\n");
1376
+ goto stop_emu_deploy;
1377
+ }
1378
+
1379
+ _tprintf( TEXT("DONE\n"));
1380
+ }
1381
+
1382
+ if (deploy_type == DEPLOY_EMU_WEBKIT)
1383
+ {
1384
+ //HANDLE hFind;
1385
+ //CE_FIND_DATA findData;
1386
+
1387
+ _tprintf( TEXT("Searching for Windows CE device..."));
1388
+
1389
+ if (SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)))
1390
+ {
1391
+ HANDLE hFind;
1392
+ CE_FIND_DATA findData;
1393
+
1394
+ CreateThread(NULL, 0, startDEM, NULL, 0, NULL);
1395
+
1396
+ _tprintf( TEXT("Starting emulator... "));
1397
+ if (!emuConnect (emu_name)) {
1398
+ _tprintf( TEXT("FAILED\n"));
1399
+ goto stop_emu_deploy;
1400
+ }
1401
+ _tprintf( TEXT("DONE\n"));
1402
+
1403
+ _tprintf( TEXT("Cradle emulator... "));
1404
+ if(!emuCradle (emu_name)) {
1405
+ _tprintf( TEXT("FAILED\n"));
1406
+ goto stop_emu_deploy;
1407
+ }
1408
+ _tprintf( TEXT("DONE\n"));
1409
+
1410
+ if (!wceConnect ()) {
1411
+ printf ("Failed to connect to remote device.\n");
1412
+ goto stop_emu_deploy;
1413
+ } else {
1414
+ hFind = CeFindFirstFile(app_dir, &findData);
1415
+ if (INVALID_HANDLE_VALUE == hFind) {
1416
+ _tprintf( TEXT("Application directory on device was not found\n"));
1417
+
1418
+ new_copy = 1;
1419
+
1420
+ if (!CeCreateDirectory(app_dir, NULL)) {
1421
+ printf ("Failed to create app directory\n");
1422
+ goto stop_emu_deploy;
1423
+ }
1424
+ }
1425
+ FindClose( hFind);
1426
+
1427
+ if (!findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
1428
+ _tprintf( TEXT("Error: target directory is file\n"));
1429
+ goto stop_emu_deploy;
1430
+ }
1431
+
1432
+ _tprintf( TEXT("Load files to device..."));
1433
+ USES_CONVERSION;
1434
+ if (copyBundle(src_path, _T("/"), app_dir) == EXIT_FAILURE) {
1435
+ printf ("Failed to copy bundle\n");
1436
+ goto stop_emu_deploy;
1437
+ }
1438
+
1439
+ _tprintf( TEXT("DONE\n"));
1440
+
1441
+ emuBringToFront(emu_name);
1442
+ }
1443
+ }
1444
+ }
1445
+
1446
+ return EXIT_SUCCESS;
1447
+ }