Update change log and spec for wrt-plugins-tizen_0.4.70
[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 #include <Security.h>
29
30 namespace DeviceAPI {
31 namespace Calendar {
32
33 #define TIZEN_CALENDAR_PROPERTY_NAME "name"
34 //#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID "accountServiceId"
35 #define TIZEN_CALENDAR_PROPERTY_ID "id"
36
37 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<ICalendarPtr,
38                                WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarPrivObjectBase;
39
40 class CalendarPrivObject :
41     public CalendarPrivObjectBase,
42     public DeviceAPI::Common::SecurityAccessor
43 {
44 public:
45     CalendarPrivObject(JSContextRef context, ICalendarPtr calendar) :
46         CalendarPrivObjectBase(context, calendar),
47         DeviceAPI::Common::SecurityAccessor()
48     {
49     }
50
51     virtual ~CalendarPrivObject()
52     {
53     }
54 };
55
56 class JSCalendar
57 {
58   public:
59
60     static const JSClassDefinition* getClassInfo();
61
62     static const JSClassRef getClassRef();
63
64   private:
65     /**
66      * This member variable contains the values which has to be passed
67      * when the this class is embedded into JS Engine.
68      */
69     static JSClassDefinition m_classInfo;
70
71     /**
72      * This structure describes a statically declared function property.
73      */
74     static JSStaticFunction m_function[];
75
76     /**
77      * This member variable contains the initialization values for the
78      * properties of this class. The values are given according to
79      * the data structure JSPropertySpec
80      */
81     static JSStaticValue m_property[];
82
83     static JSClassRef m_jsClassRef;
84
85     /**
86      * The callback invoked when an object is first created.
87      */
88     static void initialize(JSContextRef context,
89             JSObjectRef object);
90
91     /**
92      * The callback invoked when an object is finalized.
93      */
94     static void finalize(JSObjectRef object);
95
96     static JSValueRef getPropertyName(JSContextRef context,
97             JSObjectRef object,
98             JSStringRef propertyName,
99             JSValueRef* exception);
100
101     static JSValueRef getPropertyAccountServiceId(JSContextRef context,
102             JSObjectRef object,
103             JSStringRef propertyName,
104             JSValueRef* exception);
105
106     static JSValueRef getPropertyId(JSContextRef context,
107             JSObjectRef object,
108             JSStringRef propertyName,
109             JSValueRef* exception);
110
111     /**
112      * Add a calendar item.
113      */
114     static JSValueRef add(JSContextRef context,
115             JSObjectRef object,
116             JSObjectRef thisObject,
117             size_t argumentCount,
118             const JSValueRef arguments[],
119             JSValueRef* exception);
120
121     /**
122      * Add calendar items.
123      */
124     static JSValueRef addBatch(JSContextRef context,
125             JSObjectRef object,
126             JSObjectRef thisObject,
127             size_t argumentCount,
128             const JSValueRef arguments[],
129             JSValueRef* exception);
130
131     /**
132      * Update an item.
133      */
134     static JSValueRef update(JSContextRef context,
135             JSObjectRef object,
136             JSObjectRef thisObject,
137             size_t argumentCount,
138             const JSValueRef arguments[],
139             JSValueRef* exception);
140
141     /**
142      * Update items.
143      */
144     static JSValueRef updateBatch(JSContextRef context,
145             JSObjectRef object,
146             JSObjectRef thisObject,
147             size_t argumentCount,
148             const JSValueRef arguments[],
149             JSValueRef* exception);
150
151     /**
152      * Remove a calendar item.
153      */
154     static JSValueRef remove(JSContextRef context,
155             JSObjectRef object,
156             JSObjectRef thisObject,
157             size_t argumentCount,
158             const JSValueRef arguments[],
159             JSValueRef* exception);
160
161     /**
162      * Remove calendar items.
163      */
164     static JSValueRef removeBatch(JSContextRef context,
165             JSObjectRef object,
166             JSObjectRef thisObject,
167             size_t argumentCount,
168             const JSValueRef arguments[],
169             JSValueRef* exception);
170
171     /**
172      * Search for calendar items using tizen generic filter.
173      */
174     static JSValueRef find(JSContextRef context,
175             JSObjectRef object,
176             JSObjectRef thisObject,
177             size_t argumentCount,
178             const JSValueRef arguments[],
179             JSValueRef* exception);
180
181     /**
182      * Watch changes
183      */
184     static JSValueRef addChangeListener(JSContextRef context,
185             JSObjectRef object,
186             JSObjectRef thisObject,
187             size_t argumentCount,
188             const JSValueRef arguments[],
189             JSValueRef* exception);
190
191     /**
192      * Clear watch
193      */
194     static JSValueRef removeChangeListener(JSContextRef context,
195             JSObjectRef object,
196             JSObjectRef thisObject,
197             size_t argumentCount,
198             const JSValueRef arguments[],
199             JSValueRef* exception);
200
201     /**
202      * Get an item from id
203      */
204     static JSValueRef get(JSContextRef context,
205             JSObjectRef object,
206             JSObjectRef thisObject,
207             size_t argumentCount,
208             const JSValueRef arguments[],
209             JSValueRef* exception);
210
211     /**
212      *  Returns calendar stored as private object
213      */
214     static ICalendarPtr getCalendar(JSContextRef ctx,
215             const JSObjectRef object,
216             JSValueRef* exception);
217 };
218
219 }
220 }
221
222 #endif /* _JS_TIZEN_CALENDAR_H_ */
223