2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef TIZENAPIS_TIZEN_JS_BLUETOOTH_SOCKET_H_
19 #define TIZENAPIS_TIZEN_JS_BLUETOOTH_SOCKET_H_
21 #include <JavaScriptCore/JavaScript.h>
22 #include <CommonsJavaScript/PrivateObject.h>
24 #include "IBluetoothSocketManager.h"
26 using namespace WrtDeviceApis::CommonsJavaScript;
31 typedef PrivateObjectT<IBluetoothSocketManagerPtr>::Type JSBluetoothSocketPriv;
32 class JSBluetoothSocket
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);
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);
47 static bool setProperty(JSContextRef context,
49 JSStringRef propertyName,
51 JSValueRef* exception);
53 static bool setOnConnect(JSContextRef context, JSObjectRef object,
54 JSStringRef propertyName, JSValueRef value,
55 JSValueRef* exception);
58 static JSValueRef setSocketNotifier(JSContextRef context, JSObjectRef object,
59 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
60 JSValueRef* exception);
62 static JSValueRef writeData(JSContextRef context, JSObjectRef object,
63 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
64 JSValueRef* exception);
67 static JSValueRef readData(JSContextRef context, JSObjectRef object,
68 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
69 JSValueRef* exception);
72 static JSValueRef close(JSContextRef context, JSObjectRef object,
73 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
74 JSValueRef* exception);
77 static JSValueRef getProperty(JSContextRef context,
79 JSStringRef propertyName,
80 JSValueRef* exception);
82 static JSValueRef getCallback(JSContextRef context,
84 JSStringRef propertyName,
85 JSValueRef* exception);
88 * Sets attributes into JS object.
90 static void setAttributesIntoJSObject(JSContextRef context,
93 static JSClassDefinition m_classInfo;
94 static JSStaticFunction m_function[];
95 static JSStaticValue m_properties[];
97 static JSClassRef m_jsClassRef;