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
@@ -3,6 +3,7 @@
3
3
  #include "rhodes/jni/com_rhomobile_rhodes_RhodesService.h"
4
4
 
5
5
  #include <common/RhoConf.h>
6
+ #include <common/app_build_configs.h>
6
7
  #include <logging/RhoLogConf.h>
7
8
  #include <common/RhodesApp.h>
8
9
  #include <sync/SyncThread.h>
@@ -223,39 +224,83 @@ jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/)
223
224
  return jversion;
224
225
  }
225
226
 
226
- VALUE convertJavaMapToRubyHash(jobject objMap)
227
+ namespace details
227
228
  {
228
- jclass clsMap = getJNIClass(RHODES_JAVA_CLASS_MAP);
229
- if (!clsMap) return Qnil;
230
- jclass clsSet = getJNIClass(RHODES_JAVA_CLASS_SET);
231
- if (!clsSet) return Qnil;
232
- jclass clsIterator = getJNIClass(RHODES_JAVA_CLASS_ITERATOR);
233
- if (!clsIterator) return Qnil;
234
229
 
235
- JNIEnv *env = jnienv();
230
+ std::string rho_cast_helper<std::string, jstring>::operator()(JNIEnv *env, jstring s)
231
+ {
232
+ const char *ts = env->GetStringUTFChars(s, JNI_FALSE);
233
+ std::string ret(ts);
234
+ env->ReleaseStringUTFChars(s, ts);
235
+ return ret;
236
+ }
237
+
238
+ jstring rho_cast_helper<jstring, char const *>::operator()(JNIEnv *env, char const *s)
239
+ {
240
+ return env->NewStringUTF(s);
241
+ }
236
242
 
237
- jmethodID midGet = getJNIClassMethod(env, clsMap, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
238
- if (!midGet) return Qnil;
239
- jmethodID midKeySet = getJNIClassMethod(env, clsMap, "keySet", "()Ljava/util/Set;");
240
- if (!midKeySet) return Qnil;
241
- jmethodID midIterator = getJNIClassMethod(env, clsSet, "iterator", "()Ljava/util/Iterator;");
242
- if (!midIterator) return Qnil;
243
- jmethodID midHasNext = getJNIClassMethod(env, clsIterator, "hasNext", "()Z");
244
- if (!midHasNext) return Qnil;
245
- jmethodID midNext = getJNIClassMethod(env, clsIterator, "next", "()Ljava/lang/Object;");
246
- if (!midNext) return Qnil;
243
+ static rho::common::CMutex rho_cast_java_ruby_mtx;
244
+
245
+ static jclass clsString;
246
+ static jclass clsMap;
247
+ static jclass clsSet;
248
+ static jclass clsIterator;
249
+
250
+ static jmethodID midMapGet;
251
+ static jmethodID midMapKeySet;
252
+ static jmethodID midSetIterator;
253
+ static jmethodID midIteratorHasNext;
254
+ static jmethodID midIteratorNext;
255
+
256
+ static bool rho_cast_java_ruby_init(JNIEnv *env)
257
+ {
258
+ static rho::common::CMutex rho_fd_mtx;
259
+ static bool initialized = false;
260
+ if (initialized)
261
+ return true;
262
+
263
+ rho::common::CMutexLock guard(rho_cast_java_ruby_mtx);
264
+ if (initialized)
265
+ return true;
266
+
267
+ clsString = getJNIClass(RHODES_JAVA_CLASS_STRING);
268
+ if (!clsString) return false;
269
+ clsMap = getJNIClass(RHODES_JAVA_CLASS_MAP);
270
+ if (!clsMap) return false;
271
+ clsSet = getJNIClass(RHODES_JAVA_CLASS_SET);
272
+ if (!clsSet) return false;
273
+ clsIterator = getJNIClass(RHODES_JAVA_CLASS_ITERATOR);
274
+ if (!clsIterator) return false;
275
+
276
+ midMapGet = getJNIClassMethod(env, clsMap, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
277
+ if (!midMapGet) return false;
278
+ midMapKeySet = getJNIClassMethod(env, clsMap, "keySet", "()Ljava/util/Set;");
279
+ if (!midMapKeySet) return false;
280
+ midSetIterator = getJNIClassMethod(env, clsSet, "iterator", "()Ljava/util/Iterator;");
281
+ if (!midSetIterator) return false;
282
+ midIteratorHasNext = getJNIClassMethod(env, clsIterator, "hasNext", "()Z");
283
+ if (!midIteratorHasNext) return false;
284
+ midIteratorNext = getJNIClassMethod(env, clsIterator, "next", "()Ljava/lang/Object;");
285
+ if (!midIteratorNext) return false;
286
+
287
+ initialized = true;
288
+ return true;
289
+ }
247
290
 
248
- jobject objSet = env->CallObjectMethod(objMap, midKeySet);
291
+ static VALUE convertJavaMapToRubyHash(JNIEnv *env, jobject objMap)
292
+ {
293
+ jobject objSet = env->CallObjectMethod(objMap, midMapKeySet);
249
294
  if (!objSet) return Qnil;
250
- jobject objIterator = env->CallObjectMethod(objSet, midIterator);
295
+ jobject objIterator = env->CallObjectMethod(objSet, midSetIterator);
251
296
  if (!objIterator) return Qnil;
252
297
 
253
298
  CHoldRubyValue retval(rho_ruby_createHash());
254
- while(env->CallBooleanMethod(objIterator, midHasNext))
299
+ while(env->CallBooleanMethod(objIterator, midIteratorHasNext))
255
300
  {
256
- jstring objKey = (jstring)env->CallObjectMethod(objIterator, midNext);
301
+ jstring objKey = (jstring)env->CallObjectMethod(objIterator, midIteratorNext);
257
302
  if (!objKey) return Qnil;
258
- jstring objValue = (jstring)env->CallObjectMethod(objMap, midGet, objKey);
303
+ jstring objValue = (jstring)env->CallObjectMethod(objMap, midMapGet, objKey);
259
304
  if (!objValue) return Qnil;
260
305
 
261
306
  std::string const &strKey = rho_cast<std::string>(objKey);
@@ -268,20 +313,43 @@ VALUE convertJavaMapToRubyHash(jobject objMap)
268
313
  return retval;
269
314
  }
270
315
 
271
- namespace details
316
+ jobject rho_cast_helper<jobject, VALUE>::operator()(JNIEnv *env, VALUE value)
272
317
  {
318
+ if (!rho_cast_java_ruby_init(env))
319
+ {
320
+ env->ThrowNew(getJNIClass(RHODES_JAVA_CLASS_RUNTIME_EXCEPTION), "Java <=> Ruby conversion initialization failed");
321
+ return NULL;
322
+ }
273
323
 
274
- std::string rho_cast_helper<std::string, jstring>::operator()(JNIEnv *env, jstring s)
275
- {
276
- const char *ts = env->GetStringUTFChars(s, JNI_FALSE);
277
- std::string ret(ts);
278
- env->ReleaseStringUTFChars(s, ts);
279
- return ret;
324
+ if (NIL_P(value))
325
+ return NULL;
326
+
327
+ if (TYPE(value) == T_STRING)
328
+ return env->NewStringUTF(RSTRING_PTR(value));
329
+
330
+ RAWLOG_ERROR("rho_cast<jobject, VALUE>: unknown type of value");
331
+ return NULL;
280
332
  }
281
333
 
282
- jstring rho_cast_helper<jstring, char const *>::operator()(JNIEnv *env, char const *s)
334
+ VALUE rho_cast_helper<VALUE, jobject>::operator()(JNIEnv *env, jobject obj)
283
335
  {
284
- return env->NewStringUTF(s);
336
+ if (!rho_cast_java_ruby_init(env))
337
+ {
338
+ env->ThrowNew(getJNIClass(RHODES_JAVA_CLASS_RUNTIME_EXCEPTION), "Java <=> Ruby conversion initialization failed");
339
+ return Qnil;
340
+ }
341
+
342
+ if (!obj)
343
+ return Qnil;
344
+
345
+ if (env->IsInstanceOf(obj, clsString))
346
+ return rho_ruby_create_string(rho_cast<std::string>(env, (jstring)obj).c_str());
347
+
348
+ if (env->IsInstanceOf(obj, clsMap))
349
+ return convertJavaMapToRubyHash(env, obj);
350
+
351
+ RAWLOG_ERROR("rho_cast<VALUE, jobject>: unknown type of value");
352
+ return Qnil;
285
353
  }
286
354
 
287
355
  } // namespace details
@@ -477,6 +545,15 @@ RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_normalizeUrl
477
545
  return rho_cast<jstring>(env, cs);
478
546
  }
479
547
 
548
+ RHO_GLOBAL jstring JNICALL Java_com_rhomobile_rhodes_RhodesService_getBuildConfig
549
+ (JNIEnv *env, jobject, jstring key)
550
+ {
551
+ std::string const &s = rho_cast<std::string>(key);
552
+ const char* cs = get_app_build_config_item(s.c_str());
553
+ return rho_cast<jstring>(env, cs);
554
+ }
555
+
556
+
480
557
  RHO_GLOBAL void JNICALL Java_com_rhomobile_rhodes_RhodesService_navigateBack
481
558
  (JNIEnv *, jclass)
482
559
  {
@@ -532,3 +609,7 @@ RHO_GLOBAL char *rho_timezone()
532
609
  }
533
610
  return tz;
534
611
  }
612
+
613
+ RHO_GLOBAL const char* rho_sys_get_start_params() {
614
+ return "";
615
+ }
@@ -13,7 +13,7 @@ RHO_GLOBAL VALUE rho_ringtone_manager_get_all()
13
13
 
14
14
  jobject obj = env->CallStaticObjectMethod(cls, mid);
15
15
  if (!obj) return Qnil;
16
- return convertJavaMapToRubyHash(obj);
16
+ return rho_cast<VALUE>(obj);
17
17
  }
18
18
 
19
19
  RHO_GLOBAL void rho_ringtone_manager_stop()
@@ -3,6 +3,7 @@ package com.rhomobile.rhodes;
3
3
  public class Capabilities {
4
4
 
5
5
  public static boolean AUDIO_ENABLED = true;
6
+ public static boolean BLUETOOTH_ENABLED = true;
6
7
  public static boolean CALENDAR_ENABLED = true;
7
8
  public static boolean CAMERA_ENABLED = true;
8
9
  public static boolean GPS_ENABLED = true;
@@ -21,10 +21,8 @@
21
21
  package com.rhomobile.rhodes;
22
22
 
23
23
  import java.util.Timer;
24
- import java.util.TimerTask;
25
24
 
26
25
  import com.rhomobile.rhodes.mainview.MainView;
27
- import com.rhomobile.rhodes.util.PerformOnUiThread;
28
26
 
29
27
  import android.content.Intent;
30
28
  import android.content.pm.ActivityInfo;
@@ -57,6 +55,8 @@ public class Rhodes extends RhoActivity {
57
55
  private Bundle mSavedBundle = null;
58
56
  private SplashScreen mSplashScreen = null;
59
57
  private Handler mHandler = null;
58
+
59
+ private Object mStartParams = null;
60
60
 
61
61
  /** Called when the activity is first created. */
62
62
  @Override
@@ -65,10 +65,13 @@ public class Rhodes extends RhoActivity {
65
65
 
66
66
  super.onCreate(savedInstanceState);
67
67
  mHandler = new Handler();
68
-
68
+
69
69
  // Here Log should be used, not Logger. It is because Logger is not initialized yet.
70
70
  Log.v(TAG, "+++ onCreate");
71
71
 
72
+ mStartParams = getIntent().getExtras();
73
+ Log.d(TAG, "start parameters: " + mStartParams);
74
+
72
75
  instance = this;
73
76
 
74
77
  FrameLayout v = new FrameLayout(this);
@@ -100,7 +103,7 @@ public class Rhodes extends RhoActivity {
100
103
  RhodesService service = RhodesService.getInstance();
101
104
  if (service == null) {
102
105
  Log.v(TAG, "Starting rhodes service...");
103
- service = new RhodesService(this, mOuterFrame, mSplashScreen);
106
+ service = new RhodesService(this, mOuterFrame, mSplashScreen, mStartParams);
104
107
  }
105
108
  else
106
109
  Log.v(TAG, "Rhodes service already started...");
@@ -130,13 +133,11 @@ public class Rhodes extends RhoActivity {
130
133
  private Timer mTimerPostponeCreate = null;
131
134
 
132
135
  public void onResume() {
133
- RhodesService.platformLog("Rhodes", "onResume()");
134
-
135
136
  super.onResume();
136
-
137
+ RhodesService.platformLog("Rhodes", "onResume()");
137
138
  }
138
139
 
139
- public static void runPosponedSetup() {
140
+ public static void runPostponedSetup() {
140
141
  final Rhodes r = Rhodes.getInstance();
141
142
  r.mHandler.post( new Runnable() {
142
143
  public void run() {
@@ -4,6 +4,8 @@ import java.io.File;
4
4
  import java.io.IOException;
5
5
  import java.util.Calendar;
6
6
  import java.util.Enumeration;
7
+ import java.util.Iterator;
8
+ import java.util.List;
7
9
  import java.util.Locale;
8
10
  import java.util.Map;
9
11
  import java.util.Set;
@@ -11,7 +13,7 @@ import java.util.TimeZone;
11
13
  import java.util.Vector;
12
14
 
13
15
  import com.rhomobile.rhodes.alert.Alert;
14
- import com.rhomobile.rhodes.bluetooth.RhoBluetoothManager;
16
+ import com.rhomobile.rhodes.event.EventStore;
15
17
  import com.rhomobile.rhodes.file.RhoFileApi;
16
18
  import com.rhomobile.rhodes.geolocation.GeoLocation;
17
19
  import com.rhomobile.rhodes.mainview.MainView;
@@ -68,6 +70,8 @@ public class RhodesService {
68
70
  public static final int RHO_MAIN_VIEW = 2;
69
71
  public static final int RHO_TOOLBAR_VIEW = 3;
70
72
 
73
+ private static final String RHO_START_PARAMS_KEY = "RhoStartParams";
74
+
71
75
  private static RhodesService instance = null;
72
76
 
73
77
  public static RhodesService getInstance() {
@@ -128,6 +132,10 @@ public class RhodesService {
128
132
  uiHandler.post(r);
129
133
  }
130
134
 
135
+ public void post(Runnable r, int delay) {
136
+ uiHandler.postDelayed(r, delay);
137
+ }
138
+
131
139
  private static int screenWidth;
132
140
  private static int screenHeight;
133
141
  private static int screenOrientation;
@@ -162,6 +170,8 @@ public class RhodesService {
162
170
 
163
171
  public native String normalizeUrl(String url);
164
172
 
173
+ public static native String getBuildConfig(String key);
174
+
165
175
  public static native void loadUrl(String url);
166
176
 
167
177
  public static native void navigateBack();
@@ -273,13 +283,19 @@ public class RhodesService {
273
283
 
274
284
  return false;
275
285
  }
286
+
287
+ private static int mGeoLocationInactivityTimeout;
288
+
289
+ public static int getGeoLocationInactivityTimeout() {
290
+ return mGeoLocationInactivityTimeout;
291
+ }
276
292
 
277
293
  public static SplashScreen showSplashScreen(Context ctx, ViewGroup myOuterFrame) {
278
294
  SplashScreen splashScreen = new SplashScreen(ctx);
279
295
  splashScreen.start(myOuterFrame);
280
296
  return splashScreen;
281
297
  }
282
-
298
+
283
299
  public void hideSplashScreen() {
284
300
  PerformOnUiThread.exec(new Runnable() {
285
301
  public void run() {
@@ -324,7 +340,7 @@ public class RhodesService {
324
340
  Rhodes.getInstance().getWindow().setFeatureInt(Window.FEATURE_PROGRESS, MAX_PROGRESS);
325
341
  super.onPageFinished(view, url);
326
342
  if (!setupExecuted) {
327
- Rhodes.runPosponedSetup();
343
+ Rhodes.runPostponedSetup();
328
344
  setupExecuted = true;
329
345
  }
330
346
 
@@ -444,7 +460,7 @@ public class RhodesService {
444
460
  return instance != null;
445
461
  }
446
462
 
447
- public RhodesService(Activity c, ViewGroup rootWindow, SplashScreen splash_s) {
463
+ public RhodesService(Activity c, ViewGroup rootWindow, SplashScreen splash_s, Object params) {
448
464
 
449
465
  ctx = c;
450
466
  instance = this;
@@ -467,7 +483,13 @@ public class RhodesService {
467
483
  if (Utils.isAppHashChanged()) {
468
484
  try {
469
485
  Log.i(TAG, "Application hash was changed, so remove files");
470
- Utils.deleteRecursively(new File(rootPath));
486
+ String[] folders = {"apps", "lib"};
487
+ for (String folder : folders) {
488
+ File f = new File(rootPath, folder);
489
+ if (!f.exists())
490
+ continue;
491
+ Utils.deleteRecursively(f);
492
+ }
471
493
  initRootPath();
472
494
  RhoFileApi.init();
473
495
  RhoFileApi.copy("hash");
@@ -480,6 +502,53 @@ public class RhodesService {
480
502
 
481
503
  createRhodesApp();
482
504
 
505
+ /*
506
+ boolean rhoGalleryApp = false;
507
+ if (params != null && params instanceof Bundle) {
508
+ Bundle startParams = (Bundle)params;
509
+ String v = startParams.getString("rhogallery_app");
510
+ if (v != null && v.equals("1"))
511
+ rhoGalleryApp = true;
512
+ }
513
+ if (!rhoGalleryApp && RhoConf.getBool("rhogallery_only_app")) {
514
+ Logger.E(TAG, "This is RhoGallery only app and can be started only from RhoGallery");
515
+ exitApp();
516
+ }
517
+ */
518
+ boolean can_start = true;
519
+ String security_token = getBuildConfig("security_token");
520
+ if (security_token != null) {
521
+ if (security_token.length() > 0) {
522
+ can_start = false;
523
+ if (params != null && params instanceof Bundle) {
524
+ Bundle startParams = (Bundle)params;
525
+ String rho_start_params = startParams.getString(RHO_START_PARAMS_KEY);
526
+ if (rho_start_params != null) {
527
+ String security_token_key = "sequrity_token=";
528
+ int sec_index = rho_start_params.indexOf(security_token_key);
529
+ if (sec_index >= 0) {
530
+ String tmp = rho_start_params.substring(sec_index + security_token_key.length(), rho_start_params.length() - sec_index - security_token_key.length());
531
+ int end_of_token = tmp.indexOf(",");
532
+ if (end_of_token >= 0) {
533
+ tmp = tmp.substring(0, end_of_token);
534
+ }
535
+ end_of_token = tmp.indexOf(" ");
536
+ if (end_of_token >= 0) {
537
+ tmp = tmp.substring(0, end_of_token);
538
+ }
539
+ if (tmp.equals(security_token)) {
540
+ can_start = true;
541
+ }
542
+ }
543
+ }
544
+ }
545
+ }
546
+ }
547
+ if (!can_start) {
548
+ Logger.E(TAG, "SECURITY_TOKEN parameter is not valid for this application !");
549
+ exitApp();
550
+ }
551
+
483
552
  boolean fullScreen = true;
484
553
  if (RhoConf.isExist("full_screen"))
485
554
  fullScreen = RhoConf.getBool("full_screen");
@@ -494,7 +563,9 @@ public class RhodesService {
494
563
 
495
564
  Logger.I("Rhodes", "Loading...");
496
565
  //showSplashScreen();
497
- splashScreen.rho_start();
566
+ if (splashScreen != null) {
567
+ splashScreen.rho_start();
568
+ }
498
569
 
499
570
  // Increase WebView rendering priority
500
571
  WebView w = new WebView(ctx);
@@ -516,6 +587,10 @@ public class RhodesService {
516
587
  // TODO: detect camera availability
517
588
  isCameraAvailable = true;
518
589
 
590
+ mGeoLocationInactivityTimeout = RhoConf.getInt("geo_location_inactivity_timeout");
591
+ if (mGeoLocationInactivityTimeout == 0)
592
+ mGeoLocationInactivityTimeout = 25*1000; // 25s
593
+
519
594
  // Register custom uri handlers here
520
595
  uriHandlers.addElement(new ExternalHttpHandler(ctx));
521
596
  uriHandlers.addElement(new MailUriHandler(ctx));
@@ -563,6 +638,7 @@ public class RhodesService {
563
638
  }
564
639
  }
565
640
  }, false);
641
+ getMainActivity().finish();
566
642
  Process.killProcess(Process.myPid());
567
643
  }
568
644
 
@@ -595,17 +671,17 @@ public class RhodesService {
595
671
  }
596
672
 
597
673
  public void activityStopped() {
598
- PerformOnUiThread.exec( new Runnable() {
599
- public void run() {
600
- if (wakeLockObject != null) {
601
- Logger.I(TAG, "activityStopped() temporary destroy wakeLock object");
602
- wakeLockObject.release();
603
- wakeLockObject = null;
604
- }
605
- }
606
- }, false);
607
674
  --activitiesActive;
608
675
  if (activitiesActive == 0) {
676
+ PerformOnUiThread.exec( new Runnable() {
677
+ public void run() {
678
+ if (wakeLockObject != null) {
679
+ Logger.I(TAG, "activityStopped() temporary destroy wakeLock object");
680
+ wakeLockObject.release();
681
+ wakeLockObject = null;
682
+ }
683
+ }
684
+ }, false);
609
685
  needGeoLocationRestart = GeoLocation.isAvailable();
610
686
  GeoLocation.stop();
611
687
  callActivationCallback(false);
@@ -726,40 +802,47 @@ public class RhodesService {
726
802
  }
727
803
 
728
804
  public static Object getProperty(String name) {
729
- if (name.equalsIgnoreCase("platform"))
730
- return "ANDROID";
731
- else if (name.equalsIgnoreCase("locale"))
732
- return getCurrentLocale();
733
- else if (name.equalsIgnoreCase("country"))
734
- return getCurrentCountry();
735
- else if (name.equalsIgnoreCase("screen_width"))
736
- return new Integer(getScreenWidth());
737
- else if (name.equalsIgnoreCase("screen_height"))
738
- return new Integer(getScreenHeight());
739
- else if (name.equalsIgnoreCase("has_camera"))
740
- return new Boolean(isCameraAvailable);
741
- else if (name.equalsIgnoreCase("has_network"))
742
- return hasNetwork();
743
- else if (name.equalsIgnoreCase("ppi_x"))
744
- return new Float(screenPpiX);
745
- else if (name.equalsIgnoreCase("ppi_y"))
746
- return new Float(screenPpiY);
747
- else if (name.equalsIgnoreCase("phone_number")) {
748
- TelephonyManager manager = (TelephonyManager)RhodesService.getInstance().
749
- getContext().getSystemService(Context.TELEPHONY_SERVICE);
750
- String number = manager.getLine1Number();
751
- return number;
752
- }
753
- else if (name.equalsIgnoreCase("device_name")) {
754
- return Build.DEVICE;
755
- }
756
- else if (name.equalsIgnoreCase("is_emulator"))
757
- {
758
- String strDevice = Build.DEVICE;
759
- return new Boolean(strDevice != null && strDevice.equalsIgnoreCase("generic"));
805
+ try {
806
+ if (name.equalsIgnoreCase("platform"))
807
+ return "ANDROID";
808
+ else if (name.equalsIgnoreCase("locale"))
809
+ return getCurrentLocale();
810
+ else if (name.equalsIgnoreCase("country"))
811
+ return getCurrentCountry();
812
+ else if (name.equalsIgnoreCase("screen_width"))
813
+ return new Integer(getScreenWidth());
814
+ else if (name.equalsIgnoreCase("screen_height"))
815
+ return new Integer(getScreenHeight());
816
+ else if (name.equalsIgnoreCase("has_camera"))
817
+ return new Boolean(isCameraAvailable);
818
+ else if (name.equalsIgnoreCase("has_network"))
819
+ return hasNetwork();
820
+ else if (name.equalsIgnoreCase("ppi_x"))
821
+ return new Float(screenPpiX);
822
+ else if (name.equalsIgnoreCase("ppi_y"))
823
+ return new Float(screenPpiY);
824
+ else if (name.equalsIgnoreCase("phone_number")) {
825
+ TelephonyManager manager = (TelephonyManager)RhodesService.getInstance().
826
+ getContext().getSystemService(Context.TELEPHONY_SERVICE);
827
+ String number = manager.getLine1Number();
828
+ return number;
829
+ }
830
+ else if (name.equalsIgnoreCase("device_name")) {
831
+ return Build.DEVICE;
832
+ }
833
+ else if (name.equalsIgnoreCase("is_emulator")) {
834
+ String strDevice = Build.DEVICE;
835
+ return new Boolean(strDevice != null && strDevice.equalsIgnoreCase("generic"));
836
+ }
837
+ else if (name.equalsIgnoreCase("os_version")) {
838
+ return Build.VERSION.RELEASE;
839
+ }
840
+ else if (name.equalsIgnoreCase("has_calendar")) {
841
+ return new Boolean(EventStore.hasCalendar());
842
+ }
760
843
  }
761
- else if (name.equalsIgnoreCase("os_version")) {
762
- return Build.VERSION.RELEASE;
844
+ catch (Exception e) {
845
+ Logger.E(TAG, "Can't get property \"" + name + "\": " + e);
763
846
  }
764
847
 
765
848
  return null;
@@ -775,7 +858,7 @@ public class RhodesService {
775
858
  return tz.getDisplayName();
776
859
  }
777
860
 
778
- public static void runApplication(String appName, Map<Object, Object> params) {
861
+ public static void runApplication(String appName, Object params) {
779
862
  try {
780
863
  Context ctx = RhodesService.getInstance().getContext();
781
864
  PackageManager mgr = ctx.getPackageManager();
@@ -791,12 +874,64 @@ public class RhodesService {
791
874
 
792
875
  Intent intent = new Intent();
793
876
  intent.setClassName(appName, className);
877
+ if (params != null) {
878
+ Bundle startParams = new Bundle();
879
+ if (params instanceof String) {
880
+ startParams.putString(RHO_START_PARAMS_KEY, (String)params);
881
+ }
882
+ /*
883
+ else if (params instanceof List<?>) {
884
+ for (Object obj : (List<?>)params) {
885
+ startParams.putInt(obj.toString(), 1);
886
+ }
887
+ }
888
+ else if (params instanceof Map<?,?>) {
889
+ Map<?,?> mp = (Map<?,?>)params;
890
+ for (Iterator<?> it = mp.keySet().iterator(); it.hasNext();) {
891
+ Object key = it.next();
892
+ Object value = mp.get(key);
893
+ startParams.putString(key.toString(), value == null ? null : value.toString());
894
+ }
895
+ }
896
+ */
897
+ else
898
+ throw new IllegalArgumentException("Unknown type of incoming parameter");
899
+
900
+ intent.putExtras(startParams);
901
+ }
794
902
  ctx.startActivity(intent);
795
903
  }
796
904
  catch (Exception e) {
797
905
  Logger.E(TAG, "Can't run application " + appName + ": " + e.getMessage());
798
906
  }
799
907
  }
908
+
909
+ public static boolean isAppInstalled(String appName) {
910
+ try {
911
+ try {
912
+ RhodesService.getInstance().getContext().getPackageManager().getPackageInfo(appName, 0);
913
+ return true;
914
+ }
915
+ catch (NameNotFoundException ne) {
916
+ return false;
917
+ }
918
+ }
919
+ catch (Exception e) {
920
+ Logger.E(TAG, "Can't check is app " + appName + " installed: " + e.getMessage());
921
+ return false;
922
+ }
923
+ }
924
+
925
+ public static void uninstallApplication(String appName) {
926
+ try {
927
+ Uri packageUri = Uri.parse("package:" + appName);
928
+ Intent intent = new Intent(Intent.ACTION_DELETE, packageUri);
929
+ RhodesService.getInstance().startActivity(intent);
930
+ }
931
+ catch (Exception e) {
932
+ Logger.E(TAG, "Can't uninstall application " + appName + ": " + e.getMessage());
933
+ }
934
+ }
800
935
 
801
936
  public static void openExternalUrl(String url) {
802
937
  try {