2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #ifndef _JS_TIZEN_CALENDAR_CONVERTER_H_
20 #define _JS_TIZEN_CALENDAR_CONVERTER_H_
24 #include "ICalendar.h"
25 #include "EventAttendee.h"
26 #include "EventAlarm.h"
27 #include <CommonsJavaScript/Converter.h>
28 #include <CommonsJavaScript/ScopedJSStringRef.h>
34 class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
37 using Converter::toJSValueRef;
39 explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE,
40 DeviceAPI::Common::SecurityAccessor *securityAccessor=NULL);
41 explicit CalendarConverter(JSContextRef context, DeviceAPI::Common::SecurityAccessor *securityAccessor,
42 CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE);
43 virtual ~CalendarConverter();
45 CalendarEventPtr toItem(const JSValueRef value, bool updateMode);
46 CalendarEventListPtr toVectorOfItems(JSValueRef items);
47 CalendarEventListPtr toVectorOfItemsFromDictionary(JSValueRef items, bool updateMode);
48 StringArrayPtr toCategories(JSValueRef categories);
49 EventAttendeePtr toAttendee(JSValueRef attendee);
50 EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees);
51 EventAttendeeListPtr toVectorOfAttendeesFromReference(JSValueRef attendees);
53 EventAlarm::EventAlarmType toEventAlarmType(std::string tizenValue) const;
54 CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const;
55 EventRecurrenceRule::EventRecurrence toRecurrenceFrequency(std::string tizenValue) const;
56 EventRecurrenceRulePtr toEventRecurrenceRule(JSValueRef rrule);
58 CalendarEvent::EventVisibility toEventVisibility(std::string tizenValue) const;
59 CalendarEvent::EventAvailability toEventAvailability(std::string tizenValue) const;
60 EventAttendee::EventAttendeeRole toEventAttendeeRole(std::string tizenValue) const;
61 EventAttendee::EventAttendeeStatus toEventAttendeeStatus(std::string tizenValue) const;
62 EventAttendee::EventAttendeeType toEventAttendeeType(std::string tizenValue) const;
64 std::string toTizenValue(EventAlarm::EventAlarmType abstractValue) const;
65 std::string toTizenValue(CalendarEvent::EventStatus abstractValue) const;
66 std::string toTizenValue(EventRecurrenceRule::EventRecurrence abstractValue) const;
67 std::string toTizenValue(CalendarEvent::EventVisibility abstractValue) const;
68 std::string toTizenValue(CalendarEvent::EventAvailability abstractValue) const;
69 std::string toTizenValue(EventAttendee::EventAttendeeRole abstractValue) const;
70 std::string toTizenValue(EventAttendee::EventAttendeeStatus abstractValue) const;
71 std::string toTizenValue(EventAttendee::EventAttendeeType abstractValue) const;
72 std::string toTizenValue(CalendarEvent::TaskPriority abstractValue) const;
74 JSValueRef toJSValueRefEvent(const CalendarEventPtr& arg);
75 JSValueRef toJSValueRefTask(const CalendarEventPtr& arg);
76 JSValueRef toJSValueRefEventArray(const CalendarEventListPtr &arg);
77 JSValueRef toJSValueRefTaskArray(const CalendarEventListPtr &arg);
78 JSValueRef toJSValueRefCalendar(const ICalendarPtr& arg);
79 JSValueRef toJSValueRef(const std::vector<ICalendarPtr> &arg);
80 JSValueRef toJSValueRefStringArray(const StringArrayPtr &arg);
81 JSValueRef toJSValueRefNumberArray(const NumberArrayPtr &arg);
82 JSValueRef toJSValueRefTZDateArray(const NumberArrayPtr &arg, const std::string &timeZone);
83 StringArrayPtr toStringArray(const JSValueRef &jsValue);
84 NumberArrayPtr toNumberArray(const JSValueRef &jsValue);
85 NumberArrayPtr toTZDateArray(const JSValueRef &jsValue);
87 EventAlarmPtr toEventAlarm(JSValueRef alarm);
88 EventAlarmListPtr toVectorOfEventAlarmsFromDictionary(JSValueRef alarms);
89 EventAlarmListPtr toVectorOfEventAlarmsFromReference(JSValueRef alarms);
90 EventIdPtr toEventId(JSValueRef eventId);
91 EventIdListPtr toVectorOfEventIds(JSValueRef eventIds);
92 std::vector<long long int> toVectorOfTimeFromTZDate(JSValueRef dates);
93 CalendarEvent::TaskPriority toTaskPriority(std::string priority) const;
94 CalendarEvent::CalendarType toCalendarType(std::string type) const;
95 CalendarEvent::VObjectFormat toVObjectFormat(std::string type) const;
98 * @throw InvalidArgumentException If not a callback nor JS null.
100 JSValueRef toFunctionOrNull(const JSValueRef& arg);
103 * @throw ConversionException If JS null.
104 * @throw InvalidArgumentException If not a callback nor JS null.
106 JSValueRef toFunction(const JSValueRef& arg);
109 CalendarEvent::CalendarType m_calendarType;
110 DeviceAPI::Common::SecurityAccessor* m_securityAccessor;
116 #endif /* _JS_TIZEN_CALENDAR_CONVERTER_H_ */