Update change log and spec for wrt-plugins-tizen_0.4.70
[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 #include <Security.h>
30
31 namespace DeviceAPI {
32 namespace Calendar {
33
34 class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
35 {
36   public:
37     using Converter::toJSValueRef;
38   public:
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();
44
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);
52
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);
57
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;
63
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;
73
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);
86
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;
96
97     /**
98      * @throw InvalidArgumentException If not a callback nor JS null.
99      */
100     JSValueRef toFunctionOrNull(const JSValueRef& arg);
101
102     /**
103      * @throw ConversionException If JS null.
104      * @throw InvalidArgumentException If not a callback nor JS null.
105      */
106     JSValueRef toFunction(const JSValueRef& arg);
107
108   private:
109     CalendarEvent::CalendarType m_calendarType;
110     DeviceAPI::Common::SecurityAccessor* m_securityAccessor;
111 };
112
113 }
114 }
115
116 #endif /* _JS_TIZEN_CALENDAR_CONVERTER_H_ */