summaryrefslogtreecommitdiff
path: root/src/standards/Tizen/Calendar/CalendarConverter.h
blob: 7aad2b9bf06afe58e29d08a35e8d01adab5fc448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef _JS_TIZEN_CALENDAR_CONVERTER_H_
#define _JS_TIZEN_CALENDAR_CONVERTER_H_

#include <vector>
#include <string>
#include <API/Calendar/EventFilter.h>
#include <API/Calendar/ICalendar.h>
#include <API/Calendar/EventAttendee.h>
#include <API/Calendar/EventAlarm.h>
#include <CommonsJavaScript/Converter.h>
#include <CommonsJavaScript/ScopedJSStringRef.h>

namespace TizenApis {
namespace Tizen1_0 {
namespace Calendar {

class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
{
  public:
    using Converter::toJSValueRef;
  public:
    explicit CalendarConverter(JSContextRef context, TizenApis::Api::Calendar::CalendarEvent::CalendarType calendarType=TizenApis::Api::Calendar::CalendarEvent::EVENT_TYPE);
    virtual ~CalendarConverter();
    TizenApis::Api::Calendar::EventFilterPtr toEventFilter(const JSValueRef &filters);
    TizenApis::Api::Calendar::CalendarEventPtr toEvent(const JSValueRef event);
    TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEvents(JSValueRef events);
    TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events);
    TizenApis::Api::Calendar::CategoryListPtr toCategories(JSValueRef categories);
    TizenApis::Api::Calendar::EventAttendeePtr toAttendee(JSValueRef attendee);
    TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendees(JSValueRef attendees);

    TizenApis::Api::Calendar::CalendarEvent::EventAlarmType toEventAlarmType(int tizenValue) const;
    TizenApis::Api::Calendar::CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const;
    TizenApis::Api::Calendar::EventRecurrenceRule::EventRecurrence toRecurrenceFrequency(std::string tizenValue) const;
    TizenApis::Api::Calendar::EventRecurrenceRulePtr toEventRecurrenceRule(JSValueRef rrule);

    TizenApis::Api::Calendar::CalendarEvent::EventVisibility toEventVisibility(std::string tizenValue) const;
    TizenApis::Api::Calendar::CalendarEvent::EventAvailability toEventAvailability(std::string tizenValue) const;
    TizenApis::Api::Calendar::EventAttendee::EventAttendeeRole toEventAttendeeRole(std::string tizenValue) const;
    TizenApis::Api::Calendar::EventAttendee::EventAttendeeStatus toEventAttendeeStatus(std::string tizenValue) const;
    TizenApis::Api::Calendar::EventAttendee::EventAttendeeType toEventAttendeeType(std::string tizenValue) const;

    int toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventAlarmType abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventStatus abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::EventRecurrenceRule::EventRecurrence abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventVisibility abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::EventAvailability abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::EventAttendee::EventAttendeeRole abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::EventAttendee::EventAttendeeStatus abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::EventAttendee::EventAttendeeType abstractValue) const;
    std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::TaskPriority abstractValue) const;

    JSValueRef toJSValueRefItem(const TizenApis::Api::Calendar::CalendarEventPtr& arg);
    JSValueRef toJSValueRef(const TizenApis::Api::Calendar::CalendarEventListPtr &arg);
    JSValueRef toJSValueRefCalendar(const TizenApis::Api::Calendar::ICalendarPtr& arg);
    JSValueRef toJSValueRef(const std::vector<TizenApis::Api::Calendar::ICalendarPtr> &arg);
	JSValueRef toJSValueRefItemProperties(const TizenApis::Api::Calendar::CalendarEventPtr& arg);
	JSValueRef toJSValueRef(const TizenApis::Api::Calendar::EventIdPtr& arg);

    TizenApis::Api::Calendar::EventAlarmPtr toEventAlarm(JSValueRef alarm);
    TizenApis::Api::Calendar::EventAlarmListPtr toVectorOfEventAlarms(JSValueRef alarms);
    TizenApis::Api::Calendar::EventIdPtr toEventId(JSValueRef eventId);
    TizenApis::Api::Calendar::EventIdListPtr toVectorOfEventIds(JSValueRef eventIds);
    std::vector<time_t> toVectorOfTimeTFromTZDate(JSValueRef dates);
    TizenApis::Api::Calendar::CalendarEvent::TaskPriority toTaskPriority(std::string priority) const;
	TizenApis::Api::Calendar::CalendarEvent::CalendarType toCalendarType(std::string type) const;
	TizenApis::Api::Calendar::CalendarEvent::VObjectFormat toVObjectFormat(std::string type) const;

    /**
     * @throw InvalidArgumentException If not a callback nor JS null.
     */
    JSValueRef toFunctionOrNull(const JSValueRef& arg);

    /**
     * @throw ConversionException If JS null.
     * @throw InvalidArgumentException If not a callback nor JS null.
     */
    JSValueRef toFunction(const JSValueRef& arg);

  private:
    void toEventFilterConvertId(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);
    void toEventFilterConvertSummary(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);
    void toEventFilterConvertDescription(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);
    void toEventFilterConvertLocation(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);
    void toEventFilterConvertCategory(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);
    void toEventFilterConvertStatus(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);
    void toEventFilterConvertStartTime(const TizenApis::Api::Calendar::EventFilterPtr &result,
            const JSValueRef &filters);

    static std::vector<std::string> m_allowedAttributes;
    static std::vector<std::string> m_allowedCreateProperties;
    TizenApis::Api::Calendar::CalendarEvent::CalendarType m_calendarType;
};

typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<CalendarConverter> CalendarConverterFactory;

}
}
}

#endif /* _JS_TIZEN_CALENDAR_CONVERTER_H_ */