Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Filesystem / JSStorage.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 TIZENAPIS_TIZEN_JS_STORAGE_H_
20 #define TIZENAPIS_TIZEN_JS_STORAGE_H_
21
22 #include <JavaScriptCore/JavaScript.h>
23 #include <CommonsJavaScript/PrivateObject.h>
24 #include <Security.h>
25 #include "StorageProperties.h"
26
27 namespace DeviceAPI {
28 namespace Filesystem {
29
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<StorageProperties*>::Type JSStoragePriv;
31
32 class JSStorage
33 {
34 public:
35         enum StorageType
36         {
37                 TYPE_INTERNAL = 0,
38                 TYPE_EXTERNAL,
39         };
40
41         enum StorageState
42         {
43                 STATE_MOUNTED = 0,
44                 STATE_REMOVED,
45                 STATE_UNMOUNTABLE,
46         };
47                 
48         static const JSClassDefinition* getClassInfo();
49
50         static const JSClassRef getClassRef();
51
52         /**
53         * create an JSObject for callback function(onAnswerReceived).
54         */
55         static JSObjectRef createJSObject(JSContextRef context,
56                 const StorageProperties &storages);
57
58 private:
59         /**
60         * The callback invoked when an object is first created.
61         */
62         static void initialize(JSContextRef context,
63                 JSObjectRef object);
64
65         /**
66         * The callback invoked when an object is finalized.
67         */
68         static void finalize(JSObjectRef object);
69
70         /**
71         * The callback invoked when getting a property's value.
72         */
73         static JSValueRef getProperty(JSContextRef context,
74                 JSObjectRef object,
75                 JSStringRef propertyName,
76                 JSValueRef* exception);
77
78         /**
79         * The callback invoked when an object is used as the target of an 'instanceof' expression.
80         */
81         static bool hasInstance(JSContextRef context,
82                 JSObjectRef constructor,
83                 JSValueRef possibleInstance,
84                 JSValueRef* exception);
85
86         /**
87         * This structure contains properties and callbacks that define a type of object.
88         */
89         static JSClassDefinition m_classInfo;
90
91         /**
92         * This structure describes a statically declared value property.
93         */
94         static JSStaticValue m_property[];
95
96         static JSClassRef m_jsClassRef;
97 };
98 }
99 }
100
101 #endif
102