Initialize Tizen 2.3
[framework/web/wrt-plugins-common.git] / src_wearable / standards / W3C / Widget / JSPreferences.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  * @file       JSPreferences.h
19  * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
20  * @version    0.1
21  * @brief
22  */
23
24 #ifndef _WRT_PLUGIN_JS_WIDGET_PREFERENCES_H_
25 #define _WRT_PLUGIN_JS_WIDGET_PREFERENCES_H_
26
27 #include <JavaScriptCore/JavaScript.h>
28 #include <CommonsJavaScript/PrivateObject.h>
29 #include <LocalStorage/ILocalStorage.h>
30
31 namespace WrtPlugins {
32 namespace W3C {
33 struct LocalStoragePrivateData {
34     WrtDeviceApis::LocalStorage::Api::ILocalStoragePtr istorage;
35     //parent
36     JSObjectRef widgetObject;
37 };
38
39 class JSPreferences
40 {
41   public:
42     /**
43      * This method initializes this in the JS Engine.
44      */
45     static JSClassRef getClassRef();
46
47     /**
48      * Gets object's class description.
49      */
50     static const JSClassDefinition* getClassInfo();
51
52   private:
53     /**
54      * The callback invoked when an object is first created.
55      */
56     static void initialize(JSContextRef context, JSObjectRef object);
57
58     /**
59      * The callback invoked when an object is finalized.
60      */
61     static void finalize(JSObjectRef object);
62
63     /**
64      * This structure contains properties and callbacks
65      * that define a type of object.
66      */
67     static JSClassDefinition m_classInfo;
68
69     /**
70      * This structure describes a statically declared function.
71      */
72     static JSStaticFunction m_function[];
73
74     static JSStaticValue m_property[];
75
76     static JSClassRef m_jsClassRef;
77
78     //Modified functions for Preference object
79     static JSValueRef removeItem(JSContextRef context, JSObjectRef object,
80                                  JSObjectRef thisObject, size_t argumentCount,
81                                  const JSValueRef arguments[],
82                                  JSValueRef* exception);
83
84     static JSValueRef setItem(JSContextRef context, JSObjectRef object,
85                               JSObjectRef thisObject, size_t argumentCount,
86                               const JSValueRef arguments[],
87                               JSValueRef* exception);
88
89     static JSValueRef getItem(JSContextRef context, JSObjectRef object,
90                               JSObjectRef thisObject, size_t argumentCount,
91                               const JSValueRef arguments[],
92                               JSValueRef* exception);
93
94     static JSValueRef clear(JSContextRef context, JSObjectRef object,
95                             JSObjectRef thisObject, size_t argumentCount,
96                             const JSValueRef arguments[],
97                             JSValueRef* exception);
98
99     static JSValueRef key(JSContextRef context, JSObjectRef object,
100                           JSObjectRef thisObject, size_t argumentCount,
101                           const JSValueRef arguments[],
102                           JSValueRef* exception);
103
104     static JSValueRef getLength(JSContextRef context,
105                                 JSObjectRef object,
106                                 JSStringRef propertyName,
107                                 JSValueRef* exception);
108
109     static bool hasProperty(JSContextRef context,
110                             JSObjectRef object,
111                             JSStringRef propertyName);
112
113     static JSValueRef getProperty(JSContextRef context,
114                                   JSObjectRef object,
115                                   JSStringRef propertyName,
116                                   JSValueRef* exception);
117
118     static bool setProperty(JSContextRef context,
119                             JSObjectRef object,
120                             JSStringRef propertyName,
121                             JSValueRef value,
122                             JSValueRef* exception);
123 };
124 }
125 }
126
127 #endif