rhodes 2.0.0.beta7 → 2.0.0.beta8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. data/CHANGELOG +20 -1
  2. data/bin/rhodes-setup +6 -2
  3. data/lib/extensions/digest/ext/Rakefile +2 -2
  4. data/lib/framework/rho/render.rb +2 -0
  5. data/lib/framework/rho/rho.rb +159 -95
  6. data/lib/framework/rho/rhoapplication.rb +24 -5
  7. data/lib/framework/rhodes.rb +1 -1
  8. data/lib/framework/rhom/rhom_model.rb +32 -23
  9. data/lib/framework/rhom/rhom_object_factory.rb +2 -2
  10. data/lib/rhodes.rb +1 -1
  11. data/platform/android/Rhodes/jni/src/callbacks.cpp +8 -1
  12. data/platform/android/Rhodes/jni/src/mapview.cpp +4 -1
  13. data/platform/android/Rhodes/jni/src/sslimpl.cpp +5 -1
  14. data/platform/android/Rhodes/jni/src/webview.cpp +3 -1
  15. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeBar.java +3 -2
  16. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NativeLibraries.java +2 -2
  17. data/platform/android/Rhodes/src/com/rhomobile/rhodes/NavBar.java +1 -2
  18. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +1 -1
  19. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocation.java +3 -1
  20. data/platform/android/Rhodes/src/com/rhomobile/rhodes/geolocation/GeoLocationImpl.java +0 -1
  21. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +4 -1
  22. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +24 -6
  23. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +7 -2
  24. data/platform/android/build/android.rake +11 -38
  25. data/platform/android/build/androidcommon.rb +50 -2
  26. data/platform/android/build/librhocommon_build.files +1 -0
  27. data/platform/android/build/libsqlite_build.files +1 -0
  28. data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +2 -1
  29. data/platform/bb/rhodes/src/com/rho/BrowserAdapter.java +1 -5
  30. data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +3 -6
  31. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +4 -2
  32. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +12 -35
  33. data/platform/bb/rhodes/src/rhomobile/Utilities.java +2 -1
  34. data/platform/iphone/Classes/DateTimePickerDelegate.m +4 -4
  35. data/platform/iphone/Classes/NativeBar.m +12 -6
  36. data/platform/iphone/Classes/NavBar.m +1 -1
  37. data/platform/iphone/Classes/RhoMainView.h +4 -1
  38. data/platform/iphone/Classes/Rhodes.h +6 -2
  39. data/platform/iphone/Classes/Rhodes.m +23 -3
  40. data/platform/iphone/Classes/SimpleMainView.h +3 -7
  41. data/platform/iphone/Classes/SimpleMainView.m +108 -54
  42. data/platform/iphone/Classes/TabbedMainView.h +3 -2
  43. data/platform/iphone/Classes/TabbedMainView.m +21 -10
  44. data/platform/iphone/RhoLib/RhoLib.xcodeproj/project.pbxproj +8 -0
  45. data/platform/shared/common/IRhoClassFactory.h +1 -0
  46. data/platform/shared/common/RhodesApp.cpp +7 -2
  47. data/platform/shared/common/ThreadQueue.cpp +110 -0
  48. data/platform/shared/common/ThreadQueue.h +75 -0
  49. data/platform/shared/logging/RhoLogCat.h +4 -0
  50. data/platform/shared/net/AsyncHttp.cpp +134 -135
  51. data/platform/shared/net/AsyncHttp.h +74 -33
  52. data/platform/shared/net/HttpServer.cpp +7 -1
  53. data/platform/shared/ruby/thread.c +4 -0
  54. data/platform/shared/ruby/thread_win32.c +9 -8
  55. data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +26 -5
  56. data/platform/shared/rubyJVM/src/com/rho/net/INetworkAccess.java +0 -2
  57. data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +4 -13
  58. data/platform/shared/rubyJVM/src/com/rho/net/URI.java +2 -2
  59. data/platform/shared/rubyJVM/src/com/rho/sync/SyncEngine.java +3 -3
  60. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/ObjectFactory.java +12 -2
  61. data/platform/shared/rubyJVM/src/com/xruby/runtime/builtin/RubyString.java +6 -3
  62. data/platform/shared/rubyJVM/src/javolution/util/FastTable.java +12 -2
  63. data/platform/shared/sync/SyncEngine.cpp +15 -3
  64. data/platform/shared/sync/SyncEngine.h +1 -1
  65. data/platform/shared/sync/SyncThread.cpp +18 -101
  66. data/platform/shared/sync/SyncThread.h +30 -22
  67. data/platform/wm/RhoLib/RhoLib.vcproj +8 -0
  68. data/platform/wm/rhodes/Rhodes.cpp +143 -1
  69. data/platform/wm/rhodes/memory_helper.cpp +273 -0
  70. data/platform/wm/rhodes/rho/common/RhoThreadImpl.cpp +1 -0
  71. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +46 -3
  72. data/platform/wm/rhodes/rho/rubyext/WebView.cpp +29 -1
  73. data/res/build-tools/db/syncdb.schema +1 -0
  74. data/res/generators/rhogen.rb +1 -1
  75. data/rhodes.gemspec +2 -2
  76. metadata +23 -6
  77. data/Manifest.txt +0 -5289
  78. data/rhobuild.yml +0 -37
data/CHANGELOG CHANGED
@@ -1,9 +1,28 @@
1
1
  == 2.0.0
2
2
  * client support of sync protocol 3 with rhosync 2.0
3
3
  * partial support
4
- * callback calls from menu ad toolbar
4
+ * callback calls from menu and toolbar
5
5
  * installing.html(png for android)
6
6
  * implement extended Alerts
7
+ * support of :center and :radius parameters for MapView
8
+ * new WebView.set_cookie method
9
+ * added native navigation bar for iPhone and Android
10
+ * full support of native extensions on Android (including Java)
11
+ * new properties added for System.get_property: country, locale, device_name,
12
+ os_version, ppi_x, ppi_y
13
+ * AsyncHttp now send requests with User-Agent indicating mobile platform, OS
14
+ and device name
15
+ * 'sms:' uri supported for Android
16
+ * implemented dynamic menu on Android
17
+ * right handle video uri (open native video player) on Android
18
+ * support of capabilities for applications (gps, camera, vibrate etc)
19
+ * native toolbar for Android
20
+ * fix GPS on application start issue (iPhone and Android)
21
+ * AsyncHttp support basic authentication
22
+ * fixed wrong url escaping on iPhone
23
+ * suport of parallel build for Android (on multi-core cpus)
24
+ * NativeBar.create now re-use WebView so no more need to call WebView.navigate
25
+ after NativeBar.create
7
26
 
8
27
  == 1.5.4
9
28
  * Fix issue #3132788 - rake clean:iphone fails
data/bin/rhodes-setup CHANGED
@@ -76,9 +76,13 @@ Dir.glob(File.join(android, 'platforms', '*')).each do |dir|
76
76
  end
77
77
  android = "" if apilevel == -1
78
78
 
79
- android = prompt_for("Android 1.5 SDK path", android, false, android_platform_dir)
79
+ android = prompt_for("Android SDK path", android, false, android_platform_dir)
80
80
 
81
- androidndk = prompt_for("Android NDK path", "",false)
81
+ # try to detect android ndk
82
+ ndks = Dir.glob(File.dirname(android) + "/android-ndk-*").sort
83
+ ndk = ""
84
+ ndk = ndks.last if ndks.size > 0
85
+ androidndk = prompt_for("Android NDK path", ndk, false)
82
86
 
83
87
  #now cabwiz
84
88
  cabwiz = ""
@@ -72,8 +72,8 @@ namespace "build" do
72
72
  raise "TARGET_TEMP_DIR is not set" if $targetdir.nil?
73
73
  $tempdir = ENV['TEMP_FILES_DIR']
74
74
  raise "TEMP_FILES_DIR is not set" if $tempdir.nil?
75
- $rootdir = ENV['RHODES_ROOT_DIR']
76
- raise "RHODES_ROOT_DIR is not set" if $rootdir.nil?
75
+ $rootdir = ENV['RHO_ROOT']
76
+ raise "RHO_ROOT is not set" if $rootdir.nil?
77
77
 
78
78
  if ENV['RHO_PLATFORM'] == 'android'
79
79
  require File.join($rootdir, 'platform/android/build/androidcommon.rb')
@@ -157,6 +157,8 @@ module Rho
157
157
  options = options.symbolize_keys
158
158
 
159
159
  localclass = Class.new do
160
+ require 'helpers/application_helper'
161
+ include ApplicationHelper
160
162
  def initialize(obj=nil)
161
163
  @vars = {}
162
164
  if obj
@@ -157,46 +157,52 @@ module Rho
157
157
  def load_server_sources(data)
158
158
  puts "load_server_sources : #{data}"
159
159
 
160
- res = Rho::JSON.parse(data)
161
- if res['partition']
162
- str_partition = res['partition']
163
- puts "reload sources for partition: #{str_partition}"
164
- db = @db_partitions[ str_partition ]
165
-
166
- puts "sources before: #{Rho::RhoConfig::sources()}"
167
-
168
- Rho::RhoConfig::sources().delete_if {|key, value| value['partition']==str_partition }
169
- arSrcs = db.select_from_table('sources','source_id, name, sync_priority, partition, sync_type, schema, schema_version, associations, blob_attribs',
170
- {'partition'=>str_partition} )
171
- arSrcs.each do |src|
172
- Rho::RhoConfig::sources()[ src['name'] ] = src
160
+ begin
161
+ res = Rho::JSON.parse(data)
162
+ if res['partition']
163
+ str_partition = res['partition']
164
+ puts "reload sources for partition: #{str_partition}"
165
+ db = @db_partitions[ str_partition ]
166
+
167
+ puts "sources before: #{Rho::RhoConfig::sources()}"
168
+
169
+ Rho::RhoConfig::sources().delete_if {|key, value| value['partition']==str_partition }
170
+ arSrcs = db.select_from_table('sources','source_id, name, sync_priority, partition, sync_type, schema, schema_version, associations, blob_attribs',
171
+ {'partition'=>str_partition} )
172
+ arSrcs.each do |src|
173
+ Rho::RhoConfig::sources()[ src['name'] ] = src
174
+ end
175
+
176
+ puts "sources after: #{Rho::RhoConfig::sources()}"
177
+ return
173
178
  end
174
179
 
175
- puts "sources after: #{Rho::RhoConfig::sources()}"
176
- return
177
- end
178
-
179
- arSrc = res['server_sources']
180
- puts "arSrc: #{arSrc}"
181
- return unless arSrc
182
-
183
- hashSrcs = Rhom::RhomSource::find_all_ashash
184
- puts "hashSrcs : #{hashSrcs}"
185
- arSrc.each do |src|
186
- oldSrc = hashSrcs[src['name']]
187
- puts "oldSrc: #{oldSrc}"
188
- if oldSrc
189
- oldVer = oldSrc.schema_version
190
- newVer = src['schema_version']
191
- if ( oldVer != newVer )
192
- get_app(APPNAME).on_migrate_source(oldSrc.schema_version, src)
180
+ arSrc = res['sources']
181
+ puts "arSrc: #{arSrc}"
182
+ return unless arSrc
183
+
184
+ hashSrcs = Rhom::RhomSource::find_all_ashash
185
+ puts "hashSrcs : #{hashSrcs}"
186
+ arSrc.each do |src|
187
+ oldSrc = hashSrcs[src['name']]
188
+ puts "oldSrc: #{oldSrc}"
189
+ if oldSrc
190
+ oldVer = oldSrc.schema_version
191
+ newVer = src['schema_version']
192
+ if ( oldVer != newVer )
193
+ get_app(APPNAME).on_migrate_source(oldSrc.schema_version, src)
194
+ end
193
195
  end
196
+
197
+ Rho::RhoConfig::add_source(src['name'], src)
194
198
  end
195
199
 
196
- Rho::RhoConfig::add_source(src['name'], src)
197
- end
198
-
199
- init_sources()
200
+ init_sources()
201
+ rescue Exception => e
202
+ puts "Error load_server_sources: #{e}"
203
+ puts "Trace: #{e.backtrace}"
204
+ end
205
+
200
206
  end
201
207
 
202
208
  def find_src_byname(uniq_sources, src_name)
@@ -215,15 +221,19 @@ module Rho
215
221
  uniq_sources = Rho::RhoConfig::sources.values
216
222
  puts 'init_sources: ' + uniq_sources.inspect
217
223
 
224
+ uniq_sources.each do |source|
225
+ source['str_associations'] = ""
226
+ end
227
+
218
228
  uniq_sources.each do |source|
219
229
  partition = source['partition']
220
230
  @db_partitions[partition] = nil
221
231
 
222
- if source['associations']
223
- source['associations'].each do |src_name, attrib|
232
+ if source['belongs_to']
233
+ source['belongs_to'].each do |attrib, src_name|
224
234
  associationsSrc = find_src_byname(uniq_sources, src_name)
225
235
  if !associationsSrc
226
- puts ( "Error: associations from '#{source['name']}' : source name '#{src_name}' does not exist." )
236
+ puts ( "Error: belongs_to '#{source['name']}' : source name '#{src_name}' does not exist." )
227
237
  next
228
238
  end
229
239
 
@@ -239,12 +249,12 @@ module Rho
239
249
 
240
250
  #user partition should alwayse exist
241
251
  @db_partitions['user'] = nil
242
-
252
+ hash_migrate = {}
243
253
  @db_partitions.each_key do |partition|
244
254
  db = Rhom::RhomDbAdapter.new(Rho::RhoFSConnector::get_db_fullpathname(partition), partition)
245
255
  db.start_transaction
246
256
  begin
247
- init_db_sources(db, uniq_sources, partition)
257
+ init_db_sources(db, uniq_sources, partition,hash_migrate)
248
258
  db.commit
249
259
  rescue Exception => e
250
260
  puts "exception when init_db_sources: #{e}"
@@ -254,69 +264,83 @@ module Rho
254
264
  @db_partitions[partition] = db
255
265
  end
256
266
 
257
- ::Rho::RHO.init_schema_sources
267
+ ::Rho::RHO.init_schema_sources(hash_migrate)
258
268
  end
259
269
 
260
- def self.processIndexes(index_param, src_name, is_unique)
270
+ def self.processIndexes(index_ar, src_name, is_unique)
261
271
 
262
- return "" unless index_param
272
+ return "" unless index_ar
263
273
 
264
274
  strUnique = 'UNIQUE' if is_unique
265
275
  strRes = ""
266
- if index_param.is_a?( String )
267
- strRes = index_param
268
- else
269
- nInd = 0
270
- index_param.each do |index_cols|
271
- strCols = ""
272
- index_cols.each do |col|
273
- strCols += ',' if strCols.length() > 0
274
- strCols += "\"#{col}\""
276
+ index_ar.each do |index_param|
277
+
278
+ if index_param.is_a?( String )
279
+ strRes = index_param
280
+ else
281
+ nInd = 0
282
+
283
+ index_param.each do |index_name, index_cols|
284
+ strCols = ""
285
+ index_cols.each do |col|
286
+ strCols += ',' if strCols.length() > 0
287
+ strCols += "\"#{col}\""
288
+ end
289
+
290
+ #strIndName = "rhoIndex" + (is_unique ? "U" : "" ) + "_#{nInd}"
291
+ strIndex = "CREATE #{strUnique} INDEX \"#{index_name}\" on #{src_name} (#{strCols});\r\n"
292
+ strRes += strIndex
293
+ nInd += 1
275
294
  end
276
-
277
- strIndName = "rhoIndex" + (is_unique ? "U" : "" ) + "_#{nInd}"
278
- strIndex = "CREATE #{strUnique} INDEX \"#{strIndName}\" on #{src_name} (#{strCols});\r\n"
279
- strRes += strIndex
280
- nInd += 1
281
295
  end
282
296
  end
283
-
284
297
  strRes
285
298
  end
286
299
 
287
- def self.init_schema_sources
300
+ def self.init_schema_sources(hash_migrate)
288
301
  uniq_sources = Rho::RhoConfig::sources.values
289
302
  puts 'init_schema_sources'
290
303
 
291
304
  uniq_sources.each do |source|
292
305
  db = get_src_db(source['name'])
293
306
 
294
- if source['schema'] && !db.table_exist?(source['name'])
307
+ next unless source['schema'] && source['model_type'] == 'fixed_schema'
295
308
 
296
- strCreate = source['schema']['sql']
297
- if source['schema']['columns']
298
- arCols = source['schema']['columns']
299
- arCols = arCols
300
- strCols = ""
301
- arCols.each do |col|
302
- strCols += ',' if strCols.length() > 0
303
- strCols += "\"#{col}\" varchar default NULL"
304
- end
305
-
306
- strCols += ",object varchar(255) PRIMARY KEY"
307
- strCreate = "CREATE TABLE #{source['name']} ( #{strCols} )"
309
+ call_migrate = false
310
+ if db.table_exist?(source['name'])
311
+ next unless hash_migrate[ source['name'] ]
312
+ call_migrate = true
313
+ end
314
+
315
+ strCreate = source['schema']['sql']
316
+ if source['schema']['property']
317
+ arCols = source['schema']['property']
318
+ arCols = arCols
319
+ strCols = ""
320
+ arCols.each do |col, type|
321
+ strCols += ',' if strCols.length() > 0
322
+ strCols += "\"#{col}\" varchar default NULL"
323
+ #TODO: support column type
308
324
  end
309
325
 
310
- strCreate += ";\r\n" if strCreate && strCreate.length() > 0
311
- strCreate += processIndexes(source['schema']['indexes'], source['name'], false)
312
- strCreate += ";\r\n" if strCreate && strCreate.length() > 0
313
- strCreate += processIndexes(source['schema']['unique_indexes'], source['name'], true)
314
-
315
- db.update_into_table('sources', {"schema"=>strCreate, "schema_version"=>source['schema_version']},{"name"=>source['name']})
316
-
326
+ strCols += ",object varchar(255) PRIMARY KEY"
327
+ strCreate = "CREATE TABLE #{source['name']} ( #{strCols} )"
328
+ end
329
+
330
+ strCreate += ";\r\n" if strCreate && strCreate.length() > 0
331
+ strCreate += processIndexes(source['schema']['index'], source['name'], false)
332
+ strCreate += ";\r\n" if strCreate && strCreate.length() > 0
333
+ strCreate += processIndexes(source['schema']['unique_index'], source['name'], true)
334
+
335
+ if call_migrate
336
+ db.update_into_table('sources', {"schema"=>strCreate},{"name"=>source['name']})
337
+ source['migrate_version'] = hash_migrate[ source['name'] ]
338
+ source['schema']['sql'] = strCreate
339
+ else
317
340
  db.execute_batch_sql(strCreate)
341
+ db.update_into_table('sources', {"schema"=>strCreate, "schema_version"=>source['schema_version']},{"name"=>source['name']})
318
342
  end
319
-
343
+
320
344
  end
321
345
  end
322
346
 
@@ -324,24 +348,27 @@ module Rho
324
348
  return source['str_blob_attribs'] if source['str_blob_attribs']
325
349
  source['str_blob_attribs'] = ""
326
350
 
327
- if source['blob_attribs']
351
+ if source['schema'] && source['schema']['property']
328
352
  str = ""
329
- source['blob_attribs'].each do |blobAttr|
330
- str += ',' if str.length()>0
331
- if blobAttr.is_a?(Hash)
332
- str += blobAttr['name'].to_s() + ',' + blobAttr['server_overwrite'].to_i()
333
- else
334
- str += blobAttr.to_s() + ',0'
353
+ source['schema']['property'].each do |name, type|
354
+ if type && type.is_a?(Hash)
355
+ next unless type[:blob] || type['blob']
356
+ str += ',' if str.length()>0
357
+ str += name.to_s() + ',' + (type[:server_overwrite]||type[:server_overwrite].to_i() ? '1' : '0')
358
+ elsif type && type.to_s == 'blob'
359
+ str += ',' if str.length()>0
360
+ str += name.to_s() + ',0'
335
361
  end
336
362
  end
337
363
 
338
364
  source['str_blob_attribs'] = str
339
365
  end
340
-
366
+
341
367
  source['str_blob_attribs']
368
+
342
369
  end
343
370
 
344
- def init_db_sources(db, uniq_sources, db_partition)
371
+ def init_db_sources(db, uniq_sources, db_partition, hash_migrate)
345
372
 
346
373
  result = db.execute_sql("SELECT MAX(source_id) AS maxid FROM sources")
347
374
  #puts 'result: ' + result.inspect
@@ -355,10 +382,11 @@ module Rho
355
382
  partition = source['partition']
356
383
  sync_type = source['sync_type']
357
384
  schema_version = source['schema_version']
385
+ model_type = source['model_type']
358
386
  associations = source['str_associations']
359
387
  blob_attribs = process_blob_attribs(source, db)
360
388
 
361
- attribs = db.select_from_table('sources','sync_priority,source_id,partition, sync_type, schema_version, associations, blob_attribs', {'name'=>name})
389
+ attribs = db.select_from_table('sources','sync_priority,source_id,partition, sync_type, schema_version, associations, blob_attribs, model_type', {'name'=>name})
362
390
 
363
391
  if attribs && attribs.size > 0
364
392
  if attribs[0]['sync_priority'].to_i != sync_priority.to_i
@@ -368,7 +396,11 @@ module Rho
368
396
  db.update_into_table('sources', {"sync_type"=>sync_type},{"name"=>name})
369
397
  end
370
398
  if attribs[0]['schema_version'] != schema_version
371
- db.update_into_table('sources', {"schema_version"=>schema_version},{"name"=>name})
399
+ if db_partition == partition
400
+ hash_migrate[name] = attribs[0]['schema_version']
401
+ else
402
+ db.update_into_table('sources', {"schema_version"=>schema_version},{"name"=>name})
403
+ end
372
404
  end
373
405
  if attribs[0]['partition'] != partition
374
406
  db.update_into_table('sources', {"partition"=>partition},{"name"=>name})
@@ -380,6 +412,10 @@ module Rho
380
412
  db.update_into_table('sources', {"blob_attribs"=>blob_attribs},{"name"=>name})
381
413
  end
382
414
 
415
+ if attribs[0]['model_type'] != model_type
416
+ db.update_into_table('sources', {"model_type"=>model_type},{"name"=>name})
417
+ end
418
+
383
419
  if !source['source_id']
384
420
  source['source_id'] = attribs[0]['source_id'].to_i
385
421
  Rho::RhoConfig::sources[name]['source_id'] = attribs[0]['source_id'].to_i
@@ -395,7 +431,8 @@ module Rho
395
431
 
396
432
  db.insert_into_table('sources',
397
433
  {"source_id"=>source['source_id'],"name"=>name, "sync_priority"=>sync_priority, "sync_type"=>sync_type, "partition"=>partition,
398
- "schema_version"=>source['schema_version'], 'associations'=>associations, 'blob_attribs'=>blob_attribs })
434
+ "schema_version"=>source['schema_version'], 'associations'=>associations, 'blob_attribs'=>blob_attribs,
435
+ "model_type"=>model_type })
399
436
 
400
437
  end
401
438
 
@@ -633,17 +670,28 @@ module Rho
633
670
  def add_source(modelname, new_source=nil)
634
671
  return if !modelname || modelname.length() == 0# || @@sources[modelname]
635
672
 
673
+ puts "#{modelname} : #{new_source}"
636
674
  @@sources[modelname] = new_source ? new_source.clone() : {}
637
675
  @@sources[modelname]['name'] ||= modelname
638
- @@sources[modelname]['sync_priority'] ||= 1000
676
+
677
+ if @@sources[modelname]['sync_priority']
678
+ @@sources[modelname]['sync_priority'] = @@sources[modelname]['sync_priority'].to_i()
679
+ else
680
+ @@sources[modelname]['sync_priority'] = 1000
681
+ end
682
+
639
683
  if @@sources[modelname]['partition']
640
684
  @@sources[modelname]['partition'] = @@sources[modelname]['partition'].to_s
641
685
  else
642
686
  @@sources[modelname]['partition'] ||= 'user'
643
687
  end
644
688
 
645
- @@sources[modelname]['sync_type'] = 'none' if !@@sources[modelname]['sync']
646
- @@sources[modelname]['sync_type'] ||= 'incremental'
689
+ #@@sources[modelname]['sync_type'] = 'none' if !@@sources[modelname]['sync']
690
+ @@sources[modelname]['sync_type'] ||= 'none'
691
+
692
+ if @@sources[modelname]['source_id']
693
+ @@sources[modelname]['source_id'] = @@sources[modelname]['source_id'].to_i()
694
+ end
647
695
 
648
696
  @@max_config_srcid = @@sources[modelname]['source_id'] if @@sources[modelname]['source_id'] && @@max_config_srcid < @@sources[modelname]['source_id']
649
697
  end
@@ -666,6 +714,19 @@ module Rho
666
714
  ret ? 1 : 0
667
715
  end
668
716
 
717
+ def self.make_auth_header(args)
718
+ auth = args[:authorization]
719
+ return nil unless auth.is_a? Hash
720
+ return nil if auth[:type].nil?
721
+
722
+ raise "Authorization type #{auth[:type].inspect.to_s} is unsupported" if auth[:type].to_s != 'basic'
723
+ raise "Username or password should be specified for 'basic' authorization" if auth[:username].nil? or auth[:password].nil?
724
+
725
+ plain = 'Basic ' + [auth[:username].to_s + ':' + auth[:password].to_s].pack('m')
726
+ # Remove trailing \n
727
+ plain[0..-2]
728
+ end
729
+
669
730
  def self.headers(args)
670
731
  hdrs = args[:headers]
671
732
  hdrs = {} if hdrs.nil?
@@ -677,6 +738,9 @@ module Rho
677
738
  hdrs['User-Agent'] = "Mozilla-5.0 (#{platform}; #{device}; #{version})"
678
739
  end
679
740
 
741
+ auth = make_auth_header(args)
742
+ hdrs['Authorization'] = auth unless auth.nil?
743
+
680
744
  hdrs
681
745
  end
682
746