ee2486b57544d0bbd5d70f34d90ff4023c0f1e8b
[platform/framework/web/wrt-plugins-tizen.git] / src / Calendar / JSCalendar.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_H_
20 #define _JS_TIZEN_CALENDAR_H_
21
22 #include <vector>
23 #include <string>
24 #include <JavaScriptCore/JavaScript.h>
25 #include <CommonsJavaScript/PrivateObject.h>
26 #include "ICalendar.h"
27 #include <CommonsJavaScript/JSCallbackManager.h>
28
29 namespace DeviceAPI {
30 namespace Calendar {
31
32 #define TIZEN_CALENDAR_PROPERTY_NAME "name"
33 //#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID "accountServiceId"
34 #define TIZEN_CALENDAR_PROPERTY_ID "id"
35
36 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<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 getPropertyAccountServiceId(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 tizen generic filter.
156      */
157     static JSValueRef find(JSContextRef context,
158             JSObjectRef object,
159             JSObjectRef thisObject,
160             size_t argumentCount,
161             const JSValueRef arguments[],
162             JSValueRef* exception);
163
164     /**
165      * Watch changes
166      */
167     static JSValueRef addChangeListener(JSContextRef context,
168             JSObjectRef object,
169             JSObjectRef thisObject,
170             size_t argumentCount,
171             const JSValueRef arguments[],
172             JSValueRef* exception);
173
174     /**
175      * Clear watch
176      */
177     static JSValueRef removeChangeListener(JSContextRef context,
178             JSObjectRef object,
179             JSObjectRef thisObject,
180             size_t argumentCount,
181             const JSValueRef arguments[],
182             JSValueRef* exception);
183
184     /**
185      * Get an item from id
186      */
187     static JSValueRef get(JSContextRef context,
188             JSObjectRef object,
189             JSObjectRef thisObject,
190             size_t argumentCount,
191             const JSValueRef arguments[],
192             JSValueRef* exception);
193
194     /**
195      *  Returns calendar stored as private object
196      */
197     static ICalendarPtr getCalendar(JSContextRef ctx,
198             const JSObjectRef object,
199             JSValueRef* exception);
200 };
201
202 }
203 }
204
205 #endif /* _JS_TIZEN_CALENDAR_H_ */
206