rhodes 2.2.4.beta.1 → 2.2.5.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/CHANGELOG +10 -0
  2. data/Rakefile +119 -3
  3. data/lib/build/jake.rb +15 -1
  4. data/lib/framework/dateME.rb +6 -1
  5. data/lib/framework/rho/render.rb +18 -15
  6. data/lib/framework/rho/rho.rb +105 -43
  7. data/lib/framework/rho/rhoapplication.rb +1 -1
  8. data/lib/framework/rho/rhocontact.rb +41 -13
  9. data/lib/framework/rho/rhocontroller.rb +10 -1
  10. data/lib/framework/rho/rhoevent_c.rb +6 -1
  11. data/lib/framework/rho/rhosupport.rb +1 -1
  12. data/lib/framework/rhodes.rb +1 -1
  13. data/lib/framework/rholang/rhomsg_de.rb +1 -1
  14. data/lib/framework/rholang/rhomsg_es.rb +1 -1
  15. data/lib/framework/rholang/rhomsg_it.rb +28 -0
  16. data/lib/framework/rhom/rhom.rb +6 -0
  17. data/lib/framework/rhom/rhom_model.rb +14 -7
  18. data/lib/framework/rhom/rhom_object_factory.rb +121 -56
  19. data/lib/framework/version.rb +1 -1
  20. data/lib/rhodes.rb +1 -1
  21. data/platform/android/Rhodes/AndroidManifest.full.xml +62 -0
  22. data/platform/android/Rhodes/AndroidManifest.xml +3 -34
  23. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +17 -2
  24. data/platform/android/Rhodes/jni/src/alert.cpp +16 -0
  25. data/platform/android/Rhodes/jni/src/callbacks.cpp +27 -3
  26. data/platform/android/Rhodes/jni/src/nativebar.cpp +3 -0
  27. data/platform/android/Rhodes/jni/src/nativeview.cpp +131 -1
  28. data/platform/android/Rhodes/jni/src/phonebook.cpp +102 -41
  29. data/platform/android/Rhodes/jni/src/rhodes.cpp +113 -32
  30. data/platform/android/Rhodes/jni/src/ringtones.cpp +1 -1
  31. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +1 -0
  32. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +9 -8
  33. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +184 -49
  34. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +49 -25
  35. data/platform/android/Rhodes/src/com/rhomobile/rhodes/alert/Alert.java +104 -57
  36. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +36 -2
  37. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +24 -14
  38. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +7 -8
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +185 -3
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoNativeViewManager.java +54 -1
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Contact.java +107 -14
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorNew.java +72 -24
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/ContactAccessorOld.java +22 -21
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/phonebook/Phonebook.java +91 -11
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +10 -0
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/ChromeClientNew.java +11 -0
  47. data/platform/android/Rhodes/src/com/rhomobile/rhodes/webview/RhoWebSettingsNew.java +10 -0
  48. data/platform/android/build/android.rake +50 -9
  49. data/platform/android/build/librhocommon_build.files +1 -0
  50. data/platform/bb/Hsqldb/src/org/hsqldb/Parser.java +3 -2
  51. data/platform/bb/Hsqldb/src/org/hsqldb/SchemaManager.java +3 -1
  52. data/platform/bb/Hsqldb/src/org/hsqldb/Session.java +7 -0
  53. data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +2 -2
  54. data/platform/bb/RubyVM/RubyVM.jdp +1 -0
  55. data/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java +22 -0
  56. data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +5 -0
  57. data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +1 -1
  58. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +51 -4
  59. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +21 -10
  60. data/platform/bb/RubyVM/src/com/rho/sync/SyncSource.java +82 -33
  61. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +59 -6
  62. data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyFloat_Methods.java +5 -0
  63. data/platform/bb/RubyVM/src/com/xruby/GeneratedMethods/RubyString_Methods.java +19 -7
  64. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/ArrayPacker.java +1 -1
  65. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFloat.java +5 -0
  66. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyString.java +55 -11
  67. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyTime.java +18 -2
  68. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyKernelModule.java +8 -5
  69. data/platform/bb/RubyVM/src/j2me/lang/CharacterMe.java +1 -1
  70. data/platform/bb/RubyVM/src/j2me/util/StringParser.java +2 -0
  71. data/platform/bb/build/RubyVM_build.files +1 -0
  72. data/platform/bb/build/bb.rake +21 -2
  73. data/platform/bb/rhodes/platform/4.7/com/rho/RhoMainScreen.java +3 -3
  74. data/platform/bb/rhodes/platform/common/com/rho/RhoMainScreen.java +1 -1
  75. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -2
  76. data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +15 -16
  77. data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +4 -0
  78. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +58 -0
  79. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +90 -4
  80. data/platform/iphone/Classes/AppManager/AppManager.m +43 -5
  81. data/platform/iphone/Classes/Event/Event.h +2 -0
  82. data/platform/iphone/Classes/Event/Event.m +12 -1
  83. data/platform/iphone/Classes/GeoLocation/LocationController.m +9 -3
  84. data/platform/iphone/Classes/MapView/MapViewController.m +20 -9
  85. data/platform/iphone/Classes/NativeBar.m +27 -0
  86. data/platform/iphone/Classes/Phonebook/phonebook.m +17 -0
  87. data/platform/iphone/Classes/RhoAlert.m +61 -1
  88. data/platform/iphone/Classes/RhoMainView.h +1 -0
  89. data/platform/iphone/Classes/Rhodes.h +2 -0
  90. data/platform/iphone/Classes/Rhodes.m +108 -1
  91. data/platform/iphone/Classes/SimpleMainView.h +4 -0
  92. data/platform/iphone/Classes/SimpleMainView.m +30 -3
  93. data/platform/iphone/Classes/SplashViewController.m +3 -1
  94. data/platform/iphone/Classes/TabbedMainView.h +2 -0
  95. data/platform/iphone/Classes/TabbedMainView.m +63 -11
  96. data/platform/iphone/Classes/rho/net/NetRequestImpl.m +26 -0
  97. data/platform/iphone/Info.plist +12 -1
  98. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
  99. data/platform/iphone/rbuild/iphone.rake +181 -25
  100. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +5 -5
  101. data/platform/shared/common/IRhoThreadImpl.h +1 -1
  102. data/platform/shared/common/PosixThreadImpl.cpp +5 -3
  103. data/platform/shared/common/PosixThreadImpl.h +1 -1
  104. data/platform/shared/common/RhoFilePath.h +11 -0
  105. data/platform/shared/common/RhoNativeViewManager.h +17 -0
  106. data/platform/shared/common/RhoThread.h +1 -1
  107. data/platform/shared/common/RhodesApp.cpp +29 -8
  108. data/platform/shared/common/ThreadQueue.cpp +5 -3
  109. data/platform/shared/common/ThreadQueue.h +2 -1
  110. data/platform/shared/common/app_build_configs.c +25 -0
  111. data/platform/shared/common/app_build_configs.h +11 -0
  112. data/platform/shared/net/AsyncHttp.cpp +5 -5
  113. data/platform/shared/net/CURLNetRequest.cpp +25 -7
  114. data/platform/shared/net/CURLNetRequest.h +2 -1
  115. data/platform/shared/net/HttpServer.cpp +28 -0
  116. data/platform/shared/ruby/ext/nativebar/nativebar.i +3 -0
  117. data/platform/shared/ruby/ext/nativebar/nativebar_wrap.c +26 -1
  118. data/platform/shared/ruby/ext/rho/rhoruby.c +6 -0
  119. data/platform/shared/ruby/ext/rho/rhoruby.h +1 -0
  120. data/platform/shared/ruby/ext/rho/rhosupport.c +15 -2
  121. data/platform/shared/ruby/ext/syncengine/syncengine.i +14 -2
  122. data/platform/shared/ruby/ext/syncengine/syncengine_wrap.c +97 -2
  123. data/platform/shared/ruby/ext/system/system.i +13 -0
  124. data/platform/shared/ruby/ext/system/system_wrap.c +104 -1
  125. data/platform/shared/rubyext/RhoAppAdapter.cpp +7 -0
  126. data/platform/shared/sync/SyncEngine.cpp +43 -3
  127. data/platform/shared/sync/SyncEngine.h +13 -0
  128. data/platform/shared/sync/SyncNotify.cpp +41 -23
  129. data/platform/shared/sync/SyncNotify.h +18 -4
  130. data/platform/shared/sync/SyncSource.cpp +52 -14
  131. data/platform/shared/sync/SyncSource.h +1 -0
  132. data/platform/shared/sync/SyncThread.cpp +29 -9
  133. data/platform/shared/sync/SyncThread.h +4 -2
  134. data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
  135. data/platform/wm/build/build_inf.js +15 -9
  136. data/platform/wm/build/wm.rake +10 -5
  137. data/platform/wm/rhodes/Alert.cpp +10 -0
  138. data/platform/wm/rhodes/Alert.h +3 -3
  139. data/platform/wm/rhodes/MainWindow.cpp +171 -26
  140. data/platform/wm/rhodes/MainWindow.h +23 -1
  141. data/platform/wm/rhodes/MetaHandler.cpp +192 -0
  142. data/platform/wm/rhodes/MetaHandler.h +31 -0
  143. data/platform/wm/rhodes/RhoNativeViewManager.cpp +126 -0
  144. data/platform/wm/rhodes/RhoNativeViewManagerWM.h +20 -0
  145. data/platform/wm/rhodes/Rhodes.cpp +91 -2
  146. data/platform/wm/rhodes/Rhodes.rc +15 -6
  147. data/platform/wm/rhodes/SyncStatusDlg.cpp +32 -0
  148. data/platform/wm/rhodes/SyncStatusDlg.h +29 -0
  149. data/platform/wm/rhodes/resource.h +5 -2
  150. data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +3 -1
  151. data/platform/wm/rhodes/rho/common/RhoThreadImpl.h +1 -1
  152. data/platform/wm/rhodes/rho/rubyext/SystemImpl.cpp +146 -14
  153. data/platform/wm/rhodes/rhodes.vcproj +28 -0
  154. data/rakefile.rb +119 -3
  155. data/res/build-tools/iphonesim/README +58 -0
  156. data/res/build-tools/iphonesim/Source/iPhoneSimulator.h +43 -0
  157. data/res/build-tools/iphonesim/Source/iPhoneSimulator.m +224 -0
  158. data/res/build-tools/iphonesim/Source/main.m +52 -0
  159. data/res/build-tools/iphonesim/Source/nsprintf.h +3 -0
  160. data/res/build-tools/iphonesim/Source/nsprintf.m +42 -0
  161. data/res/build-tools/iphonesim/build/Release/iphonesim +0 -0
  162. data/res/build-tools/iphonesim/iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h +124 -0
  163. data/res/build-tools/iphonesim/iphonesim.xcodeproj/project.pbxproj +261 -0
  164. data/res/build-tools/iphonesim/iphonesim_Prefix.pch +7 -0
  165. data/res/generators/rhogen.rb +5 -0
  166. data/res/generators/templates/application/app/layout.erb +7 -13
  167. data/res/generators/templates/application/app/loading.png +0 -0
  168. data/res/generators/templates/application/build.yml +3 -0
  169. data/res/generators/templates/application/icon/icon114.png +0 -0
  170. data/res/generators/templates/application/icon/icon57.png +0 -0
  171. data/res/generators/templates/application/icon/icon72.png +0 -0
  172. data/res/generators/templates/application/public/css/iphone.css +96 -0
  173. data/res/generators/templates/application/public/images/backButton.png +0 -0
  174. data/res/generators/templates/application/public/jqtouch/jqtouch.js +2 -1
  175. data/res/generators/templates/application/rhoconfig.txt +2 -0
  176. data/rhodes.gemspec +1 -1
  177. data/spec/phone_spec/app/spec/array_pack_spec.rb +108 -0
  178. data/spec/phone_spec/app/spec/bulksync_spec.rb +1 -0
  179. data/spec/phone_spec/app/spec/date_spec.rb +27 -0
  180. data/spec/phone_spec/app/spec/fixtures/classes.rb +91 -0
  181. data/spec/phone_spec/app/spec/lstrip_spec.rb +57 -0
  182. data/spec/phone_spec/app/spec/rho_spec.rb +50 -19
  183. data/spec/phone_spec/app/spec/rhom_object_spec.rb +78 -0
  184. data/spec/phone_spec/app/spec/rstrip_spec.rb +51 -0
  185. data/spec/phone_spec/app/spec/strip_spec.rb +50 -0
  186. data/spec/phone_spec/app/spec/syncengine_spec.rb +46 -3
  187. data/spec/phone_spec/app/spec_runner.rb +6 -0
  188. metadata +34 -4
@@ -1024,6 +1024,22 @@
1024
1024
  RelativePath=".\MainWindow.cpp"
1025
1025
  >
1026
1026
  </File>
1027
+ <File
1028
+ RelativePath=".\MetaHandler.cpp"
1029
+ >
1030
+ </File>
1031
+ <File
1032
+ RelativePath=".\MetaHandler.h"
1033
+ >
1034
+ </File>
1035
+ <File
1036
+ RelativePath=".\SyncStatusDlg.cpp"
1037
+ >
1038
+ </File>
1039
+ <File
1040
+ RelativePath=".\SyncStatusDlg.h"
1041
+ >
1042
+ </File>
1027
1043
  <File
1028
1044
  RelativePath=".\menubar.cpp"
1029
1045
  >
@@ -1182,6 +1198,10 @@
1182
1198
  RelativePath=".\resource.h"
1183
1199
  >
1184
1200
  </File>
1201
+ <File
1202
+ RelativePath=".\RhoNativeViewManagerWM.h"
1203
+ >
1204
+ </File>
1185
1205
  <File
1186
1206
  RelativePath=".\RingtoneManager.h"
1187
1207
  >
@@ -1357,6 +1377,14 @@
1357
1377
  </FileConfiguration>
1358
1378
  </File>
1359
1379
  </Filter>
1380
+ <Filter
1381
+ Name="NativeViewmanager"
1382
+ >
1383
+ <File
1384
+ RelativePath=".\RhoNativeViewManager.cpp"
1385
+ >
1386
+ </File>
1387
+ </Filter>
1360
1388
  <Filter
1361
1389
  Name="signature"
1362
1390
  >
data/rakefile.rb CHANGED
@@ -51,6 +51,94 @@ namespace "framework" do
51
51
  end
52
52
 
53
53
 
54
+ $application_build_configs_keys = ['security_token']
55
+
56
+ def make_application_build_config_header_file
57
+ inc_file = File.join($startdir, "platform", "shared", "common", "app_build_configs.c")
58
+ File.open(inc_file, "w") do |f|
59
+ f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
60
+ f.puts "// Generated #{Time.now.to_s}"
61
+ f.puts ""
62
+ f.puts "#include <string.h>"
63
+ f.puts ""
64
+ f.puts '#include "app_build_configs.h"'
65
+ f.puts ""
66
+
67
+ f.puts 'static const char* keys[] = { ""'
68
+ $application_build_configs.keys.each do |key|
69
+ f.puts ',"'+key+'"'
70
+ end
71
+ f.puts '};'
72
+ f.puts ''
73
+
74
+ count = 1
75
+
76
+ f.puts 'static const char* values[] = { ""'
77
+ $application_build_configs.keys.each do |key|
78
+ f.puts ',"'+$application_build_configs[key]+'"'
79
+ count = count + 1
80
+ end
81
+ f.puts '};'
82
+ f.puts ''
83
+
84
+ f.puts '#define APP_BUILD_CONFIG_COUNT '+count.to_s
85
+ f.puts ''
86
+ f.puts 'const char* get_app_build_config_item(const char* key) {'
87
+ f.puts ' int i;'
88
+ f.puts ' for (i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {'
89
+ f.puts ' if (strcmp(key, keys[i]) == 0) {'
90
+ f.puts ' return values[i];'
91
+ f.puts ' }'
92
+ f.puts ' }'
93
+ f.puts ' return 0;'
94
+ f.puts '}'
95
+ f.puts ''
96
+
97
+ end
98
+ end
99
+
100
+ def make_application_build_config_java_file
101
+ file_name = $startdir + "/platform/bb/RubyVM/src/com/rho/AppBuildConfig.java"
102
+
103
+ File.open(file_name, "w") do |f|
104
+ f.puts "// WARNING! THIS FILE IS GENERATED AUTOMATICALLY! DO NOT EDIT IT MANUALLY!"
105
+ f.puts "// Generated #{Time.now.to_s}"
106
+
107
+ f.puts "package com.rho;"
108
+ f.puts ""
109
+ f.puts "public class AppBuildConfig {"
110
+
111
+ f.puts 'static final String keys[] = { ""'
112
+ $application_build_configs.keys.each do |key|
113
+ f.puts ',"'+key+'"'
114
+ end
115
+ f.puts '};'
116
+ f.puts ''
117
+
118
+ count = 1
119
+
120
+ f.puts 'static final String values[] = { ""'
121
+ $application_build_configs.keys.each do |key|
122
+ f.puts ',"'+$application_build_configs[key]+'"'
123
+ count = count + 1
124
+ end
125
+ f.puts '};'
126
+ f.puts ''
127
+
128
+ f.puts 'static final int APP_BUILD_CONFIG_COUNT = '+count.to_s + ';'
129
+ f.puts ''
130
+ f.puts 'public static String getItem(String key){'
131
+ f.puts ' for (int i = 1; i < APP_BUILD_CONFIG_COUNT; i++) {'
132
+ f.puts ' if ( key.compareTo( keys[i]) == 0) {'
133
+ f.puts ' return values[i];'
134
+ f.puts ' }'
135
+ f.puts ' }'
136
+ f.puts ' return null;'
137
+ f.puts '}'
138
+ f.puts "}"
139
+ end
140
+ end
141
+
54
142
  namespace "config" do
55
143
  task :common do
56
144
  $startdir = File.dirname(__FILE__)
@@ -106,6 +194,32 @@ namespace "config" do
106
194
  extensions += $app_config[$config["platform"]]["extensions"] if $app_config[$config["platform"]] and
107
195
  $app_config[$config["platform"]]["extensions"] and $app_config[$config["platform"]]["extensions"].is_a? Array
108
196
  $app_config["extensions"] = extensions
197
+
198
+ $hidden_app = $app_config["hidden_app"].nil?() ? "0" : $app_config["hidden_app"]
199
+
200
+
201
+ #application build configs
202
+ application_build_configs = {}
203
+
204
+ $application_build_configs_keys.each do |key|
205
+ value = $app_config[key]
206
+ if $app_config[$config["platform"]] != nil
207
+ if $app_config[$config["platform"]][key] != nil
208
+ value = $app_config[$config["platform"]][key]
209
+ end
210
+ end
211
+ if value != nil
212
+ application_build_configs[key] = value
213
+ end
214
+ end
215
+ $application_build_configs = application_build_configs
216
+
217
+ if $current_platform == "bb"
218
+ make_application_build_config_java_file
219
+ else
220
+ make_application_build_config_header_file
221
+ end
222
+
109
223
  end
110
224
 
111
225
  out = `javac -version 2>&1`
@@ -311,7 +425,7 @@ def common_bundle_start(startdir, dest)
311
425
  clear_linker_settings
312
426
 
313
427
  init_extensions(startdir, dest)
314
-
428
+
315
429
  chdir startdir
316
430
  #throw "ME"
317
431
  cp_r app + '/app',File.join($srcdir,'apps'), :preserve => true
@@ -419,6 +533,7 @@ namespace "build" do
419
533
  task :xruby do
420
534
  #needs $config, $srcdir, $excludelib, $bindir
421
535
  app = $app_path
536
+ jpath = $config["env"]["paths"]["java"]
422
537
  startdir = pwd
423
538
  dest = $srcdir
424
539
  xruby = File.dirname(__FILE__) + '/res/build-tools/xruby-0.3.3.jar'
@@ -482,8 +597,9 @@ namespace "build" do
482
597
  rm_rf $tmpdir
483
598
  mkdir_p $tmpdir
484
599
  chdir $srcdir
485
- =end
486
- puts `jar uf ../RhoBundle.jar apps/#{$all_files_mask}`
600
+ =end
601
+
602
+ puts `"#{File.join(jpath,'jar')}" uf ../RhoBundle.jar apps/#{$all_files_mask}`
487
603
  unless $? == 0
488
604
  puts "Error creating Rhobundle.jar"
489
605
  exit 1
@@ -0,0 +1,58 @@
1
+ iPhone Simulator
2
+ ----------------
3
+
4
+ The iPhone Simulator is a simple command line utility for
5
+ launching an iphone application in the simulator. This allows
6
+ for nice things like automated testing of unit tests, etc without
7
+ having to open XCode.
8
+
9
+ The original code was written by Landon Fuller (with license
10
+ below). Minor modifications made by Jeff Haynie (Appcelerator).
11
+
12
+
13
+ You can run the application by first building your application in
14
+ xcode using the xcodebuild command from the command line. You can
15
+ then run it in the simulator using the following as an example:
16
+
17
+ ./iphonesim launch ~/tmp/yourproject/build/Debug.simulator/yourproject.app
18
+
19
+ You need to point to either Debug.simulator or Release.simulator based
20
+ on which build type you built with.
21
+
22
+
23
+ Cheers!
24
+
25
+ Jeff Haynie
26
+ jhaynie@appcelerator.com
27
+
28
+
29
+
30
+ Author: Landon Fuller <landonf@plausiblelabs.com>
31
+ Copyright (c) 2008 Plausible Labs Cooperative, Inc.
32
+ All rights reserved.
33
+
34
+ Permission is hereby granted, free of charge, to any person
35
+ obtaining a copy of this software and associated documentation
36
+ files (the "Software"), to deal in the Software without
37
+ restriction, including without limitation the rights to use,
38
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the
40
+ Software is furnished to do so, subject to the following
41
+ conditions:
42
+
43
+ The above copyright notice and this permission notice shall be
44
+ included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
47
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
48
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
49
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
50
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
51
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
52
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
53
+ OTHER DEALINGS IN THE SOFTWARE.
54
+
55
+
56
+ Modifications made by Appcelerator, Inc. relicensed under
57
+ the same license as above.
58
+
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Author: Landon Fuller <landonf@plausiblelabs.com>
3
+ * Copyright (c) 2008 Plausible Labs Cooperative, Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person
7
+ * obtaining a copy of this software and associated documentation
8
+ * files (the "Software"), to deal in the Software without
9
+ * restriction, including without limitation the rights to use,
10
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the
12
+ * Software is furnished to do so, subject to the following
13
+ * conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ * OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ /**
29
+ * Modifications made by Appcelerator, Inc. relicensed under
30
+ * the same license as above.
31
+ */
32
+
33
+ #import <Foundation/Foundation.h>
34
+ #import <iPhoneSimulatorRemoteClient/iPhoneSimulatorRemoteClient.h>
35
+
36
+ @interface iPhoneSimulator : NSObject <DTiPhoneSimulatorSessionDelegate> {
37
+ @private
38
+ DTiPhoneSimulatorSystemRoot *sdkRoot;
39
+ }
40
+
41
+ - (void) runWithArgc: (int) argc argv: (char **) argv;
42
+
43
+ @end
@@ -0,0 +1,224 @@
1
+ /*
2
+ * Author: Landon Fuller <landonf@plausiblelabs.com>
3
+ * Copyright (c) 2008 Plausible Labs Cooperative, Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person
7
+ * obtaining a copy of this software and associated documentation
8
+ * files (the "Software"), to deal in the Software without
9
+ * restriction, including without limitation the rights to use,
10
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the
12
+ * Software is furnished to do so, subject to the following
13
+ * conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ * OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ /**
29
+ * Modifications made by Appcelerator, Inc. licensed under the
30
+ * same license as above.
31
+ */
32
+
33
+ #import "iPhoneSimulator.h"
34
+ #import "nsprintf.h"
35
+
36
+ /**
37
+ * A simple iPhoneSimulatorRemoteClient framework.
38
+ */
39
+ @implementation iPhoneSimulator
40
+
41
+ /**
42
+ * Print usage.
43
+ */
44
+ - (void) printUsage {
45
+ fprintf(stderr, "Usage: iphonesim <options> <command> ...\n");
46
+ fprintf(stderr, "Commands:\n");
47
+ fprintf(stderr, " showsdks\n");
48
+ fprintf(stderr, " launch <application path> [sdkversion] [family] [uuid]\n");
49
+ }
50
+
51
+
52
+ /**
53
+ * List available SDK roots.
54
+ */
55
+ - (int) showSDKs {
56
+ NSArray *roots = [DTiPhoneSimulatorSystemRoot knownRoots];
57
+
58
+ nsprintf(@"Simulator SDK Roots:");
59
+ for (DTiPhoneSimulatorSystemRoot *root in roots) {
60
+ nsfprintf(stderr, @"'%@' (%@)\n\t%@", [root sdkDisplayName], [root sdkVersion], [root sdkRootPath]);
61
+ }
62
+
63
+ return EXIT_SUCCESS;
64
+ }
65
+
66
+ - (void) session: (DTiPhoneSimulatorSession *) session didEndWithError: (NSError *) error {
67
+ nsprintf(@"Session did end with error %@", error);
68
+
69
+ if (error != nil)
70
+ exit(EXIT_FAILURE);
71
+
72
+ exit(EXIT_SUCCESS);
73
+ }
74
+
75
+
76
+ - (void) session: (DTiPhoneSimulatorSession *) session didStart: (BOOL) started withError: (NSError *) error {
77
+ if (started) {
78
+ nsprintf(@"Session started");
79
+ } else {
80
+ nsprintf(@"Session could not be started: %@", error);
81
+ exit(EXIT_FAILURE);
82
+ }
83
+ }
84
+
85
+
86
+ /**
87
+ * Launch the given Simulator binary.
88
+ */
89
+ - (int) launchApp: (NSString *) path withFamily:(NSString*)family uuid:(NSString*)uuid{
90
+ DTiPhoneSimulatorApplicationSpecifier *appSpec;
91
+ DTiPhoneSimulatorSessionConfig *config;
92
+ DTiPhoneSimulatorSession *session;
93
+ NSError *error;
94
+
95
+ /* Create the app specifier */
96
+ appSpec = [DTiPhoneSimulatorApplicationSpecifier specifierWithApplicationPath: path];
97
+ if (appSpec == nil) {
98
+ nsprintf(@"Could not load application specification for %s", path);
99
+ return EXIT_FAILURE;
100
+ }
101
+ nsprintf(@"App Spec: %@", appSpec);
102
+
103
+ /* Load the default SDK root */
104
+
105
+ nsprintf(@"SDK Root: %@", sdkRoot);
106
+
107
+ /* Set up the session configuration */
108
+ config = [[[DTiPhoneSimulatorSessionConfig alloc] init] autorelease];
109
+ [config setApplicationToSimulateOnStart: appSpec];
110
+ [config setSimulatedSystemRoot: sdkRoot];
111
+ [config setSimulatedApplicationShouldWaitForDebugger: NO];
112
+
113
+ [config setSimulatedApplicationLaunchArgs: [NSArray array]];
114
+ [config setSimulatedApplicationLaunchEnvironment: [NSDictionary dictionary]];
115
+
116
+ [config setLocalizedClientName: @"Rhodes Developer"];
117
+
118
+ // this was introduced in 3.2 of SDK
119
+ if ([config respondsToSelector:@selector(setSimulatedDeviceFamily:)])
120
+ {
121
+ if (family == nil)
122
+ {
123
+ family = @"iphone";
124
+ }
125
+
126
+ nsprintf(@"using device family %@",family);
127
+
128
+ if ([family isEqualToString:@"ipad"])
129
+ {
130
+ [config setSimulatedDeviceFamily:[NSNumber numberWithInt:2]];
131
+ }
132
+ else
133
+ {
134
+ if ([family isEqualToString:@"iphone4"])
135
+ {
136
+ [config setSimulatedDeviceFamily:[NSNumber numberWithInt:3]];
137
+ }
138
+ else
139
+ {
140
+ [config setSimulatedDeviceFamily:[NSNumber numberWithInt:1]];
141
+ }
142
+ }
143
+ }
144
+
145
+ /* Start the session */
146
+ session = [[[DTiPhoneSimulatorSession alloc] init] autorelease];
147
+ [session setDelegate: self];
148
+ [session setSimulatedApplicationPID: [NSNumber numberWithInt: 35]];
149
+ if (uuid!=nil)
150
+ {
151
+ [session setUuid:uuid];
152
+ }
153
+
154
+ if (![session requestStartWithConfig: config timeout: 30 error: &error]) {
155
+ nsprintf(@"Could not start simulator session: %@", error);
156
+ return EXIT_FAILURE;
157
+ }
158
+
159
+ return EXIT_SUCCESS;
160
+ }
161
+
162
+
163
+ /**
164
+ * Execute 'main'
165
+ */
166
+ - (void) runWithArgc: (int) argc argv: (char **) argv {
167
+ /* Read the command */
168
+ if (argc < 2) {
169
+ [self printUsage];
170
+ exit(EXIT_FAILURE);
171
+ }
172
+
173
+ if (strcmp(argv[1], "showsdks") == 0) {
174
+ exit([self showSDKs]);
175
+ }
176
+ else if (strcmp(argv[1], "launch") == 0) {
177
+ /* Requires an additional argument */
178
+ if (argc < 3) {
179
+ fprintf(stderr, "Missing application path argument\n");
180
+ [self printUsage];
181
+ exit(EXIT_FAILURE);
182
+ }
183
+ if (argc > 3) {
184
+ NSString* ver = [NSString stringWithCString:argv[3] encoding:NSUTF8StringEncoding];
185
+ NSArray *roots = [DTiPhoneSimulatorSystemRoot knownRoots];
186
+ for (DTiPhoneSimulatorSystemRoot *root in roots) {
187
+ NSString *v = [root sdkVersion];
188
+ if ([v isEqualToString:ver])
189
+ {
190
+ sdkRoot = root;
191
+ break;
192
+ }
193
+ }
194
+ if (sdkRoot == nil)
195
+ {
196
+ fprintf(stderr,"Unknown or unsupported SDK version: %s\n",argv[3]);
197
+ [self showSDKs];
198
+ exit(EXIT_FAILURE);
199
+ }
200
+ }
201
+ else {
202
+ sdkRoot = [DTiPhoneSimulatorSystemRoot defaultRoot];
203
+ }
204
+
205
+ /* Don't exit, adds to runloop */
206
+ NSString *family = nil;
207
+ NSString *uuid = nil;
208
+ if (argc > 4)
209
+ {
210
+ family = [NSString stringWithUTF8String:argv[4]];
211
+ }
212
+ if (argc > 5)
213
+ {
214
+ uuid = [NSString stringWithUTF8String:argv[5]];
215
+ }
216
+ [self launchApp: [NSString stringWithUTF8String: argv[2]] withFamily:family uuid:uuid];
217
+ } else {
218
+ fprintf(stderr, "Unknown command\n");
219
+ [self printUsage];
220
+ exit(EXIT_FAILURE);
221
+ }
222
+ }
223
+
224
+ @end
@@ -0,0 +1,52 @@
1
+ /*
2
+ * Author: Landon Fuller <landonf@plausiblelabs.com>
3
+ * Copyright (c) 2008 Plausible Labs Cooperative, Inc.
4
+ * All rights reserved.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person
7
+ * obtaining a copy of this software and associated documentation
8
+ * files (the "Software"), to deal in the Software without
9
+ * restriction, including without limitation the rights to use,
10
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the
12
+ * Software is furnished to do so, subject to the following
13
+ * conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be
16
+ * included in all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ * OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+
28
+ /**
29
+ * Some modifications made by Appcelerator which are licensed
30
+ * under the same license as above.
31
+ */
32
+
33
+ #import <AppKit/AppKit.h>
34
+
35
+ #import "iPhoneSimulator.h"
36
+
37
+ /*
38
+ * Runs the iPhoneSimulator backed by a main runloop.
39
+ */
40
+ int main (int argc, char *argv[]) {
41
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
42
+ iPhoneSimulator *sim = [[iPhoneSimulator alloc] init];
43
+
44
+ /* Execute command line handler */
45
+ [sim runWithArgc: argc argv: argv];
46
+
47
+ /* Run the loop to handle added input sources, if any */
48
+ [[NSRunLoop mainRunLoop] run];
49
+
50
+ [pool release];
51
+ return 0;
52
+ }
@@ -0,0 +1,3 @@
1
+ int nsvfprintf (FILE *stream, NSString *format, va_list args);
2
+ int nsfprintf (FILE *stream, NSString *format, ...);
3
+ int nsprintf (NSString *format, ...);
@@ -0,0 +1,42 @@
1
+ /*
2
+ * NSLog() clone, but writes to arbitrary output stream
3
+ */
4
+
5
+ #import <Foundation/Foundation.h>
6
+ #import <stdio.h>
7
+
8
+ int nsvfprintf (FILE *stream, NSString *format, va_list args) {
9
+ int retval;
10
+
11
+ NSString *str = (NSString *) CFStringCreateWithFormatAndArguments(NULL, NULL, (CFStringRef) format, args);
12
+ retval = fprintf(stream, "[DEBUG] %s\n", [str UTF8String]);
13
+ [str release];
14
+
15
+ return retval;
16
+ }
17
+
18
+ int nsfprintf (FILE *stream, NSString *format, ...) {
19
+ va_list ap;
20
+ int retval;
21
+
22
+ va_start(ap, format);
23
+ {
24
+ retval = nsvfprintf(stream, format, ap);
25
+ }
26
+ va_end(ap);
27
+
28
+ return retval;
29
+ }
30
+
31
+ int nsprintf (NSString *format, ...) {
32
+ va_list ap;
33
+ int retval;
34
+
35
+ va_start(ap, format);
36
+ {
37
+ retval = nsvfprintf(stderr, format, ap);
38
+ }
39
+ va_end(ap);
40
+
41
+ return retval;
42
+ }