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 "BluetoothHealthApplication.h"
19 #include "plugin_config.h"
21 #include <bluetooth.h>
23 #include <GlobalContextManager.h>
25 using namespace DeviceAPI::Common;
30 BluetoothHealthApplication::BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType)
32 Common::SecurityAccessor();
39 BluetoothHealthApplication::~BluetoothHealthApplication()
42 bt_hdp_unregister_sink_app(mAppID.c_str());
45 std::string BluetoothHealthApplication::getAppID() const
50 unsigned short BluetoothHealthApplication::getDataType() const
55 std::string BluetoothHealthApplication::getName() const
60 bool BluetoothHealthApplication::setOnConnect(JSContextRef context, JSObjectRef onConnect)
64 MultiCallbackUserDataPtr callback(
65 new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
67 LoggerW("Can't create MultiCallbackUserData");
70 callback->setCallback("onconnect", onConnect);
71 mOnConnect = callback;
73 return mLocalProperty.setProperty(context, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT, onConnect);
76 MultiCallbackUserDataPtr BluetoothHealthApplication::getOnConnect() const
81 JSValueRef BluetoothHealthApplication::getOnConnect(JSContextRef context)
85 JSValueRef onConnect = mLocalProperty.getProperty(context, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT);
86 if(onConnect == NULL) {
87 LoggerD("onconnect is null");
88 return JSValueMakeNull(context);
94 bool BluetoothHealthApplication::getRegistrationState() const
99 void BluetoothHealthApplication::setRegistrationState(bool isRegistered)
101 mIsRegistered = isRegistered;