rhodes 2.1.0 → 2.2.0.beta.1

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 (241) hide show
  1. data/CHANGELOG +7 -0
  2. data/README.textile +4 -5
  3. data/Rakefile +8 -1
  4. data/lib/build/jake.rb +22 -16
  5. data/lib/extensions/rhoxml/rexml/cdata.rb +67 -0
  6. data/lib/extensions/rhoxml/rexml/document.rb +2 -116
  7. data/lib/extensions/rhoxml/rexml/element.rb +1 -1
  8. data/lib/extensions/rhoxml/rexml/text.rb +117 -0
  9. data/lib/framework/rho/render.rb +19 -11
  10. data/lib/framework/rho/rho.rb +17 -10
  11. data/lib/framework/rho/rhobluetooth.rb +103 -0
  12. data/lib/framework/rho/rhocontroller.rb +2 -0
  13. data/lib/framework/rho/rhoevent.rb +43 -0
  14. data/lib/framework/rho/rhoevent_bb.rb +80 -0
  15. data/lib/framework/rho/rhoevent_c.rb +47 -0
  16. data/lib/framework/rhodes.rb +2 -2
  17. data/lib/framework/rhom/rhom_db_adapter.rb +2 -1
  18. data/lib/framework/rhom/rhom_model.rb +9 -3
  19. data/lib/framework/rhom/rhom_object_factory.rb +46 -22
  20. data/lib/framework/rhom/rhom_source.rb +12 -10
  21. data/lib/framework/version.rb +2 -2
  22. data/lib/rhodes.rb +2 -2
  23. data/platform/android/Rhodes/AndroidManifest.xml +23 -2
  24. data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +54 -38
  25. data/platform/android/Rhodes/jni/include/rhodes.h +3 -0
  26. data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +2 -2
  27. data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +4 -0
  28. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +16 -0
  29. data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_bluetooth_RhoBluetoothManager.h +21 -0
  30. data/platform/android/Rhodes/jni/src/bluetooth.cpp +169 -0
  31. data/platform/android/Rhodes/jni/src/callbacks.cpp +10 -0
  32. data/platform/android/Rhodes/jni/src/event.cpp +429 -0
  33. data/platform/android/Rhodes/jni/src/fileapi.cpp +51 -1
  34. data/platform/android/Rhodes/jni/src/rhodes.cpp +16 -0
  35. data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -0
  36. data/platform/android/Rhodes/res/layout/bt_device_list.xml +42 -0
  37. data/platform/android/Rhodes/res/layout/bt_device_name.xml +7 -0
  38. data/platform/android/Rhodes/res/values/strings.xml +8 -0
  39. data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +14 -0
  40. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +2 -0
  41. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Push.java +7 -0
  42. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +58 -0
  43. data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +53 -0
  44. data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -0
  45. data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +144 -3
  46. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/IRhoBluetoothManager.java +66 -0
  47. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothDeviceListActivity.java +201 -0
  48. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +139 -0
  49. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +401 -0
  50. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerOld.java +136 -0
  51. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothSession.java +457 -0
  52. data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/UUIDHelper.java +71 -0
  53. data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +12 -7
  54. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/Event.java +19 -0
  55. data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +261 -0
  56. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +4 -2
  57. data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +2 -2
  58. data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +10 -2
  59. data/platform/android/build/RhodesSRC_build.files +33 -22
  60. data/platform/android/build/android.rake +198 -27
  61. data/platform/android/build/librhodes_build.files +3 -1
  62. data/platform/android/build/libruby_build.files +4 -1
  63. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +2 -2
  64. data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBRowResult.java +1 -1
  65. data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +7 -4
  66. data/platform/bb/Hsqldb/src/org/hsqldb/Like.java +3 -3
  67. data/platform/bb/Hsqldb/src/org/hsqldb/Table.java +3 -1
  68. data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +1 -1
  69. data/platform/bb/RubyVM/RubyVM.jdp +1 -0
  70. data/platform/bb/RubyVM/src/com/rho/RhoConf.java +108 -1
  71. data/platform/bb/RubyVM/src/com/rho/RhoLogConf.java +7 -1
  72. data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +7 -4
  73. data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +7 -1
  74. data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
  75. data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +21 -23
  76. data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +19 -10
  77. data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +8 -0
  78. data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +3 -0
  79. data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +14 -17
  80. data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFile.java +7 -5
  81. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +2 -0
  82. data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyRuntime.java +10 -1
  83. data/platform/bb/RubyVM/src/j2me/io/File.java +7 -6
  84. data/platform/bb/build/RubyVM_build.files +412 -412
  85. data/platform/bb/build/bb.rake +42 -18
  86. data/platform/bb/build/hsqldb_build.files +151 -151
  87. data/platform/bb/build/rhodes_build.files +44 -40
  88. data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +2 -0
  89. data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +237 -0
  90. data/platform/bb/rhodes/platform/common/com/rho/RhodesApplicationPlatform.java +14 -0
  91. data/platform/bb/rhodes/rhodes.jdp +6 -1
  92. data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +7 -1
  93. data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +14 -0
  94. data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +62 -76
  95. data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +660 -0
  96. data/platform/bb/rhodes/src/{rhomobile → com/rho/rubyext}/RhoPhonebook.java +95 -38
  97. data/platform/bb/rhodes/src/com/rho/rubyext/System.java +22 -1
  98. data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +26 -6
  99. data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +21 -7
  100. data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothManager.java +528 -0
  101. data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothPort.java +281 -0
  102. data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothScreen.java +119 -0
  103. data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +2 -2
  104. data/platform/iphone/Classes/AppManager/AppManager.m +70 -7
  105. data/platform/iphone/Classes/Bluetooth/Bluetooth.h +72 -0
  106. data/platform/iphone/Classes/Bluetooth/Bluetooth.m +414 -0
  107. data/platform/iphone/Classes/Event/Event.h +12 -0
  108. data/platform/iphone/Classes/Event/Event.m +300 -0
  109. data/platform/iphone/Classes/LogOptionsController.h +2 -1
  110. data/platform/iphone/Classes/LogOptionsController.m +1 -1
  111. data/platform/iphone/Classes/LogViewController.h +2 -1
  112. data/platform/iphone/Classes/MapView/MapViewController.h +2 -1
  113. data/platform/iphone/Classes/RhoViewController.h +16 -0
  114. data/platform/iphone/Classes/RhoViewController.m +20 -0
  115. data/platform/iphone/Classes/Rhodes.h +12 -0
  116. data/platform/iphone/Classes/Rhodes.m +34 -6
  117. data/platform/iphone/Classes/Signature/SignatureViewController.h +2 -2
  118. data/platform/iphone/Classes/Signature/SignatureViewController.m +0 -10
  119. data/platform/iphone/Classes/SimpleMainView.h +2 -2
  120. data/platform/iphone/Classes/SimpleMainView.m +5 -14
  121. data/platform/iphone/Classes/SplashViewController.h +2 -2
  122. data/platform/iphone/Classes/TabbedMainView.h +2 -2
  123. data/platform/iphone/Classes/TabbedMainView.m +5 -10
  124. data/platform/iphone/Info.plist +5 -5
  125. data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +39 -0
  126. data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +47 -4
  127. data/platform/osx/Rhodes Debugger/NoodleLineNumberView.m +3 -2
  128. data/platform/shared/common/AutoPointer.h +3 -0
  129. data/platform/shared/common/RhoConf.cpp +2 -1
  130. data/platform/shared/common/RhoThread.h +1 -1
  131. data/platform/shared/common/RhoTime.h +3 -3
  132. data/platform/shared/common/RhodesApp.cpp +75 -23
  133. data/platform/shared/common/RhodesApp.h +4 -0
  134. data/platform/shared/common/RhodesAppBase.h +2 -0
  135. data/platform/shared/common/ThreadQueue.cpp +23 -18
  136. data/platform/shared/common/ThreadQueue.h +2 -0
  137. data/platform/shared/db/res/db/syncdb.schema +39 -39
  138. data/platform/shared/logging/RhoLogConf.cpp +58 -3
  139. data/platform/shared/logging/RhoLogConf.h +3 -1
  140. data/platform/shared/net/CURLNetRequest.cpp +17 -6
  141. data/platform/shared/net/HttpServer.cpp +125 -25
  142. data/platform/shared/net/HttpServer.h +4 -3
  143. data/platform/shared/ruby/ext/bluetooth/bluetooth.i +56 -0
  144. data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +2563 -0
  145. data/platform/shared/ruby/ext/calendar/calendar.i +28 -0
  146. data/platform/shared/ruby/ext/calendar/calendar_wrap.c +2251 -0
  147. data/platform/shared/ruby/ext/calendar/event.h +41 -0
  148. data/platform/shared/ruby/ext/calendar/event.i +28 -0
  149. data/platform/shared/ruby/ext/calendar/event_wrap.c +2151 -0
  150. data/platform/shared/ruby/ext/rho/rhoruby.c +103 -3
  151. data/platform/shared/ruby/ext/rho/rhoruby.h +16 -2
  152. data/platform/shared/ruby/ext/rhoconf/rhoconf.i +12 -0
  153. data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +101 -0
  154. data/platform/shared/ruby/ext/system/system.i +14 -0
  155. data/platform/shared/ruby/ext/system/system_wrap.c +2568 -2208
  156. data/platform/shared/ruby/main.c +8 -0
  157. data/platform/shared/rubyext/GeoLocation.cpp +6 -3
  158. data/platform/shared/rubyext/System.cpp +14 -0
  159. data/platform/shared/sync/SyncEngine.cpp +9 -1
  160. data/platform/shared/sync/SyncNotify.cpp +16 -8
  161. data/platform/shared/sync/SyncNotify.h +1 -0
  162. data/platform/shared/sync/SyncThread.cpp +7 -12
  163. data/platform/shared/sync/SyncThread.h +5 -3
  164. data/platform/wm/build/wm.rake +7 -1
  165. data/platform/wm/rhodes/Alert.cpp +1 -1
  166. data/platform/wm/rhodes/MainWindow.cpp +28 -0
  167. data/platform/wm/rhodes/MainWindow.h +9 -0
  168. data/platform/wm/rhodes/OutlookApp.cpp +72 -0
  169. data/platform/wm/rhodes/OutlookApp.h +22 -0
  170. data/platform/wm/rhodes/Rhodes.cpp +8 -0
  171. data/platform/wm/rhodes/Rhodes.rc +31 -0
  172. data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1274 -0
  173. data/platform/wm/rhodes/bluetooth/Bluetooth.h +321 -0
  174. data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +37 -70
  175. data/platform/wm/rhodes/phonebook/NativeAddressBook.h +0 -4
  176. data/platform/wm/rhodes/resource.h +8 -1
  177. data/platform/wm/rhodes/rho/net/NetRequest.cpp +4 -0
  178. data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +6 -4
  179. data/platform/wm/rhodes/rho/rubyext/calendar.cpp +487 -0
  180. data/platform/wm/rhodes/rhodes.vcproj +28 -11
  181. data/platform/wm/rhodes/stdafx.h +1 -0
  182. data/platform/wm/rubylib/rubylib.vcproj +32 -0
  183. data/rakefile.rb +8 -1
  184. data/res/generators/templates/application/Rakefile +1 -1
  185. data/res/generators/templates/application/app/layout.erb +4 -1
  186. data/res/generators/templates/application/build.yml +0 -1
  187. data/res/generators/templates/application/public/css/iphone.css +2 -2
  188. data/res/generators/templates/application/public/jqtouch/jqtouch-iphone.css +9 -0
  189. data/res/generators/templates/application/public/jqtouch/jqtouch.css +1 -5
  190. data/res/generators/templates/application/public/jqtouch/jqtouch.js +3 -2
  191. data/rhodes.gemspec +1 -1
  192. data/spec/perfomance_spec/app/Benchmark/benchmark.rb +4 -0
  193. data/spec/perfomance_spec/app/Benchmark/bulk_results.erb +13 -0
  194. data/spec/perfomance_spec/app/Benchmark/controller.rb +178 -0
  195. data/spec/perfomance_spec/app/Benchmark/create_results.erb +13 -0
  196. data/spec/perfomance_spec/app/Benchmark/customers.erb +35 -0
  197. data/spec/perfomance_spec/app/Benchmark/index.erb +9 -0
  198. data/spec/perfomance_spec/app/Benchmark/products.erb +25 -0
  199. data/spec/perfomance_spec/app/Benchmark/search_results.erb +13 -0
  200. data/spec/perfomance_spec/app/Customer/customer.rb +6 -0
  201. data/spec/perfomance_spec/app/Perftest/index.erb +5 -0
  202. data/spec/perfomance_spec/app/Product/index.erb +25 -0
  203. data/spec/perfomance_spec/app/Product/product.rb +6 -0
  204. data/spec/perfomance_spec/app/helpers/application_helper.rb +126 -0
  205. data/spec/perfomance_spec/app/helpers/browser_helper.rb +18 -0
  206. data/spec/perfomance_spec/rhoconfig.txt +1 -1
  207. data/spec/phone_spec/app/Account_s/account_s.rb +5 -2
  208. data/spec/phone_spec/app/Case/case.rb +1 -0
  209. data/spec/phone_spec/app/Case_s/case_s.rb +2 -0
  210. data/spec/phone_spec/app/Data/perftest.json +35 -0
  211. data/spec/phone_spec/app/Data/testCDATA.xml +11 -0
  212. data/spec/phone_spec/app/Product/product.rb +1 -1
  213. data/spec/phone_spec/app/{Spec → spec}/asynchttp_spec.rb +66 -17
  214. data/spec/phone_spec/app/{Spec → spec}/barcode_spec.rb +0 -0
  215. data/spec/phone_spec/app/{Spec → spec}/blobsync_spec.rb +0 -0
  216. data/spec/phone_spec/app/{Spec → spec}/bsearch_spec.rb +0 -0
  217. data/spec/phone_spec/app/{Spec → spec}/bulksync_spec.rb +0 -0
  218. data/spec/phone_spec/app/{Spec → spec}/contacts_spec.rb +0 -0
  219. data/spec/phone_spec/app/{Spec → spec}/crypt_spec.rb +0 -0
  220. data/spec/phone_spec/app/{Spec → spec}/date_spec.rb +0 -0
  221. data/spec/phone_spec/app/spec/events_spec.rb +199 -0
  222. data/spec/phone_spec/app/{Spec → spec}/fixtures/client_info.txt +0 -0
  223. data/spec/phone_spec/app/{Spec → spec}/fixtures/object_values.txt +0 -0
  224. data/spec/phone_spec/app/{Spec → spec}/json_spec.rb +11 -2
  225. data/spec/phone_spec/app/{Spec → spec}/mapview_spec.rb +0 -0
  226. data/spec/phone_spec/app/{Spec → spec}/nativebar_spec.rb +0 -0
  227. data/spec/phone_spec/app/{Spec → spec}/navbar_spec.rb +0 -0
  228. data/spec/phone_spec/app/{Spec → spec}/pagination/fixtures/object_values.txt +0 -0
  229. data/spec/phone_spec/app/{Spec → spec}/rho_controller_spec.rb +5 -0
  230. data/spec/phone_spec/app/{Spec → spec}/rho_spec.rb +48 -0
  231. data/spec/phone_spec/app/{Spec → spec}/rhofile_spec.rb +9 -6
  232. data/spec/phone_spec/app/{Spec → spec}/rhom_object_spec.rb +188 -9
  233. data/spec/phone_spec/app/{Spec → spec}/syncengine_spec.rb +0 -0
  234. data/spec/phone_spec/app/{Spec → spec}/xml_spec.rb +15 -0
  235. data/spec/phone_spec/app/{Spec → spec}/xruby_spec.rb +0 -0
  236. data/spec/phone_spec/app/spec_runner.rb +4 -1
  237. data/spec/phone_spec/build.yml +2 -1
  238. metadata +95 -31
  239. data/platform/bb/rhodes/platform/5.0/com/rho/RhoMainScreen.java +0 -36
  240. data/platform/bb/rhodes/platform/6.0/com/rho/BrowserAdapter5.java +0 -155
  241. data/platform/bb/rhodes/platform/6.0/com/rho/RhoMainScreen.java +0 -36
@@ -0,0 +1,660 @@
1
+ package com.rho.rubyext;
2
+
3
+ import java.util.Enumeration;
4
+ import java.util.Hashtable;
5
+
6
+ import com.rho.RhoEmptyLogger;
7
+ import com.rho.RhoLogger;
8
+ import com.rho.Version;
9
+ import com.xruby.runtime.builtin.*;
10
+ import com.xruby.runtime.lang.*;
11
+
12
+ import javax.microedition.pim.*;
13
+
14
+ //@RubyLevelClass(name="Calendar")
15
+ public class RhoCalendar extends RubyBasic {
16
+ private static final RhoLogger LOG = RhoLogger.RHO_STRIP_LOG ? new RhoEmptyLogger() :
17
+ new RhoLogger("Calendar");
18
+
19
+ private EventList m_eventList;
20
+
21
+ static final RubyString RUBY_EV_ID = ObjectFactory.createString("id");
22
+ static final RubyString RUBY_EV_TITLE = ObjectFactory.createString("title");
23
+ static final RubyString RUBY_EV_CANCELED = ObjectFactory.createString("canceled");
24
+ static final RubyString RUBY_EV_ORGANIZER = ObjectFactory.createString("organizer");
25
+ static final RubyString RUBY_EV_ATTENDEES = ObjectFactory.createString("attendees");
26
+ static final RubyString RUBY_EV_START_DATE = ObjectFactory.createString("start_date");
27
+ static final RubyString RUBY_EV_END_DATE = ObjectFactory.createString("end_date");
28
+ static final RubyString RUBY_EV_LAST_MODIFIED = ObjectFactory.createString("last_modified");
29
+ static final RubyString RUBY_EV_LOCATION = ObjectFactory.createString( "location");
30
+ static final RubyString RUBY_EV_NOTES = ObjectFactory.createString( "notes");
31
+ static final RubyString RUBY_EV_REMINDER = ObjectFactory.createString( "reminder");
32
+ static final RubyString RUBY_EV_PRIVACY = ObjectFactory.createString( "privacy");
33
+ static final RubyString RUBY_EV_RECURRENCE = ObjectFactory.createString( "recurrence");
34
+ static final RubyString RUBY_EV_RECURRENCE_FREQUENCY = ObjectFactory.createString( "frequency");
35
+ static final RubyString RUBY_EV_RECURRENCE_FREQUENCY_DAILY = ObjectFactory.createString( "daily");
36
+ static final RubyString RUBY_EV_RECURRENCE_FREQUENCY_WEEKLY = ObjectFactory.createString( "weekly");
37
+ static final RubyString RUBY_EV_RECURRENCE_FREQUENCY_MONTHLY = ObjectFactory.createString( "monthly");
38
+ static final RubyString RUBY_EV_RECURRENCE_FREQUENCY_YEARLY = ObjectFactory.createString( "yearly");
39
+ static final RubyString RUBY_EV_RECURRENCE_INTERVAL = ObjectFactory.createString( "interval");
40
+ static final RubyString RUBY_EV_RECURRENCE_COUNT = ObjectFactory.createString( "count");
41
+ static final RubyString RUBY_EV_RECURRENCE_END = ObjectFactory.createString( "end_date");
42
+ static final RubyString RUBY_EV_RECURRENCE_MONTHS = ObjectFactory.createString( "months");
43
+ static final RubyString RUBY_EV_RECURRENCE_WEEKS = ObjectFactory.createString( "weeks");
44
+ static final RubyString RUBY_EV_RECURRENCE_DAYS = ObjectFactory.createString( "days");
45
+ static final RubyString RUBY_EV_RECURRENCE_DAYOFMONTH = ObjectFactory.createString( "day_of_month");
46
+
47
+ static final RubySymbol RUBY_FIND_type = ObjectFactory.createSymbol("find_type");
48
+ static final RubySymbol RUBY_FIND_include_repeating = ObjectFactory.createSymbol("include_repeating");
49
+ static final RubySymbol RUBY_FIND_start_date = ObjectFactory.createSymbol("start_date");
50
+ static final RubySymbol RUBY_FIND_end_date = ObjectFactory.createSymbol("end_date");
51
+
52
+ public static class EVRecord extends RubyBasic {
53
+
54
+ Event m_event;
55
+ public EVRecord(RubyClass arg0) {
56
+ super(arg0);
57
+ }
58
+
59
+ public EVRecord(Event event) {
60
+ super(RubyRuntime.PBRecordClass);
61
+
62
+ m_event = event;
63
+ }
64
+
65
+ }
66
+
67
+ public RhoCalendar(RubyClass arg0) throws Exception
68
+ {
69
+ super(arg0);
70
+
71
+ m_eventList = (EventList) PIM.getInstance().openPIMList(
72
+ PIM.EVENT_LIST, PIM.READ_WRITE);
73
+ }
74
+
75
+ //@RubyAllocMethod
76
+ public static RhoCalendar alloc(RubyValue receiver)throws Exception
77
+ {
78
+ return new RhoCalendar(RubyRuntime.CalendarClass);
79
+ }
80
+
81
+ public static RubyValue openCalendar()throws Exception
82
+ {
83
+ RhoCalendar pb = alloc(null);
84
+ return pb;
85
+ }
86
+
87
+ public static RubyValue closeCalendar(RubyValue arg0)throws Exception
88
+ {
89
+ RhoCalendar pb = (RhoCalendar)arg0;
90
+ pb.m_eventList.close();
91
+ pb.m_eventList = null;
92
+ return RubyConstant.QNIL;
93
+ }
94
+
95
+ RubyHash getEVRecord( Event event )
96
+ {
97
+ RubyHash record = ObjectFactory.createHash();
98
+ int[] arFields = event.getFields();
99
+ for ( int i = 0; i < arFields.length; i++)
100
+ {
101
+ switch(arFields[i])
102
+ {
103
+ case Event.UID:
104
+ record.add(RUBY_EV_ID, ObjectFactory.createString(
105
+ "{" + event.getString(Event.UID, 0) + "}" ));
106
+ break;
107
+
108
+ case Event.SUMMARY:
109
+ record.add(RUBY_EV_TITLE, ObjectFactory.createString(event.getString(Event.SUMMARY, 0)));
110
+ break;
111
+
112
+ case Event.NOTE:
113
+ record.add(RUBY_EV_NOTES, ObjectFactory.createString(event.getString(Event.NOTE, 0)));
114
+ break;
115
+
116
+ case Event.ALARM:
117
+ record.add(RUBY_EV_REMINDER, ObjectFactory.createInteger(event.getInt(Event.ALARM, 0)/60));
118
+ break;
119
+
120
+ case Event.CLASS:
121
+ {
122
+ int nClass = event.getInt(Event.CLASS, 0);
123
+ String strValue = "public";
124
+ if ( nClass == Event.CLASS_CONFIDENTIAL )
125
+ strValue = "confidential";
126
+ else if ( nClass == Event.CLASS_PRIVATE )
127
+ strValue = "private";
128
+
129
+ record.add(RUBY_EV_PRIVACY, ObjectFactory.createString(strValue));
130
+ break;
131
+ }
132
+
133
+ case Event.END:
134
+ record.add(RUBY_EV_END_DATE, ObjectFactory.createTime(event.getDate(Event.END, 0)));
135
+ break;
136
+ case Event.START:
137
+ record.add(RUBY_EV_START_DATE, ObjectFactory.createTime(event.getDate(Event.START, 0)));
138
+ break;
139
+ case Event.REVISION:
140
+ record.add(RUBY_EV_LAST_MODIFIED, ObjectFactory.createTime(event.getDate(Event.REVISION, 0)));
141
+ break;
142
+
143
+ case Event.LOCATION:
144
+ record.add(RUBY_EV_LOCATION, ObjectFactory.createString(event.getString(Event.LOCATION, 0)));
145
+ break;
146
+
147
+ }
148
+ }
149
+
150
+ RepeatRule rl = event.getRepeat();
151
+ if ( rl != null )
152
+ {
153
+ RubyHash recurrent = ObjectFactory.createHash();
154
+ arFields = rl.getFields();
155
+ for ( int i = 0; i < arFields.length; i++)
156
+ {
157
+ switch(arFields[i])
158
+ {
159
+ case RepeatRule.COUNT:
160
+ recurrent.add(RUBY_EV_RECURRENCE_COUNT, ObjectFactory.createInteger(rl.getInt(RepeatRule.COUNT)));
161
+ break;
162
+ case RepeatRule.END:
163
+ recurrent.add(RUBY_EV_RECURRENCE_END, ObjectFactory.createTime(rl.getDate(RepeatRule.END)));
164
+ break;
165
+ case RepeatRule.FREQUENCY:
166
+ {
167
+ RubyString strValue = RUBY_EV_RECURRENCE_FREQUENCY_DAILY;
168
+ int nFreq = rl.getInt(RepeatRule.FREQUENCY);
169
+ if ( nFreq == RepeatRule.WEEKLY )
170
+ strValue = RUBY_EV_RECURRENCE_FREQUENCY_WEEKLY;
171
+ else if ( nFreq == RepeatRule.YEARLY )
172
+ strValue = RUBY_EV_RECURRENCE_FREQUENCY_YEARLY;
173
+ else if ( nFreq == RepeatRule.MONTHLY )
174
+ strValue = RUBY_EV_RECURRENCE_FREQUENCY_MONTHLY;
175
+
176
+ recurrent.add(RUBY_EV_RECURRENCE_FREQUENCY, strValue);
177
+ break;
178
+ }
179
+
180
+ case RepeatRule.INTERVAL:
181
+ recurrent.add(RUBY_EV_RECURRENCE_INTERVAL, ObjectFactory.createInteger(rl.getInt(RepeatRule.INTERVAL)));
182
+ break;
183
+ case RepeatRule.MONTH_IN_YEAR:
184
+ {
185
+ Version.SoftVersion ver = Version.getSoftVersion();
186
+ //THIS IS BUG in BB < 5.0 : return month -1. January just crash get events
187
+ int[] arMonths = {RepeatRule.JANUARY, RepeatRule.FEBRUARY, RepeatRule.MARCH, RepeatRule.APRIL, RepeatRule.MAY, RepeatRule.JUNE, RepeatRule.JULY,
188
+ RepeatRule.AUGUST, RepeatRule.SEPTEMBER, RepeatRule.OCTOBER, RepeatRule.NOVEMBER, RepeatRule.DECEMBER};
189
+ int nMonths = rl.getInt(RepeatRule.MONTH_IN_YEAR);
190
+ RubyArray months = ObjectFactory.createArray(arMonths.length, ObjectFactory.createInteger(0));
191
+ for ( int m = 0; m < arMonths.length; m++ )
192
+ {
193
+ if ( (nMonths&arMonths[m]) != 0 )
194
+ months.set(m + (ver.nMajor < 5 ? 1 : 0), ObjectFactory.createInteger(1));
195
+ }
196
+ recurrent.add( RUBY_EV_RECURRENCE_MONTHS, months);
197
+ break;
198
+
199
+ }
200
+ case RepeatRule.WEEK_IN_MONTH:
201
+ {
202
+ int[] arWeeks = {RepeatRule.FIRST, RepeatRule.SECOND, RepeatRule.THIRD, RepeatRule.FOURTH, RepeatRule.FIFTH};
203
+ int nWeeks = rl.getInt(RepeatRule.WEEK_IN_MONTH);
204
+ RubyArray weeks = ObjectFactory.createArray(arWeeks.length, ObjectFactory.createInteger(0));
205
+ for ( int m = 0; m < arWeeks.length; m++ )
206
+ {
207
+ if ( (nWeeks&arWeeks[m]) != 0 )
208
+ weeks.set(m, ObjectFactory.createInteger(1));
209
+ }
210
+ recurrent.add( RUBY_EV_RECURRENCE_WEEKS, weeks);
211
+ break;
212
+ }
213
+ case RepeatRule.DAY_IN_WEEK:
214
+ {
215
+ int[] arDays = {RepeatRule.MONDAY, RepeatRule.TUESDAY, RepeatRule.WEDNESDAY, RepeatRule.THURSDAY, RepeatRule.FRIDAY, RepeatRule.SATURDAY, RepeatRule.SUNDAY};
216
+ int nDays = rl.getInt(RepeatRule.DAY_IN_WEEK);
217
+ RubyArray days = ObjectFactory.createArray(arDays.length, ObjectFactory.createInteger(0));
218
+ for ( int m = 0; m < arDays.length; m++ )
219
+ {
220
+ if ( (nDays&arDays[m]) != 0 )
221
+ days.set(m, ObjectFactory.createInteger(1));
222
+ }
223
+ recurrent.add( RUBY_EV_RECURRENCE_DAYS, days);
224
+ break;
225
+ }
226
+ case RepeatRule.DAY_IN_MONTH:
227
+ recurrent.add(RUBY_EV_RECURRENCE_DAYOFMONTH, ObjectFactory.createInteger(rl.getInt(RepeatRule.DAY_IN_MONTH)));
228
+ break;
229
+ }
230
+ }
231
+
232
+ record.add( RUBY_EV_RECURRENCE, recurrent);
233
+ }
234
+
235
+ return record;
236
+ }
237
+
238
+ public static RubyValue setEventValue(RubyArray ar)
239
+ {
240
+ if ( ar.get(0) == RubyConstant.QNIL || ar.get(0) == null )
241
+ return RubyConstant.QFALSE;
242
+
243
+ EVRecord record = (EVRecord)ar.get(0);
244
+ RubyString strKey = ar.get(1).toRubyString();
245
+ RubyValue val = ar.get(2);
246
+ Event event = record.m_event;
247
+
248
+ if ( strKey.opEql(RUBY_EV_ID) == RubyConstant.QTRUE )
249
+ return RubyConstant.QFALSE;
250
+
251
+ if ( strKey.opEql(RUBY_EV_TITLE) == RubyConstant.QTRUE )
252
+ setStringField(event, Event.SUMMARY, val );
253
+ else if ( strKey.opEql(RUBY_EV_NOTES) == RubyConstant.QTRUE )
254
+ setStringField(event, Event.NOTE, val );
255
+ else if ( strKey.opEql(RUBY_EV_REMINDER) == RubyConstant.QTRUE )
256
+ {
257
+ int nValue = val.toInt()*60;
258
+ setIntField(event, Event.ALARM, ObjectFactory.createInteger(nValue) );
259
+ }
260
+ else if ( strKey.opEql(RUBY_EV_PRIVACY) == RubyConstant.QTRUE )
261
+ {
262
+ String strValue = val.toStr();
263
+ int nClass = Event.CLASS_PUBLIC;
264
+ if ( strValue.equalsIgnoreCase("confidential"))
265
+ nClass = Event.CLASS_CONFIDENTIAL;
266
+ else if ( strValue.equalsIgnoreCase("private"))
267
+ nClass = Event.CLASS_PRIVATE;
268
+
269
+ setIntField(event, Event.CLASS, ObjectFactory.createInteger(nClass) );
270
+ }else if ( strKey.opEql(RUBY_EV_END_DATE) == RubyConstant.QTRUE )
271
+ setDateField(event, Event.END, val );
272
+ else if ( strKey.opEql(RUBY_EV_START_DATE) == RubyConstant.QTRUE )
273
+ setDateField(event, Event.START, val );
274
+ else if ( strKey.opEql(RUBY_EV_LAST_MODIFIED) == RubyConstant.QTRUE )
275
+ setDateField(event, Event.REVISION, val );
276
+ else if ( strKey.opEql(RUBY_EV_LOCATION) == RubyConstant.QTRUE )
277
+ setStringField(event, Event.LOCATION, val );
278
+ else if ( strKey.opEql(RUBY_EV_RECURRENCE) == RubyConstant.QTRUE )
279
+ {
280
+ RubyHash recurrent = (RubyHash)val;
281
+ RepeatRule rl = new RepeatRule();
282
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_COUNT) == RubyConstant.QTRUE )
283
+ rl.setInt(RepeatRule.COUNT, recurrent.get(RUBY_EV_RECURRENCE_COUNT).toInt());
284
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_END) == RubyConstant.QTRUE )
285
+ rl.setDate(RepeatRule.END, recurrent.get(RUBY_EV_RECURRENCE_END).toRubyTime().getTime());
286
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_FREQUENCY) == RubyConstant.QTRUE )
287
+ {
288
+ RubyString strValue = (RubyString)recurrent.get(RUBY_EV_RECURRENCE_FREQUENCY);
289
+ int nFreq = RepeatRule.WEEKLY;
290
+ if ( strValue.opEql(RUBY_EV_RECURRENCE_FREQUENCY_YEARLY) == RubyConstant.QTRUE )
291
+ nFreq = RepeatRule.YEARLY;
292
+ else if ( strValue.opEql(RUBY_EV_RECURRENCE_FREQUENCY_MONTHLY) == RubyConstant.QTRUE )
293
+ nFreq = RepeatRule.MONTHLY;
294
+ else if ( strValue.opEql(RUBY_EV_RECURRENCE_FREQUENCY_DAILY) == RubyConstant.QTRUE )
295
+ nFreq = RepeatRule.DAILY;
296
+
297
+ rl.setInt(RepeatRule.FREQUENCY, nFreq);
298
+ }
299
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_INTERVAL) == RubyConstant.QTRUE )
300
+ rl.setInt(RepeatRule.INTERVAL, recurrent.get(RUBY_EV_RECURRENCE_INTERVAL).toInt());
301
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_MONTHS) == RubyConstant.QTRUE )
302
+ {
303
+ int[] arMonths = {RepeatRule.JANUARY, RepeatRule.FEBRUARY, RepeatRule.MARCH, RepeatRule.APRIL, RepeatRule.MAY, RepeatRule.JUNE, RepeatRule.JULY,
304
+ RepeatRule.AUGUST, RepeatRule.SEPTEMBER, RepeatRule.OCTOBER, RepeatRule.NOVEMBER, RepeatRule.DECEMBER};
305
+ int nMonths = 0;
306
+ RubyArray months = (RubyArray)recurrent.get(RUBY_EV_RECURRENCE_MONTHS);
307
+ for ( int m = 0; m < months.size(); m++ )
308
+ {
309
+ if ( months.get(m).toInt() != 0 )
310
+ nMonths |= arMonths[m];
311
+ }
312
+ rl.setInt(RepeatRule.MONTH_IN_YEAR, nMonths);
313
+ }
314
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_WEEKS) == RubyConstant.QTRUE )
315
+ {
316
+ int[] arWeeks = {RepeatRule.FIRST, RepeatRule.SECOND, RepeatRule.THIRD, RepeatRule.FOURTH, RepeatRule.FIFTH};
317
+ int nWeeks = 0;
318
+ RubyArray weeks = (RubyArray)recurrent.get(RUBY_EV_RECURRENCE_WEEKS);
319
+ for ( int m = 0; m < weeks.size(); m++ )
320
+ {
321
+ if ( weeks.get(m).toInt() != 0 )
322
+ nWeeks |= arWeeks[m];
323
+ }
324
+ rl.setInt(RepeatRule.WEEK_IN_MONTH, nWeeks);
325
+ }
326
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_DAYS) == RubyConstant.QTRUE )
327
+ {
328
+ int[] arDays = {RepeatRule.MONDAY, RepeatRule.TUESDAY, RepeatRule.WEDNESDAY, RepeatRule.THURSDAY, RepeatRule.FRIDAY, RepeatRule.SATURDAY, RepeatRule.SUNDAY};
329
+ int nDays = 0;
330
+ RubyArray days = (RubyArray)recurrent.get(RUBY_EV_RECURRENCE_DAYS);
331
+ for ( int m = 0; m < days.size(); m++ )
332
+ {
333
+ if ( days.get(m).toInt() != 0 )
334
+ nDays |= arDays[m];
335
+ }
336
+ rl.setInt(RepeatRule.DAY_IN_WEEK, nDays);
337
+ }
338
+ if ( recurrent.has_key(RUBY_EV_RECURRENCE_DAYOFMONTH) == RubyConstant.QTRUE )
339
+ rl.setInt(RepeatRule.DAY_IN_MONTH, recurrent.get(RUBY_EV_RECURRENCE_DAYOFMONTH).toInt());
340
+
341
+ event.setRepeat(null);
342
+ event.setRepeat(rl);
343
+ }
344
+
345
+ return RubyConstant.QTRUE;
346
+ }
347
+
348
+ public static RubyValue findCalendarEvents(RubyArray args) throws Exception
349
+ {
350
+ RhoCalendar pb = (RhoCalendar)args.get(0);
351
+ RubyHash params = (RubyHash) args.get(1);
352
+ RubyArray res = new RubyArray();
353
+ RubyValue val = params.get(RUBY_FIND_type);
354
+ String strSearchType = val != null && val != RubyConstant.QNIL ? val.toStr() : "starting";
355
+ int nSearchType = EventList.STARTING;
356
+ if ( strSearchType.equalsIgnoreCase("occurring") )
357
+ nSearchType = EventList.OCCURRING;
358
+ else if (strSearchType.equalsIgnoreCase("ending"))
359
+ nSearchType = EventList.ENDING;
360
+
361
+ val = params.get(RUBY_FIND_include_repeating);
362
+ boolean bIncludeRepeating = val == RubyConstant.QFALSE ? false : true;
363
+ RubyTime start = (RubyTime)params.get(RUBY_FIND_start_date);
364
+ RubyTime end = (RubyTime)params.get(RUBY_FIND_end_date);
365
+
366
+ java.util.Enumeration events = pb.m_eventList.items(
367
+ nSearchType, start.getTime(), end.getTime(), !bIncludeRepeating);
368
+
369
+ while (events.hasMoreElements()) {
370
+ Event event = (Event) events.nextElement();
371
+ RubyHash record = pb.getEVRecord( event );
372
+ res.add(record);
373
+ }
374
+
375
+ return res;
376
+ }
377
+
378
+ public static RubyValue getallCalendarEvents(RubyValue arg0)throws Exception
379
+ {
380
+ RhoCalendar pb = (RhoCalendar)arg0;
381
+ RubyArray res = new RubyArray();
382
+
383
+ java.util.Enumeration events = pb.m_eventList.items();
384
+ while (events.hasMoreElements()) {
385
+ Event event = (Event) events.nextElement();
386
+ RubyHash record = pb.getEVRecord( event );
387
+ res.add(record);
388
+ }
389
+
390
+ return res;
391
+ }
392
+
393
+ private Event findEventByID(RubyValue arg0, RubyValue arg1 )throws Exception
394
+ {
395
+ Event event = null;
396
+
397
+ Event matching = m_eventList.createEvent();
398
+ String id = arg1.toString();
399
+ if (id != null && id.startsWith("{") && id.endsWith("}"))
400
+ id = id.substring(1, id.length()-1);
401
+ matching.addString(Event.UID, Event.ATTR_NONE, id);
402
+ java.util.Enumeration events = m_eventList.items(matching);
403
+ if (events.hasMoreElements())
404
+ event = (Event) events.nextElement();
405
+
406
+ return event;
407
+ }
408
+
409
+ public static RubyValue getCalendarEvent(RubyValue arg0, RubyValue arg1)throws Exception
410
+ {
411
+ RhoCalendar pb = (RhoCalendar)arg0;
412
+ RubyHash record = ObjectFactory.createHash();
413
+
414
+ Event event = pb.findEventByID(arg0,arg1);
415
+ if ( event != null )
416
+ record = pb.getEVRecord( event );
417
+
418
+ return record;
419
+ }
420
+
421
+ public static RubyValue openCalendarEvent(RubyValue arg0, RubyValue arg1)throws Exception
422
+ {
423
+ RhoCalendar pb = (RhoCalendar)arg0;
424
+ Event event = pb.findEventByID(arg0,arg1);
425
+ if ( event != null )
426
+ return new EVRecord(event);
427
+
428
+ return RubyConstant.QNIL;
429
+ }
430
+
431
+ private static void setStringField(Event event, int field, RubyValue val)
432
+ {
433
+ String strValue = val.toStr();
434
+ if ( event.countValues(field) > 0 )
435
+ event.setString(field, 0, Event.ATTR_NONE, strValue);
436
+ else
437
+ event.addString(field, Event.ATTR_NONE, strValue);
438
+ }
439
+
440
+ private static void setIntField(Event event, int field, RubyValue val)
441
+ {
442
+ int nValue = val.toInt();
443
+ if ( event.countValues(field) > 0 )
444
+ event.setInt(field, 0, Event.ATTR_NONE, nValue);
445
+ else
446
+ event.addInt(field, Event.ATTR_NONE, nValue);
447
+ }
448
+
449
+ private static void setDateField(Event event, int field, RubyValue val)
450
+ {
451
+ long nValue = val.toRubyTime().getTime();
452
+ if ( event.countValues(field) > 0 )
453
+ event.setDate(field, 0, Event.ATTR_NONE, nValue);
454
+ else
455
+ event.addDate(field, Event.ATTR_NONE, nValue);
456
+ }
457
+
458
+ public static RubyValue saveEvent(RubyValue arg0, RubyValue arg1)throws Exception
459
+ {
460
+ EVRecord record = (EVRecord)arg1;
461
+ record.m_event.commit();
462
+
463
+ return RubyConstant.QTRUE;
464
+ }
465
+
466
+ public static RubyValue createEvent(RubyValue arg0) {
467
+ RhoCalendar pb = (RhoCalendar)arg0;
468
+ Event event = pb.m_eventList.createEvent();
469
+ if ( event != null )
470
+ return new EVRecord(event);
471
+
472
+ return RubyConstant.QNIL;
473
+ }
474
+
475
+ public static RubyValue addEvent(RubyValue arg0, RubyValue arg1)throws Exception
476
+ {
477
+ return saveEvent(arg0, arg1);
478
+ }
479
+
480
+ public static RubyValue deleteEvent(RubyValue arg0, RubyValue arg1)throws Exception
481
+ {
482
+ RhoCalendar pb = (RhoCalendar)arg0;
483
+ EVRecord record = (EVRecord)arg1;
484
+
485
+ pb.m_eventList.removeEvent(record.m_event);
486
+
487
+ return RubyConstant.QTRUE;
488
+ }
489
+
490
+ public static void initConstants( RubyModule module)
491
+ {
492
+ module.setConstant("ID", RUBY_EV_ID);
493
+ module.setConstant("TITLE", RUBY_EV_TITLE);
494
+ module.setConstant("START_DATE", RUBY_EV_START_DATE);
495
+ module.setConstant("END_DATE", RUBY_EV_END_DATE);
496
+ module.setConstant("LOCATION", RUBY_EV_LOCATION);
497
+ module.setConstant("NOTES", RUBY_EV_NOTES);
498
+ module.setConstant("PRIVACY", RUBY_EV_PRIVACY);
499
+ module.setConstant("REMINDER", RUBY_EV_REMINDER);
500
+ module.setConstant("RECURRENCE", RUBY_EV_RECURRENCE);
501
+ module.setConstant("RECURRENCE_FREQUENCY", RUBY_EV_RECURRENCE_FREQUENCY);
502
+ module.setConstant("RECURRENCE_FREQUENCY_DAILY", RUBY_EV_RECURRENCE_FREQUENCY_DAILY);
503
+ module.setConstant("RECURRENCE_FREQUENCY_WEEKLY", RUBY_EV_RECURRENCE_FREQUENCY_WEEKLY);
504
+ module.setConstant("RECURRENCE_FREQUENCY_MONTHLY", RUBY_EV_RECURRENCE_FREQUENCY_MONTHLY);
505
+ module.setConstant("RECURRENCE_FREQUENCY_YEARLY", RUBY_EV_RECURRENCE_FREQUENCY_YEARLY);
506
+ module.setConstant("RECURRENCE_INTERVAL", RUBY_EV_RECURRENCE_INTERVAL);
507
+ }
508
+
509
+ public static void initMethods( RubyClass klass)
510
+ {
511
+ klass.defineAllocMethod(new RubyNoArgMethod(){
512
+ protected RubyValue run(RubyValue receiver, RubyBlock block )
513
+ {
514
+ try {
515
+ return RhoCalendar.alloc(receiver);
516
+ } catch(Exception e) {
517
+ LOG.ERROR("alloc Calendar failed", e);
518
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
519
+ }
520
+
521
+ }
522
+ });
523
+
524
+ klass.getSingletonClass().defineMethod("openCalendar", new RubyNoArgMethod() {
525
+ protected RubyValue run(RubyValue receiver, RubyBlock block)
526
+ {
527
+ try {
528
+ return RhoCalendar.openCalendar();
529
+ } catch(Exception e) {
530
+ LOG.ERROR("openCalendar failed", e);
531
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
532
+ }
533
+ }
534
+ });
535
+ klass.getSingletonClass().defineMethod("closeCalendar", new RubyOneArgMethod() {
536
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyBlock block)
537
+ {
538
+ try {
539
+ return RhoCalendar.closeCalendar(arg0);
540
+ } catch(Exception e) {
541
+ LOG.ERROR("closeCalendar failed", e);
542
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
543
+ }
544
+
545
+ }
546
+ });
547
+ klass.getSingletonClass().defineMethod("getallCalendarEvents", new RubyOneArgMethod() {
548
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyBlock block)
549
+ {
550
+ try {
551
+ return RhoCalendar.getallCalendarEvents(arg0);
552
+ } catch(Exception e) {
553
+ LOG.ERROR("getallCalendarEvents failed", e);
554
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
555
+ }
556
+
557
+ }
558
+ });
559
+ klass.getSingletonClass().defineMethod("findCalendarEvents", new RubyVarArgMethod() {
560
+ protected RubyValue run(RubyValue receiver, RubyArray args, RubyBlock block)
561
+ {
562
+ try {
563
+ return RhoCalendar.findCalendarEvents(args);
564
+ } catch(Exception e) {
565
+ LOG.ERROR("findCalendarEvents failed", e);
566
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
567
+ }
568
+
569
+ }
570
+ });
571
+
572
+ klass.getSingletonClass().defineMethod("openCalendarEvent", new RubyTwoArgMethod()
573
+ {
574
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block)
575
+ {
576
+ try {
577
+ return RhoCalendar.openCalendarEvent(arg0, arg1);
578
+ } catch(Exception e) {
579
+ LOG.ERROR("openCalendarEvent failed", e);
580
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
581
+ }
582
+ }
583
+ });
584
+ klass.getSingletonClass().defineMethod("getCalendarEvent", new RubyTwoArgMethod()
585
+ {
586
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block)
587
+ {
588
+ try {
589
+ return RhoCalendar.getCalendarEvent(arg0, arg1);
590
+ } catch(Exception e) {
591
+ LOG.ERROR("getCalendarEvent failed", e);
592
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
593
+ }
594
+
595
+ }
596
+ });
597
+ klass.getSingletonClass().defineMethod("createEvent", new RubyOneArgMethod()
598
+ {
599
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyBlock block)
600
+ {
601
+ try {
602
+ return RhoCalendar.createEvent(arg0);
603
+ } catch(Exception e) {
604
+ LOG.ERROR("createEvent failed", e);
605
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
606
+ }
607
+
608
+ }
609
+ });
610
+ klass.getSingletonClass().defineMethod("setEventValue", new RubyVarArgMethod()
611
+ {
612
+ protected RubyValue run(RubyValue receiver, RubyArray ar, RubyBlock block)
613
+ {
614
+ try {
615
+ return RhoCalendar.setEventValue(ar);
616
+ } catch(Exception e) {
617
+ LOG.ERROR("setEventValue failed", e);
618
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
619
+ }
620
+ }
621
+ });
622
+ klass.getSingletonClass().defineMethod("addEvent", new RubyTwoArgMethod()
623
+ {
624
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block)
625
+ {
626
+ try {
627
+ return RhoCalendar.addEvent(arg0, arg1);
628
+ } catch(Exception e) {
629
+ LOG.ERROR("addEvent failed", e);
630
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
631
+ }
632
+ }
633
+ });
634
+ klass.getSingletonClass().defineMethod("saveEvent", new RubyTwoArgMethod()
635
+ {
636
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block)
637
+ {
638
+ try {
639
+ return RhoCalendar.saveEvent(arg0, arg1);
640
+ } catch(Exception e) {
641
+ LOG.ERROR("saveEvent failed", e);
642
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
643
+ }
644
+ }
645
+ });
646
+ klass.getSingletonClass().defineMethod("deleteEvent", new RubyTwoArgMethod()
647
+ {
648
+ protected RubyValue run(RubyValue receiver, RubyValue arg0, RubyValue arg1, RubyBlock block)
649
+ {
650
+ try {
651
+ return RhoCalendar.deleteEvent(arg0, arg1);
652
+ } catch(Exception e) {
653
+ LOG.ERROR("saveEvent failed", e);
654
+ throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
655
+ }
656
+ }
657
+ });
658
+
659
+ }
660
+ }