Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Messaging / JSMessagingStorage.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 #ifndef WRTPLUGINS_TIZEN_JS_MESSAGING_STORAGE_H_
19 #define WRTPLUGINS_TIZEN_JS_MESSAGING_STORAGE_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include <Security.h>
24 #include "MessagingListener.h"
25
26
27 namespace DeviceAPI {
28 namespace Messaging {
29
30 class MessagingStoragePrivObj
31 {
32 public:
33         long m_index;
34         int m_type;
35 //      MessagingListener instance;
36
37 long getIndex() const
38 {
39         return m_index;
40 }
41
42 int getType() const
43 {
44         return m_type;
45 }
46         
47 };
48
49 typedef DPL::SharedPtr<MessagingStoragePrivObj> MessagingStoragePrivObjPtr;
50         
51 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<MessagingStoragePrivObjPtr>::Type MessagingStoragePrivObject;
52
53 class MessagingStoragePriv :
54     public MessagingStoragePrivObject,
55     public DeviceAPI::Common::SecurityAccessor
56 {
57 public:
58     MessagingStoragePriv(JSContextRef context, MessagingStoragePrivObjPtr messageStorage) :
59         MessagingStoragePrivObject(context, messageStorage),
60         DeviceAPI::Common::SecurityAccessor()
61     {
62     }
63
64     virtual ~MessagingStoragePriv()
65     {
66     }
67 };
68
69 class JSMessagingStorage {
70 public:
71 //@struct JSClassDefinition
72 //      @abstract This structure contains properties and callbacks that define a type of object. All fields other than the version field are optional. Any pointer may be NULL.
73         static const JSClassDefinition* getClassInfo();
74         static const JSClassRef getClassRef();
75
76 private:
77         /**
78          * The callback invoked when an object is first created.
79          */
80         static void initialize(JSContextRef context, JSObjectRef object);
81
82         /**
83          * The callback invoked when an object is finalized.
84          */
85         static void finalize(JSObjectRef object);
86
87         /**
88          * The callback invoked when an object is used as the target of an 'instanceof' expression.
89          */
90         static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
91
92
93           /**
94           * The callback invoked when determining whether an object has a property.
95           */
96          static bool hasProperty(JSContextRef context,
97                          JSObjectRef object,
98                          JSStringRef propertyName);
99
100 #if 0
101          /**
102           * The callback invoked when getting a property's value.
103           */
104         static JSValueRef getProperty(JSContextRef context,
105                          JSObjectRef object,
106                          JSStringRef propertyName,
107                          JSValueRef* exception);
108 #endif
109
110         static JSValueRef addDraftMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
111          const JSValueRef arguments[], JSValueRef* exception);
112
113         static JSValueRef findMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
114          const JSValueRef arguments[], JSValueRef* exception);
115
116         static JSValueRef findConversations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
117          const JSValueRef arguments[], JSValueRef* exception);
118
119         static JSValueRef removeConversations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
120          const JSValueRef arguments[], JSValueRef* exception);
121
122         static JSValueRef findFolders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
123          const JSValueRef arguments[], JSValueRef* exception);
124
125         static JSValueRef removeMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
126          const JSValueRef arguments[], JSValueRef* exception);
127
128         static JSValueRef updateMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
129          const JSValueRef arguments[], JSValueRef* exception);
130
131         static JSValueRef addMessagesChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
132          const JSValueRef arguments[], JSValueRef* exception);   
133
134         static JSValueRef addConversationsChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
135          const JSValueRef arguments[], JSValueRef* exception);   
136
137         static JSValueRef addFoldersChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
138          const JSValueRef arguments[], JSValueRef* exception);   
139
140         static JSValueRef removeChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
141          const JSValueRef arguments[], JSValueRef* exception);   
142
143
144         /**
145          * This structure contains properties and callbacks that define a type of object.
146          */
147         static JSClassDefinition m_classInfo;
148
149         /**
150          * This structure describes a statically declared function property.
151          */
152         static JSStaticFunction m_function[];
153         static JSStaticValue m_property[];
154         static JSClassRef m_jsClassRef;
155
156 };
157
158 }
159 } //WrtPlugins
160
161 #endif //WRTPLUGINS_TIZEN_JS_MESSAGING_SERVICE_MANAGER_H_
162