tizen 2.3.1 release
[framework/web/wearable/wrt-plugins-tizen.git] / src / MessagePort / JSRemoteMessagePort.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  * @file        JSRemoteMessagePort.cpp
20  * @version     0.1
21  * @brief       Declaration of the JSRemoteMessagePort class
22  */
23
24 #ifndef _TIZEN_MESSAGE_PORT_JS_REMOTE_MESSAGE_PORT_H_
25 #define _TIZEN_MESSAGE_PORT_JS_REMOTE_MESSAGE_PORT_H_
26
27 #include <JavaScriptCore/JavaScript.h>
28 #include <CommonsJavaScript/PrivateObject.h>
29 #include "IRemoteMessagePort.h"
30
31 namespace DeviceAPI {
32 namespace MessagePort {
33
34 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject
35         <RemoteMessagePortPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSRemoteMessagePortPriv;
36
37 class JSRemoteMessagePort
38 {
39 public:
40
41     static const JSClassRef getClassRef();
42
43     static const JSClassDefinition* getClassInfo();
44
45     static bool isObjectOfClass(JSContextRef context, JSValueRef value);
46
47     static RemoteMessagePortPtr getRemoteMessagePort(JSContextRef context, JSValueRef value);
48
49 private:
50     /**
51      * The callback invoked when an object is first created.
52      */
53     static void Initialize(JSContextRef context, JSObjectRef object);
54
55     /**
56      * The callback invoked when an object is finalized.
57      */
58     static void Finalize(JSObjectRef object);
59
60     static JSClassDefinition m_classInfo;
61
62     static JSStaticFunction m_function[];
63
64     static JSStaticValue m_property[];
65
66     static JSClassRef m_jsClassRef;
67
68     static RemoteMessagePortPtr getPrivData(JSObjectRef object);
69
70     static JSValueRef getMessagePortName(JSContextRef context,
71             JSObjectRef object,
72             JSStringRef propertyName,
73             JSValueRef* exception);
74
75     static JSValueRef getAppId(JSContextRef context,
76             JSObjectRef object,
77             JSStringRef propertyName,
78             JSValueRef* exception);
79
80     static JSValueRef getIsTrusted(JSContextRef context,
81             JSObjectRef object,
82             JSStringRef propertyName,
83             JSValueRef* exception);
84
85     static JSValueRef sendMessage(JSContextRef context,
86             JSObjectRef object,
87             JSObjectRef thisObject,
88             size_t argumentCount,
89             const JSValueRef arguments[],
90             JSValueRef* exception);
91 };
92
93 } // MessagePort
94 } // DeviceAPI
95
96 #endif // _TIZEN_MESSAGE_PORT_JS_REMOTE_MESSAGE_PORT_H_