BETA merge
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Calendar / JSCalendar.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef _JS_TIZEN_CALENDAR_H_
19 #define _JS_TIZEN_CALENDAR_H_
20
21 #include <vector>
22 #include <string>
23 #include <JavaScriptCore/JavaScript.h>
24 #include <CommonsJavaScript/PrivateObject.h>
25 #include <API/Calendar/ICalendar.h>
26 #include <CommonsJavaScript/JSCallbackManager.h>
27
28 namespace TizenApis {
29 namespace Tizen1_0 {
30 namespace Calendar {
31
32 #define TIZEN_CALENDAR_PROPERTY_NAME "name"
33 #define TIZEN_CALENDAR_PROPERTY_ACCOUNT_ID "accountId"
34 #define TIZEN_CALENDAR_PROPERTY_ID "id"
35
36 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::ICalendarPtr,
37                                WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarPrivObject;
38
39 class JSCalendar
40 {
41   public:
42
43     static const JSClassDefinition* getClassInfo();
44
45     static const JSClassRef getClassRef();
46
47   private:
48     /**
49      * This member variable contains the values which has to be passed
50      * when the this class is embedded into JS Engine.
51      */
52     static JSClassDefinition m_classInfo;
53
54     /**
55      * This structure describes a statically declared function property.
56      */
57     static JSStaticFunction m_function[];
58
59     /**
60      * This member variable contains the initialization values for the
61      * properties of this class. The values are given according to
62      * the data structure JSPropertySpec
63      */
64     static JSStaticValue m_property[];
65
66     static JSClassRef m_jsClassRef;
67
68     /**
69      * The callback invoked when an object is first created.
70      */
71     static void initialize(JSContextRef context,
72             JSObjectRef object);
73
74     /**
75      * The callback invoked when an object is finalized.
76      */
77     static void finalize(JSObjectRef object);
78
79     static JSValueRef getPropertyName(JSContextRef context,
80             JSObjectRef object,
81             JSStringRef propertyName,
82             JSValueRef* exception);
83
84     static JSValueRef getPropertyAccountId(JSContextRef context,
85             JSObjectRef object,
86             JSStringRef propertyName,
87             JSValueRef* exception);
88
89     static JSValueRef getPropertyId(JSContextRef context,
90             JSObjectRef object,
91             JSStringRef propertyName,
92             JSValueRef* exception);
93
94     /**
95      * Add a calendar item.
96      */
97     static JSValueRef add(JSContextRef context,
98             JSObjectRef object,
99             JSObjectRef thisObject,
100             size_t argumentCount,
101             const JSValueRef arguments[],
102             JSValueRef* exception);
103
104     /**
105      * Add calendar items.
106      */
107     static JSValueRef addBatch(JSContextRef context,
108             JSObjectRef object,
109             JSObjectRef thisObject,
110             size_t argumentCount,
111             const JSValueRef arguments[],
112             JSValueRef* exception);
113
114     /**
115      * Update an item.
116      */
117     static JSValueRef update(JSContextRef context,
118             JSObjectRef object,
119             JSObjectRef thisObject,
120             size_t argumentCount,
121             const JSValueRef arguments[],
122             JSValueRef* exception);
123
124     /**
125      * Update items.
126      */
127     static JSValueRef updateBatch(JSContextRef context,
128             JSObjectRef object,
129             JSObjectRef thisObject,
130             size_t argumentCount,
131             const JSValueRef arguments[],
132             JSValueRef* exception);
133
134     /**
135      * Remove a calendar item.
136      */
137     static JSValueRef remove(JSContextRef context,
138             JSObjectRef object,
139             JSObjectRef thisObject,
140             size_t argumentCount,
141             const JSValueRef arguments[],
142             JSValueRef* exception);
143
144     /**
145      * Remove calendar items.
146      */
147     static JSValueRef removeBatch(JSContextRef context,
148             JSObjectRef object,
149             JSObjectRef thisObject,
150             size_t argumentCount,
151             const JSValueRef arguments[],
152             JSValueRef* exception);
153
154     /**
155      * Search for calendar items using old wac2.0 stype filter.
156      */
157     static JSValueRef findWithWACFilter(JSContextRef context,
158             JSObjectRef object,
159             JSObjectRef thisObject,
160             size_t argumentCount,
161             const JSValueRef arguments[],
162             JSValueRef* exception);
163
164     /**
165      * Search for calendar items using tizen generic filter.
166      */
167     static JSValueRef find(JSContextRef context,
168             JSObjectRef object,
169             JSObjectRef thisObject,
170             size_t argumentCount,
171             const JSValueRef arguments[],
172             JSValueRef* exception);
173
174     /**
175      * Create an event from string
176      */
177     static JSValueRef convertFromString(JSContextRef context,
178             JSObjectRef object,
179             JSObjectRef thisObject,
180             size_t argumentCount,
181             const JSValueRef arguments[],
182             JSValueRef* exception);
183
184     /**
185      * Export a string from event
186      */
187     static JSValueRef convertToString(JSContextRef context,
188             JSObjectRef object,
189             JSObjectRef thisObject,
190             size_t argumentCount,
191             const JSValueRef arguments[],
192             JSValueRef* exception);
193
194     /**
195      * Watch changes
196      */
197     static JSValueRef addChangeListener(JSContextRef context,
198             JSObjectRef object,
199             JSObjectRef thisObject,
200             size_t argumentCount,
201             const JSValueRef arguments[],
202             JSValueRef* exception);
203
204     /**
205      * Clear watch
206      */
207     static JSValueRef removeChangeListener(JSContextRef context,
208             JSObjectRef object,
209             JSObjectRef thisObject,
210             size_t argumentCount,
211             const JSValueRef arguments[],
212             JSValueRef* exception);
213
214     /**
215      * Expand event instances from a recurring event
216      */
217     static JSValueRef expandEventRecurrence(JSContextRef context,
218             JSObjectRef object,
219             JSObjectRef thisObject,
220             size_t argumentCount,
221             const JSValueRef arguments[],
222             JSValueRef* exception);
223
224     /**
225      *  Returns calendar stored as private object
226      */
227     static Api::Calendar::ICalendarPtr getCalendar(JSContextRef ctx,
228             const JSObjectRef object,
229             JSValueRef* exception);
230 };
231
232 }
233 }
234 }
235
236 #endif /* _JS_TIZEN_CALENDAR_H_ */
237