rhodes 3.2.0.beta.5 → 3.2.0.beta.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/CHANGELOG +3 -0
  2. data/Manifest.txt +10 -1
  3. data/Rakefile +6 -0
  4. data/bin/get-rhodes-info +4 -27
  5. data/bin/set-rhodes-sdk +4 -1
  6. data/doc/build.txt +12 -3
  7. data/doc/extensions.txt +26 -0
  8. data/installer/Rakefile +156 -0
  9. data/installer/ServiceLib.nsh +369 -0
  10. data/installer/jake.rb +478 -0
  11. data/installer/rhostudio.nsi +76 -143
  12. data/lib/extensions/digest-sha1/ext/Rakefile +58 -40
  13. data/lib/extensions/fileutils/fileutils.rb +3 -2
  14. data/lib/extensions/hmac/hmac-md5.rb +11 -0
  15. data/lib/extensions/hmac/hmac-rmd160.rb +11 -0
  16. data/lib/extensions/hmac/hmac-sha1.rb +11 -0
  17. data/lib/extensions/hmac/hmac-sha2.rb +25 -0
  18. data/lib/extensions/hmac/hmac.rb +118 -0
  19. data/lib/extensions/hmac/ruby_hmac.rb +2 -0
  20. data/lib/extensions/net-http/net/http.rb +1 -1
  21. data/lib/framework/rho/render.rb +1 -1
  22. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesActivity.java +1 -6
  23. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesApplication.java +52 -8
  24. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +8 -15
  25. data/platform/android/Rhodes/src/com/rhomobile/rhodes/util/PerformOnUiThread.java +4 -5
  26. data/platform/android/build/android.rake +3 -1
  27. data/platform/iphone/rbuild/iphone.rake +7 -7
  28. data/platform/shared/common/RhodesApp.cpp +18 -14
  29. data/platform/shared/common/RhodesApp.h +1 -0
  30. data/platform/shared/rubyext/System.cpp +3 -0
  31. data/platform/symbian/build/symbian.rake +13 -5
  32. data/platform/wp7/RhoRubyLib/net/NetRequest.cs +9 -1
  33. data/rakefile.rb +6 -0
  34. data/res/generators/templates/application/Rakefile +10 -1
  35. data/res/generators/templates/application/app/layout.erb +1 -1
  36. data/res/generators/templates/application/build.yml +2 -2
  37. data/res/generators/templates/application/public/jqmobile/{jquery.mobile.iphone.css → jquery-mobile-iphone.css} +0 -0
  38. data/res/generators/templates/application/public/js/jqmobile-patch.js +23 -20
  39. data/spec/framework_spec/app/spec/library/digest/sha1/file_spec.rb +3 -3
  40. data/spec/framework_spec/app/spec/library/net/http/http/Proxy_spec.rb +3 -2
  41. data/spec/framework_spec/app/spec/library/net/http/http/copy_spec.rb +1 -1
  42. data/spec/framework_spec/app/spec/library/net/http/http/delete_spec.rb +1 -1
  43. data/spec/framework_spec/app/spec/library/net/http/http/finish_spec.rb +1 -1
  44. data/spec/framework_spec/app/spec/library/net/http/http/fixtures/http_server.rb +18 -12
  45. data/spec/framework_spec/app/spec/library/net/http/http/get_print_spec.rb +2 -2
  46. data/spec/framework_spec/app/spec/library/net/http/http/get_response_spec.rb +2 -2
  47. data/spec/framework_spec/app/spec/library/net/http/http/get_spec.rb +3 -3
  48. data/spec/framework_spec/app/spec/library/net/http/http/head_spec.rb +1 -1
  49. data/spec/framework_spec/app/spec/library/net/http/http/initialize_spec.rb +2 -2
  50. data/spec/framework_spec/app/spec/library/net/http/http/inspect_spec.rb +4 -4
  51. data/spec/framework_spec/app/spec/library/net/http/http/lock_spec.rb +1 -1
  52. data/spec/framework_spec/app/spec/library/net/http/http/mkcol_spec.rb +1 -1
  53. data/spec/framework_spec/app/spec/library/net/http/http/move_spec.rb +1 -1
  54. data/spec/framework_spec/app/spec/library/net/http/http/new_spec.rb +7 -7
  55. data/spec/framework_spec/app/spec/library/net/http/http/newobj_spec.rb +2 -2
  56. data/spec/framework_spec/app/spec/library/net/http/http/options_spec.rb +1 -1
  57. data/spec/framework_spec/app/spec/library/net/http/http/port_spec.rb +2 -2
  58. data/spec/framework_spec/app/spec/library/net/http/http/post_form_spec.rb +1 -1
  59. data/spec/framework_spec/app/spec/library/net/http/http/post_spec.rb +1 -1
  60. data/spec/framework_spec/app/spec/library/net/http/http/propfind_spec.rb +1 -1
  61. data/spec/framework_spec/app/spec/library/net/http/http/proppatch_spec.rb +1 -1
  62. data/spec/framework_spec/app/spec/library/net/http/http/proxy_address_spec.rb +2 -2
  63. data/spec/framework_spec/app/spec/library/net/http/http/proxy_pass_spec.rb +3 -3
  64. data/spec/framework_spec/app/spec/library/net/http/http/proxy_port_spec.rb +3 -3
  65. data/spec/framework_spec/app/spec/library/net/http/http/proxy_user_spec.rb +3 -3
  66. data/spec/framework_spec/app/spec/library/net/http/http/put_spec.rb +1 -1
  67. data/spec/framework_spec/app/spec/library/net/http/http/request_spec.rb +1 -1
  68. data/spec/framework_spec/app/spec/library/net/http/http/send_request_spec.rb +1 -1
  69. data/spec/framework_spec/app/spec/library/net/http/http/set_debug_output_spec.rb +1 -1
  70. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_get.rb +1 -1
  71. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_head.rb +1 -1
  72. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_post.rb +1 -1
  73. data/spec/framework_spec/app/spec/library/net/http/http/shared/request_put.rb +1 -1
  74. data/spec/framework_spec/app/spec/library/net/http/http/shared/started.rb +1 -1
  75. data/spec/framework_spec/app/spec/library/net/http/http/start_spec.rb +8 -8
  76. data/spec/framework_spec/app/spec/library/net/http/http/trace_spec.rb +1 -1
  77. data/spec/framework_spec/app/spec/library/net/http/http/unlock_spec.rb +1 -1
  78. data/spec/framework_spec/app/spec_runner.rb +1 -1
  79. data/spec/framework_spec/build.yml +2 -2
  80. data/spec/phone_spec/app/spec/rhom_object_spec.rb +43 -2
  81. data/version +1 -1
  82. metadata +14 -5
data/installer/jake.rb ADDED
@@ -0,0 +1,478 @@
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
+ require 'pathname'
28
+ require 'yaml'
29
+ require 'socket'
30
+ require 'webrick'
31
+
32
+ class Hash
33
+ def fetch_r(key)
34
+ if self.has_key?(key) and not self[key].is_a?(Hash)
35
+ return self[key]
36
+ else
37
+ self.each do |val|
38
+ value = false
39
+ if val.is_a?(Array)
40
+ val.each do |x|
41
+ value = x.fetch_r(key) if x.is_a?(Hash)
42
+ return value if value
43
+ end
44
+ end
45
+ value = val.fetch_r(key) if val.is_a?(Hash)
46
+ return value if value
47
+ end
48
+ end
49
+ return false
50
+ end
51
+ end
52
+
53
+ class Jake
54
+
55
+ def self.config(configfile)
56
+ conf = YAML::load(configfile)
57
+ res = self.config_parse(conf)
58
+ res
59
+ end
60
+ def self.set_bbver(bbver)
61
+ @@bbver = bbver
62
+ end
63
+
64
+ def self.get_absolute(path)
65
+ get_absolute_ex(path, Dir.pwd())
66
+ end
67
+
68
+ def self.get_absolute_ex(path, currentdir)
69
+ ret_path = File.expand_path(path, currentdir)
70
+ return ret_path if File.exists?(ret_path)
71
+
72
+ path = currentdir + "/" + path
73
+
74
+ patharray = path.split(/\//)
75
+
76
+ while idx = patharray.index("..") do
77
+ if idx == 0
78
+ raise "error getting absolute"
79
+ end
80
+
81
+ if patharray[idx-1] != ".."
82
+ patharray.delete_at(idx)
83
+ patharray.delete_at(idx-1)
84
+ end
85
+ end
86
+ return patharray.join("/")
87
+ end
88
+
89
+ def self.config_parse(conf)
90
+ if conf.is_a?(Array)
91
+ conf.collect! do |x|
92
+ if x.is_a?(Hash) or x.is_a?(Array)
93
+ x = config_parse(x)
94
+ x
95
+ else
96
+ if x =~ /%(.*?)%/
97
+ x.gsub!(/%.*?%/, conf.fetch_r($1).to_s)
98
+ end
99
+ s = x.to_s
100
+ if File.exists? s
101
+ s.gsub!(/\\/, '/')
102
+ end
103
+ s
104
+ end
105
+ end
106
+ elsif conf.is_a?(Hash)
107
+ newhash = Hash.new
108
+
109
+ conf.each do |k,x|
110
+ if x.is_a?(Hash) or x.is_a?(Array)
111
+ newhash[k.to_s] = config_parse(x)
112
+ else
113
+ s = x.to_s
114
+ if File.exists? s
115
+ s.gsub!(/\\/, '/')
116
+ end
117
+ newhash[k.to_s] = s
118
+ end
119
+ end
120
+ conf = newhash
121
+
122
+ conf
123
+ end
124
+
125
+ conf
126
+ end
127
+
128
+ def self.localip
129
+ orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true # turn off reverse DNS resolution temporarily
130
+ UDPSocket.open do |s|
131
+ s.connect '174.142.8.58', 1
132
+ s.addr.last
133
+ end
134
+ ensure
135
+ Socket.do_not_reverse_lookup = orig
136
+ end
137
+
138
+ def self.run_local_server(port = 0)
139
+ addr = localip
140
+ server = WEBrick::HTTPServer.new :BindAddress => addr, :Port => port
141
+ port = server.config[:Port]
142
+ puts "LOCAL SERVER STARTED ON #{addr}:#{port}"
143
+ Thread.new { server.start }
144
+ return server, addr, port
145
+ end
146
+
147
+ def self.run_spec_app(platform,appname)
148
+ rhobuildyml = File.join(basedir,'rhobuild.yml')
149
+ rhobuild = YAML::load_file(rhobuildyml)
150
+ rhobuild['env']['app'] = app_expanded_path(appname)
151
+ File.open(rhobuildyml,'w') {|f| f.write rhobuild.to_yaml}
152
+ $app_path = File.expand_path(File.join(basedir,'spec',appname))
153
+ $app_config = Jake.config(File.open(File.join($app_path, "build.yml")))
154
+ $config = Jake.config(File.open(rhobuildyml,'r'))
155
+
156
+ server, addr, port = run_local_server
157
+ File.open(File.join($app_path, 'app', 'local_server.rb'), 'w') do |f|
158
+ f.puts "SPEC_LOCAL_SERVER_HOST = '#{addr}'"
159
+ f.puts "SPEC_LOCAL_SERVER_PORT = #{port}"
160
+ end
161
+ if File.exists?(File.join($app_path, 'server.rb'))
162
+ $local_server = server
163
+ require File.join($app_path, 'server.rb')
164
+ end
165
+ begin
166
+ Rake::Task.tasks.each { |t| t.reenable }
167
+ Rake::Task['run:' + platform + ':spec'].invoke
168
+ ensure
169
+ server.shutdown
170
+ end
171
+
172
+ $failed.to_i
173
+ end
174
+
175
+ def self.before_run_spec()
176
+ $total ||= 0
177
+ $passed ||= 0
178
+ $failed ||= 0
179
+ $faillog = []
180
+ $getdump = false
181
+ end
182
+
183
+ def self.process_spec_output(line)
184
+ puts line if line =~ /\| - it/ or line =~ /\| describe/
185
+
186
+ if $getdump
187
+ if line =~ /^I/
188
+ $getdump = false
189
+ else
190
+ if !$faillog.include?(line)
191
+ $faillog << line
192
+ end
193
+ end
194
+ end
195
+
196
+ if line =~ /\*\*\*Failed:\s+(.*)/
197
+ $failed += $1.to_i
198
+ return false
199
+ elsif line =~ /\*\*\*Total:\s+(.*)/
200
+ $total += $1.to_i
201
+ elsif line =~ /\*\*\*Passed:\s+(.*)/
202
+ $passed += $1.to_i
203
+ end
204
+
205
+ if line =~ /\| FAIL:/
206
+ line = line.gsub(/I.*APP\|/,"\n\n***")
207
+ if !$faillog.include?(line)
208
+ $faillog << line
209
+ end
210
+ $getdump = true
211
+ end
212
+
213
+ return true
214
+ end
215
+
216
+ def self.process_spec_results(start)
217
+ finish = Time.now
218
+
219
+ FileUtils.rm_rf $app_path + "/faillog.txt"
220
+ File.open($app_path + "/faillog.txt", "w") { |io| $faillog.each {|x| io << x } } if $failed.to_i > 0
221
+
222
+ puts "************************"
223
+ puts "\n\n"
224
+ puts "Tests completed in #{finish - start} seconds"
225
+ puts "Total: #{$total}"
226
+ puts "Passed: #{$passed}"
227
+ puts "Failed: #{$failed}"
228
+ puts "\n"
229
+ puts "Failures stored in faillog.txt" if $failed.to_i > 0
230
+ end
231
+
232
+ def self.run2(command, args, options = {}, &block)
233
+ argv = []
234
+ currentdir = ""
235
+ retval = ""
236
+ argv << command
237
+ argv += args
238
+ argv.map! { |x| x.to_s }.map! { |x| x =~ /^".*"$/ ? x[1..-2] : x }
239
+
240
+ wd = options[:directory]
241
+ if not wd.nil?
242
+ currentdir = Dir.pwd()
243
+ Dir.chdir wd
244
+ end
245
+
246
+ cmdstr = argv.map { |x| x =~ / |\|/ ? '"' + x + '"' : x }.join(' ')
247
+
248
+ puts "PWD: " + Dir.pwd()
249
+ puts "CMD: " + cmdstr
250
+ $stdout.flush
251
+
252
+ hideerrors = options[:hideerrors]
253
+ if hideerrors
254
+ if RUBY_PLATFORM =~ /(win|w)32$/
255
+ nul = "nul"
256
+ else
257
+ nul = "/dev/null"
258
+ end
259
+ end
260
+
261
+ if options[:system]
262
+ system(cmdstr)
263
+ retval = ""
264
+ else
265
+ argv = cmdstr if RUBY_VERSION =~ /^1\.8/
266
+ if options[:nowait]
267
+ retval = IO.popen(argv)
268
+ else
269
+ IO.popen(argv) do |f|
270
+ while line = f.gets
271
+ if block_given?
272
+ res = yield(line)
273
+ if !res
274
+ #puts "f.pid : #{f.pid}"
275
+ Process.kill( 9, f.pid )
276
+ end
277
+ else
278
+ retval += line
279
+ puts "RET: " + line
280
+ $stdout.flush
281
+ end
282
+ end
283
+ end
284
+ end
285
+ end
286
+
287
+ if not wd.nil?
288
+ Dir.chdir currentdir
289
+ end
290
+
291
+ retval
292
+ end
293
+
294
+ def self.run(command, args, wd=nil,system = false, hideerrors = false)
295
+ self.run2(command, args, {:directory => wd, :system => system, :hiderrors => hideerrors})
296
+ end
297
+
298
+ def self.unjar(src,targetdir)
299
+ jpath = $config["env"]["paths"]["java"]
300
+ cmd = jpath && jpath.length()>0 ? File.join(jpath, "jar" ) : "jar"
301
+
302
+ # if RUBY_PLATFORM =~ /(win|w)32$/
303
+ # cmd = $config["env"]["paths"]["java"] + "/jar.exe"
304
+ # else
305
+ # cmd = $config["env"]["paths"]["java"] + "/jar"
306
+ # end
307
+
308
+ p = Pathname.new(src)
309
+ src = p.realpath
310
+ currentdir = Dir.pwd()
311
+ src = src.to_s.gsub(/"/,"")
312
+
313
+ args = Array.new
314
+
315
+ args << "xf"
316
+ args << src.to_s
317
+
318
+ Dir.chdir targetdir
319
+ puts run(cmd,args)
320
+ Dir.chdir currentdir
321
+ end
322
+
323
+ def self.jarfilelist(target)
324
+ jpath = $config["env"]["paths"]["java"]
325
+ cmd = jpath && jpath.length()>0 ? File.join(jpath, "jar" ) : "jar"
326
+
327
+ # if RUBY_PLATFORM =~ /(win|w)32$/
328
+ # cmd = $config["env"]["paths"]["java"] + "/jar.exe"
329
+ # else
330
+ # cmd = $config["env"]["paths"]["java"] + "/jar"
331
+ # end
332
+ target.gsub!(/"/,"")
333
+
334
+ args = []
335
+ args << "tf"
336
+ args << target
337
+
338
+ filelist = []
339
+ run(cmd,args).each { |file| filelist << file if not file =~ /\/$/ }
340
+
341
+ filelist
342
+ end
343
+
344
+ def self.jar(target,manifest,files,isfolder=false)
345
+ jpath = $config["env"]["paths"]["java"]
346
+ cmd = jpath && jpath.length()>0 ? File.join(jpath, "jar" ) : "jar"
347
+ #cmd += ".exe" if RUBY_PLATFORM =~ /(win|w)32$/
348
+
349
+ target.gsub!(/"/,"")
350
+
351
+ args = []
352
+ args << "cfm"
353
+ args << target
354
+ args << manifest
355
+ if isfolder
356
+ args << "-C"
357
+ args << files
358
+ args << "."
359
+ else
360
+ args << files
361
+ end
362
+
363
+ puts run(cmd,args)
364
+
365
+
366
+ end
367
+
368
+ def self.rapc(output,destdir,imports,files,title=nil,vendor=nil,version=nil,icon=nil,library=true,cldc=false,quiet=true, nowarn=true)
369
+ #cmd = $config["env"]["paths"][$config["env"]["bbver"]]["java"] + "/java.exe"
370
+ # cmd = "java.exe"
371
+
372
+ jdehome = $config["env"]["paths"][@@bbver]["jde"]
373
+ javabin = $config["env"]["paths"]["java"]
374
+ cmd = jdehome + "/bin/rapc.exe"
375
+
376
+ currentdir = Dir.pwd()
377
+
378
+
379
+ Dir.chdir destdir
380
+
381
+ if output and title and version and vendor
382
+ f = File.new(output + ".rapc", "w")
383
+ f.write "MicroEdition-Profile: MIDP-2.0\n"
384
+ f.write "MicroEdition-Configuration: CLDC-1.1\n"
385
+ f.write "MIDlet-Name: " + title + "\n"
386
+ f.write "MIDlet-Version: " + version.to_s + "\n"
387
+ f.write "MIDlet-Vendor: " + vendor.to_s + "\n"
388
+ f.write "MIDlet-Jar-URL: " + output + ".jar\n"
389
+ f.write "MIDlet-Jar-Size: 0\n"
390
+ f.write "RIM-Library-Flags: 2\n" if library
391
+
392
+ if cldc and icon
393
+ f.write "MIDlet-1: " + title + "," + icon + ",\n"
394
+ puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! service_enabled: #{$service_enabled}"
395
+ $stdout.flush
396
+
397
+ if $service_enabled
398
+ if $hidden_app == "0"
399
+ f.write "RIM-MIDlet-Flags-1: 1\n"
400
+ else
401
+ f.write "RIM-MIDlet-Flags-1: 3\n"
402
+ end
403
+ else
404
+ if $hidden_app == "0"
405
+ f.write "RIM-MIDlet-Flags-1: 0\n"
406
+ else
407
+ f.write "RIM-MIDlet-Flags-1: 2\n"
408
+ end
409
+ end
410
+
411
+ end
412
+
413
+ f.close
414
+ end
415
+
416
+
417
+ args = []
418
+ #args << "-classpath"
419
+ # args << "-jar"
420
+ #args << jdehome + "/bin/rapc.jar"
421
+ #args << "net.rim.tools.compiler.Compiler"
422
+
423
+ args << "-javacompiler=" + javabin + "/javac.exe"
424
+ args << "-quiet" if quiet
425
+ args << "-nowarn" if nowarn
426
+ args << 'import=' + imports
427
+ args << 'codename=' + output
428
+ args << 'library=' + output if library
429
+ args << output + '.rapc'
430
+ args << files
431
+
432
+ cmd.gsub!(/\//,"\\")
433
+ outputstring = run(cmd, args)
434
+ puts outputstring unless $? == 0
435
+ Dir.chdir currentdir
436
+
437
+ end
438
+
439
+ def self.ant(dir,target)
440
+
441
+ srcdir = $config["build"]["srcdir"]
442
+ rubypath = $config["build"]["rubypath"]
443
+ excludelib = $config["build"]["excludelib"]
444
+ excludeapps = $config["build"]["excludeapps"]
445
+ compileERB = $config["build"]["compileERB"]
446
+
447
+
448
+ args = []
449
+ args << "-buildfile"
450
+ args << dir + "/build.xml"
451
+ args << '-Dsrc.dir=' + get_absolute(srcdir)
452
+ # args << '-Druby.path=' + get_absolute(rubypath)
453
+ args << '-Dexclude.lib=' + excludelib
454
+ args << '-Dexclude.apps=' + excludeapps
455
+ args << '-DcompileERB.path=' + get_absolute(compileERB)
456
+ args << '-Dsrclib.dir=' + get_absolute(srcdir)
457
+
458
+
459
+ args << target
460
+ #puts args.to_s
461
+ puts run("ant.bat",args,dir)
462
+ end
463
+
464
+ def self.modify_file_if_content_changed(file_name, f)
465
+ f.rewind
466
+ content = f.read()
467
+ old_content = File.exists?(file_name) ? File.read(file_name) : ""
468
+
469
+ if old_content != content
470
+ puts "Modify #{file_name}"
471
+ File.open(file_name, "w"){|file| file.write(content)}
472
+ end
473
+
474
+ f.close
475
+ end
476
+
477
+ end
478
+