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,
31 std::string name, unsigned short dataType)
33 Common::SecurityAccessor();
40 BluetoothHealthApplication::~BluetoothHealthApplication()
43 bt_hdp_unregister_sink_app(mAppID.c_str());
46 std::string BluetoothHealthApplication::getAppID() const
51 unsigned short BluetoothHealthApplication::getDataType() const
56 std::string BluetoothHealthApplication::getName() const
61 bool BluetoothHealthApplication::setOnConnect(JSContextRef context,
62 JSObjectRef onConnect)
66 MultiCallbackUserDataPtr callback(
67 new MultiCallbackUserData(GlobalContextManager::getInstance()->
68 getGlobalContext(context)));
71 LOGW("Can't create MultiCallbackUserData");
74 callback->setCallback("onconnect", onConnect);
75 mOnConnect = callback;
77 return mLocalProperty.setProperty(context,
78 BLUETOOTH_HEALTH_APPLICATION_ONCONNECT, onConnect);
81 MultiCallbackUserDataPtr BluetoothHealthApplication::getOnConnect() const
86 JSValueRef BluetoothHealthApplication::getOnConnect(JSContextRef context)
90 JSValueRef onConnect = mLocalProperty.getProperty(context,
91 BLUETOOTH_HEALTH_APPLICATION_ONCONNECT);
93 if(onConnect == NULL) {
94 LOGD("onconnect is null");
95 return JSValueMakeNull(context);
101 bool BluetoothHealthApplication::getRegistrationState() const
103 return mIsRegistered;
106 void BluetoothHealthApplication::setRegistrationState(bool isRegistered)
108 mIsRegistered = isRegistered;