Update change log and spec for wrt-plugins-tizen_0.4.70
[framework/web/wrt-plugins-tizen.git] / src / Messaging / JSMessagingService.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 WRT_PLUGINS_TIZEN_JS_MESSAGING_SERVICE_H_
19 #define WRT_PLUGINS_TIZEN_JS_MESSAGING_SERVICE_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include <Security.h>
24 #include "IMessagingService.h"
25
26 namespace DeviceAPI {
27 namespace Messaging {
28
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<DeviceAPI::Messaging::IMessagingServicePtr>::Type JSMessagingServicePrivObject;
30
31 class JSMessagingServicePriv :
32     public JSMessagingServicePrivObject,
33     public DeviceAPI::Common::SecurityAccessor
34 {
35 public:
36     JSMessagingServicePriv(JSContextRef context, IMessagingServicePtr messagingService) :
37         JSMessagingServicePrivObject(context, messagingService),
38         DeviceAPI::Common::SecurityAccessor()
39     {
40     }
41
42     virtual ~JSMessagingServicePriv()
43     {
44     }
45 };
46
47 class JSMessagingService {
48
49 public :
50     static const JSClassDefinition* getClassInfo();
51     static const JSClassRef getClassRef();
52
53     static JSObjectRef createJSObject(JSContextRef context, const IMessagingServicePtr &messagingService, const DeviceAPI::Common::SecurityAccessor *securityAccessor);
54
55 private :
56
57     /**
58      * The callback invoked when an object is first created.
59      */
60     static void initialize(JSContextRef context, JSObjectRef object);
61
62     /**
63      * The callback invoked when an object is finalized.
64      */
65     static void finalize(JSObjectRef object);
66
67     /**
68      * The callback invoked when an object is used as the target of an 'instanceof' expression.
69      */
70     static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
71
72     /**
73     * The callback invoked when determining whether an object has a property.
74     */
75     static bool hasProperty(JSContextRef context,
76          JSObjectRef object,
77          JSStringRef propertyName);
78
79     /**
80     * The callback invoked when getting a property's value.
81     */
82     static JSValueRef getProperty(JSContextRef context,
83              JSObjectRef object,
84              JSStringRef propertyName,
85              JSValueRef* exception);
86
87     /**
88     * The callback invoked when setting a property's value.
89     */
90     static bool setProperty(JSContextRef context,
91             JSObjectRef object,
92             JSStringRef propertyName,
93             JSValueRef value,
94             JSValueRef* exception);
95
96     /**
97      * The callback invoked when collecting the names of an object's properties.
98      */
99     static void getPropertyNames(JSContextRef context,
100             JSObjectRef object,
101             JSPropertyNameAccumulatorRef propertyNames);
102
103 #if 0
104     /**
105     * The callback invoked when create message
106     */
107     static JSValueRef createMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
108         size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
109 #endif
110
111     static JSValueRef sendMessage(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
112             size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
113
114     static JSValueRef loadMessageBody(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
115                 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
116
117     static JSValueRef loadMessageAttachment(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
118                 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
119
120     static JSValueRef sync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
121                 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
122
123     static JSValueRef syncFolder(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
124                 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
125
126 #if 0
127     static JSValueRef cancelOperation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
128                 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
129 #endif
130
131     static JSValueRef stopSync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
132                 size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
133
134     /**
135      * This structure contains properties and callbacks that define a type of object.
136      */
137     static JSClassDefinition m_classInfo;
138
139     static JSStaticFunction m_function[];
140     static JSStaticValue m_property[];
141     static JSClassRef m_jsClassRef;
142
143 }; //JSMessagingService
144
145 }
146 } //WrtPlugins
147
148
149 #endif //WRT_PLUGINS_TIZEN_JS_MESSAGING_SERVICE_H_