Update change log and spec for wrt-plugins-tizen_0.4.13
[framework/web/wrt-plugins-tizen.git] / src / Calendar / CalendarConverter.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18
19 #ifndef _JS_TIZEN_CALENDAR_CONVERTER_H_
20 #define _JS_TIZEN_CALENDAR_CONVERTER_H_
21
22 #include <vector>
23 #include <string>
24 #include "ICalendar.h"
25 #include "EventAttendee.h"
26 #include "EventAlarm.h"
27 #include <CommonsJavaScript/Converter.h>
28 #include <CommonsJavaScript/ScopedJSStringRef.h>
29
30 namespace DeviceAPI {
31 namespace Calendar {
32
33 class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
34 {
35   public:
36     using Converter::toJSValueRef;
37   public:
38     explicit CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType=CalendarEvent::EVENT_TYPE);
39     virtual ~CalendarConverter();
40
41     CalendarEventPtr toItem(const JSValueRef value, bool updateMode=false);
42     CalendarEventListPtr toVectorOfItems(JSValueRef events);
43     CalendarEventListPtr toVectorOfItemsFromDictionary(JSValueRef events);
44     StringArrayPtr toCategories(JSValueRef categories);
45     EventAttendeePtr toAttendee(JSValueRef attendee);
46     EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees);
47     EventAttendeeListPtr toVectorOfAttendeesFromReference(JSValueRef attendees);
48
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);
53
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;
59
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;
69
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 toJSValueRefStringArray(const StringArrayPtr &arg);
77     JSValueRef toJSValueRefNumberArray(const NumberArrayPtr &arg);
78     JSValueRef toJSValueRefTZDateArray(const NumberArrayPtr &arg, const std::string &timeZone);
79     StringArrayPtr toStringArray(const JSValueRef &jsValue);
80     NumberArrayPtr toNumberArray(const JSValueRef &jsValue);
81     NumberArrayPtr toTZDateArray(const JSValueRef &jsValue);
82
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;
92
93     /**
94      * @throw InvalidArgumentException If not a callback nor JS null.
95      */
96     JSValueRef toFunctionOrNull(const JSValueRef& arg);
97
98     /**
99      * @throw ConversionException If JS null.
100      * @throw InvalidArgumentException If not a callback nor JS null.
101      */
102     JSValueRef toFunction(const JSValueRef& arg);
103
104   private:
105     CalendarEvent::CalendarType m_calendarType;
106 };
107
108 }
109 }
110
111 #endif /* _JS_TIZEN_CALENDAR_CONVERTER_H_ */