Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Filesystem / JSFilestream.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_JSFILESTREAM_H_
20 #define TIZENAPIS_TIZEN_JSFILESTREAM_H_
21
22 #include <JavaScriptCore/JavaScript.h>
23 #include <CommonsJavaScript/PrivateObject.h>
24 #include <Security.h>
25 #include "IStream.h"
26
27 namespace DeviceAPI {
28 namespace Filesystem {
29
30         
31 class JSFilestream
32 {
33 public:
34         typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<IStreamPtr>::Type PrivateObjectSecurity;
35
36         class PrivateObject :
37                 public DeviceAPI::Common::SecurityAccessor,
38                 public PrivateObjectSecurity
39         {
40         public :
41                 PrivateObject (JSContextRef context, IStreamPtr stream) :
42                         DeviceAPI::Common::SecurityAccessor(), 
43                         PrivateObjectSecurity(context, stream)
44                 {
45                 }
46                         
47                 virtual ~PrivateObject()
48                 {
49                 }
50         };
51         
52 public:
53         static const JSClassDefinition* getClassInfo();
54
55         static const JSClassRef getClassRef();
56
57 private:
58         /**
59         * The callback invoked when an object is first created.
60         */
61         static void initialize(JSContextRef context,
62                 JSObjectRef object);
63
64         /**
65         * The callback invoked when an object is finalized.
66         */
67         static void finalize(JSObjectRef object);
68
69         /**
70         * The callback invoked when getting a property's value.
71         */
72         static JSValueRef getProperty(JSContextRef context,
73                 JSObjectRef object,
74                 JSStringRef propertyName,
75                 JSValueRef* exception);
76
77         /**
78         * The callback invoked when setting a property's value.
79         */
80         static bool setProperty(JSContextRef context,
81                 JSObjectRef object,
82                 JSStringRef propertyName,
83                 JSValueRef value,
84                 JSValueRef* exception);
85
86         /**
87         * The callback invoked when collecting the names of an object's properties.
88         */
89         static void getPropertyNames(JSContextRef context,
90                 JSObjectRef object,
91                 JSPropertyNameAccumulatorRef propertyNames);
92
93         /**
94         * The callback invoked when an object is used as the target of an 'instanceof' expression.
95         */
96         static bool hasInstance(JSContextRef context,
97                 JSObjectRef constructor,
98                 JSValueRef possibleInstance,
99                 JSValueRef* exception);
100
101         /**
102         * Closes this FileStream.
103         */
104         static JSValueRef close(JSContextRef context,
105                 JSObjectRef object,
106                 JSObjectRef thisObject,
107                 size_t argumentCount,
108                 const JSValueRef arguments[],
109                 JSValueRef* exception);
110
111         /**
112         * Reads the specified number of characters from this FileStream.
113         */
114         static JSValueRef read(JSContextRef context,
115                 JSObjectRef object,
116                 JSObjectRef thisObject,
117                 size_t argumentCount,
118                 const JSValueRef arguments[],
119                 JSValueRef* exception);
120
121         /**
122         * Reads the specified number of bytes from this FileStream.
123         */
124         static JSValueRef readBytes(JSContextRef context,
125                 JSObjectRef object,
126                 JSObjectRef thisObject,
127                 size_t argumentCount,
128                 const JSValueRef arguments[],
129                 JSValueRef* exception);
130
131         /**
132         * Reads the specified number of bytes from this FileStream, encoding the result in base64.
133         */
134         static JSValueRef readBase64(JSContextRef context,
135                 JSObjectRef object,
136                 JSObjectRef thisObject,
137                 size_t argumentCount,
138                 const JSValueRef arguments[],
139                 JSValueRef* exception);
140
141         /**
142         * Writes the specified DOMString to this FileStream.
143         */
144         static JSValueRef write(JSContextRef context,
145                 JSObjectRef object,
146                 JSObjectRef thisObject,
147                 size_t argumentCount,
148                 const JSValueRef arguments[],
149                 JSValueRef* exception);
150
151         /**
152         * Writes the specified bytes to this FileStream.
153         */
154         static JSValueRef writeBytes(JSContextRef context,
155                 JSObjectRef object,
156                 JSObjectRef thisObject,
157                 size_t argumentCount,
158                 const JSValueRef arguments[],
159                 JSValueRef* exception);
160
161         /**
162         * Converts the specified base64 DOMString to bytes and writes the result to this FileStream.
163         */
164         static JSValueRef writeBase64(JSContextRef context,
165                 JSObjectRef object,
166                 JSObjectRef thisObject,
167                 size_t argumentCount,
168                 const JSValueRef arguments[],
169                 JSValueRef* exception);
170
171         /**
172         * This structure describes a statically declared function property.
173         */
174         static JSStaticFunction m_functions[];
175
176         /**
177         * This structure describes a statically declared value property.
178         */
179         static JSStaticValue m_properties[];
180
181         /**
182         * This structure contains properties and callbacks that define a type of object.
183         */
184         static JSClassDefinition m_classInfo;
185
186         static JSClassRef m_classRef;
187 };
188 }
189 }
190
191 #endif