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 #include <SecurityExceptions.h>
21 #include <ArgumentValidator.h>
22 #include <GlobalContextManager.h>
23 #include <PlatformException.h>
25 #include "plugin_config.h"
26 #include "JSBluetoothProfileHandler.h"
27 #include "JSBluetoothHealthProfileHandler.h"
29 #include <TimeTracer.h>
32 using namespace WrtDeviceApis::Commons;
33 using namespace DeviceAPI::Common;
38 JSClassDefinition JSBluetoothProfileHandler::m_classInfo = {
40 kJSClassAttributeNone,
41 "BluetoothProfileHandler",
43 m_property, //StaticValues
44 NULL, //StaticFunctions
45 initialize, //Initialize
50 NULL, //DeleteProperty,
51 NULL, //GetPropertyNames,
52 NULL, //CallAsFunction,
53 NULL, //CallAsConstructor,
58 JSStaticValue JSBluetoothProfileHandler::m_property[] = {
60 BLUETOOTH_PROFILE_TYPE,
63 kJSPropertyAttributeNone |
64 kJSPropertyAttributeReadOnly |
65 kJSPropertyAttributeDontDelete
70 JSClassRef JSBluetoothProfileHandler::m_jsClassRef =
71 JSClassCreate(JSBluetoothProfileHandler::getClassInfo());
73 const JSClassRef JSBluetoothProfileHandler::getClassRef()
76 m_jsClassRef = JSClassCreate(&m_classInfo);
81 const JSClassDefinition* JSBluetoothProfileHandler::getClassInfo()
86 void JSBluetoothProfileHandler::initialize(JSContextRef context,
92 void JSBluetoothProfileHandler::finalize(JSObjectRef object)
97 JSValueRef JSBluetoothProfileHandler::getProperty(JSContextRef context,
98 JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
102 if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_PROFILE_TYPE)) {
104 if(JSValueIsObjectOfClass(context, object,
105 JSBluetoothHealthProfileHandler::getClassRef())) {
107 std::string profileType("HEALTH");
108 LOGD("profileType: %s", profileType.c_str());
109 return JSUtil::toJSValueRef(context, profileType);
113 LOGE("object is NULL");
116 } catch (const BasePlatformException &err) {
117 LOGW("Getting property is failed %s", err.getMessage().c_str());