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>
33 class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
36 using Converter::toJSValueRef;
38 explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE);
39 virtual ~CalendarConverter();
41 CalendarEventPtr toEvent(const JSValueRef event);
42 CalendarEventListPtr toVectorOfEvents(JSValueRef events);
43 CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events);
44 StringArrayPtr toCategories(JSValueRef categories);
45 EventAttendeePtr toAttendee(JSValueRef attendee);
46 EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees);
47 EventAttendeeListPtr toVectorOfAttendeesFromReference(JSValueRef attendees);
49 EventAlarm::EventAlarmType toEventAlarmType(std::string tizenValue) const;
50 CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const;
51 EventRecurrenceRule::EventRecurrence toRecurrenceFrequency(std::string tizenValue) const;
52 EventRecurrenceRulePtr toEventRecurrenceRule(JSValueRef rrule);
54 CalendarEvent::EventVisibility toEventVisibility(std::string tizenValue) const;
55 CalendarEvent::EventAvailability toEventAvailability(std::string tizenValue) const;
56 EventAttendee::EventAttendeeRole toEventAttendeeRole(std::string tizenValue) const;
57 EventAttendee::EventAttendeeStatus toEventAttendeeStatus(std::string tizenValue) const;
58 EventAttendee::EventAttendeeType toEventAttendeeType(std::string tizenValue) const;
60 std::string toTizenValue(EventAlarm::EventAlarmType abstractValue) const;
61 std::string toTizenValue(CalendarEvent::EventStatus abstractValue) const;
62 std::string toTizenValue(EventRecurrenceRule::EventRecurrence abstractValue) const;
63 std::string toTizenValue(CalendarEvent::EventVisibility abstractValue) const;
64 std::string toTizenValue(CalendarEvent::EventAvailability abstractValue) const;
65 std::string toTizenValue(EventAttendee::EventAttendeeRole abstractValue) const;
66 std::string toTizenValue(EventAttendee::EventAttendeeStatus abstractValue) const;
67 std::string toTizenValue(EventAttendee::EventAttendeeType abstractValue) const;
68 std::string toTizenValue(CalendarEvent::TaskPriority abstractValue) const;
70 JSValueRef toJSValueRefEvent(const CalendarEventPtr& arg);
71 JSValueRef toJSValueRefTask(const CalendarEventPtr& arg);
72 JSValueRef toJSValueRefEventArray(const CalendarEventListPtr &arg);
73 JSValueRef toJSValueRefTaskArray(const CalendarEventListPtr &arg);
74 JSValueRef toJSValueRefCalendar(const ICalendarPtr& arg);
75 JSValueRef toJSValueRef(const std::vector<ICalendarPtr> &arg);
76 JSValueRef toJSValueRef(const StringArrayPtr &arg);
77 JSValueRef toJSValueRefNumberArray(const NumberArrayPtr &arg);
78 JSValueRef toJSValueRefTZDateArray(const NumberArrayPtr &arg);
79 StringArrayPtr toStringArray(const JSValueRef &jsValue);
80 NumberArrayPtr toNumberArray(const JSValueRef &jsValue);
81 NumberArrayPtr toTZDateArray(const JSValueRef &jsValue);
83 EventAlarmPtr toEventAlarm(JSValueRef alarm);
84 EventAlarmListPtr toVectorOfEventAlarmsFromDictionary(JSValueRef alarms);
85 EventAlarmListPtr toVectorOfEventAlarmsFromReference(JSValueRef alarms);
86 EventIdPtr toEventId(JSValueRef eventId);
87 EventIdListPtr toVectorOfEventIds(JSValueRef eventIds);
88 std::vector<long long int> toVectorOfTimeFromTZDate(JSValueRef dates);
89 CalendarEvent::TaskPriority toTaskPriority(std::string priority) const;
90 CalendarEvent::CalendarType toCalendarType(std::string type) const;
91 CalendarEvent::VObjectFormat toVObjectFormat(std::string type) const;
94 * @throw InvalidArgumentException If not a callback nor JS null.
96 JSValueRef toFunctionOrNull(const JSValueRef& arg);
99 * @throw ConversionException If JS null.
100 * @throw InvalidArgumentException If not a callback nor JS null.
102 JSValueRef toFunction(const JSValueRef& arg);
105 CalendarEvent::CalendarType m_calendarType;
111 #endif /* _JS_TIZEN_CALENDAR_CONVERTER_H_ */