bcc65eb10a3d503dba2b26d502474537975ff108
[framework/web/wrt-plugins-tizen.git] / src / Bluetooth / JSBluetoothSocket.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 TIZENAPIS_TIZEN_JS_BLUETOOTH_SOCKET_H_
19 #define TIZENAPIS_TIZEN_JS_BLUETOOTH_SOCKET_H_
20
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include "BTDevice.h"
24 #include "IBluetoothSocketManager.h"
25
26 using namespace WrtDeviceApis::CommonsJavaScript;
27   
28 namespace DeviceAPI {
29 namespace Bluetooth {
30
31 typedef  PrivateObjectT<IBluetoothSocketManagerPtr>::Type JSBluetoothSocketPriv;
32 class JSBluetoothSocket 
33 {
34 public:
35         static const JSClassDefinition* getClassInfo();
36         static const JSClassRef getClassRef();
37         static JSObjectRef createJSObject(JSContextRef context, BluetoothSocketData socketData);
38         static JSObjectRef createJSObject(JSContextRef context, BluetoothSocketData socketData, 
39                 EventBTReadDataType readData);
40
41 private:
42         static void initialize(JSContextRef context, JSObjectRef object);
43         static void finalize(JSObjectRef object);
44         static bool hasInstance(JSContextRef context, JSObjectRef constructor,
45                 JSValueRef possibleInstance, JSValueRef* exception);
46
47         static bool setProperty(JSContextRef context, 
48                                                 JSObjectRef object,
49                                                 JSStringRef propertyName,
50                                                 JSValueRef value,
51                                                 JSValueRef* exception);
52
53         static bool setOnConnect(JSContextRef context, JSObjectRef object,
54                                                 JSStringRef propertyName, JSValueRef value,
55                                                 JSValueRef* exception);
56
57
58         static JSValueRef setSocketNotifier(JSContextRef context, JSObjectRef object,
59                 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
60                 JSValueRef* exception);
61
62         static JSValueRef writeData(JSContextRef context, JSObjectRef object,
63                 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
64                 JSValueRef* exception);
65
66                 
67         static JSValueRef readData(JSContextRef context, JSObjectRef object,
68                 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
69                 JSValueRef* exception);
70
71                 
72         static JSValueRef close(JSContextRef context, JSObjectRef object,
73                 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
74                 JSValueRef* exception);
75
76
77         static JSValueRef getProperty(JSContextRef context,
78                                JSObjectRef object,
79                                JSStringRef propertyName,
80                                JSValueRef* exception);
81
82         static JSValueRef getCallback(JSContextRef context,
83                                JSObjectRef object,
84                                JSStringRef propertyName,
85                                JSValueRef* exception);
86
87         static JSClassDefinition m_classInfo;
88         static JSStaticFunction m_function[];
89         static JSStaticValue m_properties[];
90
91         static JSClassRef m_jsClassRef;
92         static JSObjectRef m_peer;
93         
94 };
95
96
97 }
98
99 #endif
100