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