Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.46
+Version: 0.4.47
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
TIME_TRACER_ITEM_BEGIN("(getAppMetaData)ACE", 0);
- //AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_META_DATA);
- //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_META_DATA);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
TIME_TRACER_ITEM_END("(getAppMetaData)ACE", 0);
try {
#include <Logger.h>
#include <JSWebAPIErrorFactory.h>
-#include <system_info.h>
#include <JSUtil.h>
#include <TimeTracer.h>
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <Ecore.h>\r
-\r
-#include <JSUtil.h>\r
-#include <JSWebAPIErrorFactory.h>\r
-#include <Logger.h>\r
-\r
-#include "BluetoothCallback.h"\r
-\r
-\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-\r
-class BluetoothCallbackData\r
-{\r
-public:\r
- BluetoothCallbackData(MultiCallbackUserDataPtr callback)\r
- {\r
- mCallback = callback;\r
- mError = NULL;\r
- };\r
-\r
- BluetoothCallbackData(MultiCallbackUserDataPtr callback, Common::BasePlatformException *error)\r
- {\r
- mCallback = callback;\r
- mError = error;\r
- }; \r
-\r
- virtual ~BluetoothCallbackData()\r
- {\r
- if(mError)\r
- delete mError;\r
- };\r
-\r
- MultiCallbackUserDataPtr mCallback;\r
- Common::BasePlatformException *mError;\r
-};\r
-\r
-typedef BluetoothCallbackData* BluetoothCallbackDataPtr;\r
-\r
-\r
-static Eina_Bool jobCompleteCB(void *userData){\r
- BluetoothCallbackDataPtr data = static_cast<BluetoothCallbackDataPtr>(userData);\r
-\r
- if(!data) {\r
- LoggerW("BluetoothCallbackDataPtr is NULL");\r
- return false;\r
- }\r
-\r
- if(!(data->mCallback)) {\r
- LoggerW("MulticallbackUserData is NULL");\r
- delete data;\r
- return false; \r
- }\r
-\r
- if(data->mError == NULL) { // Success Callback\r
- LoggerD("Success Callback");\r
- data->mCallback->invokeCallback("success"); \r
- }\r
- else { // Error Callback\r
- LoggerD("BT_CB_ERROR");\r
- data->mCallback->invokeCallback("error", JSWebAPIErrorFactory::makeErrorObject(data->mCallback->getContext(), *(data->mError))); \r
- }\r
-\r
- delete data;\r
- return false;\r
-}\r
-\r
-void BluetoothCallback::syncToAsyncSuccessCB(MultiCallbackUserDataPtr callback)\r
-{\r
- BluetoothCallbackDataPtr data = new BluetoothCallbackData(callback);\r
- ecore_idler_add(jobCompleteCB, data);\r
-}\r
-\r
-void BluetoothCallback::syncToAsyncErrorCB(MultiCallbackUserDataPtr callback, Common::BasePlatformException *error)\r
-{\r
- BluetoothCallbackDataPtr data = new BluetoothCallbackData(callback, error);\r
- ecore_idler_add(jobCompleteCB, data);\r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <Ecore.h>
+
+#include <JSUtil.h>
+#include <JSWebAPIErrorFactory.h>
+#include <Logger.h>
+
+#include "BluetoothCallback.h"
+
+
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+
+class BluetoothCallbackData
+{
+public:
+ BluetoothCallbackData(MultiCallbackUserDataPtr callback)
+ {
+ mCallback = callback;
+ mError = NULL;
+ };
+
+ BluetoothCallbackData(MultiCallbackUserDataPtr callback, Common::BasePlatformException *error)
+ {
+ mCallback = callback;
+ mError = error;
+ };
+
+ virtual ~BluetoothCallbackData()
+ {
+ if(mError)
+ delete mError;
+ };
+
+ MultiCallbackUserDataPtr mCallback;
+ Common::BasePlatformException *mError;
+};
+
+typedef BluetoothCallbackData* BluetoothCallbackDataPtr;
+
+
+static Eina_Bool jobCompleteCB(void *userData){
+ BluetoothCallbackDataPtr data = static_cast<BluetoothCallbackDataPtr>(userData);
+
+ if(!data) {
+ LoggerW("BluetoothCallbackDataPtr is NULL");
+ return false;
+ }
+
+ if(!(data->mCallback)) {
+ LoggerW("MulticallbackUserData is NULL");
+ delete data;
+ return false;
+ }
+
+ if(data->mError == NULL) { // Success Callback
+ LoggerD("Success Callback");
+ data->mCallback->invokeCallback("success");
+ }
+ else { // Error Callback
+ LoggerD("BT_CB_ERROR");
+ data->mCallback->invokeCallback("error", JSWebAPIErrorFactory::makeErrorObject(data->mCallback->getContext(), *(data->mError)));
+ }
+
+ delete data;
+ return false;
+}
+
+void BluetoothCallback::syncToAsyncSuccessCB(MultiCallbackUserDataPtr callback)
+{
+ BluetoothCallbackDataPtr data = new BluetoothCallbackData(callback);
+ ecore_idler_add(jobCompleteCB, data);
+}
+
+void BluetoothCallback::syncToAsyncErrorCB(MultiCallbackUserDataPtr callback, Common::BasePlatformException *error)
+{
+ BluetoothCallbackDataPtr data = new BluetoothCallbackData(callback, error);
+ ecore_idler_add(jobCompleteCB, data);
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_BLUETOOTH_CALLBACK_H__\r
-#define __TIZEN_BLUETOOTH_CALLBACK_H__\r
-\r
-#include <string>\r
-#include <MultiCallbackUserData.h>\r
-#include <PlatformException.h>\r
-\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-\r
-class BluetoothCallback\r
-{\r
-public:\r
- static void syncToAsyncSuccessCB(DeviceAPI::Common::MultiCallbackUserDataPtr userData);\r
- static void syncToAsyncErrorCB(DeviceAPI::Common::MultiCallbackUserDataPtr userData, Common::BasePlatformException *error);\r
-};\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-\r
-\r
-#endif // __TIZEN_BLUETOOTH_CALLBACK_H__\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_BLUETOOTH_CALLBACK_H__
+#define __TIZEN_BLUETOOTH_CALLBACK_H__
+
+#include <string>
+#include <MultiCallbackUserData.h>
+#include <PlatformException.h>
+
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+
+class BluetoothCallback
+{
+public:
+ static void syncToAsyncSuccessCB(DeviceAPI::Common::MultiCallbackUserDataPtr userData);
+ static void syncToAsyncErrorCB(DeviceAPI::Common::MultiCallbackUserDataPtr userData, Common::BasePlatformException *error);
+};
+
+
+} // Bluetooth
+} // DeviceAPI
+
+
+
+#endif // __TIZEN_BLUETOOTH_CALLBACK_H__
+
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include "BluetoothHealthApplication.h"\r
-#include "plugin_config.h"\r
-\r
-#include <bluetooth.h>\r
-#include <Logger.h>\r
-#include <GlobalContextManager.h>\r
-\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-BluetoothHealthApplication::BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType)\r
-{\r
- mAppID = appID;\r
- mName = name;\r
- mDataType = dataType;\r
- mIsRegistered = true;\r
-}\r
-\r
-BluetoothHealthApplication::~BluetoothHealthApplication()\r
-{\r
- if(mIsRegistered)\r
- bt_hdp_unregister_sink_app(mAppID.c_str());\r
-}\r
-\r
-std::string BluetoothHealthApplication::getAppID() const\r
-{\r
- return mAppID;\r
-}\r
-\r
-unsigned short BluetoothHealthApplication::getDataType() const\r
-{\r
- return mDataType;\r
-}\r
-\r
-std::string BluetoothHealthApplication::getName() const\r
-{\r
- return mName;\r
-}\r
-\r
-bool BluetoothHealthApplication::setOnConnect(JSContextRef context, JSObjectRef onConnect)\r
-{\r
- MultiCallbackUserDataPtr callback(\r
- new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));\r
- if(!callback){\r
- LoggerW("Can't create MultiCallbackUserData");\r
- return false;\r
- } \r
- callback->setCallback("onconnect", onConnect);\r
- mOnConnect = callback;\r
-\r
- return mLocalProperty.setProperty(context, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT, onConnect);\r
-}\r
-\r
-MultiCallbackUserDataPtr BluetoothHealthApplication::getOnConnect() const\r
-{\r
- return mOnConnect;\r
-}\r
-\r
-JSValueRef BluetoothHealthApplication::getOnConnect(JSContextRef context)\r
-{\r
- JSValueRef onConnect = mLocalProperty.getProperty(context, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT);\r
- if(onConnect == NULL) {\r
- LoggerD("onconnect is null");\r
- return JSValueMakeNull(context);\r
- }\r
- \r
- return onConnect;\r
-}\r
-\r
-bool BluetoothHealthApplication::getRegistrationState() const\r
-{\r
- return mIsRegistered;\r
-}\r
-\r
-void BluetoothHealthApplication::setRegistrationState(bool isRegistered)\r
-{\r
- mIsRegistered = isRegistered;\r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include "BluetoothHealthApplication.h"
+#include "plugin_config.h"
+
+#include <bluetooth.h>
+#include <Logger.h>
+#include <GlobalContextManager.h>
+
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+BluetoothHealthApplication::BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType)
+{
+ mAppID = appID;
+ mName = name;
+ mDataType = dataType;
+ mIsRegistered = true;
+}
+
+BluetoothHealthApplication::~BluetoothHealthApplication()
+{
+ if(mIsRegistered)
+ bt_hdp_unregister_sink_app(mAppID.c_str());
+}
+
+std::string BluetoothHealthApplication::getAppID() const
+{
+ return mAppID;
+}
+
+unsigned short BluetoothHealthApplication::getDataType() const
+{
+ return mDataType;
+}
+
+std::string BluetoothHealthApplication::getName() const
+{
+ return mName;
+}
+
+bool BluetoothHealthApplication::setOnConnect(JSContextRef context, JSObjectRef onConnect)
+{
+ LoggerD("Enter");
+
+ MultiCallbackUserDataPtr callback(
+ new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+ if(!callback){
+ LoggerW("Can't create MultiCallbackUserData");
+ return false;
+ }
+ callback->setCallback("onconnect", onConnect);
+ mOnConnect = callback;
+
+ return mLocalProperty.setProperty(context, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT, onConnect);
+}
+
+MultiCallbackUserDataPtr BluetoothHealthApplication::getOnConnect() const
+{
+ return mOnConnect;
+}
+
+JSValueRef BluetoothHealthApplication::getOnConnect(JSContextRef context)
+{
+ LoggerD("Enter");
+
+ JSValueRef onConnect = mLocalProperty.getProperty(context, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT);
+ if(onConnect == NULL) {
+ LoggerD("onconnect is null");
+ return JSValueMakeNull(context);
+ }
+
+ return onConnect;
+}
+
+bool BluetoothHealthApplication::getRegistrationState() const
+{
+ return mIsRegistered;
+}
+
+void BluetoothHealthApplication::setRegistrationState(bool isRegistered)
+{
+ mIsRegistered = isRegistered;
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_BLUETOOTH_HEALTH_APPLICATION_H__\r
-#define __TIZEN_BLUETOOTH_HEALTH_APPLICATION_H__\r
-\r
-#include <string>\r
-\r
-#include <JavaScriptCore/JavaScript.h>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-#include <MultiCallbackUserData.h>\r
-#include <PropertyBag.h>\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class BluetoothHealthApplication\r
-{\r
-public:\r
- BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType);\r
- virtual ~BluetoothHealthApplication();\r
-\r
- std::string getAppID() const;\r
- unsigned short getDataType() const;\r
- std::string getName() const; \r
- bool getRegistrationState() const;\r
- void setRegistrationState(bool isRegistered);\r
- Common::MultiCallbackUserDataPtr getOnConnect() const;\r
- JSValueRef getOnConnect(JSContextRef context);\r
- bool setOnConnect(JSContextRef context, JSObjectRef onConnect);\r
-\r
-\r
-private:\r
- std::string mAppID;\r
- std::string mName;\r
- bool mIsRegistered;\r
- Common::MultiCallbackUserDataPtr mOnConnect; \r
- unsigned short mDataType;\r
- Common::PropertyBag mLocalProperty; \r
-};\r
-\r
-typedef boost::shared_ptr<BluetoothHealthApplication> BluetoothHealthApplicationSharedPtr;\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_BLUETOOTH_HEALTH_APPLICATION_H__\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_BLUETOOTH_HEALTH_APPLICATION_H__
+#define __TIZEN_BLUETOOTH_HEALTH_APPLICATION_H__
+
+#include <string>
+
+#include <JavaScriptCore/JavaScript.h>
+#include <boost/shared_ptr.hpp>
+
+#include <MultiCallbackUserData.h>
+#include <PropertyBag.h>
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class BluetoothHealthApplication
+{
+public:
+ BluetoothHealthApplication(std::string appID, std::string name, unsigned short dataType);
+ virtual ~BluetoothHealthApplication();
+
+ std::string getAppID() const;
+ unsigned short getDataType() const;
+ std::string getName() const;
+ bool getRegistrationState() const;
+ void setRegistrationState(bool isRegistered);
+ Common::MultiCallbackUserDataPtr getOnConnect() const;
+ JSValueRef getOnConnect(JSContextRef context);
+ bool setOnConnect(JSContextRef context, JSObjectRef onConnect);
+
+
+private:
+ std::string mAppID;
+ std::string mName;
+ bool mIsRegistered;
+ Common::MultiCallbackUserDataPtr mOnConnect;
+ unsigned short mDataType;
+ Common::PropertyBag mLocalProperty;
+};
+
+typedef boost::shared_ptr<BluetoothHealthApplication> BluetoothHealthApplicationSharedPtr;
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_BLUETOOTH_HEALTH_APPLICATION_H__
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <GlobalContextManager.h>\r
-#include <PlatformException.h>\r
-\r
-#include "BluetoothHealthChannel.h"\r
-#include "JSBluetoothDevice.h"\r
-#include "JSBluetoothHealthApplication.h"\r
-\r
-#include <Logger.h>\r
-#include <TimeTracer.h>\r
-\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-BluetoothHealthChannel::BluetoothHealthChannel(unsigned int channel, BluetoothDeviceSharedPtr remoteDevice, \r
- bt_hdp_channel_type_e type, BluetoothHealthApplicationSharedPtr application)\r
-{\r
- mChannel = channel;\r
- mRemoteDevice = remoteDevice;\r
- if(type == BT_HDP_CHANNEL_TYPE_RELIABLE) {\r
- mChannelTypeStr = "RELIABLE";\r
- }\r
- else {\r
- mChannelTypeStr = "STREAMING";\r
- }\r
- mChannelType = type;\r
- mApp = application;\r
- mIsConnected = true;\r
-}\r
-\r
-BluetoothHealthChannel::~BluetoothHealthChannel()\r
-{\r
- if(mIsConnected) {\r
- bt_hdp_disconnect(mRemoteDevice->getAddress().c_str(), mChannel);\r
- }\r
-}\r
-\r
-bool BluetoothHealthChannel::getConnectionState() const\r
-{\r
- return mIsConnected;\r
-}\r
-\r
-void BluetoothHealthChannel::setConnectionState(bool isConnected)\r
-{\r
- mIsConnected = isConnected;\r
-}\r
-\r
-unsigned int BluetoothHealthChannel::getChannel() const\r
-{\r
- return mChannel;\r
-}\r
-\r
-std::string BluetoothHealthChannel::getChannelTypeStr() const\r
-{\r
- return mChannelTypeStr;\r
-}\r
-\r
-bt_hdp_channel_type_e BluetoothHealthChannel::getChannelType() const\r
-{\r
- return mChannelType;\r
-}\r
-\r
-JSValueRef BluetoothHealthChannel::getApp(JSContextRef context)\r
-{\r
- return JSBluetoothHealthApplication::createJSObject(context, mApp);\r
-}\r
-\r
-JSValueRef BluetoothHealthChannel::getPeer(JSContextRef context)\r
-{\r
- return JSBluetoothDevice::createJSObject(context, mRemoteDevice);\r
-}\r
-\r
-Common::MultiCallbackUserDataPtr BluetoothHealthChannel::getListener() const\r
-{\r
- return mListener;\r
-}\r
-\r
-unsigned long BluetoothHealthChannel::sendData(char* data, unsigned long size)\r
-{\r
- unsigned long ret = 0;\r
- TIME_TRACER_ITEM_BEGIN("sendData::bt_hdp_send_data", 1);\r
- if(bt_hdp_send_data(mChannel, data, static_cast<unsigned int>(size)) == BT_ERROR_NONE) {\r
- TIME_TRACER_ITEM_END("sendData::bt_hdp_send_data", 1);\r
- LoggerD("bt_hdp_send_data() succeeded");\r
- ret = size;\r
- }\r
- else {\r
- throw UnknownException("Unknown error");\r
- }\r
-\r
- //delete data;\r
- return ret;\r
-}\r
-\r
-void BluetoothHealthChannel::close()\r
-{\r
- if(!mIsConnected) {\r
- LoggerD("Already disconnected");\r
- return;\r
- }\r
-\r
- TIME_TRACER_ITEM_BEGIN("close::bt_hdp_disconnect", 1);\r
- if(bt_hdp_disconnect(mRemoteDevice->getAddress().c_str(), mChannel) != BT_ERROR_NONE) {\r
- LoggerE("bt_hdp_disconnect() failed");\r
- throw UnknownException("Unknown error");\r
- }\r
- TIME_TRACER_ITEM_END("close::bt_hdp_disconnect", 1);\r
-\r
- mIsConnected = false;\r
-}\r
-\r
-void BluetoothHealthChannel::setListener(Common::MultiCallbackUserDataPtr callback)\r
-{\r
- mListener = callback;\r
-}\r
-\r
-void BluetoothHealthChannel::unsetListener()\r
-{\r
- mListener.reset();\r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <GlobalContextManager.h>
+#include <PlatformException.h>
+
+#include "BluetoothHealthChannel.h"
+#include "JSBluetoothDevice.h"
+#include "JSBluetoothHealthApplication.h"
+
+#include <Logger.h>
+#include <TimeTracer.h>
+
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+BluetoothHealthChannel::BluetoothHealthChannel(unsigned int channel, BluetoothDeviceSharedPtr remoteDevice,
+ bt_hdp_channel_type_e type, BluetoothHealthApplicationSharedPtr application)
+{
+ mChannel = channel;
+ mRemoteDevice = remoteDevice;
+ if(type == BT_HDP_CHANNEL_TYPE_RELIABLE) {
+ mChannelTypeStr = "RELIABLE";
+ }
+ else {
+ mChannelTypeStr = "STREAMING";
+ }
+ mChannelType = type;
+ mApp = application;
+ mIsConnected = true;
+}
+
+BluetoothHealthChannel::~BluetoothHealthChannel()
+{
+ if(mIsConnected) {
+ bt_hdp_disconnect(mRemoteDevice->getAddress().c_str(), mChannel);
+ }
+}
+
+bool BluetoothHealthChannel::getConnectionState() const
+{
+ return mIsConnected;
+}
+
+void BluetoothHealthChannel::setConnectionState(bool isConnected)
+{
+ mIsConnected = isConnected;
+}
+
+unsigned int BluetoothHealthChannel::getChannel() const
+{
+ return mChannel;
+}
+
+std::string BluetoothHealthChannel::getChannelTypeStr() const
+{
+ return mChannelTypeStr;
+}
+
+bt_hdp_channel_type_e BluetoothHealthChannel::getChannelType() const
+{
+ return mChannelType;
+}
+
+JSValueRef BluetoothHealthChannel::getApp(JSContextRef context)
+{
+ return JSBluetoothHealthApplication::createJSObject(context, mApp);
+}
+
+JSValueRef BluetoothHealthChannel::getPeer(JSContextRef context)
+{
+ return JSBluetoothDevice::createJSObject(context, mRemoteDevice);
+}
+
+Common::MultiCallbackUserDataPtr BluetoothHealthChannel::getListener() const
+{
+ return mListener;
+}
+
+unsigned long BluetoothHealthChannel::sendData(char* data, unsigned long size)
+{
+ unsigned long ret = 0;
+ TIME_TRACER_ITEM_BEGIN("sendData::bt_hdp_send_data", 1);
+ if(bt_hdp_send_data(mChannel, data, static_cast<unsigned int>(size)) == BT_ERROR_NONE) {
+ TIME_TRACER_ITEM_END("sendData::bt_hdp_send_data", 1);
+ LoggerD("bt_hdp_send_data() succeeded");
+ ret = size;
+ }
+ else {
+ throw UnknownException("Unknown error");
+ }
+
+ //delete data;
+ return ret;
+}
+
+void BluetoothHealthChannel::close()
+{
+ LoggerD("Enter");
+ if(!mIsConnected) {
+ LoggerD("Already disconnected");
+ return;
+ }
+
+ TIME_TRACER_ITEM_BEGIN("close::bt_hdp_disconnect", 1);
+ if(bt_hdp_disconnect(mRemoteDevice->getAddress().c_str(), mChannel) != BT_ERROR_NONE) {
+ LoggerE("bt_hdp_disconnect() failed");
+ throw UnknownException("Unknown error");
+ }
+ TIME_TRACER_ITEM_END("close::bt_hdp_disconnect", 1);
+
+ mIsConnected = false;
+
+ LoggerD("End");
+}
+
+void BluetoothHealthChannel::setListener(Common::MultiCallbackUserDataPtr callback)
+{
+ mListener = callback;
+}
+
+void BluetoothHealthChannel::unsetListener()
+{
+ mListener.reset();
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_BLUETOOTH_HEALTH_CHANNEL_H__\r
-#define __TIZEN_BLUETOOTH_HEALTH_CHANNEL_H__\r
-\r
-#include <string>\r
-#include <bluetooth.h>\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-#include <MultiCallbackUserData.h>\r
-#include "BluetoothDevice.h"\r
-#include "BluetoothHealthApplication.h"\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class BluetoothHealthChannel\r
-{\r
-public:\r
- BluetoothHealthChannel(unsigned int channel, BluetoothDeviceSharedPtr remoteDevice, bt_hdp_channel_type_e type, BluetoothHealthApplicationSharedPtr application);\r
- virtual ~BluetoothHealthChannel();\r
-\r
- bool getConnectionState() const;\r
- void setConnectionState(bool isConnected);\r
- unsigned int getChannel() const;\r
- std::string getChannelTypeStr() const;\r
- bt_hdp_channel_type_e getChannelType() const;\r
- JSValueRef getApp(JSContextRef context);\r
- JSValueRef getPeer(JSContextRef context); \r
- Common::MultiCallbackUserDataPtr getListener() const;\r
- \r
- unsigned long sendData(char* data, unsigned long size);\r
- void close();\r
- void setListener(Common::MultiCallbackUserDataPtr callback);\r
- void unsetListener(); \r
-\r
-private:\r
- unsigned int mChannel;\r
- bool mIsConnected;\r
- std::string mChannelTypeStr;\r
- bt_hdp_channel_type_e mChannelType;\r
- BluetoothDeviceSharedPtr mRemoteDevice;\r
- BluetoothHealthApplicationSharedPtr mApp;\r
-\r
- Common::MultiCallbackUserDataPtr mListener;\r
-};\r
-\r
-typedef BluetoothHealthChannel* BluetoothHealthChannelPtr;\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_BLUETOOTH_HEALTH_CHANNEL_H__\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_BLUETOOTH_HEALTH_CHANNEL_H__
+#define __TIZEN_BLUETOOTH_HEALTH_CHANNEL_H__
+
+#include <string>
+#include <bluetooth.h>
+#include <JavaScriptCore/JavaScript.h>
+
+#include <MultiCallbackUserData.h>
+#include "BluetoothDevice.h"
+#include "BluetoothHealthApplication.h"
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class BluetoothHealthChannel
+{
+public:
+ BluetoothHealthChannel(unsigned int channel, BluetoothDeviceSharedPtr remoteDevice, bt_hdp_channel_type_e type, BluetoothHealthApplicationSharedPtr application);
+ virtual ~BluetoothHealthChannel();
+
+ bool getConnectionState() const;
+ void setConnectionState(bool isConnected);
+ unsigned int getChannel() const;
+ std::string getChannelTypeStr() const;
+ bt_hdp_channel_type_e getChannelType() const;
+ JSValueRef getApp(JSContextRef context);
+ JSValueRef getPeer(JSContextRef context);
+ Common::MultiCallbackUserDataPtr getListener() const;
+
+ unsigned long sendData(char* data, unsigned long size);
+ void close();
+ void setListener(Common::MultiCallbackUserDataPtr callback);
+ void unsetListener();
+
+private:
+ unsigned int mChannel;
+ bool mIsConnected;
+ std::string mChannelTypeStr;
+ bt_hdp_channel_type_e mChannelType;
+ BluetoothDeviceSharedPtr mRemoteDevice;
+ BluetoothHealthApplicationSharedPtr mApp;
+
+ Common::MultiCallbackUserDataPtr mListener;
+};
+
+typedef BluetoothHealthChannel* BluetoothHealthChannelPtr;
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_BLUETOOTH_HEALTH_CHANNEL_H__
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-\r
-#include <Logger.h>\r
-#include <JSWebAPIErrorFactory.h>\r
-#include <system_info.h>\r
-#include <JSUtil.h>\r
-#include <TimeTracer.h>\r
-\r
-#include "BluetoothHealthProfileHandler.h"\r
-#include "BluetoothHealthProfileHandlerCallback.h"\r
-#include "JSBluetoothHealthApplication.h"\r
-#include "JSBluetoothDevice.h"\r
-#include "JSBluetoothHealthChannel.h"\r
-#include "BluetoothHealthChannel.h"\r
-\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-void BluetoothHealthProfileHandler::onConnected(int result, const char *remote_address, const char *app_id, \r
- bt_hdp_channel_type_e type, unsigned int channel, void *userData)\r
-{\r
- LoggerD("Enter");\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
-\r
- HealthProfileHandlerPtr object = static_cast<HealthProfileHandlerPtr>(userData);\r
- if(!object) {\r
- LoggerW("userData is NULL");\r
- return;\r
- }\r
-\r
- if(result != BT_ERROR_NONE) {\r
- LoggerD("Not BT_ERROR_NONE");\r
- }\r
-\r
- LoggerD("Connected app: " << app_id);\r
- LoggerD("Connected channel: " << channel);\r
-\r
- std::string appID(app_id);\r
- RegisteredHealthAppMapT::iterator iter = object->mRegisteredHealthAppMap.find(appID);\r
- if(iter == object->mRegisteredHealthAppMap.end()) {\r
- LoggerW("This app is not registered");\r
- return; \r
- }\r
- BluetoothHealthApplicationSharedPtr application = iter->second;\r
-\r
- // call BluetoothHealthApplication.onconnect\r
- if(result == BT_ERROR_NONE) {\r
- Common::MultiCallbackUserDataPtr callback = application->getOnConnect();\r
- if(callback) {\r
- bt_device_info_s *deviceInfo = NULL;\r
- if(bt_adapter_get_bonded_device_info(remote_address, &deviceInfo) == BT_ERROR_NONE &&\r
- deviceInfo != NULL) { \r
- BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo));\r
- bt_adapter_free_device_info(deviceInfo);\r
- \r
- LoggerD("invoke BluetoothHealthApplication.onconnect");\r
- BluetoothHealthChannelPtr healthChannel = new BluetoothHealthChannel(channel, device, type, application); \r
- object->mConnectedSocketMap.insert(std::pair<unsigned int, BluetoothHealthChannelPtr>(channel, healthChannel));\r
- callback->invokeCallback("success", JSBluetoothHealthChannel::createJSObject(callback->getContext(), healthChannel)); \r
- }\r
- else {\r
- LoggerE("Can't call BluetoothHealthApplication.onconnect because failed to get device info");\r
- }\r
- }\r
- else {\r
- LoggerD("BluetoothHealthApplication.onconnect is not set");\r
- }\r
- }\r
-\r
- // in case of connectToSource()\r
- HealthConnReqMapT::iterator i = object->mHealthConnReqMap.find(application);\r
- if(i != object->mHealthConnReqMap.end()) {\r
- LoggerD("Requested connection");\r
- Common::MultiCallbackUserDataPtr callback = i->second->mUserData;\r
- if(callback) {\r
- if(result == BT_ERROR_NONE) {\r
- BluetoothHealthChannelPtr healthChannel = new BluetoothHealthChannel(channel, i->second->mRemoteDevice, type, application); \r
- //object->mConnectedSocketMap.insert(std::pair<unsigned int, BluetoothHealthChannelPtr>(channel, healthChannel));\r
- callback->invokeCallback("success", JSBluetoothHealthChannel::createJSObject(callback->getContext(), healthChannel)); \r
- }\r
- else {\r
- LoggerE("Failed to establish a connection with health profile");\r
- callback->invokeCallback("error", \r
- JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), UnknownException("Failed to establish a connection with health profile")));\r
- } \r
- } \r
-\r
- // Update mHealthConnReqMap\r
- object->mHealthConnReqMap.erase(i); \r
- }\r
- else {\r
- LoggerD("There is no connection request");\r
- } \r
-\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);\r
-}\r
-\r
-void BluetoothHealthProfileHandler::onDisconnected(int result, const char *remote_address, unsigned int channel, void *userData)\r
-{\r
- LoggerD("Enter");\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
-\r
- HealthProfileHandlerPtr object = static_cast<HealthProfileHandlerPtr>(userData);\r
- if(!object) {\r
- LoggerW("userData is NULL");\r
- return;\r
- }\r
-\r
- LoggerD("Disconnected channel: " << channel);\r
- HealthConnectedSocketMapT::iterator iter = object->mConnectedSocketMap.find(channel);\r
- if(iter == object->mConnectedSocketMap.end()) {\r
- LoggerW("Unexpected health disconnection event");\r
- return;\r
- }\r
-\r
- if(result == BT_ERROR_NONE) {\r
- BluetoothHealthChannelPtr healthChannel = iter->second;\r
- object->mConnectedSocketMap.erase(iter);\r
-\r
- healthChannel->setConnectionState(false);\r
- MultiCallbackUserDataPtr callback = healthChannel->getListener();\r
- if(callback)\r
- callback->invokeCallback("onclose"); \r
- }\r
- else {\r
- LoggerW("Failed to disconnect a connection");\r
- }\r
- \r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);\r
-}\r
-\r
-void BluetoothHealthProfileHandler::onDataReceivedCB(unsigned int channel, const char *data, unsigned int size, void *userData)\r
-{\r
- LoggerD("Enter");\r
-\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
-\r
- HealthProfileHandlerPtr object = static_cast<HealthProfileHandlerPtr>(userData);\r
- if(!object) {\r
- LoggerW("userData is NULL");\r
- return;\r
- }\r
-\r
- LoggerD("data channel: " << channel);\r
- LoggerD("sent data size: " << size);\r
- HealthConnectedSocketMapT::iterator iter = object->mConnectedSocketMap.find(channel);\r
- if(iter == object->mConnectedSocketMap.end()) {\r
- LoggerW("Unexpected health data received event");\r
- return;\r
- }\r
-\r
- BluetoothHealthChannelPtr healthChannel = iter->second;\r
- MultiCallbackUserDataPtr callback = healthChannel->getListener(); \r
- if(callback) {\r
- std::vector<signed char> receivedData;\r
- for(unsigned int i = 0; i < size; i++) {\r
- receivedData.push_back(static_cast<signed char>(data[i]));\r
- }\r
- callback->invokeCallback("onmessage", JSUtil::toJSValueRef_(callback->getContext(), receivedData));\r
- }\r
- \r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);\r
-}\r
-\r
-BluetoothHealthProfileHandler* BluetoothHealthProfileHandler::getInstance()\r
-{\r
- static BluetoothHealthProfileHandler instance;\r
- return &instance;\r
-}\r
-\r
-BluetoothHealthProfileHandler::BluetoothHealthProfileHandler()\r
-{\r
- if(bt_hdp_set_connection_state_changed_cb(onConnected, onDisconnected, this) != BT_ERROR_NONE) {\r
- LoggerE("bt_hdp_set_connection_state_changed_cb() failed");\r
- }\r
-\r
- if(bt_hdp_set_data_received_cb(onDataReceivedCB, this) != BT_ERROR_NONE) {\r
- LoggerE("bt_hdp_set_data_received_cb() failed");\r
- } \r
-}\r
-\r
-BluetoothHealthProfileHandler::~BluetoothHealthProfileHandler()\r
-{\r
- // unset platform callback\r
- bt_hdp_unset_connection_state_changed_cb();\r
- bt_hdp_unset_data_received_cb();\r
-\r
- mHealthConnReqMap.clear();\r
- mConnectedSocketMap.clear();\r
- mRegisteredHealthAppMap.clear(); \r
-}\r
-\r
-void BluetoothHealthProfileHandler::registerSinkApp(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncRegisterCB(callback, dataType, name);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-\r
-void BluetoothHealthProfileHandler::returnRegisteringSinkAppResult(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- LoggerD("Enter");\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- \r
- char *app_id = NULL;\r
- int ret = bt_hdp_register_sink_app(dataType, &app_id);\r
- switch(ret) {\r
- case BT_ERROR_NONE:\r
- {\r
- LoggerD("Registered app: " << app_id);\r
- std::string appID(app_id);\r
- free(app_id);\r
- BluetoothHealthApplicationSharedPtr application(new BluetoothHealthApplication(appID, name, dataType));\r
- mRegisteredHealthAppMap.insert(std::pair<std::string, BluetoothHealthApplicationSharedPtr>(appID, application));\r
- if(callback)\r
- callback->invokeCallback("success", JSBluetoothHealthApplication::createJSObject(callback->getContext(), application));\r
- break;\r
- }\r
- case BT_ERROR_NOT_ENABLED:\r
- {\r
- if(callback) {\r
- callback->invokeCallback("error", \r
- JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), ServiceNotAvailableException("Bluetooth device is turned off"))); \r
- }\r
- break;\r
- }\r
- default:\r
- {\r
- if(callback) {\r
- callback->invokeCallback("error", \r
- JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), UnknownException("Unknown error"))); \r
- }\r
- }\r
- }\r
- \r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-\r
-/*\r
-void BluetoothHealthProfileHandler::unregisterSinkApplication(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(callback, appObj);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-\r
-void BluetoothHealthProfileHandler::returnUnregisteringResult(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- \r
- BluetoothHealthApplicationSharedPtr app = JSBluetoothHealthApplication::toBluetoothHealthApplication(appObj);\r
- int ret = bt_hdp_unregister_sink_app(app->getAppID().c_str());\r
- switch(ret) {\r
- case BT_ERROR_NONE:\r
- {\r
- //app->setRegistrationState(false);\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncSuccessCB(callback);\r
- break;\r
- }\r
- case BT_ERROR_NOT_ENABLED:\r
- {\r
- ServiceNotAvailableException *error = new ServiceNotAvailableException("Bluetooth device is turned off");\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);\r
- break;\r
- }\r
- default:\r
- {\r
- UnknownException *error = new UnknownException("Unknown error");\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);\r
- } \r
- }\r
- \r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-*/\r
-\r
-void BluetoothHealthProfileHandler::unregisterApp(std::string appID, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(callback, appID);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-\r
-void BluetoothHealthProfileHandler::returnUnregisteringAppResult(std::string appID, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1); \r
-\r
- RegisteredHealthAppMapT::iterator iter = mRegisteredHealthAppMap.find(appID);\r
- BluetoothHealthApplicationSharedPtr application;\r
- if(iter != mRegisteredHealthAppMap.end()) {\r
- LoggerE("registered Health Application is found");\r
- application = iter->second; \r
- }\r
- else {\r
- LoggerD("Already unregistered");\r
- if(callback)\r
- callback->invokeCallback("success");\r
- return;\r
- } \r
-\r
- int ret = bt_hdp_unregister_sink_app(appID.c_str());\r
- switch(ret) {\r
- case BT_ERROR_NONE:\r
- {\r
- mRegisteredHealthAppMap.erase(iter);\r
- application->setRegistrationState(false);\r
- if(callback)\r
- callback->invokeCallback("success"); \r
- break;\r
- }\r
- case BT_ERROR_NOT_ENABLED:\r
- {\r
- if(callback) {\r
- callback->invokeCallback("error", \r
- JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), ServiceNotAvailableException("Bluetooth device is turned off"))); \r
- }\r
- break;\r
- }\r
- default:\r
- {\r
- if(callback) {\r
- callback->invokeCallback("error", \r
- JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), UnknownException("Unknown error"))); \r
- }\r
- } \r
- }\r
- \r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-\r
-void BluetoothHealthProfileHandler::connectToSource(JSObjectRef remoteDeviceObj, JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback)\r
-{\r
- LoggerD("Enter");\r
- \r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
-\r
- BluetoothDeviceSharedPtr device = JSBluetoothDevice::toBluetoothDevice(remoteDeviceObj);\r
- BluetoothHealthApplicationSharedPtr app = JSBluetoothHealthApplication::toBluetoothHealthApplication(appObj);\r
- LoggerD("address: " << device->getAddress().c_str());\r
- LoggerD("app ID: " << app->getAppID().c_str()); \r
- int ret = bt_hdp_connect_to_source(device->getAddress().c_str(), app->getAppID().c_str());\r
- switch(ret) {\r
- case BT_ERROR_NONE:\r
- {\r
- LoggerD("NONE");\r
- HealthConnReqPtr connReq = new HealthConnReq(device, callback);\r
- mHealthConnReqMap.insert(std::pair<BluetoothHealthApplicationSharedPtr, HealthConnReqPtr>(app, connReq)); \r
- break;\r
- }\r
- case BT_ERROR_NOT_ENABLED:\r
- {\r
- LoggerD("Not Enabled");\r
- ServiceNotAvailableException *error = new ServiceNotAvailableException("Bluetooth device is turned off");\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);\r
- break;\r
- }\r
- case BT_ERROR_INVALID_PARAMETER:\r
- case BT_ERROR_REMOTE_DEVICE_NOT_BONDED:\r
- {\r
- LoggerD("invalid value");\r
- InvalidValuesException *error = new InvalidValuesException("Invalid value");\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);\r
- break;\r
- }\r
- default:\r
- {\r
- LoggerD("Unknown error");\r
- UnknownException *error = new UnknownException("Unknown error");\r
- BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);\r
- } \r
- }\r
-\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+#include <Logger.h>
+#include <JSWebAPIErrorFactory.h>
+#include <JSUtil.h>
+#include <TimeTracer.h>
+
+#include "BluetoothHealthProfileHandler.h"
+#include "BluetoothHealthProfileHandlerCallback.h"
+#include "JSBluetoothHealthApplication.h"
+#include "JSBluetoothDevice.h"
+#include "JSBluetoothHealthChannel.h"
+#include "BluetoothHealthChannel.h"
+
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+void BluetoothHealthProfileHandler::onConnected(int result, const char *remote_address, const char *app_id,
+ bt_hdp_channel_type_e type, unsigned int channel, void *userData)
+{
+ LoggerD("Enter");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ HealthProfileHandlerPtr object = static_cast<HealthProfileHandlerPtr>(userData);
+ if(!object) {
+ LoggerW("userData is NULL");
+ return;
+ }
+
+ if(result != BT_ERROR_NONE) {
+ LoggerD("Not BT_ERROR_NONE");
+ }
+
+ LoggerD("Connected app: " << app_id);
+ LoggerD("Connected channel: " << channel);
+
+ std::string appID(app_id);
+ RegisteredHealthAppMapT::iterator iter = object->mRegisteredHealthAppMap.find(appID);
+ if(iter == object->mRegisteredHealthAppMap.end()) {
+ LoggerW("This app is not registered");
+ return;
+ }
+ BluetoothHealthApplicationSharedPtr application = iter->second;
+
+ bool isChannelInserted = false;
+ BluetoothHealthChannelPtr healthChannel = NULL;
+
+ // call BluetoothHealthApplication.onconnect
+ if(result == BT_ERROR_NONE) {
+ Common::MultiCallbackUserDataPtr callback = application->getOnConnect();
+ if(callback) {
+ bt_device_info_s *deviceInfo = NULL;
+ if(bt_adapter_get_bonded_device_info(remote_address, &deviceInfo) == BT_ERROR_NONE &&
+ deviceInfo != NULL) {
+ BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo));
+ bt_adapter_free_device_info(deviceInfo);
+
+ LoggerD("invoke BluetoothHealthApplication.onconnect");
+ healthChannel = new BluetoothHealthChannel(channel, device, type, application);
+ object->mConnectedSocketMap.insert(std::pair<unsigned int, BluetoothHealthChannelPtr>(channel, healthChannel));
+ isChannelInserted = true;
+ callback->invokeCallback("onconnect", JSBluetoothHealthChannel::createJSObject(callback->getContext(), healthChannel));
+ }
+ else {
+ LoggerE("Can't call BluetoothHealthApplication.onconnect because failed to get device info");
+ }
+ }
+ else {
+ LoggerD("BluetoothHealthApplication.onconnect is not set");
+ }
+ }
+
+ // in case of connectToSource()
+ HealthConnReqMapT::iterator i = object->mHealthConnReqMap.find(application);
+ if(i != object->mHealthConnReqMap.end()) {
+ LoggerD("Requested connection");
+ Common::MultiCallbackUserDataPtr callback = i->second->mUserData;
+ if(callback) {
+ if(result == BT_ERROR_NONE) {
+ if(isChannelInserted == false) {
+ healthChannel = new BluetoothHealthChannel(channel, i->second->mRemoteDevice, type, application);
+ object->mConnectedSocketMap.insert(std::pair<unsigned int, BluetoothHealthChannelPtr>(channel, healthChannel));
+ }
+ callback->invokeCallback("success", JSBluetoothHealthChannel::createJSObject(callback->getContext(), healthChannel));
+ }
+ else {
+ LoggerE("Failed to establish a connection with health profile");
+ callback->invokeCallback("error",
+ JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), UnknownException("Failed to establish a connection with health profile")));
+ }
+ }
+
+ // Update mHealthConnReqMap
+ object->mHealthConnReqMap.erase(i);
+ }
+ else {
+ LoggerD("There is no connection request");
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+void BluetoothHealthProfileHandler::onDisconnected(int result, const char *remote_address, unsigned int channel, void *userData)
+{
+ LoggerD("Enter");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ HealthProfileHandlerPtr object = static_cast<HealthProfileHandlerPtr>(userData);
+ if(!object) {
+ LoggerW("userData is NULL");
+ return;
+ }
+
+ LoggerD("Disconnected channel: " << channel);
+ HealthConnectedSocketMapT::iterator iter = object->mConnectedSocketMap.find(channel);
+ if(iter == object->mConnectedSocketMap.end()) {
+ LoggerW("Unexpected health disconnection event");
+ return;
+ }
+
+ if(result == BT_ERROR_NONE) {
+ BluetoothHealthChannelPtr healthChannel = iter->second;
+ object->mConnectedSocketMap.erase(iter);
+
+ healthChannel->setConnectionState(false);
+ MultiCallbackUserDataPtr callback = healthChannel->getListener();
+ if(callback)
+ callback->invokeCallback("onclose");
+ }
+ else {
+ LoggerW("Failed to disconnect a connection");
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+ LoggerD("End");
+}
+
+void BluetoothHealthProfileHandler::onDataReceivedCB(unsigned int channel, const char *data, unsigned int size, void *userData)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ HealthProfileHandlerPtr object = static_cast<HealthProfileHandlerPtr>(userData);
+ if(!object) {
+ LoggerW("userData is NULL");
+ return;
+ }
+
+ LoggerD("data channel: " << channel);
+ LoggerD("sent data size: " << size);
+ HealthConnectedSocketMapT::iterator iter = object->mConnectedSocketMap.find(channel);
+ if(iter == object->mConnectedSocketMap.end()) {
+ LoggerW("Unexpected health data received event");
+ return;
+ }
+
+ BluetoothHealthChannelPtr healthChannel = iter->second;
+ MultiCallbackUserDataPtr callback = healthChannel->getListener();
+ if(callback) {
+ std::vector<signed char> receivedData;
+ for(unsigned int i = 0; i < size; i++) {
+ receivedData.push_back(static_cast<signed char>(data[i]));
+ }
+ callback->invokeCallback("onmessage", JSUtil::toJSValueRef_(callback->getContext(), receivedData));
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+BluetoothHealthProfileHandler* BluetoothHealthProfileHandler::getInstance()
+{
+ static BluetoothHealthProfileHandler instance;
+ return &instance;
+}
+
+BluetoothHealthProfileHandler::BluetoothHealthProfileHandler()
+{
+ if(bt_hdp_set_connection_state_changed_cb(onConnected, onDisconnected, this) != BT_ERROR_NONE) {
+ LoggerE("bt_hdp_set_connection_state_changed_cb() failed");
+ }
+
+ if(bt_hdp_set_data_received_cb(onDataReceivedCB, this) != BT_ERROR_NONE) {
+ LoggerE("bt_hdp_set_data_received_cb() failed");
+ }
+}
+
+BluetoothHealthProfileHandler::~BluetoothHealthProfileHandler()
+{
+ // unset platform callback
+ bt_hdp_unset_connection_state_changed_cb();
+ bt_hdp_unset_data_received_cb();
+
+ mHealthConnReqMap.clear();
+ mConnectedSocketMap.clear();
+ mRegisteredHealthAppMap.clear();
+}
+
+void BluetoothHealthProfileHandler::registerSinkApp(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback)
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+ BluetoothHealthProfileHandlerCallback::syncToAsyncRegisterCB(callback, dataType, name);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+void BluetoothHealthProfileHandler::returnRegisteringSinkAppResult(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback)
+{
+ LoggerD("Enter");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ char *app_id = NULL;
+ int ret = bt_hdp_register_sink_app(dataType, &app_id);
+ switch(ret) {
+ case BT_ERROR_NONE:
+ {
+ LoggerD("Registered app: " << app_id);
+ std::string appID(app_id);
+ //free(app_id);
+ BluetoothHealthApplicationSharedPtr application(new BluetoothHealthApplication(appID, name, dataType));
+ mRegisteredHealthAppMap.insert(std::pair<std::string, BluetoothHealthApplicationSharedPtr>(appID, application));
+ if(callback)
+ callback->invokeCallback("success", JSBluetoothHealthApplication::createJSObject(callback->getContext(), application));
+ break;
+ }
+ case BT_ERROR_NOT_ENABLED:
+ {
+ if(callback) {
+ callback->invokeCallback("error",
+ JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), ServiceNotAvailableException("Bluetooth device is turned off")));
+ }
+ break;
+ }
+ default:
+ {
+ if(callback) {
+ callback->invokeCallback("error",
+ JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), UnknownException("Unknown error")));
+ }
+ }
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+/*
+void BluetoothHealthProfileHandler::unregisterSinkApplication(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback)
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+ BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(callback, appObj);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+void BluetoothHealthProfileHandler::returnUnregisteringResult(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback)
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ BluetoothHealthApplicationSharedPtr app = JSBluetoothHealthApplication::toBluetoothHealthApplication(appObj);
+ int ret = bt_hdp_unregister_sink_app(app->getAppID().c_str());
+ switch(ret) {
+ case BT_ERROR_NONE:
+ {
+ //app->setRegistrationState(false);
+ BluetoothHealthProfileHandlerCallback::syncToAsyncSuccessCB(callback);
+ break;
+ }
+ case BT_ERROR_NOT_ENABLED:
+ {
+ ServiceNotAvailableException *error = new ServiceNotAvailableException("Bluetooth device is turned off");
+ BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);
+ break;
+ }
+ default:
+ {
+ UnknownException *error = new UnknownException("Unknown error");
+ BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);
+ }
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+*/
+
+void BluetoothHealthProfileHandler::unregisterApp(std::string appID, Common::MultiCallbackUserDataPtr callback)
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+ BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(callback, appID);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+void BluetoothHealthProfileHandler::returnUnregisteringAppResult(std::string appID, Common::MultiCallbackUserDataPtr callback)
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ RegisteredHealthAppMapT::iterator iter = mRegisteredHealthAppMap.find(appID);
+ BluetoothHealthApplicationSharedPtr application;
+ if(iter != mRegisteredHealthAppMap.end()) {
+ LoggerE("registered Health Application is found");
+ application = iter->second;
+ }
+ else {
+ LoggerD("Already unregistered");
+ if(callback)
+ callback->invokeCallback("success");
+ return;
+ }
+
+ int ret = bt_hdp_unregister_sink_app(appID.c_str());
+ switch(ret) {
+ case BT_ERROR_NONE:
+ {
+ mRegisteredHealthAppMap.erase(iter);
+ application->setRegistrationState(false);
+ if(callback)
+ callback->invokeCallback("success");
+ break;
+ }
+ case BT_ERROR_NOT_ENABLED:
+ {
+ if(callback) {
+ callback->invokeCallback("error",
+ JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), ServiceNotAvailableException("Bluetooth device is turned off")));
+ }
+ break;
+ }
+ default:
+ {
+ if(callback) {
+ callback->invokeCallback("error",
+ JSWebAPIErrorFactory::makeErrorObject(callback->getContext(), UnknownException("Unknown error")));
+ }
+ }
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+void BluetoothHealthProfileHandler::connectToSource(JSObjectRef remoteDeviceObj, JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ BluetoothDeviceSharedPtr device = JSBluetoothDevice::toBluetoothDevice(remoteDeviceObj);
+ BluetoothHealthApplicationSharedPtr app = JSBluetoothHealthApplication::toBluetoothHealthApplication(appObj);
+ LoggerD("address: " << device->getAddress().c_str());
+ LoggerD("app ID: " << app->getAppID().c_str());
+ int ret = bt_hdp_connect_to_source(device->getAddress().c_str(), app->getAppID().c_str());
+ switch(ret) {
+ case BT_ERROR_NONE:
+ {
+ LoggerD("NONE");
+ HealthConnReqPtr connReq = new HealthConnReq(device, callback);
+ mHealthConnReqMap.insert(std::pair<BluetoothHealthApplicationSharedPtr, HealthConnReqPtr>(app, connReq));
+ break;
+ }
+ case BT_ERROR_NOT_ENABLED:
+ {
+ LoggerD("Not Enabled");
+ ServiceNotAvailableException *error = new ServiceNotAvailableException("Bluetooth device is turned off");
+ BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);
+ break;
+ }
+ case BT_ERROR_INVALID_PARAMETER:
+ case BT_ERROR_REMOTE_DEVICE_NOT_BONDED:
+ {
+ LoggerD("invalid value");
+ InvalidValuesException *error = new InvalidValuesException("Invalid value");
+ BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);
+ break;
+ }
+ default:
+ {
+ LoggerD("Unknown error");
+ UnknownException *error = new UnknownException("Unknown error");
+ BluetoothHealthProfileHandlerCallback::syncToAsyncErrorCB(callback, error);
+ }
+ }
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_BLUETOOTH_ADAPTER_H__\r
-#define __TIZEN_HEALTH_PROFILE_HANDLER_H__\r
-\r
-#include <string>\r
-#include <map>\r
-#include <vector>\r
-\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-#include <MultiCallbackUserData.h>\r
-#include <PlatformException.h>\r
-#include <bluetooth.h>\r
-\r
-#include "BluetoothHealthChannel.h"\r
-#include "BluetoothHealthApplication.h"\r
-#include "BluetoothDevice.h"\r
-\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class HealthConnReq\r
-{\r
-public:\r
- HealthConnReq(BluetoothDeviceSharedPtr remoteDevice, Common::MultiCallbackUserDataPtr userData) \r
- {\r
- mRemoteDevice = remoteDevice;\r
- mUserData = userData;\r
- };\r
- \r
- BluetoothDeviceSharedPtr mRemoteDevice;\r
- Common::MultiCallbackUserDataPtr mUserData;\r
-};\r
-typedef HealthConnReq* HealthConnReqPtr;\r
-\r
-class BluetoothHealthProfileHandler\r
-{\r
-public: \r
- static BluetoothHealthProfileHandler* getInstance(); \r
- void registerSinkApp(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback);\r
- void returnRegisteringSinkAppResult(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback);\r
-// void unregisterSinkApplication(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);\r
-// void returnUnregisteringResult(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);\r
- void unregisterApp(std::string appID, Common::MultiCallbackUserDataPtr callback);\r
- void returnUnregisteringAppResult(std::string appID, Common::MultiCallbackUserDataPtr callback);\r
- void connectToSource(JSObjectRef remoteDeviceObj, JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);\r
- \r
-private: \r
- BluetoothHealthProfileHandler();\r
- virtual ~BluetoothHealthProfileHandler();\r
-\r
- static void onConnected(int result, const char *remote_address, const char *app_id,\r
- bt_hdp_channel_type_e type, unsigned int channel, void *userData);\r
- static void onDisconnected(int result, const char *remote_address, unsigned int channel, void *userData);\r
- static void onDataReceivedCB(unsigned int channel, const char *data, unsigned int size, void *userData);\r
-\r
- typedef std::map<BluetoothHealthApplicationSharedPtr, HealthConnReqPtr> HealthConnReqMapT;\r
- typedef std::map<unsigned int, BluetoothHealthChannelPtr> HealthConnectedSocketMapT; // <channel, BluetoothHealthChannelPtr>\r
- typedef std::map<std::string, BluetoothHealthApplicationSharedPtr> RegisteredHealthAppMapT; // <app_id, BluetoothHealthApplicationSharedPtr>\r
- \r
- HealthConnReqMapT mHealthConnReqMap;\r
- HealthConnectedSocketMapT mConnectedSocketMap;\r
- RegisteredHealthAppMapT mRegisteredHealthAppMap;\r
-};\r
-\r
-typedef BluetoothHealthProfileHandler* HealthProfileHandlerPtr;\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_HEALTH_PROFILE_HANDLER_H__\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_BLUETOOTH_ADAPTER_H__
+#define __TIZEN_HEALTH_PROFILE_HANDLER_H__
+
+#include <string>
+#include <map>
+#include <vector>
+
+#include <JavaScriptCore/JavaScript.h>
+
+#include <MultiCallbackUserData.h>
+#include <PlatformException.h>
+#include <bluetooth.h>
+
+#include "BluetoothHealthChannel.h"
+#include "BluetoothHealthApplication.h"
+#include "BluetoothDevice.h"
+
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class HealthConnReq
+{
+public:
+ HealthConnReq(BluetoothDeviceSharedPtr remoteDevice, Common::MultiCallbackUserDataPtr userData)
+ {
+ mRemoteDevice = remoteDevice;
+ mUserData = userData;
+ };
+
+ BluetoothDeviceSharedPtr mRemoteDevice;
+ Common::MultiCallbackUserDataPtr mUserData;
+};
+typedef HealthConnReq* HealthConnReqPtr;
+
+class BluetoothHealthProfileHandler
+{
+public:
+ static BluetoothHealthProfileHandler* getInstance();
+ void registerSinkApp(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback);
+ void returnRegisteringSinkAppResult(unsigned short dataType, std::string name, Common::MultiCallbackUserDataPtr callback);
+// void unregisterSinkApplication(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);
+// void returnUnregisteringResult(JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);
+ void unregisterApp(std::string appID, Common::MultiCallbackUserDataPtr callback);
+ void returnUnregisteringAppResult(std::string appID, Common::MultiCallbackUserDataPtr callback);
+ void connectToSource(JSObjectRef remoteDeviceObj, JSObjectRef appObj, Common::MultiCallbackUserDataPtr callback);
+
+private:
+ BluetoothHealthProfileHandler();
+ virtual ~BluetoothHealthProfileHandler();
+
+ static void onConnected(int result, const char *remote_address, const char *app_id,
+ bt_hdp_channel_type_e type, unsigned int channel, void *userData);
+ static void onDisconnected(int result, const char *remote_address, unsigned int channel, void *userData);
+ static void onDataReceivedCB(unsigned int channel, const char *data, unsigned int size, void *userData);
+
+ typedef std::map<BluetoothHealthApplicationSharedPtr, HealthConnReqPtr> HealthConnReqMapT;
+ typedef std::map<unsigned int, BluetoothHealthChannelPtr> HealthConnectedSocketMapT; // <channel, BluetoothHealthChannelPtr>
+ typedef std::map<std::string, BluetoothHealthApplicationSharedPtr> RegisteredHealthAppMapT; // <app_id, BluetoothHealthApplicationSharedPtr>
+
+ HealthConnReqMapT mHealthConnReqMap;
+ HealthConnectedSocketMapT mConnectedSocketMap;
+ RegisteredHealthAppMapT mRegisteredHealthAppMap;
+};
+
+typedef BluetoothHealthProfileHandler* HealthProfileHandlerPtr;
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_HEALTH_PROFILE_HANDLER_H__
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <Ecore.h>\r
-\r
-#include <JSUtil.h>\r
-#include <Logger.h>\r
-\r
-#include "BluetoothHealthProfileHandlerCallback.h"\r
-#include "BluetoothHealthProfileHandler.h"\r
-\r
-\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-\r
-class HealthProfileHandlerCallbackData\r
-{\r
-public:\r
- HealthProfileHandlerCallbackData(MultiCallbackUserDataPtr callback, unsigned short dataType, std::string name)\r
- {\r
- mCallback = callback;\r
- mDataType = dataType;\r
- mName = name;\r
- mIsRegistering = true;\r
- };\r
-\r
- HealthProfileHandlerCallbackData(MultiCallbackUserDataPtr callback, std::string appID)\r
- {\r
- mCallback = callback;\r
- mAppID = appID;\r
- mIsRegistering = false;\r
- }; \r
-\r
- virtual ~HealthProfileHandlerCallbackData()\r
- {\r
- // Do nothing\r
- };\r
-\r
- MultiCallbackUserDataPtr mCallback;\r
- unsigned short mDataType;\r
- std::string mName;\r
- std::string mAppID;\r
- bool mIsRegistering;\r
-};\r
-\r
-typedef HealthProfileHandlerCallbackData* HealthProfileHandlerCallbackDataPtr;\r
-\r
-\r
-static Eina_Bool idlerCallback(void *userData){\r
- HealthProfileHandlerCallbackDataPtr data = static_cast<HealthProfileHandlerCallbackDataPtr>(userData);\r
-\r
- if(!data) {\r
- LoggerW("BluetoothCallbackDataPtr is NULL");\r
- return false;\r
- }\r
-\r
- if(!(data->mCallback)) {\r
- LoggerW("MulticallbackUserData is NULL");\r
- delete data;\r
- return false; \r
- }\r
-\r
- if(data->mIsRegistering) { // registerSinkApplication\r
- LoggerD("In case of registerSinkApplication");\r
- BluetoothHealthProfileHandler::getInstance()->returnRegisteringSinkAppResult(data->mDataType, data->mName, data->mCallback);\r
- }\r
- else { // unregisterSinkApplication\r
- LoggerD("In case of unregisterSinkApplication");\r
- BluetoothHealthProfileHandler::getInstance()->returnUnregisteringAppResult(data->mAppID, data->mCallback);\r
- }\r
-\r
- delete data;\r
- return false;\r
-}\r
-\r
-void BluetoothHealthProfileHandlerCallback::syncToAsyncRegisterCB(MultiCallbackUserDataPtr callback, unsigned short dataType, std::string name)\r
-{\r
- HealthProfileHandlerCallbackDataPtr data = new HealthProfileHandlerCallbackData(callback, dataType, name);\r
- ecore_idler_add(idlerCallback, data);\r
-}\r
-\r
-/*\r
-void BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(MultiCallbackUserDataPtr callback, JSObjectRef application)\r
-{\r
- HealthProfileHandlerCallbackDataPtr data = new HealthProfileHandlerCallbackData(callback, application);\r
- ecore_idler_add(idlerCallback, data);\r
-}\r
-*/\r
-void BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(MultiCallbackUserDataPtr callback, std::string appID)\r
-{\r
- HealthProfileHandlerCallbackDataPtr data = new HealthProfileHandlerCallbackData(callback, appID);\r
- ecore_idler_add(idlerCallback, data);\r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <Ecore.h>
+
+#include <JSUtil.h>
+#include <Logger.h>
+
+#include "BluetoothHealthProfileHandlerCallback.h"
+#include "BluetoothHealthProfileHandler.h"
+
+
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+
+class HealthProfileHandlerCallbackData
+{
+public:
+ HealthProfileHandlerCallbackData(MultiCallbackUserDataPtr callback, unsigned short dataType, std::string name)
+ {
+ mCallback = callback;
+ mDataType = dataType;
+ mName = name;
+ mIsRegistering = true;
+ };
+
+ HealthProfileHandlerCallbackData(MultiCallbackUserDataPtr callback, std::string appID)
+ {
+ mCallback = callback;
+ mAppID = appID;
+ mIsRegistering = false;
+ };
+
+ virtual ~HealthProfileHandlerCallbackData()
+ {
+ // Do nothing
+ };
+
+ MultiCallbackUserDataPtr mCallback;
+ unsigned short mDataType;
+ std::string mName;
+ std::string mAppID;
+ bool mIsRegistering;
+};
+
+typedef HealthProfileHandlerCallbackData* HealthProfileHandlerCallbackDataPtr;
+
+
+static Eina_Bool idlerCallback(void *userData){
+ HealthProfileHandlerCallbackDataPtr data = static_cast<HealthProfileHandlerCallbackDataPtr>(userData);
+
+ if(!data) {
+ LoggerW("BluetoothCallbackDataPtr is NULL");
+ return false;
+ }
+
+ if(!(data->mCallback)) {
+ LoggerW("MulticallbackUserData is NULL");
+ delete data;
+ return false;
+ }
+
+ if(data->mIsRegistering) { // registerSinkApplication
+ LoggerD("In case of registerSinkApplication");
+ BluetoothHealthProfileHandler::getInstance()->returnRegisteringSinkAppResult(data->mDataType, data->mName, data->mCallback);
+ }
+ else { // unregisterSinkApplication
+ LoggerD("In case of unregisterSinkApplication");
+ BluetoothHealthProfileHandler::getInstance()->returnUnregisteringAppResult(data->mAppID, data->mCallback);
+ }
+
+ delete data;
+ return false;
+}
+
+void BluetoothHealthProfileHandlerCallback::syncToAsyncRegisterCB(MultiCallbackUserDataPtr callback, unsigned short dataType, std::string name)
+{
+ HealthProfileHandlerCallbackDataPtr data = new HealthProfileHandlerCallbackData(callback, dataType, name);
+ ecore_idler_add(idlerCallback, data);
+}
+
+/*
+void BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(MultiCallbackUserDataPtr callback, JSObjectRef application)
+{
+ HealthProfileHandlerCallbackDataPtr data = new HealthProfileHandlerCallbackData(callback, application);
+ ecore_idler_add(idlerCallback, data);
+}
+*/
+void BluetoothHealthProfileHandlerCallback::syncToAsyncUnregisterCB(MultiCallbackUserDataPtr callback, std::string appID)
+{
+ HealthProfileHandlerCallbackDataPtr data = new HealthProfileHandlerCallbackData(callback, appID);
+ ecore_idler_add(idlerCallback, data);
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_HEALTH_PROFILE_HANDLER_CALLBACK_H__\r
-#define __TIZEN_HEALTH_PROFILE_HANDLER_CALLBACK_H__\r
-\r
-#include <string>\r
-#include <MultiCallbackUserData.h>\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-#include "BluetoothCallback.h"\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-\r
-class BluetoothHealthProfileHandlerCallback : public BluetoothCallback\r
-{\r
-public:\r
- static void syncToAsyncRegisterCB(DeviceAPI::Common::MultiCallbackUserDataPtr callback, unsigned short dataType, std::string name);\r
- //static void syncToAsyncUnregisterCB(DeviceAPI::Common::MultiCallbackUserDataPtr callback, JSObjectRef application);\r
- static void syncToAsyncUnregisterCB(DeviceAPI::Common::MultiCallbackUserDataPtr callback, std::string appID);\r
-};\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-\r
-\r
-#endif // __TIZEN_HEALTH_PROFILE_HANDLER_CALLBACK_H__\r
-\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_HEALTH_PROFILE_HANDLER_CALLBACK_H__
+#define __TIZEN_HEALTH_PROFILE_HANDLER_CALLBACK_H__
+
+#include <string>
+#include <MultiCallbackUserData.h>
+#include <JavaScriptCore/JavaScript.h>
+
+#include "BluetoothCallback.h"
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+
+class BluetoothHealthProfileHandlerCallback : public BluetoothCallback
+{
+public:
+ static void syncToAsyncRegisterCB(DeviceAPI::Common::MultiCallbackUserDataPtr callback, unsigned short dataType, std::string name);
+ //static void syncToAsyncUnregisterCB(DeviceAPI::Common::MultiCallbackUserDataPtr callback, JSObjectRef application);
+ static void syncToAsyncUnregisterCB(DeviceAPI::Common::MultiCallbackUserDataPtr callback, std::string appID);
+};
+
+
+} // Bluetooth
+} // DeviceAPI
+
+
+
+#endif // __TIZEN_HEALTH_PROFILE_HANDLER_CALLBACK_H__
IF(ENABLE_OPTIONAL_BT)
PKG_SEARCH_MODULE(bluetooth REQUIRED capi-network-bluetooth)
-PKG_SEARCH_MODULE(system-info REQUIRED capi-system-info)
SET(CMAKE_INSTALL_RPATH
${CMAKE_INSTALL_RPATH}
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <SecurityExceptions.h>\r
-\r
-#include <JSUtil.h>\r
-#include <ArgumentValidator.h>\r
-#include <GlobalContextManager.h>\r
-#include <PlatformException.h>\r
-#include <MultiCallbackUserData.h>\r
-\r
-#include "plugin_config.h"\r
-#include "JSBluetoothHealthApplication.h"\r
-#include "BluetoothHealthProfileHandler.h"\r
-\r
-#include <TimeTracer.h>\r
-#include <Logger.h>\r
-\r
-using namespace WrtDeviceApis::Commons;\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-JSClassDefinition JSBluetoothHealthApplication::m_classInfo = {\r
- 0,\r
- kJSClassAttributeNone,\r
- "BluetoothHealthApplication",\r
- NULL, //ParentClass\r
- m_property, //StaticValues\r
- m_function, //StaticFunctions\r
- initialize, //Initialize\r
- finalize, //Finalize\r
- NULL, //HasProperty,\r
- NULL, //GetProperty,\r
- NULL, //SetProperty,\r
- NULL, //DeleteProperty,\r
- NULL, //GetPropertyNames,\r
- NULL, //CallAsFunction,\r
- NULL, //CallAsConstructor,\r
- NULL, //HasInstance,\r
- NULL //ConvertToType\r
-};\r
-\r
-JSStaticValue JSBluetoothHealthApplication::m_property[] = {\r
- { BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- { BLUETOOTH_HEALTH_APPLICATION_NAME, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- { BLUETOOTH_HEALTH_APPLICATION_ONCONNECT, getProperty, setProperty, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- //{ BLUETOOTH_HEALTH_APPLICATION_IS_REGISTERED, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- { 0, 0, 0, 0 }\r
-};\r
-\r
-JSStaticFunction JSBluetoothHealthApplication::m_function[] = {\r
- { BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER, unregister, kJSPropertyAttributeNone },\r
- { 0, 0, 0 }\r
-};\r
-\r
-JSClassRef JSBluetoothHealthApplication::m_jsClassRef = JSClassCreate(JSBluetoothHealthApplication::getClassInfo());\r
-\r
-const JSClassRef JSBluetoothHealthApplication::getClassRef()\r
-{\r
- if (!m_jsClassRef) {\r
- m_jsClassRef = JSClassCreate(&m_classInfo);\r
- }\r
- return m_jsClassRef;\r
-}\r
-\r
-const JSClassDefinition* JSBluetoothHealthApplication::getClassInfo()\r
-{\r
- return &m_classInfo;\r
-}\r
-\r
-JSObjectRef JSBluetoothHealthApplication::createJSObject(JSContextRef context, BluetoothHealthApplicationSharedPtr app)\r
-{\r
- BluetoothHealthApplicationHolderPtr holder = new BluetoothHealthApplicationHolder(app);\r
- return JSObjectMake(context, getClassRef(), static_cast<void*>(holder));\r
-}\r
-\r
-BluetoothHealthApplicationSharedPtr JSBluetoothHealthApplication::toBluetoothHealthApplication(JSObjectRef appObj)\r
-{\r
- BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(appObj));\r
- return priv->mApp;\r
-}\r
-\r
-void JSBluetoothHealthApplication::initialize(JSContextRef context, JSObjectRef object)\r
-{\r
- // Do nothing\r
-}\r
-\r
-void JSBluetoothHealthApplication::finalize(JSObjectRef object)\r
-{\r
- BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(object));\r
- if (priv) {\r
- JSObjectSetPrivate(object, NULL);\r
- delete priv;\r
- }\r
-}\r
-\r
-JSValueRef JSBluetoothHealthApplication::getProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef* exception)\r
-{\r
- try {\r
- BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(object));\r
- if (!priv) {\r
- throw TypeMismatchException("Private object is NULL");\r
- }\r
-\r
- if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE)) {\r
- return JSValueMakeNumber(context, priv->mApp->getDataType());\r
- }\r
- else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_NAME)) {\r
- return JSUtil::toJSValueRef(context, priv->mApp->getName());\r
- }\r
- else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT)) {\r
- return JSUtil::toJSValueRef(context, priv->mApp->getOnConnect());\r
- } \r
- /*\r
- else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_IS_REGISTERED)) {\r
- return JSUtil::toJSValueRef(context, priv->mApp->getRegistrationState());\r
- }\r
- */\r
- } catch (const BasePlatformException &err) {\r
- LoggerW("Getting property is failed: " << err.getMessage().c_str());\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-bool JSBluetoothHealthApplication::setProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef value,\r
- JSValueRef* exception)\r
-{\r
- try {\r
- BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(object));\r
- if (!priv) {\r
- throw TypeMismatchException("Private object is NULL");\r
- }\r
- \r
- if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT)) {\r
- JSObjectRef object = NULL;\r
- if(!JSValueIsNull(context, value)) {\r
- if(!JSValueIsObject(context, value)) {\r
- throw TypeMismatchException("Value is not Object");\r
- }\r
-\r
- JSValueRef ex = NULL;\r
- object = JSValueToObject(context, value, &ex);\r
- if(ex){\r
- throw TypeMismatchException("Can't convert to Object");\r
- } \r
-\r
- if(!JSObjectIsFunction(context, object)) {\r
- throw TypeMismatchException("Not function");\r
- }\r
- }\r
- else {\r
- LoggerD("onconnect() is NULL");\r
- }\r
- \r
- return priv->mApp->setOnConnect(context, object);\r
- }\r
- } catch (const BasePlatformException &err) {\r
- JSWebAPIErrorFactory::postException(context, exception, err);\r
- }\r
-\r
- return false;\r
-}\r
-\r
-\r
-JSValueRef JSBluetoothHealthApplication::unregister(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
-\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- \r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1);\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER);\r
- TIME_TRACER_ITEM_END("unregister::ACE", 1);\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(thisObject));\r
- if (!priv) {\r
- throw TypeMismatchException("Private object is NULL");\r
- }\r
-\r
- ArgumentValidator validator(context, argumentCount, arguments);\r
- JSObjectRef successCallback = validator.toFunction(0, true); // successCallback \r
- JSObjectRef errorCallback = validator.toFunction(1, true); // errorCallback\r
-\r
- // perform\r
- MultiCallbackUserDataPtr callback(\r
- new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));\r
- if(!callback){\r
- LoggerW("Can't create MultiCallbackUserData");\r
- }\r
- else {\r
- callback->setCallback("success", successCallback);\r
- callback->setCallback("error", errorCallback);\r
- } \r
- \r
- BluetoothHealthProfileHandler::getInstance()->unregisterApp(priv->mApp->getAppID(), callback);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);\r
- \r
- return JSValueMakeUndefined(context); \r
- } catch (const BasePlatformException &err) {\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.setName().");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } \r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <SecurityExceptions.h>
+
+#include <JSUtil.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+#include <PlatformException.h>
+#include <MultiCallbackUserData.h>
+
+#include "plugin_config.h"
+#include "JSBluetoothHealthApplication.h"
+#include "BluetoothHealthProfileHandler.h"
+
+#include <TimeTracer.h>
+#include <Logger.h>
+
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+JSClassDefinition JSBluetoothHealthApplication::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "BluetoothHealthApplication",
+ NULL, //ParentClass
+ m_property, //StaticValues
+ m_function, //StaticFunctions
+ initialize, //Initialize
+ finalize, //Finalize
+ NULL, //HasProperty,
+ NULL, //GetProperty,
+ NULL, //SetProperty,
+ NULL, //DeleteProperty,
+ NULL, //GetPropertyNames,
+ NULL, //CallAsFunction,
+ NULL, //CallAsConstructor,
+ NULL, //HasInstance,
+ NULL //ConvertToType
+};
+
+JSStaticValue JSBluetoothHealthApplication::m_property[] = {
+ { BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },
+ { BLUETOOTH_HEALTH_APPLICATION_NAME, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },
+ { BLUETOOTH_HEALTH_APPLICATION_ONCONNECT, getProperty, setProperty, kJSPropertyAttributeNone|kJSPropertyAttributeDontDelete },
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSBluetoothHealthApplication::m_function[] = {
+ { BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER, unregister, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+JSClassRef JSBluetoothHealthApplication::m_jsClassRef = JSClassCreate(JSBluetoothHealthApplication::getClassInfo());
+
+const JSClassRef JSBluetoothHealthApplication::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSBluetoothHealthApplication::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+JSObjectRef JSBluetoothHealthApplication::createJSObject(JSContextRef context, BluetoothHealthApplicationSharedPtr app)
+{
+ BluetoothHealthApplicationHolderPtr holder = new BluetoothHealthApplicationHolder(app);
+ return JSObjectMake(context, getClassRef(), static_cast<void*>(holder));
+}
+
+BluetoothHealthApplicationSharedPtr JSBluetoothHealthApplication::toBluetoothHealthApplication(JSObjectRef appObj)
+{
+ BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(appObj));
+ return priv->mApp;
+}
+
+void JSBluetoothHealthApplication::initialize(JSContextRef context, JSObjectRef object)
+{
+ // Do nothing
+}
+
+void JSBluetoothHealthApplication::finalize(JSObjectRef object)
+{
+ BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(object));
+ if (priv) {
+ JSObjectSetPrivate(object, NULL);
+ delete priv;
+ }
+}
+
+JSValueRef JSBluetoothHealthApplication::getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ try {
+ BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(object));
+ if (!priv) {
+ throw TypeMismatchException("Private object is NULL");
+ }
+
+ if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE)) {
+ return JSValueMakeNumber(context, priv->mApp->getDataType());
+ }
+ else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_NAME)) {
+ return JSUtil::toJSValueRef(context, priv->mApp->getName());
+ }
+ else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT)) {
+ LoggerD("get onconnect");
+ return JSUtil::toJSValueRef(context, priv->mApp->getOnConnect());
+ }
+ /*
+ else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_IS_REGISTERED)) {
+ return JSUtil::toJSValueRef(context, priv->mApp->getRegistrationState());
+ }
+ */
+ } catch (const BasePlatformException &err) {
+ LoggerW("Getting property is failed: " << err.getMessage().c_str());
+ }
+
+ return NULL;
+}
+
+bool JSBluetoothHealthApplication::setProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ try {
+ BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(object));
+ if (!priv) {
+ throw TypeMismatchException("Private object is NULL");
+ }
+
+ if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_APPLICATION_ONCONNECT)) {
+ LoggerD("Set onconnect");
+ JSObjectRef onconnectObj = NULL;
+ if(!JSValueIsNull(context, value)) {
+ if(!JSValueIsObject(context, value)) {
+ throw TypeMismatchException("Value is not Object");
+ }
+
+ JSValueRef ex = NULL;
+ onconnectObj = JSValueToObject(context, value, &ex);
+ if(ex){
+ throw TypeMismatchException("Can't convert to Object");
+ }
+
+ if(!JSObjectIsFunction(context, onconnectObj)) {
+ throw TypeMismatchException("Not function");
+ }
+ }
+ else {
+ LoggerD("onconnect() is NULL");
+ }
+
+ return priv->mApp->setOnConnect(context, onconnectObj);
+ }
+ } catch (const BasePlatformException &err) {
+ JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+
+ return false;
+}
+
+
+JSValueRef JSBluetoothHealthApplication::unregister(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1);
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER);
+ TIME_TRACER_ITEM_END("unregister::ACE", 1);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ BluetoothHealthApplicationHolderPtr priv = static_cast<BluetoothHealthApplicationHolderPtr>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw TypeMismatchException("Private object is NULL");
+ }
+
+ ArgumentValidator validator(context, argumentCount, arguments);
+ JSObjectRef successCallback = validator.toFunction(0, true); // successCallback
+ JSObjectRef errorCallback = validator.toFunction(1, true); // errorCallback
+
+ // perform
+ MultiCallbackUserDataPtr callback(
+ new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+ if(!callback){
+ LoggerW("Can't create MultiCallbackUserData");
+ }
+ else {
+ callback->setCallback("success", successCallback);
+ callback->setCallback("error", errorCallback);
+ }
+
+ BluetoothHealthProfileHandler::getInstance()->unregisterApp(priv->mApp->getAppID(), callback);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.setName().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__\r
-#define __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__\r
-\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-#include "BluetoothHealthApplication.h"\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class BluetoothHealthApplicationHolder\r
-{\r
-public:\r
- BluetoothHealthApplicationHolder(BluetoothHealthApplicationSharedPtr app) {mApp = app;}\r
- BluetoothHealthApplicationSharedPtr mApp; \r
-};\r
-typedef BluetoothHealthApplicationHolder* BluetoothHealthApplicationHolderPtr;\r
-\r
-class JSBluetoothHealthApplication\r
-{\r
-public:\r
- static const JSClassDefinition* getClassInfo();\r
- static const JSClassRef getClassRef();\r
- static JSObjectRef createJSObject(JSContextRef context, BluetoothHealthApplicationSharedPtr app);\r
- static BluetoothHealthApplicationSharedPtr toBluetoothHealthApplication(JSObjectRef appObj);\r
- \r
-private:\r
-\r
- /**\r
- * The callback invoked when an object is first created.\r
- */\r
- static void initialize(JSContextRef context,\r
- JSObjectRef object);\r
-\r
- /**\r
- * The callback invoked when an object is finalized.\r
- */\r
- static void finalize(JSObjectRef object);\r
-\r
- static JSValueRef getProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef* exception);\r
-\r
- static bool setProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef value,\r
- JSValueRef* exception);\r
-\r
- static JSValueRef unregister(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- /**\r
- * This member variable contains the values which has to be passed\r
- * when the this class is embedded into JS Engine.\r
- */\r
- static JSClassDefinition m_classInfo;\r
-\r
- /**\r
- * This structure describes a statically declared function property.\r
- */\r
- static JSStaticFunction m_function[];\r
-\r
- /**\r
- * This member variable contains the initialization values for the\r
- * properties of this class. The values are given according to\r
- * the data structure JSPropertySpec\r
- */\r
- static JSStaticValue m_property[];\r
-\r
- static JSClassRef m_jsClassRef;\r
-};\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__\r
-\r
-\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__
+#define __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__
+
+#include <JavaScriptCore/JavaScript.h>
+
+#include "BluetoothHealthApplication.h"
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class BluetoothHealthApplicationHolder
+{
+public:
+ BluetoothHealthApplicationHolder(BluetoothHealthApplicationSharedPtr app) {mApp = app;}
+ BluetoothHealthApplicationSharedPtr mApp;
+};
+typedef BluetoothHealthApplicationHolder* BluetoothHealthApplicationHolderPtr;
+
+class JSBluetoothHealthApplication
+{
+public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, BluetoothHealthApplicationSharedPtr app);
+ static BluetoothHealthApplicationSharedPtr toBluetoothHealthApplication(JSObjectRef appObj);
+
+private:
+
+ /**
+ * The callback invoked when an object is first created.
+ */
+ static void initialize(JSContextRef context,
+ JSObjectRef object);
+
+ /**
+ * The callback invoked when an object is finalized.
+ */
+ static void finalize(JSObjectRef object);
+
+ static JSValueRef getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+
+ static bool setProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef value,
+ JSValueRef* exception);
+
+ static JSValueRef unregister(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ /**
+ * This member variable contains the values which has to be passed
+ * when the this class is embedded into JS Engine.
+ */
+ static JSClassDefinition m_classInfo;
+
+ /**
+ * This structure describes a statically declared function property.
+ */
+ static JSStaticFunction m_function[];
+
+ /**
+ * This member variable contains the initialization values for the
+ * properties of this class. The values are given according to
+ * the data structure JSPropertySpec
+ */
+ static JSStaticValue m_property[];
+
+ static JSClassRef m_jsClassRef;
+};
+
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_JS_BLUETOOTH_HEALTH_APPLICATION_H__
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <vector>\r
-\r
-#include <SecurityExceptions.h>\r
-#include <JSUtil.h>\r
-#include <ArgumentValidator.h>\r
-#include <GlobalContextManager.h>\r
-#include <PlatformException.h>\r
-#include <MultiCallbackUserData.h>\r
-\r
-#include "plugin_config.h"\r
-#include "JSBluetoothHealthChannel.h"\r
-#include "BluetoothHealthProfileHandler.h"\r
-\r
-#include <TimeTracer.h>\r
-#include <Logger.h>\r
-\r
-using namespace WrtDeviceApis::Commons;\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-JSClassDefinition JSBluetoothHealthChannel::m_classInfo = {\r
- 0,\r
- kJSClassAttributeNone,\r
- "BluetoothHealthChannel",\r
- NULL, //ParentClass\r
- m_property, //StaticValues\r
- m_function, //StaticFunctions\r
- initialize, //Initialize\r
- finalize, //Finalize\r
- NULL, //HasProperty,\r
- NULL, //GetProperty,\r
- NULL, //SetProperty,\r
- NULL, //DeleteProperty,\r
- NULL, //GetPropertyNames,\r
- NULL, //CallAsFunction,\r
- NULL, //CallAsConstructor,\r
- NULL, //HasInstance,\r
- NULL //ConvertToType\r
-};\r
-\r
-JSStaticValue JSBluetoothHealthChannel::m_property[] = {\r
- { BLUETOOTH_HEALTH_CHANNEL_PEER, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- { BLUETOOTH_HEALTH_CHANNEL_TYPE, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- { BLUETOOTH_HEALTH_CHANNEL_APP, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },\r
- { BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeDontDelete },\r
- { 0, 0, 0, 0 }\r
-};\r
-\r
-JSStaticFunction JSBluetoothHealthChannel::m_function[] = {\r
- { BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA, sendData, kJSPropertyAttributeNone },\r
- { BLUETOOTH_HEALTH_CHANNEL_API_CLOSE, close, kJSPropertyAttributeNone },\r
- { BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER, setListener, kJSPropertyAttributeNone },\r
- { BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER, unsetListener, kJSPropertyAttributeNone }, \r
- { 0, 0, 0 }\r
-};\r
-\r
-JSClassRef JSBluetoothHealthChannel::m_jsClassRef = JSClassCreate(JSBluetoothHealthChannel::getClassInfo());\r
-\r
-const JSClassRef JSBluetoothHealthChannel::getClassRef()\r
-{\r
- if (!m_jsClassRef) {\r
- m_jsClassRef = JSClassCreate(&m_classInfo);\r
- }\r
- return m_jsClassRef;\r
-}\r
-\r
-const JSClassDefinition* JSBluetoothHealthChannel::getClassInfo()\r
-{\r
- return &m_classInfo;\r
-}\r
-\r
-JSObjectRef JSBluetoothHealthChannel::createJSObject(JSContextRef context, BluetoothHealthChannelPtr channel)\r
-{\r
- return JSObjectMake(context, getClassRef(), static_cast<void*>(channel));\r
-}\r
-\r
-void JSBluetoothHealthChannel::initialize(JSContextRef context, JSObjectRef object)\r
-{\r
- // do nothing\r
-}\r
-\r
-void JSBluetoothHealthChannel::finalize(JSObjectRef object)\r
-{\r
- BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(object));\r
- if (priv) {\r
- JSObjectSetPrivate(object, NULL);\r
- delete priv;\r
- }\r
-}\r
-\r
-JSValueRef JSBluetoothHealthChannel::getProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef* exception)\r
-{\r
- try {\r
- BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(object));\r
- if (!priv) {\r
- throw TypeMismatchException("Private object is NULL");\r
- }\r
-\r
- if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_PEER)) {\r
- return priv->getPeer(context);\r
- }\r
- else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_TYPE)) {\r
- return JSUtil::toJSValueRef(context, priv->getChannelTypeStr());\r
- }\r
- else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_APP)) {\r
- return priv->getApp(context);\r
- }\r
- else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED)) {\r
- return JSUtil::toJSValueRef(context, priv->getConnectionState());\r
- }\r
- } catch (const BasePlatformException &err) {\r
- LoggerW("Getting property is failed: " << err.getMessage().c_str());\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-JSValueRef JSBluetoothHealthChannel::sendData(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
-\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;\r
-\r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("sendData::ACE", 1);;\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA);\r
- TIME_TRACER_ITEM_END("sendData::ACE", 1);;\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- // Private Object\r
- BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));\r
- if (!priv) {\r
- throw DeviceAPI::Common::UnknownException("Private object is NULL.");\r
- }\r
- \r
- ArgumentValidator validator(context, argumentCount, arguments);\r
-\r
- JSObjectRef dataArrayObj = validator.toArrayObject(0); // data\r
- size_t size = JSGetArrayLength(context, dataArrayObj);\r
- char *buffer = new char[size];\r
- for(size_t i = 0; i < size; ++i) {\r
- JSValueRef element = JSGetArrayElement(context, dataArrayObj, i);\r
- buffer[i] = static_cast<char>(JSUtil::JSValueToByte(context, element));\r
- }\r
-\r
- JSValueRef result = JSUtil::toJSValueRef(context, priv->sendData(buffer, size));\r
- delete buffer;\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);;\r
-\r
- return result;\r
- } catch (const BasePlatformException &err) {\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- }\r
-}\r
-\r
-JSValueRef JSBluetoothHealthChannel::close(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
-\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;\r
- \r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("close::ACE", 1);;\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_CLOSE);\r
- TIME_TRACER_ITEM_END("close::ACE", 1);;\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- // Private Object\r
- BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));\r
- if (!priv) {\r
- throw DeviceAPI::Common::UnknownException("Private object is NULL.");\r
- }\r
-\r
- priv->close();\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);;\r
- \r
- return JSValueMakeUndefined(context);\r
- } catch (const BasePlatformException &err) {\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- }\r
-}\r
-\r
-JSValueRef JSBluetoothHealthChannel::setListener(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
-\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;\r
- \r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("setListener::ACE", 1);;\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER);\r
- TIME_TRACER_ITEM_END("setListener::ACE", 1);;\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- // Private Object\r
- BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));\r
- if (!priv) {\r
- throw DeviceAPI::Common::UnknownException("Private object is NULL.");\r
- }\r
-\r
- // Validate arguments\r
- ArgumentValidator validator(context, argumentCount, arguments);\r
-\r
- // successCallback\r
- JSObjectRef successCallback = validator.toCallbackObject(0, false, "onmessage", "onclose", NULL);\r
-\r
- MultiCallbackUserDataPtr callback(\r
- new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));\r
- if(!callback){\r
- LoggerW("Can't create MultiMultiCallbackUserData");\r
- }\r
- else {\r
- // onmessage\r
- JSValueRef onmessageValue = JSUtil::getProperty(context , successCallback, "onmessage");\r
- if(!JSValueIsUndefined(context, onmessageValue)) {\r
- LoggerD("There is a onmessage()");\r
- callback->setCallback("onmessage", JSUtil::JSValueToObject(context, onmessageValue));\r
- }\r
- \r
- // onclose\r
- JSValueRef oncloseValue = JSUtil::getProperty(context , successCallback, "onclose");\r
- if(!JSValueIsUndefined(context, oncloseValue)) {\r
- LoggerD("There is a onclose()");\r
- callback->setCallback("onclose", JSUtil::JSValueToObject(context, oncloseValue));\r
- }\r
- }\r
-\r
- priv->setListener(callback);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);;\r
- \r
- return JSValueMakeUndefined(context);\r
- } catch (const BasePlatformException &err) {\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- }\r
-}\r
-\r
-JSValueRef JSBluetoothHealthChannel::unsetListener(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
-\r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;\r
- \r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("unsetListener::ACE", 1);;\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER);\r
- TIME_TRACER_ITEM_END("unsetListener::ACE", 1);;\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- // Private Object\r
- BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));\r
- if (!priv) {\r
- throw DeviceAPI::Common::UnknownException("Private object is NULL.");\r
- }\r
-\r
- priv->unsetListener();\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);;\r
- \r
- return JSValueMakeUndefined(context);\r
- } catch (const BasePlatformException &err) {\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- }\r
-}\r
-\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <vector>
+
+#include <SecurityExceptions.h>
+#include <JSUtil.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+#include <PlatformException.h>
+#include <MultiCallbackUserData.h>
+
+#include "plugin_config.h"
+#include "JSBluetoothHealthChannel.h"
+#include "BluetoothHealthProfileHandler.h"
+
+#include <TimeTracer.h>
+#include <Logger.h>
+
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+JSClassDefinition JSBluetoothHealthChannel::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "BluetoothHealthChannel",
+ NULL, //ParentClass
+ m_property, //StaticValues
+ m_function, //StaticFunctions
+ initialize, //Initialize
+ finalize, //Finalize
+ NULL, //HasProperty,
+ NULL, //GetProperty,
+ NULL, //SetProperty,
+ NULL, //DeleteProperty,
+ NULL, //GetPropertyNames,
+ NULL, //CallAsFunction,
+ NULL, //CallAsConstructor,
+ NULL, //HasInstance,
+ NULL //ConvertToType
+};
+
+JSStaticValue JSBluetoothHealthChannel::m_property[] = {
+ { BLUETOOTH_HEALTH_CHANNEL_PEER, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },
+ { BLUETOOTH_HEALTH_CHANNEL_TYPE, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },
+ { BLUETOOTH_HEALTH_CHANNEL_APP, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete },
+ { BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeDontDelete },
+ { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSBluetoothHealthChannel::m_function[] = {
+ { BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA, sendData, kJSPropertyAttributeNone },
+ { BLUETOOTH_HEALTH_CHANNEL_API_CLOSE, close, kJSPropertyAttributeNone },
+ { BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER, setListener, kJSPropertyAttributeNone },
+ { BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER, unsetListener, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+JSClassRef JSBluetoothHealthChannel::m_jsClassRef = JSClassCreate(JSBluetoothHealthChannel::getClassInfo());
+
+const JSClassRef JSBluetoothHealthChannel::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSBluetoothHealthChannel::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+JSObjectRef JSBluetoothHealthChannel::createJSObject(JSContextRef context, BluetoothHealthChannelPtr channel)
+{
+ return JSObjectMake(context, getClassRef(), static_cast<void*>(channel));
+}
+
+void JSBluetoothHealthChannel::initialize(JSContextRef context, JSObjectRef object)
+{
+ // do nothing
+}
+
+void JSBluetoothHealthChannel::finalize(JSObjectRef object)
+{
+ BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(object));
+ if (priv) {
+ JSObjectSetPrivate(object, NULL);
+ delete priv;
+ }
+}
+
+JSValueRef JSBluetoothHealthChannel::getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ try {
+ BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(object));
+ if (!priv) {
+ throw TypeMismatchException("Private object is NULL");
+ }
+
+ if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_PEER)) {
+ return priv->getPeer(context);
+ }
+ else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_TYPE)) {
+ return JSUtil::toJSValueRef(context, priv->getChannelTypeStr());
+ }
+ else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_APP)) {
+ return priv->getApp(context);
+ }
+ else if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED)) {
+ return JSUtil::toJSValueRef(context, priv->getConnectionState());
+ }
+ } catch (const BasePlatformException &err) {
+ LoggerW("Getting property is failed: " << err.getMessage().c_str());
+ }
+
+ return NULL;
+}
+
+JSValueRef JSBluetoothHealthChannel::sendData(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("sendData::ACE", 1);;
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA);
+ TIME_TRACER_ITEM_END("sendData::ACE", 1);;
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ // Private Object
+ BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw DeviceAPI::Common::UnknownException("Private object is NULL.");
+ }
+
+ ArgumentValidator validator(context, argumentCount, arguments);
+
+ JSObjectRef dataArrayObj = validator.toArrayObject(0); // data
+ size_t size = JSGetArrayLength(context, dataArrayObj);
+ char *buffer = new char[size];
+ for(size_t i = 0; i < size; ++i) {
+ JSValueRef element = JSGetArrayElement(context, dataArrayObj, i);
+ buffer[i] = static_cast<char>(JSUtil::JSValueToByte(context, element));
+ }
+
+ JSValueRef result = JSUtil::toJSValueRef(context, priv->sendData(buffer, size));
+ delete buffer;
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
+
+ return result;
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSBluetoothHealthChannel::close(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("close::ACE", 1);;
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_CLOSE);
+ TIME_TRACER_ITEM_END("close::ACE", 1);;
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ // Private Object
+ BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw DeviceAPI::Common::UnknownException("Private object is NULL.");
+ }
+
+ priv->close();
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
+
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSBluetoothHealthChannel::setListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("setListener::ACE", 1);;
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER);
+ TIME_TRACER_ITEM_END("setListener::ACE", 1);;
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ // Private Object
+ BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw DeviceAPI::Common::UnknownException("Private object is NULL.");
+ }
+
+ // Validate arguments
+ ArgumentValidator validator(context, argumentCount, arguments);
+
+ // successCallback
+ JSObjectRef successCallback = validator.toCallbackObject(0, false, "onmessage", "onclose", NULL);
+
+ MultiCallbackUserDataPtr callback(
+ new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+ if(!callback){
+ LoggerW("Can't create MultiMultiCallbackUserData");
+ }
+ else {
+ // onmessage
+ JSValueRef onmessageValue = JSUtil::getProperty(context , successCallback, "onmessage");
+ if(!JSValueIsUndefined(context, onmessageValue)) {
+ LoggerD("There is a onmessage()");
+ callback->setCallback("onmessage", JSUtil::JSValueToObject(context, onmessageValue));
+ }
+
+ // onclose
+ JSValueRef oncloseValue = JSUtil::getProperty(context , successCallback, "onclose");
+ if(!JSValueIsUndefined(context, oncloseValue)) {
+ LoggerD("There is a onclose()");
+ callback->setCallback("onclose", JSUtil::JSValueToObject(context, oncloseValue));
+ }
+ }
+
+ priv->setListener(callback);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
+
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSBluetoothHealthChannel::unsetListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("unsetListener::ACE", 1);;
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER);
+ TIME_TRACER_ITEM_END("unsetListener::ACE", 1);;
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ // Private Object
+ BluetoothHealthChannelPtr priv = static_cast<BluetoothHealthChannelPtr>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw DeviceAPI::Common::UnknownException("Private object is NULL.");
+ }
+
+ priv->unsetListener();
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
+
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_JS_BLUETOOTH_HEALTH_CHANNEL_H__\r
-#define __TIZEN_JS_BLUETOOTH_HEALTH_CHANNEL_H__\r
-\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-#include "BluetoothHealthChannel.h"\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class JSBluetoothHealthChannel\r
-{\r
-public:\r
- static const JSClassDefinition* getClassInfo();\r
- static const JSClassRef getClassRef();\r
- static JSObjectRef createJSObject(JSContextRef context, BluetoothHealthChannelPtr channel);\r
- \r
-private:\r
-\r
- /**\r
- * The callback invoked when an object is first created.\r
- */\r
- static void initialize(JSContextRef context,\r
- JSObjectRef object);\r
-\r
- /**\r
- * The callback invoked when an object is finalized.\r
- */\r
- static void finalize(JSObjectRef object);\r
-\r
- static JSValueRef getProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef* exception);\r
-\r
- static JSValueRef close(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- static JSValueRef sendData(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- static JSValueRef setListener(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- static JSValueRef unsetListener(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- /**\r
- * This member variable contains the values which has to be passed\r
- * when the this class is embedded into JS Engine.\r
- */\r
- static JSClassDefinition m_classInfo;\r
-\r
- /**\r
- * This structure describes a statically declared function property.\r
- */\r
- static JSStaticFunction m_function[];\r
-\r
- /**\r
- * This member variable contains the initialization values for the\r
- * properties of this class. The values are given according to\r
- * the data structure JSPropertySpec\r
- */\r
- static JSStaticValue m_property[];\r
-\r
- static JSClassRef m_jsClassRef;\r
-};\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_JS_BLUETOOTH_HEALTH_CHANNEL_H__\r
-\r
-\r
-\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_JS_BLUETOOTH_HEALTH_CHANNEL_H__
+#define __TIZEN_JS_BLUETOOTH_HEALTH_CHANNEL_H__
+
+#include <JavaScriptCore/JavaScript.h>
+
+#include "BluetoothHealthChannel.h"
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class JSBluetoothHealthChannel
+{
+public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, BluetoothHealthChannelPtr channel);
+
+private:
+
+ /**
+ * The callback invoked when an object is first created.
+ */
+ static void initialize(JSContextRef context,
+ JSObjectRef object);
+
+ /**
+ * The callback invoked when an object is finalized.
+ */
+ static void finalize(JSObjectRef object);
+
+ static JSValueRef getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+
+ static JSValueRef close(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef sendData(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef setListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef unsetListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ /**
+ * This member variable contains the values which has to be passed
+ * when the this class is embedded into JS Engine.
+ */
+ static JSClassDefinition m_classInfo;
+
+ /**
+ * This structure describes a statically declared function property.
+ */
+ static JSStaticFunction m_function[];
+
+ /**
+ * This member variable contains the initialization values for the
+ * properties of this class. The values are given according to
+ * the data structure JSPropertySpec
+ */
+ static JSStaticValue m_property[];
+
+ static JSClassRef m_jsClassRef;
+};
+
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_JS_BLUETOOTH_HEALTH_CHANNEL_H__
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <SecurityExceptions.h>\r
-\r
-#include <JSUtil.h>\r
-#include <ArgumentValidator.h>\r
-#include <GlobalContextManager.h>\r
-\r
-#include "plugin_config.h"\r
-#include "JSBluetoothHealthProfileHandler.h"\r
-#include "JSBluetoothProfileHandler.h"\r
-#include "JSBluetoothHealthApplication.h"\r
-#include "JSBluetoothDevice.h"\r
-#include "BluetoothHealthProfileHandler.h"\r
-\r
-#include <TimeTracer.h>\r
-#include <Logger.h>\r
-\r
-using namespace WrtDeviceApis::Commons;\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-JSClassDefinition JSBluetoothHealthProfileHandler::m_classInfo = {\r
- 0,\r
- kJSClassAttributeNone,\r
- "BluetoothHealthProfileHandler",\r
- JSBluetoothProfileHandler::getClassRef(), //ParentClass\r
- NULL, //StaticValues\r
- m_function, //StaticFunctions\r
- initialize, //Initialize\r
- finalize, //Finalize\r
- NULL, //HasProperty,\r
- NULL, //GetProperty,\r
- NULL, //SetProperty,\r
- NULL, //DeleteProperty,\r
- NULL, //GetPropertyNames,\r
- NULL, //CallAsFunction,\r
- NULL, //CallAsConstructor,\r
- NULL, //HasInstance,\r
- NULL //ConvertToType\r
-};\r
-\r
-JSStaticFunction JSBluetoothHealthProfileHandler::m_function[] = {\r
- { BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION, registerSinkApplication, kJSPropertyAttributeNone },\r
- { BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE, connectToSource, kJSPropertyAttributeNone },\r
- { 0, 0, 0 }\r
-};\r
-\r
-JSClassRef JSBluetoothHealthProfileHandler::m_jsClassRef = JSClassCreate(JSBluetoothHealthProfileHandler::getClassInfo());\r
-\r
-const JSClassRef JSBluetoothHealthProfileHandler::getClassRef()\r
-{\r
- if (!m_jsClassRef) {\r
- m_jsClassRef = JSClassCreate(&m_classInfo);\r
- }\r
- return m_jsClassRef;\r
-}\r
-\r
-const JSClassDefinition* JSBluetoothHealthProfileHandler::getClassInfo()\r
-{\r
- return &m_classInfo;\r
-}\r
-\r
-JSObjectRef JSBluetoothHealthProfileHandler::createJSObject(JSContextRef context)\r
-{\r
- return JSObjectMake(context, getClassRef(), NULL);\r
-}\r
-\r
-void JSBluetoothHealthProfileHandler::initialize(JSContextRef context, JSObjectRef object)\r
-{\r
- // do nothing\r
-}\r
-\r
-\r
-void JSBluetoothHealthProfileHandler::finalize(JSObjectRef object)\r
-{\r
- // do nothing\r
-}\r
-\r
-JSValueRef JSBluetoothHealthProfileHandler::registerSinkApplication(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
- \r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- \r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("registerSinkApplication::ACE", 1);\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION);\r
- TIME_TRACER_ITEM_END("registerSinkApplication::ACE", 1);\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- ArgumentValidator validator(context, argumentCount, arguments); \r
- unsigned short dataType = static_cast<unsigned short>(validator.toULong(0)); // dataType\r
- std::string name = validator.toString(1); // name\r
- JSObjectRef successCallback = validator.toFunction(2); // successCallback \r
- JSObjectRef errorCallback = validator.toFunction(3, true); // errorCallback\r
-\r
- // perform\r
- MultiCallbackUserDataPtr callback(\r
- new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));\r
- if(!callback){\r
- LoggerW("Can't create MultiCallbackUserData");\r
- }\r
- else {\r
- callback->setCallback("success", successCallback);\r
- callback->setCallback("error", errorCallback);\r
- } \r
- \r
- BluetoothHealthProfileHandler::getInstance()->registerSinkApp(dataType, name, callback);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);\r
- \r
- return JSValueMakeUndefined(context);\r
- } catch (const BasePlatformException &err) {\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.setName().");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } \r
-}\r
-\r
-JSValueRef JSBluetoothHealthProfileHandler::connectToSource(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception)\r
-{\r
- LoggerD("Enter");\r
- \r
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);\r
- \r
- // Access Check\r
- /*\r
- TIME_TRACER_ITEM_BEGIN("setName::ACE", 1);\r
- AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE);\r
- TIME_TRACER_ITEM_END("setName::ACE", 1);\r
- TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);\r
- */\r
-\r
- try {\r
- ArgumentValidator validator(context, argumentCount, arguments);\r
- JSObjectRef remoteObj = validator.toObject(0); // remoteDevice \r
- if(!JSValueIsObjectOfClass(context, remoteObj, JSBluetoothDevice::getClassRef())) {\r
- throw TypeMismatchException("remoteDevice is not a BluetoothDevice object");\r
- }\r
-\r
- JSObjectRef appObj = validator.toObject(1); // application\r
- if(!JSValueIsObjectOfClass(context, appObj, JSBluetoothHealthApplication::getClassRef())) {\r
- throw TypeMismatchException("application is not a BluetoothHealthApplication object");\r
- }\r
-\r
- JSObjectRef successCallback = validator.toFunction(2); // successCallback \r
- JSObjectRef errorCallback = validator.toFunction(3, true); // errorCallback\r
-\r
- // perform\r
- MultiCallbackUserDataPtr callback(\r
- new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));\r
- if(!callback){\r
- LoggerW("Can't create MultiCallbackUserData");\r
- }\r
- else {\r
- callback->setCallback("success", successCallback);\r
- callback->setCallback("error", errorCallback);\r
- } \r
-\r
- BluetoothHealthProfileHandler::getInstance()->connectToSource(remoteObj, appObj, callback);\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1);\r
- \r
- return JSValueMakeUndefined(context); \r
- } catch (const BasePlatformException &err) {\r
- TIME_TRACER_ITEM_END(__FUNCTION__, 1); \r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } catch (...) {\r
- DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.setName().");\r
- return JSWebAPIErrorFactory::postException(context, exception, err);\r
- } \r
-}\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <SecurityExceptions.h>
+
+#include <JSUtil.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+
+#include "plugin_config.h"
+#include "JSBluetoothHealthProfileHandler.h"
+#include "JSBluetoothProfileHandler.h"
+#include "JSBluetoothHealthApplication.h"
+#include "JSBluetoothDevice.h"
+#include "BluetoothHealthProfileHandler.h"
+
+#include <TimeTracer.h>
+#include <Logger.h>
+
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+JSClassDefinition JSBluetoothHealthProfileHandler::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "BluetoothHealthProfileHandler",
+ JSBluetoothProfileHandler::getClassRef(), //ParentClass
+ NULL, //StaticValues
+ m_function, //StaticFunctions
+ initialize, //Initialize
+ finalize, //Finalize
+ NULL, //HasProperty,
+ NULL, //GetProperty,
+ NULL, //SetProperty,
+ NULL, //DeleteProperty,
+ NULL, //GetPropertyNames,
+ NULL, //CallAsFunction,
+ NULL, //CallAsConstructor,
+ NULL, //HasInstance,
+ NULL //ConvertToType
+};
+
+JSStaticFunction JSBluetoothHealthProfileHandler::m_function[] = {
+ { BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION, registerSinkApplication, kJSPropertyAttributeNone },
+ { BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE, connectToSource, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+JSClassRef JSBluetoothHealthProfileHandler::m_jsClassRef = JSClassCreate(JSBluetoothHealthProfileHandler::getClassInfo());
+
+const JSClassRef JSBluetoothHealthProfileHandler::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSBluetoothHealthProfileHandler::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+JSObjectRef JSBluetoothHealthProfileHandler::createJSObject(JSContextRef context)
+{
+ return JSObjectMake(context, getClassRef(), NULL);
+}
+
+void JSBluetoothHealthProfileHandler::initialize(JSContextRef context, JSObjectRef object)
+{
+ // do nothing
+}
+
+
+void JSBluetoothHealthProfileHandler::finalize(JSObjectRef object)
+{
+ // do nothing
+}
+
+JSValueRef JSBluetoothHealthProfileHandler::registerSinkApplication(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("registerSinkApplication::ACE", 1);
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION);
+ TIME_TRACER_ITEM_END("registerSinkApplication::ACE", 1);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ ArgumentValidator validator(context, argumentCount, arguments);
+ unsigned short dataType = static_cast<unsigned short>(validator.toULong(0)); // dataType
+ std::string name = validator.toString(1); // name
+ JSObjectRef successCallback = validator.toFunction(2); // successCallback
+ JSObjectRef errorCallback = validator.toFunction(3, true); // errorCallback
+
+ // perform
+ MultiCallbackUserDataPtr callback(
+ new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+ if(!callback){
+ LoggerW("Can't create MultiCallbackUserData");
+ }
+ else {
+ callback->setCallback("success", successCallback);
+ callback->setCallback("error", errorCallback);
+ }
+
+ BluetoothHealthProfileHandler::getInstance()->registerSinkApp(dataType, name, callback);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.setName().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSBluetoothHealthProfileHandler::connectToSource(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ // Access Check
+ TIME_TRACER_ITEM_BEGIN("setName::ACE", 1);
+ AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE);
+ TIME_TRACER_ITEM_END("setName::ACE", 1);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ ArgumentValidator validator(context, argumentCount, arguments);
+ JSObjectRef remoteObj = validator.toObject(0); // remoteDevice
+ if(!JSValueIsObjectOfClass(context, remoteObj, JSBluetoothDevice::getClassRef())) {
+ throw TypeMismatchException("remoteDevice is not a BluetoothDevice object");
+ }
+
+ JSObjectRef appObj = validator.toObject(1); // application
+ if(!JSValueIsObjectOfClass(context, appObj, JSBluetoothHealthApplication::getClassRef())) {
+ throw TypeMismatchException("application is not a BluetoothHealthApplication object");
+ }
+
+ JSObjectRef successCallback = validator.toFunction(2); // successCallback
+ JSObjectRef errorCallback = validator.toFunction(3, true); // errorCallback
+
+ // perform
+ MultiCallbackUserDataPtr callback(
+ new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+ if(!callback){
+ LoggerW("Can't create MultiCallbackUserData");
+ }
+ else {
+ callback->setCallback("success", successCallback);
+ callback->setCallback("error", errorCallback);
+ }
+
+ BluetoothHealthProfileHandler::getInstance()->connectToSource(remoteObj, appObj, callback);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.setName().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_JS_HEALTH_PROFILE_HANDLER_H__\r
-#define __TIZEN_JS_HEALTH_PROFILE_HANDLER_H__\r
-\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class JSBluetoothHealthProfileHandler\r
-{\r
-public:\r
- static const JSClassDefinition* getClassInfo();\r
- static const JSClassRef getClassRef();\r
- static JSObjectRef createJSObject(JSContextRef context);\r
- \r
-private:\r
-\r
- /**\r
- * The callback invoked when an object is first created.\r
- */\r
- static void initialize(JSContextRef context,\r
- JSObjectRef object);\r
-\r
- /**\r
- * The callback invoked when an object is finalized.\r
- */\r
- static void finalize(JSObjectRef object);\r
-\r
- static JSValueRef registerSinkApplication(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- static JSValueRef connectToSource(JSContextRef context,\r
- JSObjectRef object,\r
- JSObjectRef thisObject,\r
- size_t argumentCount,\r
- const JSValueRef arguments[],\r
- JSValueRef* exception);\r
-\r
- /**\r
- * This member variable contains the values which has to be passed\r
- * when the this class is embedded into JS Engine.\r
- */\r
- static JSClassDefinition m_classInfo;\r
-\r
- /**\r
- * This structure describes a statically declared function property.\r
- */\r
- static JSStaticFunction m_function[];\r
-\r
- static JSClassRef m_jsClassRef;\r
-};\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_JS_HEALTH_PROFILE_HANDLER_H__\r
-\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_JS_HEALTH_PROFILE_HANDLER_H__
+#define __TIZEN_JS_HEALTH_PROFILE_HANDLER_H__
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class JSBluetoothHealthProfileHandler
+{
+public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context);
+
+private:
+
+ /**
+ * The callback invoked when an object is first created.
+ */
+ static void initialize(JSContextRef context,
+ JSObjectRef object);
+
+ /**
+ * The callback invoked when an object is finalized.
+ */
+ static void finalize(JSObjectRef object);
+
+ static JSValueRef registerSinkApplication(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef connectToSource(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ /**
+ * This member variable contains the values which has to be passed
+ * when the this class is embedded into JS Engine.
+ */
+ static JSClassDefinition m_classInfo;
+
+ /**
+ * This structure describes a statically declared function property.
+ */
+ static JSStaticFunction m_function[];
+
+ static JSClassRef m_jsClassRef;
+};
+
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_JS_HEALTH_PROFILE_HANDLER_H__
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <SecurityExceptions.h>\r
-\r
-#include <JSUtil.h>\r
-#include <ArgumentValidator.h>\r
-#include <GlobalContextManager.h>\r
-#include <PlatformException.h>\r
-\r
-#include "plugin_config.h"\r
-#include "JSBluetoothProfileHandler.h"\r
-#include "JSBluetoothHealthProfileHandler.h"\r
-\r
-#include <TimeTracer.h>\r
-#include <Logger.h>\r
-\r
-using namespace WrtDeviceApis::Commons;\r
-using namespace DeviceAPI::Common;\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-JSClassDefinition JSBluetoothProfileHandler::m_classInfo = {\r
- 0,\r
- kJSClassAttributeNone,\r
- "BluetoothProfileHandler",\r
- NULL, //ParentClass\r
- m_property, //StaticValues\r
- NULL, //StaticFunctions\r
- initialize, //Initialize\r
- finalize, //Finalize\r
- NULL, //HasProperty,\r
- NULL, //GetProperty,\r
- NULL, //SetProperty,\r
- NULL, //DeleteProperty,\r
- NULL, //GetPropertyNames,\r
- NULL, //CallAsFunction,\r
- NULL, //CallAsConstructor,\r
- NULL, //HasInstance,\r
- NULL //ConvertToType\r
-};\r
-\r
-JSStaticValue JSBluetoothProfileHandler::m_property[] = {\r
- { BLUETOOTH_PROFILE_TYPE, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},\r
- { 0, 0, 0, 0 }\r
-};\r
-\r
-JSClassRef JSBluetoothProfileHandler::m_jsClassRef = JSClassCreate(JSBluetoothProfileHandler::getClassInfo());\r
-\r
-const JSClassRef JSBluetoothProfileHandler::getClassRef()\r
-{\r
- if (!m_jsClassRef) {\r
- m_jsClassRef = JSClassCreate(&m_classInfo);\r
- }\r
- return m_jsClassRef;\r
-}\r
-\r
-const JSClassDefinition* JSBluetoothProfileHandler::getClassInfo()\r
-{\r
- return &m_classInfo;\r
-}\r
-\r
-void JSBluetoothProfileHandler::initialize(JSContextRef context, JSObjectRef object)\r
-{\r
- // Do nothing\r
-}\r
-\r
-void JSBluetoothProfileHandler::finalize(JSObjectRef object)\r
-{\r
- // Do nothing\r
-}\r
-\r
-JSValueRef JSBluetoothProfileHandler::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {\r
- LoggerD("Enter");\r
- try {\r
- if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_PROFILE_TYPE)) {\r
- if(object) {\r
- if(JSValueIsObjectOfClass(context, object, JSBluetoothHealthProfileHandler::getClassRef())) {\r
- std::string profileType("HEALTH");\r
- LoggerD("profileType: " << profileType.c_str());\r
- return JSUtil::toJSValueRef(context, profileType);\r
- }\r
- }\r
- else {\r
- LoggerE("object is NULL");\r
- }\r
- }\r
- } catch (const BasePlatformException &err) {\r
- LoggerW("Getting property is failed" << err.getMessage().c_str());\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <SecurityExceptions.h>
+
+#include <JSUtil.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+#include <PlatformException.h>
+
+#include "plugin_config.h"
+#include "JSBluetoothProfileHandler.h"
+#include "JSBluetoothHealthProfileHandler.h"
+
+#include <TimeTracer.h>
+#include <Logger.h>
+
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+JSClassDefinition JSBluetoothProfileHandler::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "BluetoothProfileHandler",
+ NULL, //ParentClass
+ m_property, //StaticValues
+ NULL, //StaticFunctions
+ initialize, //Initialize
+ finalize, //Finalize
+ NULL, //HasProperty,
+ NULL, //GetProperty,
+ NULL, //SetProperty,
+ NULL, //DeleteProperty,
+ NULL, //GetPropertyNames,
+ NULL, //CallAsFunction,
+ NULL, //CallAsConstructor,
+ NULL, //HasInstance,
+ NULL //ConvertToType
+};
+
+JSStaticValue JSBluetoothProfileHandler::m_property[] = {
+ { BLUETOOTH_PROFILE_TYPE, getProperty, NULL, kJSPropertyAttributeNone|kJSPropertyAttributeReadOnly|kJSPropertyAttributeDontDelete},
+ { 0, 0, 0, 0 }
+};
+
+JSClassRef JSBluetoothProfileHandler::m_jsClassRef = JSClassCreate(JSBluetoothProfileHandler::getClassInfo());
+
+const JSClassRef JSBluetoothProfileHandler::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSBluetoothProfileHandler::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSBluetoothProfileHandler::initialize(JSContextRef context, JSObjectRef object)
+{
+ // Do nothing
+}
+
+void JSBluetoothProfileHandler::finalize(JSObjectRef object)
+{
+ // Do nothing
+}
+
+JSValueRef JSBluetoothProfileHandler::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
+ LoggerD("Enter");
+ try {
+ if (JSStringIsEqualToUTF8CString(propertyName, BLUETOOTH_PROFILE_TYPE)) {
+ if(object) {
+ if(JSValueIsObjectOfClass(context, object, JSBluetoothHealthProfileHandler::getClassRef())) {
+ std::string profileType("HEALTH");
+ LoggerD("profileType: " << profileType.c_str());
+ return JSUtil::toJSValueRef(context, profileType);
+ }
+ }
+ else {
+ LoggerE("object is NULL");
+ }
+ }
+ } catch (const BasePlatformException &err) {
+ LoggerW("Getting property is failed" << err.getMessage().c_str());
+ }
+
+ return NULL;
+}
+
+
+
+} // Bluetooth
+} // DeviceAPI
-//\r
-// Tizen Web Device API\r
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-// http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#ifndef __TIZEN_JS_BLUETOOTH_PROFILE_HANDLER_H__\r
-#define __TIZEN_JS_BLUETOOTH_PROFILE_HANDLER_H__\r
-\r
-#include <JavaScriptCore/JavaScript.h>\r
-\r
-namespace DeviceAPI {\r
-namespace Bluetooth {\r
-\r
-class JSBluetoothProfileHandler\r
-{\r
-public:\r
- static const JSClassDefinition* getClassInfo();\r
- static const JSClassRef getClassRef();\r
-\r
-private:\r
-\r
- /**\r
- * The callback invoked when an object is first created.\r
- */\r
- static void initialize(JSContextRef context,\r
- JSObjectRef object);\r
-\r
- /**\r
- * The callback invoked when an object is finalized.\r
- */\r
- static void finalize(JSObjectRef object);\r
-\r
- static JSValueRef getProperty(JSContextRef context,\r
- JSObjectRef object,\r
- JSStringRef propertyName,\r
- JSValueRef* exception);\r
-\r
- /**\r
- * This member variable contains the values which has to be passed\r
- * when the this class is embedded into JS Engine.\r
- */\r
- static JSClassDefinition m_classInfo;\r
-\r
- static JSStaticValue m_property[];\r
-\r
- static JSClassRef m_jsClassRef;\r
-\r
-};\r
-\r
-\r
-\r
-} // Bluetooth\r
-} // DeviceAPI\r
-\r
-#endif // __TIZEN_JS_BLUETOOTH_PROFILE_HANDLER_H__\r
-\r
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef __TIZEN_JS_BLUETOOTH_PROFILE_HANDLER_H__
+#define __TIZEN_JS_BLUETOOTH_PROFILE_HANDLER_H__
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace DeviceAPI {
+namespace Bluetooth {
+
+class JSBluetoothProfileHandler
+{
+public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+
+private:
+
+ /**
+ * The callback invoked when an object is first created.
+ */
+ static void initialize(JSContextRef context,
+ JSObjectRef object);
+
+ /**
+ * The callback invoked when an object is finalized.
+ */
+ static void finalize(JSObjectRef object);
+
+ static JSValueRef getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+
+ /**
+ * This member variable contains the values which has to be passed
+ * when the this class is embedded into JS Engine.
+ */
+ static JSClassDefinition m_classInfo;
+
+ static JSStaticValue m_property[];
+
+ static JSClassRef m_jsClassRef;
+
+};
+
+
+
+} // Bluetooth
+} // DeviceAPI
+
+#endif // __TIZEN_JS_BLUETOOTH_PROFILE_HANDLER_H__
<device-capability>bluetooth.spp</device-capability>
</api-feature>
-</plugin-properties>
\ No newline at end of file
+ <api-feature>
+ <name>http://tizen.org/privilege/bluetooth.health</name>
+ <device-capability>bluetooth.health</device-capability>
+ </api-feature>
+
+</plugin-properties>
JSObjectRef JSBookmarkFolder::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
LoggerD("Enter");
+ JSObjectRef bookmarkFolder = NULL;
try{
ArgumentValidator validator(ctx, argumentCount, arguments);
std::string title = validator.toString(0);
- JSObjectRef bookmarkFolder = createJSObject(ctx, title);
- if (bookmarkFolder) {
- JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
- JSObjectSetProperty(ctx, bookmarkFolder, ctorName, constructor,
- kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
- JSStringRelease(ctorName);
- return bookmarkFolder;
- } else
- throw TypeMismatchException("Can't create BookmarkFolder");
- } catch(const BasePlatformException& err){
- return JSWebAPIErrorFactory::postException(ctx, exception, err);
- }
+ bookmarkFolder = createJSObject(ctx, title);
+ } catch(const BasePlatformException& err){
+ LoggerE(err.getName() << ":" << err.getMessage());
+ bookmarkFolder = createJSObject(ctx, "");
+ }
+ JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+ JSObjectSetProperty(ctx, bookmarkFolder, ctorName, constructor,
+ kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+ JSStringRelease(ctorName);
+ return bookmarkFolder;
}
JSObjectRef JSBookmarkFolder::createJSObject(JSContextRef context, const std::string &title) {
JSObjectRef JSBookmarkFolder::createJSObject(JSContextRef context, const std::string &title, const int id, const int parentId) {
LoggerD("Enter");
- if (title == "")
- throw InvalidValuesException("Title is empty");
+
BookmarkData *priv = new BookmarkData(BOOKMARKFOLDER_TYPE, title, "", id, parentId);
JSObjectRef obj = JSObjectMake(context, getClassRef(), priv);
return obj;
}
-#if 0
-JSObjectRef JSBookmarkFolder::createJSObject(JSContextRef context, void *priv) {
- JSObjectRef obj = JSObjectMake(context, getClassRef(), priv);
- return obj;
-}
-#endif
JSValueRef JSBookmarkFolder::getParent(JSContextRef context, JSObjectRef object) {
LoggerD("Enter");;
BookmarkData * priv = static_cast<BookmarkData *>(JSObjectGetPrivate(object));
JSObjectRef JSBookmarkItem::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
LoggerD("JSBookmarkItem::constructor()");
ArgumentValidator validator(ctx, argumentCount, arguments);
- try{
- std::string title = validator.toString(0);
+ JSObjectRef bookmarkItem = NULL;
+ try{
+ std::string title = validator.toString(0);
std::string url = validator.toString(1);
- JSObjectRef bookmarkItem = createJSObject(ctx, title, url);
- if (bookmarkItem) {
- JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
- JSObjectSetProperty(ctx, bookmarkItem, ctorName, constructor,
- kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
- JSStringRelease(ctorName);
- return bookmarkItem;
- } else
- throw TypeMismatchException("Can't create BookmarkItem");
- }catch(const BasePlatformException& err){
- return JSWebAPIErrorFactory::postException(ctx, exception, err);
- }
+ bookmarkItem = createJSObject(ctx, title, url);
+ }catch(const BasePlatformException& err){
+ LoggerE(err.getName() << ":" << err.getMessage());
+ bookmarkItem = createJSObject(ctx, "", "");
+ }
+ JSStringRef ctorName = JSStringCreateWithUTF8CString("constructor");
+ JSObjectSetProperty(ctx, bookmarkItem, ctorName, constructor,
+ kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete | kJSPropertyAttributeDontEnum, NULL);
+ JSStringRelease(ctorName);
+ return bookmarkItem;
}
JSObjectRef JSBookmarkItem::createJSObject(JSContextRef context, const std::string &title, const std::string &url) {
}
JSObjectRef JSBookmarkItem::createJSObject(JSContextRef context, const std::string &title, const std::string &url, const int id, const int parentId) {
LoggerD("Enter");
- if (title == "")
- throw InvalidValuesException("Title is empty");
- if (url == "")
- throw InvalidValuesException("URL is empty");
BookmarkData *priv = new BookmarkData(BOOKMARKITEM_TYPE, title, url, id, parentId);
JSObjectRef obj = JSObjectMake(context, getClassRef(), priv);
return obj;
}
-#if 0
-JSObjectRef JSBookmarkItem::createJSObject(JSContextRef context, void *priv) {
- JSObjectRef obj = JSObjectMake(context, getClassRef(), priv);
- return obj;
-}
-#endif
+
JSValueRef JSBookmarkItem::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
{
LoggerD("Enter");
JSClassRef JSCalendarEvent::m_jsClassRef = JSClassCreate(JSCalendarEvent::getClassInfo());
-ICalendarPtr JSCalendarEvent::m_calendar = CalendarFactory::getInstance().createCalendarObject();
+ICalendarPtr JSCalendarEvent::m_calendar;
void JSCalendarEvent::initialize(JSContextRef context,
JSObjectRef object)
LoggerD("Private object already set.");
}
+ if (NULL==m_calendar) {
+ m_calendar = CalendarFactory::getInstance().createCalendarObject();
+ LoggerD("Static calendar for event created.");
+ }
+
if (m_calendar) {
m_calendar->setType(CalendarEvent::EVENT_TYPE);
LoggerD("Calendar object type is set to event.");
JSClassRef JSCalendarTask::m_jsClassRef = JSClassCreate(JSCalendarTask::getClassInfo());
-ICalendarPtr JSCalendarTask::m_calendar = CalendarFactory::getInstance().createCalendarObject();
+ICalendarPtr JSCalendarTask::m_calendar;
void JSCalendarTask::initialize(JSContextRef context,
JSObjectRef object)
LoggerD("Private object already set.");
}
+ if (NULL==m_calendar) {
+ m_calendar = CalendarFactory::getInstance().createCalendarObject();
+ LoggerD("Static calendar for task created.");
+ }
+
if (m_calendar) {
m_calendar->setType(CalendarEvent::TASK_TYPE);
LoggerD("Calendar object type is set to task.");
}
Catch (PlatformException)
{
- LoggerE("Error during updating contact : " << _rethrown_exception.GetMessage());
+ LoggerE("Error during deleting contact : " << _rethrown_exception.GetMessage());
event->setResult(false);
event->setExceptionCode(ExceptionCodes::PlatformException);
return;
}
Catch (Exception)
{
- LoggerE("Error during updating contact : " << _rethrown_exception.GetMessage());
+ LoggerE("Error during deleting contact : " << _rethrown_exception.GetMessage());
event->setResult(false);
event->setExceptionCode(ExceptionCodes::PlatformException);
return;
ThrowMsg(WrtDeviceApis::Commons::ConversionException, "ContactArray is not array.");
ContactArrayPtr result = ContactArrayPtr(new ContactArray());
+ bool duplicate = false;
JSObjectRef jsObject = toJSObjectRef(jsValue);
for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
- result->push_back(toContact(element));
+
+ ContactPtr tmpContactObj = toContact(element);
+ duplicate = false;
+ for(int j=0; j<result->size(); j++){
+ if(result->at(j) == tmpContactObj)
+ duplicate = true;
+ }
+ if(!duplicate)
+ result->push_back(tmpContactObj);
}
return result;
}
DPL::SharedPtr<Contact> newContactT = DPL::StaticPointerCast<Contact>(contact);
if(newContactT->EmailsJSObjIsSet()){
- LoggerD("return init value");
return newContactT->getEmailsJSObj();
}else{
- LoggerD("new array");
JSValueRef tempJSValue = newContactT->getEmailsJSValue();
tempJSValue = converter->toJSValueRef(newContactT->getEmails());
// CONTACT_FUNCTION_API_CONVERT_TO_STRING);
// TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
- ArgumentValidator validator(context, argumentCount, arguments);
std::string format;
+ if(argumentCount > 0){
+ ArgumentValidator validator(context, argumentCount, arguments);
try {
format = validator.toString(0, false);
} catch (const TypeMismatchException& err ) {
} catch(const NullPointerException& err) {
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
}
+ }else{
+ format = "VCARD_30";
+ }
std::string vCard;
Try {
errorCode = contacts_person_link_person(selfPersonId, personId);
if(errorCode == CONTACTS_ERROR_INVALID_PARAMETER)
- ThrowMsg(NotFoundException, "Error during executing contacts_db_delete_record()");
+ ThrowMsg(NotFoundException, "Error during executing person link()");
else if (errorCode != CONTACTS_ERROR_NONE)
- ThrowMsg(PlatformException, "Error during executing contacts_db_delete_record()");
+ ThrowMsg(PlatformException, "Error during executing person link()");
errorCode = contacts_db_get_record(_contacts_person._uri, selfPersonId, &contacts_record);
if(errorCode != CONTACTS_ERROR_NONE)
if(matchValue->isType(PrimitiveType_Time))
{
- tm date = *matchValue->getDateTm();
- valueStr = toDateDbStr(date);
+ tm date = *matchValue->getDateTm();
+ if(attrName.compare("MEDIA_DATETAKEN")==0)
+ {
+ char buf[512];
+ strftime(buf, sizeof(buf), "'%Y:%m:%d %H:%M:%S'", &date);
+ valueStr = buf;
+ }
+ else
+ {
+ valueStr = toDateDbStr(date);
+ }
cond = EQUAL;
}
else
{
if(initialValue->isType(PrimitiveType_Time))
{
- tm date = *initialValue->getDateTm();
- initialValueStr = toDateDbStr(date);
-
+ tm date = *initialValue->getDateTm();
+ if(attrName.compare("MEDIA_DATETAKEN")==0)
+ {
+ char buf[512];
+ strftime(buf, sizeof(buf), "'%Y:%m:%d %H:%M:%S'", &date);
+ initialValueStr = buf;
+ }
+ else
+ {
+ initialValueStr = toDateDbStr(date);
+ }
}
else
{
{
if(endValue->isType(PrimitiveType_Time))
{
- tm date = *endValue->getDateTm();
- endValueStr = toDateDbStr(date);
+ tm date = *endValue->getDateTm();
+ if(attrName.compare("MEDIA_DATETAKEN")==0)
+ {
+ char buf[512];
+ strftime(buf, sizeof(buf), "'%Y:%m:%d %H:%M:%S'", &date);
+ endValueStr = buf;
+ }
+ else
+ {
+ endValueStr = toDateDbStr(date);
+ }
}
else
{
if(successCallbackObj){
cbm->setOnSuccess(successCallbackObj);
}
- else{
- throw TypeMismatchException("SuccessCallback type mismatched.");
- }
JSObjectRef errorCallbackObj = argValidator.toFunction(2,true);
if(errorCallbackObj){
}
m_mappedDataControlGCMap[address] = gc;
}
+
+ bool checkDoSQLOperation()
+ {
+// return m_callbackSQLUserDataMap.empty();
+ // limitation 128
+ if (m_callbackSQLUserDataMap.size() < 128)
+ return true;
+ else
+ return false;
+ }
+
+ void* getRemainingSQLOperation()
+ {
+ LoggerD("OK");
+ void *retPtr = NULL;
+
+ if (m_callbackSQLUserDataMap.empty() == false)
+ {
+ std::string key = m_sqlReqIdVector[0];
+ retPtr = m_callbackSQLUserDataMap[key];
+ }
+ return retPtr;
+ }
bool checkReqIdUnique(std::string key)
{
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "same id exist");
}
+ m_sqlReqIdVector.push_back(key);
+
LoggerD("Add OK ReqId : " << key);
DPL::Mutex::ScopedLock lock(&m_mutex);
void* removeSQLUserData(std::string key)
{
+ size_t index = 0;
if (m_callbackSQLUserDataMap.find(key) == m_callbackSQLUserDataMap.end())
{
LoggerD("Fail ReqId : " << key);
// LoggerD(key << " : " << std::hex << data);
m_callbackSQLUserDataMap.erase(key);
+
+ for (index = 0; index < m_sqlReqIdVector.size(); index++)
+ {
+ if (m_sqlReqIdVector[index] == key)
+ {
+ m_sqlReqIdVector.erase(m_sqlReqIdVector.begin() + index);
+ break;
+ }
+ }
+
+
return data;
}
std::map<void*, bool> m_sqlDataControlGCMap;
std::map<void*, bool> m_mappedDataControlGCMap;
std::map<std::string, void*> m_callbackSQLUserDataMap;
+ std::vector<std::string> m_sqlReqIdVector;
};
return NULL;
}
-RowDataPtr DataControlConverter::toRowDataPtr(const JSValueRef& arg)
+RowData* DataControlConverter::toRowDataPtr(const JSValueRef& arg)
{
if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)
|| !JSValueIsObject(m_context, arg))
std::vector<std::string> keysArray = toVectorOfStrings(keysProperty);
std::vector<std::string> valuesArray = toVectorOfStrings(valuesProperty);
- RowDataPtr rowdata(new RowData(keysArray, valuesArray));
+ RowData* rowdata = new RowData(keysArray, valuesArray);
return rowdata;
}
JSValueRef toFunctionOrNull(const JSValueRef& arg);
JSValueRef toFunction(const JSValueRef& arg);
- RowDataPtr toRowDataPtr(const JSValueRef& arg);
+ RowData* toRowDataPtr(const JSValueRef& arg);
JSValueRef toJSRowData(const RowDataPtr & arg);
std::string toString(const JSValueRef& arg);
std::string toString(int arg);
std::string m_dataId;
unsigned int m_reqId;
std::string m_errorMsg;
- RowDataPtr m_rowData;
+ RowData* m_rowData;
long m_insertRowId;
+ unsigned int m_columnSize;
public:
unsigned int getReqId() { return m_reqId; }
- RowDataPtr getRowData() { return m_rowData; }
+ RowData* getRowData() { return m_rowData; }
std::string getErrorMsg() { return m_errorMsg; }
long getInsertRowId() { return m_insertRowId;}
+ unsigned int getColumnSize() { return m_columnSize;}
+
void setReqId(const unsigned int & reqId) { m_reqId = reqId;}
- void setRowData(const RowDataPtr& rowData) { m_rowData = rowData;}
+ void setRowData(RowData* rowData) { m_rowData = rowData;}
void setErrorMsg(const std::string &msg) { m_errorMsg = msg; }
void setRowId(const long &id) { m_insertRowId = id;}
- EventInsert() { LoggerD("entered"); m_insertRowId = -1;}
+ void setColumnSize(unsigned int& columnSize) { m_columnSize = columnSize;}
+ EventInsert() { LoggerD("entered"); m_insertRowId = -1; m_columnSize = 0;}
~EventInsert() { }
};
std::string m_page;
std::string m_numberPerPage;
std::string m_resultSetPath;
- char *m_errorMsg;
+ std::string m_errorMsg;
public:
EventSelect() {
m_page = "";
m_numberPerPage = "";
m_resultSetPath = "";
+ m_errorMsg = "";
- m_errorMsg = NULL;
}
~EventSelect() {
- if (m_errorMsg) {
- delete[] m_errorMsg;
- m_errorMsg = NULL;
- }
}
unsigned int getReqId() { return m_reqId; }
std::string getNumerPerPage() { return m_numberPerPage; }
std::vector<std::string> getColumns() { return m_columns;}
std::string getResultSetPath() { return m_resultSetPath;}
- std::string getErrorMsg() {
- if (m_errorMsg)
- return m_errorMsg;
- else
- return "";
- }
-
+ std::string getErrorMsg() { return m_errorMsg; }
void setReqId(const unsigned int & reqId) { m_reqId = reqId;}
void setWhere(const std::string& where) { m_where = where; }
void setOrder(const std::string& order) { m_order = order; }
void setNumberPerPage(const std::string &number) { m_numberPerPage = number;}
void setColumns(const std::vector<std::string>& columns) { m_columns = columns;}
void setResultSetPath(const std::string& path) { m_resultSetPath = path;}
- void setErrorMsg(const std::string& msg) {
- if (msg.size() > 0) {
- m_errorMsg = new char[msg.size() + 1];
- msg.copy(m_errorMsg, 0, msg.size() - 1);
- m_errorMsg[msg.size()] = NULL;
- }
- }
+ void setErrorMsg(const std::string& msg) { m_errorMsg = msg; }
};
typedef DPL::SharedPtr<EventSelect> EventSelectPtr;
private :
std::string m_where;
unsigned int m_reqId;
- RowDataPtr m_rowData;
+ unsigned int m_columnSize;
+ RowData* m_rowData;
std::string m_errorMsg;
public:
unsigned int getReqId() { return m_reqId;}
+ unsigned int getColumnSize() { return m_columnSize;}
std::string getWhere() { return m_where; }
- RowDataPtr getRowData() { return m_rowData; }
+ RowData* getRowData() { return m_rowData; }
std::string getErrorMsg() { return m_errorMsg;}
void setReqId(const unsigned int & reqId) { m_reqId = reqId;}
- void setRowData(const RowDataPtr& rowData) { m_rowData = rowData;}
+ void setRowData(RowData* rowData) { m_rowData = rowData;}
void setWhere(const std::string& where) { m_where = where; }
void setErrorMsg(const std::string& errorMsg) { m_errorMsg = errorMsg;}
+ void setColumnSize(unsigned int& columnSize) {\rm_columnSize = columnSize; }
EventUpdate() { LoggerD("entered"); }
~EventUpdate() { }
EventInsertPtr event(new EventInsert);
unsigned int reqId = converter.toULong(reserveArguments[0]);
- RowDataPtr rowData = converter.toRowDataPtr(reserveArguments[1]);
+ RowData* rowData = converter.toRowDataPtr(reserveArguments[1]);
+ unsigned int colSize = rowData->m_Data.size();
successCallback = converter.toFunctionOrNull(reserveArguments[2]);
errorCallBack = converter.toFunctionOrNull(reserveArguments[3]);
event->setReqId(reqId);
event->setRowData(rowData);
+ event->setColumnSize(colSize);
event->setForAsynchronousCall(&listener);
dataControlConsumer->insertData(event);
EventUpdatePtr event(new EventUpdate);
unsigned int reqId = converter.toULong(reserveArguments[0]);
- RowDataPtr rowData = converter.toRowDataPtr(reserveArguments[1]);
- std::string where = converter.toString(reserveArguments[2]);
+ RowData* rowData = converter.toRowDataPtr(reserveArguments[1]);
+ unsigned int colSize = rowData->m_Data.size();
+ std::string where = converter.toString(reserveArguments[2]);
successCallback = converter.toFunctionOrNull(reserveArguments[3]);
errorCallBack = converter.toFunctionOrNull(reserveArguments[4]);
event->setReqId(reqId);
event->setWhere(where);
event->setRowData(rowData);
- event->setForAsynchronousCall(&listener);
+ event->setColumnSize(colSize);
+ event->setForAsynchronousCall(&listener);
dataControlConsumer->updateData(event);
DataControlAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, priv->getContext());
}
+
static void MappedDataControlGetValueCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
{
LoggerD("Enter");
{
delete pendingEvent;
}
+
+}
+
+static void MappedDataControlCommonCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+ LoggerD("Enter");
+
+ if (b == NULL)
+ {
+ LoggerD("Bundle null, Error");
+ return;
+ }
+
+
+ const char *reqType = appsvc_get_data(b, OSP_K_DATACONTROL_REQUEST_TYPE);
+
+ if (reqType == NULL)
+ {
+ LoggerD("UnkownRequest");
+ return;
+ }
+
+ std::istringstream buffer(reqType);
+ int reqTypeInt = 0;
+
+ buffer >> reqTypeInt;
+
+
+ LoggerD(reqTypeInt);
+
+
+ switch (reqTypeInt)
+ {
+ case _DATACONTROL_REQUEST_TYPE_MAP_QUERY:
+ MappedDataControlGetValueCallback(b, request_code, res, data);
+ break;
+ case _DATACONTROL_REQUEST_TYPE_MAP_INSERT:
+ MappedDataControlAddValueCallback(b, request_code, res, data);
+ break;
+ case _DATACONTROL_REQUEST_TYPE_MAP_UPDATE:
+ MappedDataControlUpdateValueCallback(b, request_code, res, data);
+ break;
+ case _DATACONTROL_REQUEST_TYPE_MAP_DELETE:
+ MappedDataControlRemoveValueCallback(b, request_code, res, data);
+ break;
+ default:
+ LoggerD("Unknown Request");
+ }
+
}
}
// FIXEME
// reqid sholud be known
EventAddValuePendingEvent* pendingEvent = new EventAddValuePendingEvent((void*)this, event);
- int pid = appsvc_run_service(passData, reqId, MappedDataControlAddValueCallback, (void*)pendingEvent);
+ int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
if (pid < 0)
{
addArrayToBundle(passData, queryItem);
EventRemoveValuePendingEvent* pendingEvent = new EventRemoveValuePendingEvent(this, event);
- int pid = appsvc_run_service(passData, reqId, MappedDataControlRemoveValueCallback, (void*)pendingEvent);
+ int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
if (pid < 0)
{
addArrayToBundle(passData, queryItem);
EventGetValuePendingEvent* pendingEvent = new EventGetValuePendingEvent(this, event);
- int pid = appsvc_run_service(passData, reqId, MappedDataControlGetValueCallback, (void*)pendingEvent);
+ int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
if (pid < 0)
{
addArrayToBundle(passData, queryItem);
EventUpdateValuePendingEvent* pendingEvent = new EventUpdateValuePendingEvent(this, event);
- int pid = appsvc_run_service(passData, reqId, MappedDataControlUpdateValueCallback, (void*)pendingEvent);
+ int pid = appsvc_run_service(passData, reqId, MappedDataControlCommonCallback, (void*)pendingEvent);
if (pid < 0)
{
// To get ppid
#include <unistd.h>
#include <security-server.h>
+#include <sstream>
#include "DataControlAsyncCallbackManager.h"
namespace DeviceAPI {
delete pendingEvent;
}
}
+
+static void sqldataControlCommonCallback(bundle* b, int request_code, appsvc_result_val res, void* data)
+{
+ LoggerD("Enter");
+
+ if (b == NULL)
+ {
+ LoggerD("Bundle null, Error");
+ return;
+ }
+
+ const char *reqType = appsvc_get_data(b, OSP_K_DATACONTROL_REQUEST_TYPE);
+
+ if (reqType == NULL)
+ {
+ LoggerD("UnkownRequest");
+ return;
+ }
+
+ std::istringstream buffer(reqType);
+ int reqTypeInt = 0;
+
+ buffer >> reqTypeInt;
+
+
+ LoggerD(reqTypeInt);
+
+ switch (reqTypeInt)
+ {
+ case _DATACONTROL_REQUEST_TYPE_SQL_QUERY:
+ sqldataControlSelectCallback(b, request_code, res, data);
+ break;
+ case _DATACONTROL_REQUEST_TYPE_SQL_INSERT:
+ sqldataControlInsertCallback(b, request_code, res, data);
+ break;
+ case _DATACONTROL_REQUEST_TYPE_SQL_DELETE:
+ sqldataControlDeleteCallback(b, request_code, res, data);
+ break;
+ case _DATACONTROL_REQUEST_TYPE_SQL_UPDATE:
+ sqldataControlUpdateCallback(b, request_code, res, data);
+ break;
+ default:
+ LoggerD("Unknown Request");
+ }
+}
+
}
SQLDataControlConsumer::SQLDataControlConsumer(std::string& provId, std::string& dataId, std::string& type)
bool SQLDataControlConsumer::checkReqIdUniqueness(unsigned int reqId)
{
- size_t index = 0;
+ std::string reqIdStr;
+ std::stringstream ssReqId;
- for (index = 0; index < m_currentReqIds.size(); index++)
- {
- if (m_currentReqIds[index] == reqId)
- return false;
- }
-
- return true;
+ ssReqId << reqId;
+ reqIdStr = ssReqId.str();
+ return DataControlAsyncCallbackManagerSingleton::Instance().checkReqIdUnique(reqIdStr);
}
return filename;
}
-void SQLDataControlConsumer::saveArrayToFile(std::string filename, RowDataPtr &rowData)
+void SQLDataControlConsumer::saveArrayToFile(std::string filename, RowData *rowData)
{
std::fstream insertUpdateFile;
std::map<std::string, std::string>::iterator it;
void SQLDataControlConsumer::handlePendingEvent(const EventInsertPtr& event)
{
+ LoggerD("OK");
WrtDeviceApis::Commons::EventRequestReceiver<EventInsert>::ManualAnswer(event);
- removeReqId(event->getReqId());
+
+ CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+
+ if (userData)
+ {
+ SendAppControlLaunchToProvider(userData);
+ }
+
}
void SQLDataControlConsumer::handlePendingEvent(const EventDeletePtr& event)
{
WrtDeviceApis::Commons::EventRequestReceiver<EventDelete>::ManualAnswer(event);
- removeReqId(event->getReqId());
+
+ CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+
+ if (userData)
+ {
+ SendAppControlLaunchToProvider(userData);
+ }
+
+
}
void SQLDataControlConsumer::handlePendingEvent(const EventSelectPtr& event)
{
WrtDeviceApis::Commons::EventRequestReceiver<EventSelect>::ManualAnswer(event);
- removeReqId(event->getReqId());
+
+ CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+
+ if (userData)
+ {
+ SendAppControlLaunchToProvider(userData);
+ }
+
}
void SQLDataControlConsumer::handlePendingEvent(const EventUpdatePtr& event)
{
WrtDeviceApis::Commons::EventRequestReceiver<EventUpdate>::ManualAnswer(event);
- removeReqId(event->getReqId());
+
+ CommonPendingEvent* userData = (CommonPendingEvent*)DataControlAsyncCallbackManagerSingleton::Instance().getRemainingSQLOperation();
+
+ if (userData)
+ {
+ SendAppControlLaunchToProvider(userData);
+ }
+
}
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "result dir could be error during checking status");
}
-void SQLDataControlConsumer::OnRequestReceived(const EventInsertPtr& event)
+std::string SQLDataControlConsumer::convertIntToString(unsigned int data)
{
- LoggerD("Enter");
+ std::stringstream ssbuffer;
+
+ ssbuffer.str("");
+ ssbuffer << data;
+ return ssbuffer.str();
+}
+
+void SQLDataControlConsumer::SendAppControlLaunchToProvider(void* event)
+{
+ LoggerD("OK");
bundle* passData = NULL;
+ std::string dataId = getDataId();
+ std::vector<std::string> queryItem;
+ std::stringstream ssBuffer;
+ std::string stringBuffer;
+ CommonPendingEvent* pEvent = (CommonPendingEvent*)(event);
+ std::string ipcFilename;
+ std::string where;
+ unsigned int reqId = 0;
+ unsigned int columnSize = 0;
try
{
- std::string dataId = getDataId();
- RowDataPtr rowData = event->getRowData();
- unsigned int reqId = event->getReqId();
- std::stringstream ss, ssreqtype;
- std::string reqIdStr, reqtypestr;
- std::vector<std::string> queryItem;
- // column count
- int columnSize = rowData->m_Data.size();
- std::stringstream counts;
- std::string countStr;
- std::string ipcFilename = generateFileName(reqId);
-
- if (checkReqIdUniqueness(reqId) == false)
- {
- ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
- }
+ passData = bundle_create();
- if (columnSize == 0)
+ if (passData == NULL)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No insertion data");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
}
-
- counts << columnSize;
- countStr = counts.str();
-
- // conversion
- ss << reqId;
- reqIdStr = ss.str();
- ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_INSERT;
- reqtypestr = ssreqtype.str();
-
- passData = bundle_create();
-
- if (passData == NULL)
+ if (pEvent == NULL)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "event null");
}
appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
appsvc_set_appid(passData, m_appId.c_str());
- bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
- bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
bundle_add(passData, AUL_K_CALLER_APPID, m_currentAppId.c_str());
- queryItem.push_back(dataId); // dataid
- queryItem.push_back(countStr); // count
- queryItem.push_back(ipcFilename); // filepath
+ if (dynamic_cast<EventInsertPendingEvent*>(pEvent) != NULL)
+ {
+ EventInsertPendingEvent* pendingInsertEvent = (EventInsertPendingEvent*)pEvent;
+ EventInsertPtr insertEvent = pendingInsertEvent->getEvent();
+
+ reqId = insertEvent->getReqId();
+ columnSize = insertEvent->getColumnSize();
- addArrayToBundle(passData, queryItem);
- saveArrayToFile(ipcFilename, rowData);
+ stringBuffer = convertIntToString(reqId);
+ bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());
- EventInsertPendingEvent* pendingEvent = new EventInsertPendingEvent((void*)this, event);
- int pid = appsvc_run_service(passData, reqId, sqldataControlInsertCallback, (void*)NULL);
+ ipcFilename = generateFileName(reqId);
+ stringBuffer = convertIntToString(columnSize);
+
+ queryItem.push_back(dataId);
+ queryItem.push_back(stringBuffer);
+ queryItem.push_back(ipcFilename);
- if (pid < 0)
- {
- ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Error");
+ stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_INSERT);
+ bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
+
+ addArrayToBundle(passData, queryItem);
}
-
- event->switchToManualAnswer();
+ else if (dynamic_cast<EventUpdatePendingEvent*>(pEvent) != NULL)
+ {
+ EventUpdatePendingEvent* pendingUpdateEvent = (EventUpdatePendingEvent*)pEvent;
+ EventUpdatePtr updateEvent = pendingUpdateEvent->getEvent();
+
+ reqId = updateEvent->getReqId();
+ columnSize = updateEvent->getColumnSize();
+ where = updateEvent->getWhere();
+
+ stringBuffer = convertIntToString(reqId);
+ bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());
- DPL::Mutex::ScopedLock lock(&m_mutex);
- m_currentReqIds.push_back(reqId);
- DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
+ stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_UPDATE);
+ bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
- }
- catch (const WrtDeviceApis::Commons::Exception& ex)
- {
- event->setExceptionCode(ex.getCode());
- event->setErrorMsg(ex.GetMessage());
- LoggerE("Exception: " << ex.GetMessage());
-
-
- }
+ ipcFilename = generateFileName(reqId);
+ stringBuffer = convertIntToString(columnSize);
- if (passData)
- {
- bundle_free(passData);
- passData = NULL;
- }
-
-}
+ queryItem.push_back(dataId);
+ queryItem.push_back(stringBuffer);
+ queryItem.push_back(ipcFilename);
-void SQLDataControlConsumer::OnRequestReceived(const EventDeletePtr& event)
-{
- LoggerD("Enter");
- bundle* passData = NULL;
-
- try
- {
- std::string dataId = getDataId();
- std::string where = event->getWhere();
- std::vector<std::string> queryItem;
+ if (where.size() == 0) // where
+ {
+ queryItem.push_back("NULL");
+ }
+ else
+ {
+ queryItem.push_back(where);
+ }
- unsigned int reqId = event->getReqId();
- std::stringstream ss, ssreqtype;
- std::string reqIdStr, reqtypestr;
-
- ss << reqId;
- reqIdStr = ss.str();
+ addArrayToBundle(passData, queryItem);
- if (checkReqIdUniqueness(reqId) == false)
- {
- ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
}
-
+ else if (dynamic_cast<EventSelectPendingEvent*>(pEvent) != NULL)
+ {
+ EventSelectPendingEvent* pendingSelectEvent = (EventSelectPendingEvent*)pEvent;
+ EventSelectPtr selectEvent = pendingSelectEvent->getEvent();
+
+ reqId = selectEvent->getReqId();
+ std::vector<std::string> columns = selectEvent->getColumns();
+ columnSize = columns.size();
+ where = selectEvent->getWhere();
+ std::string order = selectEvent->getOrder();
+ std::string page = selectEvent->getPage();
+ std::string numberPerPage = selectEvent->getNumerPerPage();
- ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_DELETE;
- reqtypestr = ssreqtype.str();
+ stringBuffer = convertIntToString(reqId);
+ bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());
- passData = bundle_create();
+ stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_QUERY);
+ bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
-
- if (passData == NULL)
- {
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
- }
+ queryItem.push_back(dataId);
- appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
- appsvc_set_appid(passData, m_appId.c_str());
+ if (columnSize == 0)
+ {
+ queryItem.push_back("NULL");
+ }
+ else
+ {
+ stringBuffer = convertIntToString(columnSize);
+ queryItem.push_back(stringBuffer);
- bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
- bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
- bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
- bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
- bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
- bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
- bundle_add(passData, AUL_K_CALLER_APPID, m_currentAppId.c_str());
+ for (int index = 0; index < columnSize; index++)
+ {
+ queryItem.push_back(columns[index]);
+ }
+ }
-
+ if (where.size() == 0)
+ {
+ queryItem.push_back("NULL");
+ }
+ else
+ {
+ queryItem.push_back(where);
+ }
+
+ if (order.size() == 0)
+ {
+ queryItem.push_back("NULL");
+ }
+ else
+ {
+ queryItem.push_back(order);
+ }
+
+ if (page.size() == 0) // page
+ {
+ queryItem.push_back("1");
+ }
+ else
+ {
+ queryItem.push_back(page);
+ }
- queryItem.push_back(dataId); // dataid
+ if (numberPerPage.size() == 0) // numberOfPage
+ {
+ queryItem.push_back("20");
+ }
+ else
+ {
+ queryItem.push_back(numberPerPage);
+ }
- if (where.size() == 0) // where
+ addArrayToBundle(passData, queryItem);
+ }
+ else if (dynamic_cast<EventDeletePendingEvent*>(pEvent) != NULL)
{
- queryItem.push_back("NULL");
+ EventDeletePendingEvent* pendingDeleteEvent = (EventDeletePendingEvent*)pEvent;
+ EventDeletePtr deleteEvent = pendingDeleteEvent->getEvent();
+ reqId = deleteEvent->getReqId();
+ stringBuffer = convertIntToString(reqId);
+ bundle_add(passData, OSP_K_REQUEST_ID, stringBuffer.c_str());
+
+ stringBuffer = convertIntToString(_DATACONTROL_REQUEST_TYPE_SQL_DELETE);
+ bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, stringBuffer.c_str());
+
+ queryItem.push_back(dataId); // dataid
+ where = deleteEvent->getWhere();
+
+ if (where.size() == 0) // where
+ {
+ queryItem.push_back("NULL");
+ }
+ else
+ {
+ queryItem.push_back(where);
+ }
+
+ addArrayToBundle(passData, queryItem);
}
else
{
- queryItem.push_back(where);
+ // never happen
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "no type request type");
}
- addArrayToBundle(passData, queryItem);
- EventDeletePendingEvent* pendingEvent = new EventDeletePendingEvent(this, event);
-
- int pid = appsvc_run_service(passData, reqId, sqldataControlDeleteCallback, (void*)NULL);
+ int pid = appsvc_run_service(passData, reqId, sqldataControlCommonCallback, (void*)NULL);
if (pid < 0)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
+ ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Launch Error");
}
- event->switchToManualAnswer();
-
- DPL::Mutex::ScopedLock lock(&m_mutex);
- m_currentReqIds.push_back(reqId);
- DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
- }
-
+ LoggerD("Launch OK : pid(" << pid << "), reqid : (" << reqId << ")");
+ }
catch (const WrtDeviceApis::Commons::Exception& ex)
- {
+ {
LoggerE("Exception: " << ex.GetMessage());
- event->setExceptionCode(ex.getCode());
- event->setErrorMsg(ex.GetMessage());
- }
+ if (passData)
+ {
+ bundle_free(passData);
+ passData = NULL;
+ }
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, ex.GetMessage());
- if (passData)
- {
- bundle_free(passData);
- passData = NULL;
}
-
+
}
-
-
-void SQLDataControlConsumer::OnRequestReceived(const EventSelectPtr& event)
+void SQLDataControlConsumer::OnRequestReceived(const EventInsertPtr& event)
{
LoggerD("Enter");
- bundle* passData = NULL;
-
+
try
{
- std::string dataId = getDataId();
- std::string where = event->getWhere();
- std::vector<std::string> columns = event->getColumns();
- std::vector<std::string> queryItem;
- std::string order = event->getOrder();
- std::string page = event->getPage();
- std::string numberPerPage = event->getNumerPerPage();
-
+ RowData* rowData = event->getRowData();
unsigned int reqId = event->getReqId();
- int columnSize = columns.size();
- std::stringstream ss, ssreqtype;
- std::string reqIdStr, reqtypestr;
-
+ std::string ipcFilename = generateFileName(reqId);
+ std::string reqIdStr = convertIntToString(reqId);
+
if (checkReqIdUniqueness(reqId) == false)
{
ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
}
-
-
- ss << reqId;
- reqIdStr = ss.str();
-
- ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_QUERY;
- reqtypestr = ssreqtype.str();
-
- passData = bundle_create();
-
- if (passData == NULL)
- {
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
- }
-
- appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
- appsvc_set_appid(passData, m_appId.c_str());
-
- bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
- bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
- bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
- bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
- bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
- bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE); // version
- bundle_add(passData, AUL_K_CALLER_APPID, m_currentAppId.c_str());
-
-
- queryItem.push_back(dataId); // dataid
-
- if (columnSize == 0)
- {
- queryItem.push_back("NULL"); // column
- }
- else
- {
- // column count
- std::stringstream counts;
- std::string countStr;
-
- counts << columnSize;
- countStr = counts.str();
- queryItem.push_back(countStr);
-
- // column
- for (int index = 0; index < columnSize; index++)
- {
- queryItem.push_back(columns[index]);
- }
- }
-
- if (where.size() == 0) // where
- {
- queryItem.push_back("NULL");
- }
- else
- {
- queryItem.push_back(where);
- }
-
- if (order.size() == 0) // order
+
+ if (rowData == NULL || rowData->m_Data.size() == 0)
{
- queryItem.push_back("NULL");
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No insertion data");
}
- else
+
+ saveArrayToFile(ipcFilename, rowData);
+ delete rowData;
+
+ EventInsertPendingEvent* pendingEvent = new EventInsertPendingEvent((void*)this, event);
+ event->switchToManualAnswer();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
{
- queryItem.push_back(order);
+ SendAppControlLaunchToProvider(pendingEvent);
}
- if (page.size() == 0) // page
- {
- queryItem.push_back("1");
- }
- else
- {
- queryItem.push_back(page);
- }
+ DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
- if (numberPerPage.size() == 0) // numberOfPage
- {
- queryItem.push_back("20");
- }
- else
- {
- queryItem.push_back(numberPerPage);
- }
- addArrayToBundle(passData, queryItem);
- EventSelectPendingEvent* pendingEvent = new EventSelectPendingEvent(this, event);
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ event->setExceptionCode(ex.getCode());
+ event->setErrorMsg(ex.GetMessage());
+ LoggerE("Exception: " << ex.GetMessage());
+
- int pid = appsvc_run_service(passData, reqId, sqldataControlSelectCallback, (void*)NULL);
+ }
+}
+void SQLDataControlConsumer::OnRequestReceived(const EventDeletePtr& event)
+{
+ LoggerD("Enter");
+ bundle* passData = NULL;
+
+ try
+ {
+ unsigned int reqId = event->getReqId();
+ std::string reqIdStr = convertIntToString(reqId);
- if (pid < 0)
+ if (checkReqIdUniqueness(reqId) == false)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
+ ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
}
+ EventDeletePendingEvent* pendingEvent = new EventDeletePendingEvent(this, event);
event->switchToManualAnswer();
- DPL::Mutex::ScopedLock lock(&m_mutex);
- m_currentReqIds.push_back(reqId);
+ if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
+ {
+ SendAppControlLaunchToProvider(pendingEvent);
+ }
DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
}
+
catch (const WrtDeviceApis::Commons::Exception& ex)
{
LoggerE("Exception: " << ex.GetMessage());
bundle_free(passData);
passData = NULL;
}
-
-}
-void SQLDataControlConsumer::OnRequestReceived(const EventUpdatePtr& event)
+}
+void SQLDataControlConsumer::OnRequestReceived(const EventSelectPtr& event)
{
- LoggerD("Enter");
- bundle* passData = NULL;
-
try
{
- std::string dataId = getDataId();
- std::string where = event->getWhere();
- RowDataPtr rowData = event->getRowData();
- std::vector<std::string> queryItem;
-
unsigned int reqId = event->getReqId();
- int columnSize = rowData->m_Data.size();
- std::stringstream ss, ssreqtype;
- std::string reqIdStr, reqtypestr;
- std::string ipcFilename = generateFileName(reqId);
-
+ std::string reqIdStr = convertIntToString(reqId);
if (checkReqIdUniqueness(reqId) == false)
{
ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
}
+
+ EventSelectPendingEvent* pendingEvent = new EventSelectPendingEvent(this, event);
+ event->switchToManualAnswer();
- passData = bundle_create();
-
- if (passData == NULL)
+ if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "ipc memory allocation fail");
+ SendAppControlLaunchToProvider(pendingEvent);
}
- appsvc_set_operation(passData, APPSVC_OPERATION_DEFAULT);
- appsvc_set_appid(passData, m_appId.c_str());
-
- ss << reqId;
- reqIdStr = ss.str();
+ DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
+ }
+ catch (const WrtDeviceApis::Commons::Exception& ex)
+ {
+ LoggerE("Exception: " << ex.GetMessage());
+ event->setExceptionCode(ex.getCode());
+ event->setErrorMsg(ex.GetMessage());
+ }
- ssreqtype << _DATACONTROL_REQUEST_TYPE_SQL_UPDATE;
- reqtypestr = ssreqtype.str();
-
+}
- bundle_add(passData, OSP_K_REQUEST_ID, reqIdStr.c_str());
- bundle_add(passData, OSP_K_CALLER_TYPE, OSP_V_CALLER_TYPE_OSP);
- bundle_add(passData, OSP_K_LAUNCH_TYPE, OSP_V_LAUNCH_TYPE_DATACONTROL);
- bundle_add(passData, OSP_K_DATACONTROL_REQUEST_TYPE, reqtypestr.c_str());
- bundle_add(passData, OSP_K_DATACONTROL_PROVIDER, m_providerId.c_str());
- bundle_add(passData, OSP_K_DATACONTROL_PROTOCOL_VERSION, OSP_K_DATACONTROL_PROTOCOL_VERSION_VALUE);
- bundle_add(passData, AUL_K_CALLER_APPID, m_currentAppId.c_str());
+void SQLDataControlConsumer::OnRequestReceived(const EventUpdatePtr& event)
+{
+ LoggerD("Enter");
- queryItem.push_back(dataId); // dataid
+ try
+ {
+ unsigned int reqId = event->getReqId();
+ RowData* rowData = event->getRowData();
+ std::string ipcFilename = generateFileName(reqId);
+ std::stringstream ssReqId;
+ ssReqId << reqId;
- if (columnSize == 0)
+ if (checkReqIdUniqueness(reqId) == false)
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "should not be update data as 0");
+ ThrowMsg(WrtDeviceApis::Commons::AlreadyInUseException, "Duplicated requested id");
}
- else
- {
- // column count
- std::stringstream counts;
- std::string countStr;
-
- counts << columnSize;
- countStr = counts.str();
- queryItem.push_back(countStr); // count
- queryItem.push_back(ipcFilename); // filepath
-
- saveArrayToFile(ipcFilename, rowData);
+
+ if (rowData == NULL || rowData->m_Data.size() == 0)
+ {\r
+ ThrowMsg(WrtDeviceApis::Commons::PlatformException, "No update data");
}
- if (where.size() == 0) // where
- {
- queryItem.push_back("NULL");
- }
- else
- {
- queryItem.push_back(where);
- }
+ saveArrayToFile(ipcFilename, rowData);
+ delete rowData;
- addArrayToBundle(passData, queryItem);
EventUpdatePendingEvent* pendingEvent = new EventUpdatePendingEvent(this, event);
-
- int pid = appsvc_run_service(passData, reqId, sqldataControlUpdateCallback, (void*)NULL);
-
- if (pid < 0)
+ event->switchToManualAnswer();
+
+ if (DataControlAsyncCallbackManagerSingleton::Instance().checkDoSQLOperation())
{
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "dataconstrol request fail.(can not launch)");
+ SendAppControlLaunchToProvider(pendingEvent);
}
- event->switchToManualAnswer();
+ DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(ssReqId.str(), (void*)pendingEvent);
- DPL::Mutex::ScopedLock lock(&m_mutex);
- m_currentReqIds.push_back(reqId);
- DataControlAsyncCallbackManagerSingleton::Instance().addSQLUserData(reqIdStr, (void*)pendingEvent);
-
- }
+ }
catch (const WrtDeviceApis::Commons::Exception& ex)
{
LoggerE("Exception: " << ex.GetMessage());
event->setErrorMsg(ex.GetMessage());
}
- if (passData)
- {
- bundle_free(passData);
- passData = NULL;
- }
-
}
}
}
std::string getType();
std::string getDataId();
std::string getProviderId();
-
+
+ void SendAppControlLaunchToProvider(void* event);
void handlePendingEvent(const EventInsertPtr& event);
void handlePendingEvent(const EventDeletePtr& event);
void handlePendingEvent(const EventSelectPtr& event);
std::string getApplicationId(const std::string& provId);
std::string getProviderPkgId(const std::string& appId);
-
std::string getCurrentApplicationId();
void addArrayToBundle(bundle* passData, std::vector<std::string>& array);
+ std::string convertIntToString(unsigned int data);
+
static std::vector<unsigned int> m_currentReqIds;
bool checkReqIdUniqueness(unsigned int reqId);
+
void removeReqId(unsigned int reqId);
std::string generateFileName(unsigned int reqId);
- void saveArrayToFile(std::string filename, RowDataPtr &rowData);
+ void saveArrayToFile(std::string filename, RowData* rowData);
void createResultDir();
-
static DPL::Mutex m_mutex;
protected:
SQLDataControlConsumer(std::string& provId, std::string& dataId, std::string& type);
ThrowMsg(Commons::NotFoundException,
"Not a valid path: " + str + ".");
}
-
- std::string tmp = Commons::String::unique(Commons::String::trim(
+ std::string tmp = Commons::String::unique(/*Commons::String::trim*/(
str), m_pathSeparator);
std::string::size_type pos = tmp.find_last_of(m_pathSeparator);
if (pos == std::string::npos) {
from.setRecipients(EmailUtils::stripAddress(m_mail->full_address_from));
setSourceAddress(from);
setSourceAddressValidity(true); //not needed to update in platform
+ setFrom(EmailUtils::stripAddress(m_mail->full_address_from));
+ setFromValidity(true);
}
LOG_EXIT
do{
if(m_mode == MODE_EMAIL){
if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_FROM)==0){
- retClause = emfAttributeName + " LIKE '%%<" + valueString +">'";
+ retClause = emfAttributeName + " LIKE '%%<" + valueString +">%%'";
break;
}else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)==0){
retClause = emfAttributeName + "=" + createDateTimeTypeForEmail(value);
#include <Logger.h>
#include <sstream>
#include <appsvc/appsvc.h>
+#include <sstream>
+#include <boost/algorithm/string.hpp>
#include "StatusNotification.h"
namespace DeviceAPI {
return true;
}
-#if 0
-static bool service_extra_data_delete_cb(service_h service, const char *key, void *user_data)
-{
- LoggerI("OK");
- if (key != NULL)
- {
- LoggerI("del key = " << key);
-
- if (service_remove_extra_data(service, key) != SERVICE_ERROR_NONE)
- {
- LoggerW("remove extra data failed");
- return false;
- }
- }
- return true;
-}
-#endif
-
StatusNotification::StatusNotification(NotificationType statusType) :
m_notiType(NOTI_TYPE_NONE),
m_service(NULL),
}
}
-
std::string StatusNotification::getContent()
{
LoggerI("get Content handle: " << m_notiHandle);
return m_service;
}
-
std::string StatusNotification::getLight()
{
LoggerI("get Light handle: " << m_notiHandle);
{
throw UnknownException("get notification Content error");
}
-
- //ledColor = ledColor | 0xff000000;
+ std::string light;
std::stringstream stream;
if (NOTIFICATION_LED_OP_OFF != type)
{
stream << std::hex << ledColor;
+ light = "#" + stream.str();
}
- return stream.str();
+ return boost::to_lower_copy(light);
}
else
{
}
}
+bool StatusNotification::isColorFormatNumberic(std::string& color)
+{
+ //first check length
+ std::string hexCode = "0123456789abcdef";
+ if (color.length() == 7 && !color.compare(0, 1, "#") )
+ {
+ for ( int i = 1 ; i < color.length() ; i++)
+ {
+ if (std::string::npos == hexCode.find(color[i]))
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
void StatusNotification::setLight(std::string color)
{
LoggerI("set Light handle: " << m_notiHandle);
LoggerI("led Color : " << color);
if (m_notiHandle)
- {
+ {
+ color = boost::to_lower_copy(color); //convert lowercase.
+ if ( isColorFormatNumberic(color))
+ {
+ std::stringstream stream;
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ std::string colorCode = color.substr(1, color.length());
- std::stringstream stream;
- int ledColor = 0;
- notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ stream << std::hex << colorCode;
+ LoggerI("LedColor = " << stream.str());
+ stream >> ledColor;
+ LoggerI("LedColor = " << ledColor);
+
+ if (ledColor != 0)
+ type = NOTIFICATION_LED_OP_ON_CUSTOM_COLOR;
+ else
+ type = NOTIFICATION_LED_OP_OFF;
- stream << std::hex << color;
- LoggerI("LedColor = " << stream.str());
- stream >> ledColor;
- LoggerI("LedColor = " << ledColor);
-
- if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_ON_CUSTOM_COLOR, ledColor) != NOTIFICATION_ERROR_NONE)
+ if (notification_set_led(m_notiHandle, type, ledColor) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+
+ }
+ else
{
- throw UnknownException("set notification led ");
+ LoggerI("color.length()=" << color.length());
+ if (color.length() == 0)
+ {
+ if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, NULL) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ }
+ else
+ {
+ throw InvalidValuesException("color code error!");
+ }
}
}
else
}
}
-
-#if 0
-
-StatusNotification::StatusNotification():
- m_statusType(""),
- m_iconPath(""),
- m_subIconPath(""),
- m_number(0),
- m_backgroundImagePath(""),
- m_soundPath(""),
- m_vibration(false),
- m_progressType(""),
- m_progressValue(0)
-{
-}
-
-StatusNotification::~StatusNotification()
-{
-}
-
-std::string StatusNotification::getStatusType() const
-{
- return m_statusType;
-}
-
-void StatusNotification::setStatusType(std::string statusType)
-{
- m_statusType = statusType;
-}
-
-std::string StatusNotification::getIconPath() const
-{
- return m_iconPath;
-}
-
-void StatusNotification::setIconPath(std::string iconPath)
-{
- m_iconPath = iconPath;
-}
-
-std::string StatusNotification::getSubIconPath() const
-{
- return m_subIconPath;
-}
-
-void StatusNotification::setSubIconPath(std::string subIconPath)
-{
- m_subIconPath = subIconPath;
-}
-
-long StatusNotification::getNumber() const
-{
- return m_number;
-}
-
-void StatusNotification::setNumber(long number)
-{
- m_number = number;
-}
-
-std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfo() const
-{
- return m_detailInfo;
-}
-
-void StatusNotification::setDetailInfo(std::vector<NotificationDetailInfo*> detailInfo)
-{
- m_detailInfo = detailInfo;
-}
-
-std::string StatusNotification::getBackgroundImagePath() const
-{
- return m_backgroundImagePath;
-}
-
-void StatusNotification::setBackgroundImagePath(std::string backgroundImagePath)
-{
- m_backgroundImagePath = backgroundImagePath;
-}
-
-std::vector<std::string> StatusNotification::getThumbnails() const
-{
- return m_thumbnails;
-}
-
-void StatusNotification::setThumbnails(std::vector<std::string> thumbnails)
-{
- m_thumbnails = thumbnails;
-}
-
-std::string StatusNotification::getSoundPath() const
-{
- return m_soundPath;
-}
-
-void StatusNotification::setSoundPath(std::string soundPath)
-{
- m_soundPath = soundPath;
-}
-
-bool StatusNotification::getVibration() const
-{
- return m_vibration;
-}
-
-void StatusNotification::setVibration(bool vibration)
-{
- m_vibration = vibration;
-}
-
-ApplicationControl StatusNotification::getAppControl() const
-{
- return m_appControl;
-}
-
-void StatusNotification::setAppControl(ApplicationControl appControl)
-{
- m_appControl = appControl;
-}
-
-ApplicationId StatusNotification::getAppId() const
-{
- return m_appId;
-}
-
-void StatusNotification::setAppId(ApplicationId appId)
-{
- m_appId = appId;
-}
-
-std::string StatusNotification::getProgressType() const
-{
- return m_progressType;
-}
-
-void StatusNotification::setProgressType(std::string progressType)
-{
- m_progressType = progressType;
-}
-
-unsigned long StatusNotification::getProgressValue() const
-{
- return m_progressValue;
-}
-
-void StatusNotification::setProgressValue(unsigned long progressValue)
-{
- m_progressValue = progressValue;
-}
-#endif
-
} // Notification
} // DeviceAPI
~StatusNotification();
-#if 0
- NotificationProgressType getProgressType()
- {
- return m_progressType;
- }
- void setProgressType( NotificationProgressType type)
- {
- m_progressType = type;
- }
-#endif
-
std::string getEnumProgressType();
-
void setUpdatedFlag(bool value)
{
if (value)
std::string getSubIconPath() ;
void setSubIconPath(const std::string& subIconPath) ;
-#if 0
- std::vector<std::string> getInformations() ;
- std::string getInformation(int index) ;
- void setInformations(std::vector<std::string>& infos) ;
- void setInformation( const std::string& info, int index) ;
-
- std::vector<std::string> getSubInformations() ;
- std::string getSubInformation(int index) ;
- void setSubInformations(std::vector<std::string>& infos) ;
- void setSubInformation( const std::string& info, int index) ;
-#endif
-
std::vector<std::string> getThumbnails();
void setThumbnails(std::vector<std::string> thumbs);
void setSubInformation( const std::string& info, int index) ;
void loadDetailInfos();
+
+ bool isColorFormatNumberic(std::string& color);
protected:
std::vector<std::string> m_thumbs; //thumbnail images path
std::vector<NotificationDetailInfo*> m_detailInfos; // detail Info
-
};
} // Notification
#define STATUS_NOTIFICATION_APP_CONTROL "appControl"
#define STATUS_NOTIFICATION_APP_ID "appId"
#define STATUS_NOTIFICATION_LIGHT "ledColor"
-#define STATUS_NOTIFICATION_LIGHT_ONTIME "ledOnTime"
-#define STATUS_NOTIFICATION_LIGHT_OFFTIME "ledOffTime"
+#define STATUS_NOTIFICATION_LIGHT_ONTIME "ledOnPeriod"
+#define STATUS_NOTIFICATION_LIGHT_OFFTIME "ledOffPeriod"
#define STATUS_NOTIFICATION_PROGRESS_TYPE "progressType"
#define STATUS_NOTIFICATION_PROGRESS_VALUE "progressValue"
#define NOTIFICATION_DETAIL_INFO_MAIN_TEXT "mainText"
// limitations under the License.
//
-#include <dpl/assert.h>
#include <Commons/Exception.h>
#include <CommonsJavaScript/PrivateObject.h>
#include <CommonsJavaScript/Validator.h>
#include <Logger.h>
#define MAXBUFSIZE 256
-#define DEVICE_PROFILE "MOBILE"
+#define DEVICE_PROFILE "MOBILE_FULL"
namespace DeviceAPI {
namespace Systeminfo {
if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_BLUETOOTH)) {
bool bluetooth = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_BLUETOOTH_SUPPORTED, &bluetooth) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("bluetooth : " << bluetooth);
+ if(system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->bluetooth = bluetooth;
+ } else {
+ LoggerE("get fail bluetooth value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->bluetooth);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NFC)) {
bool nfc = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_NFC_SUPPORTED, &nfc) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("nfc : " << nfc);
+ if(system_info_get_platform_bool("tizen.org/feature/network.nfc", &nfc) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->nfc = nfc;
+ } else {
+ LoggerE("get fail nfc value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->nfc);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NFC_RESERVED_PUSH)) {
bool nfcReservedPush = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_NFC_RESERVED_PUSH_SUPPORTED, &nfcReservedPush) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("nfcReservedPush : " << nfcReservedPush);
+ if(system_info_get_platform_bool("tizen.org/feature/network.nfc.reserved_push", &nfcReservedPush) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->nfcReservedPush = nfcReservedPush;
+ } else {
+ LoggerE("get fail nfc reserved push value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->nfcReservedPush);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MULTITOUCHCOUNT)) {
int multiTouchCount = 0;
- if (system_info_get_value_int(SYSTEM_INFO_KEY_MULTI_POINT_TOUCH_COUNT, &multiTouchCount) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("multiTouchCount : " << multiTouchCount);
+ if(system_info_get_platform_int("tizen.org/feature/multi_point_touch.point_count", &multiTouchCount) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->multiTouchCount = multiTouchCount;
+ } else {
+ LoggerE("get fail multiTouchCount value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->multiTouchCount);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_INPUTKEYBOARD)) {
- char* inputKeyboard = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &inputKeyboard) == SYSTEM_INFO_ERROR_NONE) {
- if (inputKeyboard != NULL) {
- LoggerD("inputKeyboard : " << inputKeyboard);
- if (strcmp(inputKeyboard, "NULL") == 0) {
- deviceCapabilitiesInfo->inputKeyboard = false;
- } else {
- deviceCapabilitiesInfo->inputKeyboard = true;
- }
- free(inputKeyboard);
- }
+ bool inputKeyboard = false;
+ if(system_info_get_platform_bool("tizen.org/feature/input.keyboard", &inputKeyboard) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->inputKeyboard = inputKeyboard;
+ } else {
+ LoggerE("get fail inputKeyboard value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyboard);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_INPUTKEYBOARD_LAYOUT)) {
- char* inputKeyboard = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_KEYBOARD_TYPE, &inputKeyboard) == SYSTEM_INFO_ERROR_NONE) {
- if (inputKeyboard != NULL) {
- LoggerD("inputKeyboard : " << inputKeyboard);
- if (strcmp(inputKeyboard, "NULL") == 0) {
- deviceCapabilitiesInfo->inputKeyboard = false;
- } else {
- deviceCapabilitiesInfo->inputKeyboard = true;
- }
- free(inputKeyboard);
+ char* inputKeyboardLayout = NULL;
+ if(system_info_get_platform_string("tizen.org/feature/input.keyboard.layout", &inputKeyboardLayout) == SYSTEM_INFO_ERROR_NONE) {
+ if (inputKeyboardLayout) {
+ deviceCapabilitiesInfo->inputKeyboardLayout = true;
+ free(inputKeyboardLayout);
+ } else {
+ deviceCapabilitiesInfo->inputKeyboardLayout = false;
}
+ } else {
+ LoggerE("get fail inputKeyboardLayout value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyboardLayout);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WIFI)) {
bool wifi = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_SUPPORTED, &wifi) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("wifi : " << wifi);
+ if(system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->wifi = wifi;
+ } else {
+ LoggerE("get fail wifi value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->wifi);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WIFIDIRECT)) {
bool wifiDirect = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_WIFI_DIRECT_SUPPORTED, &wifiDirect) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("wifiDirect : " << wifiDirect);
+ if(system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifiDirect) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->wifiDirect = wifiDirect;
+ } else {
+ LoggerE("get fail wifiDirect value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->wifiDirect);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLES)) {
- char* openglesVersion = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &openglesVersion) == SYSTEM_INFO_ERROR_NONE) {
- if (openglesVersion!= NULL) {
- LoggerD("openglesVersion : " << openglesVersion);
- deviceCapabilitiesInfo->opengles = true;
- free(openglesVersion);
- }
+ bool opengles = NULL;
+ if(system_info_get_platform_bool("tizen.org/feature/opengles", &opengles) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->opengles = opengles;
+ } else {
+ LoggerE("get fail opengles value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->opengles);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLES_TEXTURE_FORMAT)) {
+ bool texture = false;
+ bool data = false;
char* textureFormat = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_TEXTURE_FORMAT, &textureFormat) == SYSTEM_INFO_ERROR_NONE) {
- if (textureFormat!= NULL) {
- LoggerD("textureFormat : " << textureFormat);
- deviceCapabilitiesInfo->openglestextureFormat = textureFormat;
- free(textureFormat);
+ char textureFormatFull[MAXBUFSIZE];
+ textureFormatFull[0] = '\0';
+
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.utc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ strcat(textureFormatFull, "utc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.ptc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
}
- }
+ strcat(textureFormatFull, "ptc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.etc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "etc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.3dc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "3dc");
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.atc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "atc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.pvrtc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "pvrtc");
+ }
+
+ textureFormat = strdup(textureFormatFull);
+
+ if (textureFormat == NULL) {
+ LoggerE("get fail openglestextureFormat value");
+ return JSValueMakeUndefined(context);
+ }
+
+ deviceCapabilitiesInfo->openglestextureFormat = textureFormat;
+ free(textureFormat);
+
return convert.toJSValueRef(deviceCapabilitiesInfo->openglestextureFormat);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLESVERSION1_1)) {
- char* openglesVersion = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &openglesVersion) == SYSTEM_INFO_ERROR_NONE) {
- if (openglesVersion!= NULL) {
- LoggerD("openglesVersion : " << openglesVersion);
- if (strcmp(openglesVersion, "1.1") == 0) {
- deviceCapabilitiesInfo->openglesVersion1_1 = true;
- } else if (strcmp(openglesVersion, "1.1/2.0") == 0) {
- deviceCapabilitiesInfo->openglesVersion1_1 = true;
- }
- free(openglesVersion);
- }
+ bool openglesVersion1_1 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/opengles.version.1_1", &openglesVersion1_1) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->openglesVersion1_1 = openglesVersion1_1;
+ } else {
+ LoggerE("get fail openglesVersion1_1 value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->openglesVersion1_1);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLESVERSION2_0)) {
- char* openglesVersion = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_OPENGLES_VERSION, &openglesVersion) == SYSTEM_INFO_ERROR_NONE) {
- if (openglesVersion!= NULL) {
- LoggerD("openglesVersion : " << openglesVersion);
- if (strcmp(openglesVersion, "2.0") == 0) {
- deviceCapabilitiesInfo->openglesVersion2_0 = true;
- } else if (strcmp(openglesVersion, "1.1/2.0") == 0) {
- deviceCapabilitiesInfo->openglesVersion2_0 = true;
- }
- free(openglesVersion);
- }
- }
+ bool openglesVersion2_0 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/opengles.version.2_0", &openglesVersion2_0) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->openglesVersion2_0 = openglesVersion2_0;
+ } else {
+ LoggerE("get fail openglesVersion2_0 value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->openglesVersion2_0);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_FMRADIO)) {
bool fmRadio = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_FMRADIO_SUPPORTED, &fmRadio) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("fmRadio : " << fmRadio);
+ if(system_info_get_platform_bool("tizen.org/feature/fmradio", &fmRadio) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->fmRadio = fmRadio;
+ } else {
+ LoggerE("get fail fmRadio value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->fmRadio);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMVERSION)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
char* platformVersion = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_TIZEN_VERSION, &platformVersion) == SYSTEM_INFO_ERROR_NONE) {
- if (platformVersion) {
- LoggerD("platformVersion : " << platformVersion);
- deviceCapabilitiesInfo->platformVersion = platformVersion;
- free(platformVersion);
- }
- }
+ if(system_info_get_platform_string("tizen.org/feature/platform.version", &platformVersion) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->platformVersion = platformVersion;
+ free(platformVersion);
+ } else {
+ LoggerE("get fail platformVersion value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->platformVersion);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMNAME)) {
char* platformName = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_PLATFORM_NAME, &platformName) == SYSTEM_INFO_ERROR_NONE) {
- if (platformName) {
- LoggerD("platformName : " << platformName);
- deviceCapabilitiesInfo->platformName = platformName;
- free(platformName);
- }
- }
+ if(system_info_get_platform_string("tizen.org/system/platform.name", &platformName) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->platformName = platformName;
+ free(platformName);
+ } else {
+ LoggerE("get fail platformName value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->platformName);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WEBAPIVERSION)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- std::ifstream file("/usr/etc/system-info.ini");
- std::string line;
- std::string webApiVersionMajor = "";
- std::string webApiVersionMinor = "";
-
- if(!file) {
- LoggerD("api/native version info file not found");
- } else {
- while ((std::getline(file, line).rdstate() & (std::ifstream::failbit | std::ifstream::eofbit)) == 0) {
- if (pcrecpp::RE("platform.web.api.version=(\\w+).(\\w+)").PartialMatch(line, &webApiVersionMajor, &webApiVersionMinor)) {
- deviceCapabilitiesInfo->webApiVersion = webApiVersionMajor;
- deviceCapabilitiesInfo->webApiVersion += ".";
- deviceCapabilitiesInfo->webApiVersion += webApiVersionMinor;
- LoggerD("web api version : " << deviceCapabilitiesInfo->webApiVersion);
- break;
- }
- }
- file.close();
- }
-
+ char* webApiVersion = NULL;
+ if(system_info_get_platform_string("tizen.org/feature/platform.web.api.version", &webApiVersion) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->webApiVersion = webApiVersion;
+ free(webApiVersion);
+ } else {
+ LoggerE("get fail webApiVersion value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->webApiVersion);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NATIVEAPIVERSION)) {
AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
- std::ifstream file("/usr/etc/system-info.ini");
- std::string line;
- std::string nativeApiVersionMajor = "";
- std::string nativeApiVersionMinor = "";
-
- if(!file) {
- LoggerD("api/native version info file not found");
- } else {
- while ((std::getline(file, line).rdstate() & (std::ifstream::failbit | std::ifstream::eofbit)) == 0) {
- if (pcrecpp::RE("platform.native.api.version=(\\w+).(\\w+)").PartialMatch(line, &nativeApiVersionMajor, &nativeApiVersionMinor )) {
- deviceCapabilitiesInfo->nativeApiVersion = nativeApiVersionMajor;
- deviceCapabilitiesInfo->nativeApiVersion += ".";
- deviceCapabilitiesInfo->nativeApiVersion += nativeApiVersionMinor;
- LoggerD("native api version : " << deviceCapabilitiesInfo->nativeApiVersion);
- break;
- }
- }
- file.close();
- }
-
+ char* nativeApiVersion = NULL;
+ if(system_info_get_platform_string("tizen.org/feature/platform.native.api.version", &nativeApiVersion) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->nativeApiVersion = nativeApiVersion;
+ free(nativeApiVersion);
+ } else {
+ LoggerE("get fail nativeApiVersion value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->nativeApiVersion);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERAFRONT)) {
bool cameraFront = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_SUPPORTED, &cameraFront) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("cameraFront : " << cameraFront);
+ if(system_info_get_platform_bool("tizen.org/feature/camera.front", &cameraFront) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->cameraFront = cameraFront;
+ } else {
+ LoggerE("get fail cameraFront value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->cameraFront);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERA)) {
- int cameraCount = 0;
- if (system_info_get_value_int(SYSTEM_INFO_KEY_CAMERA_COUNT, &cameraCount) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("cameraCount : " << cameraCount);
- if (cameraCount > 0) {
- deviceCapabilitiesInfo->camera = true;
- } else {
- deviceCapabilitiesInfo->camera = false;
- }
+ bool camera = false;
+ if(system_info_get_platform_bool("tizen.org/feature/camera", &camera) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->camera = camera;
+ } else {
+ LoggerE("get fail camera value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->camera);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERAFRONTFLASH)) {
bool cameraFrontFlash = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_FRONT_CAMERA_FLASH_SUPPORTED, &cameraFrontFlash) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("cameraFrontFlash : " << cameraFrontFlash);
+ if(system_info_get_platform_bool("tizen.org/feature/camera.front.flash", &cameraFrontFlash) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->cameraFrontFlash = cameraFrontFlash;
+ } else {
+ LoggerE("get fail cameraFrontFlash value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->cameraFrontFlash);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERABACK)) {
bool cameraBack = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_BACK_CAMERA_SUPPORTED, &cameraBack) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("cameraBack : " << cameraBack);
+ if(system_info_get_platform_bool("tizen.org/feature/camera.back", &cameraBack) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->cameraBack = cameraBack;
+ } else {
+ LoggerE("get fail cameraBack value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->cameraBack);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERABACKFLASH)) {
bool cameraBackFlash = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_BACK_CAMERA_FLASH_SUPPORTED, &cameraBackFlash) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("cameraBackFlash : " << cameraBackFlash);
+ if(system_info_get_platform_bool("tizen.org/feature/camera.back.flash", &cameraBackFlash) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->cameraBackFlash = cameraBackFlash;
+ } else {
+ LoggerE("get fail cameraBackFlash value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->cameraBackFlash);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_LOCATION)) {
bool location = false;
- bool locationGps = false;
- bool locationWps = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GPS_SUPPORTED, &locationGps) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("locationGps : " << locationGps);
- }
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_WPS_SUPPORTED, &locationWps) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("locationWps : " << locationWps);
- }
- if (locationGps || locationWps) {
- location = true;
+ if(system_info_get_platform_bool("tizen.org/feature/location", &location) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->location = location;
+ } else {
+ LoggerE("get fail location value");
+ return JSValueMakeUndefined(context);
}
- deviceCapabilitiesInfo->location = location;
return convert.toJSValueRef(deviceCapabilitiesInfo->location);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_LOCATIONGPS)) {
bool locationGps = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GPS_SUPPORTED, &locationGps) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("locationGps : " << locationGps);
+ if(system_info_get_platform_bool("tizen.org/feature/location.gps", &locationGps) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->locationGps = locationGps;
+ } else {
+ LoggerE("get fail locationGps value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->locationGps);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_LOCATIONWPS)) {
bool locationWps = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_WPS_SUPPORTED, &locationWps) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("locationWps : " << locationWps);
+ if(system_info_get_platform_bool("tizen.org/feature/location.wps", &locationWps) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->locationWps = locationWps;
+ } else {
+ LoggerE("get fail locationWps value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->locationWps);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MICROPHONE)) {
bool microphone = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_MICROPHONE_SUPPORTED, µphone) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("microphone : " << microphone);
+ if(system_info_get_platform_bool("tizen.org/feature/microphone", µphone) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->microphone = microphone;
+ } else {
+ LoggerE("get fail microphone value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->microphone);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_USBHOST)) {
bool usbHost = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_USB_HOST_SUPPORTED, &usbHost) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("usbHost : " << usbHost);
+ if(system_info_get_platform_bool("tizen.org/feature/usb.host", &usbHost) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->usbHost = usbHost;
+ } else {
+ LoggerE("get fail usbHost value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->usbHost);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_USBACCESSORY)) {
bool usbAccessory = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_USB_ACCESSORY_SUPPORTED, &usbAccessory) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("usbAccessory : " << usbAccessory);
+ if(system_info_get_platform_bool("tizen.org/feature/usb.accessory", &usbAccessory) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->usbAccessory = usbAccessory;
+ } else {
+ LoggerE("get fail usbAccessory value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->usbAccessory);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENOUTPUTRCA)) {
bool screenOutputRca = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_RCA_SUPPORTED, &screenOutputRca) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("screenOutputRca : " << screenOutputRca);
+ if(system_info_get_platform_bool("tizen.org/feature/screen.output.rca", &screenOutputRca) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->screenOutputRca = screenOutputRca;
+ } else {
+ LoggerE("get fail screenOutputRca value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->screenOutputRca);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENOUTPUTHDMI)) {
bool screenOutputHdmi = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_HDMI_SUPPORTED, &screenOutputHdmi) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("screenOutputHdmi : " << screenOutputHdmi);
+ if(system_info_get_platform_bool("tizen.org/feature/screen.output.hdmi", &screenOutputHdmi) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->screenOutputHdmi = screenOutputHdmi;
+ } else {
+ LoggerE("get fail screenOutputHdmi value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->screenOutputHdmi);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMCORECPUARCH)) {
+ bool cpuArch = false;
+ bool data = false;
char* platformCoreCpuArch = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_CORE_CPU_ARCH, &platformCoreCpuArch) == SYSTEM_INFO_ERROR_NONE) {
- if (platformCoreCpuArch) {
- LoggerD("platformCoreCpuArch : " << platformCoreCpuArch);
- deviceCapabilitiesInfo->platformCoreCpuArch = platformCoreCpuArch;
- free(platformCoreCpuArch);
+ char platformCoreCpuArchFull[MAXBUFSIZE];
+ platformCoreCpuArchFull[0] = '\0';
+
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.armv6", &cpuArch) == SYSTEM_INFO_ERROR_NONE && cpuArch == true) {
+ strcat(platformCoreCpuArchFull, "armv6");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.armv7", &cpuArch) == SYSTEM_INFO_ERROR_NONE && cpuArch == true) {
+ if (data) {
+ strcat(platformCoreCpuArchFull, " | ");
}
+ strcat(platformCoreCpuArchFull, "armv7");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.x86", &cpuArch) == SYSTEM_INFO_ERROR_NONE && cpuArch == true) {
+ if (data) {
+ strcat(platformCoreCpuArchFull, " | ");
+ }
+ strcat(platformCoreCpuArchFull, "x86");
}
+
+ platformCoreCpuArch = strdup(platformCoreCpuArchFull);
+
+ if (platformCoreCpuArch == NULL) {
+ LoggerE("get fail platformCoreCpuArch value");
+ return JSValueMakeUndefined(context);
+ }
+
+ deviceCapabilitiesInfo->platformCoreCpuArch = platformCoreCpuArch;
+ free(platformCoreCpuArch);
+
return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreCpuArch);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMCOREFPUARCH)) {
+ bool fpuArch = false;
+ bool data = true;
char* platformCoreFpuArch = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_CORE_FPU_ARCH, &platformCoreFpuArch) == SYSTEM_INFO_ERROR_NONE) {
- if (platformCoreFpuArch) {
- LoggerD("platformCoreFpuArch : " << platformCoreFpuArch);
- deviceCapabilitiesInfo->platformCoreFpuArch = platformCoreFpuArch;
- free(platformCoreFpuArch);
+ char platformCoreFpuArchFull[MAXBUFSIZE];
+ platformCoreFpuArchFull[0] = '\0';
+
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.sse2", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ data = true;
+ strcat(platformCoreFpuArchFull, "sse2");
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.sse3", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
}
+ strcat(platformCoreFpuArchFull, "sse3");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.ssse3", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "ssse3");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.vfpv2", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "vfpv2");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.vfpv3", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "vfpv3");
}
+ platformCoreFpuArch = strdup(platformCoreFpuArchFull);
+
+ if (platformCoreFpuArch == NULL) {
+ LoggerE("get fail platformCoreFpuArch value");
+ return JSValueMakeUndefined(context);
+ }
+
+ deviceCapabilitiesInfo->platformCoreCpuArch = platformCoreFpuArch;
+ free(platformCoreFpuArch);
+
return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreFpuArch);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SIPVOIP)) {
bool sipVoip = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_SIP_VOIP_SUPPORTED, &sipVoip) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("sipVoip : " << sipVoip);
+ if(system_info_get_platform_bool("tizen.org/feature/sip.voip", &sipVoip) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->sipVoip = sipVoip;
+ } else {
+ LoggerE("get fail sipVoip value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->sipVoip);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_DUID)) {
return convert.toJSValueRef(deviceCapabilitiesInfo->duid);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SPEECH_ROCOGNITION)) {
bool speechRecognition = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_SPEECH_RECOGNITION_SUPPORTED, &speechRecognition) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("speechRecognition : " << speechRecognition);
+ if(system_info_get_platform_bool("tizen.org/feature/speech.recognition", &speechRecognition) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->speechRecognition = speechRecognition;
+ } else {
+ LoggerE("get fail speechRecognition value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->speechRecognition);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SPEECH_SYNTHESIS)) {
- void* handle = dlopen("/usr/lib/libtts.so",RTLD_NOW);
- if(handle!=NULL) {
- deviceCapabilitiesInfo->speechSynthesis = true;
+ bool speechSynthesis = false;
+ if(system_info_get_platform_bool("tizen.org/feature/speech.synthesis", &speechSynthesis) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->speechSynthesis = speechSynthesis;
} else {
- deviceCapabilitiesInfo->speechSynthesis = false;
+ LoggerE("get fail speechSynthesis value");
+ return JSValueMakeUndefined(context);
}
- LoggerD("speechSynthesis : " << deviceCapabilitiesInfo->speechSynthesis);
return convert.toJSValueRef(deviceCapabilitiesInfo->speechSynthesis);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_ACCELEROMETER)) {
- bool isAccelerometer = false;
- if (sensor_is_supported(SENSOR_ACCELEROMETER, &isAccelerometer) == SENSOR_ERROR_NONE) {
- LoggerD("accelerometer : " << isAccelerometer);
- deviceCapabilitiesInfo->accelerometer = isAccelerometer;
+ bool accelerometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.accelerometer", &accelerometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->accelerometer = accelerometer;
+ } else {
+ LoggerE("get fail accelerometer value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->accelerometer);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_ACCELEROMETER_WAKEUP)) {
- bool isAccelerometerWakeup = false;
- if (sensor_awake_is_supported(SENSOR_ACCELEROMETER, &isAccelerometerWakeup) == SENSOR_ERROR_NONE) {
- LoggerD("isAccelerometerWakeup : " << isAccelerometerWakeup);
- deviceCapabilitiesInfo->accelerometerWakeup = isAccelerometerWakeup;
+ bool accelerometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.accelerometer.wakeup", &accelerometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->accelerometerWakeup = accelerometerWakeup;
+ } else {
+ LoggerE("get fail accelerometerWakeup value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->accelerometerWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_BAROMETER)) {
- bool isBarometer = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_BAROMETER_SENSOR_SUPPORTED, &isBarometer) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("barometer : " << isBarometer);
- deviceCapabilitiesInfo->barometer = isBarometer;
+ bool barometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.barometer", &barometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->barometer = barometer;
+ } else {
+ LoggerE("get fail barometer value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->barometer);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_BAROMETER_WAKEUP)) {
+ bool barometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.barometer.wakeup", &barometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->barometerWakeup = barometerWakeup;
+ } else {
+ LoggerE("get fail barometerWakeup value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->barometerWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_GYROSCOPE)) {
- bool isGyroscope = false;
- if (sensor_is_supported(SENSOR_GYROSCOPE, &isGyroscope) == SENSOR_ERROR_NONE) {
- LoggerD("gyroscope : " << isGyroscope);
- deviceCapabilitiesInfo->gyroscope = isGyroscope;
+ bool gyroscope = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.gyroscope", &gyroscope) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->gyroscope = gyroscope;
+ } else {
+ LoggerE("get fail gyroscope value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->gyroscope);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_GYROSCOPE_WAKEUP)) {
- bool isGyroscopeWakeup = false;
- if (sensor_awake_is_supported(SENSOR_GYROSCOPE, &isGyroscopeWakeup) == SENSOR_ERROR_NONE) {
- LoggerD("isGyroscopeWakeup : " << isGyroscopeWakeup);
- deviceCapabilitiesInfo->gyroscopeWakeup = isGyroscopeWakeup;
+ bool gyroscopeWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.gyroscope.wakeup", &gyroscopeWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->gyroscopeWakeup = gyroscopeWakeup;
+ } else {
+ LoggerE("get fail gyroscopeWakeup value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->gyroscopeWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MAGNETOMETER)) {
- bool isMagnetometer = false;
- if (sensor_is_supported(SENSOR_MAGNETIC, &isMagnetometer) == SENSOR_ERROR_NONE) {
- LoggerD("magnetometer : " << isMagnetometer);
- deviceCapabilitiesInfo->magnetometer = isMagnetometer;
+ bool magnetometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.magnetometer", &magnetometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->magnetometer = magnetometer;
+ } else {
+ LoggerE("get fail magnetometer value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->magnetometer);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MAGNETOMETER_WAKEUP)) {
- bool isMagnetometerWakeup = false;
- if (sensor_awake_is_supported(SENSOR_MAGNETIC, &isMagnetometerWakeup) == SENSOR_ERROR_NONE) {
- LoggerD("isMagnetometerWakeup : " << isMagnetometerWakeup);
- deviceCapabilitiesInfo->magnetometerWakeup = isMagnetometerWakeup;
+ bool magnetometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.magnetometer.wakeup", &magnetometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->magnetometerWakeup = magnetometerWakeup;
+ } else {
+ LoggerE("get fail magnetometerWakeup value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->magnetometerWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PHOTOMETER)) {
- bool isPhotometer = false;
- if (sensor_is_supported(SENSOR_LIGHT, &isPhotometer) == SENSOR_ERROR_NONE) {
- LoggerD("isPhotometer : " << isPhotometer);
- deviceCapabilitiesInfo->photometer = isPhotometer;
- }
+ bool photometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.photometer", &photometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->photometer = photometer;
+ } else {
+ LoggerE("get fail photometer value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->photometer);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PHOTOMETER_WAKEUP)) {
- bool isphotometerWakeup = false;
- if (sensor_awake_is_supported(SENSOR_LIGHT, &isphotometerWakeup) == SENSOR_ERROR_NONE) {
- LoggerD("isphotometerWakeup : " << isphotometerWakeup);
- deviceCapabilitiesInfo->photometerWakeup = isphotometerWakeup;
- }
+ bool photometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.photometer.wakeup", &photometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->photometerWakeup = photometerWakeup;
+ } else {
+ LoggerE("get fail photometerWakeup value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->photometerWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROXIMITY)) {
- bool isProximity = false;
- if (sensor_is_supported(SENSOR_PROXIMITY, &isProximity) == SENSOR_ERROR_NONE) {
- LoggerD("proximity : " << isProximity);
- deviceCapabilitiesInfo->proximity = isProximity;
+ bool proximity = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.proximity", &proximity) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->proximity = proximity;
+ } else {
+ LoggerE("get fail proximity value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->proximity);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROXIMITY_WAKEUP)) {
- bool isProximityWakeup = false;
- if (sensor_awake_is_supported(SENSOR_PROXIMITY, &isProximityWakeup) == SENSOR_ERROR_NONE) {
- LoggerD("isProximityWakeup : " << isProximityWakeup);
- deviceCapabilitiesInfo->proximityWakeup = isProximityWakeup;
- }
+ bool proximityWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.proximity.wakeup", &proximityWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->proximityWakeup = proximityWakeup;
+ } else {
+ LoggerE("get fail proximityWakeup value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->proximityWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TILTMETER)) {
- bool isTiltmeter = false;
- if (sensor_is_supported(SENSOR_MOTION_TILT, &isTiltmeter) == SENSOR_ERROR_NONE) {
- LoggerD("isTiltmeter : " << isTiltmeter);
- deviceCapabilitiesInfo->tiltmeter = isTiltmeter;
- }
+ bool tiltmeter = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.tiltmeter", &tiltmeter) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->tiltmeter = tiltmeter;
+ } else {
+ LoggerE("get fail tiltmeter value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->tiltmeter);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TILTMETER_WAKEUP)) {
- bool isTiltmeterWakeup = false;
- if (sensor_awake_is_supported(SENSOR_MOTION_TILT, &isTiltmeterWakeup) == SENSOR_ERROR_NONE) {
- LoggerD("isTiltmeterWakeup : " << isTiltmeterWakeup);
- deviceCapabilitiesInfo->tiltmeterWakeup = isTiltmeterWakeup;
- }
+ bool tiltmeterWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.tiltmeter.wakeup", &tiltmeterWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->tiltmeterWakeup = tiltmeterWakeup;
+ } else {
+ LoggerE("get fail tiltmeterWakeup value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->tiltmeterWakeup);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_DATA_ENCRYPTION)) {
- void* handle = dlopen("/usr/lib/libsqlite3.so.0",RTLD_NOW);
- if(handle != NULL) {
- deviceCapabilitiesInfo->dataEncryption = true;
+ bool dataEncryption = false;
+ if(system_info_get_platform_bool("tizen.org/feature/database.encryption", &dataEncryption) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->dataEncryption = dataEncryption;
} else {
- deviceCapabilitiesInfo->dataEncryption = false;
+ LoggerE("get fail dataEncryption value");
+ return JSValueMakeUndefined(context);
}
- LoggerD("dataEncryption : " << deviceCapabilitiesInfo->dataEncryption);
return convert.toJSValueRef(deviceCapabilitiesInfo->dataEncryption);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_GRAPHICS_ACCELERATION)) {
- bool isGraphicsAccelerationSupported = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_GRAPHICS_HWACCEL_SUPPORTED , &isGraphicsAccelerationSupported) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("graphicsAcceleration : " << isGraphicsAccelerationSupported);
- deviceCapabilitiesInfo->graphicsAcceleration = isGraphicsAccelerationSupported;
+ bool graphicsAcceleration = false;
+ if(system_info_get_platform_bool("tizen.org/feature/graphics.acceleration", &graphicsAcceleration) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->graphicsAcceleration = graphicsAcceleration;
+ } else {
+ LoggerE("get fail graphicsAcceleration value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->graphicsAcceleration);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PUSH)) {
- deviceCapabilitiesInfo->push = isExist("/usr/bin/pushd");
- LoggerD("push : " << deviceCapabilitiesInfo->push);
+ bool push = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.push", &push) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->push = push;
+ } else {
+ LoggerE("get fail push value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->push);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TELEPHONY)) {
- deviceCapabilitiesInfo->telephony = isExist("/usr/bin/telephony-daemon");
- LoggerD("telephony : " << deviceCapabilitiesInfo->telephony);
+ bool telephony = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->telephony = telephony;
+ } else {
+ LoggerE("get fail telephony value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->telephony);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TELEPHONY_MMS)) {
bool telephonyMms = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_MMS_SUPPORTED, &telephonyMms) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("telephonyMms : " << telephonyMms);
+ if(system_info_get_platform_bool("tizen.org/feature/network.telephony.mms", &telephonyMms) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->telephonyMms = telephonyMms;
+ } else {
+ LoggerE("get fail telephonyMms value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->telephonyMms);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TELEPHONY_SMS)) {
bool telephonySms = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_SMS_SUPPORTED, &telephonySms) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("telephonySms : " << telephonySms);
+ if(system_info_get_platform_bool("tizen.org/feature/network.telephony.sms", &telephonySms) == SYSTEM_INFO_ERROR_NONE) {
deviceCapabilitiesInfo->telephonySms = telephonySms;
+ } else {
+ LoggerE("get fail telephonySms value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->telephonySms);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENSIZE_NORMAL)) {
- deviceCapabilitiesInfo->screenSizeNormal = getRegistry("screen.coordinate_system.size.normal");
- LoggerD("screenSizeNormal : " << deviceCapabilitiesInfo->screenSizeNormal);
+ bool screenSizeNormal = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal", &screenSizeNormal) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenSizeNormal = screenSizeNormal;
+ } else {
+ LoggerE("get fail screenSizeNormal value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->screenSizeNormal);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENSIZE_480_800)) {
- deviceCapabilitiesInfo->screenSize480_800 = getRegistry("screen.coordinate_system.physical.normal_480x800");
- LoggerD("screenSize480_800 : " << deviceCapabilitiesInfo->screenSize480_800);
+ bool screenSize480_800 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.480.800", &screenSize480_800) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenSize480_800 = screenSize480_800;
+ } else {
+ LoggerE("get fail screenSize480_800 value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->screenSize480_800);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENSIZE_720_1280)) {
- deviceCapabilitiesInfo->screenSize720_1280 = getRegistry("screen.coordinate_system.physical.normal_720x1280");
- LoggerD("screenSize720_1280 : " << deviceCapabilitiesInfo->screenSize720_1280);
+ bool screenSize720_1280 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.720.1280", &screenSize720_1280) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenSize720_1280 = screenSize720_1280;
+ } else {
+ LoggerE("get fail screenSize720_1280 value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->screenSize720_1280);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_AUTO_ROTATION)) {
- bool isAutoRotation = false;
- if (system_info_get_value_bool(SYSTEM_INFO_KEY_FEATURE_AUTO_ROTATION_SUPPORTED, &isAutoRotation) == SYSTEM_INFO_ERROR_NONE) {
- LoggerD("auto rotation : " << isAutoRotation);
- deviceCapabilitiesInfo->autoRotation = isAutoRotation;
+ bool autoRotation = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.auto_rotation", &autoRotation) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->autoRotation = autoRotation;
+ } else {
+ LoggerE("get fail autoRotation value");
+ return JSValueMakeUndefined(context);
}
return convert.toJSValueRef(deviceCapabilitiesInfo->autoRotation);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SHELL_APP_WIDGET)) {
- bool isShellAppWidgetSupported = false;
- pkgmgrinfo_pkginfo_h handle;
- if (pkgmgrinfo_pkginfo_get_pkginfo("gi2qxenosh",&handle) == PMINFO_R_OK) {
- isShellAppWidgetSupported = true;
- pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- LoggerD("shellAppWidget : " << isShellAppWidgetSupported);
- }
- deviceCapabilitiesInfo->shellAppWidget = isShellAppWidgetSupported;
+ bool shellAppWidget = false;
+ if(system_info_get_platform_bool("tizen.org/feature/shell.appwidget", &shellAppWidget) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->shellAppWidget = shellAppWidget;
+ } else {
+ LoggerE("get fail shellAppWidget value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->shellAppWidget);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_IMAGE_RECOGNITION)) {
- deviceCapabilitiesInfo->visionImageRecognition = isExist("/usr/lib/osp/libarengine.so");
- LoggerD("visionImageRecognition : " << deviceCapabilitiesInfo->visionImageRecognition);
+ bool visionImageRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.image_recognition", &visionImageRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionImageRecognition = visionImageRecognition;
+ } else {
+ LoggerE("get fail visionImageRecognition value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->visionImageRecognition);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_QRCODE_GENERATION)) {
- deviceCapabilitiesInfo->visionQrcodeGeneration = isExist("/usr/lib/osp/libarengine.so");
- LoggerD("visionQrcodeGeneration : " << deviceCapabilitiesInfo->visionQrcodeGeneration);
+ bool visionQrcodeGeneration = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.qrcode_generation", &visionQrcodeGeneration) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionQrcodeGeneration = visionQrcodeGeneration;
+ } else {
+ LoggerE("get fail visionQrcodeGeneration value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->visionQrcodeGeneration);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_QRCODE_RECOGNITION)) {
- deviceCapabilitiesInfo->visionQrcodeRecognition = isExist("/usr/lib/osp/libarengine.so");
- LoggerD("visionQrcodeRecognition : " << deviceCapabilitiesInfo->visionQrcodeRecognition);
+ bool visionQrcodeRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.qrcode_recognition", &visionQrcodeRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionQrcodeRecognition = visionQrcodeRecognition;
+ } else {
+ LoggerE("get fail visionQrcodeRecognition value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->visionQrcodeRecognition);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_FACE_RECOGNITION)) {
- deviceCapabilitiesInfo->visionFaceRecognition = isExist("/usr/lib/osp/libarengine.so");
- LoggerD("visionFaceRecognition : " << deviceCapabilitiesInfo->visionFaceRecognition);
+ bool visionFaceRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.face_recognition", &visionFaceRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionFaceRecognition = visionFaceRecognition;
+ } else {
+ LoggerE("get fail visionFaceRecognition value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->visionFaceRecognition);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SECURE_ELEMENT)) {
- deviceCapabilitiesInfo->secureElement = isExist("/usr/bin/smartcard-daemon");
- LoggerD("secureElement : " << deviceCapabilitiesInfo->secureElement);
+ bool secureElement = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.secure_element", &secureElement) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->secureElement = secureElement;
+ } else {
+ LoggerE("get fail secureElement value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->secureElement);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NATIVE_OSP_COMPATIBLE)) {
- deviceCapabilitiesInfo->nativeOspCompatible = getRegistry("platform.native.osp_compatible");
- LoggerD("nativeOspCompatible : " << deviceCapabilitiesInfo->nativeOspCompatible);
+ bool nativeOspCompatible = false;
+ if(system_info_get_platform_bool("tizen.org/feature/platform.native.osp_compatible", &nativeOspCompatible) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->nativeOspCompatible = nativeOspCompatible;
+ } else {
+ LoggerE("get fail nativeOspCompatible value");
+ return JSValueMakeUndefined(context);
+ }
return convert.toJSValueRef(deviceCapabilitiesInfo->nativeOspCompatible);
} else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROFILE)) {
deviceCapabilitiesInfo->profile = DEVICE_PROFILE;
return JSValueMakeUndefined(context);
}
-bool JSDeviceCapabilitiesInfo::isExist(const char* path)
-{
- if (0 == access(path ,F_OK))
- return true;
- return false;
-}
-
-bool JSDeviceCapabilitiesInfo::getRegistry(std::string key)
-{
- std::ifstream file("/usr/etc/system-info.ini");
- std::string line;
- std::string _key;
- _key.append(key);
- _key.append("=(\\w+)");
- std::string value = "";
- bool ret = false;
-
- if(!file) {
- LoggerD("Registry file not found");
- } else {
- while ((std::getline(file, line).rdstate() & (std::ifstream::failbit | std::ifstream::eofbit)) == 0) {
- if (pcrecpp::RE(_key).PartialMatch(line, &value)) {
- LoggerD("Key[" << key << "] : " << value; );
- if(0==value.compare("true")) {
- ret = true;
- } else {
- ret = false;
- }
- break;
- }
- }
- file.close();
- }
- return ret;
-}
-
}
}
static void Finalize(JSObjectRef object);
static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
- static bool isExist(const char* path);
- static bool getRegistry(std::string key);
static JSStaticValue m_properties[];
static JSClassRef m_classRef;
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid values error");
}
Catch(WrtDeviceApis::Commons::Exception) {
- return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown error");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Platform error");
}
}
struct statfs fs;
if (statfs(STORAGE_INTERNAL_PATH, &fs) < 0) {
- // make exception
return JSValueMakeNull(context);
}
StoragePropertiesPtr storagePtr(new StorageProperties());
Converter converter(context);
DisplayPropertiesPtr display(new DisplayProperties());
- int brightness=0, dotsPerInchX=0, dotsPerInchY=0, physicalW=0, physicalH=0, resolutionW=0, resolutionH=0;
+ int brightness=0, dotsPerInch=0, physicalW=0, physicalH=0;
+ bool screenSizeSmall = false, screenSizeBig = false;
if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness) == 0) {
display->brightness = (double)(brightness)/DISPLAY_BRIGHTNESS_DIVIDE_VALUE;
- LoggerD("brightness : " << display->brightness);
}
- if (system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &resolutionW) == SYSTEM_INFO_ERROR_NONE) {
- display->resolutionWidth = resolutionW;
- LoggerD("resolutionWidth : " << display->resolutionWidth);
- }
- if (system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_HEIGHT, &resolutionH) == SYSTEM_INFO_ERROR_NONE) {
- display->resolutionHeight = resolutionH;
- LoggerD("resolutionHeight : " << display->resolutionHeight);
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.480.800", &screenSizeSmall) == SYSTEM_INFO_ERROR_NONE) {
+ if (screenSizeSmall) {
+ display->resolutionWidth = 480;
+ display->resolutionHeight = 800;
+ } else {
+ if (system_info_get_platform_bool("tizen.org/feature/screen.size.normal.720.1280", &screenSizeBig) == SYSTEM_INFO_ERROR_NONE) {
+ if (screenSizeBig) {
+ display->resolutionWidth = 720;
+ display->resolutionHeight = 1280;
+ }
+ }
+ }
}
- if (system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_DPI, &dotsPerInchX) == SYSTEM_INFO_ERROR_NONE) {
- display->dotsPerInchWidth = dotsPerInchX;
- LoggerD("dotsPerInchWidth : " << display->dotsPerInchWidth);
+
+ if(system_info_get_platform_int("tizen.org/feature/screen.dpi", &dotsPerInch) == SYSTEM_INFO_ERROR_NONE) {
+ display->dotsPerInchWidth = dotsPerInch;
+ display->dotsPerInchHeight = dotsPerInch;
}
- if (system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_DPI, &dotsPerInchY) == SYSTEM_INFO_ERROR_NONE) {
- display->dotsPerInchHeight = dotsPerInchY;
- LoggerD("dotsPerInchHeight : " << display->dotsPerInchHeight);
+
+ if(system_info_get_platform_int("tizen.org/feature/screen.width", &physicalW) == SYSTEM_INFO_ERROR_NONE) {
+ display->physicalWidth = physicalW;
}
- if (system_info_get_value_int(SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, &physicalH) == SYSTEM_INFO_ERROR_NONE) {
+
+ if(system_info_get_platform_int("tizen.org/feature/screen.height", &physicalH) == SYSTEM_INFO_ERROR_NONE) {
display->physicalHeight = physicalH;
- LoggerD("physicalHeight : " << display->physicalHeight);
- }
- if (system_info_get_value_int(SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, &physicalW) == SYSTEM_INFO_ERROR_NONE) {
- display->physicalWidth = physicalW;
- LoggerD("physicalWidth : " << display->physicalWidth);
}
return JSDisplayInfo::createJSObject(context, display);
char* manufacturer = NULL;
char* buildVersion = NULL;
- if (system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &model) == SYSTEM_INFO_ERROR_NONE) {
+ if(system_info_get_platform_string("tizen.org/system/model_name", &model) == SYSTEM_INFO_ERROR_NONE) {
if (model != NULL) {
LoggerD("model : " << model);
Build->model = model;