rhodes 2.1.0 → 2.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/README.textile +4 -5
- data/Rakefile +8 -1
- data/lib/build/jake.rb +22 -16
- data/lib/extensions/rhoxml/rexml/cdata.rb +67 -0
- data/lib/extensions/rhoxml/rexml/document.rb +2 -116
- data/lib/extensions/rhoxml/rexml/element.rb +1 -1
- data/lib/extensions/rhoxml/rexml/text.rb +117 -0
- data/lib/framework/rho/render.rb +19 -11
- data/lib/framework/rho/rho.rb +17 -10
- data/lib/framework/rho/rhobluetooth.rb +103 -0
- data/lib/framework/rho/rhocontroller.rb +2 -0
- data/lib/framework/rho/rhoevent.rb +43 -0
- data/lib/framework/rho/rhoevent_bb.rb +80 -0
- data/lib/framework/rho/rhoevent_c.rb +47 -0
- data/lib/framework/rhodes.rb +2 -2
- data/lib/framework/rhom/rhom_db_adapter.rb +2 -1
- data/lib/framework/rhom/rhom_model.rb +9 -3
- data/lib/framework/rhom/rhom_object_factory.rb +46 -22
- data/lib/framework/rhom/rhom_source.rb +12 -10
- data/lib/framework/version.rb +2 -2
- data/lib/rhodes.rb +2 -2
- data/platform/android/Rhodes/AndroidManifest.xml +23 -2
- data/platform/android/Rhodes/gen/com/rhomobile/rhodes/R.java +54 -38
- data/platform/android/Rhodes/jni/include/rhodes.h +3 -0
- data/platform/android/Rhodes/jni/include/rhodes/JNIRhodes.h +2 -2
- data/platform/android/Rhodes/jni/include/rhodes/details/rhojava.inc +4 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_RhodesService.h +16 -0
- data/platform/android/Rhodes/jni/include/rhodes/jni/com_rhomobile_rhodes_bluetooth_RhoBluetoothManager.h +21 -0
- data/platform/android/Rhodes/jni/src/bluetooth.cpp +169 -0
- data/platform/android/Rhodes/jni/src/callbacks.cpp +10 -0
- data/platform/android/Rhodes/jni/src/event.cpp +429 -0
- data/platform/android/Rhodes/jni/src/fileapi.cpp +51 -1
- data/platform/android/Rhodes/jni/src/rhodes.cpp +16 -0
- data/platform/android/Rhodes/jni/src/sslimpl.cpp +3 -0
- data/platform/android/Rhodes/res/layout/bt_device_list.xml +42 -0
- data/platform/android/Rhodes/res/layout/bt_device_name.xml +7 -0
- data/platform/android/Rhodes/res/values/strings.xml +8 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/AndroidR.java +14 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Capabilities.java +2 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Push.java +7 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushReceiver.java +58 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/PushService.java +53 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/Rhodes.java +8 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/RhodesService.java +144 -3
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/IRhoBluetoothManager.java +66 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothDeviceListActivity.java +201 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManager.java +139 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerNew.java +401 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothManagerOld.java +136 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/RhoBluetoothSession.java +457 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/bluetooth/UUIDHelper.java +71 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/camera/ImageCapture.java +12 -7
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/Event.java +19 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/event/EventStore.java +261 -0
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/SimpleMainView.java +4 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/mainview/TabbedMainView.java +2 -2
- data/platform/android/Rhodes/src/com/rhomobile/rhodes/uri/MailUriHandler.java +10 -2
- data/platform/android/build/RhodesSRC_build.files +33 -22
- data/platform/android/build/android.rake +198 -27
- data/platform/android/build/librhodes_build.files +3 -1
- data/platform/android/build/libruby_build.files +4 -1
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBResult.java +2 -2
- data/platform/bb/Hsqldb/src/com/rho/db/HsqlDBRowResult.java +1 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Expression.java +7 -4
- data/platform/bb/Hsqldb/src/org/hsqldb/Like.java +3 -3
- data/platform/bb/Hsqldb/src/org/hsqldb/Table.java +3 -1
- data/platform/bb/Hsqldb/src/org/hsqldb/Tokenizer.java +1 -1
- data/platform/bb/RubyVM/RubyVM.jdp +1 -0
- data/platform/bb/RubyVM/src/com/rho/RhoConf.java +108 -1
- data/platform/bb/RubyVM/src/com/rho/RhoLogConf.java +7 -1
- data/platform/bb/RubyVM/src/com/rho/RhoRuby.java +7 -4
- data/platform/bb/RubyVM/src/com/rho/ThreadQueue.java +7 -1
- data/platform/bb/RubyVM/src/com/rho/net/AsyncHttp.java +1 -1
- data/platform/bb/RubyVM/src/com/rho/net/NetRequest.java +21 -23
- data/platform/bb/RubyVM/src/com/rho/net/RhoConnection.java +19 -10
- data/platform/bb/RubyVM/src/com/rho/sync/SyncEngine.java +8 -0
- data/platform/bb/RubyVM/src/com/rho/sync/SyncNotify.java +3 -0
- data/platform/bb/RubyVM/src/com/rho/sync/SyncThread.java +14 -17
- data/platform/bb/RubyVM/src/com/xruby/runtime/builtin/RubyFile.java +7 -5
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RhoSupport.java +2 -0
- data/platform/bb/RubyVM/src/com/xruby/runtime/lang/RubyRuntime.java +10 -1
- data/platform/bb/RubyVM/src/j2me/io/File.java +7 -6
- data/platform/bb/build/RubyVM_build.files +412 -412
- data/platform/bb/build/bb.rake +42 -18
- data/platform/bb/build/hsqldb_build.files +151 -151
- data/platform/bb/build/rhodes_build.files +44 -40
- data/platform/bb/rhodes/platform/5.0/com/rho/BrowserAdapter5.java +2 -0
- data/platform/bb/rhodes/platform/5.0/com/rho/RhodesApplicationPlatform.java +237 -0
- data/platform/bb/rhodes/platform/common/com/rho/RhodesApplicationPlatform.java +14 -0
- data/platform/bb/rhodes/rhodes.jdp +6 -1
- data/platform/bb/rhodes/src/com/rho/RhoRubyHelper.java +7 -1
- data/platform/bb/rhodes/src/com/rho/RhodesApplicationPlatform.java +14 -0
- data/platform/bb/rhodes/src/com/rho/net/NetworkAccess.java +62 -76
- data/platform/bb/rhodes/src/com/rho/rubyext/RhoCalendar.java +660 -0
- data/platform/bb/rhodes/src/{rhomobile → com/rho/rubyext}/RhoPhonebook.java +95 -38
- data/platform/bb/rhodes/src/com/rho/rubyext/System.java +22 -1
- data/platform/bb/rhodes/src/rhomobile/PushListeningThread.java +26 -6
- data/platform/bb/rhodes/src/rhomobile/RhodesApplication.java +21 -7
- data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothManager.java +528 -0
- data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothPort.java +281 -0
- data/platform/bb/rhodes/src/rhomobile/bluetooth/BluetoothScreen.java +119 -0
- data/platform/bb/rhodes/src/rhomobile/camera/CameraFilesListener.java +2 -2
- data/platform/iphone/Classes/AppManager/AppManager.m +70 -7
- data/platform/iphone/Classes/Bluetooth/Bluetooth.h +72 -0
- data/platform/iphone/Classes/Bluetooth/Bluetooth.m +414 -0
- data/platform/iphone/Classes/Event/Event.h +12 -0
- data/platform/iphone/Classes/Event/Event.m +300 -0
- data/platform/iphone/Classes/LogOptionsController.h +2 -1
- data/platform/iphone/Classes/LogOptionsController.m +1 -1
- data/platform/iphone/Classes/LogViewController.h +2 -1
- data/platform/iphone/Classes/MapView/MapViewController.h +2 -1
- data/platform/iphone/Classes/RhoViewController.h +16 -0
- data/platform/iphone/Classes/RhoViewController.m +20 -0
- data/platform/iphone/Classes/Rhodes.h +12 -0
- data/platform/iphone/Classes/Rhodes.m +34 -6
- data/platform/iphone/Classes/Signature/SignatureViewController.h +2 -2
- data/platform/iphone/Classes/Signature/SignatureViewController.m +0 -10
- data/platform/iphone/Classes/SimpleMainView.h +2 -2
- data/platform/iphone/Classes/SimpleMainView.m +5 -14
- data/platform/iphone/Classes/SplashViewController.h +2 -2
- data/platform/iphone/Classes/TabbedMainView.h +2 -2
- data/platform/iphone/Classes/TabbedMainView.m +5 -10
- data/platform/iphone/Info.plist +5 -5
- data/platform/iphone/rhorubylib/rhorubylib.xcodeproj/project.pbxproj +39 -0
- data/platform/iphone/rhorunner.xcodeproj/project.pbxproj +47 -4
- data/platform/osx/Rhodes Debugger/NoodleLineNumberView.m +3 -2
- data/platform/shared/common/AutoPointer.h +3 -0
- data/platform/shared/common/RhoConf.cpp +2 -1
- data/platform/shared/common/RhoThread.h +1 -1
- data/platform/shared/common/RhoTime.h +3 -3
- data/platform/shared/common/RhodesApp.cpp +75 -23
- data/platform/shared/common/RhodesApp.h +4 -0
- data/platform/shared/common/RhodesAppBase.h +2 -0
- data/platform/shared/common/ThreadQueue.cpp +23 -18
- data/platform/shared/common/ThreadQueue.h +2 -0
- data/platform/shared/db/res/db/syncdb.schema +39 -39
- data/platform/shared/logging/RhoLogConf.cpp +58 -3
- data/platform/shared/logging/RhoLogConf.h +3 -1
- data/platform/shared/net/CURLNetRequest.cpp +17 -6
- data/platform/shared/net/HttpServer.cpp +125 -25
- data/platform/shared/net/HttpServer.h +4 -3
- data/platform/shared/ruby/ext/bluetooth/bluetooth.i +56 -0
- data/platform/shared/ruby/ext/bluetooth/bluetooth_wrap.c +2563 -0
- data/platform/shared/ruby/ext/calendar/calendar.i +28 -0
- data/platform/shared/ruby/ext/calendar/calendar_wrap.c +2251 -0
- data/platform/shared/ruby/ext/calendar/event.h +41 -0
- data/platform/shared/ruby/ext/calendar/event.i +28 -0
- data/platform/shared/ruby/ext/calendar/event_wrap.c +2151 -0
- data/platform/shared/ruby/ext/rho/rhoruby.c +103 -3
- data/platform/shared/ruby/ext/rho/rhoruby.h +16 -2
- data/platform/shared/ruby/ext/rhoconf/rhoconf.i +12 -0
- data/platform/shared/ruby/ext/rhoconf/rhoconf_wrap.c +101 -0
- data/platform/shared/ruby/ext/system/system.i +14 -0
- data/platform/shared/ruby/ext/system/system_wrap.c +2568 -2208
- data/platform/shared/ruby/main.c +8 -0
- data/platform/shared/rubyext/GeoLocation.cpp +6 -3
- data/platform/shared/rubyext/System.cpp +14 -0
- data/platform/shared/sync/SyncEngine.cpp +9 -1
- data/platform/shared/sync/SyncNotify.cpp +16 -8
- data/platform/shared/sync/SyncNotify.h +1 -0
- data/platform/shared/sync/SyncThread.cpp +7 -12
- data/platform/shared/sync/SyncThread.h +5 -3
- data/platform/wm/build/wm.rake +7 -1
- data/platform/wm/rhodes/Alert.cpp +1 -1
- data/platform/wm/rhodes/MainWindow.cpp +28 -0
- data/platform/wm/rhodes/MainWindow.h +9 -0
- data/platform/wm/rhodes/OutlookApp.cpp +72 -0
- data/platform/wm/rhodes/OutlookApp.h +22 -0
- data/platform/wm/rhodes/Rhodes.cpp +8 -0
- data/platform/wm/rhodes/Rhodes.rc +31 -0
- data/platform/wm/rhodes/bluetooth/Bluetooth.cpp +1274 -0
- data/platform/wm/rhodes/bluetooth/Bluetooth.h +321 -0
- data/platform/wm/rhodes/phonebook/NativeAddressBook.cpp +37 -70
- data/platform/wm/rhodes/phonebook/NativeAddressBook.h +0 -4
- data/platform/wm/rhodes/resource.h +8 -1
- data/platform/wm/rhodes/rho/net/NetRequest.cpp +4 -0
- data/platform/wm/rhodes/rho/net/NetRequestImpl.cpp +6 -4
- data/platform/wm/rhodes/rho/rubyext/calendar.cpp +487 -0
- data/platform/wm/rhodes/rhodes.vcproj +28 -11
- data/platform/wm/rhodes/stdafx.h +1 -0
- data/platform/wm/rubylib/rubylib.vcproj +32 -0
- data/rakefile.rb +8 -1
- data/res/generators/templates/application/Rakefile +1 -1
- data/res/generators/templates/application/app/layout.erb +4 -1
- data/res/generators/templates/application/build.yml +0 -1
- data/res/generators/templates/application/public/css/iphone.css +2 -2
- data/res/generators/templates/application/public/jqtouch/jqtouch-iphone.css +9 -0
- data/res/generators/templates/application/public/jqtouch/jqtouch.css +1 -5
- data/res/generators/templates/application/public/jqtouch/jqtouch.js +3 -2
- data/rhodes.gemspec +1 -1
- data/spec/perfomance_spec/app/Benchmark/benchmark.rb +4 -0
- data/spec/perfomance_spec/app/Benchmark/bulk_results.erb +13 -0
- data/spec/perfomance_spec/app/Benchmark/controller.rb +178 -0
- data/spec/perfomance_spec/app/Benchmark/create_results.erb +13 -0
- data/spec/perfomance_spec/app/Benchmark/customers.erb +35 -0
- data/spec/perfomance_spec/app/Benchmark/index.erb +9 -0
- data/spec/perfomance_spec/app/Benchmark/products.erb +25 -0
- data/spec/perfomance_spec/app/Benchmark/search_results.erb +13 -0
- data/spec/perfomance_spec/app/Customer/customer.rb +6 -0
- data/spec/perfomance_spec/app/Perftest/index.erb +5 -0
- data/spec/perfomance_spec/app/Product/index.erb +25 -0
- data/spec/perfomance_spec/app/Product/product.rb +6 -0
- data/spec/perfomance_spec/app/helpers/application_helper.rb +126 -0
- data/spec/perfomance_spec/app/helpers/browser_helper.rb +18 -0
- data/spec/perfomance_spec/rhoconfig.txt +1 -1
- data/spec/phone_spec/app/Account_s/account_s.rb +5 -2
- data/spec/phone_spec/app/Case/case.rb +1 -0
- data/spec/phone_spec/app/Case_s/case_s.rb +2 -0
- data/spec/phone_spec/app/Data/perftest.json +35 -0
- data/spec/phone_spec/app/Data/testCDATA.xml +11 -0
- data/spec/phone_spec/app/Product/product.rb +1 -1
- data/spec/phone_spec/app/{Spec → spec}/asynchttp_spec.rb +66 -17
- data/spec/phone_spec/app/{Spec → spec}/barcode_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/blobsync_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/bsearch_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/bulksync_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/contacts_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/crypt_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/date_spec.rb +0 -0
- data/spec/phone_spec/app/spec/events_spec.rb +199 -0
- data/spec/phone_spec/app/{Spec → spec}/fixtures/client_info.txt +0 -0
- data/spec/phone_spec/app/{Spec → spec}/fixtures/object_values.txt +0 -0
- data/spec/phone_spec/app/{Spec → spec}/json_spec.rb +11 -2
- data/spec/phone_spec/app/{Spec → spec}/mapview_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/nativebar_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/navbar_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/pagination/fixtures/object_values.txt +0 -0
- data/spec/phone_spec/app/{Spec → spec}/rho_controller_spec.rb +5 -0
- data/spec/phone_spec/app/{Spec → spec}/rho_spec.rb +48 -0
- data/spec/phone_spec/app/{Spec → spec}/rhofile_spec.rb +9 -6
- data/spec/phone_spec/app/{Spec → spec}/rhom_object_spec.rb +188 -9
- data/spec/phone_spec/app/{Spec → spec}/syncengine_spec.rb +0 -0
- data/spec/phone_spec/app/{Spec → spec}/xml_spec.rb +15 -0
- data/spec/phone_spec/app/{Spec → spec}/xruby_spec.rb +0 -0
- data/spec/phone_spec/app/spec_runner.rb +4 -1
- data/spec/phone_spec/build.yml +2 -1
- metadata +95 -31
- data/platform/bb/rhodes/platform/5.0/com/rho/RhoMainScreen.java +0 -36
- data/platform/bb/rhodes/platform/6.0/com/rho/BrowserAdapter5.java +0 -155
- data/platform/bb/rhodes/platform/6.0/com/rho/RhoMainScreen.java +0 -36
@@ -0,0 +1,300 @@
|
|
1
|
+
//
|
2
|
+
// Event.m
|
3
|
+
// rhorunner
|
4
|
+
//
|
5
|
+
// Created by Dmitry Moskalchuk on 16.09.10.
|
6
|
+
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "Event.h"
|
10
|
+
#import "Rhodes.h"
|
11
|
+
|
12
|
+
#include "ruby.h"
|
13
|
+
#include "ruby/ext/rho/rhoruby.h"
|
14
|
+
#include "ruby/ext/calendar/event.h"
|
15
|
+
|
16
|
+
#include "logging/RhoLogConf.h"
|
17
|
+
#include "logging/RhoLog.h"
|
18
|
+
|
19
|
+
#undef DEFAULT_LOGCATEGORY
|
20
|
+
#define DEFAULT_LOGCATEGORY "Event"
|
21
|
+
|
22
|
+
static void calendar_check()
|
23
|
+
{
|
24
|
+
#if defined(__IPHONE_4_0)
|
25
|
+
NSString *version = [[UIDevice currentDevice] systemVersion];
|
26
|
+
if ([version hasPrefix:@"3."] || [version hasPrefix:@"2."])
|
27
|
+
#endif
|
28
|
+
rb_raise(rb_eRuntimeError, "No calendar support on this device");
|
29
|
+
}
|
30
|
+
|
31
|
+
#ifdef __IPHONE_4_0
|
32
|
+
static VALUE dateToRuby(NSDate *date)
|
33
|
+
{
|
34
|
+
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
|
35
|
+
unsigned unitFlags = NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit;
|
36
|
+
NSDateComponents *dateComponents = [gregorian components:unitFlags fromDate:date];
|
37
|
+
unitFlags = NSHourCalendarUnit|NSMinuteCalendarUnit|NSSecondCalendarUnit;
|
38
|
+
NSDateComponents *timeComponents = [gregorian components:unitFlags fromDate:date];
|
39
|
+
|
40
|
+
int year = [dateComponents year];
|
41
|
+
int month = [dateComponents month];
|
42
|
+
int day = [dateComponents day];// - 1;
|
43
|
+
int hour = [timeComponents hour];
|
44
|
+
int minute = [timeComponents minute];
|
45
|
+
int second = [timeComponents second];
|
46
|
+
|
47
|
+
[gregorian release];
|
48
|
+
|
49
|
+
VALUE rDate = rb_funcall(rb_cTime, rb_intern("utc"), 7, INT2FIX(year), INT2FIX(month), INT2FIX(day),
|
50
|
+
INT2FIX(hour), INT2FIX(minute), INT2FIX(second), INT2FIX(0));
|
51
|
+
return rDate;
|
52
|
+
}
|
53
|
+
|
54
|
+
static NSDate *dateFromRuby(VALUE rDate)
|
55
|
+
{
|
56
|
+
if (TYPE(rDate) == T_STRING) {
|
57
|
+
// Convert to time
|
58
|
+
ID id_parse = rb_intern("parse");
|
59
|
+
rDate = rb_funcall(rb_cTime, id_parse, 1, rDate);
|
60
|
+
}
|
61
|
+
|
62
|
+
VALUE cDate = rb_class_of(rDate);
|
63
|
+
if (!rb_equal(cDate, rb_cTime))
|
64
|
+
rb_raise(rb_eArgError, "Wrong type of parameter: %s (Time expected)", rb_class2name(cDate));
|
65
|
+
|
66
|
+
ID id_gmtime = rb_intern("gmtime");
|
67
|
+
ID id_year = rb_intern("year");
|
68
|
+
ID id_month = rb_intern("month");
|
69
|
+
ID id_day = rb_intern("day");
|
70
|
+
ID id_hour = rb_intern("hour");
|
71
|
+
ID id_min = rb_intern("min");
|
72
|
+
ID id_sec = rb_intern("sec");
|
73
|
+
|
74
|
+
// Get GM time
|
75
|
+
rDate = rb_funcall(rDate, id_gmtime, 0);
|
76
|
+
|
77
|
+
int year = FIX2INT(rb_funcall(rDate, id_year, 0));
|
78
|
+
int month = FIX2INT(rb_funcall(rDate, id_month, 0));
|
79
|
+
int day = FIX2INT(rb_funcall(rDate, id_day, 0));// + 1;
|
80
|
+
int hour = FIX2INT(rb_funcall(rDate, id_hour, 0));
|
81
|
+
int minute = FIX2INT(rb_funcall(rDate, id_min, 0));
|
82
|
+
int second = FIX2INT(rb_funcall(rDate, id_sec, 0));
|
83
|
+
|
84
|
+
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
|
85
|
+
[dateComponents setYear:year];
|
86
|
+
[dateComponents setMonth:month];
|
87
|
+
[dateComponents setDay:day];
|
88
|
+
[dateComponents setHour:hour];
|
89
|
+
[dateComponents setMinute:minute];
|
90
|
+
[dateComponents setSecond:second];
|
91
|
+
|
92
|
+
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
|
93
|
+
|
94
|
+
NSDate *date = [gregorian dateFromComponents:dateComponents];
|
95
|
+
|
96
|
+
[gregorian release];
|
97
|
+
[dateComponents release];
|
98
|
+
|
99
|
+
return date;
|
100
|
+
}
|
101
|
+
|
102
|
+
static VALUE eventToRuby(EKEvent *event)
|
103
|
+
{
|
104
|
+
if (!event)
|
105
|
+
return Qnil;
|
106
|
+
|
107
|
+
VALUE rEvent = rho_ruby_createHash();
|
108
|
+
const char *eid = [event.eventIdentifier UTF8String];
|
109
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_ID), rb_str_new2(eid));
|
110
|
+
if (event.title) {
|
111
|
+
const char *title = [event.title UTF8String];
|
112
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_TITLE), rb_str_new2(title));
|
113
|
+
}
|
114
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_CANCELED), rho_ruby_create_boolean(event.status == EKEventStatusCanceled));
|
115
|
+
if (event.organizer) {
|
116
|
+
const char *oname = [event.organizer.name UTF8String];
|
117
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_ORGANIZER), rb_str_new2(oname));
|
118
|
+
}
|
119
|
+
|
120
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_START_DATE), dateToRuby(event.startDate));
|
121
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_END_DATE), dateToRuby(event.endDate));
|
122
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_LAST_MODIFIED), dateToRuby(event.lastModifiedDate));
|
123
|
+
if (event.location) {
|
124
|
+
const char *location = [event.location UTF8String];
|
125
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_LOCATION), rb_str_new2(location));
|
126
|
+
}
|
127
|
+
if (event.notes) {
|
128
|
+
const char *notes = [event.notes UTF8String];
|
129
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_NOTES), rb_str_new2(notes));
|
130
|
+
}
|
131
|
+
|
132
|
+
if (event.recurrenceRule) {
|
133
|
+
VALUE rRecurrence = rb_hash_new();
|
134
|
+
const char *s;
|
135
|
+
switch (event.recurrenceRule.frequency) {
|
136
|
+
case EKRecurrenceFrequencyDaily: s = RUBY_EV_RECURRENCE_FREQUENCY_DAILY; break;
|
137
|
+
case EKRecurrenceFrequencyWeekly: s = RUBY_EV_RECURRENCE_FREQUENCY_WEEKLY; break;
|
138
|
+
case EKRecurrenceFrequencyMonthly: s = RUBY_EV_RECURRENCE_FREQUENCY_MONTHLY; break;
|
139
|
+
case EKRecurrenceFrequencyYearly: s = RUBY_EV_RECURRENCE_FREQUENCY_YEARLY; break;
|
140
|
+
default: s = "undefined";
|
141
|
+
}
|
142
|
+
rb_hash_aset(rRecurrence, rb_str_new2(RUBY_EV_RECURRENCE_FREQUENCY), rb_str_new2(s));
|
143
|
+
|
144
|
+
int interval = event.recurrenceRule.interval;
|
145
|
+
rb_hash_aset(rRecurrence, rb_str_new2(RUBY_EV_RECURRENCE_INTERVAL), INT2FIX(interval));
|
146
|
+
|
147
|
+
rb_hash_aset(rEvent, rb_str_new2(RUBY_EV_RECURRENCE), rRecurrence);
|
148
|
+
}
|
149
|
+
|
150
|
+
return rEvent;
|
151
|
+
}
|
152
|
+
|
153
|
+
static EKEvent *eventFromRuby(EKEventStore *eventStore, VALUE rEvent)
|
154
|
+
{
|
155
|
+
VALUE rId = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_ID));
|
156
|
+
if (!NIL_P(rId))
|
157
|
+
Check_Type(rId, T_STRING);
|
158
|
+
|
159
|
+
EKEvent *event = nil;
|
160
|
+
if (NIL_P(rId) || strlen(RSTRING_PTR(rId)) == 0) {
|
161
|
+
// New event
|
162
|
+
event = [EKEvent eventWithEventStore:eventStore];
|
163
|
+
event.calendar = [eventStore defaultCalendarForNewEvents];
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
// Existing event
|
167
|
+
const char *sid = RSTRING_PTR(rId);
|
168
|
+
event = [eventStore eventWithIdentifier:[NSString stringWithUTF8String:sid]];
|
169
|
+
}
|
170
|
+
|
171
|
+
VALUE rTitle = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_TITLE));
|
172
|
+
if (!NIL_P(rTitle)) {
|
173
|
+
Check_Type(rTitle, T_STRING);
|
174
|
+
event.title = [NSString stringWithUTF8String:RSTRING_PTR(rTitle)];
|
175
|
+
}
|
176
|
+
|
177
|
+
VALUE rStartDate = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_START_DATE));
|
178
|
+
if (!NIL_P(rStartDate))
|
179
|
+
event.startDate = dateFromRuby(rStartDate);
|
180
|
+
VALUE rEndDate = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_END_DATE));
|
181
|
+
if (!NIL_P(rEndDate))
|
182
|
+
event.endDate = dateFromRuby(rEndDate);
|
183
|
+
|
184
|
+
VALUE rLocation = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_LOCATION));
|
185
|
+
if (!NIL_P(rLocation)) {
|
186
|
+
Check_Type(rLocation, T_STRING);
|
187
|
+
event.location = [NSString stringWithUTF8String:RSTRING_PTR(rLocation)];
|
188
|
+
}
|
189
|
+
|
190
|
+
VALUE rNotes = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_NOTES));
|
191
|
+
if (!NIL_P(rNotes)) {
|
192
|
+
Check_Type(rNotes, T_STRING);
|
193
|
+
event.notes = [NSString stringWithUTF8String:RSTRING_PTR(rNotes)];
|
194
|
+
}
|
195
|
+
|
196
|
+
VALUE rRecurrence = rb_hash_aref(rEvent, rb_str_new2(RUBY_EV_RECURRENCE));
|
197
|
+
if (!NIL_P(rRecurrence)) {
|
198
|
+
Check_Type(rRecurrence, T_HASH);
|
199
|
+
VALUE rFrequency = rb_hash_aref(rRecurrence, rb_str_new2(RUBY_EV_RECURRENCE_FREQUENCY));
|
200
|
+
Check_Type(rFrequency, T_STRING);
|
201
|
+
const char *frequency = RSTRING_PTR(rFrequency);
|
202
|
+
|
203
|
+
EKRecurrenceFrequency freq;
|
204
|
+
if (strcasecmp(frequency, RUBY_EV_RECURRENCE_FREQUENCY_DAILY) == 0)
|
205
|
+
freq = EKRecurrenceFrequencyDaily;
|
206
|
+
else if (strcasecmp(frequency, RUBY_EV_RECURRENCE_FREQUENCY_WEEKLY) == 0)
|
207
|
+
freq = EKRecurrenceFrequencyWeekly;
|
208
|
+
else if (strcasecmp(frequency, RUBY_EV_RECURRENCE_FREQUENCY_MONTHLY) == 0)
|
209
|
+
freq = EKRecurrenceFrequencyMonthly;
|
210
|
+
else if (strcasecmp(frequency, RUBY_EV_RECURRENCE_FREQUENCY_YEARLY) == 0)
|
211
|
+
freq = EKRecurrenceFrequencyYearly;
|
212
|
+
else
|
213
|
+
rb_raise(rb_eArgError, "Wrong recurrence frequency: %s", frequency);
|
214
|
+
|
215
|
+
VALUE rInterval = rb_hash_aref(rRecurrence, rb_str_new2(RUBY_EV_RECURRENCE_INTERVAL));
|
216
|
+
rInterval = rb_funcall(rInterval, rb_intern("to_i"), 0);
|
217
|
+
int interval = NUM2INT(rInterval);
|
218
|
+
|
219
|
+
EKRecurrenceRule *rule = [[EKRecurrenceRule alloc] initRecurrenceWithFrequency:freq interval:interval end:nil];
|
220
|
+
event.recurrenceRule = rule;
|
221
|
+
[rule release];
|
222
|
+
}
|
223
|
+
|
224
|
+
return event;
|
225
|
+
}
|
226
|
+
#endif // __IPHONE_4_0
|
227
|
+
|
228
|
+
VALUE event_fetch(VALUE rParams)
|
229
|
+
{
|
230
|
+
calendar_check();
|
231
|
+
|
232
|
+
#if defined(__IPHONE_4_0)
|
233
|
+
VALUE start_date = rb_hash_aref(rParams, rb_str_new2(RUBY_EV_START_DATE));
|
234
|
+
VALUE end_date = rb_hash_aref(rParams, rb_str_new2(RUBY_EV_END_DATE));
|
235
|
+
int include_repeating = rho_ruby_get_bool(rb_hash_aref(rParams, rb_str_new2(RUBY_FETCH_include_repeating)));
|
236
|
+
|
237
|
+
NSDate *start = dateFromRuby(start_date);
|
238
|
+
NSDate *finish = dateFromRuby(end_date);
|
239
|
+
|
240
|
+
EKEventStore *eventStore = [[Rhodes sharedInstance] eventStore];
|
241
|
+
NSPredicate *pred = [eventStore predicateForEventsWithStartDate:start endDate:finish calendars:nil];
|
242
|
+
NSArray *events = [eventStore eventsMatchingPredicate:pred];
|
243
|
+
|
244
|
+
VALUE ret = rho_ruby_create_array();
|
245
|
+
|
246
|
+
for (int i = 0, lim = [events count]; i != lim; ++i) {
|
247
|
+
EKEvent *event = [events objectAtIndex:i];
|
248
|
+
if (!include_repeating && event.recurrenceRule)
|
249
|
+
continue;
|
250
|
+
VALUE rEvent = eventToRuby(event);
|
251
|
+
rho_ruby_add_to_array(ret, rEvent);
|
252
|
+
}
|
253
|
+
|
254
|
+
return ret;
|
255
|
+
#endif
|
256
|
+
}
|
257
|
+
|
258
|
+
VALUE event_fetch_by_id(const char *eid)
|
259
|
+
{
|
260
|
+
calendar_check();
|
261
|
+
|
262
|
+
#if defined(__IPHONE_4_0)
|
263
|
+
EKEventStore *eventStore = [[Rhodes sharedInstance] eventStore];
|
264
|
+
EKEvent *event = [eventStore eventWithIdentifier:[NSString stringWithUTF8String:eid]];
|
265
|
+
|
266
|
+
return eventToRuby(event);
|
267
|
+
#endif
|
268
|
+
}
|
269
|
+
|
270
|
+
void event_save(VALUE rEvent)
|
271
|
+
{
|
272
|
+
calendar_check();
|
273
|
+
|
274
|
+
#if defined(__IPHONE_4_0)
|
275
|
+
EKEventStore *eventStore = [[Rhodes sharedInstance] eventStore];
|
276
|
+
|
277
|
+
EKEvent *event = eventFromRuby(eventStore, rEvent);
|
278
|
+
|
279
|
+
NSError *err;
|
280
|
+
BOOL saved = [eventStore saveEvent:event span:EKSpanFutureEvents error:&err];
|
281
|
+
|
282
|
+
if (!saved)
|
283
|
+
rb_raise(rb_eRuntimeError, "Event save failed: %s", [[err localizedDescription] UTF8String]);
|
284
|
+
#endif
|
285
|
+
}
|
286
|
+
|
287
|
+
void event_delete(const char *eid)
|
288
|
+
{
|
289
|
+
calendar_check();
|
290
|
+
|
291
|
+
#if defined(__IPHONE_4_0)
|
292
|
+
EKEventStore *eventStore = [[Rhodes sharedInstance] eventStore];
|
293
|
+
EKEvent *event = [eventStore eventWithIdentifier:[NSString stringWithUTF8String:eid]];
|
294
|
+
NSError *err;
|
295
|
+
BOOL removed = [eventStore removeEvent:event span:EKSpanFutureEvents error:&err];
|
296
|
+
|
297
|
+
if (!removed)
|
298
|
+
rb_raise(rb_eRuntimeError, "Event was not removed: %s", [[err localizedDescription] UTF8String]);
|
299
|
+
#endif
|
300
|
+
}
|
@@ -8,8 +8,9 @@
|
|
8
8
|
|
9
9
|
#import <UIKit/UIKit.h>
|
10
10
|
#import <Foundation/Foundation.h>
|
11
|
+
#import "RhoViewController.h"
|
11
12
|
|
12
|
-
@interface LogOptionsController :
|
13
|
+
@interface LogOptionsController : RhoViewController <UIScrollViewDelegate, UITextViewDelegate, UIPickerViewDelegate> {
|
13
14
|
UITableView *tableView;
|
14
15
|
UITextView *textViewEnabledCategories;
|
15
16
|
UITextView *textViewDisabledCategories;
|
@@ -161,7 +161,7 @@
|
|
161
161
|
text = textViewDisabledCategories.text;
|
162
162
|
categories = [text cStringUsingEncoding:[NSString defaultCStringEncoding]];
|
163
163
|
rho_logconf_setDisabledCategories(categories);
|
164
|
-
|
164
|
+
rho_logconf_setSeverity(selectedRow);
|
165
165
|
rho_logconf_saveSettings();
|
166
166
|
|
167
167
|
[self dismissModalViewControllerAnimated:YES];
|
@@ -8,8 +8,9 @@
|
|
8
8
|
|
9
9
|
#import <UIKit/UIKit.h>
|
10
10
|
#import <Foundation/Foundation.h>
|
11
|
+
#import "RhoViewController.h"
|
11
12
|
|
12
|
-
@interface LogViewController :
|
13
|
+
@interface LogViewController : RhoViewController <UIScrollViewDelegate, UITextViewDelegate> {
|
13
14
|
UITextView *textView;
|
14
15
|
|
15
16
|
@public
|
@@ -11,10 +11,11 @@
|
|
11
11
|
#import <MapKit/MKAnnotation.h>
|
12
12
|
#import <MapKit/MKReverseGeocoder.h>
|
13
13
|
#import "GoogleGeocoder.h"
|
14
|
+
#import "RhoViewController.h"
|
14
15
|
|
15
16
|
#include "ruby/ext/rho/rhoruby.h"
|
16
17
|
|
17
|
-
@interface MapViewController :
|
18
|
+
@interface MapViewController : RhoViewController <MKReverseGeocoderDelegate,MKMapViewDelegate> {
|
18
19
|
MKMapView *mapView;
|
19
20
|
MKReverseGeocoder *geoCoder;
|
20
21
|
GoogleGeocoder* ggeoCoder;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//
|
2
|
+
// RhoViewController.h
|
3
|
+
// rhorunner
|
4
|
+
//
|
5
|
+
// Created by Dmitry Moskalchuk on 13.09.10.
|
6
|
+
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <Foundation/Foundation.h>
|
10
|
+
|
11
|
+
|
12
|
+
@interface RhoViewController : UIViewController {}
|
13
|
+
|
14
|
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
|
15
|
+
|
16
|
+
@end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
//
|
2
|
+
// RhoViewController.m
|
3
|
+
// rhorunner
|
4
|
+
//
|
5
|
+
// Created by Dmitry Moskalchuk on 13.09.10.
|
6
|
+
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "Rhodes.h"
|
10
|
+
#import "RhoViewController.h"
|
11
|
+
|
12
|
+
@implementation RhoViewController
|
13
|
+
|
14
|
+
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
|
15
|
+
if ([[Rhodes sharedInstance] isRotationLocked])
|
16
|
+
return interfaceOrientation == UIInterfaceOrientationPortrait;
|
17
|
+
return YES;
|
18
|
+
}
|
19
|
+
|
20
|
+
@end
|
@@ -9,6 +9,9 @@
|
|
9
9
|
|
10
10
|
#import <UIKit/UIKit.h>
|
11
11
|
#import <AVFoundation/AVFoundation.h>
|
12
|
+
#ifdef __IPHONE_4_0
|
13
|
+
#import <EventKit/EventKit.h>
|
14
|
+
#endif
|
12
15
|
#import "AppManager.h"
|
13
16
|
#import "RhoMainView.h"
|
14
17
|
|
@@ -34,14 +37,21 @@
|
|
34
37
|
DateTimePickerDelegate* dateTimePickerDelegate;
|
35
38
|
PickImageDelegate* pickImageDelegate;
|
36
39
|
SignatureDelegate* signatureDelegate;
|
40
|
+
#ifdef __IPHONE_4_0
|
41
|
+
EKEventStore *eventStore;
|
42
|
+
#endif
|
37
43
|
|
38
44
|
id<RhoMainView,NSObject> mainView;
|
45
|
+
BOOL rotationLocked;
|
39
46
|
}
|
40
47
|
|
41
48
|
@property (nonatomic, retain) UIWindow *window;
|
42
49
|
@property (nonatomic, retain) AVAudioPlayer *player;
|
43
50
|
@property (nonatomic, retain) NSMutableDictionary *cookies;
|
44
51
|
@property (nonatomic, copy) SignatureDelegate* signatureDelegate;
|
52
|
+
#ifdef __IPHONE_4_0
|
53
|
+
@property (nonatomic, readonly) EKEventStore *eventStore;
|
54
|
+
#endif
|
45
55
|
|
46
56
|
+ (Rhodes*)sharedInstance;
|
47
57
|
|
@@ -50,6 +60,8 @@
|
|
50
60
|
+ (CGRect)applicationFrame;
|
51
61
|
+ (void)setStatusBarHidden:(BOOL)v;
|
52
62
|
|
63
|
+
- (BOOL)isRotationLocked;
|
64
|
+
|
53
65
|
//+ (UIView*)subviewWithTag:(NSInteger)tag ofView:(UIView*)view;
|
54
66
|
|
55
67
|
+ (void)performOnUiThread:(id)runnable wait:(BOOL)wait;
|
@@ -23,10 +23,6 @@ static BOOL app_created = NO;
|
|
23
23
|
|
24
24
|
@implementation RhoActivateTask
|
25
25
|
+ (void)run {
|
26
|
-
if (!app_created) {
|
27
|
-
[Rhodes performOnUiThread:[RhoActivateTask class] wait:NO];
|
28
|
-
return;
|
29
|
-
}
|
30
26
|
rho_rhodesapp_callAppActiveCallback(1);
|
31
27
|
}
|
32
28
|
@end
|
@@ -35,6 +31,9 @@ static BOOL app_created = NO;
|
|
35
31
|
@implementation Rhodes
|
36
32
|
|
37
33
|
@synthesize window, player, cookies, signatureDelegate;
|
34
|
+
#ifdef __IPHONE_4_0
|
35
|
+
@synthesize eventStore;
|
36
|
+
#endif
|
38
37
|
|
39
38
|
static Rhodes *instance = NULL;
|
40
39
|
|
@@ -130,6 +129,10 @@ static Rhodes *instance = NULL;
|
|
130
129
|
[[Rhodes sharedInstance] performSelectorOnMainThread:@selector(runRunnable:) withObject:args waitUntilDone:wait];
|
131
130
|
}
|
132
131
|
|
132
|
+
- (BOOL)isRotationLocked {
|
133
|
+
return rotationLocked;
|
134
|
+
}
|
135
|
+
|
133
136
|
- (void)openMapLocation:(NSString*)query {
|
134
137
|
[self hideSplash];
|
135
138
|
NSURL* url = [NSURL URLWithString:[@"http://maps.google.com/?" stringByAppendingString:query]];
|
@@ -282,7 +285,6 @@ static Rhodes *instance = NULL;
|
|
282
285
|
|
283
286
|
}
|
284
287
|
|
285
|
-
|
286
288
|
- (void)choosePicture:(NSString*) url {
|
287
289
|
if (!rho_rhodesapp_check_mode())
|
288
290
|
return;
|
@@ -340,6 +342,20 @@ static Rhodes *instance = NULL;
|
|
340
342
|
}
|
341
343
|
}
|
342
344
|
|
345
|
+
- (void)doRhoActivate {
|
346
|
+
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
347
|
+
@try {
|
348
|
+
NSLog(@"doRhoActivate thread started");
|
349
|
+
while (!app_created)
|
350
|
+
[NSThread sleepForTimeInterval:0.1];
|
351
|
+
[Rhodes performOnUiThread:[RhoActivateTask class] wait:NO];
|
352
|
+
}
|
353
|
+
@finally {
|
354
|
+
NSLog(@"doRhoActivate thread finished");
|
355
|
+
[pool release];
|
356
|
+
}
|
357
|
+
}
|
358
|
+
|
343
359
|
- (void)doRhoInit {
|
344
360
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
345
361
|
@try {
|
@@ -355,6 +371,8 @@ static Rhodes *instance = NULL;
|
|
355
371
|
rho_rhodesapp_create(szRootPath);
|
356
372
|
app_created = YES;
|
357
373
|
|
374
|
+
rotationLocked = rho_conf_getBool("disable_screen_rotation");
|
375
|
+
|
358
376
|
NSLog(@"Show loading page");
|
359
377
|
[self performSelectorOnMainThread:@selector(showLoadingPage) withObject:nil waitUntilDone:NO];
|
360
378
|
|
@@ -370,6 +388,7 @@ static Rhodes *instance = NULL;
|
|
370
388
|
NSLog(@"Rhodes starting application...");
|
371
389
|
instance = self;
|
372
390
|
application = [UIApplication sharedApplication];
|
391
|
+
rotationLocked = YES;
|
373
392
|
|
374
393
|
[NSThread setThreadPriority:1.0];
|
375
394
|
|
@@ -409,6 +428,10 @@ static Rhodes *instance = NULL;
|
|
409
428
|
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
|
410
429
|
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
|
411
430
|
#endif
|
431
|
+
|
432
|
+
#ifdef __IPHONE_4_0
|
433
|
+
eventStore = [[EKEventStore alloc] init];
|
434
|
+
#endif
|
412
435
|
|
413
436
|
NSLog(@"Initialization finished");
|
414
437
|
}
|
@@ -611,7 +634,12 @@ static Rhodes *instance = NULL;
|
|
611
634
|
|
612
635
|
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
613
636
|
RAWLOG_INFO("Application did become active");
|
614
|
-
|
637
|
+
if (!app_created) {
|
638
|
+
NSLog(@"Application is not created yet so postpone activation callback");
|
639
|
+
[NSThread detachNewThreadSelector:@selector(doRhoActivate) toTarget:self withObject:nil];
|
640
|
+
}
|
641
|
+
else
|
642
|
+
[Rhodes performOnUiThread:[RhoActivateTask class] wait:NO];
|
615
643
|
}
|
616
644
|
|
617
645
|
- (void)applicationWillResignActive:(UIApplication *)application {
|