rhodes 1.5.4 → 1.5.5

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 (60) hide show
  1. data/Manifest.txt +11 -1
  2. data/Rakefile +1 -1
  3. data/lib/extensions/digest/ext/Rakefile +11 -6
  4. data/lib/extensions/digest/ext/build.bat +2 -0
  5. data/lib/extensions/uri/uri.rb +29 -0
  6. data/lib/extensions/uri/uri/common.rb +727 -0
  7. data/lib/extensions/uri/uri/ftp.rb +198 -0
  8. data/lib/extensions/uri/uri/generic.rb +1128 -0
  9. data/lib/extensions/uri/uri/http.rb +100 -0
  10. data/lib/extensions/uri/uri/https.rb +20 -0
  11. data/lib/extensions/uri/uri/ldap.rb +190 -0
  12. data/lib/extensions/uri/uri/ldaps.rb +12 -0
  13. data/lib/extensions/uri/uri/mailto.rb +266 -0
  14. data/lib/framework/rhodes.rb +2 -2
  15. data/lib/framework/rhom/rhom_db_adapter.rb +12 -26
  16. data/lib/framework/rhom/rhom_object_factory.rb +8 -1
  17. data/lib/framework/version.rb +2 -2
  18. data/lib/rhodes.rb +2 -2
  19. data/platform/android/Rhodes/AndroidManifest.xml +2 -2
  20. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +87 -42
  21. data/platform/android/Rhodes/src/com/rhomobile/rhodes/SplashScreen.java +58 -7
  22. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/MainView.java +2 -0
  23. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +35 -19
  24. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +4 -0
  25. data/platform/android/build/android.rake +30 -25
  26. data/platform/bb/build/rhodes_build.files +1 -1
  27. data/platform/bb/rhodes/rhodes.jdp +1 -1
  28. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +1 -1
  29. data/platform/bb/rhodes/src/com/rho/rubyext/Alert.java +300 -0
  30. data/platform/bb/rhodes/src/com/rho/rubyext/GeoLocation.java +42 -5
  31. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +3 -4
  32. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +33 -107
  33. data/platform/iphone/Classes/RhoRunnerAppDelegate.m +2 -0
  34. data/platform/iphone/Info.plist +1 -1
  35. data/platform/iphone/rbuild/iphone.rake +1 -1
  36. data/platform/iphone/rhoextlib/rhoextlib.xcodeproj/project.pbxproj +4 -0
  37. data/platform/shared/common/RhoMutexLock.h +8 -1
  38. data/platform/shared/common/RhodesApp.cpp +1 -1
  39. data/platform/shared/db/DBAdapter.cpp +77 -8
  40. data/platform/shared/db/DBAdapter.h +24 -9
  41. data/platform/shared/db/DBResult.cpp +19 -0
  42. data/platform/shared/db/DBResult.h +7 -5
  43. data/platform/shared/net/HttpServer.cpp +2 -0
  44. data/platform/shared/ruby/ext/rho/rhoruby.c +55 -0
  45. data/platform/shared/ruby/ext/rho/rhoruby.h +9 -0
  46. data/platform/shared/ruby/ext/rho/rhosupport.c +13 -4
  47. data/platform/shared/ruby/ext/sqlite3_api/sqlite3_api_wrap.c +21 -0
  48. data/platform/shared/ruby/thread_pthread.c +4 -4
  49. data/platform/shared/ruby/thread_win32.c +4 -4
  50. data/platform/shared/rubyJVM/src/com/rho/RhodesApp.java +19 -1
  51. data/platform/shared/rubyJVM/src/com/rho/db/DBAdapter.java +57 -24
  52. data/platform/shared/rubyJVM/src/com/rho/net/NetRequest.java +6 -1
  53. data/platform/shared/rubyJVM/src/com/rho/sync/SyncSource.java +2 -2
  54. data/platform/shared/rubyJVM/src/com/rho/sync/SyncThread.java +5 -5
  55. data/platform/shared/sync/SyncSource.cpp +1 -1
  56. data/platform/shared/sync/SyncThread.cpp +6 -9
  57. data/platform/wm/rhodes/Rhodes.cpp +4 -0
  58. data/rakefile.rb +1 -1
  59. metadata +13 -3
  60. data/platform/bb/rhodes/src/rhomobile/Alert.java +0 -65
@@ -1,9 +1,9 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '1.5.4'
3
+ VERSION = '1.5.5'
4
4
  end
5
5
  unless defined? Rhodes::DBVERSION
6
- DBVERSION = '1.5.4'
6
+ DBVERSION = '1.5.5'
7
7
  end
8
8
 
9
9
  end
@@ -23,7 +23,6 @@ module Rhom
23
23
  class RhomDbAdapter
24
24
 
25
25
  @@database = nil
26
- @@inside_transaction = false
27
26
 
28
27
  class << self
29
28
 
@@ -44,10 +43,13 @@ module Rhom
44
43
  end
45
44
  return true
46
45
  end
47
-
46
+
47
+ def is_ui_waitfordb
48
+ @@database.is_ui_waitfordb
49
+ end
50
+
48
51
  def start_transaction
49
52
  begin
50
- @@inside_transaction = true
51
53
  @@database.start_transaction
52
54
  rescue Exception => e
53
55
  puts "exception when start_transaction"
@@ -56,7 +58,6 @@ module Rhom
56
58
 
57
59
  def commit
58
60
  begin
59
- @@inside_transaction = false
60
61
  @@database.commit
61
62
  rescue Exception => e
62
63
  puts "exception when commit transaction"
@@ -65,7 +66,6 @@ module Rhom
65
66
 
66
67
  def rollback
67
68
  begin
68
- @@inside_transaction = false
69
69
  @@database.rollback
70
70
  rescue Exception => e
71
71
  puts "exception when rollback transaction"
@@ -82,19 +82,12 @@ module Rhom
82
82
  # Make sure we lock the sync engine's mutex
83
83
  # before we perform a database transaction.
84
84
  # This prevents concurrency issues.
85
- begin
86
- SyncEngine.lock_sync_mutex unless @@inside_transaction
87
- result = @@database.execute( sql, args )
88
- SyncEngine.unlock_sync_mutex unless @@inside_transaction
89
- rescue Exception => e
90
- #puts "exception when running query: #{e}"
91
- # make sure we unlock even if there's an error!
92
- if @@inside_transaction
93
- raise
94
- else
95
- SyncEngine.unlock_sync_mutex
96
- end
97
- end
85
+ begin
86
+ result = @@database.execute( sql, args )
87
+ rescue Exception => e
88
+ #puts "exception when running query: #{e}"
89
+ #raise
90
+ end
98
91
  end
99
92
  #puts "result is: #{result.inspect}"
100
93
  result
@@ -231,14 +224,7 @@ module Rhom
231
224
 
232
225
  # deletes all rows from a given table by recreating db-file and save all other tables
233
226
  def destroy_table(table)
234
- begin
235
- SyncEngine.lock_sync_mutex unless @@inside_transaction
236
- @@database.destroy_table table
237
- SyncEngine.unlock_sync_mutex unless @@inside_transaction
238
- rescue Exception => e
239
- SyncEngine.unlock_sync_mutex
240
- raise
241
- end
227
+ @@database.destroy_table table
242
228
  end
243
229
 
244
230
  # updates values (hash) in a given table which satisfy condition (hash)
@@ -116,7 +116,14 @@ module Rhom
116
116
 
117
117
  sql << "attrib=" + ::Rhom::RhomDbAdapter.get_value_for_sql_stmt(attrib_name)
118
118
  sql << " AND source_id=" + srcid_value
119
- sql << " AND " + (val_func.length > 0 ? val_func + "(value)" : "value") + ' ' + val_op + ' ' + ::Rhom::RhomDbAdapter.get_value_for_sql_stmt(value)
119
+ sql << " AND " + (val_func.length > 0 ? val_func + "(value)" : "value") + ' '
120
+
121
+ if val_op == 'IN' or val_op == 'in'
122
+ svalue = ::Rhom::RhomDbAdapter.get_value_for_sql_stmt(value)
123
+ sql << val_op + ' ( ' + svalue[1,svalue.length()-2] + ' )'
124
+ else
125
+ sql << val_op + ' ' + ::Rhom::RhomDbAdapter.get_value_for_sql_stmt(value)
126
+ end
120
127
 
121
128
  sql
122
129
  end
@@ -1,8 +1,8 @@
1
1
  module RhodesFramework
2
2
  unless defined? RhodesFramework::VERSION
3
- VERSION = '1.5.4'
3
+ VERSION = '1.5.5'
4
4
  end
5
5
  unless defined? RhodesFramework::DBVERSION
6
- DBVERSION = '1.5.4'
6
+ DBVERSION = '1.5.5'
7
7
  end
8
8
  end
@@ -1,9 +1,9 @@
1
1
  module Rhodes
2
2
  unless defined? Rhodes::VERSION
3
- VERSION = '1.5.4'
3
+ VERSION = '1.5.5'
4
4
  end
5
5
  unless defined? Rhodes::DBVERSION
6
- DBVERSION = '1.5.4'
6
+ DBVERSION = '1.5.5'
7
7
  end
8
8
 
9
9
  end
@@ -1,8 +1,8 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
3
  package="com.rhomobile.rhodes"
4
- android:versionCode="23"
5
- android:versionName="1.5.4">
4
+ android:versionCode="24"
5
+ android:versionName="1.5.5">
6
6
  <uses-sdk android:minSdkVersion="3" />
7
7
  <application android:icon="@drawable/icon"
8
8
  android:multiprocess="true"
@@ -42,6 +42,7 @@ import android.content.Context;
42
42
  import android.content.DialogInterface;
43
43
  import android.content.pm.ActivityInfo;
44
44
  import android.content.res.Configuration;
45
+ import android.graphics.Bitmap;
45
46
  import android.net.ConnectivityManager;
46
47
  import android.net.NetworkInfo;
47
48
  import android.net.Uri;
@@ -59,6 +60,7 @@ import android.view.View;
59
60
  import android.view.Window;
60
61
  import android.view.WindowManager;
61
62
  import android.view.ViewGroup.LayoutParams;
63
+ import android.webkit.WebChromeClient;
62
64
  import android.webkit.WebSettings;
63
65
  import android.webkit.WebView;
64
66
  import android.webkit.WebViewClient;
@@ -78,6 +80,8 @@ public class Rhodes extends Activity {
78
80
  public static int WINDOW_FLAGS = WindowManager.LayoutParams.FLAG_FULLSCREEN;
79
81
  public static int WINDOW_MASK = WindowManager.LayoutParams.FLAG_FULLSCREEN;
80
82
 
83
+ private static int MAX_PROGRESS = 10000;
84
+
81
85
  private long uiThreadId;
82
86
  public long getUiThreadId() {
83
87
  return uiThreadId;
@@ -96,7 +100,8 @@ public class Rhodes extends Activity {
96
100
  private SplashScreen splashScreen = null;
97
101
 
98
102
  private Hashtable<String, UriHandler> uriHandlers = new Hashtable<String, UriHandler>();
99
-
103
+ private Boolean contentChanged = null;
104
+
100
105
  private String sdCardError = "Application can not access the SD card while it's mounted. Please unmount the device and stop the adb server before launching the app.";
101
106
 
102
107
  private String rootPath = null;
@@ -183,38 +188,53 @@ public class Rhodes extends Activity {
183
188
  */
184
189
  }
185
190
 
186
- private void copyFilesFromBundle() {
191
+ public boolean isNameChanged() {
187
192
  try {
188
- //String phRootPath = phoneMemoryRootPath();
189
- String sdRootPath = sdcardRootPath();
190
-
191
- boolean nameChanged = false;
192
- boolean contentChanged = true;
193
-
194
193
  FileSource as = new AssetsSource(getResources().getAssets());
195
194
  FileSource fs = new FileSource();
196
-
197
- nameChanged = !Utils.isContentsEquals(as, "name", fs, new File(sdRootPath, "name").getPath());
198
- if (nameChanged)
199
- contentChanged = true;
200
- else
201
- contentChanged = !Utils.isContentsEquals(as, "hash", fs, new File(sdRootPath, "hash").getPath());
202
-
203
- if (contentChanged) {
204
- Logger.D(TAG, "Copying required files from bundle to sdcard");
195
+ return !Utils.isContentsEquals(as, "name", fs, new File(getRootPath(), "name").getPath());
196
+ }
197
+ catch (IOException e) {
198
+ return true;
199
+ }
200
+ }
201
+
202
+ public boolean isBundleChanged() {
203
+ if (contentChanged == null) {
204
+ try {
205
+ String rp = getRootPath();
206
+
207
+ FileSource as = new AssetsSource(getResources().getAssets());
208
+ FileSource fs = new FileSource();
209
+
210
+ if (isNameChanged())
211
+ contentChanged = new Boolean(true);
212
+ else
213
+ contentChanged = new Boolean(!Utils.isContentsEquals(as, "hash", fs, new File(rp, "hash").getPath()));
214
+ }
215
+ catch (IOException e) {
216
+ contentChanged = new Boolean(true);
217
+ }
218
+ }
219
+ return contentChanged.booleanValue();
220
+ }
221
+
222
+ private void copyFilesFromBundle() {
223
+ try {
224
+ if (isBundleChanged()) {
225
+ Logger.D(TAG, "Copying required files from bundle");
226
+
227
+ boolean nameChanged = isNameChanged();
205
228
 
206
- /*
207
- File phrf = new File(phRootPath);
208
- if (!phrf.exists())
209
- phrf.mkdirs();
210
- phrf = null;
211
- */
229
+ String rp = getRootPath();
230
+
231
+ FileSource as = new AssetsSource(getResources().getAssets());
212
232
 
213
233
  String items[] = {"apps", "lib", "db", "hash", "name"};
214
234
  for (int i = 0; i != items.length; ++i) {
215
235
  String item = items[i];
216
236
  //File phf = new File(phRootPath, item);
217
- File sdf = new File(sdRootPath, item);
237
+ File sdf = new File(rp, item);
218
238
  Logger.D(TAG, "Copy '" + item + "' to '" + sdf + "'");
219
239
  Utils.copyRecursively(as, item, sdf, nameChanged);
220
240
  /*
@@ -230,6 +250,7 @@ public class Rhodes extends Activity {
230
250
  dbfiles.mkdirs();
231
251
  dbfiles = null;
232
252
 
253
+ contentChanged = new Boolean(true);
233
254
  Logger.D(TAG, "All files copied");
234
255
  }
235
256
  else
@@ -253,13 +274,6 @@ public class Rhodes extends Activity {
253
274
  public WebView createWebView() {
254
275
  WebView w = new WebView(this);
255
276
 
256
- try {
257
- w.loadUrl("file:///android_asset/apps/app/loading.html");
258
- }
259
- catch (Exception e) {
260
- // Ignore
261
- }
262
-
263
277
  WebSettings webSettings = w.getSettings();
264
278
  webSettings.setSavePassword(false);
265
279
  webSettings.setSaveFormData(false);
@@ -274,19 +288,44 @@ public class Rhodes extends Activity {
274
288
  w.setHorizontalScrollBarEnabled(true);
275
289
 
276
290
  w.setWebViewClient(new WebViewClient() {
291
+
292
+ private boolean splashHidden = false;
277
293
 
278
294
  @Override
279
295
  public boolean shouldOverrideUrlLoading(WebView view, String url) {
280
296
  return handleUrlLoading(url);
281
297
  }
282
298
 
299
+ @Override
300
+ public void onPageStarted(WebView view, String url, Bitmap favicon) {
301
+ getWindow().setFeatureInt(Window.FEATURE_PROGRESS, 0);
302
+ super.onPageStarted(view, url, favicon);
303
+ }
304
+
283
305
  @Override
284
306
  public void onPageFinished(WebView view, String url) {
285
- if (url.startsWith("http://"))
307
+ if (!splashHidden && url.startsWith("http://")) {
286
308
  hideSplashScreen();
309
+ splashHidden = true;
310
+ }
311
+ getWindow().setFeatureInt(Window.FEATURE_PROGRESS, MAX_PROGRESS);
312
+ super.onPageFinished(view, url);
287
313
  }
288
314
 
289
315
  });
316
+
317
+ w.setWebChromeClient(new WebChromeClient() {
318
+ @Override
319
+ public void onProgressChanged(WebView view, int newProgress) {
320
+ newProgress *= 100;
321
+ if (newProgress < 0)
322
+ newProgress = 0;
323
+ if (newProgress > MAX_PROGRESS)
324
+ newProgress = MAX_PROGRESS;
325
+ getWindow().setFeatureInt(Window.FEATURE_PROGRESS, newProgress);
326
+ super.onProgressChanged(view, newProgress);
327
+ }
328
+ });
290
329
 
291
330
  return w;
292
331
  }
@@ -355,8 +394,8 @@ public class Rhodes extends Activity {
355
394
  }
356
395
  }
357
396
 
358
- private void showSplashScreen(String file) throws IOException {
359
- splashScreen = new SplashScreen(this, file);
397
+ private void showSplashScreen() {
398
+ splashScreen = new SplashScreen(this, "apps/app/loading.png");
360
399
  splashScreen.start(outerFrame);
361
400
  }
362
401
 
@@ -380,7 +419,9 @@ public class Rhodes extends Activity {
380
419
  return;
381
420
  }
382
421
 
383
- uiThreadId = Thread.currentThread().getId();
422
+ Thread ct = Thread.currentThread();
423
+ ct.setPriority(Thread.MAX_PRIORITY);
424
+ uiThreadId = ct.getId();
384
425
  RhodesInstance.setInstance(this);
385
426
 
386
427
  initRootPath();
@@ -412,19 +453,19 @@ public class Rhodes extends Activity {
412
453
  this.setContentView(outerFrame, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
413
454
 
414
455
  Logger.I("Rhodes", "Loading...");
456
+ showSplashScreen();
457
+
458
+ // Increase WebView rendering priority
459
+ WebView w = new WebView(this);
460
+ WebSettings webSettings = w.getSettings();
461
+ webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
415
462
 
463
+ // Get screen width/height
416
464
  WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE);
417
465
  Display d = wm.getDefaultDisplay();
418
466
  screenHeight = d.getHeight();
419
467
  screenWidth = d.getWidth();
420
468
 
421
- try {
422
- showSplashScreen("apps/app/loading.png");
423
- }
424
- catch (Exception e) {
425
- setMainView(new SimpleMainView());
426
- }
427
-
428
469
  // TODO: detect camera availability
429
470
  isCameraAvailable = true;
430
471
 
@@ -645,6 +686,10 @@ public class Rhodes extends Activity {
645
686
  Process.killProcess(Process.myPid());
646
687
  }
647
688
 
689
+ public static void exit() {
690
+ RhodesInstance.getInstance().stopSelf();
691
+ }
692
+
648
693
  static {
649
694
  // Load native implementation of rhodes
650
695
  System.loadLibrary("rhodes");
@@ -7,23 +7,74 @@ import android.content.Context;
7
7
  import android.content.res.AssetManager;
8
8
  import android.graphics.Bitmap;
9
9
  import android.graphics.BitmapFactory;
10
+ import android.view.View;
10
11
  import android.view.ViewGroup;
12
+ import android.webkit.WebView;
11
13
  import android.widget.ImageView;
12
14
 
13
15
  public class SplashScreen {
14
16
 
15
- private ImageView view;
17
+ private static final String INSTALLING_PAGE = "apps/app/installing.html";
18
+ private static final String LOADING_PAGE = "apps/app/loading.html";
19
+
20
+ private View view;
16
21
 
17
22
  private native void nativeStart();
18
23
  private native void nativeHide();
19
24
 
20
- public SplashScreen(Context ctx, String file) throws IOException {
21
- view = new ImageView(ctx);
25
+ public SplashScreen(Context ctx, String file) {
22
26
  AssetManager am = ctx.getResources().getAssets();
23
- InputStream is = am.open(file);
24
- Bitmap bitmap = BitmapFactory.decodeStream(is);
25
- view.setImageBitmap(bitmap);
26
- view.setId(Rhodes.RHO_SPLASH_VIEW);
27
+
28
+ Bitmap bitmap = null;
29
+ if (file != null) {
30
+ try {
31
+ InputStream is = am.open(file);
32
+ bitmap = BitmapFactory.decodeStream(is);
33
+ is.close();
34
+ }
35
+ catch (IOException e) {}
36
+ }
37
+ if (bitmap != null) {
38
+ ImageView v = new ImageView(ctx);
39
+ v.setImageBitmap(bitmap);
40
+ v.setId(Rhodes.RHO_SPLASH_VIEW);
41
+ view = v;
42
+ }
43
+ else {
44
+ Rhodes r = RhodesInstance.getInstance();
45
+ WebView v = r.createWebView();
46
+
47
+ boolean bc = r.isBundleChanged();
48
+ String page = bc ? INSTALLING_PAGE : LOADING_PAGE;
49
+
50
+ boolean hasNeededPage;
51
+ try {
52
+ InputStream is1 = am.open(page);
53
+ if (is1 != null)
54
+ is1.close();
55
+ hasNeededPage = true;
56
+ }
57
+ catch (IOException e1) {
58
+ hasNeededPage = false;
59
+ }
60
+
61
+ if (hasNeededPage) {
62
+ v.loadUrl("file:///android_asset/" + page);
63
+ }
64
+ else {
65
+ StringBuffer p = new StringBuffer();
66
+ p.append("<html><title>");
67
+ p.append(bc ? "Installing" : "Loading");
68
+ p.append("</title><body>");
69
+ p.append(bc ? "Installing" : "Loading");
70
+ p.append("...</body></html>");
71
+ v.loadData(p.toString(), "text/html", "utf-8");
72
+ }
73
+
74
+ v.setId(Rhodes.RHO_SPLASH_VIEW);
75
+
76
+ view = v;
77
+ }
27
78
  }
28
79
 
29
80
  public void start(ViewGroup outer) {