Name: wrt-plugins-tizen
Summary: JavaScript plugins for WebRuntime
-Version: 0.4.43
+Version: 0.4.44
Release: 0
Group: Development/Libraries
License: Apache License, Version 2.0
--- /dev/null
+prefix=/usr
+project_name=@CMAKE_PROJECT_NAME@
+module_name=websetting
+exec_prefix=${prefix}
+libdir=${prefix}/lib/wrt-plugins/tizen-${module_name}
+includedir=${prefix}/include/${project_name}
+
+Name: wrt-plugins-tizen-${module_name}
+Description: wrt-plugins-tizen-${module_name}
+Version: @CMAKE_PROJECT_VERSION@
+Libs: -L${libdir} -lwrt-plugins-tizen-${module_name}
+Cflags: -I${includedir}/${module_name}
#include "JSApplicationControlData.h"
#include "JSApplicationControl.h"
#include "JSRequestedApplicationControl.h"
+#include "JSApplicationMetaData.h"
#include "JSApplicationCert.h"
namespace DeviceAPI {
}
-JSValueRef ApplicationConverter::toJSValueRefFromeApplicationCerts(const ApplicationCertArrayPtr &arg)
+JSValueRef ApplicationConverter::toJSValueRefFromApplicationCerts(const ApplicationCertArrayPtr &arg)
{
if(arg == NULL) {
Throw(Commons::InvalidArgumentException);
}
+JSValueRef ApplicationConverter::toJSValueRefFromApplicationMetaData(const ApplicationMetaDataPtr &arg)
+{
+ if(arg == NULL) {
+ Throw(Commons::ConversionException);
+ }
+ return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationMetaData::getClassRef(), arg);
+}
+
+
+JSValueRef ApplicationConverter::toJSValueRefFromApplicationMetaDataArray(const ApplicationMetaDataArrayPtr &arg)
+{
+ if(arg == NULL) {
+ Throw(Commons::InvalidArgumentException);
+ }
+ return toJSValueRef_(*arg, &ApplicationConverter::toJSValueRefFromApplicationMetaData, this);
+}
+
+
JSValueRef ApplicationConverter::toJSValueRefFromApplicationInformation(const ApplicationInformationPtr &arg)
{
if(arg == NULL) {
#include "ApplicationControlData.h"
#include "ApplicationControl.h"
#include "ApplicationCert.h"
+#include "ApplicationMetaData.h"
#include "Application.h"
#include <Export.h>
JSValueRef toJSValueRefFromApplication(const ApplicationPtr &arg);
JSValueRef toJSValueRefFromApplicationInformation(const ApplicationInformationPtr &arg);
JSValueRef toJSValueRefFromApplicationCert(const ApplicationCertPtr &arg);
- JSValueRef toJSValueRefFromeApplicationCerts(const ApplicationCertArrayPtr &arg);
+ JSValueRef toJSValueRefFromApplicationCerts(const ApplicationCertArrayPtr &arg);
+ JSValueRef toJSValueRefFromApplicationMetaData(const ApplicationMetaDataPtr &arg);
+ JSValueRef toJSValueRefFromApplicationMetaDataArray(const ApplicationMetaDataArrayPtr &arg);
ApplicationInformationPtr toApplicationInformation(const JSValueRef &jsValue);
JSValueRef toJSValueRef(const ApplicationInformationArrayPtr &arg);
ApplicationInformationArrayPtr toApplicationInformationArray(const JSValueRef &jsValue);
#include "ApplicationContext.h"
#include "ApplicationControlData.h"
#include "ApplicationControl.h"
-#include "ApplicationCert.h"
#include "Application.h"
#include <app.h>
return true;
}
+
+ static int app_meta_data_cb(const char *meta_key, const char *meta_value, void *user_data)
+ {
+ if ((meta_key == NULL) || (meta_value == NULL)) {
+ LoggerE("meta_key or meta_value is null");
+ return 0;
+ }
+
+ ApplicationMetaDataPtr metaData(new ApplicationMetaData());
+
+ metaData->setKey(meta_key);
+ metaData->setValue(meta_value);
+
+ ApplicationMetaDataArray *metaDataArray = (ApplicationMetaDataArray *)user_data;
+ metaDataArray->push_back(metaData);
+
+ return 0;
+ }
}
ApplicationManager::ApplicationManager() :
return certArray;
}
+std::string ApplicationManager::getAppSharedURI(const std::string id)
+{
#define TIZENAPIS_APP_FILE_SCHEME "file://"
#define TIZENAPIS_APP_SLASH "/"
#define TIZENAPIS_APP_SHARED "shared"
-
-std::string ApplicationManager::getAppSharedURI(const std::string id)
-{
std::string appId;
if (id.empty()) {
return sharedURI;
}
+ApplicationMetaDataArrayPtr ApplicationManager::getAppMetaData(const std::string id)
+{
+ std::string appId = id;
+
+ // in case of no argument, get application information of current.
+ if (appId.empty())
+ {
+ appId = get_current_app_id();
+ }
+
+ int ret = 0;
+ pkgmgrinfo_appinfo_h handle;
+
+ TIME_TRACER_ITEM_BEGIN("(getAppMetaData)pkgmgrinfo_appinfo_get_appinfo", 0);
+ ret = pkgmgrinfo_appinfo_get_appinfo(appId.c_str(), &handle);
+ TIME_TRACER_ITEM_END("(getAppMetaData)pkgmgrinfo_appinfo_get_appinfo", 0);
+
+ if (ret != PMINFO_R_OK) {
+ ThrowMsg(NotFoundException, "Cannot found application with given appId");
+ }
+
+ ApplicationMetaDataArrayPtr metaDataArray(new ApplicationMetaDataArray());
+
+ TIME_TRACER_ITEM_BEGIN("(getAppMetaData)pkgmgrinfo_appinfo_foreach_metadata", 0);
+ ret = pkgmgrinfo_appinfo_foreach_metadata(handle, app_meta_data_cb, (void*)metaDataArray.Get());
+ TIME_TRACER_ITEM_END("(getAppMetaData)pkgmgrinfo_appinfo_foreach_metadata", 0);
+
+ if (ret != PMINFO_R_OK) {
+ LoggerE("pkgmgrinfo_appinfo_metadata_filter_foreach() failed");
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ ThrowMsg(UnknownException, "fail to get custom tag");
+ }
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+
+ return metaDataArray;
+}
void ApplicationManager::OnRequestReceived(const EventApplicationLaunchPtr& event)
{
#include "ApplicationContext.h"
#include "ApplicationInformation.h"
#include "ApplicationCert.h"
+#include "ApplicationMetaData.h"
//#include <app_manager.h>
#include <app_service.h>
static ApplicationInformationPtr getAppInfo(const std::string id);
static ApplicationCertArrayPtr getAppCerts(const std::string id);
static std::string getAppSharedURI(const std::string appId);
+ static ApplicationMetaDataArrayPtr getAppMetaData(const std::string id);
protected:
virtual void OnRequestReceived(const EventApplicationLaunchPtr& event);
--- /dev/null
+//
+// 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 "ApplicationMetaData.h"
+
+namespace DeviceAPI {
+namespace Application {
+ApplicationMetaData::ApplicationMetaData()
+{
+}
+
+ApplicationMetaData::~ApplicationMetaData()
+{
+}
+
+std::string ApplicationMetaData::getKey() const
+{
+ return m_key;
+}
+
+void ApplicationMetaData::setKey(const std::string &key)
+{
+ m_key = key;
+}
+
+std::string ApplicationMetaData::getValue() const
+{
+ return m_value;
+}
+
+void ApplicationMetaData::setValue(const std::string &value)
+{
+ m_value = value;
+}
+
+}
+}
--- /dev/null
+//
+// 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 TIZENAPIS_API_APPLICATION_META_DATA_H_
+#define TIZENAPIS_API_APPLICATION_META_DATA_H_
+
+#include <string>
+#include <vector>
+#include <dpl/shared_ptr.h>
+
+namespace DeviceAPI {
+namespace Application {
+
+class ApplicationMetaData;
+typedef DPL::SharedPtr<ApplicationMetaData> ApplicationMetaDataPtr;
+
+typedef std::vector<ApplicationMetaDataPtr> ApplicationMetaDataArray;
+typedef DPL::SharedPtr<ApplicationMetaDataArray> ApplicationMetaDataArrayPtr;
+
+
+class ApplicationMetaData
+{
+ public:
+ ApplicationMetaData();
+ ~ApplicationMetaData();
+
+ std::string getKey() const;
+ void setKey(const std::string &key);
+ std::string getValue() const;
+ void setValue(const std::string &value);
+
+ private:
+ std::string m_key;
+ std::string m_value;
+};
+}
+}
+#endif
ApplicationFactory.cpp
ApplicationInformation.cpp
ApplicationCert.cpp
+ ApplicationMetaData.cpp
IApplicationManager.cpp
ApplicationManager.cpp
AppManagerWrapper.cpp
JSApplicationEventCallbackManager.cpp
JSApplicationInformation.cpp
JSApplicationCert.cpp
+ JSApplicationMetaData.cpp
)
ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
{ APPLICATION_FUNCTION_API_FIND_APP_CONTROL, JSApplicationManager::findAppControl, kJSPropertyAttributeNone },
{ APPLICATION_FUNCTION_API_GET_APP_CERTS, JSApplicationManager::getAppCerts, kJSPropertyAttributeNone },
{ APPLICATION_FUNCTION_API_GET_APP_SHARED_URI, JSApplicationManager::getAppSharedURI, kJSPropertyAttributeNone },
+ { APPLICATION_FUNCTION_API_GET_APP_META_DATA, JSApplicationManager::getAppMetaData, kJSPropertyAttributeNone },
{ 0, 0, 0 }
};
ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return converter->toJSValueRefFromeApplicationCerts(result);
+ return converter->toJSValueRefFromApplicationCerts(result);
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
}
}
+JSValueRef JSApplicationManager::getAppMetaData(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ 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);
+ TIME_TRACER_ITEM_END("(getAppMetaData)ACE", 0);
+
+ try {
+ ArgumentValidator validator(context, argumentCount, arguments);
+
+ ApplicationMetaDataArrayPtr result = ApplicationManager::getAppMetaData(validator.toString(0, true, ""));
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ return converter->toJSValueRefFromApplicationMetaDataArray(result);
+
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::NOT_FOUND_ERROR, ex.GetMessage());
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in ApplicationManager.getAppCerts().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
void JSApplicationManager::setTitleProperty(JSContextRef context, std::string propertyValue){
WrtDeviceApis::CommonsJavaScript::Converter converter(context);
const JSValueRef arguments[], JSValueRef* exception);
/**
+ * Get meta data of specific application
+ */
+ static JSValueRef getAppMetaData(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+ const JSValueRef arguments[], JSValueRef* exception);
+
+ /**
* This structure contains properties and callbacks that define a type of object.
*/
static JSClassDefinition m_classInfo;
--- /dev/null
+//
+// 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 <cassert>
+#include <memory>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+
+//#include <Commons/Exception.h>
+#include <JSWebAPIErrorFactory.h>
+
+#include "ApplicationMetaData.h"
+#include "JSApplicationMetaData.h"
+#include <Export.h>
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Application {
+
+using namespace WrtDeviceApis;
+using namespace DeviceAPI::Common;
+
+
+JSClassRef JSApplicationMetaData::m_classRef = NULL;
+
+JSClassDefinition JSApplicationMetaData::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ TIZEN_INTERFACE_APPLICATION_META_DATA,
+ 0,
+ m_property,
+ 0,
+ initialize,
+ finalize,
+ NULL, //HasProperty,
+ NULL, //GetProperty,
+ NULL, //SetProperty,
+ NULL, //DeleteProperty,
+ NULL, //GetPropertyNames,
+ NULL, //CallAsFunction,
+ NULL, //CallAsConstructor,
+ NULL,
+ NULL, //ConvertToType
+};
+
+JSStaticValue JSApplicationMetaData::m_property[] = {
+ { TIZEN_APPLICATION_META_DATA_KEY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { TIZEN_APPLICATION_META_DATA_VALUE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+JSClassRef DLL_EXPORT JSApplicationMetaData::getClassRef() {
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+
+void JSApplicationMetaData::initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSApplicationMetaData::finalize(JSObjectRef object)
+{
+ JSApplicationMetaDataPriv* priv = static_cast<JSApplicationMetaDataPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ delete priv;
+}
+
+bool JSApplicationMetaData::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+ return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+ApplicationMetaDataPtr JSApplicationMetaData::getPrivData(JSObjectRef object)
+{
+ JSApplicationMetaDataPriv *priv = static_cast<JSApplicationMetaDataPriv*>(JSObjectGetPrivate(object));
+ if (!priv) {
+ throw TypeMismatchException("Private object is null");
+ }
+ ApplicationMetaDataPtr result = priv->getObject();
+ if (!result) {
+ throw TypeMismatchException("Private object is null");
+ }
+ return result;
+}
+
+
+JSValueRef JSApplicationMetaData::getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception)
+{
+ try {
+ CommonsJavaScript::Converter converter(context);
+ ApplicationMetaDataPtr privateData = getPrivData(object);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_META_DATA_KEY)) {
+ return converter.toJSValueRef(privateData->getKey());
+ } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_APPLICATION_META_DATA_VALUE)) {
+ std::string value = privateData->getValue();
+
+ // if key is not exist, return NULL
+ if (value.empty()) {
+ return JSValueMakeNull(context);
+ }
+
+ // if key does not have value, return empty string.
+ if (value.compare("(null)") == 0) {
+ value.clear();
+ }
+
+ return converter.toJSValueRef(value);
+ }
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::TypeMismatchException err("TypeMismatchException occured");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+
+ return JSValueMakeUndefined(context);
+}
+
+}
+}
--- /dev/null
+//
+// 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 TIZENAPIS_TIZEN_JS_APPLICATION_META_DATA_H_
+#define TIZENAPIS_TIZEN_JS_APPLICATION_META_DATA_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <dpl/shared_ptr.h>
+
+namespace DeviceAPI {
+namespace Application {
+
+#define TIZEN_INTERFACE_APPLICATION_META_DATA "ApplicationMetaData"
+
+#define TIZEN_APPLICATION_META_DATA_KEY "key"
+#define TIZEN_APPLICATION_META_DATA_VALUE "value"
+
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<ApplicationMetaDataPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationMetaDataPriv;
+
+class JSApplicationMetaData{
+public:
+ /*
+ * This initializes this JS class in the JS Engine.
+ */
+ static JSClassRef getClassRef();
+
+ static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+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);
+
+ /**
+ * This structure contains properties and callbacks that define a type of object.
+ */
+ static JSClassDefinition m_classInfo;
+
+ /**
+ * This member variable contains the initialization values for the static properties of this class.
+ * The values are given according to the data structure JSPropertySpec
+ */
+ static JSStaticValue m_property[];
+
+ static JSClassRef m_classRef;
+
+ static ApplicationMetaDataPtr getPrivData(JSObjectRef object);
+
+ static JSValueRef getProperty(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef propertyName,
+ JSValueRef* exception);
+
+};
+
+}
+}
+#endif
#include <cassert>
#include <memory>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/JSUtils.h>
+
#include <SecurityExceptions.h>
-#include <Commons/Exception.h>
-#include <JSWebAPIErrorFactory.h>
+#include <JSWebAPIError.h>
+#include <ArgumentValidator.h>
#include "plugin_config.h"
#include "ApplicationConverter.h"
initialize,
finalize,
NULL, //HasProperty,
- getProperty,
+ NULL,
NULL, //SetProperty,
NULL, //DeleteProperty,
NULL, //GetPropertyNames,
NULL, //CallAsFunction,
NULL, //CallAsConstructor,
- hasInstance,
+ NULL,
NULL, //ConvertToType
};
return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
}
- Try {
+ try {
RequestedApplicationControlPtr providerMgr = priv->getObject();
ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALLER_APP_ID)) {
return converter->toJSValueRef(providerMgr->getCallerAppId());
}
- } Catch(WrtDeviceApis::Commons::Exception) {
- LoggerE("Exception: "<< _rethrown_exception.GetMessage());
- return JSDOMExceptionFactory::UnknownException.make(context, exception);
+ } catch (const BasePlatformException &err) {
+ LoggerW("Getting property is failed. %s", err.getMessage().c_str());
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in RequestedApplicationControl.replyFailure().");
+ LoggerW("Getting property is failed. %s", err.getMessage().c_str());
}
/* do not return undefined object to find method */
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(thisObject));
- Try {
+ try {
if (!priv) {
ThrowMsg(ConversionException, "Object is null.");
}
- ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+ ArgumentValidator validator(context, argumentCount, arguments);
- RequestedApplicationControlPtr providerMgr = priv->getObject();
- std::vector<ApplicationControlDataPtr> resultArray;
- if (argumentCount > 0) {
- resultArray = converter->toApplicationControlDataArray(arguments[0]);
+ JSObjectRef dataArrayObj = validator.toArrayObject(0, true);
+ std::vector<ApplicationControlDataPtr> dataArray;
+ if (dataArrayObj) {
+ ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+ dataArray = converter->toApplicationControlDataArray(arguments[0]);
}
- providerMgr->replyResult(resultArray);
+ RequestedApplicationControlPtr providerMgr = priv->getObject();
+ providerMgr->replyResult(dataArray);
+
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- } Catch (ConversionException) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
- } Catch (NotFoundException) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
- } Catch (NullPointerException) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
- } Catch (Exception) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
- }
return JSValueMakeUndefined(context);
+
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch(const ConversionException& err) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "");
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in RequestedApplicationControl.replyResult().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
}
JSValueRef JSRequestedApplicationControl::replyFailure(JSContextRef context,
TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
JSRequestedApplicationControlPriv *priv = static_cast<JSRequestedApplicationControlPriv*>(JSObjectGetPrivate(thisObject));
- Try {
+ try {
if (!priv) {
ThrowMsg(ConversionException, "Object is null.");
}
RequestedApplicationControlPtr providerMgr = priv->getObject();
providerMgr->replyFailure();
+
TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- } Catch (NotFoundException) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
- } Catch (NullPointerException) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
- } Catch (Exception) {
- LoggerE("Exception: "<<_rethrown_exception.GetMessage());
- return JSWebAPIErrorFactory::postException(context, exception,JSWebAPIErrorFactory::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
- }
return JSValueMakeUndefined(context);
+
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in RequestedApplicationControl.replyFailure().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
}
}
<name>http://tizen.org/privilege/application.read</name>
<device-capability>appmanager.certificate</device-capability>
</api-feature>
+
+ <api-feature>
+ <name>http://tizen.org/privilege/application.info</name>
+ <device-capability>application.info</device-capability>
+ </api-feature>
</plugin-properties>
#define APPLICATION_FEATURE_API_KILL "http://tizen.org/privilege/application.kill"
#define APPLICATION_FEATURE_API_KILL2 "http://tizen.org/privilege/appmanager.kill"
#define APPLICATION_FEATURE_API_CERT "http://tizen.org/privilege/appmanager.certificate"
+#define APPLICATION_FEATURE_API_INFO "http://tizen.org/privilege/application.info"
+
// for backword compatibility
#define APPLICATION_FEATURE_API_READ "http://tizen.org/privilege/application.read"
#define APPLICATION_DEVICE_CAP_LAUNCH "application.launch"
#define APPLICATION_DEVICE_CAP_KILL "appmanager.kill"
#define APPLICATION_DEVICE_CAP_CERT "appmanager.certificate"
+#define APPLICATION_DEVICE_CAP_INFO "application.info"
//#define APPLICATION_DEVICE_CAP_READ "application.read"
//#define APPLICATION_DEVICE_CAP_INSTALL "application.install"
*/
ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_LAUNCH, APPLICATION_DEVICE_CAP_LAUNCH);
ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_KILL, APPLICATION_DEVICE_CAP_KILL);
- ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_CERT, APPLICATION_DEVICE_CAP_CERT);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_CERT, APPLICATION_DEVICE_CAP_CERT);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_INFO, APPLICATION_DEVICE_CAP_INFO);
ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_LAUNCH);
ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_KILL);
- ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_CERT);
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_CERT);
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_INFO);
+
ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_LAUNCH, DEVICE_CAP_APPLICATION_LAUNCH);
ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_KILL, DEVICE_CAP_APPLICATION_KILL);
- ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_CERT, DEVICE_CAP_APPLICATION_CERT);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_CERT, DEVICE_CAP_APPLICATION_CERT);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_INFO, DEVICE_CAP_APPLICATION_INFO);
#if 0
- ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
-
- ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_READ, APPLICATION_DEVICE_CAP_READ);
- ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_INSTALL, APPLICATION_DEVICE_CAP_INSTALL);
- ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_READ);
- ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_INSTALL);
- ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_READ, DEVICE_CAP_APPLICATION_READ);
- ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_INSTALL, DEVICE_CAP_APPLICATION_INSTALL);
+ ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
+
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_READ, APPLICATION_DEVICE_CAP_READ);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_APPLICATION_INSTALL, APPLICATION_DEVICE_CAP_INSTALL);
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_READ);
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_APPLICATION_INSTALL);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_READ, DEVICE_CAP_APPLICATION_READ);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_APPLICATION_INSTALL, DEVICE_CAP_APPLICATION_INSTALL);
#endif
/**
* Api Features
*/
ACE_CREATE_FEATURE(FEATURE_APPLICATION_LAUNCH, APPLICATION_FEATURE_API_LAUNCH);
- ACE_CREATE_FEATURE(FEATURE_APPLICATION_KILL, APPLICATION_FEATURE_API_KILL);
- ACE_CREATE_FEATURE(FEATURE_APPLICATION_KILL2, APPLICATION_FEATURE_API_KILL2);
- ACE_CREATE_FEATURE(FEATURE_APPLICATION_CERT, APPLICATION_FEATURE_API_CERT);
- ACE_CREATE_FEATURE(FEATURE_APPLICATION_READ, APPLICATION_FEATURE_API_READ);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_KILL, APPLICATION_FEATURE_API_KILL);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_KILL2, APPLICATION_FEATURE_API_KILL2);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_CERT, APPLICATION_FEATURE_API_CERT);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_READ, APPLICATION_FEATURE_API_READ);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_INFO, APPLICATION_FEATURE_API_INFO);
ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_LAUNCH);
ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_KILL);
ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_KILL, FEATURE_APPLICATION_KILL);
- ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_KILL, FEATURE_APPLICATION_KILL2);
+ ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_KILL, FEATURE_APPLICATION_KILL2);
+
+ ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_CERT);
+ ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_CERT, FEATURE_APPLICATION_CERT);
+ ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_CERT, FEATURE_APPLICATION_READ);
+
+ ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_INFO);
+ ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_INFO, FEATURE_APPLICATION_INFO);
- ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_CERT);
- ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_CERT, FEATURE_APPLICATION_CERT);
- ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_CERT, FEATURE_APPLICATION_READ);
#if 0
- ACE_CREATE_FEATURE(FEATURE_APPLICATION_READ, APPLICATION_FEATURE_API_READ);
- ACE_CREATE_FEATURE(FEATURE_APPLICATION_INSTALL, APPLICATION_FEATURE_API_INSTALL);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_READ, APPLICATION_FEATURE_API_READ);
+ ACE_CREATE_FEATURE(FEATURE_APPLICATION_INSTALL, APPLICATION_FEATURE_API_INSTALL);
ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_READ);
ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_READ, FEATURE_APPLICATION_READ);
APPLICATION_FUNCTION_API_GET_APP_CERTS,
getAppCertsFunc));
-
+ // getAppMetaData
+ AceFunction getAppMetaDataFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_GET_APP_META_DATA,
+ APPLICATION_FUNCTION_API_GET_APP_META_DATA,
+ APPLICATION_FEATURES_APPLICATION_INFO,
+ DEVICE_LIST_APPLICATION_INFO);
+
+ applicationMapping.insert(std::make_pair(
+ APPLICATION_FUNCTION_API_GET_APP_META_DATA,
+ getAppMetaDataFunc));
+
#if 0
// setUserAgent
#define APPLICATION_FUNCTION_API_REPLY_RESULT "replyResult"\r
#define APPLICATION_FUNCTION_API_REPLY_FAILURE "replyFailure"\r
#define APPLICATION_FUNCTION_API_GET_APP_SHARED_URI "getAppSharedURI"\r
+#define APPLICATION_FUNCTION_API_GET_APP_META_DATA "getAppMetaData"\r
#define APPLICATION_FUNCTION_API_SET_USER_AGENT "setUserAgent"\r
\r
namespace DeviceAPI {\r
#include <JSWebAPIErrorFactory.h>
#include <system_info.h>
#include <JSUtil.h>
+#include <TimeTracer.h>
#include "BluetoothAdapter.h"
#include "BluetoothCallbackUtil.h"
void BluetoothAdapter::onStateChangedCB(int result, bt_adapter_state_e adapterState, void *userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
BluetoothAdapterPtr object = static_cast<BluetoothAdapterPtr>(userData);
if(!object) {
LoggerW("userData is NULL");
return;
}
+
+ bool previousState = object->mEnabled;
object->mEnabled = (adapterState == BT_ADAPTER_ENABLED) ? true : false;
+ // call onstatechanged in ChangeListener
+ if(previousState != object->mEnabled && result == BT_ERROR_NONE && object->mChangeListener != NULL) {
+ LoggerD("call onstatechanged in ChangeListener");
+ object->mChangeListener->invokeCallback("onstatechanged", JSUtil::toJSValueRef(object->mChangeListener->getContext(), object->mEnabled));
+ }
+
+ // call a result callback of setPowered()
if(object->mUserDataList[SET_POWERED] != NULL) { // requested event
- bool state = (adapterState == BT_ADAPTER_ENABLED) ? true : false;
- if(object->mRequestedState != state) {
- LoggerW("Requested state is same to current state");
+ LoggerD("call a result callback of setPowered()");
+ if(object->mRequestedState != object->mEnabled) {
+ LoggerW("Requested state is not equal to current state");
return;
}
else { // unexpected event
LoggerW("Bluetooth state is changed unexpectedly");
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::onNameChangedCB(char *name, void *userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
BluetoothAdapterPtr object = static_cast<BluetoothAdapterPtr>(userData);
if(!object) {
LoggerW("userData is NULL");
return;
}
+
+ // call onnamechanged in ChangeListener
+ if(object->mChangeListener != NULL) {
+ LoggerD("call onnamechanged in ChangeListener");
+ object->mChangeListener->invokeCallback("onnamechanged", JSUtil::toJSValueRef(object->mChangeListener->getContext(), std::string(name)));
+ }
+ // call a result callback of setName()
if(object->mUserDataList[SET_NAME] != NULL && !strcmp(object->mRequestedName.c_str(), name)) { // requested event
MultiCallbackUserDataPtr callback = static_cast<MultiCallbackUserDataPtr>(object->mUserDataList[SET_NAME]);
object->mUserDataList[SET_NAME].reset();
if(callback)
callback->invokeCallback("success");
- bt_adapter_unset_name_changed_cb();
+ //bt_adapter_unset_name_changed_cb();
}
else { // unexpected event
LoggerW("Bluetooth name is changed unexpectedly");
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::onVisibilityChangedCB(int result, bt_adapter_visibility_mode_e visibilityMode, void *userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
BluetoothAdapterPtr object = static_cast<BluetoothAdapterPtr>(userData);
if(!object) {
LoggerW("userData is NULL");
return;
}
+ bool previousVisible = object->mVisible;
+ object->mVisible = (visibilityMode != BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) ? true : false;
+
+ // call onvisibilitychanged in ChangeListener
+ if(object->mChangeListener != NULL) {
+ if(previousVisible != object->mVisible) {
+ LoggerD("call onvisibilitychanged in ChangeListener");
+ object->mChangeListener->invokeCallback("onvisibilitychanged", JSUtil::toJSValueRef(object->mChangeListener->getContext(), object->mVisible));
+ }
+ }
+
+ // call a result callback of setVisible()
if(object->mUserDataList[SET_VISIBLE] != NULL) { // requested event
//bool visibility = (visibilityMode == BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) ? false : true;
if(object->mRequestedVisibility != visibilityMode) {
}
}
- bt_adapter_unset_visibility_mode_changed_cb();
+ //bt_adapter_unset_visibility_mode_changed_cb();
}
else { // unexpected event
LoggerW("Bluetooth visibility is changed unexpectedly");
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::onDiscoveryStateChangedCB(int result, bt_adapter_device_discovery_state_e discoveryState,
void BluetoothAdapter::onBondCreatedCB(int result, bt_device_info_s *deviceInfo, void *userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
BluetoothAdapterPtr object = static_cast<BluetoothAdapterPtr>(userData);
if(!object) {
LoggerW("userData is NULL");
else { // unexpected event
LoggerW("A bonding is created unexpectedly");
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::onBondDestroyedCB(int result, char *remoteAddress, void *userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
BluetoothAdapterPtr object = static_cast<BluetoothAdapterPtr>(userData);
if(!object) {
LoggerW("userData is NULL");
else { // unexpected event
LoggerW("A bonding is destroyed unexpectedly");
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::onSocketConnected(int result, bt_socket_connection_state_e state, bt_socket_connection_s *connection, void *userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
BluetoothAdapterPtr object = static_cast<BluetoothAdapterPtr>(userData);
if(!object) {
LoggerW("userData is NULL");
if(object->mRegisteredUUID.size() == 0 && object->mConnReqMap.size() == 0 && object->mConnectedSocket.size() == 0) {
bt_socket_unset_connection_state_changed_cb();
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::onSocketReceivedCB(bt_socket_received_data_s *data, void *userData)
}
BluetoothAdapter::BluetoothAdapter():
- mEnabled(false)
+ mEnabled(false), mVisible(false)
{
- if(bt_initialize() != BT_ERROR_NONE) {
- LoggerE("bt_initialize() failed");
- }
-
bt_adapter_state_e state;
if (bt_adapter_get_state(&state) == BT_ERROR_NONE) {
if (state == BT_ADAPTER_ENABLED) {
mEnabled = true;
}
- }
+ }
+
+ bt_adapter_visibility_mode_e mode;
+ if (bt_adapter_get_visibility(&mode, NULL) == BT_ERROR_NONE) {
+ if (mode != BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE) {
+ mVisible = true;
+ }
+ }
if(bt_adapter_set_state_changed_cb(onStateChangedCB, this) != BT_ERROR_NONE) {
LoggerE("bt_adapter_set_state_changed_cb() failed");
if(bt_adapter_set_device_discovery_state_changed_cb(onDiscoveryStateChangedCB, this) != BT_ERROR_NONE) {
LoggerE("bt_adapter_set_device_discovery_state_changed_cb() failed");
- }
+ }
+
+ if(bt_adapter_set_name_changed_cb(onNameChangedCB, this) != BT_ERROR_NONE) {
+ LoggerE("bt_adapter_set_name_changed_cb() failed");
+ }
+
+ if(bt_adapter_set_visibility_mode_changed_cb(onVisibilityChangedCB, this) != BT_ERROR_NONE) {
+ LoggerE("bt_adapter_set_visibility_mode_changed_cb() failed");
+ }
}
BluetoothAdapter::~BluetoothAdapter()
char* name = NULL;
std::string str = "";
+ TIME_TRACER_ITEM_BEGIN("getName::bt_adapter_get_name", 1);
if(bt_adapter_get_name(&name) == BT_ERROR_NONE) {
+ TIME_TRACER_ITEM_END("getName::bt_adapter_get_name", 1);
if (name != NULL)
{
str = name;
}
}
else {
+ TIME_TRACER_ITEM_END("getName::bt_adapter_get_name", 1);
LoggerE("bt_adapter_get_name() failed");
}
}
if(mUserDataList[SET_NAME] == NULL) {
- bt_adapter_set_name_changed_cb(onNameChangedCB, this);
mUserDataList[SET_NAME] = userData;
} else {
LoggerE("Already requested");
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
return;
}
-
+
+ TIME_TRACER_ITEM_BEGIN("setName::bt_adapter_set_name", 1);
int ret = bt_adapter_set_name(name.c_str());
+ TIME_TRACER_ITEM_END("setName::bt_adapter_set_name", 1);
switch(ret) {
case BT_ERROR_NONE:
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
}
}
-
- bt_adapter_unset_name_changed_cb();
+
+ //TIME_TRACER_ITEM_BEGIN("setName::bt_adapter_unset_name_changed_cb", 1);
+ //bt_adapter_unset_name_changed_cb();
+ //TIME_TRACER_ITEM_END("setName::bt_adapter_unset_name_changed_cb", 1);
mUserDataList[SET_NAME].reset();
} else { // Not enabled
LoggerE("Bluetooth device is turned off");
void BluetoothAdapter::setPowered(bool powered, MultiCallbackUserDataPtr userData)
{
+ TIME_TRACER_ITEM_BEGIN("setPowered::check current state", 1);
+
if(powered == mEnabled) {
LoggerD("same state");
BluetoothCallbackUtil::syncToAsyncSuccessCallback(userData);
return;
}
+ TIME_TRACER_ITEM_END("setPowered::check current state", 1);
+
mRequestedState = powered;
if(powered == true) {
+ TIME_TRACER_ITEM_BEGIN("setPowered::bt_adapter_enable", 1);
int ret = bt_adapter_enable();
+ TIME_TRACER_ITEM_END("setPowered::bt_adapter_enable", 1);
switch(ret) {
case BT_ERROR_NONE:
}
}
} else {
+ TIME_TRACER_ITEM_BEGIN("setPowered::bt_adapter_disable", 1);
int ret = bt_adapter_disable();
+ TIME_TRACER_ITEM_END("setPowered::bt_adapter_disable", 1);
switch(ret) {
case BT_ERROR_NONE:
bool BluetoothAdapter::getVisible() const
{
+/*
bt_adapter_visibility_mode_e mode;
if (bt_adapter_get_visibility(&mode, NULL) == BT_ERROR_NONE) {
}
return false;
+*/
+ return mVisible;
}
void BluetoothAdapter::setVisible(bool visible, unsigned int timeout, MultiCallbackUserDataPtr userData)
bt_adapter_visibility_mode_e current = BT_ADAPTER_VISIBILITY_MODE_NON_DISCOVERABLE;
int time = 0;
+
+ TIME_TRACER_ITEM_BEGIN("setVisible::bt_adapter_get_visibility", 1);
if(bt_adapter_get_visibility(¤t , &time) != BT_ERROR_NONE) {
LoggerE("bt_adapter_get_visibility() failed");
UnknownException *error = new UnknownException("Can't get current visibility");
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
return;
}
+ TIME_TRACER_ITEM_END("setVisible::bt_adapter_get_visibility", 1);
if(discoverable_mode == current) {
if(discoverable_mode != BT_ADAPTER_VISIBILITY_MODE_LIMITED_DISCOVERABLE) {
}
if(mUserDataList[SET_VISIBLE] == NULL) {
- bt_adapter_set_visibility_mode_changed_cb(onVisibilityChangedCB, this);
mUserDataList[SET_VISIBLE] = userData;
} else {
UnknownException *error = new UnknownException("Already requested");
return;
}
- mRequestedVisibility = discoverable_mode;
+ mRequestedVisibility = discoverable_mode;
+ TIME_TRACER_ITEM_BEGIN("setVisible::bt_adapter_set_visibility", 1);
int ret = bt_adapter_set_visibility(discoverable_mode, timeout);
+ TIME_TRACER_ITEM_END("setVisible::bt_adapter_set_visibility", 1);
switch(ret) {
case BT_ERROR_NONE:
{
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
}
}
-
+
+ /*
+ TIME_TRACER_ITEM_BEGIN("setVisible::bt_adapter_unset_visibility_mode_changed_cb", 1);
bt_adapter_unset_visibility_mode_changed_cb();
+ TIME_TRACER_ITEM_END("setVisible::bt_adapter_unset_visibility_mode_changed_cb", 1);
+ */
mUserDataList[SET_VISIBLE].reset();
} else { // Not enabled
ServiceNotAvailableException *error = new ServiceNotAvailableException("Bluetooth device is turned off");
void BluetoothAdapter::discoverDevices(MultiCallbackUserDataPtr userData)
{
+ TIME_TRACER_ITEM_BEGIN("discoverDevices::current state", 1);
+
if(mUserDataList[DISCOVER_DEVICES] == NULL) {
mUserDataList[DISCOVER_DEVICES] = userData;
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
return;
}
+
+ TIME_TRACER_ITEM_END("discoverDevices::current state", 1);
- if(mEnabled == true) {
+ if(mEnabled == true) {
+ TIME_TRACER_ITEM_BEGIN("discoverDevices::bt_adapter_start_device_discovery", 1);
int ret = bt_adapter_start_device_discovery();
+ TIME_TRACER_ITEM_END("discoverDevices::bt_adapter_start_device_discovery", 1);
switch(ret) {
case BT_ERROR_NONE:
{
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
return;
}
-
+
+ TIME_TRACER_ITEM_BEGIN("stopDiscovery::bt_adapter_stop_device_discovery", 1);
int ret = bt_adapter_stop_device_discovery();
+ TIME_TRACER_ITEM_END("stopDiscovery::bt_adapter_stop_device_discovery", 1);
switch(ret) {
case BT_ERROR_NONE:
{
}
if(mUserDataList[CREATE_BONDING] == NULL) {
+ TIME_TRACER_ITEM_BEGIN("createBonding::bt_device_set_bond_created_cb", 1);
bt_device_set_bond_created_cb(onBondCreatedCB, this);
+ TIME_TRACER_ITEM_END("createBonding::bt_device_set_bond_created_cb", 1);
mCreateBondingAddress = address;
mUserDataList[CREATE_BONDING] = userData;
} else {
}
if(mEnabled == true) {
+ TIME_TRACER_ITEM_BEGIN("createBonding::bt_device_create_bond", 1);
int ret = bt_device_create_bond(address.c_str());
+ TIME_TRACER_ITEM_END("createBonding::bt_device_create_bond", 1);
switch(ret) {
case BT_ERROR_NONE:
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
}
+ TIME_TRACER_ITEM_BEGIN("createBonding::bt_device_unset_bond_created_cb", 1);
bt_device_unset_bond_created_cb();
+ TIME_TRACER_ITEM_END("createBonding::bt_device_unset_bond_created_cb", 1);
mCreateBondingAddress.clear();
mUserDataList[CREATE_BONDING].reset();
}
}
if(mUserDataList[DESTROY_BONDING] == NULL) {
+ TIME_TRACER_ITEM_BEGIN("destroyBonding::bt_device_set_bond_destroyed_cb", 1);
bt_device_set_bond_destroyed_cb(onBondDestroyedCB, this);
+ TIME_TRACER_ITEM_END("destroyBonding::bt_device_set_bond_destroyed_cb", 1);
mDestroyBondingAddress = address;
mUserDataList[DESTROY_BONDING] = userData;
} else {
if(mEnabled == true) {
bt_device_info_s *deviceInfo = NULL;
+ TIME_TRACER_ITEM_BEGIN("destroyBonding::bt_adapter_get_bonded_device_info", 1);
if(bt_adapter_get_bonded_device_info(address.c_str(), &deviceInfo) != BT_ERROR_NONE || deviceInfo == NULL) {
+ TIME_TRACER_ITEM_END("destroyBonding::bt_adapter_get_bonded_device_info", 1);
LoggerD("There is no bonding");
NotFoundException *error = new NotFoundException("Not found");
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
}
else {
+ TIME_TRACER_ITEM_END("destroyBonding::bt_adapter_get_bonded_device_info", 1);
bt_adapter_free_device_info(deviceInfo);
+ TIME_TRACER_ITEM_BEGIN("destroyBonding::bt_device_destroy_bond", 1);
int ret = bt_device_destroy_bond(address.c_str());
+ TIME_TRACER_ITEM_END("destroyBonding::bt_device_destroy_bond", 1);
switch(ret) {
case BT_ERROR_NONE:
BluetoothCallbackUtil::syncToAsyncErrorCallback(userData, error);
}
+ TIME_TRACER_ITEM_BEGIN("destroyBonding::bt_device_unset_bond_destroyed_cb", 1);
bt_device_unset_bond_destroyed_cb();
+ TIME_TRACER_ITEM_END("destroyBonding::bt_device_unset_bond_destroyed_cb", 1);
+
mDestroyBondingAddress.clear();
mUserDataList[DESTROY_BONDING].reset();
}
if(mEnabled == true) {
+ TIME_TRACER_ITEM_BEGIN("connectToServiceByUUID::bt_socket_connect_rfcomm", 1);
int ret = bt_socket_connect_rfcomm(remoteAddress.c_str(), uuid.c_str());
+ TIME_TRACER_ITEM_END("connectToServiceByUUID::bt_socket_connect_rfcomm", 1);
switch(ret) {
case BT_ERROR_NONE:
{
LoggerD("bt_socket_connect_rfcomm() succeeded");
+ TIME_TRACER_ITEM_BEGIN("connectToServiceByUUID::bt_socket_set_connection_state_changed_cb", 1);
bt_socket_set_connection_state_changed_cb(onSocketConnected, this);
+ TIME_TRACER_ITEM_END("connectToServiceByUUID::bt_socket_set_connection_state_changed_cb", 1);
BluetoothConnReqPtr connReq = new BluetoothConnReq(uuid, userData);
mConnReqMap.insert(std::pair<std::string, BluetoothConnReqPtr>(remoteAddress, connReq));
void BluetoothAdapter::returnDevice(std::string &address, Common::MultiCallbackUserDataPtr userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
if(!isValidAddress(address)) {
LoggerE("Wrong address");
userData->invokeCallback("error", JSWebAPIErrorFactory::makeErrorObject(userData->getContext(), NotFoundException("Wrong address")));
if(mEnabled == true) {
bt_device_info_s *deviceInfo = NULL;
+
+ TIME_TRACER_ITEM_BEGIN("returnDevice::bt_adapter_get_bonded_device_info", 1);
if(bt_adapter_get_bonded_device_info(address.c_str(), &deviceInfo) == BT_ERROR_NONE &&
- deviceInfo != NULL) {
+ deviceInfo != NULL) {
+ TIME_TRACER_ITEM_END("returnDevice::bt_adapter_get_bonded_device_info", 1);
BluetoothDeviceSharedPtr device(new BluetoothDevice(deviceInfo));
bt_adapter_free_device_info(deviceInfo);
LoggerD("invoke successCallback");
userData->invokeCallback("success", JSBluetoothDevice::createJSObject(userData->getContext(), device));
+ TIME_TRACER_ITEM_END("returnDevice::bt_adapter_get_bonded_device_info", 1);
return;
}
JSWebAPIErrorFactory::makeErrorObject(userData->getContext(), ServiceNotAvailableException("Bluetooth device is turned off"))
);
}
+
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
}
void BluetoothAdapter::returnRegisteredService(std::string &uuid, std::string &name, Common::MultiCallbackUserDataPtr userData)
{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
if(!isValidUUID(uuid)) {
LoggerE("Wrong UUID");
userData->invokeCallback("error", JSWebAPIErrorFactory::makeErrorObject(userData->getContext(), InvalidValuesException("Wrong UUID")));
if(mEnabled == true) {
bool isRegistered;
+ TIME_TRACER_ITEM_BEGIN("returnRegisteredService::bt_adapter_is_service_used", 1);
if(bt_adapter_is_service_used(uuid.c_str(), &isRegistered) == BT_ERROR_NONE && isRegistered == true) {
+ TIME_TRACER_ITEM_END("returnRegisteredService::bt_adapter_is_service_used", 1);
LoggerD("Already registered");
userData->invokeCallback("error", JSWebAPIErrorFactory::makeErrorObject(userData->getContext(), InvalidValuesException("Already registered")));
return;
- }
+ }
+ TIME_TRACER_ITEM_END("returnRegisteredService::bt_adapter_is_service_used", 1);
int socket = -1;
+ TIME_TRACER_ITEM_BEGIN("returnRegisteredService::bt_socket_create_rfcomm", 1);
int ret = bt_socket_create_rfcomm(uuid.c_str(), &socket);
+ TIME_TRACER_ITEM_END("returnRegisteredService::bt_socket_create_rfcomm", 1);
switch(ret) {
case BT_ERROR_NONE:
{
LoggerD("bt_socket_create_rfcomm() succeeded");
+ TIME_TRACER_ITEM_BEGIN("returnRegisteredService::bt_socket_listen_and_accept_rfcomm", 1);
int ret = bt_socket_listen_and_accept_rfcomm(socket, 0);
+ TIME_TRACER_ITEM_END("returnRegisteredService::bt_socket_listen_and_accept_rfcomm", 1);
switch(ret) {
case BT_ERROR_NONE:
{
JSWebAPIErrorFactory::makeErrorObject(userData->getContext(), ServiceNotAvailableException("Bluetooth device is turned off"))
);
}
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+}
+
+void BluetoothAdapter::setChangeListener(MultiCallbackUserDataPtr userData)
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ LoggerD("Enter");
+ mChangeListener = userData;
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+}
+
+void BluetoothAdapter::unsetChangeListener()
+{
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ LoggerD("Enter");
+ mChangeListener.reset();
+
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
}
void unregisterUUID(std::string &uuid);
bool closeConnectedSocket(int socket);
void removeConnReq(std::string &remoteAddress);
+
+ void setChangeListener(Common::MultiCallbackUserDataPtr userData);
+ void unsetChangeListener();
static BluetoothAdapter* getInstance();
static bool isValidAddress(std::string &address);
typedef std::map<int, BluetoothSocketPtr> ConnectedSocketMapT; // <socketFD, BluetoothSocketPtr>
bool mEnabled;
+ bool mVisible;
ConnReqMultiMapT mConnReqMap;
RegisteredUUIDMapT mRegisteredUUID;
ConnectedSocketMapT mConnectedSocket;
std::vector<std::string> mDisappearedDevices;
std::vector<BluetoothDeviceSharedPtr> mFoundDevices;
std::vector<BluetoothDeviceSharedPtr> knownDevices;
+ Common::MultiCallbackUserDataPtr mChangeListener;
};
typedef BluetoothAdapter* BluetoothAdapterPtr;
--- /dev/null
+//\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
--- /dev/null
+//\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
if(mCBType == BT_CB_ERROR)
delete mError;
};
-
+
callbackTypeE mCBType;
DeviceAPI::Common::MultiCallbackUserDataPtr mUserData;
class BluetoothCallbackUtil
{
-public:
+public:
static void syncToAsyncSuccessCallback(DeviceAPI::Common::MultiCallbackUserDataPtr userData);
static void syncToAsyncErrorCallback(DeviceAPI::Common::MultiCallbackUserDataPtr userData, Common::BasePlatformException *error);
static void syncToAsyncDeviceCallback(DeviceAPI::Common::MultiCallbackUserDataPtr userData, std::string &address);
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+// 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
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
#include "plugin_config.h"
#include <Logger.h>
+#include <TimeTracer.h>
using namespace DeviceAPI::Common;
mIsConnected = isConnected;
}
-bool BluetoothServiceHandler::getConnectionState()
+bool BluetoothServiceHandler::getConnectionState() const
{
return mIsConnected;
}
void BluetoothServiceHandler::unregister(MultiCallbackUserDataPtr userData)
{
if(BluetoothAdapter::getInstance()->getPowered() == true) {
+ TIME_TRACER_ITEM_BEGIN("unregister::bt_socket_destroy_rfcomm", 1);
if(bt_socket_destroy_rfcomm(mRegisteredSocket) == BT_ERROR_NONE) {
+ TIME_TRACER_ITEM_END("unregister::bt_socket_destroy_rfcomm", 1);
mIsRegistered = false;
BluetoothAdapter::getInstance()->unregisterUUID(mUUID);
BluetoothCallbackUtil::syncToAsyncSuccessCallback(userData);
std::string getUUID() const;
std::string getName() const;
int getRegisteredSocket() const;
- bool getConnectionState();
+ bool getConnectionState() const;
Common::MultiCallbackUserDataPtr getOnConnect() const;
JSValueRef getOnConnect(JSContextRef context);
#include "JSBluetoothDevice.h"
#include <Logger.h>
+#include <TimeTracer.h>
using namespace DeviceAPI::Common;
unsigned long BluetoothSocket::writeData(char* data, unsigned long size)
{
unsigned long ret = 0;
+ TIME_TRACER_ITEM_BEGIN("writeData::bt_socket_send_data", 1);
if(bt_socket_send_data(mConnectedSocket, data, static_cast<int>(size)) == BT_ERROR_NONE) {
+ TIME_TRACER_ITEM_END("writeData::bt_socket_send_data", 1);
LoggerD("bt_socket_send_data() succeeded");
ret = size;
}
else {
+ TIME_TRACER_ITEM_END("writeData::bt_socket_send_data", 1);
throw UnknownException("Unknown error");
}
- delete data;
+ //delete data;
return ret;
}
LoggerD("Already disconnected");
return;
}
-
+
+ TIME_TRACER_ITEM_BEGIN("close::bt_socket_disconnect_rfcomm", 1);
if(bt_socket_disconnect_rfcomm(mConnectedSocket) != BT_ERROR_NONE) {
+ TIME_TRACER_ITEM_END("close::bt_socket_disconnect_rfcomm", 1);
LoggerE("bt_socket_disconnect_rfcomm() failed");
throw UnknownException("Unknown error");
- }
+ }
+ TIME_TRACER_ITEM_END("close::bt_socket_disconnect_rfcomm", 1);
mIsConnected = false;
}
JSBluetoothClassDeviceMinor.cpp
JSBluetoothClassDeviceService.cpp
JSBluetoothServiceHandler.cpp
+ JSBluetoothHealthApplication.cpp
+ JSBluetoothHealthChannel.cpp
+ JSBluetoothProfileHandler.cpp
+ JSBluetoothHealthProfileHandler.cpp
BluetoothAdapter.cpp
BluetoothDevice.cpp
BluetoothSocket.cpp
BluetoothClassDeviceService.cpp
BluetoothServiceHandler.cpp
BluetoothCallbackUtil.cpp
+ BluetoothCallback.cpp
+ BluetoothHealthApplication.cpp
+ BluetoothHealthChannel.cpp
+ BluetoothHealthProfileHandlerCallback.cpp
+ BluetoothHealthProfileHandler.cpp
)
-# BluetoothManager.cpp
INCLUDE_DIRECTORIES(
${INCLUDE_COMMON}
#include "plugin_config.h"
#include "JSBluetoothAdapter.h"
#include "BluetoothAdapter.h"
+#include "JSBluetoothHealthProfileHandler.h"
#include <TimeTracer.h>
#include <Logger.h>
{ BLUETOOTH_ADAPTER_API_CREATE_BONDING, createBonding, kJSPropertyAttributeNone },
{ BLUETOOTH_ADAPTER_API_DESTROY_BONDING, destroyBonding, kJSPropertyAttributeNone },
{ BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID, registerRFCOMMServiceByUUID, kJSPropertyAttributeNone },
+ { BLUETOOTH_ADAPTER_API_GET_BLUETOOTH_PROFILE_HANDLER, getBluetoothProfileHandler, kJSPropertyAttributeNone },
+ { BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER, setChangeListener, kJSPropertyAttributeNone },
+ { BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER, unsetChangeListener, kJSPropertyAttributeNone },
{ 0, 0, 0 }
};
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("setName::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_SET_NAME);
+ TIME_TRACER_ITEM_END("setName::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->setName(name, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("setPowered::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_SET_POWERED);
+ TIME_TRACER_ITEM_END("setPowered::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->setPowered(state, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("setVisible::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_SET_VISIBLE);
+ TIME_TRACER_ITEM_END("setVisible::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->setVisible(mode, timeout, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("discoverDevices::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_DISCOVER_DEVICES);
+ TIME_TRACER_ITEM_END("discoverDevices::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
+ TIME_TRACER_ITEM_BEGIN("discoverDevices::parameter", 1);
+
// Validate arguments
ArgumentValidator validator(context, argumentCount, arguments);
callback->setCallback("error", errorCallback);
}
+ TIME_TRACER_ITEM_END("discoverDevices::parameter", 1);
// perform
BluetoothAdapter::getInstance()->discoverDevices(callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("stopDiscovery::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_STOP_DISCOVERY);
+ TIME_TRACER_ITEM_END("stopDiscovery::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->stopDiscovery(callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("getKnownDevices::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_GET_KNOWN_DEVICES);
+ TIME_TRACER_ITEM_END("getKnownDevices::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->getKnownDevices(callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("getDevice::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_GET_DEVICE);
+ TIME_TRACER_ITEM_END("getDevice::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->getDevice(address, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("createBonding::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_CREATE_BONDING);
+ TIME_TRACER_ITEM_END("createBonding::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->createBonding(address, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("destroyBonding::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_DESTROY_BONDING);
+ TIME_TRACER_ITEM_END("destroyBonding::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->destroyBonding(address, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("registerRFCOMMServiceByUUID::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID);
+ TIME_TRACER_ITEM_END("registerRFCOMMServiceByUUID::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->registerRFCOMMServiceByUUID(uuid, name, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
}
}
+JSValueRef JSBluetoothAdapter::getBluetoothProfileHandler(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ try {
+ // Validate arguments
+ ArgumentValidator validator(context, argumentCount, arguments);
+ std::string type = validator.toString(0); // profileType
+
+ // perform
+ JSObjectRef profileHandler;
+ bool isCorrectParameter = false;
+ if(type.compare("HEALTH") == 0) {
+ isCorrectParameter = true;
+ profileHandler = JSBluetoothHealthProfileHandler::createJSObject(context);
+ }
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
+
+ if(!isCorrectParameter) {
+ throw InvalidValuesException("Invalid Value");
+ }
+
+ return profileHandler;
+ } catch (const BasePlatformException &err) {
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in BluetoothAdapter.registerRFCOMMServiceByUUID().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSBluetoothAdapter::setChangeListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ try {
+ // Validate arguments
+ ArgumentValidator validator(context, argumentCount, arguments);
+ JSObjectRef changeCallbackObj = validator.toCallbackObject(0, false, "onstatechanged", "onnamechanged", "onvisibilitychanged", NULL);
+
+ MultiCallbackUserDataPtr callback(
+ new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+ if(!callback){
+ LoggerW("Can't create MultiMultiCallbackUserData");
+ }
+ else {
+ // onstatechanged
+ JSValueRef onstatechangedValue = JSUtil::getProperty(context , changeCallbackObj, "onstatechanged");
+ if(!JSValueIsUndefined(context, onstatechangedValue)) {
+ LoggerD("There is a onstatechanged()");
+ callback->setCallback("onstatechanged", JSUtil::JSValueToObject(context, onstatechangedValue));
+ }
+
+ // onnamechanged
+ JSValueRef onnamechangedValue = JSUtil::getProperty(context , changeCallbackObj, "onnamechanged");
+ if(!JSValueIsUndefined(context, onnamechangedValue)) {
+ LoggerD("There is a onnamechanged()");
+ callback->setCallback("onnamechanged", JSUtil::JSValueToObject(context, onnamechangedValue));
+ }
+
+ // onvisibilitychanged
+ JSValueRef onvisibilitychangedValue = JSUtil::getProperty(context , changeCallbackObj, "onvisibilitychanged");
+ if(!JSValueIsUndefined(context, onvisibilitychangedValue)) {
+ LoggerD("There is a onvisibilitychanged()");
+ callback->setCallback("onvisibilitychanged", JSUtil::JSValueToObject(context, onvisibilitychangedValue));
+ }
+ }
+
+ // perform
+ BluetoothAdapter::getInstance()->setChangeListener(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 in BluetoothAdapter.registerRFCOMMServiceByUUID().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSBluetoothAdapter::unsetChangeListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Enter");
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
+
+ try {
+ // perform
+ BluetoothAdapter::getInstance()->unsetChangeListener();
+ 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 in BluetoothAdapter.registerRFCOMMServiceByUUID().");
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
} // Bluetooth
} // DeviceAPI
const JSValueRef arguments[],
JSValueRef* exception);
+ static JSValueRef getBluetoothProfileHandler(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef setChangeListener(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef unsetChangeListener(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.
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("hasService::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_CLASS_API_HAS_SERVICE);
+ TIME_TRACER_ITEM_END("hasService::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
ArgumentValidator validator(context, argumentCount, arguments);
unsigned long service = validator.toULong(0); // uuid
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ JSValueRef result = JSUtil::toJSValueRef(context, priv->mClass->hasService(service));
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
- return JSUtil::toJSValueRef(context, priv->mClass->hasService(service));
+ return result;
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
} catch (...) {
return JSObjectMake(context, getClassRef(), static_cast<void*>(holder));
}
+BluetoothDeviceSharedPtr JSBluetoothDevice::toBluetoothDevice(JSObjectRef deviceObj)
+{
+ BluetoothDeviceHolderPtr priv = static_cast<BluetoothDeviceHolderPtr>(JSObjectGetPrivate(deviceObj));
+ return priv->mDevice;
+}
+
void JSBluetoothDevice::initialize(JSContextRef context, JSObjectRef object)
{
// Do nothing
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("connectToServiceByUUID::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_DEVICE_API_CONNECT_TO_SERVICE_BY_UUID);
+ TIME_TRACER_ITEM_END("connectToServiceByUUID::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
BluetoothAdapter::getInstance()->connectToServiceByUUID(remoteAddress, uuid, callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
static const JSClassDefinition* getClassInfo();
static const JSClassRef getClassRef();
static JSObjectRef createJSObject(JSContextRef context, BluetoothDeviceSharedPtr device);
+ static BluetoothDeviceSharedPtr toBluetoothDevice(JSObjectRef deviceObj);
private:
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
--- /dev/null
+//\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
#include <GlobalContextManager.h>
#include <PlatformException.h>
#include <PropertyBag.h>
+#include <bluetooth.h>
#include "plugin_config.h"
#include "JSBluetoothManager.h"
#include "JSBluetoothClassDeviceMajor.h"
#include "JSBluetoothClassDeviceMinor.h"
#include "JSBluetoothClassDeviceService.h"
-//#include "BluetoothManager.h"
#include "JSBluetoothAdapter.h"
#include "BluetoothAdapter.h"
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN("getDefaultAdapter", 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("getDefaultAdapter::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_MANAGER_API_GET_DEFAULT_ADAPTER);
+ TIME_TRACER_ITEM_END("getDefaultAdapter::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return JSBluetoothAdapter::createJSObject(context);
+ JSObjectRef adapter = JSBluetoothAdapter::createJSObject(context);
+
+ if(bt_initialize() != BT_ERROR_NONE) {
+ LoggerE("bt_initialize() failed");
+ }
+
+ TIME_TRACER_ITEM_END("getDefaultAdapter", 1);
+ return adapter;
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
--- /dev/null
+//\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
--- /dev/null
+//\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
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);
// Access Check
+ TIME_TRACER_ITEM_BEGIN("unregister::ACE", 1);
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER);
+ TIME_TRACER_ITEM_END("unregister::ACE", 1);
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
priv->unregister(callback);
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
// Access Check
+ TIME_TRACER_ITEM_BEGIN("writeData::ACE", 1);;
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SOCKET_API_WRITE_DATA);
+ TIME_TRACER_ITEM_END("writeData::ACE", 1);;
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
JSValueRef element = JSGetArrayElement(context, dataArrayObj, i);
buffer[i] = static_cast<char>(JSUtil::JSValueToByte(context, element));
}
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
- return JSUtil::toJSValueRef(context, priv->writeData(buffer, size));
+ JSValueRef result = JSUtil::toJSValueRef(context, priv->writeData(buffer, size));
+ delete buffer;
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
+
+ return result;
} catch (const BasePlatformException &err) {
return JSWebAPIErrorFactory::postException(context, exception, err);
} catch (...) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
// Access Check
+ TIME_TRACER_ITEM_BEGIN("readData::ACE", 1);;
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SOCKET_API_READ_DATA);
+ TIME_TRACER_ITEM_END("readData::ACE", 1);;
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
std::vector<signed char> data = priv->readData();
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
return JSUtil::toJSValueRef_(context, data);
} catch (const BasePlatformException &err) {
const JSValueRef arguments[],
JSValueRef* exception)
{
- TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_BEGIN(__FUNCTION__, 1);;
// Access Check
+ TIME_TRACER_ITEM_BEGIN("close::ACE", 1);;
AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(BLUETOOTH_SOCKET_API_CLOSE);
+ TIME_TRACER_ITEM_END("close::ACE", 1);;
TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
try {
}
priv->close();
- TIME_TRACER_ITEM_END(__FUNCTION__, 0);
+ TIME_TRACER_ITEM_END(__FUNCTION__, 1);;
return JSValueMakeUndefined(context);
} catch (const BasePlatformException &err) {
#define BLUETOOTH_FEATURE_API_GAP "http://tizen.org/privilege/bluetooth.gap"
#define BLUETOOTH_FEATURE_API_SPP "http://tizen.org/privilege/bluetooth.spp"
#define BLUETOOTH_FEATURE_API_MANAGER "http://tizen.org/privilege/bluetoothmanager"
+#define BLUETOOTH_FEATURE_API_HDP "http://tizen.org/privilege/bluetooth.health"
#define BLUETOOTH_DEVICE_CAP_ADMIN "bluetooth.admin"
#define BLUETOOTH_DEVICE_CAP_GAP "bluetooth.gap"
#define BLUETOOTH_DEVICE_CAP_SPP "bluetooth.spp"
#define BLUETOOTH_DEVICE_CAP_MANAGER "bluetoothmanager"
+#define BLUETOOTH_DEVICE_CAP_HDP "bluetooth.health"
+
using namespace WrtDeviceApis::Commons;
ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_MANAGER, BLUETOOTH_DEVICE_CAP_MANAGER);
ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_MANAGER);
ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_MANAGER, DEVICE_CAP_BLUETOOTH_MANAGER);
+
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_HDP, BLUETOOTH_DEVICE_CAP_HDP);
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_HDP);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_HDP, DEVICE_CAP_BLUETOOTH_HDP);
/**
ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_MANAGER, FEATURE_MANAGER);
ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_MANAGER, FEATURE_ADMIN); // for backward compatibility
+ ACE_CREATE_FEATURE(FEATURE_HDP, BLUETOOTH_FEATURE_API_HDP);
+ ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_HDP);
+ ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_HDP, FEATURE_HDP);
+
/**
* Functions
BLUETOOTH_ADAPTER_API_SET_VISIBLE,
setVisibleFunc));
+ // setChangeListener()
+ AceFunction setChangeListenerFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER,
+ BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER,
+ BLUETOOTH_FEATURES_BLUETOOTH_ADMIN,
+ DEVICE_LIST_BLUETOOTH_ADMIN);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER,
+ setChangeListenerFunc));
+
+ // unsetChangeListener()
+ AceFunction unsetChangeListenerFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER,
+ BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER,
+ BLUETOOTH_FEATURES_BLUETOOTH_ADMIN,
+ DEVICE_LIST_BLUETOOTH_ADMIN);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER,
+ unsetChangeListenerFunc));
+
// discoverDevices()
AceFunction discoverDevicesFunc = ACE_CREATE_FUNCTION(
FUNCTION_BLUETOOTH_ADAPTER_API_DISCOVER_DEVICES,
BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER,
unregisterFunc));
+ // registerSinkApplication()
+ AceFunction registerSinkApplicationFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION,
+ BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION,
+ registerSinkApplicationFunc));
+
+ // connectToSource()
+ AceFunction connectToSourceFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE,
+ BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE,
+ connectToSourceFunc));
+
+ // unregister()
+ AceFunction unregisterHDPFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER,
+ BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER,
+ unregisterHDPFunc));
+
+ // close()
+ AceFunction closeHDPFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_CHANNEL_API_CLOSE,
+ BLUETOOTH_HEALTH_CHANNEL_API_CLOSE,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_CHANNEL_API_CLOSE,
+ closeHDPFunc));
+
+ // sendData()
+ AceFunction sendDataFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA,
+ BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA,
+ sendDataFunc));
+
+ // setListener()
+ AceFunction setListenerFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER,
+ BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER,
+ setListenerFunc));
+
+ // unsetListener()
+ AceFunction unsetListenerFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER,
+ BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER,
+ BLUETOOTH_FEATURES_BLUETOOTH_HDP,
+ DEVICE_LIST_BLUETOOTH_HDP);
+
+ BluetoothMapping.insert(std::make_pair(
+ BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER,
+ unsetListenerFunc));
+
return BluetoothMapping;
}
#ifndef _BLUETOOTH_PLUGIN_CONFIG_H_
#define _BLUETOOTH_PLUGIN_CONFIG_H_
-#include <string>
#include <Commons/FunctionDeclaration.h>
-#include <Logger.h>
-
namespace DeviceAPI {
namespace Bluetooth {
#define BLUETOOTH_SERVICE_HANDLER_NAME "name"
#define BLUETOOTH_SERVICE_HANDLER_IS_CONNECTED "isConnected"
#define BLUETOOTH_SERVICE_HANDLER_ONCONNECT "onconnect"
+#define BLUETOOTH_PROFILE_TYPE "profileType"
+#define BLUETOOTH_HEALTH_APPLICATION_DATA_TYPE "dataType"
+#define BLUETOOTH_HEALTH_APPLICATION_NAME "name"
+#define BLUETOOTH_HEALTH_APPLICATION_ONCONNECT "onconnect"
+#define BLUETOOTH_HEALTH_CHANNEL_PEER "peer"
+#define BLUETOOTH_HEALTH_CHANNEL_TYPE "channelType"
+#define BLUETOOTH_HEALTH_CHANNEL_APP "application"
+#define BLUETOOTH_HEALTH_CHANNEL_IS_CONNECTED "isConnected"
+
// functions
#define BLUETOOTH_MANAGER_API_GET_DEFAULT_ADAPTER "getDefaultAdapter"
#define BLUETOOTH_ADAPTER_API_CREATE_BONDING "createBonding"
#define BLUETOOTH_ADAPTER_API_DESTROY_BONDING "destroyBonding"
#define BLUETOOTH_ADAPTER_API_REGISTER_RFCOMMSERVICE_BY_UUID "registerRFCOMMServiceByUUID"
+#define BLUETOOTH_ADAPTER_API_GET_BLUETOOTH_PROFILE_HANDLER "getBluetoothProfileHandler"
+#define BLUETOOTH_ADAPTER_API_SET_CHANGE_LISTENER "setChangeListener"
+#define BLUETOOTH_ADAPTER_API_UNSET_CHANGE_LISTENER "unsetChangeListener"
#define BLUETOOTH_DEVICE_API_CONNECT_TO_SERVICE_BY_UUID "connectToServiceByUUID"
#define BLUETOOTH_SOCKET_API_WRITE_DATA "writeData"
#define BLUETOOTH_SOCKET_API_READ_DATA "readData"
#define BLUETOOTH_SOCKET_API_CLOSE "close"
#define BLUETOOTH_CLASS_API_HAS_SERVICE "hasService"
#define BLUETOOTH_SERVICE_HANDLER_API_UNREGISTER "unregister"
+#define BLUETOOTH_HEALTH_PROFILE_HANDLER_API_REGISTER_SINK_APPLICATION "registerSinkApplication"
+#define BLUETOOTH_HEALTH_APPLICATION_API_UNREGISTER "unregister"
+#define BLUETOOTH_HEALTH_PROFILE_HANDLER_API_CONNECT_TO_SOURCE "connectToSource"
+#define BLUETOOTH_HEALTH_CHANNEL_API_SEND_DATA "sendData"
+#define BLUETOOTH_HEALTH_CHANNEL_API_SET_LISTENER "setListener"
+#define BLUETOOTH_HEALTH_CHANNEL_API_UNSET_LISTENER "unsetListener"
+#define BLUETOOTH_HEALTH_CHANNEL_API_CLOSE "close"
+
DECLARE_FUNCTION_GETTER(Bluetooth);
Bookmark
SecureElement
DataSync
+ WebSetting
)
// Item Properties
{ TIZEN_CALENDAR_ITEM_DESCRIPTION, getPropertyDescription, setPropertyDescription, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_ITEM_SUMMARY, getPropertySummary, setPropertySummary, kJSPropertyAttributeNone },
- { TIZEN_CALENDAR_ITEM_START_DATE, getPropertyStartTime, setPropertyStartTime, kJSPropertyAttributeNone },
+ { TIZEN_CALENDAR_ITEM_START_DATE, getPropertyStartDate, setPropertyStartDate, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_ITEM_LOCATION, getPropertyLocation, setPropertyLocation, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_ITEM_GEOLOCATION, getPropertyGeolocation, setPropertyGeolocation, kJSPropertyAttributeNone },
{ TIZEN_CALENDAR_ITEM_ORGANIZER, getPropertyOrganizer, setPropertyOrganizer, kJSPropertyAttributeNone },
return true;
}
-JSValueRef JSCalendarItemProperties::getPropertyStartTime(JSContextRef context,
+JSValueRef JSCalendarItemProperties::getPropertyStartDate(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception)
{
Try
{
- CalendarItemPropertiesPrivObject *privateObject =
- static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
+ CalendarItemPropertiesPrivObject *privateObject = static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
+
TimeUtilConverter timeConverter(context);
- CalendarEventPtr event = privateObject->getObject();
+ CalendarEventPtr item = privateObject->getObject();
- LoggerI("start time before converted to TZDate: "<<event->getStartTime()<<", time zone: "<<event->getTimeZone());
- if (UNDEFINED_TIME==event->getStartTime()) {
+ LoggerI("start time before converted to TZDate: "<<item->getStartTime()<<", time zone: "<<item->getTimeZone());
+ if (UNDEFINED_TIME==item->getStartTime()) {
return JSValueMakeUndefined(context);
} else {
- return timeConverter.toJSValueRefTZDate((double)(event->getStartTime()*1000.0), event->getTimeZone());
+ return timeConverter.toJSValueRefTZDate((double)(item->getStartTime()*1000.0), item->getTimeZone());
}
}
Catch(Exception)
{
LoggerW("Exception: "<<_rethrown_exception.GetMessage());
}
+
return JSValueMakeUndefined(context);
}
-bool JSCalendarItemProperties::setPropertyStartTime(JSContextRef context,
+bool JSCalendarItemProperties::setPropertyStartDate(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
ThrowMsg(ConversionException, "Wrong parameter type.");
}
- CalendarEventPtr event = getPrivateObject(object);
- TimeUtilConverter converter(context);
- std::time_t duration = event->getEndTime() - event->getStartTime();
- if (duration<0) {
- duration = 0;
- }
+ CalendarEventPtr item = getPrivateObject(object);
+ TimeUtilConverter timeConverter(context);
+
+ long long int startTime = (long long int) (timeConverter.getTimeInMilliseconds(value)/1000);
+ item->setStartTime(startTime);
- long long int startTime = (long long int) (converter.getTimeInMilliseconds(value)/1000);
- event->setStartTime(startTime);
- event->setEndTime(startTime + duration);
+ std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone;
+ item->setTimeZone(timeZone);
- std::string timeZone = converter.getPropertiesInTZDate(value).timezone;
- event->setTimeZone(timeZone);
return true;
}
Catch(Exception)
{
Try
{
- CalendarEventPtr event = getPrivateObject(object);
+ CalendarEventPtr item = getPrivateObject(object);
TimeUtilConverter timeUtilConverter(context);
DurationPropertiesPtr duration = timeUtilConverter.getDuration(value);
}
LoggerD("length: "<<length<< ", unit:" <<unit);
- event->setDuration(duration);
+ item->setDuration(duration);
+
+ // Adjust the endDate because the endDate has priority over duration when saving the item.
+ long long int endDate;
+ if( DeviceAPI::Time::SECONDS_UNIT==unit ) {
+ endDate = item->getStartTime() + length;
+ } else if ( DeviceAPI::Time::MINUTES_UNIT==unit ) {
+ endDate = item->getStartTime() + length*60;
+ } else if ( DeviceAPI::Time::HOURS_UNIT==unit ) {
+ endDate = item->getStartTime() + length*60*60;
+ } else if ( DeviceAPI::Time::DAYS_UNIT==unit ) {
+ endDate = item->getStartTime() + length*24*60*60;
+ } else if ( DeviceAPI::Time::MSECS_UNIT==unit ) {
+ endDate = item->getStartTime() + length/1000;
+ } else {
+ LoggerW("Wrong duration unit: "<<unit);
+ return true;
+ }
+ item->setEndTime(endDate);
+ LoggerD("Set the endDate from the duration: "<<endDate);
return true;
}
JSStringRef propertyName,
JSValueRef value,
JSValueRef* exception);
- static JSValueRef getPropertyStartTime(JSContextRef context,
+ static JSValueRef getPropertyStartDate(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef* exception);
- static bool setPropertyStartTime(JSContextRef context,
+ static bool setPropertyStartDate(JSContextRef context,
JSObjectRef object,
JSStringRef propertyName,
JSValueRef value,
}
else
{
+ bool is_first = false;
errorCode = contacts_record_get_child_record_at_p(m_platformContact, _contacts_contact.image, 0, &child_record);
if(errorCode != CONTACTS_ERROR_NONE || child_record == NULL)
{
errorCode = contacts_record_create(_contacts_image._uri, &child_record);
if(errorCode != CONTACTS_ERROR_NONE)
ThrowMsg(UnknownException, "creating name value B (errorCode:" << errorCode << ")");
+ is_first = true;
}
contacts_record_get_str_p(child_record, _contacts_image.path, &oldValueStr);
ThrowMsg(PlatformException, "importing photoURI E (err:" << errorCode);
}
}
+
+ if(is_first)
contacts_record_add_child_record(m_platformContact, _contacts_contact.image, child_record);
}
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "same id exist");
}
-// LoggerD(key << " : " << std::hex << data);
+ LoggerD("Add OK ReqId : " << key);
DPL::Mutex::ScopedLock lock(&m_mutex);
m_callbackSQLUserDataMap[key] = data;
{
if (m_callbackSQLUserDataMap.find(key) == m_callbackSQLUserDataMap.end())
{
+ LoggerD("Fail ReqId : " << key);
ThrowMsg(WrtDeviceApis::Commons::PlatformException, "there is no key");
}
std::string m_page;
std::string m_numberPerPage;
std::string m_resultSetPath;
- std::string m_errorMsg;
+ char *m_errorMsg;
+
public:
EventSelect() {
LoggerD("entered");
m_page = "";
m_numberPerPage = "";
m_resultSetPath = "";
- m_errorMsg = "";
+
+ m_errorMsg = NULL;
+ }
+ ~EventSelect() {
+ if (m_errorMsg) {
+ delete[] m_errorMsg;
+ m_errorMsg = NULL;
+ }
}
- ~EventSelect() { }
unsigned int getReqId() { return m_reqId; }
std::string getWhere() { return m_where; }
std::string getNumerPerPage() { return m_numberPerPage; }
std::vector<std::string> getColumns() { return m_columns;}
std::string getResultSetPath() { return m_resultSetPath;}
- std::string getErrorMsg() { return m_errorMsg;}
+ std::string getErrorMsg() {
+ if (m_errorMsg)
+ return m_errorMsg;
+ else
+ return "";
+ }
void setReqId(const unsigned int & reqId) { m_reqId = reqId;}
void setWhere(const std::string& where) { m_where = where; }
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) { m_errorMsg = msg;}
+ 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;
+ }
+ }
};
typedef DPL::SharedPtr<EventSelect> EventSelectPtr;
try {
std::string networkType = validator.toString(3, true, "ALL");
if (networkType.compare("CELLULAR") && networkType.compare("WIFI") && networkType.compare("ALL")) {
- delete priv;
- TypeMismatchException err("networkType is invalid.");
- JSObjectRef errObj = JSWebAPIErrorFactory::makeErrorObject(context, err);
- *exception = errObj;
- return errObj;
+ networkType = "ALL";
+ LOGW("networkType is invalid. 'ALL' type is set.");
}
priv->setNetworkType(networkType);
} catch (const BasePlatformException& err) {
MessagePortDataItemMapPtr dataItemMap = MessagePortUtilitySingleton::Instance().getDataItemMap(data);
localMessagePort->OnMessageReceived(dataItemMap, remoteMessagePort);
+
+ MessagePortUtilitySingleton::Instance().releaseBundle(data);
}
// private static
JSValueRef appIdValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_APP_ID);
if (!JSValueIsUndefined(context, appIdValue))
priv->setApplicationId(JSUtil::JSValueToString(context, appIdValue));
-
+
+ //Light
+ JSValueRef lightValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT);
+ LoggerI("Light :" << JSUtil::JSValueToString(context, lightValue));
+ if (!JSValueIsUndefined(context, lightValue))
+ priv->setLight(JSUtil::JSValueToString(context, lightValue));
+
+ //onTime
+ JSValueRef onTimeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT_ONTIME);
+ if (!JSValueIsUndefined(context, onTimeValue))
+ priv->setLightOnTime(JSUtil::JSValueToLong(context, onTimeValue));
+
+ //offTime
+ JSValueRef offTimeValue = JSUtil::getProperty(context, notiInitDict, STATUS_NOTIFICATION_LIGHT_OFFTIME);
+ if (!JSValueIsUndefined(context, offTimeValue))
+ priv->setLightOffTime(JSUtil::JSValueToLong(context, offTimeValue));
+
//progressType
NotificationProgressType progressType = NOTI_PROGRESS_TYPE_PERCENTAGE;
JSValueRef appId = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_APP_ID);
if (!JSValueIsNull(context, appId))
priv->setApplicationId(JSUtil::JSValueToString(context, appId));
+
+ // light
+ JSValueRef light = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_LIGHT);
+ if (!JSValueIsNull(context, light))
+ priv->setLight(JSUtil::JSValueToString(context, light));
+
+ // onTime
+ JSValueRef onTime = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_LIGHT_ONTIME);
+ if (!JSValueIsNull(context, onTime))
+ priv->setLightOnTime(JSUtil::JSValueToLong(context, onTime));
+
+ // offTime
+ JSValueRef offTime = JSUtil::getProperty(context, object, STATUS_NOTIFICATION_LIGHT_OFFTIME);
+ if (!JSValueIsNull(context, offTime))
+ priv->setLightOffTime(JSUtil::JSValueToLong(context, offTime));
#if 0
// progressType
else
JSUtil::setProperty(context, object, STATUS_NOTIFICATION_APP_ID, JSValueMakeNull(context), kJSPropertyAttributeNone);
+ //Light
+ JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT,
+ JSUtil::toJSValueRef(context, priv->getLight()), kJSPropertyAttributeNone);
+
+ JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT_ONTIME,
+ JSUtil::toJSValueRef(context, priv->getLightOnTime()), kJSPropertyAttributeNone);
+
+ JSUtil::setProperty(context, object, STATUS_NOTIFICATION_LIGHT_OFFTIME,
+ JSUtil::toJSValueRef(context, priv->getLightOffTime()), kJSPropertyAttributeNone);
+
#if 0
// progressType & Value
LoggerI("Progress Type=" << priv->getProgressType());
}
+std::string StatusNotification::getLight()
+{
+ LoggerI("get Light handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ if (notification_get_led(m_notiHandle, &type, &ledColor) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("get notification Content error");
+ }
+
+ //ledColor = ledColor | 0xff000000;
+ std::stringstream stream;
+ if (NOTIFICATION_LED_OP_OFF != type)
+ {
+ stream << std::hex << ledColor;
+ }
+
+ return stream.str();
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+void StatusNotification::setLight(std::string color)
+{
+ LoggerI("set Light handle: " << m_notiHandle);
+ LoggerI("led Color : " << color);
+ if (m_notiHandle)
+ {
+
+ std::stringstream stream;
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+
+ 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)
+ {
+ throw UnknownException("set notification led ");
+ }
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+unsigned long StatusNotification::getLightOnTime()
+{
+ LoggerI("get Light on Time handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ int onTime = 0;
+ int offTime = 0;
+
+ if (notification_get_led_time_period(m_notiHandle, &onTime, &offTime ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ LoggerI("onTime " << onTime);
+
+ return (unsigned long) onTime;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+void StatusNotification::setLightOnTime(unsigned long time)
+{
+ LoggerI("set Light on Time handle: " << m_notiHandle);
+ LoggerI("itme = " << time);
+ if (m_notiHandle)
+ {
+ int offTime = getLightOffTime();
+
+ if (notification_set_led_time_period(m_notiHandle, time, offTime ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+unsigned long StatusNotification::getLightOffTime()
+{
+
+ LoggerI("get Light on Time handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ int onTime = 0;
+ int offTime = 0;
+
+ if (notification_get_led_time_period(m_notiHandle, &onTime, &offTime ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ LoggerI("offTime " << offTime);
+
+ return offTime;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+
+}
+
+void StatusNotification::setLightOffTime(unsigned long time)
+{
+ LoggerI("set Light off Time handle: " << m_notiHandle);
+ LoggerI("time = " << time);
+ if (m_notiHandle)
+ {
+ int onTime = getLightOnTime();
+
+ if (notification_set_led_time_period(m_notiHandle, onTime, time ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
//Detail Info
void StatusNotification::loadDetailInfos()
{
void setApplicationId(const std::string& appId);
std::string getApplicationId();
+ std::string getLight();
+ void setLight(std::string color);
+
+ unsigned long getLightOnTime();
+ void setLightOnTime(unsigned long onTime);
+
+ unsigned long getLightOffTime();
+ void setLightOffTime(unsigned long offTime);
+
void* getNotificationHandle();
void setNotificationHandle(void *handle);
#define STATUS_NOTIFICATION_VIBRATION "vibration"
#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_PROGRESS_TYPE "progressType"
#define STATUS_NOTIFICATION_PROGRESS_VALUE "progressValue"
#define NOTIFICATION_DETAIL_INFO_MAIN_TEXT "mainText"
}
}
-#endif // _NOTIFICATION_PLUGIN_CONFIG_H_
\ No newline at end of file
+#endif // _NOTIFICATION_PLUGIN_CONFIG_H_
capi-system-runtime-info
capi-system-sensor
sensor
- pkgmgr-info
tapi
)
#include "plugin_config.h"
#include <Logger.h>
+#define MAXBUFSIZE 256
+#define DEVICE_PROFILE "MOBILE"
+
namespace DeviceAPI {
namespace Systeminfo {
using namespace WrtDeviceApis::CommonsJavaScript;
const char* DEVICE_CAPABILITIES_NATIVE_OSP_COMPATIBLE = "nativeOspCompatible";
const char* DEVICE_CAPABILITIES_INPUT_KEY_BACK = "inputKeyBack";
const char* DEVICE_CAPABILITIES_INPUT_KEY_OPTION = "inputKeyMenu";
+const char* DEVICE_CAPABILITIES_PROFILE = "profile";
}
JSClassRef JSDeviceCapabilitiesInfo::m_classRef = NULL;
{ DEVICE_CAPABILITIES_NATIVE_OSP_COMPATIBLE, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ DEVICE_CAPABILITIES_INPUT_KEY_BACK, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ DEVICE_CAPABILITIES_INPUT_KEY_OPTION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PROFILE, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
} else {
return JSValueMakeUndefined(context);
}
- return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyMenu);
+ return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyMenu);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROFILE)) {
+ deviceCapabilitiesInfo->profile = DEVICE_PROFILE;
+ return convert.toJSValueRef(deviceCapabilitiesInfo->profile);
}
}
Catch(Exception)
namespace {
const char* DEVICEORIENTATION_STATUS_PROPERTY = "status";
+const char* DEVICEORIENTATION_IS_AUTOROTATION_PROPERTY = "isAutoRotation";
}
JSClassRef JSDeviceOrientationInfo::m_classRef = NULL;
JSStaticValue JSDeviceOrientationInfo::m_properties[] = {
{ DEVICEORIENTATION_STATUS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICEORIENTATION_IS_AUTOROTATION_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
{ 0, 0, 0, 0 }
};
if (JSStringIsEqualToUTF8CString(propertyName, DEVICEORIENTATION_STATUS_PROPERTY)) {
return convert.toJSValueRef(deviceOrientationInfo->status);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICEORIENTATION_IS_AUTOROTATION_PROPERTY)) {
+ return convert.toJSValueRef(deviceOrientationInfo->isAutoRotation);
}
}
Catch(Exception)
}
}
+void OrientationValueVconfCallback(keynode_t *node, void *event_ptr)
+{
+ LoggerD("enter");
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DEVICE_ORIENTATION);
+ }
+}
+
void NetworkTypeValueCallback(connection_type_e type, void* event_ptr)
{
if(event_ptr) {
void OrientationValueCallback(unsigned int event_type, sensor_event_data_t *event , void *event_ptr)
{
- LoggerD("enter");
if(event_ptr) {
((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DEVICE_ORIENTATION);
}
void localeChangedCallback(runtime_info_key_e key, void* event_ptr)
{
- LoggerD("enter");
if(event_ptr) {
((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_LOCALE);
}
break;
case WATCH_TYPE_DEVICE_ORIENTATION:
if ((m_EventMgrPtr->getEventDeviceOrientationList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, OrientationValueVconfCallback);
int state = sf_unregister_event(m_sensorHandle, ACCELEROMETER_EVENT_ROTATION_CHECK);
if (state < 0) {
LoggerD("sf_unregister_event fail to gather data\n");
case WATCH_TYPE_DEVICE_ORIENTATION:
LoggerD("regist sensor");
if ((m_EventMgrPtr->getEventDeviceOrientationList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, OrientationValueVconfCallback, (void *)this);
int state = sf_register_event(m_sensorHandle, ACCELEROMETER_EVENT_ROTATION_CHECK, NULL, OrientationValueCallback, (void *)this);
if (state < 0) {
LoggerD("sensor_register_cb fail to gather data");
unsigned long rotation = 0;
int handleOrientaion = 0;
+ int isAutoRotation = 0;
+
+ if (vconf_get_bool(VCONFKEY_SETAPPL_AUTO_ROTATE_SCREEN_BOOL, &isAutoRotation) == 0) {
+ if (isAutoRotation) {
+ deviceOrientation->isAutoRotation = true;
+ } else {
+ deviceOrientation->isAutoRotation = false;
+ }
+ }
handleOrientaion = sf_connect(ACCELEROMETER_SENSOR);
LoggerD("handleOrientaion : " << handleOrientaion);
}
SysteminfoListener::SysteminfoListener() :
- EventGetSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
- EventWatchSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD)
+ EventGetSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::SYSTEMINFO_THREAD),
+ EventWatchSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::SYSTEMINFO_THREAD)
{
}
bool nativeOspCompatible;
bool inputKeyBack;
bool inputKeyMenu;
+ std::string profile;
DeviceCapabilitiesProperties() :
bluetooth(false),
secureElement(false),
nativeOspCompatible(false),
inputKeyBack(false),
- inputKeyMenu(false)
+ inputKeyMenu(false),
+ profile("")
{
}
};
struct DeviceOrientationProperties
{
std::string status;
+ bool isAutoRotation;
DeviceOrientationProperties() :
- status("")
+ status(""),
+ isAutoRotation(false)
{
}
};
--- /dev/null
+
+SET(TARGET_NAME ${websetting_target})
+SET(DESTINATION_NAME ${websetting_dest})
+SET(TARGET_IMPL_NAME ${websetting_impl})
+
+#PKG_CHECK_MODULES(websetting REQUIRED [.. required package name ..])
+
+INCLUDE_DIRECTORIES(
+ ${INCLUDE_COMMON}
+ ${websetting_INCLUDE_DIRS}
+)
+
+SET(CMAKE_INSTALL_RPATH
+ ${CMAKE_INSTALL_RPATH}
+ ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${tizen_dest}
+ ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
+)
+
+SET(SRCS_IMPL
+ JSWebSettingManager.cpp
+ WebSettingManager.cpp
+)
+
+ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+
+TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
+ ${LIBS_COMMON}
+ ${tizen_impl}
+ ${websetting_LIBRARIES}
+)
+
+SET(SRCS
+ plugin_config.cpp
+ plugin_initializer.cpp
+)
+
+ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS})
+
+TARGET_LINK_LIBRARIES(${TARGET_NAME}
+ ${TARGET_IMPL_NAME}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME})
+INSTALL(
+ DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/websetting
+ FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
+)
--- /dev/null
+//
+// 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 <JSWebAPIError.h>
+#include <ArgumentValidator.h>
+#include <GlobalContextManager.h>
+#include <MultiCallbackUserData.h>
+#include <PlatformException.h>
+
+#include "plugin_config.h"
+
+#include "JSWebSettingManager.h"
+
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+JSClassDefinition JSWebSettingManager::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "WebSettingManager",
+ NULL, //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 JSWebSettingManager::m_function[] = {
+ { WEB_SETTING_MANAGER_API_SET_USER_AGENT_STRING, setUserAgentString, kJSPropertyAttributeNone },
+ { WEB_SETTING_MANAGER_API_REMOVE_ALL_COOKIES, removeAllCookies, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+JSClassRef JSWebSettingManager::m_jsClassRef = JSClassCreate(JSWebSettingManager::getClassInfo());
+
+const JSClassRef JSWebSettingManager::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSWebSettingManager::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSWebSettingManager::initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object)) {
+ WebSettingManager *priv = new WebSettingManager();
+ if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+ delete priv;
+ }
+ }
+}
+
+void JSWebSettingManager::finalize(JSObjectRef object)
+{
+ WebSettingManager *priv = static_cast<WebSettingManager*>(JSObjectGetPrivate(object));
+ if (priv) {
+ JSObjectSetPrivate(object, NULL);
+ delete priv;
+ }
+}
+
+JSValueRef JSWebSettingManager::setUserAgentString(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ try {
+ // Private Object
+ WebSettingManager *priv = static_cast<WebSettingManager*>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw TypeMismatchException("Private object is NULL.");
+ }
+ ArgumentValidator validator(context, argumentCount, arguments);
+ MultiCallbackUserDataPtr callbacks(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+
+ // userAgent
+ std::string userAgent = validator.toString(0);
+
+ // successCallback
+ JSObjectRef successCallbackObj = validator.toFunction(1, true);
+ if (successCallbackObj)
+ {
+ callbacks->setCallback("onsuccess", successCallbackObj);
+ }
+
+ // errorCallback
+ JSObjectRef errorCallbackObj = validator.toFunction(2, true);
+
+ if (errorCallbackObj)
+ {
+ callbacks->setCallback("onerror", errorCallbackObj);
+ }
+
+ priv->setUserAgentString(userAgent, callbacks);
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ LoggerE("%s: %s", err.getName().c_str(), err.getMessage().c_str());
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in WebSettingManager.setUserAgentString().");
+ LoggerE("%s: %s", err.getName().c_str(), err.getMessage().c_str());
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+JSValueRef JSWebSettingManager::removeAllCookies(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ //TODO: Need to implement ACE check
+ //AceSecurityStatus status = WEB_SETTING_CHECK_ACCESS(WEB_SETTING_MANAGER_API_REMOVE_ALL_COOKIES);
+ //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ try {
+ // Private Object
+ WebSettingManager *priv = static_cast<WebSettingManager*>(JSObjectGetPrivate(thisObject));
+ if (!priv) {
+ throw TypeMismatchException("Private object is NULL.");
+ }
+
+ ArgumentValidator validator(context, argumentCount, arguments);
+ MultiCallbackUserDataPtr callbacks(new MultiCallbackUserData(GlobalContextManager::getInstance()->getGlobalContext(context)));
+
+ // successCallback
+ JSObjectRef successCallbackObj = validator.toFunction(0, true);
+ if (successCallbackObj)
+ {
+ callbacks->setCallback("onsuccess", successCallbackObj);
+ }
+
+ // errorCallback
+ JSObjectRef errorCallbackObj = validator.toFunction(1, true);
+ if (errorCallbackObj)
+ {
+ callbacks->setCallback("onerror", errorCallbackObj);
+ }
+ priv->removeAllCookies(callbacks);
+ return JSValueMakeUndefined(context);
+ } catch (const BasePlatformException &err) {
+ LoggerE("%s: %s", err.getName().c_str(), err.getMessage().c_str());
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ } catch (...) {
+ DeviceAPI::Common::UnknownException err("Unknown Error in WebSettingManager.removeAllCookies().");
+ LoggerE("%s: %s", err.getName().c_str(), err.getMessage().c_str());
+ return JSWebAPIErrorFactory::postException(context, exception, err);
+ }
+}
+
+
+} // WebSetting
+} // DeviceAPI
--- /dev/null
+//
+// 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_WEB_SETTING_MANAGER_H__
+#define __TIZEN_JS_WEB_SETTING_MANAGER_H__
+
+#include <JavaScriptCore/JavaScript.h>
+
+#include "WebSettingManager.h"
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+class JSWebSettingManager
+{
+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 setUserAgentString(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception);
+
+ static JSValueRef removeAllCookies(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;
+};
+
+
+
+} // WebSetting
+} // DeviceAPI
+
+#endif // __TIZEN_JS_DOWNLOAD_MANAGER_H__
--- /dev/null
+//
+// 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 <PlatformException.h>
+#include <Logger.h>
+#include "WebSettingManager.h"
+#include <glib.h>
+#include <Ecore.h>
+#include <JSUtil.h>
+#include <JSWebAPIError.h>
+#include <PlatformException.h>
+
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+WebSettingManager::WebSettingManager()
+{
+}
+
+WebSettingManager::~WebSettingManager()
+{
+}
+
+static gboolean asyncUserAgentStringResult(void *data)
+{
+ LoggerD("[asyncUserAgentStringResult] entered in Mainloop");
+
+ WebSettingManager* object = static_cast<WebSettingManager*>(data);
+ if(object == NULL)
+ {
+ //TBD : JSWebAPIErrorFactory::postException(context, exception, err);
+ LoggerD("[asyncUserAgentStringResult] User data is NULL");
+ return true;
+ }
+
+ MultiCallbackUserDataPtr callback = (MultiCallbackUserDataPtr)object->mSetUserAgentCallbacks;
+
+ if (callback)
+ {
+ JSContextRef context = callback->getContext();
+ callback->invokeCallback("onsuccess");
+ }
+
+ return false;
+}
+
+static gboolean asyncRemoveAllCookiesResult(void *data)
+{
+ LoggerD("[asyncRemoveAllCookiesResult] entered in Mainloop");
+
+ WebSettingManager* object = static_cast<WebSettingManager*>(data);
+ if(object == NULL)
+ {
+ //TBD : JSWebAPIErrorFactory::postException(context, exception, err);
+ LoggerD("[asyncRemoveAllCookiesResult] User data is NULL");
+ return true;
+ }
+
+ MultiCallbackUserDataPtr callback = (MultiCallbackUserDataPtr)object->mRemoveAllCookiesCallbacks;
+ if (callback)
+ {
+ JSContextRef context = callback->getContext();
+ callback->invokeCallback("onsuccess");
+ }
+
+ return false;
+}
+
+static void checkSetUserAgentString(void *data, Ecore_Thread *thread)
+{
+ LoggerD("WebSettingManager::checkUserAgentString");
+ g_idle_add(asyncUserAgentStringResult, data);
+}
+
+static void checkRemoveAllCookies(void *data, Ecore_Thread *thread)
+{
+ LoggerD("WebSettingManager::checkRemoveAllCookies");
+ g_idle_add(asyncRemoveAllCookiesResult, data);
+}
+
+void WebSettingManager::setUserAgentString(std::string userAgent, MultiCallbackUserDataPtr callbacks)
+{
+ LoggerD("WebSetting:setUserAgentString: " << userAgent);
+ mSetUserAgentCallbacks = callbacks;
+ ecore_thread_run(checkSetUserAgentString, NULL, NULL, this);
+ //throw UnknownException("Not Implemented.");
+}
+
+void WebSettingManager::removeAllCookies(MultiCallbackUserDataPtr callbacks)
+{
+ LoggerD("WebSetting:removeAllCookies: ");
+ mRemoveAllCookiesCallbacks = callbacks;
+ ecore_thread_run(checkRemoveAllCookies, NULL, NULL, this);
+ //throw UnknownException("Not Implemented.");
+}
+
+} // WebSetting
+} // DeviceAPI
--- /dev/null
+//
+// 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_WEB_SETTING_MANAGER_H__
+#define __TIZEN_WEB_SETTING_MANAGER_H__
+
+#include <MultiCallbackUserData.h>
+
+#include "WebSettingTypes.h"
+
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+class WebSettingManager
+{
+public:
+ WebSettingManager();
+ virtual ~WebSettingManager();
+
+ void setUserAgentString(std::string userAgent, MultiCallbackUserDataPtr callbacks);
+
+ void removeAllCookies(MultiCallbackUserDataPtr callbacks);
+
+ Common::MultiCallbackUserDataPtr mSetUserAgentCallbacks;
+
+ Common::MultiCallbackUserDataPtr mRemoveAllCookiesCallbacks;
+
+private:
+};
+
+} // WebSetting
+} // DeviceAPI
+
+#endif // __TIZEN_WEB_SETTING_MANAGER_H__
\ No newline at end of file
--- /dev/null
+//
+// 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 _WEB_SETTING_TYPES_H_
+#define _WEB_SETTING_TYPES_H_
+
+#include <string>
+#include <vector>
+#include <map>
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+
+} // WebSetting
+} // DeviceAPI
+
+#endif // _WEB_SETTING_TYPES_H_
--- /dev/null
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+ <library-name>libwrt-plugins-tizen-websetting.so</library-name>
+ <feature-install-uri>websetting.install.uri</feature-install-uri>
+ <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+ <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+ <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+
+ <api-feature>
+ <name>http://tizen.org/privilege/websetting</name>
+ <device-capability>websetting</device-capability>
+ </api-feature>
+
+</plugin-properties>
\ No newline at end of file
--- /dev/null
+//
+// 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 <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <Commons/Exception.h>
+#include <map>
+
+#include "plugin_config.h"
+
+using namespace WrtDeviceApis::Commons;
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+static FunctionMapping createWebSettingFunctions();
+static FunctionMapping WebSettingFunctions = createWebSettingFunctions();
+
+DEFINE_FUNCTION_GETTER(WebSetting, WebSettingFunctions);
+
+static FunctionMapping createWebSettingFunctions()
+{
+ FunctionMapping webSettingMapping;
+ // TODO: implement here
+ return webSettingMapping;
+}
+
+} // WebSetting
+} // DeviceAPI
--- /dev/null
+//
+// 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 _WEB_SETTING_PLUGIN_CONFIG_H_
+#define _WEB_SETTING_PLUGIN_CONFIG_H_
+
+#include <string>
+#include <Commons/FunctionDeclaration.h>
+
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+// attributes
+
+// functions
+#define WEB_SETTING_MANAGER_API_SET_USER_AGENT_STRING "setUserAgentString"
+#define WEB_SETTING_MANAGER_API_REMOVE_ALL_COOKIES "removeAllCookies"
+
+DECLARE_FUNCTION_GETTER(WebSetting);
+
+#define WEB_SETTING_CHECK_ACCESS(functionName) \
+ aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+ getWebSettingFunctionData, \
+ functionName)
+
+}
+}
+
+#endif // _WEB_SETTING_PLUGIN_CONFIG_H_
\ No newline at end of file
--- /dev/null
+//
+// 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 <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+
+#include <GlobalContextManager.h>
+
+#include "JSWebSettingManager.h"
+
+#include <Logger.h>
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace DeviceAPI {
+namespace WebSetting {
+
+
+void on_widget_start_callback(int widgetId)
+{
+ LoggerD("[Tizen\\WebSetting] on_widget_start_callback (%d)", widgetId);
+ try {
+ WrtAccessSingleton::Instance().initialize(widgetId);
+ } catch (...) {
+ LoggerE("WrtAccess initialization failed");
+ }
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+ LoggerD("[Tizen\\WebSetting] on_widget_stop_callback (%d)", widgetId);
+ try {
+ WrtAccessSingleton::Instance().deinitialize(widgetId);
+ } catch (...) {
+ LoggerE("WrtAccess deinitialization failed");
+ }
+}
+
+void on_frame_load_callback(const void * context)
+{
+ LoggerD("[Tizen\\WebSetting] on_frame_load_callback (%p)", context);
+ GlobalContextManager::getInstance()->addGlobalContext(static_cast<JSContextRef>(context));
+}
+
+void on_frame_unload_callback(const void * context)
+{
+ LoggerD("[Tizen\\WebSetting] on_frame_unload_callback (%p)", context);
+ GlobalContextManager::getInstance()->removeGlobalContext(static_cast<JSContextRef>(context));
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
+PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+ "websetting",
+ (js_class_template_getter)JSWebSettingManager::getClassRef,
+ NULL)
+PLUGIN_CLASS_MAP_END
+
+} // WebSetting
+} // DeviceAPI