cdbd0c4517c97b74c53aaafa0979d73cd2d67c0f
[framework/web/wrt-plugins-tizen.git] / src / Calendar / JSCalendarEvent.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_CALENDAR_EVENT_H_
20 #define _JS_CALENDAR_EVENT_H_
21
22 #include <JavaScriptCore/JavaScript.h>
23 #include "CalendarEvent.h"
24 #include "ICalendar.h"
25 #include "CalendarFactory.h"
26 #include <CommonsJavaScript/PrivateObject.h>
27
28 namespace DeviceAPI {
29 namespace Calendar {
30
31 #define TIZEN_INTERFACE_CALENDAR_EVENT "CalendarEvent"
32
33 #define TIZEN_CALENDAR_EVENT_ID "id"
34 #define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate"
35 #define TIZEN_CALENDAR_EVENT_IS_DETACHED "isDetached"
36
37 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<CalendarEventPtr,
38         WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarEventPrivObject;
39
40 class JSCalendarEvent
41 {
42   public:
43
44     static const JSClassDefinition* getClassInfo();
45
46     static const JSClassRef getClassRef();
47
48     static CalendarEventPtr getPrivateObject(JSObjectRef object);
49
50     static void setPrivateObject(const CalendarEventPtr &event,
51             JSContextRef ctx,
52             const JSObjectRef object);
53
54     static bool validate(JSContextRef ctx,
55             const JSObjectRef object,
56             JSValueRef* exception);
57
58         static JSObjectRef createJSCalendarEvent(JSContextRef context, CalendarEventPtr event);
59
60   private:
61     /**
62      * This member variable contains the values which has to be passed when
63      * the this class is embedded into JS Engine.
64      */
65     static JSClassDefinition m_classInfo;
66
67     /**
68      * This structure describes a statically declared function property.
69      */
70     static JSStaticFunction m_function[];
71
72     /**
73      * This member variable contains the initialization values for the
74      * properties of this class. The values are given according to the
75      * data structure JSPropertySpec.
76      */
77     static JSStaticValue m_property[];
78
79     static JSClassRef m_jsClassRef;
80
81         /**
82          * The calendar object to be used for asynchronous platform function invocation.
83          */
84         static ICalendarPtr m_calendar;
85
86     /**
87      * The callback invoked when an object is first created.
88      */
89     static void initialize(JSContextRef context,
90             JSObjectRef object);
91
92     /**
93      * The callback invoked when an object is finalized.
94      */
95     static void finalize(JSObjectRef object);
96
97         /**
98          * Constructor for the CalendarEvent interface.
99          */
100         static JSObjectRef constructor(JSContextRef context,
101     JSObjectRef constructor,
102     size_t argumentCount,
103     const JSValueRef arguments[],
104     JSValueRef* exception);
105
106     /**
107      * Expand event instances from a recurring event
108      */
109     static JSValueRef expandRecurrence(JSContextRef context,
110             JSObjectRef object,
111             JSObjectRef thisObject,
112             size_t argumentCount,
113             const JSValueRef arguments[],
114             JSValueRef* exception);
115
116     /**
117      * Getters and setters for properties
118      */
119     static JSValueRef getPropertyId(JSContextRef context,
120             JSObjectRef object,
121             JSStringRef propertyName,
122             JSValueRef* exception);
123     static JSValueRef getPropertyIsDetached(JSContextRef context,
124             JSObjectRef object,
125             JSStringRef propertyName,
126             JSValueRef* exception);
127 };
128
129 }
130 }
131
132 #endif /* _JS_CALENDAR_EVENT_H_ */