summaryrefslogtreecommitdiff
path: root/mobile_src/Systeminfo
diff options
context:
space:
mode:
Diffstat (limited to 'mobile_src/Systeminfo')
-rwxr-xr-xmobile_src/Systeminfo/BaseProperties.h82
-rwxr-xr-xmobile_src/Systeminfo/CMakeLists.txt76
-rwxr-xr-xmobile_src/Systeminfo/EventGetSysteminfo.cpp142
-rwxr-xr-xmobile_src/Systeminfo/EventGetSysteminfo.h60
-rwxr-xr-xmobile_src/Systeminfo/EventWatchSysteminfo.cpp374
-rwxr-xr-xmobile_src/Systeminfo/EventWatchSysteminfo.h102
-rwxr-xr-xmobile_src/Systeminfo/ISysteminfo.cpp36
-rwxr-xr-xmobile_src/Systeminfo/ISysteminfo.h61
-rw-r--r--mobile_src/Systeminfo/JSBatteryInfo.cpp126
-rwxr-xr-xmobile_src/Systeminfo/JSBatteryInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSBuildInfo.cpp129
-rwxr-xr-xmobile_src/Systeminfo/JSBuildInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSCellularNetworkInfo.cpp168
-rwxr-xr-xmobile_src/Systeminfo/JSCellularNetworkInfo.h49
-rw-r--r--mobile_src/Systeminfo/JSCpuInfo.cpp121
-rwxr-xr-xmobile_src/Systeminfo/JSCpuInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSDeviceCapabilitiesInfo.cpp1019
-rwxr-xr-xmobile_src/Systeminfo/JSDeviceCapabilitiesInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSDeviceOrientationInfo.cpp124
-rwxr-xr-xmobile_src/Systeminfo/JSDeviceOrientationInfo.h48
-rw-r--r--mobile_src/Systeminfo/JSDisplayInfo.cpp143
-rwxr-xr-xmobile_src/Systeminfo/JSDisplayInfo.h48
-rw-r--r--mobile_src/Systeminfo/JSLocaleInfo.cpp124
-rwxr-xr-xmobile_src/Systeminfo/JSLocaleInfo.h48
-rw-r--r--mobile_src/Systeminfo/JSNetworkInfo.cpp120
-rwxr-xr-xmobile_src/Systeminfo/JSNetworkInfo.h48
-rw-r--r--mobile_src/Systeminfo/JSPeripheralInfo.cpp120
-rwxr-xr-xmobile_src/Systeminfo/JSPeripheralInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSSIMInfo.cpp168
-rwxr-xr-xmobile_src/Systeminfo/JSSIMInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSStorageInfo.cpp140
-rwxr-xr-xmobile_src/Systeminfo/JSStorageInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSStorageUnitInfo.cpp134
-rwxr-xr-xmobile_src/Systeminfo/JSStorageUnitInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/JSSysteminfo.cpp313
-rwxr-xr-xmobile_src/Systeminfo/JSSysteminfo.h61
-rw-r--r--mobile_src/Systeminfo/JSWifiNetworkInfo.cpp137
-rwxr-xr-xmobile_src/Systeminfo/JSWifiNetworkInfo.h48
-rwxr-xr-xmobile_src/Systeminfo/Systeminfo.cpp1716
-rwxr-xr-xmobile_src/Systeminfo/Systeminfo.h236
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoAsyncCallbackManager.cpp26
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoAsyncCallbackManager.h46
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoFactory.cpp41
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoFactory.h42
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoListener.cpp68
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoListener.h51
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoListenerManager.cpp26
-rw-r--r--mobile_src/Systeminfo/SysteminfoListenerManager.h81
-rwxr-xr-xmobile_src/Systeminfo/SysteminfoPropertyInfo.h404
-rwxr-xr-xmobile_src/Systeminfo/config.xml23
-rwxr-xr-xmobile_src/Systeminfo/plugin_config.cpp114
-rwxr-xr-xmobile_src/Systeminfo/plugin_config.h39
-rw-r--r--mobile_src/Systeminfo/plugin_initializer.cpp87
53 files changed, 7753 insertions, 0 deletions
diff --git a/mobile_src/Systeminfo/BaseProperties.h b/mobile_src/Systeminfo/BaseProperties.h
new file mode 100755
index 0000000..1f20876
--- /dev/null
+++ b/mobile_src/Systeminfo/BaseProperties.h
@@ -0,0 +1,82 @@
+//
+// 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 WRTPLUGINS_API_BASE_PROPERTIES_H_
+#define WRTPLUGINS_API_BASE_PROPERTIES_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include "JSNetworkInfo.h"
+#include "JSWifiNetworkInfo.h"
+#include "JSCellularNetworkInfo.h"
+#include "JSSIMInfo.h"
+#include "JSStorageInfo.h"
+#include "JSBatteryInfo.h"
+#include "JSDisplayInfo.h"
+#include "JSCpuInfo.h"
+#include "JSDeviceCapabilitiesInfo.h"
+#include "JSDeviceOrientationInfo.h"
+#include "JSBuildInfo.h"
+#include "JSLocaleInfo.h"
+#include "JSPeripheralInfo.h"
+#include "SysteminfoPropertyInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+struct WatchOption
+{
+ unsigned long timeout;
+ double highThreshold;
+ double lowThreshold;
+ std::string id;
+
+ WatchOption () :
+ timeout(0),
+ highThreshold(0.0),
+ lowThreshold(0.0),
+ id("")
+ {
+ }
+};
+
+class BaseProperty
+{
+ public:
+
+ explicit BaseProperty()
+ {
+ }
+
+ virtual ~BaseProperty()
+ {
+ }
+
+ virtual JSValueRef getValue(JSContextRef context, void* handle, void* tapiHandle) const = 0;
+ virtual const char* getProperty() const = 0;
+ virtual const int getWatchType() const = 0;
+};
+
+typedef DPL::SharedPtr<BaseProperty> BasePropertyPtr;
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/CMakeLists.txt b/mobile_src/Systeminfo/CMakeLists.txt
new file mode 100755
index 0000000..4ff3261
--- /dev/null
+++ b/mobile_src/Systeminfo/CMakeLists.txt
@@ -0,0 +1,76 @@
+SET(TARGET_NAME ${systeminfo_target})
+SET(DESTINATION_NAME ${systeminfo_dest})
+SET(TARGET_IMPL_NAME ${systeminfo_impl})
+
+PKG_CHECK_MODULES(platform_pkgs_systeminfo REQUIRED
+ capi-telephony-sim
+ capi-network-connection
+ capi-system-info
+ capi-system-runtime-info
+ capi-system-sensor
+ sensor
+ tapi
+)
+
+ADD_DEFINITIONS("-fvisibility=hidden")
+
+INCLUDE_DIRECTORIES(
+ ${INCLUDE_COMMON}
+ ${platform_pkgs_systeminfo_INCLUDE_DIRS}
+)
+
+SET(CMAKE_INSTALL_RPATH
+ ${CMAKE_INSTALL_RPATH}
+ ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}
+)
+
+SET(SRCS_IMPL
+ SysteminfoFactory.cpp
+ EventGetSysteminfo.cpp
+ EventWatchSysteminfo.cpp
+ ISysteminfo.cpp
+ Systeminfo.cpp
+ JSDisplayInfo.cpp
+ JSStorageInfo.cpp
+ JSStorageUnitInfo.cpp
+ JSCpuInfo.cpp
+ JSWifiNetworkInfo.cpp
+ JSCellularNetworkInfo.cpp
+ JSBatteryInfo.cpp
+ JSNetworkInfo.cpp
+ JSSIMInfo.cpp
+ JSDeviceOrientationInfo.cpp
+ JSBuildInfo.cpp
+ JSLocaleInfo.cpp
+ JSDeviceCapabilitiesInfo.cpp
+ JSPeripheralInfo.cpp
+ JSSysteminfo.cpp
+ SysteminfoAsyncCallbackManager.cpp
+ SysteminfoListener.cpp
+ SysteminfoListenerManager.cpp
+)
+
+ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+
+TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME}
+ ${LIBS_COMMON}
+ ${platform_pkgs_systeminfo_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}/systeminfo
+ FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE
+)
diff --git a/mobile_src/Systeminfo/EventGetSysteminfo.cpp b/mobile_src/Systeminfo/EventGetSysteminfo.cpp
new file mode 100755
index 0000000..f6dd721
--- /dev/null
+++ b/mobile_src/Systeminfo/EventGetSysteminfo.cpp
@@ -0,0 +1,142 @@
+//
+// 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/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+
+#include "EventGetSysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+EventGetSysteminfo::EventGetSysteminfo()
+{
+ m_simValueCnt = 0;
+}
+
+EventGetSysteminfo::~EventGetSysteminfo()
+{
+}
+
+void EventGetSysteminfo::setSimState(char* state)
+{
+ m_simProperty.state = state;
+}
+
+void EventGetSysteminfo::setSimImsi(char* mcc, char* mnc, char* msin)
+{
+ m_simProperty.mcc = atoi(mcc);
+ m_simProperty.mnc = atoi(mnc);
+ m_simProperty.msin = msin;
+}
+
+int EventGetSysteminfo::addSimValueCnt()
+{
+ return ++m_simValueCnt;
+}
+
+int EventGetSysteminfo::setSimValue(const int attribute, char* value)
+{
+ switch(attribute) {
+ case 0 :
+ m_simProperty.operatorName = value;
+ break;
+ case 1 :
+ m_simProperty.msisdn = value;
+ break;
+ case 2 :
+ m_simProperty.iccid = value;
+ break;
+ case 3 :
+ m_simProperty.spn = value;
+ break;
+ }
+
+ return ++m_simValueCnt;
+}
+
+void EventGetSysteminfo::setTapiHandle(void* handle)
+{
+ m_tapiHandle = handle;
+}
+
+void EventGetSysteminfo::setBasePropertyPtr(const BasePropertyPtr& baseProperty)
+{
+ m_BaseProperty = baseProperty;
+}
+
+void EventGetSysteminfo::makeSimObject()
+{
+ LoggerD("enter");
+ SIMPropertiesPtr SIM(new SIMProperties());
+
+ if (!m_BaseProperty) {
+ LoggerE("property is not set");
+ setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::ConversionException);
+ } else {
+ WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_callbackManager = DPL::StaticPointerCast<WrtDeviceApis::CommonsJavaScript::JSCallbackManager >(getPrivateData());
+ if (!m_callbackManager) {
+ LoggerE("property is not set");
+ setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::NullPointerException);
+ } else {
+ JSContextRef context = m_callbackManager->getContext();
+ SIM->state = m_simProperty.state;
+ SIM->mcc = m_simProperty.mcc;
+ SIM->mnc = m_simProperty.mnc;
+ SIM->msin = m_simProperty.msin;
+ SIM->operatorName = m_simProperty.operatorName;
+ SIM->msisdn = m_simProperty.msisdn;
+ SIM->iccid = m_simProperty.iccid;
+ SIM->spn = m_simProperty.spn;
+ m_value = JSSIMInfo::createJSObject(context, SIM);
+ }
+ }
+}
+
+
+JSValueRef EventGetSysteminfo::getValue() const
+{
+ return m_value;
+}
+
+const char * EventGetSysteminfo::getProperty() const
+{
+ return m_BaseProperty->getProperty();
+}
+
+void EventGetSysteminfo::processGetValue(void* handle)
+{
+ LoggerD("enter");
+ if (!m_BaseProperty) {
+ LoggerE("property is not set");
+ setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::ConversionException);
+ } else {
+ WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_callbackManager = DPL::StaticPointerCast<WrtDeviceApis::CommonsJavaScript::JSCallbackManager >(getPrivateData());
+ if (!m_callbackManager) {
+ LoggerE("property is not set");
+ setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::NullPointerException);
+ } else {
+ JSContextRef context = m_callbackManager->getContext();
+ m_value = m_BaseProperty->getValue(context, handle, m_tapiHandle);
+ }
+ }
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/EventGetSysteminfo.h b/mobile_src/Systeminfo/EventGetSysteminfo.h
new file mode 100755
index 0000000..5a1f9a8
--- /dev/null
+++ b/mobile_src/Systeminfo/EventGetSysteminfo.h
@@ -0,0 +1,60 @@
+//
+// 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 WRTPLUGINS_API_SYSTEMINFO_EVENT_GET_SYSTEMINFO_H_
+#define WRTPLUGINS_API_SYSTEMINFO_EVENT_GET_SYSTEMINFO_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include "ISysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+class EventGetSysteminfo;
+
+class EventGetSysteminfo : public WrtDeviceApis::Commons::IEvent<EventGetSysteminfo>
+{
+ private :
+ BasePropertyPtr m_BaseProperty;
+ JSValueRef m_value;
+ void* m_tapiHandle;
+ SIMProperties m_simProperty;
+ int m_simValueCnt;
+
+ public :
+ EventGetSysteminfo();
+ ~EventGetSysteminfo();
+ int addSimValueCnt();
+ void setSimState(char* state);
+ void setSimImsi(char* mcc, char* mnc, char* msin);
+ int setSimValue(const int attribute, char* value);
+ void setTapiHandle(void* handle);
+ void setBasePropertyPtr(const BasePropertyPtr& baseProperty);
+ void makeSimObject();
+ JSValueRef getValue() const;
+ const char * getProperty() const;
+ void processGetValue(void* handle);
+};
+
+typedef DPL::SharedPtr<EventGetSysteminfo> EventGetSysteminfoPtr;
+
+}
+}
+
+#endif \ No newline at end of file
diff --git a/mobile_src/Systeminfo/EventWatchSysteminfo.cpp b/mobile_src/Systeminfo/EventWatchSysteminfo.cpp
new file mode 100755
index 0000000..a34a638
--- /dev/null
+++ b/mobile_src/Systeminfo/EventWatchSysteminfo.cpp
@@ -0,0 +1,374 @@
+//
+// 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 <CommonsJavaScript/Converter.h>
+#include <Commons/Exception.h>
+#include "EventWatchSysteminfo.h"
+#include "Systeminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+
+static Eina_Bool timeout_timer_cb(void* data)
+{
+ EventWatchSysteminfo *event = static_cast<EventWatchSysteminfo *> (data);
+ event->timeoutWatch();
+ return ECORE_CALLBACK_RENEW;
+}
+
+}
+
+#define MAX_STORAGE_CNT 2
+DPL::Atomic EventWatchSysteminfo::m_uniqId = 1;
+
+EventWatchSysteminfo::EventWatchSysteminfo() : m_id(m_uniqId)
+{
+ m_initTimer = NULL;
+ m_canceled = false;
+ m_storageCnt = 0;
+ m_tmpStorageCnt = 0;
+ m_Systeminfo = NULL;
+ m_setLastValue = false;
+ m_tapiHandle = NULL;
+ ++m_uniqId;
+}
+
+EventWatchSysteminfo::~EventWatchSysteminfo()
+{
+ LoggerD("destroy event data, id=" << m_id);
+ removeTimer();
+}
+
+void EventWatchSysteminfo::setTapiHandle(void* handle)
+{
+ m_tapiHandle = handle;
+}
+
+void EventWatchSysteminfo::setWatchOption(const WatchOption& watchoption) {
+ m_WatchOption = watchoption;
+}
+
+WatchOption EventWatchSysteminfo::getWatchOption() {
+ return m_WatchOption;
+}
+
+JSCallbackManagerPtr EventWatchSysteminfo::getCallbackManager() {
+ return DPL::StaticPointerCast< JSCallbackManager >(getPrivateData());
+}
+
+BasePropertyPtr EventWatchSysteminfo::getBasePropertyPtr() {
+ return m_BaseProperty;
+}
+
+void EventWatchSysteminfo::setSysteminfoPtr(void* SysteminfoPtr) {
+ m_Systeminfo = SysteminfoPtr;
+}
+
+void EventWatchSysteminfo::setBasePropertyPtr(const BasePropertyPtr& baseProperty) {
+ m_BaseProperty = baseProperty;
+}
+
+const char * EventWatchSysteminfo::getProperty() const {
+ return m_BaseProperty->getProperty();
+}
+
+const int EventWatchSysteminfo::getWatchType() const {
+ return m_BaseProperty->getWatchType();
+}
+
+void EventWatchSysteminfo::getWatchValue(int cnt)
+{
+ m_tmpStorageCnt = cnt;
+ processGetValue();
+}
+
+int EventWatchSysteminfo::getId() const
+{
+ return m_id;
+}
+
+void EventWatchSysteminfo::setId(int id)
+{
+ m_id = id;
+}
+
+void EventWatchSysteminfo::processGetValue()
+{
+ LoggerD("thread=" << DPL::Thread::GetCurrentThread());
+ JSValueRef lastValue = NULL;
+ JSValueRef lastValueList[MAX_STORAGE_CNT];
+ JSValueRef tmpValue = NULL;
+ JSValueRef tmpValueList[MAX_STORAGE_CNT];
+ JSStringRef propertyName = NULL;
+ std::string key;
+ JSObjectRef object = NULL;
+ JSValueRef value = NULL;
+ double level = 0.0, brightness = 0.0, load = 0.0;
+ bool isCharging = false;
+ double capacity[MAX_STORAGE_CNT];
+ double availableCapacity[MAX_STORAGE_CNT];
+ bool isRemovable[MAX_STORAGE_CNT];
+ int watchType = m_BaseProperty->getWatchType();
+
+ if(m_canceled) {
+ LoggerD("Watch event is cancelled aleardy.");
+ return;
+ }
+ if (m_Systeminfo == NULL) {
+ LoggerE("systeminfo pointer is not set");
+ return;
+ }
+
+ JSCallbackManagerPtr m_cbm = DPL::StaticPointerCast< JSCallbackManager >(getPrivateData());
+ JSContextRef context = m_cbm->getContext();
+
+ if (!m_setLastValue) {
+ lastValue = m_BaseProperty->getValue(context, (void*)((Systeminfo*)m_Systeminfo)->getConnectionHandle(), (void*)m_tapiHandle);
+ switch(watchType) {
+ case WATCH_TYPE_BATTERY :
+ key = "level";
+ object = JSValueToObject(context, lastValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ m_propertyValue.batterInfo.level = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ key = "isCharging";
+ object = JSValueToObject(context, lastValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ m_propertyValue.batterInfo.isCharging = JSValueToBoolean(context, JSObjectGetProperty(context, object, propertyName, NULL));
+ break;
+
+ case WATCH_TYPE_CPU :
+ key = "load";
+ object = JSValueToObject(context, lastValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ m_propertyValue.cpuInfo.load = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+ break;
+
+ case WATCH_TYPE_STORAGE:
+ if (m_tmpStorageCnt > MAX_STORAGE_CNT) {
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+
+ key = "units";
+ object = JSValueToObject(context, lastValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ value = JSObjectGetProperty(context, object, propertyName, NULL);
+
+ for (int i=0; i<m_tmpStorageCnt; i++) {
+
+ lastValueList[i] = JSGetArrayElement(context, JSValueToObject(context, value, NULL), i);
+
+ key = "capacity";
+ object = JSValueToObject(context, lastValueList[i], NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ m_propertyValue.storageInfo[i].capacity = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ key = "availableCapacity";
+ object = JSValueToObject(context, lastValueList[i], NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ m_propertyValue.storageInfo[i].availableCapacity = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ key = "isRemovable";
+ object = JSValueToObject(context, lastValueList[i], NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ m_propertyValue.storageInfo[i].isRemovable = JSValueToBoolean(context, JSObjectGetProperty(context, object, propertyName, NULL));
+ }
+
+ m_storageCnt = m_tmpStorageCnt;
+ break;
+
+ default :
+ LoggerD("default value");
+ break;
+ }
+ m_setLastValue = true;
+ return;
+ }
+
+ if (watchType == WATCH_TYPE_CPU) {
+ tmpValue = ((Systeminfo*)m_Systeminfo)->getCpuValue(context);
+ } else {
+ tmpValue = m_BaseProperty->getValue(context, (void*)((Systeminfo*)m_Systeminfo)->getConnectionHandle(), (void*)m_tapiHandle);
+ }
+
+ if (!tmpValue) {
+ return;
+ }
+
+ LoggerD("watchType : " << watchType);
+ switch(watchType) {
+ case WATCH_TYPE_BATTERY :
+ key = "level";
+ object = JSValueToObject(context, tmpValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ level = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ key = "isCharging";
+ object = JSValueToObject(context, tmpValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ isCharging = JSValueToBoolean(context, JSObjectGetProperty(context, object, propertyName, NULL));
+
+ if (m_propertyValue.batterInfo.level != level || m_propertyValue.batterInfo.isCharging != isCharging) {
+ if (((m_WatchOption.highThreshold > 0) && (level > m_WatchOption.highThreshold))
+ || ((m_WatchOption.lowThreshold > 0) && (level < m_WatchOption.lowThreshold))
+ || ((m_WatchOption.highThreshold == 0) && (m_WatchOption.lowThreshold == 0))) {
+ m_cbm->callOnSuccess(tmpValue);
+ setTimer();
+ }
+ }
+ m_propertyValue.batterInfo.level = level;
+ m_propertyValue.batterInfo.isCharging = isCharging;
+ break;
+
+ case WATCH_TYPE_CPU :
+ key = "load";
+ object = JSValueToObject(context, tmpValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ load = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ if (m_propertyValue.cpuInfo.load != load) {
+ if (((m_WatchOption.highThreshold > 0) && (load > m_WatchOption.highThreshold))
+ || ((m_WatchOption.lowThreshold > 0) && (load < m_WatchOption.lowThreshold))
+ || ((m_WatchOption.highThreshold == 0) && (m_WatchOption.lowThreshold == 0))) {
+ m_cbm->callOnSuccess(tmpValue);
+ setTimer();
+ }
+ }
+ m_propertyValue.cpuInfo.load = load;
+ break;
+
+ case WATCH_TYPE_STORAGE :
+ if (m_tmpStorageCnt > MAX_STORAGE_CNT) {
+ Throw(Exception);
+ }
+
+ key = "units";
+ object = JSValueToObject(context, tmpValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ value = JSObjectGetProperty(context, object, propertyName, NULL);
+
+ for (int i=0; i<m_tmpStorageCnt; i++) {
+ tmpValueList[i] = JSGetArrayElement(context, JSValueToObject(context, value, NULL), i);
+ key = "capacity";
+ object = JSValueToObject(context, tmpValueList[i], NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ capacity[i] = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ key = "availableCapacity";
+ object = JSValueToObject(context, tmpValueList[i], NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ availableCapacity[i] = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+
+ key = "isRemovable";
+ object = JSValueToObject(context, tmpValueList[i], NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ isRemovable[i] = JSValueToBoolean(context, JSObjectGetProperty(context, object, propertyName, NULL));
+ }
+
+ if (m_tmpStorageCnt == m_storageCnt) {
+ for (int k=0; k<m_tmpStorageCnt; k++) {
+ if (m_propertyValue.storageInfo[k].capacity != capacity[k] || m_propertyValue.storageInfo[k].availableCapacity != availableCapacity[k]
+ || m_propertyValue.storageInfo[k].isRemovable != isRemovable[k]) {
+ LoggerD("make callback / m_tmpStorageCnt : " << m_tmpStorageCnt);
+ m_cbm->callOnSuccess(tmpValue);
+ setTimer();
+ break;
+ }
+ }
+ } else {
+ LoggerD("make callback / m_tmpStorageCnt : " << m_tmpStorageCnt);
+ m_cbm->callOnSuccess(tmpValue);
+ setTimer();
+ }
+
+ m_storageCnt = m_tmpStorageCnt;
+ for (int j=0; j<m_tmpStorageCnt; j++) {
+ m_propertyValue.storageInfo[j].capacity = capacity[j];
+ m_propertyValue.storageInfo[j].availableCapacity = availableCapacity[j];
+ m_propertyValue.storageInfo[j].isRemovable = isRemovable[j];
+ }
+ break;
+
+ case WATCH_TYPE_DISPLAY :
+ key = "brightness";
+ object = JSValueToObject(context, tmpValue, NULL);
+ propertyName = JSStringCreateWithUTF8CString(key.c_str());
+ brightness = JSValueToNumber(context, JSObjectGetProperty(context, object, propertyName, NULL), NULL);
+ if (((m_WatchOption.highThreshold > 0) && (brightness > m_WatchOption.highThreshold))
+ || ((m_WatchOption.lowThreshold > 0) && (brightness < m_WatchOption.lowThreshold))
+ || ((m_WatchOption.highThreshold == 0) && (m_WatchOption.lowThreshold == 0))) {
+ LoggerD("make callback");
+ m_cbm->callOnSuccess(tmpValue);
+ setTimer();
+ }
+ break;
+
+ case WATCH_TYPE_WIFINETWORK :
+ case WATCH_TYPE_CELLULARNETWORK :
+ case WATCH_TYPE_DEVICE_ORIENTATION :
+ case WATCH_TYPE_NETWORK :
+ case WATCH_TYPE_LOCALE :
+ case WATCH_TYPE_PERIPHERAL :
+ LoggerD("make callback");
+ m_cbm->callOnSuccess(tmpValue);
+ setTimer();
+ break;
+ }
+}
+
+void EventWatchSysteminfo::setTimer()
+{
+ if (m_WatchOption.timeout > 0) {
+ if (m_initTimer) {
+ ecore_timer_freeze(m_initTimer);
+ ecore_timer_del(m_initTimer);
+ m_initTimer = NULL;
+ }
+ double value = m_WatchOption.timeout/(double)1000;
+ m_initTimer = ecore_timer_add(value, timeout_timer_cb, this);
+ ecore_timer_thaw(m_initTimer);
+ }
+}
+
+void EventWatchSysteminfo::removeTimer()
+{
+ if (m_initTimer) {
+ ecore_timer_freeze(m_initTimer);
+ ecore_timer_del(m_initTimer);
+ }
+ m_initTimer = NULL;
+}
+
+void EventWatchSysteminfo::clearWatch()
+{
+ m_canceled = true;
+ removeTimer();
+ ((Systeminfo*)m_Systeminfo)->clearWatch(m_id);
+}
+
+void EventWatchSysteminfo::timeoutWatch()
+{
+ clearWatch();
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/EventWatchSysteminfo.h b/mobile_src/Systeminfo/EventWatchSysteminfo.h
new file mode 100755
index 0000000..c03e78f
--- /dev/null
+++ b/mobile_src/Systeminfo/EventWatchSysteminfo.h
@@ -0,0 +1,102 @@
+//
+// 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 WRTPLUGINS_API_SYSTEMINFO_EVENT_WATCH_SYSTEMINFO_H_
+#define WRTPLUGINS_API_SYSTEMINFO_EVENT_WATCH_SYSTEMINFO_H_
+
+#include <ctime>
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <dpl/noncopyable.h>
+#include <Commons/IEvent.h>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include "ISysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+class EventWatchSysteminfo;
+
+struct BatteryPropertyValue {
+ double level;
+ bool isCharging;
+};
+
+struct CpuPropertyValue {
+ double load;
+};
+
+struct StoragePropertyValue {
+ unsigned long long capacity;
+ unsigned long long availableCapacity;
+ bool isRemovable;
+};
+
+struct PropertyValue {
+ BatteryPropertyValue batterInfo;
+ CpuPropertyValue cpuInfo;
+ StoragePropertyValue storageInfo[2];
+};
+
+class EventWatchSysteminfo : public WrtDeviceApis::Commons::IEvent<EventWatchSysteminfo>
+{
+ private :
+ static DPL::Atomic m_uniqId;
+
+ BasePropertyPtr m_BaseProperty;
+ WatchOption m_WatchOption;
+ void* m_Systeminfo;
+
+ Ecore_Timer *m_initTimer;
+ long m_id;
+ int m_watchType;
+ bool m_canceled;
+ DPL::Mutex m_mutex;
+ int m_storageCnt;
+ int m_tmpStorageCnt;
+ PropertyValue m_propertyValue;
+ bool m_setLastValue;
+ void* m_tapiHandle;
+
+ public :
+ EventWatchSysteminfo();
+ ~EventWatchSysteminfo();
+
+ void setTapiHandle(void* handle);
+ void setWatchOption(const WatchOption& watchoption);
+ WatchOption getWatchOption();
+ WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr getCallbackManager();
+ BasePropertyPtr getBasePropertyPtr();
+ void setSysteminfoPtr(void* SysteminfoPtr);
+ void setBasePropertyPtr(const BasePropertyPtr& baseProperty);
+ const char * getProperty() const;
+ const int getWatchType() const;
+ void getWatchValue(int cnt = 1);
+ int getId() const;
+ void setId(int id);
+ void processGetValue();
+ void setTimer();
+ void removeTimer();
+ void clearWatch();
+ void timeoutWatch();
+};
+
+typedef DPL::SharedPtr<EventWatchSysteminfo> EventWatchSysteminfoPtr;
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/ISysteminfo.cpp b/mobile_src/Systeminfo/ISysteminfo.cpp
new file mode 100755
index 0000000..11bf8a3
--- /dev/null
+++ b/mobile_src/Systeminfo/ISysteminfo.cpp
@@ -0,0 +1,36 @@
+//
+// 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 "ISysteminfo.h"
+#include "EventGetSysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::Commons;
+
+ISysteminfo::ISysteminfo() :
+ EventRequestReceiver<EventGetSysteminfo>(ThreadEnum::NULL_THREAD),
+ EventRequestReceiver<EventWatchSysteminfo>(ThreadEnum::NULL_THREAD)
+{
+}
+
+ISysteminfo::~ISysteminfo()
+{
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/ISysteminfo.h b/mobile_src/Systeminfo/ISysteminfo.h
new file mode 100755
index 0000000..694c887
--- /dev/null
+++ b/mobile_src/Systeminfo/ISysteminfo.h
@@ -0,0 +1,61 @@
+//
+// 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 WRTPLUGINS_API_ISYSTEMINFO_H_
+#define WRTPLUGINS_API_ISYSTEMINFO_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/ThreadPool.h>
+
+#include "BaseProperties.h"
+#include "EventGetSysteminfo.h"
+#include "EventWatchSysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+class EventGetSysteminfo;
+class EventWatchSysteminfo;
+typedef DPL::SharedPtr<EventGetSysteminfo> EventGetSysteminfoPtr;
+typedef DPL::SharedPtr<EventWatchSysteminfo> EventWatchSysteminfoPtr;
+
+class ISysteminfo :
+ public WrtDeviceApis::Commons::EventRequestReceiver<EventGetSysteminfo>,
+ public WrtDeviceApis::Commons::EventRequestReceiver<EventWatchSysteminfo>
+{
+ public:
+ virtual ~ISysteminfo();
+
+ virtual DeviceCapabilitiesPropertiesPtr getCapabilities() = 0;
+ virtual void get(const EventGetSysteminfoPtr& event) = 0;
+ virtual void watch(const EventWatchSysteminfoPtr& event) = 0;
+ virtual BasePropertyPtr getBasePropertyPtr(JSContextRef context, JSValueRef property) = 0;
+ virtual void clearWatch(const long id) = 0;
+
+ protected:
+ ISysteminfo();
+
+ virtual void OnRequestReceived(const EventGetSysteminfoPtr& event) = 0;
+ virtual void OnRequestReceived(const EventWatchSysteminfoPtr& event) = 0;
+};
+
+typedef DPL::SharedPtr<ISysteminfo> ISysteminfoPtr;
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/JSBatteryInfo.cpp b/mobile_src/Systeminfo/JSBatteryInfo.cpp
new file mode 100644
index 0000000..d430faf
--- /dev/null
+++ b/mobile_src/Systeminfo/JSBatteryInfo.cpp
@@ -0,0 +1,126 @@
+//
+// 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 <memory>
+#include "JSBatteryInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* BATTERY_LEVEL_PROPERTY = "level";
+const char* BATTERY_ISCHARGING_PROPERTY = "isCharging";
+}
+
+JSClassRef JSBatteryInfo::m_classRef = NULL;
+
+JSClassDefinition JSBatteryInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "batteryinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSBatteryInfo::m_properties[] = {
+ { BATTERY_LEVEL_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { BATTERY_ISCHARGING_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSBatteryInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSBatteryInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSBatteryInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSBatteryInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSBatteryPriv* priv = static_cast<JSBatteryPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting batteryInfo object");
+ delete priv;
+}
+
+bool JSBatteryInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSBatteryInfo::createJSObject(JSContextRef context, const BatteryPropertiesPtr batteryInfo)
+{
+ LoggerD("test");
+ JSBatteryPriv *priv = new JSBatteryPriv(context, batteryInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSBatteryInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSBatteryPriv *priv = static_cast<JSBatteryPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ BatteryPropertiesPtr batteryInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, BATTERY_LEVEL_PROPERTY)) {
+ return convert.toJSValueRef(batteryInfo->level);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, BATTERY_ISCHARGING_PROPERTY)) {
+ return convert.toJSValueRef(batteryInfo->isCharging);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/JSBatteryInfo.h b/mobile_src/Systeminfo/JSBatteryInfo.h
new file mode 100755
index 0000000..b9a7bbb
--- /dev/null
+++ b/mobile_src/Systeminfo/JSBatteryInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_BATTERY_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_BATTERY_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<BatteryPropertiesPtr>::Type JSBatteryPriv;
+
+class JSBatteryInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const BatteryPropertiesPtr batteryInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSBuildInfo.cpp b/mobile_src/Systeminfo/JSBuildInfo.cpp
new file mode 100755
index 0000000..a0d96ac
--- /dev/null
+++ b/mobile_src/Systeminfo/JSBuildInfo.cpp
@@ -0,0 +1,129 @@
+//
+// 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 <memory>
+#include "JSBuildInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* BUILD_MODEL_PROPERTY = "model";
+const char* BUILD_MANUFACTURER_PROPERTY = "manufacturer";
+const char* BUILD_BUILD_PROPERTY = "buildVersion";
+
+}
+
+JSClassRef JSBuildInfo::m_classRef = NULL;
+
+JSClassDefinition JSBuildInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "buildinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSBuildInfo::m_properties[] = {
+ { BUILD_MODEL_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { BUILD_MANUFACTURER_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { BUILD_BUILD_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSBuildInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSBuildInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSBuildInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSBuildInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSBuildPriv* priv = static_cast<JSBuildPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting buildInfo object");
+ delete priv;
+}
+
+bool JSBuildInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSBuildInfo::createJSObject(JSContextRef context, const BuildPropertiesPtr buildInfo)
+{
+ JSBuildPriv *priv = new JSBuildPriv(context, buildInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSBuildInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSBuildPriv *priv = static_cast<JSBuildPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ BuildPropertiesPtr buildInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, BUILD_MODEL_PROPERTY)) {
+ return convert.toJSValueRef(buildInfo->model);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, BUILD_MANUFACTURER_PROPERTY)) {
+ return convert.toJSValueRef(buildInfo->manufacturer);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, BUILD_BUILD_PROPERTY)) {
+ return convert.toJSValueRef(buildInfo->buildVersion);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSBuildInfo.h b/mobile_src/Systeminfo/JSBuildInfo.h
new file mode 100755
index 0000000..4e765be
--- /dev/null
+++ b/mobile_src/Systeminfo/JSBuildInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_BUILD_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_BUILD_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<BuildPropertiesPtr>::Type JSBuildPriv;
+
+class JSBuildInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const BuildPropertiesPtr buildInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSCellularNetworkInfo.cpp b/mobile_src/Systeminfo/JSCellularNetworkInfo.cpp
new file mode 100755
index 0000000..0c84d4d
--- /dev/null
+++ b/mobile_src/Systeminfo/JSCellularNetworkInfo.cpp
@@ -0,0 +1,168 @@
+//
+// 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 <memory>
+#include <JSWebAPIErrorFactory.h>
+#include <SecurityExceptions.h>
+#include "JSCellularNetworkInfo.h"
+#include "plugin_config.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace {
+const char* CELLULARNETWORK_STATUS_PROPERTY = "status";
+const char* CELLULARNETWORK_APN_PROPERTY = "apn";
+const char* CELLULARNETWORK_IPADDRESS_PROPERTY = "ipAddress";
+const char* CELLULARNETWORK_IPV6ADDRESS_PROPERTY = "ipv6Address";
+const char* CELLULARNETWORK_MCC_PROPERTY = "mcc";
+const char* CELLULARNETWORK_MNC_PROPERTY = "mnc";
+const char* CELLULARNETWORK_CELLID_PROPERTY = "cellId";
+const char* CELLULARNETWORK_LAC_PROPERTY = "lac";
+const char* CELLULARNETWORK_ROAMING_PROPERTY = "isRoaming";
+const char* CELLULARNETWORK_FLIGHT_MODE_PROPERTY = "isFlightMode";
+const char* CELLULARNETWORK_IMEI_PROPERTY = "imei";
+}
+
+JSClassRef JSCellularNetworkInfo::m_classRef = NULL;
+
+JSClassDefinition JSCellularNetworkInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "cellularnetworkinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSCellularNetworkInfo::m_properties[] = {
+ { CELLULARNETWORK_STATUS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_APN_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_IPADDRESS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_IPV6ADDRESS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_MCC_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_MNC_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_CELLID_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_LAC_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_ROAMING_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_FLIGHT_MODE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { CELLULARNETWORK_IMEI_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSCellularNetworkInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSCellularNetworkInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSCellularNetworkInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSCellularNetworkInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSCellularNetworkPriv* priv = static_cast<JSCellularNetworkPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting CellularNetworkInfo object");
+ delete priv;
+}
+
+bool JSCellularNetworkInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSCellularNetworkInfo::createJSObject(JSContextRef context, const CellularNetworkPropertiesPtr cellularNetworkInfo)
+{
+ LoggerD("Enter");
+ JSCellularNetworkPriv *priv = new JSCellularNetworkPriv(context, cellularNetworkInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSCellularNetworkInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSCellularNetworkPriv *priv = static_cast<JSCellularNetworkPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ CellularNetworkPropertiesPtr cellularNetworkInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_STATUS_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->status);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_APN_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->apn);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_IPADDRESS_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->ipAddress);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_IPV6ADDRESS_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->ipv6Address);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_MCC_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->mcc);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_MNC_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->mnc);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_CELLID_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->cellId);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_LAC_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->lac);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_ROAMING_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->isRoaming);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_FLIGHT_MODE_PROPERTY)) {
+ return convert.toJSValueRef(cellularNetworkInfo->isFlightMode);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_IMEI_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+ return convert.toJSValueRef(cellularNetworkInfo->imei);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSCellularNetworkInfo.h b/mobile_src/Systeminfo/JSCellularNetworkInfo.h
new file mode 100755
index 0000000..b68a6f9
--- /dev/null
+++ b/mobile_src/Systeminfo/JSCellularNetworkInfo.h
@@ -0,0 +1,49 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_CELLULARNETWORK_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_CELLULARNETWORK_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <SecurityExceptions.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<CellularNetworkPropertiesPtr>::Type JSCellularNetworkPriv;
+
+class JSCellularNetworkInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const CellularNetworkPropertiesPtr cellularNetworkInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSCpuInfo.cpp b/mobile_src/Systeminfo/JSCpuInfo.cpp
new file mode 100644
index 0000000..36cf77d
--- /dev/null
+++ b/mobile_src/Systeminfo/JSCpuInfo.cpp
@@ -0,0 +1,121 @@
+//
+// 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 <memory>
+#include "JSCpuInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* CPU_LOAD_PROPERTY = "load";
+}
+
+JSClassRef JSCpuInfo::m_classRef = NULL;
+
+JSClassDefinition JSCpuInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "cpuinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSCpuInfo::m_properties[] = {
+ { CPU_LOAD_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSCpuInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSCpuInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSCpuInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSCpuInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSCpuPriv* priv = static_cast<JSCpuPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting CpuInfo object");
+ delete priv;
+}
+
+bool JSCpuInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSCpuInfo::createJSObject(JSContextRef context, const CpuPropertiesPtr cpuInfo)
+{
+ LoggerD("Enter");
+ JSCpuPriv *priv = new JSCpuPriv(context, cpuInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSCpuInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSCpuPriv *priv = static_cast<JSCpuPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ CpuPropertiesPtr cpuInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, CPU_LOAD_PROPERTY)) {
+ return convert.toJSValueRef(cpuInfo->load);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSCpuInfo.h b/mobile_src/Systeminfo/JSCpuInfo.h
new file mode 100755
index 0000000..71fc969
--- /dev/null
+++ b/mobile_src/Systeminfo/JSCpuInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_CPU_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_CPU_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<CpuPropertiesPtr>::Type JSCpuPriv;
+
+class JSCpuInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const CpuPropertiesPtr cpuInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSDeviceCapabilitiesInfo.cpp b/mobile_src/Systeminfo/JSDeviceCapabilitiesInfo.cpp
new file mode 100755
index 0000000..771b0ee
--- /dev/null
+++ b/mobile_src/Systeminfo/JSDeviceCapabilitiesInfo.cpp
@@ -0,0 +1,1019 @@
+//
+// 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 <fstream>
+#include <pcrecpp.h>
+#include <memory>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <JSWebAPIErrorFactory.h>
+#include <SecurityExceptions.h>
+#include <sensors.h>
+#include <system_info.h>
+#include <pkgmgr-info.h>
+#include "JSDeviceCapabilitiesInfo.h"
+#include "plugin_config.h"
+#include <Logger.h>
+
+#define MAXBUFSIZE 256
+#define DEVICE_PROFILE "MOBILE_FULL"
+#define DUID_KEY_STRING 28
+#define DUID_BUFFER_SIZE 100
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace {
+const char* DEVICE_CAPABILITIES_BLUETOOTH = "bluetooth";
+const char* DEVICE_CAPABILITIES_NFC = "nfc";
+const char* DEVICE_CAPABILITIES_NFC_RESERVED_PUSH = "nfcReservedPush";
+const char* DEVICE_CAPABILITIES_MULTITOUCHCOUNT = "multiTouchCount";
+const char* DEVICE_CAPABILITIES_INPUTKEYBOARD = "inputKeyboard";
+const char* DEVICE_CAPABILITIES_INPUTKEYBOARD_LAYOUT = "inputKeyboardLayout";
+const char* DEVICE_CAPABILITIES_WIFI = "wifi";
+const char* DEVICE_CAPABILITIES_WIFIDIRECT = "wifiDirect";
+const char* DEVICE_CAPABILITIES_OPENGLES = "opengles";
+const char* DEVICE_CAPABILITIES_OPENGLES_TEXTURE_FORMAT = "openglestextureFormat";
+const char* DEVICE_CAPABILITIES_OPENGLESVERSION1_1 = "openglesVersion1_1";
+const char* DEVICE_CAPABILITIES_OPENGLESVERSION2_0 = "openglesVersion2_0";
+const char* DEVICE_CAPABILITIES_FMRADIO = "fmRadio";
+const char* DEVICE_CAPABILITIES_PLATFORMVERSION = "platformVersion";
+const char* DEVICE_CAPABILITIES_PLATFORMNAME = "platformName";
+const char* DEVICE_CAPABILITIES_WEBAPIVERSION = "webApiVersion";
+const char* DEVICE_CAPABILITIES_NATIVEAPIVERSION = "nativeApiVersion";
+const char* DEVICE_CAPABILITIES_CAMERA = "camera";
+const char* DEVICE_CAPABILITIES_CAMERAFRONT = "cameraFront";
+const char* DEVICE_CAPABILITIES_CAMERAFRONTFLASH = "cameraFrontFlash";
+const char* DEVICE_CAPABILITIES_CAMERABACK = "cameraBack";
+const char* DEVICE_CAPABILITIES_CAMERABACKFLASH = "cameraBackFlash";
+const char* DEVICE_CAPABILITIES_LOCATION = "location";
+const char* DEVICE_CAPABILITIES_LOCATIONGPS = "locationGps";
+const char* DEVICE_CAPABILITIES_LOCATIONWPS = "locationWps";
+const char* DEVICE_CAPABILITIES_MICROPHONE = "microphone";
+const char* DEVICE_CAPABILITIES_USBHOST = "usbHost";
+const char* DEVICE_CAPABILITIES_USBACCESSORY = "usbAccessory";
+const char* DEVICE_CAPABILITIES_SCREENOUTPUTRCA = "screenOutputRca";
+const char* DEVICE_CAPABILITIES_SCREENOUTPUTHDMI = "screenOutputHdmi";
+const char* DEVICE_CAPABILITIES_PLATFORMCORECPUARCH = "platformCoreCpuArch";
+const char* DEVICE_CAPABILITIES_PLATFORMCOREFPUARCH = "platformCoreFpuArch";
+const char* DEVICE_CAPABILITIES_SIPVOIP = "sipVoip";
+const char* DEVICE_CAPABILITIES_DUID = "duid";
+const char* DEVICE_CAPABILITIES_SPEECH_ROCOGNITION = "speechRecognition";
+const char* DEVICE_CAPABILITIES_SPEECH_SYNTHESIS = "speechSynthesis";
+const char* DEVICE_CAPABILITIES_ACCELEROMETER = "accelerometer";
+const char* DEVICE_CAPABILITIES_ACCELEROMETER_WAKEUP = "accelerometerWakeup";
+const char* DEVICE_CAPABILITIES_BAROMETER = "barometer";
+const char* DEVICE_CAPABILITIES_BAROMETER_WAKEUP = "barometerWakeup";
+const char* DEVICE_CAPABILITIES_GYROSCOPE = "gyroscope";
+const char* DEVICE_CAPABILITIES_GYROSCOPE_WAKEUP = "gyroscopeWakeup";
+const char* DEVICE_CAPABILITIES_MAGNETOMETER = "magnetometer";
+const char* DEVICE_CAPABILITIES_MAGNETOMETER_WAKEUP = "magnetometerWakeup";
+const char* DEVICE_CAPABILITIES_PHOTOMETER = "photometer";
+const char* DEVICE_CAPABILITIES_PHOTOMETER_WAKEUP = "photometerWakeup";
+const char* DEVICE_CAPABILITIES_PROXIMITY = "proximity";
+const char* DEVICE_CAPABILITIES_PROXIMITY_WAKEUP = "proximityWakeup";
+const char* DEVICE_CAPABILITIES_TILTMETER = "tiltmeter";
+const char* DEVICE_CAPABILITIES_TILTMETER_WAKEUP = "tiltmeterWakeup";
+const char* DEVICE_CAPABILITIES_DATA_ENCRYPTION = "dataEncryption";
+const char* DEVICE_CAPABILITIES_GRAPHICS_ACCELERATION = "graphicsAcceleration";
+const char* DEVICE_CAPABILITIES_PUSH = "push";
+const char* DEVICE_CAPABILITIES_TELEPHONY = "telephony";
+const char* DEVICE_CAPABILITIES_TELEPHONY_MMS = "telephonyMms";
+const char* DEVICE_CAPABILITIES_TELEPHONY_SMS = "telephonySms";
+const char* DEVICE_CAPABILITIES_SCREENSIZE_NORMAL = "screenSizeNormal";
+const char* DEVICE_CAPABILITIES_SCREENSIZE_480_800 = "screenSize480_800";
+const char* DEVICE_CAPABILITIES_SCREENSIZE_720_1280 = "screenSize720_1280";
+const char* DEVICE_CAPABILITIES_AUTO_ROTATION = "autoRotation";
+const char* DEVICE_CAPABILITIES_SHELL_APP_WIDGET = "shellAppWidget";
+const char* DEVICE_CAPABILITIES_VISION_IMAGE_RECOGNITION = "visionImageRecognition";
+const char* DEVICE_CAPABILITIES_VISION_QRCODE_GENERATION = "visionQrcodeGeneration";
+const char* DEVICE_CAPABILITIES_VISION_QRCODE_RECOGNITION = "visionQrcodeRecognition";
+const char* DEVICE_CAPABILITIES_VISION_FACE_RECOGNITION = "visionFaceRecognition";
+const char* DEVICE_CAPABILITIES_SECURE_ELEMENT = "secureElement";
+const char* DEVICE_CAPABILITIES_NATIVE_OSP_COMPATIBLE = "nativeOspCompatible";
+const char* DEVICE_CAPABILITIES_PROFILE = "profile";
+}
+
+JSClassRef JSDeviceCapabilitiesInfo::m_classRef = NULL;
+
+JSClassDefinition JSDeviceCapabilitiesInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "devicecapabilitiesinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSDeviceCapabilitiesInfo::m_properties[] = {
+ { DEVICE_CAPABILITIES_BLUETOOTH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_NFC, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_NFC_RESERVED_PUSH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_MULTITOUCHCOUNT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_INPUTKEYBOARD, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_INPUTKEYBOARD_LAYOUT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_WIFI, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_WIFIDIRECT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_OPENGLES, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_OPENGLES_TEXTURE_FORMAT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_OPENGLESVERSION1_1, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_OPENGLESVERSION2_0, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_FMRADIO, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PLATFORMVERSION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PLATFORMNAME, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_WEBAPIVERSION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_NATIVEAPIVERSION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_CAMERA, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_CAMERAFRONT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_CAMERAFRONTFLASH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_CAMERABACK, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_CAMERABACKFLASH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_LOCATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_LOCATIONGPS, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_LOCATIONWPS, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_MICROPHONE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_USBHOST, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_USBACCESSORY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SCREENOUTPUTRCA, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SCREENOUTPUTHDMI, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PLATFORMCORECPUARCH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PLATFORMCOREFPUARCH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SIPVOIP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_DUID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SPEECH_ROCOGNITION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SPEECH_SYNTHESIS, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_ACCELEROMETER, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_ACCELEROMETER_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_BAROMETER, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_BAROMETER_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_GYROSCOPE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_GYROSCOPE_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_MAGNETOMETER, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_MAGNETOMETER_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PHOTOMETER, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PHOTOMETER_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PROXIMITY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PROXIMITY_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_TILTMETER, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_TILTMETER_WAKEUP, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_DATA_ENCRYPTION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_GRAPHICS_ACCELERATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PUSH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_TELEPHONY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_TELEPHONY_MMS, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_TELEPHONY_SMS, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SCREENSIZE_NORMAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SCREENSIZE_480_800, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SCREENSIZE_720_1280, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_AUTO_ROTATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SHELL_APP_WIDGET, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_VISION_IMAGE_RECOGNITION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_VISION_QRCODE_GENERATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_VISION_QRCODE_RECOGNITION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_VISION_FACE_RECOGNITION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_SECURE_ELEMENT, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_NATIVE_OSP_COMPATIBLE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICE_CAPABILITIES_PROFILE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSDeviceCapabilitiesInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSDeviceCapabilitiesInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSDeviceCapabilitiesInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSDeviceCapabilitiesInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSDeviceCapabilitiesPriv* priv = static_cast<JSDeviceCapabilitiesPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting DeviceCapabilitiesInfo object");
+ delete priv;
+}
+
+bool JSDeviceCapabilitiesInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSDeviceCapabilitiesInfo::createJSObject(JSContextRef context, const DeviceCapabilitiesPropertiesPtr deviceCapabilitiesInfo)
+{
+ LoggerD("Enter");
+ JSDeviceCapabilitiesPriv *priv = new JSDeviceCapabilitiesPriv(context, deviceCapabilitiesInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSDeviceCapabilitiesInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSDeviceCapabilitiesPriv *priv = static_cast<JSDeviceCapabilitiesPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ DeviceCapabilitiesPropertiesPtr deviceCapabilitiesInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_BLUETOOTH)) {
+ bool bluetooth = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.bluetooth", &bluetooth) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->bluetooth = bluetooth;
+ } else {
+ LoggerE("get fail bluetooth value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->bluetooth);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NFC)) {
+ bool nfc = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.nfc", &nfc) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->nfc = nfc;
+ } else {
+ LoggerE("get fail nfc value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->nfc);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NFC_RESERVED_PUSH)) {
+ bool nfcReservedPush = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.nfc.reserved_push", &nfcReservedPush) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->nfcReservedPush = nfcReservedPush;
+ } else {
+ LoggerE("get fail nfc reserved push value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->nfcReservedPush);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MULTITOUCHCOUNT)) {
+ int multiTouchCount = 0;
+ if(system_info_get_platform_int("tizen.org/feature/multi_point_touch.point_count", &multiTouchCount) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->multiTouchCount = multiTouchCount;
+ } else {
+ LoggerE("get fail multiTouchCount value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->multiTouchCount);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_INPUTKEYBOARD)) {
+ bool inputKeyboard = false;
+ if(system_info_get_platform_bool("tizen.org/feature/input.keyboard", &inputKeyboard) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->inputKeyboard = inputKeyboard;
+ } else {
+ LoggerE("get fail inputKeyboard value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyboard);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_INPUTKEYBOARD_LAYOUT)) {
+ bool inputKeyboard = false;
+ if(system_info_get_platform_bool("tizen.org/feature/input.keyboard", &inputKeyboard) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->inputKeyboardLayout = inputKeyboard;
+ } else {
+ LoggerE("get fail inputKeyboardLayout value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->inputKeyboardLayout);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WIFI)) {
+ bool wifi = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.wifi", &wifi) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->wifi = wifi;
+ } else {
+ LoggerE("get fail wifi value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->wifi);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WIFIDIRECT)) {
+ bool wifiDirect = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.wifi.direct", &wifiDirect) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->wifiDirect = wifiDirect;
+ } else {
+ LoggerE("get fail wifiDirect value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->wifiDirect);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLES)) {
+ bool opengles = NULL;
+ if(system_info_get_platform_bool("tizen.org/feature/opengles", &opengles) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->opengles = opengles;
+ } else {
+ LoggerE("get fail opengles value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->opengles);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLES_TEXTURE_FORMAT)) {
+ bool texture = false;
+ bool data = false;
+ char* textureFormat = NULL;
+ char textureFormatFull[MAXBUFSIZE];
+ textureFormatFull[0] = '\0';
+
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.utc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ strcat(textureFormatFull, "utc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.ptc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "ptc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.etc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "etc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.3dc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "3dc");
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.atc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "atc");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/opengles.texture_format.pvrtc", &texture) == SYSTEM_INFO_ERROR_NONE && texture == true) {
+ if (data) {
+ strcat(textureFormatFull, " | ");
+ }
+ strcat(textureFormatFull, "pvrtc");
+ }
+
+ textureFormat = strdup(textureFormatFull);
+
+ if (textureFormat == NULL) {
+ LoggerE("get fail openglestextureFormat value");
+ return JSValueMakeUndefined(context);
+ }
+
+ deviceCapabilitiesInfo->openglestextureFormat = textureFormat;
+ free(textureFormat);
+
+ return convert.toJSValueRef(deviceCapabilitiesInfo->openglestextureFormat);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLESVERSION1_1)) {
+ bool openglesVersion1_1 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/opengles.version.1_1", &openglesVersion1_1) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->openglesVersion1_1 = openglesVersion1_1;
+ } else {
+ LoggerE("get fail openglesVersion1_1 value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->openglesVersion1_1);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_OPENGLESVERSION2_0)) {
+ bool openglesVersion2_0 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/opengles.version.2_0", &openglesVersion2_0) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->openglesVersion2_0 = openglesVersion2_0;
+ } else {
+ LoggerE("get fail openglesVersion2_0 value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->openglesVersion2_0);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_FMRADIO)) {
+ bool fmRadio = false;
+ if(system_info_get_platform_bool("tizen.org/feature/fmradio", &fmRadio) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->fmRadio = fmRadio;
+ } else {
+ LoggerE("get fail fmRadio value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->fmRadio);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMVERSION)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ char* platformVersion = NULL;
+ if(system_info_get_platform_string("tizen.org/feature/platform.version", &platformVersion) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->platformVersion = platformVersion;
+ free(platformVersion);
+ } else {
+ LoggerE("get fail platformVersion value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->platformVersion);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMNAME)) {
+ char* platformName = NULL;
+ if(system_info_get_platform_string("tizen.org/system/platform.name", &platformName) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->platformName = platformName;
+ free(platformName);
+ } else {
+ LoggerE("get fail platformName value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->platformName);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_WEBAPIVERSION)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ char* webApiVersion = NULL;
+ if(system_info_get_platform_string("tizen.org/feature/platform.web.api.version", &webApiVersion) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->webApiVersion = webApiVersion;
+ free(webApiVersion);
+ } else {
+ LoggerE("get fail webApiVersion value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->webApiVersion);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NATIVEAPIVERSION)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ char* nativeApiVersion = NULL;
+ if(system_info_get_platform_string("tizen.org/feature/platform.native.api.version", &nativeApiVersion) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->nativeApiVersion = nativeApiVersion;
+ free(nativeApiVersion);
+ } else {
+ LoggerE("get fail nativeApiVersion value");
+ deviceCapabilitiesInfo->nativeApiVersion = "";
+ free(nativeApiVersion);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->nativeApiVersion);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERAFRONT)) {
+ bool cameraFront = false;
+ if(system_info_get_platform_bool("tizen.org/feature/camera.front", &cameraFront) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->cameraFront = cameraFront;
+ } else {
+ LoggerE("get fail cameraFront value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->cameraFront);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERA)) {
+ bool camera = false;
+ if(system_info_get_platform_bool("tizen.org/feature/camera", &camera) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->camera = camera;
+ } else {
+ LoggerE("get fail camera value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->camera);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERAFRONTFLASH)) {
+ bool cameraFrontFlash = false;
+ if(system_info_get_platform_bool("tizen.org/feature/camera.front.flash", &cameraFrontFlash) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->cameraFrontFlash = cameraFrontFlash;
+ } else {
+ LoggerE("get fail cameraFrontFlash value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->cameraFrontFlash);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERABACK)) {
+ bool cameraBack = false;
+ if(system_info_get_platform_bool("tizen.org/feature/camera.back", &cameraBack) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->cameraBack = cameraBack;
+ } else {
+ LoggerE("get fail cameraBack value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->cameraBack);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_CAMERABACKFLASH)) {
+ bool cameraBackFlash = false;
+ if(system_info_get_platform_bool("tizen.org/feature/camera.back.flash", &cameraBackFlash) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->cameraBackFlash = cameraBackFlash;
+ } else {
+ LoggerE("get fail cameraBackFlash value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->cameraBackFlash);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_LOCATION)) {
+ bool location = false;
+ if(system_info_get_platform_bool("tizen.org/feature/location", &location) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->location = location;
+ } else {
+ LoggerE("get fail location value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->location);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_LOCATIONGPS)) {
+ bool locationGps = false;
+ if(system_info_get_platform_bool("tizen.org/feature/location.gps", &locationGps) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->locationGps = locationGps;
+ } else {
+ LoggerE("get fail locationGps value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->locationGps);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_LOCATIONWPS)) {
+ bool locationWps = false;
+ if(system_info_get_platform_bool("tizen.org/feature/location.wps", &locationWps) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->locationWps = locationWps;
+ } else {
+ LoggerE("get fail locationWps value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->locationWps);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MICROPHONE)) {
+ bool microphone = false;
+ if(system_info_get_platform_bool("tizen.org/feature/microphone", &microphone) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->microphone = microphone;
+ } else {
+ LoggerE("get fail microphone value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->microphone);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_USBHOST)) {
+ bool usbHost = false;
+ if(system_info_get_platform_bool("tizen.org/feature/usb.host", &usbHost) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->usbHost = usbHost;
+ } else {
+ LoggerE("get fail usbHost value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->usbHost);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_USBACCESSORY)) {
+ bool usbAccessory = false;
+ if(system_info_get_platform_bool("tizen.org/feature/usb.accessory", &usbAccessory) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->usbAccessory = usbAccessory;
+ } else {
+ LoggerE("get fail usbAccessory value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->usbAccessory);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENOUTPUTRCA)) {
+ bool screenOutputRca = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.output.rca", &screenOutputRca) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenOutputRca = screenOutputRca;
+ } else {
+ LoggerE("get fail screenOutputRca value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->screenOutputRca);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENOUTPUTHDMI)) {
+ bool screenOutputHdmi = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.output.hdmi", &screenOutputHdmi) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenOutputHdmi = screenOutputHdmi;
+ } else {
+ LoggerE("get fail screenOutputHdmi value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->screenOutputHdmi);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMCORECPUARCH)) {
+ bool cpuArch = false;
+ bool data = false;
+ char* platformCoreCpuArch = NULL;
+ char platformCoreCpuArchFull[MAXBUFSIZE];
+ platformCoreCpuArchFull[0] = '\0';
+
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.armv6", &cpuArch) == SYSTEM_INFO_ERROR_NONE && cpuArch == true) {
+ strcat(platformCoreCpuArchFull, "armv6");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.armv7", &cpuArch) == SYSTEM_INFO_ERROR_NONE && cpuArch == true) {
+ if (data) {
+ strcat(platformCoreCpuArchFull, " | ");
+ }
+ strcat(platformCoreCpuArchFull, "armv7");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.cpu.arch.x86", &cpuArch) == SYSTEM_INFO_ERROR_NONE && cpuArch == true) {
+ if (data) {
+ strcat(platformCoreCpuArchFull, " | ");
+ }
+ strcat(platformCoreCpuArchFull, "x86");
+ }
+
+ platformCoreCpuArch = strdup(platformCoreCpuArchFull);
+
+ if (platformCoreCpuArch == NULL) {
+ LoggerE("get fail platformCoreCpuArch value");
+ return JSValueMakeUndefined(context);
+ }
+
+ deviceCapabilitiesInfo->platformCoreCpuArch = platformCoreCpuArch;
+ free(platformCoreCpuArch);
+
+ return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreCpuArch);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PLATFORMCOREFPUARCH)) {
+ bool fpuArch = false;
+ bool data = false;
+ char* platformCoreFpuArch = NULL;
+ char platformCoreFpuArchFull[MAXBUFSIZE];
+ platformCoreFpuArchFull[0] = '\0';
+
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.sse2", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ data = true;
+ strcat(platformCoreFpuArchFull, "sse2");
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.sse3", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "sse3");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.ssse3", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "ssse3");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.vfpv2", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "vfpv2");
+ data = true;
+ }
+ if (system_info_get_platform_bool("tizen.org/feature/platform.core.fpu.arch.vfpv3", &fpuArch) == SYSTEM_INFO_ERROR_NONE && fpuArch == true) {
+ if(data) {
+ strcat(platformCoreFpuArchFull, " | ");
+ }
+ strcat(platformCoreFpuArchFull, "vfpv3");
+ }
+ platformCoreFpuArch = strdup(platformCoreFpuArchFull);
+
+ if (platformCoreFpuArch == NULL) {
+ LoggerE("get fail platformCoreFpuArch value");
+ return JSValueMakeUndefined(context);
+ }
+
+ deviceCapabilitiesInfo->platformCoreFpuArch = platformCoreFpuArch;
+ free(platformCoreFpuArch);
+
+ return convert.toJSValueRef(deviceCapabilitiesInfo->platformCoreFpuArch);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SIPVOIP)) {
+ bool sipVoip = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sip.voip", &sipVoip) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->sipVoip = sipVoip;
+ } else {
+ LoggerE("get fail sipVoip value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->sipVoip);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_DUID)) {
+ FILE *fp = NULL;
+ char duid[DUID_BUFFER_SIZE] = {0,};
+ fp = fopen("/opt/usr/etc/system_info_cache.ini", "r");
+
+ if(fp == NULL) {
+ LoggerD("fail file open.");
+ return convert.toJSValueRef(deviceCapabilitiesInfo->duid);
+ }
+ while(fgets(duid, DUID_BUFFER_SIZE-1, fp)) {
+ if (strncmp(duid, "http://tizen.org/system/duid", DUID_KEY_STRING) == 0) {
+ char* token = NULL;
+ char* ptr = NULL;
+ token = strtok_r(duid, "=\r\n", &ptr);
+ if (token != NULL) {
+ token = strtok_r(NULL, "=\r\n", &ptr);
+ if (token != NULL) {
+ deviceCapabilitiesInfo->duid = token;
+ LoggerD("deviceCapabilitiesInfo->duid : " << deviceCapabilitiesInfo->duid);
+ }
+ }
+ break;
+ }
+ }
+ fclose(fp);
+ return convert.toJSValueRef(deviceCapabilitiesInfo->duid);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SPEECH_ROCOGNITION)) {
+ bool speechRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/speech.recognition", &speechRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->speechRecognition = speechRecognition;
+ } else {
+ LoggerE("get fail speechRecognition value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->speechRecognition);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SPEECH_SYNTHESIS)) {
+ bool speechSynthesis = false;
+ if(system_info_get_platform_bool("tizen.org/feature/speech.synthesis", &speechSynthesis) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->speechSynthesis = speechSynthesis;
+ } else {
+ LoggerE("get fail speechSynthesis value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->speechSynthesis);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_ACCELEROMETER)) {
+ bool accelerometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.accelerometer", &accelerometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->accelerometer = accelerometer;
+ } else {
+ LoggerE("get fail accelerometer value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->accelerometer);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_ACCELEROMETER_WAKEUP)) {
+ bool accelerometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.accelerometer.wakeup", &accelerometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->accelerometerWakeup = accelerometerWakeup;
+ } else {
+ LoggerE("get fail accelerometerWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->accelerometerWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_BAROMETER)) {
+ bool barometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.barometer", &barometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->barometer = barometer;
+ } else {
+ LoggerE("get fail barometer value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->barometer);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_BAROMETER_WAKEUP)) {
+ bool barometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.barometer.wakeup", &barometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->barometerWakeup = barometerWakeup;
+ } else {
+ LoggerE("get fail barometerWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->barometerWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_GYROSCOPE)) {
+ bool gyroscope = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.gyroscope", &gyroscope) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->gyroscope = gyroscope;
+ } else {
+ LoggerE("get fail gyroscope value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->gyroscope);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_GYROSCOPE_WAKEUP)) {
+ bool gyroscopeWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.gyroscope.wakeup", &gyroscopeWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->gyroscopeWakeup = gyroscopeWakeup;
+ } else {
+ LoggerE("get fail gyroscopeWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->gyroscopeWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MAGNETOMETER)) {
+ bool magnetometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.magnetometer", &magnetometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->magnetometer = magnetometer;
+ } else {
+ LoggerE("get fail magnetometer value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->magnetometer);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_MAGNETOMETER_WAKEUP)) {
+ bool magnetometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.magnetometer.wakeup", &magnetometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->magnetometerWakeup = magnetometerWakeup;
+ } else {
+ LoggerE("get fail magnetometerWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->magnetometerWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PHOTOMETER)) {
+ bool photometer = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.photometer", &photometer) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->photometer = photometer;
+ } else {
+ LoggerE("get fail photometer value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->photometer);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PHOTOMETER_WAKEUP)) {
+ bool photometerWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.photometer.wakeup", &photometerWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->photometerWakeup = photometerWakeup;
+ } else {
+ LoggerE("get fail photometerWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->photometerWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROXIMITY)) {
+ bool proximity = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.proximity", &proximity) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->proximity = proximity;
+ } else {
+ LoggerE("get fail proximity value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->proximity);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROXIMITY_WAKEUP)) {
+ bool proximityWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.proximity.wakeup", &proximityWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->proximityWakeup = proximityWakeup;
+ } else {
+ LoggerE("get fail proximityWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->proximityWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TILTMETER)) {
+ bool tiltmeter = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.tiltmeter", &tiltmeter) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->tiltmeter = tiltmeter;
+ } else {
+ LoggerE("get fail tiltmeter value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->tiltmeter);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TILTMETER_WAKEUP)) {
+ bool tiltmeterWakeup = false;
+ if(system_info_get_platform_bool("tizen.org/feature/sensor.tiltmeter.wakeup", &tiltmeterWakeup) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->tiltmeterWakeup = tiltmeterWakeup;
+ } else {
+ LoggerE("get fail tiltmeterWakeup value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->tiltmeterWakeup);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_DATA_ENCRYPTION)) {
+ bool dataEncryption = false;
+ if(system_info_get_platform_bool("tizen.org/feature/database.encryption", &dataEncryption) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->dataEncryption = dataEncryption;
+ } else {
+ LoggerE("get fail dataEncryption value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->dataEncryption);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_GRAPHICS_ACCELERATION)) {
+ bool graphicsAcceleration = false;
+ if(system_info_get_platform_bool("tizen.org/feature/graphics.acceleration", &graphicsAcceleration) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->graphicsAcceleration = graphicsAcceleration;
+ } else {
+ LoggerE("get fail graphicsAcceleration value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->graphicsAcceleration);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PUSH)) {
+ bool push = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.push", &push) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->push = push;
+ } else {
+ LoggerE("get fail push value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->push);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TELEPHONY)) {
+ bool telephony = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.telephony", &telephony) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->telephony = telephony;
+ } else {
+ LoggerE("get fail telephony value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->telephony);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TELEPHONY_MMS)) {
+ bool telephonyMms = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.telephony.mms", &telephonyMms) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->telephonyMms = telephonyMms;
+ } else {
+ LoggerE("get fail telephonyMms value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->telephonyMms);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_TELEPHONY_SMS)) {
+ bool telephonySms = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.telephony.sms", &telephonySms) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->telephonySms = telephonySms;
+ } else {
+ LoggerE("get fail telephonySms value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->telephonySms);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENSIZE_NORMAL)) {
+ bool screenSizeNormal = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal", &screenSizeNormal) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenSizeNormal = screenSizeNormal;
+ } else {
+ LoggerE("get fail screenSizeNormal value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->screenSizeNormal);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENSIZE_480_800)) {
+ bool screenSize480_800 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.480.800", &screenSize480_800) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenSize480_800 = screenSize480_800;
+ } else {
+ LoggerE("get fail screenSize480_800 value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->screenSize480_800);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SCREENSIZE_720_1280)) {
+ bool screenSize720_1280 = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.720.1280", &screenSize720_1280) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->screenSize720_1280 = screenSize720_1280;
+ } else {
+ LoggerE("get fail screenSize720_1280 value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->screenSize720_1280);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_AUTO_ROTATION)) {
+ bool autoRotation = false;
+ if(system_info_get_platform_bool("tizen.org/feature/screen.auto_rotation", &autoRotation) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->autoRotation = autoRotation;
+ } else {
+ LoggerE("get fail autoRotation value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->autoRotation);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SHELL_APP_WIDGET)) {
+ bool shellAppWidget = false;
+ if(system_info_get_platform_bool("tizen.org/feature/shell.appwidget", &shellAppWidget) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->shellAppWidget = shellAppWidget;
+ } else {
+ LoggerE("get fail shellAppWidget value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->shellAppWidget);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_IMAGE_RECOGNITION)) {
+ bool visionImageRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.image_recognition", &visionImageRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionImageRecognition = visionImageRecognition;
+ } else {
+ LoggerE("get fail visionImageRecognition value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->visionImageRecognition);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_QRCODE_GENERATION)) {
+ bool visionQrcodeGeneration = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.qrcode_generation", &visionQrcodeGeneration) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionQrcodeGeneration = visionQrcodeGeneration;
+ } else {
+ LoggerE("get fail visionQrcodeGeneration value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->visionQrcodeGeneration);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_QRCODE_RECOGNITION)) {
+ bool visionQrcodeRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.qrcode_recognition", &visionQrcodeRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionQrcodeRecognition = visionQrcodeRecognition;
+ } else {
+ LoggerE("get fail visionQrcodeRecognition value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->visionQrcodeRecognition);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_VISION_FACE_RECOGNITION)) {
+ bool visionFaceRecognition = false;
+ if(system_info_get_platform_bool("tizen.org/feature/vision.face_recognition", &visionFaceRecognition) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->visionFaceRecognition = visionFaceRecognition;
+ } else {
+ LoggerE("get fail visionFaceRecognition value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->visionFaceRecognition);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_SECURE_ELEMENT)) {
+ bool secureElement = false;
+ if(system_info_get_platform_bool("tizen.org/feature/network.secure_element", &secureElement) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->secureElement = secureElement;
+ } else {
+ LoggerE("get fail secureElement value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->secureElement);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_NATIVE_OSP_COMPATIBLE)) {
+ bool nativeOspCompatible = false;
+ if(system_info_get_platform_bool("tizen.org/feature/platform.native.osp_compatible", &nativeOspCompatible) == SYSTEM_INFO_ERROR_NONE) {
+ deviceCapabilitiesInfo->nativeOspCompatible = nativeOspCompatible;
+ } else {
+ LoggerE("get fail nativeOspCompatible value");
+ return JSValueMakeUndefined(context);
+ }
+ return convert.toJSValueRef(deviceCapabilitiesInfo->nativeOspCompatible);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DEVICE_CAPABILITIES_PROFILE)) {
+ deviceCapabilitiesInfo->profile = DEVICE_PROFILE;
+ return convert.toJSValueRef(deviceCapabilitiesInfo->profile);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR);
+ }
+ return JSValueMakeUndefined(context);
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/JSDeviceCapabilitiesInfo.h b/mobile_src/Systeminfo/JSDeviceCapabilitiesInfo.h
new file mode 100755
index 0000000..89053ab
--- /dev/null
+++ b/mobile_src/Systeminfo/JSDeviceCapabilitiesInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_DEVICE_CAPABILITIES_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_DEVICE_CAPABILITIES_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<DeviceCapabilitiesPropertiesPtr>::Type JSDeviceCapabilitiesPriv;
+
+class JSDeviceCapabilitiesInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const DeviceCapabilitiesPropertiesPtr deviceCapabilitiesInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSDeviceOrientationInfo.cpp b/mobile_src/Systeminfo/JSDeviceOrientationInfo.cpp
new file mode 100755
index 0000000..b6c843a
--- /dev/null
+++ b/mobile_src/Systeminfo/JSDeviceOrientationInfo.cpp
@@ -0,0 +1,124 @@
+//
+// 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 <memory>
+#include "JSDeviceOrientationInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* DEVICEORIENTATION_STATUS_PROPERTY = "status";
+const char* DEVICEORIENTATION_IS_AUTOROTATION_PROPERTY = "isAutoRotation";
+}
+
+JSClassRef JSDeviceOrientationInfo::m_classRef = NULL;
+
+JSClassDefinition JSDeviceOrientationInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "deviceorientationinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSDeviceOrientationInfo::m_properties[] = {
+ { DEVICEORIENTATION_STATUS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DEVICEORIENTATION_IS_AUTOROTATION_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSDeviceOrientationInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSDeviceOrientationInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSDeviceOrientationInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSDeviceOrientationInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSDeviceOrientationPriv* priv = static_cast<JSDeviceOrientationPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting deviceOrientationInfo object");
+ delete priv;
+}
+
+bool JSDeviceOrientationInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSDeviceOrientationInfo::createJSObject(JSContextRef context, const DeviceOrientationPropertiesPtr deviceOrientationInfo)
+{
+ JSDeviceOrientationPriv *priv = new JSDeviceOrientationPriv(context, deviceOrientationInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSDeviceOrientationInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSDeviceOrientationPriv *priv = static_cast<JSDeviceOrientationPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ DeviceOrientationPropertiesPtr deviceOrientationInfo = priv->getObject();
+ Converter convert(context);
+
+ 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)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSDeviceOrientationInfo.h b/mobile_src/Systeminfo/JSDeviceOrientationInfo.h
new file mode 100755
index 0000000..4c4555d
--- /dev/null
+++ b/mobile_src/Systeminfo/JSDeviceOrientationInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_DEVICEORIENTATION_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_DEVICEORIENTATION_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<DeviceOrientationPropertiesPtr>::Type JSDeviceOrientationPriv;
+
+class JSDeviceOrientationInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const DeviceOrientationPropertiesPtr deviceOrientationInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSDisplayInfo.cpp b/mobile_src/Systeminfo/JSDisplayInfo.cpp
new file mode 100644
index 0000000..1667562
--- /dev/null
+++ b/mobile_src/Systeminfo/JSDisplayInfo.cpp
@@ -0,0 +1,143 @@
+//
+// 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 <memory>
+#include "JSDisplayInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* DISPLAY_RESOLUTIONW_PROPERTY = "resolutionWidth";
+const char* DISPLAY_RESOLUTIONH_PROPERTY = "resolutionHeight";
+const char* DISPLAY_INCHW_PROPERTY = "dotsPerInchWidth";
+const char* DISPLAY_INCHH_PROPERTY = "dotsPerInchHeight";
+const char* DISPLAY_PHYSICALW_PROPERTY = "physicalWidth";
+const char* DISPLAY_PHYSICALH_PROPERTY = "physicalHeight";
+const char* DISPLAY_BRIGHTNESS_PROPERTY = "brightness";
+}
+
+JSClassRef JSDisplayInfo::m_classRef = NULL;
+
+JSClassDefinition JSDisplayInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "displayinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSDisplayInfo::m_properties[] = {
+ { DISPLAY_RESOLUTIONW_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DISPLAY_RESOLUTIONH_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DISPLAY_INCHW_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DISPLAY_INCHH_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DISPLAY_PHYSICALW_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DISPLAY_PHYSICALH_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { DISPLAY_BRIGHTNESS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSDisplayInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSDisplayInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSDisplayInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSDisplayInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSDisplayPriv* priv = static_cast<JSDisplayPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting DisplayInfo object");
+ delete priv;
+}
+
+bool JSDisplayInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSDisplayInfo::createJSObject(JSContextRef context, const DisplayPropertiesPtr displayInfo)
+{
+ JSDisplayPriv *priv = new JSDisplayPriv(context, displayInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSDisplayInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSDisplayPriv *priv = static_cast<JSDisplayPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ DisplayPropertiesPtr displayInfo = priv->getObject();
+ Converter convert(context);
+ if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_RESOLUTIONW_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->resolutionWidth);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_RESOLUTIONH_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->resolutionHeight);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_INCHW_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->dotsPerInchWidth);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_INCHH_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->dotsPerInchHeight);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_PHYSICALW_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->physicalWidth);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_PHYSICALH_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->physicalHeight);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, DISPLAY_BRIGHTNESS_PROPERTY)) {
+ return convert.toJSValueRef(displayInfo->brightness);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSDisplayInfo.h b/mobile_src/Systeminfo/JSDisplayInfo.h
new file mode 100755
index 0000000..ec83737
--- /dev/null
+++ b/mobile_src/Systeminfo/JSDisplayInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_DISPLAY_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_DISPLAY_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<DisplayPropertiesPtr>::Type JSDisplayPriv;
+
+class JSDisplayInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const DisplayPropertiesPtr displayInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSLocaleInfo.cpp b/mobile_src/Systeminfo/JSLocaleInfo.cpp
new file mode 100644
index 0000000..61310e4
--- /dev/null
+++ b/mobile_src/Systeminfo/JSLocaleInfo.cpp
@@ -0,0 +1,124 @@
+//
+// 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 <memory>
+#include "JSLocaleInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* LOCALE_LANGUAGE_PROPERTY = "language";
+const char* LOCALE_COUNTRY_PROPERTY = "country";
+}
+
+JSClassRef JSLocaleInfo::m_classRef = NULL;
+
+JSClassDefinition JSLocaleInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "localeinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSLocaleInfo::m_properties[] = {
+ { LOCALE_LANGUAGE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { LOCALE_COUNTRY_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSLocaleInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSLocaleInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSLocaleInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSLocaleInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSLocalePriv* priv = static_cast<JSLocalePriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting localeInfo object");
+ delete priv;
+}
+
+bool JSLocaleInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSLocaleInfo::createJSObject(JSContextRef context, const LocalePropertiesPtr localeInfo)
+{
+ JSLocalePriv *priv = new JSLocalePriv(context, localeInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSLocaleInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSLocalePriv *priv = static_cast<JSLocalePriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ LocalePropertiesPtr localeInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, LOCALE_LANGUAGE_PROPERTY)) {
+ return convert.toJSValueRef(localeInfo->language);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, LOCALE_COUNTRY_PROPERTY)) {
+ return convert.toJSValueRef(localeInfo->country);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSLocaleInfo.h b/mobile_src/Systeminfo/JSLocaleInfo.h
new file mode 100755
index 0000000..95c8174
--- /dev/null
+++ b/mobile_src/Systeminfo/JSLocaleInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_LOCALE_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_LOCALE_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<LocalePropertiesPtr>::Type JSLocalePriv;
+
+class JSLocaleInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const LocalePropertiesPtr localeInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSNetworkInfo.cpp b/mobile_src/Systeminfo/JSNetworkInfo.cpp
new file mode 100644
index 0000000..83cf4db
--- /dev/null
+++ b/mobile_src/Systeminfo/JSNetworkInfo.cpp
@@ -0,0 +1,120 @@
+//
+// 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 <memory>
+#include "JSNetworkInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* NETWORK_TYPE_PROPERTY = "networkType";
+}
+
+JSClassRef JSNetworkInfo::m_classRef = NULL;
+
+JSClassDefinition JSNetworkInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "networkinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSNetworkInfo::m_properties[] = {
+ { NETWORK_TYPE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSNetworkInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSNetworkInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSNetworkInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSNetworkInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSNetworkPriv* priv = static_cast<JSNetworkPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting networkInfo object");
+ delete priv;
+}
+
+bool JSNetworkInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSNetworkInfo::createJSObject(JSContextRef context, const NetworkPropertiesPtr networkInfo)
+{
+ JSNetworkPriv *priv = new JSNetworkPriv(context, networkInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSNetworkInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSNetworkPriv *priv = static_cast<JSNetworkPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ NetworkPropertiesPtr networkInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, NETWORK_TYPE_PROPERTY)) {
+ return convert.toJSValueRef(networkInfo->networkType);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSNetworkInfo.h b/mobile_src/Systeminfo/JSNetworkInfo.h
new file mode 100755
index 0000000..21971ed
--- /dev/null
+++ b/mobile_src/Systeminfo/JSNetworkInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_NETWORK_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_NETWORK_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<NetworkPropertiesPtr>::Type JSNetworkPriv;
+
+class JSNetworkInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const NetworkPropertiesPtr networkInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSPeripheralInfo.cpp b/mobile_src/Systeminfo/JSPeripheralInfo.cpp
new file mode 100644
index 0000000..826cf7b
--- /dev/null
+++ b/mobile_src/Systeminfo/JSPeripheralInfo.cpp
@@ -0,0 +1,120 @@
+//
+// 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 <memory>
+#include "JSPeripheralInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* PERIPHERAL_IS_VIDEO_OUTPUT_ON_PROPERTY = "isVideoOutputOn";
+}
+
+JSClassRef JSPeripheralInfo::m_classRef = NULL;
+
+JSClassDefinition JSPeripheralInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "peripheralinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSPeripheralInfo::m_properties[] = {
+ { PERIPHERAL_IS_VIDEO_OUTPUT_ON_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSPeripheralInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSPeripheralInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSPeripheralInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSPeripheralInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSPeripheralPriv* priv = static_cast<JSPeripheralPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting peripheralInfo object");
+ delete priv;
+}
+
+bool JSPeripheralInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSPeripheralInfo::createJSObject(JSContextRef context, const PeripheralPropertiesPtr peripheralInfo)
+{
+ JSPeripheralPriv *priv = new JSPeripheralPriv(context, peripheralInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSPeripheralInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSPeripheralPriv *priv = static_cast<JSPeripheralPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ PeripheralPropertiesPtr peripheralInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, PERIPHERAL_IS_VIDEO_OUTPUT_ON_PROPERTY)) {
+ return convert.toJSValueRef(peripheralInfo->isVideoOutputOn);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSPeripheralInfo.h b/mobile_src/Systeminfo/JSPeripheralInfo.h
new file mode 100755
index 0000000..45aca3d
--- /dev/null
+++ b/mobile_src/Systeminfo/JSPeripheralInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_PERIPHERAL_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_PERIPHERAL_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<PeripheralPropertiesPtr>::Type JSPeripheralPriv;
+
+class JSPeripheralInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const PeripheralPropertiesPtr peripheralInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSSIMInfo.cpp b/mobile_src/Systeminfo/JSSIMInfo.cpp
new file mode 100755
index 0000000..1613e3f
--- /dev/null
+++ b/mobile_src/Systeminfo/JSSIMInfo.cpp
@@ -0,0 +1,168 @@
+//
+// 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 <memory>
+#include <JSWebAPIErrorFactory.h>
+#include <SecurityExceptions.h>
+#include "JSSIMInfo.h"
+#include "plugin_config.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+namespace {
+const char* SIM_STATE_PROPERTY = "state";
+const char* SIM_OPERATORNAME_PROPERTY = "operatorName";
+const char* SIM_MSISDN_PROPERTY = "msisdn";
+const char* SIM_ICCID_PROPERTY = "iccid";
+const char* SIM_MCC_PROPERTY = "mcc";
+const char* SIM_MNC_PROPERTY = "mnc";
+const char* SIM_MSIN_PROPERTY = "msin";
+const char* SIM_SPN_PROPERTY = "spn";
+}
+
+JSClassRef JSSIMInfo::m_classRef = NULL;
+
+JSClassDefinition JSSIMInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "siminfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSSIMInfo::m_properties[] = {
+ { SIM_STATE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_OPERATORNAME_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_MSISDN_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_ICCID_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_MCC_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_MNC_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_MSIN_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { SIM_SPN_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSSIMInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSSIMInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSSIMInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSSIMInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSSIMPriv* priv = static_cast<JSSIMPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting SIM Info object");
+ delete priv;
+}
+
+bool JSSIMInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSSIMInfo::createJSObject(JSContextRef context, const SIMPropertiesPtr SIMInfo)
+{
+ LoggerD("Enter");
+ JSSIMPriv *priv = new JSSIMPriv(context, SIMInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSSIMInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSSIMPriv *priv = static_cast<JSSIMPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ SIMPropertiesPtr SIMInfo = priv->getObject();
+ Converter convert(context);
+ if (JSStringIsEqualToUTF8CString(propertyName, SIM_STATE_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->state);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_OPERATORNAME_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->operatorName);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_MSISDN_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->msisdn);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_ICCID_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->iccid);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_MCC_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->mcc);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_MNC_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->mnc);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_MSIN_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->msin);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, SIM_SPN_PROPERTY)) {
+ AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE);
+ TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+ return convert.toJSValueRef(SIMInfo->spn);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSSIMInfo.h b/mobile_src/Systeminfo/JSSIMInfo.h
new file mode 100755
index 0000000..7de6d53
--- /dev/null
+++ b/mobile_src/Systeminfo/JSSIMInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_SIM_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_SIM_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<SIMPropertiesPtr>::Type JSSIMPriv;
+
+class JSSIMInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const SIMPropertiesPtr SIMInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSStorageInfo.cpp b/mobile_src/Systeminfo/JSStorageInfo.cpp
new file mode 100755
index 0000000..8034487
--- /dev/null
+++ b/mobile_src/Systeminfo/JSStorageInfo.cpp
@@ -0,0 +1,140 @@
+//
+// 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 <memory>
+#include "JSStorageUnitInfo.h"
+#include "JSStorageInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* STORAGE_UNITS_PROPERTY = "units";
+}
+
+JSClassRef JSStorageInfo::m_classRef = NULL;
+
+JSClassDefinition JSStorageInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "storageinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSStorageInfo::m_properties[] = {
+ { STORAGE_UNITS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSStorageInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSStorageInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSStorageInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSStorageInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSStoragePriv* priv = static_cast<JSStoragePriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting StorageInfo object");
+ delete priv;
+}
+
+bool JSStorageInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSStorageInfo::createJSObject(JSContextRef context, const StoragePropertiesPtr storageInfo)
+{
+ JSStoragePriv *priv = new JSStoragePriv(context, storageInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSStorageInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ JSStoragePriv *priv = static_cast<JSStoragePriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ StoragePropertiesPtr storageInfo = priv->getObject();
+ Converter convert(context);
+ std::vector <JSObjectRef> storagelist;
+ StorageUnitPropertiesPtr internal(new StorageUnitProperties());
+ StorageUnitPropertiesPtr sdcard(new StorageUnitProperties());
+
+ if (storageInfo->cnt > 0) {
+ internal->type = storageInfo->units[0].type;
+ internal->capacity = storageInfo->units[0].capacity;
+ internal->availableCapacity = storageInfo->units[0].availableCapacity;
+ internal->isRemoveable = storageInfo->units[0].isRemoveable;
+ internal->isRemovable = storageInfo->units[0].isRemovable;
+ storagelist.push_back(JSStorageUnitInfo::createJSObject(context, internal));
+ }
+ if (storageInfo->cnt > 1) {
+ sdcard->type = storageInfo->units[1].type;
+ sdcard->capacity = storageInfo->units[1].capacity;
+ sdcard->availableCapacity = storageInfo->units[1].availableCapacity;
+ sdcard->isRemoveable = storageInfo->units[1].isRemoveable;
+ sdcard->isRemovable = storageInfo->units[1].isRemovable;
+ storagelist.push_back(JSStorageUnitInfo::createJSObject(context, sdcard));
+ }
+
+ if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNITS_PROPERTY)) {
+ return JSObjectMakeArray(context, storageInfo->cnt, storagelist.data(), NULL);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSStorageInfo.h b/mobile_src/Systeminfo/JSStorageInfo.h
new file mode 100755
index 0000000..9161016
--- /dev/null
+++ b/mobile_src/Systeminfo/JSStorageInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_STORAGE_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_STORAGE_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<StoragePropertiesPtr>::Type JSStoragePriv;
+
+class JSStorageInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const StoragePropertiesPtr storageInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSStorageUnitInfo.cpp b/mobile_src/Systeminfo/JSStorageUnitInfo.cpp
new file mode 100755
index 0000000..e71cca2
--- /dev/null
+++ b/mobile_src/Systeminfo/JSStorageUnitInfo.cpp
@@ -0,0 +1,134 @@
+//
+// 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 <memory>
+#include "JSStorageUnitInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* STORAGE_UNIT_TYPE_PROPERTY = "type";
+const char* STORAGE_UNIT_CAPACITY_PROPERTY = "capacity";
+const char* STORAGE_UNIT_AVAILCAPA_PROPERTY = "availableCapacity";
+const char* STORAGE_UNIT_REMOVEABLE_PROPERTY = "isRemoveable";
+const char* STORAGE_UNIT_REMOVABLE_PROPERTY = "isRemovable";
+}
+
+JSClassRef JSStorageUnitInfo::m_classRef = NULL;
+
+JSClassDefinition JSStorageUnitInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "storageunitinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSStorageUnitInfo::m_properties[] = {
+ { STORAGE_UNIT_TYPE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { STORAGE_UNIT_CAPACITY_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { STORAGE_UNIT_AVAILCAPA_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { STORAGE_UNIT_REMOVEABLE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { STORAGE_UNIT_REMOVABLE_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSStorageUnitInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSStorageUnitInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSStorageUnitInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSStorageUnitInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSStorageUnitPriv* priv = static_cast<JSStorageUnitPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting StorageUnitInfo object");
+ delete priv;
+}
+
+bool JSStorageUnitInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSStorageUnitInfo::createJSObject(JSContextRef context, const StorageUnitPropertiesPtr storageUnitInfo)
+{
+ JSStorageUnitPriv *priv = new JSStorageUnitPriv(context, storageUnitInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSStorageUnitInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ JSStorageUnitPriv *priv = static_cast<JSStorageUnitPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ StorageUnitPropertiesPtr storageUnitInfo = priv->getObject();
+ Converter convert(context);
+ if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_TYPE_PROPERTY)) {
+ return convert.toJSValueRef(storageUnitInfo->type);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_CAPACITY_PROPERTY)) {
+ return JSValueMakeNumber(context, storageUnitInfo->capacity);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_AVAILCAPA_PROPERTY)) {
+ return JSValueMakeNumber(context, storageUnitInfo->availableCapacity);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_REMOVEABLE_PROPERTY)) {
+ return convert.toJSValueRef(storageUnitInfo->isRemoveable);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, STORAGE_UNIT_REMOVABLE_PROPERTY)) {
+ return convert.toJSValueRef(storageUnitInfo->isRemovable);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSStorageUnitInfo.h b/mobile_src/Systeminfo/JSStorageUnitInfo.h
new file mode 100755
index 0000000..f435286
--- /dev/null
+++ b/mobile_src/Systeminfo/JSStorageUnitInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_STORAGE_UNIT_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_STORAGE_UNIT_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<StorageUnitPropertiesPtr>::Type JSStorageUnitPriv;
+
+class JSStorageUnitInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const StorageUnitPropertiesPtr storageUnitInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/JSSysteminfo.cpp b/mobile_src/Systeminfo/JSSysteminfo.cpp
new file mode 100755
index 0000000..21b5d4e
--- /dev/null
+++ b/mobile_src/Systeminfo/JSSysteminfo.cpp
@@ -0,0 +1,313 @@
+//
+// 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 <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/Converter.h>
+#include "SysteminfoFactory.h"
+#include "EventGetSysteminfo.h"
+#include "EventWatchSysteminfo.h"
+#include <JSWebAPIErrorFactory.h>
+#include <SecurityExceptions.h>
+#include <TimeTracer.h>
+#include <Export.h>
+#include "SysteminfoListener.h"
+#include "SysteminfoAsyncCallbackManager.h"
+#include "SysteminfoListenerManager.h"
+#include "JSSysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+using namespace std;
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+using namespace DeviceAPI::Common;
+
+JSClassDefinition JSSysteminfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "systeminfo",
+ NULL,
+ NULL,
+ m_function,
+ initialize,
+ finalize,
+ NULL, //hasProperty,
+ NULL, //getProperty,
+ NULL, //setProperty,
+ NULL, //deleteProperty,
+ NULL, //getPropertyNames,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticFunction JSSysteminfo::m_function[] = {
+ { "getCapabilities", JSSysteminfo::getCapabilities, kJSPropertyAttributeNone },
+ { "getPropertyValue", JSSysteminfo::getPropertyValue, kJSPropertyAttributeNone },
+ { "addPropertyValueChangeListener", JSSysteminfo::addPropertyValueChangeListener, kJSPropertyAttributeNone },
+ { "removePropertyValueChangeListener", JSSysteminfo::removePropertyValueChangeListener, kJSPropertyAttributeNone },
+ { 0, 0, 0 }
+};
+
+const JSClassRef DLL_EXPORT JSSysteminfo::getClassRef()
+{
+ if (!m_jsClassRef) {
+ m_jsClassRef = JSClassCreate(&m_classInfo);
+ }
+ return m_jsClassRef;
+}
+
+const JSClassDefinition* JSSysteminfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+JSClassRef JSSysteminfo::m_jsClassRef = JSClassCreate(JSSysteminfo::getClassInfo());
+
+void JSSysteminfo::initialize(JSContextRef context, JSObjectRef object)
+{
+ if (!JSObjectGetPrivate(object)) {
+ ISysteminfoPtr Systeminfos(SysteminfoFactory::getInstance().getSysteminfos());
+ JSSysteminfoPriv* priv = new JSSysteminfoPriv(context, Systeminfos);
+ if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+ LoggerE("Object can't store private data.");
+ delete priv;
+ }
+
+ LoggerD("JSSysteminfo::initialize ");
+ } else {
+ LoggerD("Private object already set.");
+ }
+}
+
+void JSSysteminfo::finalize(JSObjectRef object)
+{
+ JSSysteminfoPriv* priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(object));
+
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting gallery");
+ delete priv;
+}
+
+JSValueRef JSSysteminfo::getCapabilities(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
+
+ Converter converter(context);
+ Validator check(context, exception);
+
+ if (!priv) {
+ LoggerE("private object is null");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ Try
+ {
+ ISysteminfoPtr Systeminfos(priv->getObject());
+
+ DeviceCapabilitiesPropertiesPtr result(new DeviceCapabilitiesProperties());
+
+ result = Systeminfos->getCapabilities();
+
+ return (static_cast<JSValueRef>(JSDeviceCapabilitiesInfo::createJSObject(context, result)));
+ }
+ Catch(WrtDeviceApis::Commons::ConversionException) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid values error");
+ }
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException){
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid values error");
+ }
+ Catch(WrtDeviceApis::Commons::Exception) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown error");
+ }
+}
+
+JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
+
+ Converter converter(context);
+ Validator check(context, exception);
+ std::string property;
+
+ if (!priv) {
+ LoggerE("private object is null");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Wrong Object");
+ }
+ if (argumentCount < 2) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ if (!check.isCallback(arguments[1])) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+
+ JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+ onSuccessForCbm = arguments[1];
+ if (argumentCount == 3) {
+ if (check.isCallback(arguments[2])) {
+ onErrorForCbm = arguments[2];
+ } else if (!JSValueIsNull(context, arguments[2])) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ }
+
+ JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccessForCbm, onErrorForCbm, true, true));
+ cbm->setObject(thisObject);
+
+ Try {
+ ISysteminfoPtr Systeminfos(priv->getObject());
+ BasePropertyPtr baseProperty = Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]);
+
+ EventGetSysteminfoPtr event(new EventGetSysteminfo());
+ event->setBasePropertyPtr(baseProperty);
+ TIME_TRACER_ITEM_BEGIN(event->getProperty(), 0);
+ event->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
+
+ SysteminfoListener& listener = SysteminfoListener::getInstance();
+ event->setForAsynchronousCall(&listener);
+
+ Systeminfos->get(event);
+ SysteminfoAsyncCallbackManagerSingleton::Instance().registerCallbackManager(cbm, priv->getContext());
+
+ return JSValueMakeUndefined(context);
+ }
+
+ Catch(WrtDeviceApis::Commons::ConversionException) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ Catch(WrtDeviceApis::Commons::Exception) {
+ cbm->callOnError(JSWebAPIErrorFactory::makeErrorObject(context, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown error"));
+ }
+ return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ WatchOption option;
+ JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
+
+ Converter converter(context);
+ Validator check(context, exception);
+
+ if (!priv) {
+ LoggerE("private object is null");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Wrong Object");
+ }
+ if (argumentCount < 2) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ if (!check.isCallback(arguments[1])) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+
+ JSValueRef onSuccessForCbm = NULL;
+ onSuccessForCbm = arguments[1];
+
+ JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccessForCbm, NULL, true, true));
+
+ Try {
+ if (argumentCount > 2) {
+ if (JSValueIsObject(context, arguments[2])) {
+ option.timeout = converter.toULong(JSUtils::getJSProperty(context, arguments[2], "timeout", exception));
+ option.highThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[2], "highThreshold", exception));
+ option.lowThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[2], "lowThreshold", exception));
+ } else if (!JSValueIsNull(context, arguments[2])) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ }
+ ISysteminfoPtr Systeminfos(priv->getObject());
+ BasePropertyPtr baseProperty = Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]);
+
+ EventWatchSysteminfoPtr event(new EventWatchSysteminfo);
+ event->setWatchOption(option);
+ event->setBasePropertyPtr(baseProperty);
+ event->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
+
+ SysteminfoListener& listener = SysteminfoListener::getInstance();
+ event->setForAsynchronousCall(&listener);
+
+ Systeminfos->watch(event);
+ LoggerD("event->getId()" << event->getId());
+
+ SysteminfoListenerCancellerPtr canceller = SysteminfoListenerCancellerPtr(new SysteminfoListenerCanceller(priv->getContext(), thisObject, event->getId()));
+ DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast<DeviceAPI::Common::IListenerItem>(canceller);
+ SysteminfoListenerManagerSingleton::Instance().registerListener(listenerItem, priv->getContext());
+
+ return converter.toJSValueRef(event->getId());
+ }
+
+ Catch(WrtDeviceApis::Commons::ConversionException) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid values error");
+ }
+ Catch(WrtDeviceApis::Commons::Exception) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Platform error");
+ }
+}
+
+JSValueRef JSSysteminfo::removePropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ long id = 0;
+ JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
+
+ Converter converter(context);
+ if (!priv) {
+ LoggerE("private object is null");
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Wrong Object");
+ }
+ if (argumentCount < 1) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+
+ Try {
+ ISysteminfoPtr Systeminfos(priv->getObject());
+ id = static_cast<long>(converter.toLong(arguments[0]));
+
+ LoggerD("clearWatch id = " << id );
+ Systeminfos->clearWatch(id);
+
+ SysteminfoListenerCancellerPtr canceller = SysteminfoListenerCancellerPtr(new SysteminfoListenerCanceller(priv->getContext(), thisObject, id));
+ DeviceAPI::Common::IListenerItemPtr listenerItem = DPL::StaticPointerCast<DeviceAPI::Common::IListenerItem>(canceller);
+ SysteminfoListenerManagerSingleton::Instance().unregisterListener(listenerItem);
+
+ return JSValueMakeUndefined(context);
+ }
+ Catch(WrtDeviceApis::Commons::ConversionException) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::TYPE_MISMATCH_ERROR, "Type missmatch error");
+ }
+ Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::INVALID_VALUES_ERROR, "Invalid values error");
+ }
+ Catch(WrtDeviceApis::Commons::Exception) {
+ return JSWebAPIErrorFactory::postException(context, exception, JSWebAPIErrorFactory::UNKNOWN_ERROR, "Unknown error");
+ }
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/JSSysteminfo.h b/mobile_src/Systeminfo/JSSysteminfo.h
new file mode 100755
index 0000000..16c0b09
--- /dev/null
+++ b/mobile_src/Systeminfo/JSSysteminfo.h
@@ -0,0 +1,61 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_JS_SYSTEMINFO_H_
+#define WRTPLUGINS_TIZEN1_0_JS_SYSTEMINFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include "ISysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<ISysteminfoPtr>::Type JSSysteminfoPriv;
+
+class JSSysteminfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+
+ private:
+ static void initialize(JSContextRef context, JSObjectRef object);
+ static void finalize(JSObjectRef object);
+
+ static JSValueRef getCapabilities(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+ static JSValueRef getPropertyValue(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+ static JSValueRef addPropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+ static JSValueRef removePropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+ size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+ static JSClassDefinition m_classInfo;
+ static JSStaticFunction m_function[];
+
+ static JSClassRef m_jsClassRef;
+};
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/JSWifiNetworkInfo.cpp b/mobile_src/Systeminfo/JSWifiNetworkInfo.cpp
new file mode 100644
index 0000000..aa5c6da
--- /dev/null
+++ b/mobile_src/Systeminfo/JSWifiNetworkInfo.cpp
@@ -0,0 +1,137 @@
+//
+// 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 <memory>
+#include "JSWifiNetworkInfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace {
+const char* WIFINETWORK_STATUS_PROPERTY = "status";
+const char* WIFINETWORK_SSID_PROPERTY = "ssid";
+const char* WIFINETWORK_IPADDRESS_PROPERTY = "ipAddress";
+const char* WIFINETWORK_IPV6ADDRESS_PROPERTY = "ipv6Address";
+const char* WIFINETWORK_SIGNALSTRENGTH_PROPERTY = "signalStrength";
+}
+
+JSClassRef JSWifiNetworkInfo::m_classRef = NULL;
+
+JSClassDefinition JSWifiNetworkInfo::m_classInfo = {
+ 0,
+ kJSClassAttributeNone,
+ "wifinetworkinfo",
+ 0,
+ m_properties,
+ NULL,
+ Initialize,
+ Finalize,
+ hasProperty,
+ getProperty,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+JSStaticValue JSWifiNetworkInfo::m_properties[] = {
+ { WIFINETWORK_STATUS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { WIFINETWORK_SSID_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { WIFINETWORK_IPADDRESS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { WIFINETWORK_IPV6ADDRESS_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { WIFINETWORK_SIGNALSTRENGTH_PROPERTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+ { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSWifiNetworkInfo::getClassRef()
+{
+ if (!m_classRef) {
+ m_classRef = JSClassCreate(&m_classInfo);
+ }
+ return m_classRef;
+}
+
+const JSClassDefinition* JSWifiNetworkInfo::getClassInfo()
+{
+ return &m_classInfo;
+}
+
+void JSWifiNetworkInfo::Initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSWifiNetworkInfo::Finalize(JSObjectRef object)
+{
+ LoggerD("Entered");
+ JSWifiNetworkPriv* priv = static_cast<JSWifiNetworkPriv*>(JSObjectGetPrivate(object));
+ JSObjectSetPrivate(object, NULL);
+ LoggerD("Deleting WifiNetworkInfo object");
+ delete priv;
+}
+
+bool JSWifiNetworkInfo::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+ return JSUtils::hasProperty(m_properties, propertyName);
+}
+
+JSObjectRef JSWifiNetworkInfo::createJSObject(JSContextRef context, const WifiNetworkPropertiesPtr wifiNetworkInfo)
+{
+ LoggerD("Enter");
+ JSWifiNetworkPriv *priv = new JSWifiNetworkPriv(context, wifiNetworkInfo);
+ return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSWifiNetworkInfo::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+ LoggerD("Enter");
+ JSWifiNetworkPriv *priv = static_cast<JSWifiNetworkPriv*>(JSObjectGetPrivate(object));
+ if (NULL == priv) {
+ LoggerE("Private object not set.");
+ return JSValueMakeUndefined(context);
+ }
+
+ Try
+ {
+ WifiNetworkPropertiesPtr wifiNetworkInfo = priv->getObject();
+ Converter convert(context);
+
+ if (JSStringIsEqualToUTF8CString(propertyName, WIFINETWORK_STATUS_PROPERTY)) {
+ return convert.toJSValueRef(wifiNetworkInfo->status);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, WIFINETWORK_SSID_PROPERTY)) {
+ return convert.toJSValueRef(wifiNetworkInfo->ssid);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, WIFINETWORK_IPADDRESS_PROPERTY)) {
+ return convert.toJSValueRef(wifiNetworkInfo->ipAddress);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, WIFINETWORK_IPV6ADDRESS_PROPERTY)) {
+ return convert.toJSValueRef(wifiNetworkInfo->ipv6Address);
+ } else if (JSStringIsEqualToUTF8CString(propertyName, WIFINETWORK_SIGNALSTRENGTH_PROPERTY)) {
+ return convert.toJSValueRef(wifiNetworkInfo->signalStrength);
+ }
+ }
+ Catch(Exception)
+ {
+ LoggerE("Exception: " << _rethrown_exception.GetMessage());
+ }
+ return JSValueMakeUndefined(context);
+}
+}
+}
diff --git a/mobile_src/Systeminfo/JSWifiNetworkInfo.h b/mobile_src/Systeminfo/JSWifiNetworkInfo.h
new file mode 100755
index 0000000..de658d1
--- /dev/null
+++ b/mobile_src/Systeminfo/JSWifiNetworkInfo.h
@@ -0,0 +1,48 @@
+//
+// 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 WRTPLUGINS_TIZEN1_0_WIFINETWORK_INFO_H_
+#define WRTPLUGINS_TIZEN1_0_WIFINETWORK_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include "SysteminfoPropertyInfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<WifiNetworkPropertiesPtr>::Type JSWifiNetworkPriv;
+
+class JSWifiNetworkInfo
+{
+ public:
+ static const JSClassDefinition* getClassInfo();
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const WifiNetworkPropertiesPtr wifiNetworkInfo);
+
+ private:
+ static void Initialize(JSContextRef context, JSObjectRef object);
+ static void Finalize(JSObjectRef object);
+ static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+ static JSStaticValue m_properties[];
+ static JSClassRef m_classRef;
+ static JSClassDefinition m_classInfo;
+};
+
+}
+}
+#endif
diff --git a/mobile_src/Systeminfo/Systeminfo.cpp b/mobile_src/Systeminfo/Systeminfo.cpp
new file mode 100755
index 0000000..0f33312
--- /dev/null
+++ b/mobile_src/Systeminfo/Systeminfo.cpp
@@ -0,0 +1,1716 @@
+//
+// 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 <stddef.h>
+#include <cassert>
+#include <math.h>
+#include <Commons/Exception.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <TimeTracer.h>
+#include "Systeminfo.h"
+#include <Logger.h>
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+#define SIM_VALUE_MAX 4
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+namespace {
+
+void BatteryValueCallback(keynode_t *node, void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_BATTERY);
+ }
+}
+
+void PeripheralValueCallback(keynode_t *node, void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_PERIPHERAL);
+ }
+}
+
+void CellularNetworkValueCallback(keynode_t *node, void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_CELLULARNETWORK);
+ }
+}
+
+void DisplayValueCallback(keynode_t *node, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DISPLAY);
+ }
+}
+
+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) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_NETWORK);
+ }
+}
+
+void NetworkValueCallback(const char* ipv4_address, const char* ipv6_address, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_NETWORK_ALL);
+ }
+}
+
+void StorageValueVconfCallback(keynode_t *node, void *event_ptr)
+{
+ LoggerD("enter");
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_STORAGE);
+ }
+}
+
+static Eina_Bool StorageValueCallback(void* event_ptr)
+{
+ LoggerD("enter");
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_STORAGE);
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+static Eina_Bool CpuValueCallback(void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_CPU);
+ }
+ return ECORE_CALLBACK_RENEW;
+}
+
+void OrientationValueCallback(unsigned int event_type, sensor_event_data_t *event , void *event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_DEVICE_ORIENTATION);
+ }
+}
+
+void localeChangedCallback(runtime_info_key_e key, void* event_ptr)
+{
+ if(event_ptr) {
+ ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_LOCALE);
+ }
+}
+
+void SimCphsValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimCphsNetName_t *cphsInfo = (TelSimCphsNetName_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ if(strlen((const char*)cphsInfo->full_name) == 0) {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, (char *)cphsInfo->full_name, event);
+ } else if (strlen((const char*)cphsInfo->short_name) == 0) {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, (char *)cphsInfo->short_name, event);
+ } else {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, NULL, event);
+ }
+ } else {
+ systeminfo->setSimValue(SIM_CPHS_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+void SimMsisdnValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimMsisdnList_t *msisdnInfo = (TelSimMsisdnList_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ systeminfo->setSimValue(SIM_MSISDN_VALUE, (char *)msisdnInfo->list[0].num, event);
+ } else {
+ systeminfo->setSimValue(SIM_MSISDN_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+void SimIccidValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimIccIdInfo_t *iccidInfo = (TelSimIccIdInfo_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ systeminfo->setSimValue(SIM_ICCID_VALUE, (char *)iccidInfo->icc_num, event);
+ } else {
+ systeminfo->setSimValue(SIM_ICCID_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+void SimSpnValueCallback(TapiHandle *handle, int result, void *data, void *user_data)
+{
+ TelSimAccessResult_t access_rt = (TelSimAccessResult_t)result;
+ TelSimSpn_t *spnInfo = (TelSimSpn_t *)data;
+
+ LoggerD("access_rt : " << access_rt);
+
+ if (user_data != NULL){
+ SysteminfoAsyncPendingEvent *pendingEvent = (SysteminfoAsyncPendingEvent *)user_data;
+ Systeminfo *systeminfo = (Systeminfo *)pendingEvent->getThisObject();
+ EventGetSysteminfoPtr event = pendingEvent->getEvent();
+
+ if (access_rt == TAPI_SIM_ACCESS_SUCCESS) {
+ systeminfo->setSimValue(SIM_SPN_VALUE, (char *)spnInfo->spn, event);
+ } else {
+ systeminfo->setSimValue(SIM_ICCID_VALUE, NULL, event);
+ }
+
+ delete pendingEvent;
+ pendingEvent = NULL;
+ user_data = NULL;
+ }
+}
+
+}
+
+#define STORAGE_INTERNAL_PATH "/opt/usr/media"
+#define STORAGE_SDCARD_PATH "/opt/storage/sdcard"
+#define STORAGE_USBHOST_PATH "/opt/storage/usb"
+#define DISPLAY_BRIGHTNESS_DIVIDE_VALUE 100
+#define WIFI_SIGNAL_STRENGTH_DIVIDE_VALUE 100
+#define CPU_POWER_DEVICE_VALUE 100
+
+#define RADIAN_VALUE (57.2957)
+
+enum {
+ STORAGE_TYPE_UNKNOWN = 0,
+ STORAGE_TYPE_INTERNAL = 1,
+ STORAGE_TYPE_MMC = 2,
+ STORAGE_TYPE_USBHOST = 3
+};
+
+Systeminfo::OptionalProperty Systeminfo::m_Property;
+
+Systeminfo::Systeminfo() : m_networkRegist(REGIST_NOT),
+ m_storageTimer(NULL),
+ m_cpuTimer(NULL),
+ m_sensorHandle(0),
+ m_connectionHandle(NULL)
+{
+ EventMgrPtr eventMgrPtr(new EventMgr());
+ m_EventMgrPtr = eventMgrPtr;
+ if (m_Property.IsNull()) {
+ mapProperties properties;
+ properties["BATTERY"] = BasePropertyPtr(new Battery());
+ m_Property = properties;
+ (*m_Property)["CPU"] = BasePropertyPtr(new Cpu());
+ (*m_Property)["STORAGE"] = BasePropertyPtr(new Storage());
+ (*m_Property)["DISPLAY"] = BasePropertyPtr(new Display());
+ (*m_Property)["NETWORK"] = BasePropertyPtr(new Network());
+ (*m_Property)["WIFI_NETWORK"] = BasePropertyPtr(new WifiNetwork());
+ (*m_Property)["CELLULAR_NETWORK"] = BasePropertyPtr(new CellularNetwork());
+ (*m_Property)["SIM"] = BasePropertyPtr(new SIM());
+ (*m_Property)["DEVICE_ORIENTATION"] = BasePropertyPtr(new DeviceOrientation());
+ (*m_Property)["BUILD"] = BasePropertyPtr(new Build());
+ (*m_Property)["LOCALE"] = BasePropertyPtr(new Locale());
+ (*m_Property)["PERIPHERAL"] = BasePropertyPtr(new Peripheral());
+ }
+
+ int ret = connection_create(&m_connectionHandle);
+
+ if (CONNECTION_ERROR_NONE == ret) {
+ LoggerD("Network Client registration success");
+ } else {
+ LoggerD("Network Client registration success");
+ m_connectionHandle = NULL;
+ }
+
+ m_sensorHandle = sf_connect(ACCELEROMETER_SENSOR);
+ if (m_sensorHandle < 0) {
+ LoggerD ("sensor attach fail");
+ } else {
+ LoggerD("m_sensorHandle : " << m_sensorHandle);
+ int state = sf_start(m_sensorHandle, 0);
+ if(state < 0) {
+ LoggerD("failed");
+ }
+ }
+
+ m_tapiHandle = tel_init(0);
+ if (m_tapiHandle == NULL) {
+ LoggerE ("tel init fail");
+ }
+}
+
+Systeminfo::~Systeminfo()
+{
+ int state = 0;
+ if (m_storageTimer) {
+ ecore_timer_freeze(m_storageTimer);
+ ecore_timer_del(m_storageTimer);
+ m_storageTimer = NULL;
+ }
+ if (m_cpuTimer) {
+ ecore_timer_freeze(m_cpuTimer);
+ ecore_timer_del(m_cpuTimer);
+ m_cpuTimer = NULL;
+ }
+ m_EventMgrPtr->clearAllEvent();
+
+ if(m_connectionHandle != NULL) {
+ LoggerD("Network Client deregistration success");
+ connection_destroy(m_connectionHandle);
+ } else {
+ LoggerD("Network Client deregistration failed");
+ }
+
+ if (m_tapiHandle != NULL) {
+ tel_deinit(m_tapiHandle);
+ }
+
+ state = sf_stop(m_sensorHandle);
+ LoggerD("handle 1 state = " << state);
+
+ state = sf_disconnect(m_sensorHandle);
+ LoggerD("handle state =" << state);
+}
+
+DeviceCapabilitiesPropertiesPtr Systeminfo::getCapabilities()
+{
+ LoggerD("enter");
+ DeviceCapabilitiesPropertiesPtr deviceCapabilities(new DeviceCapabilitiesProperties());
+ return deviceCapabilities;
+}
+
+void Systeminfo::get(const EventGetSysteminfoPtr& event)
+{
+ event->setTapiHandle((void*)m_tapiHandle);
+ EventRequestReceiver<EventGetSysteminfo>::PostRequest(event);
+}
+
+void Systeminfo::watch(const EventWatchSysteminfoPtr& event)
+{
+ if(event->getWatchType() == WATCH_TYPE_UNKNOWN) {
+ LoggerD("watch method is not supported");
+ event->setId(-1);
+ return;
+ }
+
+ event->setSysteminfoPtr(this);
+ event->setTapiHandle((void*)m_tapiHandle);
+ m_EventMgrPtr->addEvent(event, event->getWatchType());
+
+ EventRequestReceiver<EventWatchSysteminfo>::PostRequest(event);
+}
+
+void Systeminfo::clearWatch(const long id)
+{
+ if (id < 1) {
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+ } else {
+ int watchType = m_EventMgrPtr->getWatchType(id);
+ switch(watchType) {
+ case WATCH_TYPE_BATTERY:
+ if ((m_EventMgrPtr->getEventBatteryList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, BatteryValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, BatteryValueCallback);
+ }
+ break;
+ case WATCH_TYPE_DISPLAY:
+ if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback);
+ }
+ break;
+ case WATCH_TYPE_NETWORK:
+ if ((m_EventMgrPtr->getEventNetworkList()).size() == 1) {
+ connection_unset_type_changed_cb(m_connectionHandle);
+ }
+ break;
+ case WATCH_TYPE_WIFINETWORK:
+ if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
+ if (m_networkRegist == REGIST_WIFI) {
+ connection_unset_ip_address_changed_cb(m_connectionHandle);
+ m_networkRegist = REGIST_NOT;
+ } else if (m_networkRegist== REGIST_ALL) {
+ m_networkRegist = REGIST_CELLULAR;
+ }
+ }
+ break;
+ case WATCH_TYPE_CELLULARNETWORK:
+ if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, CellularNetworkValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_CELLID, CellularNetworkValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_LAC, CellularNetworkValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, CellularNetworkValueCallback);
+ if (m_networkRegist == REGIST_CELLULAR) {
+ connection_unset_ip_address_changed_cb(m_connectionHandle);
+ m_networkRegist = REGIST_NOT;
+ } else if (m_networkRegist== REGIST_ALL) {
+ m_networkRegist = REGIST_WIFI;
+ }
+ }
+ break;
+ case WATCH_TYPE_STORAGE:
+ if ((m_EventMgrPtr->getEventStorageList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, StorageValueVconfCallback);
+ if (m_storageTimer) {
+ ecore_timer_freeze(m_storageTimer);
+ ecore_timer_del(m_storageTimer);
+ m_storageTimer = NULL;
+ }
+ }
+ break;
+ case WATCH_TYPE_CPU:
+ if ((m_EventMgrPtr->getEventCpuList()).size() == 1) {
+ if (m_cpuTimer) {
+ ecore_timer_freeze(m_cpuTimer);
+ ecore_timer_del(m_cpuTimer);
+ m_cpuTimer = NULL;
+ }
+ }
+ 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");
+ }
+ }
+ break;
+ case WATCH_TYPE_LOCALE:
+ if ((m_EventMgrPtr->getEventLocaleList()).size() == 1) {
+ if (runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_LANGUAGE) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ if (runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_REGION) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ }
+ break;
+ case WATCH_TYPE_PERIPHERAL:
+ if ((m_EventMgrPtr->getEventPeripheralList()).size() == 1) {
+ vconf_ignore_key_changed(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, PeripheralValueCallback);
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_HDMI, PeripheralValueCallback);
+ }
+ break;
+ case WATCH_TYPE_UNKNOWN:
+ Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+ break;
+ }
+ m_EventMgrPtr->removeEvent(id, watchType);
+ }
+}
+
+BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef property)
+{
+ Converter converter(context);
+ std::string l_property = converter.toString(property);
+ mapProperties::iterator it = (*m_Property).find(l_property);
+ if (it == (*m_Property).end()) {
+ LoggerE("not existing property");
+ Throw(WrtDeviceApis::Commons::ConversionException);
+ return BasePropertyPtr(NULL);
+ }
+
+ return it->second;
+}
+
+void Systeminfo::getWatchValue(const int watchType)
+{
+ LoggerD(" watch type : " << watchType);
+
+ if (watchType == WATCH_TYPE_BATTERY) {
+ EventBatteryList eventList = m_EventMgrPtr->getEventBatteryList();
+ for (EventBatteryList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_DISPLAY) {
+ EventDisplayList eventList = m_EventMgrPtr->getEventDisplayList();
+ for (EventDisplayList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_NETWORK) {
+ EventNetworkList eventList = m_EventMgrPtr->getEventNetworkList();
+ for (EventNetworkList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_NETWORK_ALL) {
+ EventWifiNetworkList eventListWifi = m_EventMgrPtr->getEventWifiNetworkList();
+ EventWifiNetworkList eventListCellular = m_EventMgrPtr->getEventCellularNetworkList();
+ if (eventListWifi.size() > 0) {
+ for (EventWifiNetworkList::iterator it = eventListWifi.begin(); it != eventListWifi.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ }
+ if (eventListCellular.size() > 0) {
+ for (EventCellularNetworkList::iterator it = eventListCellular.begin(); it != eventListCellular.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ }
+ } else if (watchType == WATCH_TYPE_CPU) {
+ EventCpuList eventList = m_EventMgrPtr->getEventCpuList();
+ for (EventCpuList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_STORAGE) {
+ EventStorageList eventList = m_EventMgrPtr->getEventStorageList();
+ for (EventStorageList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ int storageCnt = 1;
+ int sdcardState = 0;
+ if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
+ if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+ LoggerD("mmc is mounted");
+ storageCnt++;
+ } else {
+ LoggerD("mmc is unmounted");
+ }
+ }
+ LoggerD("storage cnt : " << storageCnt);
+ (*it)->getWatchValue(storageCnt);
+ }
+ }else if (watchType == WATCH_TYPE_DEVICE_ORIENTATION) {
+ EventDeviceOrientationList eventList = m_EventMgrPtr->getEventDeviceOrientationList();
+ for (EventDeviceOrientationList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_LOCALE) {
+ EventLocaleList eventList = m_EventMgrPtr->getEventLocaleList();
+ for (EventLocaleList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_PERIPHERAL) {
+ EventPeripheralList eventList = m_EventMgrPtr->getEventPeripheralList();
+ for (EventPeripheralList::iterator it = eventList.begin(); it != eventList.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
+ EventWifiNetworkList eventListCellular = m_EventMgrPtr->getEventCellularNetworkList();
+ if (eventListCellular.size() > 0) {
+ for (EventCellularNetworkList::iterator it = eventListCellular.begin(); it != eventListCellular.end(); it++) {
+ (*it)->getWatchValue();
+ }
+ }
+ }
+}
+
+connection_h Systeminfo::getConnectionHandle()
+{
+ return m_connectionHandle;
+}
+
+JSValueRef Systeminfo::getCpuValue(JSContextRef context)
+{
+ LoggerD("enter");
+ Converter converter(context);
+
+ CpuPropertiesPtr cpuPtr(new CpuProperties());
+ FILE *fp = NULL;
+ long long usr = 0, nice = 0, system = 0, idle = 0, cpuUsage = 0, diffIdle = 0, total = 0;
+
+ fp = fopen("/proc/stat", "r");
+ if(fp == NULL) {
+ return JSValueMakeNull(context);
+ }
+
+ if (fscanf(fp, "%*s %lld %lld %lld %lld", &usr, &system, &nice, &idle) > 0) {
+ total = usr + nice + system + idle - m_cpuInfo.usr - m_cpuInfo.nice - m_cpuInfo.system - m_cpuInfo.idle;
+ diffIdle = idle-m_cpuInfo.idle;
+ if ((total > 0LL) && (diffIdle > 0LL)) {
+ cpuUsage = diffIdle * 100LL / total;
+ cpuPtr->load = (double)cpuUsage / 100.0;
+ m_cpuInfo.usr = usr;
+ m_cpuInfo.system = system;
+ m_cpuInfo.nice = nice;
+ m_cpuInfo.idle = idle;
+ LoggerD("cpu load : " << cpuPtr->load);
+ }
+ }
+
+ fclose(fp);
+ return JSCpuInfo::createJSObject(context, cpuPtr);
+}
+
+void Systeminfo::setSimValue(const int simAttribute, char* value, const EventGetSysteminfoPtr &event)
+{
+ int ret = 0;
+ if (!value) {
+ ret = event->addSimValueCnt();
+ } else {
+ ret = event->setSimValue(simAttribute, value);
+ }
+
+ if (ret == SIM_VALUE_MAX) {
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ }
+}
+
+void Systeminfo::OnRequestReceived(const EventGetSysteminfoPtr& event)
+{
+ LoggerD("enter");
+
+ if (strcmp(event->getProperty(), (const char*)"SIM") == 0) {
+ int cardChanged = 0;
+ TelSimCardStatus_t simCardState;
+ TelSimImsiInfo_t imsi;
+ char* simState = NULL;
+
+ event->switchToManualAnswer();
+ event->setCancelAllowed(true);
+
+ if (tel_get_sim_init_info(m_tapiHandle, &simCardState, &cardChanged) == TAPI_API_SUCCESS) {
+ switch(simCardState) {
+ case TAPI_SIM_STATUS_CARD_NOT_PRESENT :
+ case TAPI_SIM_STATUS_CARD_REMOVED :
+ simState = strdup("ABSENT");
+ break;
+ case TAPI_SIM_STATUS_SIM_INITIALIZING :
+ simState = strdup("INITIALIZING");
+ break;
+ case TAPI_SIM_STATUS_SIM_INIT_COMPLETED :
+ simState = strdup("READY");
+ break;
+ case TAPI_SIM_STATUS_SIM_PIN_REQUIRED :
+ simState = strdup("PIN_REQUIRED");
+ break;
+ case TAPI_SIM_STATUS_SIM_PUK_REQUIRED :
+ simState = strdup("PUK_REQUIRED");
+ break;
+ case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED :
+ case TAPI_SIM_STATUS_CARD_BLOCKED :
+ simState = strdup("SIM_LOCKED");
+ break;
+ case TAPI_SIM_STATUS_SIM_NCK_REQUIRED :
+ case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED :
+ simState = strdup("NETWORK_LOCKED");
+ break;
+ default:
+ simState = strdup("UNKNOWN");
+ break;
+ }
+ if (simState == NULL) {
+ LoggerE("get fail sim state");
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ return;
+ }
+ event->setSimState(simState);
+ if(strcmp(simState, "READY") == 0) {
+ if (tel_get_sim_imsi(m_tapiHandle, &imsi) == TAPI_API_SUCCESS) {
+ LoggerD("mcc : " << imsi.szMcc << " mnc : " << imsi.szMnc << " msin : " << imsi.szMsin);
+ event->setSimImsi(imsi.szMcc, imsi.szMnc, imsi.szMsin);
+ } else {
+ LoggerE("get fail sim imsi");
+ }
+ SysteminfoAsyncPendingEvent *cphsPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_cphs_netname(m_tapiHandle, SimCphsValueCallback, cphsPendingEvent);
+ SysteminfoAsyncPendingEvent *msisdnPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_msisdn(m_tapiHandle, SimMsisdnValueCallback, msisdnPendingEvent);
+ SysteminfoAsyncPendingEvent *iccidPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_iccid(m_tapiHandle, SimIccidValueCallback, iccidPendingEvent);
+ SysteminfoAsyncPendingEvent *spnPendingEvent = new SysteminfoAsyncPendingEvent((void *)this, event);
+ tel_get_sim_spn(m_tapiHandle, SimSpnValueCallback, spnPendingEvent);
+ } else {
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ }
+ free(simState);
+ } else {
+ LoggerE("get fail sim state");
+ event->makeSimObject();
+ EventRequestReceiver<EventGetSysteminfo>::ManualAnswer(event);
+ }
+ } else {
+ event->processGetValue((void *)m_connectionHandle);
+ }
+}
+
+void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
+{
+ WatchOption watchOption = event->getWatchOption();
+
+ event->switchToManualAnswer();
+ event->setCancelAllowed(true);
+
+ switch(event->getWatchType()) {
+ case WATCH_TYPE_BATTERY:
+ if ((m_EventMgrPtr->getEventBatteryList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, BatteryValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, BatteryValueCallback, (void *)this);
+ }
+ break;
+ case WATCH_TYPE_DISPLAY:
+ if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback, (void *)this);
+ }
+ break;
+ case WATCH_TYPE_NETWORK:
+ if ((m_EventMgrPtr->getEventNetworkList()).size() == 1) {
+ connection_set_type_changed_cb(m_connectionHandle, NetworkTypeValueCallback, (void *)this);
+ }
+ break;
+ case WATCH_TYPE_WIFINETWORK:
+ if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
+ if (m_networkRegist == REGIST_NOT) {
+ connection_set_ip_address_changed_cb(m_connectionHandle, NetworkValueCallback, (void *)this);
+ m_networkRegist = REGIST_WIFI;
+ } else if (m_networkRegist== REGIST_CELLULAR) {
+ m_networkRegist = REGIST_ALL;
+ }
+ }
+ break;
+ case WATCH_TYPE_CELLULARNETWORK:
+ if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, CellularNetworkValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_CELLID, CellularNetworkValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_LAC, CellularNetworkValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, CellularNetworkValueCallback, (void *)this);
+ if (m_networkRegist == REGIST_NOT) {
+ connection_set_ip_address_changed_cb(m_connectionHandle, NetworkValueCallback, (void *)this);
+ m_networkRegist = REGIST_CELLULAR;
+ } else if (m_networkRegist== REGIST_WIFI) {
+ m_networkRegist = REGIST_ALL;
+ }
+ }
+ break;
+ case WATCH_TYPE_STORAGE:
+ if ((m_EventMgrPtr->getEventStorageList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, StorageValueVconfCallback, (void *)this);
+ if (!m_storageTimer) {
+ m_storageTimer = ecore_timer_add(1, StorageValueCallback, this);
+ ecore_timer_thaw(m_storageTimer);
+ }
+ }
+ break;
+ case WATCH_TYPE_CPU:
+ if ((m_EventMgrPtr->getEventCpuList()).size() == 1) {
+ if (!m_cpuTimer) {
+ m_cpuTimer = ecore_timer_add(1, CpuValueCallback, this);
+ ecore_timer_thaw(m_cpuTimer);
+ }
+ }
+ break;
+ 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");
+ } else if (state == 0) {
+ LoggerD("sensor_register_cb success to gather data");
+ }
+ } else {
+ LoggerD("already regist");
+ }
+ break;
+ case WATCH_TYPE_LOCALE:
+ if ((m_EventMgrPtr->getEventLocaleList()).size() == 1) {
+ if (runtime_info_set_changed_cb(RUNTIME_INFO_KEY_REGION, localeChangedCallback, (void *)this) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ if (runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LANGUAGE, localeChangedCallback, (void *)this) != RUNTIME_INFO_ERROR_NONE) {
+ LoggerE("regist failed");
+ Throw(WrtDeviceApis::Commons::Exception);
+ }
+ }
+ break;
+ case WATCH_TYPE_PERIPHERAL:
+ if ((m_EventMgrPtr->getEventPeripheralList()).size() == 1) {
+ vconf_notify_key_changed(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, PeripheralValueCallback, (void *)this);
+ vconf_notify_key_changed(VCONFKEY_SYSMAN_HDMI, PeripheralValueCallback, (void *)this);
+ }
+ break;
+ }
+ event->processGetValue();
+ event->setTimer();
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+
+Systeminfo::EventMgr::EventMgr()
+{
+}
+
+Systeminfo::EventMgr::~EventMgr()
+{
+}
+
+void Systeminfo::EventMgr::clearAllEvent()
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+
+ while (!m_eventBatteryList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventBatteryList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventBatteryList.pop_front();
+ }
+ while (!m_eventDisplayList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventDisplayList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventDisplayList.pop_front();
+ }
+ while (!m_eventWifiNetworkList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventWifiNetworkList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventWifiNetworkList.pop_front();
+ }
+ while (!m_eventCelluarNetworkList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventCelluarNetworkList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventCelluarNetworkList.pop_front();
+ }
+ while (!m_eventStorageList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventStorageList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventStorageList.pop_front();
+ }
+ while (!m_eventCpuList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventCpuList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventCpuList.pop_front();
+ }
+ while (!m_eventSimList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventSimList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventSimList.pop_front();
+ }
+ while (!m_eventDeviceOrientationList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventDeviceOrientationList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventDeviceOrientationList.pop_front();
+ }
+ while (!m_eventLocaleList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventLocaleList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventLocaleList.pop_front();
+ }
+ while (!m_eventPeripheralList.empty()) {
+ EventWatchSysteminfoPtr event = m_eventPeripheralList.front();
+ LoggerD("removing EventId=" << event->getId());
+ event->clearWatch();
+ m_eventPeripheralList.pop_front();
+ }
+}
+
+void Systeminfo::EventMgr::addEvent(const EventWatchSysteminfoPtr& arg, const int watchType)
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+
+ if (watchType == WATCH_TYPE_BATTERY){
+ m_eventBatteryList.push_back(arg);
+ LoggerD("Event Battery list size=" << m_eventBatteryList.size());
+ } else if (watchType == WATCH_TYPE_DISPLAY) {
+ m_eventDisplayList.push_back(arg);
+ LoggerD("Event display list size=" << m_eventDisplayList.size());
+ } else if (watchType == WATCH_TYPE_WIFINETWORK) {
+ m_eventWifiNetworkList.push_back(arg);
+ LoggerD("Event wifi network list size=" << m_eventWifiNetworkList.size());
+ } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
+ m_eventCelluarNetworkList.push_back(arg);
+ LoggerD("Event cellular network list size=" << m_eventCelluarNetworkList.size());
+ } else if (watchType == WATCH_TYPE_STORAGE) {
+ m_eventStorageList.push_back(arg);
+ LoggerD("Event storage list size=" << m_eventStorageList.size());
+ } else if (watchType == WATCH_TYPE_CPU) {
+ m_eventCpuList.push_back(arg);
+ LoggerD("Event cpu list size=" << m_eventCpuList.size());
+ } else if (watchType == WATCH_TYPE_SIM) {
+ m_eventSimList.push_back(arg);
+ LoggerD("Event sim list size=" << m_eventSimList.size());
+ } else if (watchType == WATCH_TYPE_DEVICE_ORIENTATION) {
+ m_eventDeviceOrientationList.push_back(arg);
+ LoggerD("Event device orientation list size=" << m_eventDeviceOrientationList.size());
+ } else if (watchType == WATCH_TYPE_NETWORK) {
+ m_eventNetworkList.push_back(arg);
+ LoggerD("Event network list size=" << m_eventNetworkList.size());
+ } else if (watchType == WATCH_TYPE_LOCALE) {
+ m_eventLocaleList.push_back(arg);
+ LoggerD("Event Locale list size=" << m_eventLocaleList.size());
+ } else if (watchType == WATCH_TYPE_PERIPHERAL) {
+ m_eventPeripheralList.push_back(arg);
+ LoggerD("Event peripheral list size=" << m_eventPeripheralList.size());
+ }
+}
+
+void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+ LoggerD("Event id : " << id);
+
+ EventWatchSysteminfoPtr event(NULL);
+
+ LoggerD("trying to delete event, id=" << id);
+
+ if (watchType == WATCH_TYPE_BATTERY) {
+ for (EventBatteryList::iterator it = m_eventBatteryList.begin(); it != m_eventBatteryList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event Battery list size=" << m_eventBatteryList.size());
+ m_eventBatteryList.remove(event);
+ LoggerD( "event removed, event Battery list size=" << m_eventBatteryList.size());
+ } else if (watchType == WATCH_TYPE_DISPLAY) {
+ for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event display list size=" << m_eventDisplayList.size());
+ m_eventDisplayList.remove(event);
+ LoggerD( "event removed, event display list size=" << m_eventDisplayList.size());
+ } else if (watchType == WATCH_TYPE_WIFINETWORK) {
+ for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event wifi network list size=" << m_eventWifiNetworkList.size());
+ m_eventWifiNetworkList.remove(event);
+ LoggerD( "event removed, event wifi network list size=" << m_eventCelluarNetworkList.size());
+ } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
+ for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event cellular network list size=" << m_eventCelluarNetworkList.size());
+ m_eventCelluarNetworkList.remove(event);
+ LoggerD( "event removed, event cellular network list size=" << m_eventCelluarNetworkList.size());
+ } else if (watchType == WATCH_TYPE_STORAGE) {
+ for (EventStorageList::iterator it = m_eventStorageList.begin(); it != m_eventStorageList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event storage list size=" << m_eventStorageList.size());
+ m_eventStorageList.remove(event);
+ LoggerD( "event removed, event storage list size=" << m_eventStorageList.size());
+ } else if (watchType == WATCH_TYPE_CPU) {
+ for (EventCpuList::iterator it = m_eventCpuList.begin(); it != m_eventCpuList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event cpu list size=" << m_eventCpuList.size());
+ m_eventCpuList.remove(event);
+ LoggerD( "event removed, event cpu list size=" << m_eventCpuList.size());
+ } else if (watchType == WATCH_TYPE_SIM) {
+ for (EventSimList::iterator it = m_eventSimList.begin(); it != m_eventSimList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event sim list size=" << m_eventSimList.size());
+ m_eventSimList.remove(event);
+ LoggerD( "event removed, event sim list size=" << m_eventSimList.size());
+ } else if (watchType == WATCH_TYPE_DEVICE_ORIENTATION) {
+ for (EventDeviceOrientationList::iterator it = m_eventDeviceOrientationList.begin(); it != m_eventDeviceOrientationList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event device orientation list size=" << m_eventDeviceOrientationList.size());
+ m_eventDeviceOrientationList.remove(event);
+ LoggerD( "event removed, event device orientation list size=" << m_eventDeviceOrientationList.size());
+ } else if (watchType == WATCH_TYPE_NETWORK) {
+ for (EventNetworkList::iterator it = m_eventNetworkList.begin(); it != m_eventNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event network list size=" << m_eventNetworkList.size());
+ m_eventNetworkList.remove(event);
+ LoggerD( "event removed, event network list size=" << m_eventNetworkList.size());
+ } else if (watchType == WATCH_TYPE_LOCALE) {
+ for (EventLocaleList::iterator it = m_eventLocaleList.begin(); it != m_eventLocaleList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event Locale list size=" << m_eventLocaleList.size());
+ m_eventLocaleList.remove(event);
+ LoggerD( "event removed, event Locale list size=" << m_eventLocaleList.size());
+ } else if (watchType == WATCH_TYPE_PERIPHERAL) {
+ for (EventPeripheralList::iterator it = m_eventPeripheralList.begin(); it != m_eventPeripheralList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return;
+ }
+
+ LoggerD("event peripheral list size=" << m_eventPeripheralList.size());
+ m_eventPeripheralList.remove(event);
+ LoggerD( "event removed, event peripheral list size=" << m_eventPeripheralList.size());
+ }
+}
+
+const int Systeminfo::EventMgr::getWatchType(const long id)
+{
+ DPL::Mutex::ScopedLock lock(&m_synchro);
+
+ EventWatchSysteminfoPtr event(NULL);
+
+ for (EventBatteryList::iterator it = m_eventBatteryList.begin(); it != m_eventBatteryList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventDisplayList::iterator it = m_eventDisplayList.begin(); it != m_eventDisplayList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventStorageList::iterator it = m_eventStorageList.begin(); it != m_eventStorageList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventCpuList::iterator it = m_eventCpuList.begin(); it != m_eventCpuList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventSimList::iterator it = m_eventSimList.begin(); it != m_eventSimList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventDeviceOrientationList::iterator it = m_eventDeviceOrientationList.begin(); it != m_eventDeviceOrientationList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventNetworkList::iterator it = m_eventNetworkList.begin(); it != m_eventNetworkList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventSimList::iterator it = m_eventSimList.begin(); it != m_eventSimList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventLocaleList::iterator it = m_eventLocaleList.begin(); it != m_eventLocaleList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ for (EventPeripheralList::iterator it = m_eventPeripheralList.begin(); it != m_eventPeripheralList.end(); it++) {
+ if (id == (*it)->getId()) {
+ event = *it;
+ break;
+ }
+ }
+
+ if (!event) {
+ LoggerE("event id not in the list, nothing to do");
+ return WATCH_TYPE_UNKNOWN;
+ }
+
+ return event->getWatchType();
+}
+
+EventBatteryList Systeminfo::EventMgr::getEventBatteryList()
+{
+ return m_eventBatteryList;
+}
+
+EventDisplayList Systeminfo::EventMgr::getEventDisplayList()
+{
+ return m_eventDisplayList;
+}
+
+EventNetworkList Systeminfo::EventMgr::getEventNetworkList()
+{
+ return m_eventNetworkList;
+}
+
+EventWifiNetworkList Systeminfo::EventMgr::getEventWifiNetworkList()
+{
+ return m_eventWifiNetworkList;
+}
+
+EventCellularNetworkList Systeminfo::EventMgr::getEventCellularNetworkList()
+{
+ return m_eventCelluarNetworkList;
+}
+
+EventStorageList Systeminfo::EventMgr::getEventStorageList()
+{
+ return m_eventStorageList;
+}
+
+EventCpuList Systeminfo::EventMgr::getEventCpuList()
+{
+ return m_eventCpuList;
+}
+
+EventDeviceOrientationList Systeminfo::EventMgr::getEventDeviceOrientationList()
+{
+ return m_eventDeviceOrientationList;
+}
+
+EventSimList Systeminfo::EventMgr::getEventSimList()
+{
+ return m_eventSimList;
+}
+
+EventLocaleList Systeminfo::EventMgr::getEventLocaleList()
+{
+ return m_eventLocaleList;
+}
+
+EventPeripheralList Systeminfo::EventMgr::getEventPeripheralList()
+{
+ return m_eventPeripheralList;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Battery) {
+ BatteryPropertiesPtr BatteryPtr(new BatteryProperties());
+ int value=0;
+ int value2=0;
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CAPACITY, &value) != 0) {
+ return JSValueMakeNull(context);
+ } else {
+ BatteryPtr->level = (double)(value)/CPU_POWER_DEVICE_VALUE;
+ }
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, &value2) != 0) {
+ return JSValueMakeNull(context);
+ } else {
+ BatteryPtr->isCharging = (value2 == 0) ? false : true;
+ }
+
+ return JSBatteryInfo::createJSObject(context, BatteryPtr);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Cpu) {
+ Converter converter(context);
+
+ CpuPropertiesPtr cpuPtr(new CpuProperties());
+ FILE *fp = NULL;
+ long long usr = 0, nice = 0, system = 0, idle = 0, total = 0, cpuUsage = 0;
+
+ fp = fopen("/proc/stat", "r");
+ if(fp == NULL) {
+ return JSValueMakeNull(context);
+ }
+
+ if (fscanf(fp, "%*s %lld %lld %lld %lld", &usr, &system, &nice, &idle) > 0) {
+ total = usr + nice + system + idle;
+ if ((total > 0LL) && (idle > 0LL)) {
+ cpuUsage = idle * 100LL / total;
+ cpuPtr->load = (double)cpuUsage / 100.0;
+ LoggerD("cpu load : " << cpuPtr->load);
+ }
+ }
+
+ fclose(fp);
+ return JSCpuInfo::createJSObject(context, cpuPtr);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Storage) {
+ Converter converter(context);
+ int sdcardState=0;
+ struct statfs fs;
+
+ if (statfs(STORAGE_INTERNAL_PATH, &fs) < 0) {
+ return JSValueMakeNull(context);
+ }
+ StoragePropertiesPtr storagePtr(new StorageProperties());
+ storagePtr->units[0].type = "INTERNAL";
+ storagePtr->units[0].capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
+ storagePtr->units[0].availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
+ storagePtr->units[0].isRemoveable = false;
+ storagePtr->units[0].isRemovable = false;
+ storagePtr->cnt = 1;
+ LoggerD("type : " << storagePtr->units[0].type);
+ if(vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &sdcardState) == 0) {
+ if(sdcardState == VCONFKEY_SYSMAN_MMC_MOUNTED){
+ if (statfs(STORAGE_SDCARD_PATH, &fs) < 0) {
+ return JSValueMakeNull(context);
+ }
+ storagePtr->units[1].type = "MMC";
+ storagePtr->units[1].capacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_blocks;
+ storagePtr->units[1].availableCapacity = (unsigned long long)fs.f_bsize * (unsigned long long)fs.f_bavail;
+ storagePtr->units[1].isRemoveable = true;
+ storagePtr->units[1].isRemovable = true;
+ storagePtr->cnt = 2;
+ LoggerD("type : " << storagePtr->units[1].type);
+ }
+ }
+ return JSStorageInfo::createJSObject(context, storagePtr);
+
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
+ Converter converter(context);
+
+ DisplayPropertiesPtr display(new DisplayProperties());
+ int brightness=0, dotsPerInch=0, physicalW=0, physicalH=0;
+ bool screenSizeSmall = false, screenSizeBig = false;
+
+ if(vconf_get_int(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, &brightness) == 0) {
+ display->brightness = (double)(brightness)/DISPLAY_BRIGHTNESS_DIVIDE_VALUE;
+ }
+
+ if(system_info_get_platform_bool("tizen.org/feature/screen.size.normal.480.800", &screenSizeSmall) == SYSTEM_INFO_ERROR_NONE) {
+ if (screenSizeSmall) {
+ display->resolutionWidth = 480;
+ display->resolutionHeight = 800;
+ } else {
+ if (system_info_get_platform_bool("tizen.org/feature/screen.size.normal.720.1280", &screenSizeBig) == SYSTEM_INFO_ERROR_NONE) {
+ if (screenSizeBig) {
+ display->resolutionWidth = 720;
+ display->resolutionHeight = 1280;
+ }
+ }
+ }
+ }
+
+ if(system_info_get_platform_int("tizen.org/feature/screen.dpi", &dotsPerInch) == SYSTEM_INFO_ERROR_NONE) {
+ display->dotsPerInchWidth = dotsPerInch;
+ display->dotsPerInchHeight = dotsPerInch;
+ }
+
+ if(system_info_get_value_int(SYSTEM_INFO_KEY_PHYSICAL_SCREEN_WIDTH, &physicalW) == SYSTEM_INFO_ERROR_NONE) {
+ display->physicalWidth = physicalW;
+ }
+
+ if(system_info_get_value_int(SYSTEM_INFO_KEY_PHYSICAL_SCREEN_HEIGHT, &physicalH) == SYSTEM_INFO_ERROR_NONE) {
+ display->physicalHeight = physicalH;
+ }
+
+ return JSDisplayInfo::createJSObject(context, display);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Network) {
+ LoggerD("enter");
+ Converter converter(context);
+ NetworkPropertiesPtr Network(new NetworkProperties());
+ connection_h connectionHandle = (connection_h)handle;
+ connection_type_e connectionType;
+ int networkType = 0;
+
+ if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
+ LoggerD("get connection type is failed");
+ return JSNetworkInfo::createJSObject(context, Network);
+ }
+
+ if (connectionType == CONNECTION_TYPE_WIFI) {
+ LoggerD("wifi network");
+ Network->networkType= "WIFI";
+ } else if (connectionType == CONNECTION_TYPE_CELLULAR) {
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVCTYPE, &networkType) == 0) {
+ if (networkType < VCONFKEY_TELEPHONY_SVCTYPE_2G) {
+ Network->networkType= "NONE";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_2G) {
+ Network->networkType= "2G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_2G || networkType == VCONFKEY_TELEPHONY_SVCTYPE_2_5G_EDGE) {
+ Network->networkType= "2.5G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_3G || networkType == VCONFKEY_TELEPHONY_SVCTYPE_HSDPA) {
+ Network->networkType= "3G";
+ } else if (networkType == VCONFKEY_TELEPHONY_SVCTYPE_LTE) {
+ Network->networkType= "4G";
+ } else {
+ Network->networkType= "NONE";
+ }
+ }
+ } else if (connectionType == CONNECTION_TYPE_ETHERNET) {
+ LoggerD("ethernet network");
+ Network->networkType= "ETHERNET";
+ } else {
+ Network->networkType= "NONE";
+ }
+
+ return JSNetworkInfo::createJSObject(context, Network);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(WifiNetwork) {
+ Converter converter(context);
+ WifiNetworkPropertiesPtr wifiNetwork(new WifiNetworkProperties());
+ connection_h connectionHandle = (connection_h)handle;
+ connection_type_e connectionType;
+ connection_profile_h profileHandle = NULL;
+ connection_address_family_e addressFamily = CONNECTION_ADDRESS_FAMILY_IPV4;
+ char* ipAddr = NULL;
+ char* essid = NULL;
+ int rssi = 0;
+
+ if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+ }
+
+ if (connectionType == CONNECTION_TYPE_WIFI) {
+ wifiNetwork->status = "ON";
+ } else {
+ wifiNetwork->status = "OFF";
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+ }
+
+ if (connection_get_current_profile(connectionHandle, &profileHandle) != CONNECTION_ERROR_NONE) {
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+ }
+
+ if (connection_profile_get_wifi_essid(profileHandle, &essid) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->ssid = essid;
+ free(essid);
+ }
+
+ if (connection_profile_get_ip_address(profileHandle, addressFamily, &ipAddr) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->ipAddress = ipAddr;
+ free(ipAddr);
+ }
+
+ if (connection_profile_get_wifi_rssi(profileHandle, &rssi) == CONNECTION_ERROR_NONE) {
+ wifiNetwork->signalStrength = (double) rssi/WIFI_SIGNAL_STRENGTH_DIVIDE_VALUE;
+ }
+
+ return JSWifiNetworkInfo::createJSObject(context, wifiNetwork);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(CellularNetwork) {
+ Converter converter(context);
+ CellularNetworkPropertiesPtr cellularNetwork(new CellularNetworkProperties());
+ connection_h connectionHandle = (connection_h)handle;
+ connection_type_e connectionType;
+ connection_profile_h profileHandle = NULL;
+ connection_address_family_e addressFamily = CONNECTION_ADDRESS_FAMILY_IPV4;
+ char* ipAddr = NULL;
+ char* apn = NULL;
+ char* imei = NULL;
+ int plmn = 0, cellId = 0, lac = 0, isRoaming = 0, isFlightMode = 0;
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)mcc", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_PLMN, &plmn) == 0) {
+ cellularNetwork->mcc = plmn / 100;
+ cellularNetwork->mnc = plmn % 100;
+ }
+ TIME_TRACER_ITEM_END("(cellular)mcc", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)cellId", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_CELLID, &cellId) == 0) {
+ cellularNetwork->cellId = cellId;
+ }
+ TIME_TRACER_ITEM_END("(cellular)cellId", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)lac", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_LAC, &lac) == 0) {
+ cellularNetwork->lac = lac;
+ }
+ TIME_TRACER_ITEM_END("(cellular)lac", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)isRoaming", 0);
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, &isRoaming) == 0) {
+ if (isRoaming) {
+ cellularNetwork->isRoaming = true;
+ } else {
+ cellularNetwork->isRoaming = false;
+ }
+ }
+ TIME_TRACER_ITEM_END("(cellular)isRoaming", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)isFlightMode", 0);
+ if (vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &isFlightMode) == 0) {
+ if (isFlightMode) {
+ cellularNetwork->isFlightMode = true;
+ } else {
+ cellularNetwork->isFlightMode = false;
+ }
+ }
+ TIME_TRACER_ITEM_END("(cellular)isFlightMode", 0);
+
+ if (connection_get_type(connectionHandle, &connectionType) != CONNECTION_ERROR_NONE) {
+ return JSCellularNetworkInfo::createJSObject(context, cellularNetwork);
+ }
+
+ if (connectionType == CONNECTION_TYPE_CELLULAR) {
+ cellularNetwork->status = "ON";
+ if (connection_get_current_profile(connectionHandle, &profileHandle) == CONNECTION_ERROR_NONE) {
+ TIME_TRACER_ITEM_BEGIN("(cellular)apn", 0);
+ if (connection_profile_get_cellular_apn(profileHandle, &apn) == CONNECTION_ERROR_NONE) {
+ cellularNetwork->apn = apn;
+ free(apn);
+ }
+ TIME_TRACER_ITEM_END("(cellular)apn", 0);
+
+ TIME_TRACER_ITEM_BEGIN("(cellular)ipAddress", 0);
+ if (connection_profile_get_ip_address(profileHandle, addressFamily, &ipAddr) == CONNECTION_ERROR_NONE) {
+ cellularNetwork->ipAddress = ipAddr;
+ free(ipAddr);
+ }
+ TIME_TRACER_ITEM_END("(cellular)ipAddress", 0);
+ connection_profile_destroy(profileHandle);
+ }
+ } else {
+ cellularNetwork->status = "OFF";
+ if (connection_get_default_cellular_service_profile(connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, &profileHandle) == CONNECTION_ERROR_NONE) {
+ TIME_TRACER_ITEM_BEGIN("(cellular)apn", 0);
+ if (connection_profile_get_cellular_apn(profileHandle, &apn) == CONNECTION_ERROR_NONE) {
+ cellularNetwork->apn = apn;
+ free(apn);
+ }
+ TIME_TRACER_ITEM_END("(cellular)apn", 0);
+ connection_profile_destroy(profileHandle);
+ }
+ }
+
+ imei = tel_get_misc_me_imei_sync((TapiHandle*)tapiHandle);
+
+ if (imei != NULL) {
+ LoggerD("imei : " << imei);
+ cellularNetwork->imei = imei;
+ free(imei);
+ } else {
+ LoggerD("get fail imei");
+ }
+
+ return JSCellularNetworkInfo::createJSObject(context, cellularNetwork);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(SIM) {
+ Converter converter(context);
+ SIMPropertiesPtr SIM(new SIMProperties());
+
+ return JSSIMInfo::createJSObject(context, SIM);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(DeviceOrientation) {
+ LoggerD("enter");
+ Converter converter(context);
+ DeviceOrientationPropertiesPtr deviceOrientation(new DeviceOrientationProperties());
+
+ 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);
+ if (handleOrientaion < 0) {
+ LoggerD ("sensor attach fail");
+ return JSDeviceOrientationInfo::createJSObject(context, deviceOrientation);
+ }
+ int state = sf_start(handleOrientaion, 0);
+ if(state < 0) {
+ LoggerD("start failed");
+ }
+
+ int ret_val = sf_check_rotation(&rotation);
+ if (ret_val < 0) {
+ LoggerD("sf_check_rotation fail to gather data\n");
+ }
+
+ LoggerD(" rotation value = " << rotation);
+
+ switch (rotation) {
+ case 0:
+ case ROTATION_EVENT_0:
+ LoggerD("my_callback_func received data (PORTRAIT_TOP|HEAD_CENTER)\n");
+ deviceOrientation->status = "PORTRAIT_PRIMARY";
+ break;
+ case ROTATION_EVENT_90:
+ LoggerD("my_callback_func received data (LANDSCAPE|HEAD_RIGHT)\n");
+ deviceOrientation->status = "LANDSCAPE_PRIMARY";
+ break;
+ case ROTATION_EVENT_180:
+ LoggerD("my_callback_func received data (PORTRAIT_BTM|HEAD_CENTER)\n");
+ deviceOrientation->status = "PORTRAIT_SECONDARY";
+ break;
+ case ROTATION_EVENT_270:
+ LoggerD("my_callback_func received data (LANDSCAPE|HEAD_LEFT)\n");
+ deviceOrientation->status = "LANDSCAPE_SECONDARY";
+ break;
+ default:
+ LoggerD(" received data unexpected\n");
+ break;
+ }
+
+ state = sf_stop(handleOrientaion);
+ LoggerD("handleOrientaion 1 state = " << state);
+
+ state = sf_disconnect(handleOrientaion);
+ LoggerD("handleOrientaion state =" << state);
+
+ return JSDeviceOrientationInfo::createJSObject(context, deviceOrientation);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Build) {
+ LoggerD("enter");
+ Converter converter(context);
+ BuildPropertiesPtr Build(new BuildProperties());
+
+ char* model = NULL;
+ char* manufacturer = NULL;
+ char* buildVersion = NULL;
+
+ if(system_info_get_platform_string("tizen.org/system/model_name", &model) == SYSTEM_INFO_ERROR_NONE) {
+ if (model != NULL) {
+ LoggerD("model : " << model);
+ Build->model = model;
+ free(model);
+ }
+ }
+
+ if (system_info_get_value_string(SYSTEM_INFO_KEY_MANUFACTURER, &manufacturer) == SYSTEM_INFO_ERROR_NONE) {
+ if (manufacturer != NULL) {
+ LoggerD("manufacturer : " << manufacturer);
+ Build->manufacturer = manufacturer;
+ free(manufacturer);
+ }
+ }
+
+ if (system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &buildVersion) == SYSTEM_INFO_ERROR_NONE) {
+ if (buildVersion != NULL) {
+ LoggerD("buildVersion : " << buildVersion);
+ Build->buildVersion = buildVersion;
+ free(buildVersion);
+ }
+ }
+
+ return JSBuildInfo::createJSObject(context, Build);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Locale) {
+ LoggerD("enter");
+ Converter converter(context);
+ LocalePropertiesPtr Locale(new LocaleProperties());
+
+ char* country = NULL;
+ char* language = NULL;
+
+ if (runtime_info_get_value_string(RUNTIME_INFO_KEY_LANGUAGE, &language) == RUNTIME_INFO_ERROR_NONE) {
+ if (language != NULL) {
+ LoggerD("language : " << language);
+ Locale->language = language;
+ free(language);
+ }
+ }
+
+ if (runtime_info_get_value_string(RUNTIME_INFO_KEY_REGION, &country) == RUNTIME_INFO_ERROR_NONE) {
+ if (country != NULL) {
+ LoggerD("country : " << country);
+ char* token = NULL;
+ char* countryTemp = NULL;
+ token = strtok(country, ".");
+ if (token != NULL) {
+ countryTemp = strdup(token);
+ if (countryTemp != NULL) {
+ Locale->country = countryTemp;
+ free(countryTemp);
+ }
+ }
+ free(country);
+ }
+ }
+
+ return JSLocaleInfo::createJSObject(context, Locale);
+}
+
+PROPERTY_GET_SYSTEMINFO_DEFINITION(Peripheral) {
+ Converter converter(context);
+ PeripheralPropertiesPtr peripheral(new PeripheralProperties());
+ int hdmiStatus = 0, wirelessDisplayStatus = 0 ;
+
+ if (vconf_get_int(VCONFKEY_MIRACAST_WFD_SOURCE_STATUS, &wirelessDisplayStatus) == 0) {
+ switch(wirelessDisplayStatus) {
+ case VCONFKEY_MIRACAST_WFD_SOURCE_ON:
+ peripheral->isVideoOutputOn = true;
+ break;
+ default:
+ LoggerD("VideOutput status is off");
+ break;
+ }
+ }
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_HDMI, &hdmiStatus) == 0) {
+ switch(hdmiStatus) {
+ case VCONFKEY_SYSMAN_HDMI_CONNECTED:
+ peripheral->isVideoOutputOn = true;
+ break;
+ default:
+ LoggerD("VideOutput status is off");
+ break;
+ }
+ }
+
+ return JSPeripheralInfo::createJSObject(context, peripheral);
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/Systeminfo.h b/mobile_src/Systeminfo/Systeminfo.h
new file mode 100755
index 0000000..fde871f
--- /dev/null
+++ b/mobile_src/Systeminfo/Systeminfo.h
@@ -0,0 +1,236 @@
+//
+// 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 WRTPLUGINS_PLATFORM_SYSTEMINFO_H_
+#define WRTPLUGINS_PLATFORM_SYSTEMINFO_H_
+
+#include <map>
+#include <vector>
+#include <string>
+#include <sys/vfs.h>
+#include <vconf.h>
+#include <sensor.h>
+#include <sensors.h>
+#include <net_connection.h>
+#include <system_info.h>
+#include <runtime_info.h>
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <dpl/noncopyable.h>
+#include "ISysteminfo.h"
+#include "SysteminfoFactory.h"
+#include "EventGetSysteminfo.h"
+#include "EventWatchSysteminfo.h"
+#include "BaseProperties.h"
+#include <tapi_common.h>
+#include <ITapiModem.h>
+#include <ITapiSim.h>
+#include <Commons/Emitters.h>
+#include <CommonsJavaScript/Converter.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+enum {
+ WATCH_TYPE_UNKNOWN = 0,
+ WATCH_TYPE_BATTERY = 1,
+ WATCH_TYPE_DISPLAY = 2,
+ WATCH_TYPE_WIFINETWORK = 3,
+ WATCH_TYPE_CELLULARNETWORK = 4,
+ WATCH_TYPE_NETWORK = 5,
+ WATCH_TYPE_STORAGE = 6,
+ WATCH_TYPE_CPU = 8,
+ WATCH_TYPE_SIM = 9,
+ WATCH_TYPE_DEVICE_ORIENTATION = 10,
+ WATCH_TYPE_PERIPHERAL = 11,
+ WATCH_TYPE_LOCALE = 12,
+ WATCH_TYPE_NETWORK_ALL = 13
+};
+
+enum {
+ REGIST_NOT = 0,
+ REGIST_WIFI = 1,
+ REGIST_CELLULAR =2,
+ REGIST_ALL = 3
+};
+
+enum {
+ SIM_CPHS_VALUE = 0,
+ SIM_MSISDN_VALUE = 1,
+ SIM_ICCID_VALUE = 2,
+ SIM_SPN_VALUE = 3
+};
+
+struct cpuInfo {
+ unsigned long long usr;
+ unsigned long long nice;
+ unsigned long long system;
+ unsigned long long idle;
+ unsigned long long usage;
+ cpuInfo() : usr(0), nice(0), system(0), idle(0), usage(0)
+ {
+ }
+};
+
+typedef DPL::Atomic::ValueType WatchId;
+
+#define PROPERTY_DECLARATION(className, propertyName, watchType) \
+ class className : public BaseProperty { \
+ public: \
+ explicit className() : BaseProperty() { \
+ } \
+ JSValueRef getValue(JSContextRef context, void* handle, void* tapiHandle) const; \
+ const char* getProperty() const \
+ { \
+ return propertyName; \
+ } \
+ const int getWatchType() const \
+ { \
+ return watchType; \
+ } \
+ };
+
+#define PROPERTY_GET_SYSTEMINFO_DEFINITION(className) JSValueRef className::getValue( \
+ JSContextRef context, void* handle, void* tapiHandle) const
+
+PROPERTY_DECLARATION(Battery, "BATTERY", WATCH_TYPE_BATTERY)
+PROPERTY_DECLARATION(Cpu, "CPU", WATCH_TYPE_CPU)
+PROPERTY_DECLARATION(Storage, "STORAGE", WATCH_TYPE_STORAGE)
+PROPERTY_DECLARATION(Display, "DISPLAY", WATCH_TYPE_DISPLAY)
+PROPERTY_DECLARATION(Network, "NETWORK", WATCH_TYPE_NETWORK)
+PROPERTY_DECLARATION(WifiNetwork, "WIFI_NETWORK", WATCH_TYPE_WIFINETWORK)
+PROPERTY_DECLARATION(CellularNetwork, "CELLULAR_NETWORK", WATCH_TYPE_CELLULARNETWORK)
+PROPERTY_DECLARATION(SIM, "SIM", WATCH_TYPE_SIM)
+PROPERTY_DECLARATION(DeviceOrientation, "DEVICE_ORIENTATION", WATCH_TYPE_DEVICE_ORIENTATION)
+PROPERTY_DECLARATION(Build, "BUILD", WATCH_TYPE_UNKNOWN)
+PROPERTY_DECLARATION(Locale, "LOCALE", WATCH_TYPE_LOCALE)
+PROPERTY_DECLARATION(Peripheral, "PERIPHERAL", WATCH_TYPE_PERIPHERAL)
+
+typedef std::list<EventWatchSysteminfoPtr> EventBatteryList;
+typedef std::list<EventWatchSysteminfoPtr> EventDisplayList;
+typedef std::list<EventWatchSysteminfoPtr> EventNetworkList;
+typedef std::list<EventWatchSysteminfoPtr> EventWifiNetworkList;
+typedef std::list<EventWatchSysteminfoPtr> EventCellularNetworkList;
+typedef std::list<EventWatchSysteminfoPtr> EventStorageList;
+typedef std::list<EventWatchSysteminfoPtr> EventCpuList;
+typedef std::list<EventWatchSysteminfoPtr> EventSimList;
+typedef std::list<EventWatchSysteminfoPtr> EventDeviceOrientationList;
+typedef std::list<EventWatchSysteminfoPtr> EventLocaleList;
+typedef std::list<EventWatchSysteminfoPtr> EventPeripheralList;
+
+class Systeminfo : public ISysteminfo
+{
+ friend class SysteminfoFactory;
+ friend class EventWatchSysteminfo;;
+
+ public:
+
+ virtual ~Systeminfo();
+ virtual DeviceCapabilitiesPropertiesPtr getCapabilities();
+ virtual void get(const EventGetSysteminfoPtr& event);
+ virtual void watch(const EventWatchSysteminfoPtr& event);
+ virtual BasePropertyPtr getBasePropertyPtr(JSContextRef context, JSValueRef property);
+ virtual void clearWatch(const long id);
+ void getWatchValue(const int watchType);
+ connection_h getConnectionHandle();
+ JSValueRef getCpuValue(JSContextRef context);
+ void setSimValue(const int simAttribute, char* value, const EventGetSysteminfoPtr &event);
+
+ class EventMgr
+ {
+ public:
+ EventMgr();
+ ~EventMgr();
+
+ void clearAllEvent();
+ void addEvent(const EventWatchSysteminfoPtr& arg, const int watchType);
+ void removeEvent(WatchId id, const int watchType);
+ const int getWatchType(const long id);
+ EventBatteryList getEventBatteryList();
+ EventDisplayList getEventDisplayList();
+ EventNetworkList getEventNetworkList();
+ EventWifiNetworkList getEventWifiNetworkList();
+ EventCellularNetworkList getEventCellularNetworkList();
+ EventStorageList getEventStorageList();
+ EventCpuList getEventCpuList();
+ EventSimList getEventSimList();
+ EventDeviceOrientationList getEventDeviceOrientationList();
+ EventLocaleList getEventLocaleList();
+ EventPeripheralList getEventPeripheralList();
+
+ private:
+ EventBatteryList m_eventBatteryList;
+ EventDisplayList m_eventDisplayList;
+ EventNetworkList m_eventNetworkList;
+ EventWifiNetworkList m_eventWifiNetworkList;
+ EventCellularNetworkList m_eventCelluarNetworkList;
+ EventStorageList m_eventStorageList;
+ EventCpuList m_eventCpuList;
+ EventSimList m_eventSimList;
+ EventDeviceOrientationList m_eventDeviceOrientationList;
+ EventLocaleList m_eventLocaleList;
+ EventPeripheralList m_eventPeripheralList;
+ DPL::Mutex m_synchro;
+ };
+ typedef DPL::SharedPtr<EventMgr> EventMgrPtr;
+
+ protected:
+ Systeminfo();
+ virtual void OnRequestReceived(const EventGetSysteminfoPtr& event);
+ virtual void OnRequestReceived(const EventWatchSysteminfoPtr& event);
+
+ private:
+ typedef std::map<std::string, BasePropertyPtr > mapProperties;
+ typedef DPL::Optional<mapProperties> OptionalProperty;
+
+ static OptionalProperty m_Property;
+ int m_networkRegist;
+ DPL::Mutex m_initializationMutex;
+ EventMgrPtr m_EventMgrPtr;
+ Ecore_Timer *m_storageTimer;
+ Ecore_Timer *m_cpuTimer;
+ int m_sensorHandle;
+ connection_h m_connectionHandle;
+ cpuInfo m_cpuInfo;
+ TapiHandle *m_tapiHandle;
+};
+
+class SysteminfoAsyncPendingEvent
+{
+ public:
+ SysteminfoAsyncPendingEvent(void *thisObject, const EventGetSysteminfoPtr &event) :
+ m_thisObject(thisObject),
+ m_event(event)
+ {
+ }
+
+ virtual ~SysteminfoAsyncPendingEvent()
+ {
+ }
+
+ void* getThisObject() const { return m_thisObject; }
+ EventGetSysteminfoPtr getEvent() const { return m_event; }
+
+ private:
+ void *m_thisObject;
+ EventGetSysteminfoPtr m_event;
+};
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/SysteminfoAsyncCallbackManager.cpp b/mobile_src/Systeminfo/SysteminfoAsyncCallbackManager.cpp
new file mode 100755
index 0000000..6fa6b26
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoAsyncCallbackManager.cpp
@@ -0,0 +1,26 @@
+//
+// 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 "SysteminfoAsyncCallbackManager.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+SINGLETON_IMPLEMENTATION(SysteminfoAsyncCallbackManager)
+
+} // Systeminfo
+} // DeviceAPI
diff --git a/mobile_src/Systeminfo/SysteminfoAsyncCallbackManager.h b/mobile_src/Systeminfo/SysteminfoAsyncCallbackManager.h
new file mode 100755
index 0000000..2393cc7
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoAsyncCallbackManager.h
@@ -0,0 +1,46 @@
+//
+// 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_SYSTEMINFO_ASYNC_CALLBACK_MANAGER_H_
+#define _TIZEN_SYSTEMINFO_ASYNC_CALLBACK_MANAGER_H_
+
+#include <AsyncCallbackManager.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+class SysteminfoAsyncCallbackManager : public DeviceAPI::Common::AsyncCallbackManager
+{
+private:
+ SysteminfoAsyncCallbackManager()
+ {
+ }
+
+public:
+ virtual ~SysteminfoAsyncCallbackManager()
+ {
+ }
+
+ friend class SysteminfoAsyncCallbackManagerSingleton;
+};
+
+SINGLETON_DEFINITION(SysteminfoAsyncCallbackManager)
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/SysteminfoFactory.cpp b/mobile_src/Systeminfo/SysteminfoFactory.cpp
new file mode 100755
index 0000000..e24374b
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoFactory.cpp
@@ -0,0 +1,41 @@
+//
+// 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 "Systeminfo.h"
+#include "SysteminfoFactory.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+ISysteminfoPtr SysteminfoFactory::getSysteminfos()
+{
+ static ISysteminfoPtr obj(new Systeminfo());
+ return obj;
+}
+
+SysteminfoFactory& SysteminfoFactory::getInstance()
+{
+ static SysteminfoFactory theInstance;
+ return theInstance;
+}
+
+SysteminfoFactory::SysteminfoFactory()
+{
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/SysteminfoFactory.h b/mobile_src/Systeminfo/SysteminfoFactory.h
new file mode 100755
index 0000000..41b7066
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoFactory.h
@@ -0,0 +1,42 @@
+//
+// 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 WRTPLUGINS_API_SYSTMEINFOFACTORY_H_
+#define WRTPLUGINS_API_SYSTMEINFOFACTORY_H_
+
+#include <dpl/noncopyable.h>
+#include "ISysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+class SysteminfoFactory : DPL::Noncopyable
+{
+ public:
+ ISysteminfoPtr getSysteminfos();
+
+ static SysteminfoFactory& getInstance();
+
+ protected:
+ SysteminfoFactory();
+};
+
+}
+}
+
+#endif
+
diff --git a/mobile_src/Systeminfo/SysteminfoListener.cpp b/mobile_src/Systeminfo/SysteminfoListener.cpp
new file mode 100755
index 0000000..287d13f
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoListener.cpp
@@ -0,0 +1,68 @@
+//
+// 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 <CommonsJavaScript/JSCallbackManager.h>
+#include "SysteminfoListener.h"
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include "SysteminfoAsyncCallbackManager.h"
+#include <TimeTracer.h>
+#include <Logger.h>
+
+using namespace std;
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+SysteminfoListener& SysteminfoListener::getInstance()
+{
+ static SysteminfoListener instance;
+ return instance;
+}
+
+SysteminfoListener::SysteminfoListener() :
+ EventGetSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+ EventWatchSysteminfoAnswerReceiver(WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD)
+{
+}
+
+SysteminfoListener::~SysteminfoListener()
+{
+}
+
+void SysteminfoListener::OnAnswerReceived(const EventGetSysteminfoPtr& event)
+{
+ LoggerD("Enter");
+ WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<WrtDeviceApis::CommonsJavaScript::JSCallbackManager >(event->getPrivateData());
+ LoggerD("thread=" << DPL::Thread::GetCurrentThread());
+
+ SysteminfoAsyncCallbackManagerSingleton::Instance().unregisterCallbackManager(callbackManager);
+
+ if (!event->checkCancelled()) {
+ JSValueRef tmpValue = event->getValue();
+ if ((WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) && (NULL != tmpValue)) {
+ callbackManager->callOnSuccess(tmpValue);
+ TIME_TRACER_ITEM_END(event->getProperty(), 0);
+ }
+ }
+}
+
+void SysteminfoListener::OnAnswerReceived(const EventWatchSysteminfoPtr& event)
+{
+}
+
+}
+}
diff --git a/mobile_src/Systeminfo/SysteminfoListener.h b/mobile_src/Systeminfo/SysteminfoListener.h
new file mode 100755
index 0000000..fa85b3b
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoListener.h
@@ -0,0 +1,51 @@
+//
+// 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 WRTPLUGINS_API_SYSTEMINFO_LISTENER_H_
+#define WRTPLUGINS_API_SYSTEMINFO_LISTENER_H_
+
+#include <CommonsJavaScript/JSPendingOperation.h>
+#include "ISysteminfo.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventGetSysteminfo> EventGetSysteminfoAnswerReceiver;
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<EventWatchSysteminfo> EventWatchSysteminfoAnswerReceiver;
+
+class SysteminfoListener : public EventGetSysteminfoAnswerReceiver, public EventWatchSysteminfoAnswerReceiver
+{
+ private:
+ explicit SysteminfoListener();
+
+ public:
+ static SysteminfoListener& getInstance();
+
+ virtual ~SysteminfoListener();
+
+ protected:
+ virtual void OnAnswerReceived(const EventGetSysteminfoPtr& event);
+
+ virtual void OnAnswerReceived(const EventWatchSysteminfoPtr& event);
+};
+
+typedef DPL::SharedPtr<SysteminfoListener> SysteminfoListenerPtr;
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/SysteminfoListenerManager.cpp b/mobile_src/Systeminfo/SysteminfoListenerManager.cpp
new file mode 100755
index 0000000..54cac75
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoListenerManager.cpp
@@ -0,0 +1,26 @@
+//
+// 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 "SysteminfoListenerManager.h"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+SINGLETON_IMPLEMENTATION(SysteminfoListenerManager)
+
+} // Systeminfo
+} // DeviceAPI
diff --git a/mobile_src/Systeminfo/SysteminfoListenerManager.h b/mobile_src/Systeminfo/SysteminfoListenerManager.h
new file mode 100644
index 0000000..7807ba2
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoListenerManager.h
@@ -0,0 +1,81 @@
+//
+// 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_SYSTEMINFO_LISTENER_MANAGER_H_
+#define _TIZEN_SYSTEMINFO_LISTENER_MANAGER_H_
+
+#include <map>
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <IListenerManager.h>
+#include "JSSysteminfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+class SysteminfoListenerManager : public DeviceAPI::Common::IListenerController
+{
+private:
+ SysteminfoListenerManager()
+ {
+ }
+
+public:
+ virtual ~SysteminfoListenerManager()
+ {
+ }
+
+ friend class SysteminfoListenerManagerSingleton;
+};
+SINGLETON_DEFINITION(SysteminfoListenerManager)
+
+class SysteminfoListenerCanceller : public DeviceAPI::Common::IListenerItem
+{
+public:
+ SysteminfoListenerCanceller(JSContextRef context, JSObjectRef object, long watchId) :
+ DeviceAPI::Common::IListenerItem(context, object, watchId)
+ {
+ }
+
+ virtual ~SysteminfoListenerCanceller()
+ {
+ }
+
+ virtual void cancelListener()
+ {
+ JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(m_object));
+
+ if (!priv) {
+ LoggerW("Object has no private object");
+ return;
+ }
+
+ try {
+ ISysteminfoPtr Systeminfos(priv->getObject());
+ Systeminfos->clearWatch(m_watchId);
+ } Catch(WrtDeviceApis::Commons::Exception) {
+ LoggerE("Error on platform : " << _rethrown_exception.GetMessage());
+ }
+ }
+};
+typedef DPL::SharedPtr<SysteminfoListenerCanceller> SysteminfoListenerCancellerPtr;
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/SysteminfoPropertyInfo.h b/mobile_src/Systeminfo/SysteminfoPropertyInfo.h
new file mode 100755
index 0000000..960868c
--- /dev/null
+++ b/mobile_src/Systeminfo/SysteminfoPropertyInfo.h
@@ -0,0 +1,404 @@
+//
+// 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 WRTPLUGINS_API_PROPERTY_INFO_H_
+#define WRTPLUGINS_API_PROPERTY_INFO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+#include <string>
+#include <dpl/shared_ptr.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+enum SystemInfosDeviceOrientationStatus {
+ PORTRAIT_PRIMARY = 0,
+ PORTRAIT_SECONDARY = 1,
+ LANDSCAPE_PRIMARY = 2,
+ LANDSCAPE_SECONDARY = 3
+};
+
+struct DeviceCapabilitiesProperties
+{
+ bool bluetooth;
+ bool nfc;
+ bool nfcReservedPush;
+ unsigned short multiTouchCount;
+ bool inputKeyboard;
+ bool inputKeyboardLayout;
+ bool wifi;
+ bool wifiDirect;
+ bool opengles;
+ std::string openglestextureFormat;
+ bool openglesVersion1_1;
+ bool openglesVersion2_0;
+ bool fmRadio;
+ std::string platformVersion;
+ std::string platformName;
+ std::string webApiVersion;
+ std::string nativeApiVersion;
+ bool camera;
+ bool cameraFront;
+ bool cameraFrontFlash;
+ bool cameraBack;
+ bool cameraBackFlash;
+ bool location;
+ bool locationGps;
+ bool locationWps;
+ bool microphone;
+ bool usbHost;
+ bool usbAccessory;
+ bool screenOutputRca;
+ bool screenOutputHdmi;
+ std::string platformCoreCpuArch;
+ std::string platformCoreFpuArch;
+ bool sipVoip;
+ std::string duid;
+ bool speechRecognition;
+ bool speechSynthesis;
+ bool accelerometer;
+ bool accelerometerWakeup;
+ bool barometer;
+ bool barometerWakeup;
+ bool gyroscope;
+ bool gyroscopeWakeup;
+ bool magnetometer;
+ bool magnetometerWakeup;
+ bool photometer;
+ bool photometerWakeup;
+ bool proximity;
+ bool proximityWakeup;
+ bool tiltmeter;
+ bool tiltmeterWakeup;
+ bool dataEncryption;
+ bool graphicsAcceleration;
+ bool push;
+ bool telephony;
+ bool telephonyMms;
+ bool telephonySms;
+ bool screenSizeNormal;
+ bool screenSize480_800;
+ bool screenSize720_1280;
+ bool autoRotation;
+ bool shellAppWidget;
+ bool visionImageRecognition;
+ bool visionQrcodeGeneration;
+ bool visionQrcodeRecognition;
+ bool visionFaceRecognition;
+ bool secureElement;
+ bool nativeOspCompatible;
+ std::string profile;
+
+ DeviceCapabilitiesProperties() :
+ bluetooth(false),
+ nfc(false),
+ nfcReservedPush(false),
+ multiTouchCount(0),
+ inputKeyboard(false),
+ inputKeyboardLayout(false),
+ wifi(false),
+ wifiDirect(false),
+ opengles(false),
+ openglestextureFormat(""),
+ openglesVersion1_1(false),
+ openglesVersion2_0(false),
+ fmRadio(false),
+ platformVersion(""),
+ platformName(""),
+ webApiVersion(""),
+ nativeApiVersion(""),
+ camera(false),
+ cameraFront(false),
+ cameraFrontFlash(false),
+ cameraBack(false),
+ cameraBackFlash(false),
+ location(false),
+ locationGps(false),
+ locationWps(false),
+ microphone(false),
+ usbHost(false),
+ usbAccessory(false),
+ screenOutputRca(false),
+ screenOutputHdmi(false),
+ platformCoreCpuArch(""),
+ platformCoreFpuArch(""),
+ sipVoip(false),
+ duid(""),
+ speechRecognition(false),
+ speechSynthesis(false),
+ accelerometer(false),
+ accelerometerWakeup(false),
+ barometer(false),
+ barometerWakeup(false),
+ gyroscope(false),
+ gyroscopeWakeup(false),
+ magnetometer(false),
+ magnetometerWakeup(false),
+ photometer(false),
+ photometerWakeup(false),
+ proximity(false),
+ proximityWakeup(false),
+ tiltmeter(false),
+ tiltmeterWakeup(false),
+ dataEncryption(false),
+ graphicsAcceleration(false),
+ push(false),
+ telephony(false),
+ telephonyMms(false),
+ telephonySms(false),
+ screenSizeNormal(false),
+ screenSize480_800(false),
+ screenSize720_1280(false),
+ autoRotation(false),
+ shellAppWidget(false),
+ visionImageRecognition(false),
+ visionQrcodeGeneration(false),
+ visionQrcodeRecognition(false),
+ visionFaceRecognition(false),
+ secureElement(false),
+ nativeOspCompatible(false),
+ profile("")
+ {
+ }
+};
+
+struct BatteryProperties
+{
+ double level;
+ bool isCharging;
+
+ BatteryProperties() :
+ level(0.0),
+ isCharging(false)
+ {
+ }
+};
+
+struct CpuProperties
+{
+ double load;
+
+ CpuProperties() :
+ load(0.0)
+ {
+ }
+};
+
+struct StorageUnitProperties
+{
+ std::string type;
+ unsigned long long capacity;
+ unsigned long long availableCapacity;
+ bool isRemoveable;
+ bool isRemovable;
+
+ StorageUnitProperties():
+ type("UNKNOWN"),
+ capacity(0),
+ availableCapacity(0),
+ isRemoveable(false),
+ isRemovable(false)
+ {
+ }
+};
+
+struct StorageProperties
+{
+ StorageUnitProperties units[2];
+ unsigned long cnt;
+
+ StorageProperties():
+ cnt(0)
+ {
+ }
+};
+
+
+struct DisplayProperties
+{
+ unsigned long resolutionWidth;
+ unsigned long resolutionHeight;
+ unsigned long dotsPerInchWidth;
+ unsigned long dotsPerInchHeight;
+ double physicalWidth;
+ double physicalHeight;
+ double brightness;
+
+ DisplayProperties() :
+ resolutionWidth(0),
+ resolutionHeight(0),
+ dotsPerInchWidth(0),
+ dotsPerInchHeight(0),
+ physicalWidth(0.0),
+ physicalHeight(0.0),
+ brightness(0.0)
+ {
+ }
+};
+
+struct WifiNetworkProperties
+{
+ std::string status;
+ std::string ssid;
+ std::string ipAddress;
+ std::string ipv6Address;
+ double signalStrength;
+
+ WifiNetworkProperties() :
+ status(""),
+ ssid(""),
+ ipAddress(""),
+ ipv6Address(""),
+ signalStrength(0.0)
+ {
+ }
+};
+
+struct NetworkProperties
+{
+ std::string networkType;
+
+ NetworkProperties() :
+ networkType("UNKNOWN")
+ {
+ }
+};
+
+struct CellularNetworkProperties
+{
+ std::string status;
+ std::string apn;
+ std::string ipAddress;
+ std::string ipv6Address;
+ unsigned short mcc;
+ unsigned short mnc;
+ unsigned short cellId;
+ unsigned short lac;
+ bool isRoaming;
+ bool isFlightMode;
+ std::string imei;
+
+ CellularNetworkProperties() :
+ status(""),
+ apn(""),
+ ipAddress(""),
+ ipv6Address(""),
+ mcc(0),
+ mnc(0),
+ cellId(0),
+ lac(0),
+ isRoaming(false),
+ isFlightMode(false),
+ imei("")
+ {
+ }
+};
+
+struct SIMProperties
+{
+ std::string state;
+ std::string operatorName;
+ std::string msisdn;
+ std::string iccid;
+ unsigned short mcc;
+ unsigned short mnc;
+ std::string msin;
+ std::string spn;
+
+ SIMProperties() :
+ state("UNKNOWN"),
+ operatorName(""),
+ msisdn(""),
+ iccid(""),
+ mcc(0),
+ mnc(0),
+ msin(""),
+ spn("")
+ {
+ }
+};
+
+struct DeviceOrientationProperties
+{
+ std::string status;
+ bool isAutoRotation;
+
+ DeviceOrientationProperties() :
+ status(""),
+ isAutoRotation(false)
+ {
+ }
+};
+
+struct BuildProperties
+{
+ std::string model;
+ std::string manufacturer;
+ std::string buildVersion;
+
+ BuildProperties() :
+ model(""),
+ manufacturer(""),
+ buildVersion("")
+ {
+ }
+};
+
+struct LocaleProperties
+{
+ std::string language;
+ std::string country;
+
+ LocaleProperties() :
+ language(""),
+ country("")
+ {
+ }
+};
+
+struct PeripheralProperties
+{
+ bool isVideoOutputOn;
+
+ PeripheralProperties() :
+ isVideoOutputOn(false)
+ {
+ }
+};
+
+typedef DPL::SharedPtr<DeviceCapabilitiesProperties> DeviceCapabilitiesPropertiesPtr;
+typedef DPL::SharedPtr<BatteryProperties> BatteryPropertiesPtr;
+typedef DPL::SharedPtr<CpuProperties> CpuPropertiesPtr;
+typedef DPL::SharedPtr<StorageUnitProperties> StorageUnitPropertiesPtr;
+typedef DPL::SharedPtr<StorageProperties> StoragePropertiesPtr;
+typedef DPL::SharedPtr<DisplayProperties> DisplayPropertiesPtr;
+typedef DPL::SharedPtr<WifiNetworkProperties> WifiNetworkPropertiesPtr;
+typedef DPL::SharedPtr<NetworkProperties> NetworkPropertiesPtr;
+typedef DPL::SharedPtr<CellularNetworkProperties> CellularNetworkPropertiesPtr;
+typedef DPL::SharedPtr<SIMProperties> SIMPropertiesPtr;
+typedef DPL::SharedPtr<DeviceOrientationProperties> DeviceOrientationPropertiesPtr;
+typedef DPL::SharedPtr<BuildProperties> BuildPropertiesPtr;
+typedef DPL::SharedPtr<LocaleProperties> LocalePropertiesPtr;
+typedef DPL::SharedPtr<PeripheralProperties> PeripheralPropertiesPtr;
+
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/config.xml b/mobile_src/Systeminfo/config.xml
new file mode 100755
index 0000000..2956c4e
--- /dev/null
+++ b/mobile_src/Systeminfo/config.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+ <library-name>libwrt-plugins-tizen-systeminfo.so</library-name>
+ <feature-install-uri>systeminfo.install.uri</feature-install-uri>
+
+ <api-feature>
+ <name>http://tizen.org/privilege/systeminfo</name>
+ <device-capability>system.info</device-capability>
+ <device-capability>systemmanager.info</device-capability>
+ </api-feature>
+
+ <api-feature>
+ <name>http://tizen.org/privilege/system</name>
+ <device-capability>system.info</device-capability>
+ </api-feature>
+
+ <api-feature>
+ <name>http://tizen.org/privilege/systemmanager</name>
+ <device-capability>systemmanager.info</device-capability>
+ </api-feature>
+</plugin-properties>
+
diff --git a/mobile_src/Systeminfo/plugin_config.cpp b/mobile_src/Systeminfo/plugin_config.cpp
new file mode 100755
index 0000000..a444bf8
--- /dev/null
+++ b/mobile_src/Systeminfo/plugin_config.cpp
@@ -0,0 +1,114 @@
+//
+// 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 <map>
+#include <utility>
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <Commons/Exception.h>
+#include "plugin_config.h"
+
+#define SYSTEMINFO_FEATURE_API_MASTER "http://tizen.org/privilege/systeminfo"
+#define SYSTEMINFO_FEATURE_API_SYSTEMINFO "http://tizen.org/privilege/system"
+#define SYSTEMINFO_FEATURE_API_SYSTEMMANAGER "http://tizen.org/privilege/systemmanager"
+
+#define SYSTEMINFO_DEVICE_CAP_SYSTEMINFO "system.info"
+#define SYSTEMINFO_DEVICE_CAP_SYSTEMMANAGER "system.manager"
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+#pragma GCC visibility push(default)
+
+const char* SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES = "getCapabilities";
+const char* SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE = "getPropertyPartnerValue";
+const char* SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE = "getPropertySimValue";
+
+static WrtDeviceApis::Commons::FunctionMapping createSysteminfoFunctions();
+
+static WrtDeviceApis::Commons::FunctionMapping SysteminfoFunctions =
+ createSysteminfoFunctions();
+
+DEFINE_FUNCTION_GETTER(Systeminfo, SysteminfoFunctions);
+
+#pragma GCC visibility pop
+
+static WrtDeviceApis::Commons::FunctionMapping createSysteminfoFunctions()
+{
+ /**
+ * Device capabilities
+ */
+ using namespace WrtDeviceApis::Commons;
+
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_SYSTEMINFO, SYSTEMINFO_DEVICE_CAP_SYSTEMINFO);
+ ACE_CREATE_DEVICE_CAP(DEVICE_CAP_SYSTEMMANAGER, SYSTEMINFO_DEVICE_CAP_SYSTEMMANAGER);
+
+ ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
+
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_SYSTEMINFO);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SYSTEMINFO, DEVICE_CAP_SYSTEMINFO);
+
+ ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_SYSTEMMANAGER);
+ ACE_ADD_DEVICE_CAP(DEVICE_LIST_SYSTEMMANAGER, DEVICE_CAP_SYSTEMMANAGER);
+
+ /**
+ * Api Features
+ */
+ ACE_CREATE_FEATURE(FEATURE_MASTER, SYSTEMINFO_FEATURE_API_MASTER);
+ ACE_CREATE_FEATURE(FEATURE_SYSTEMINFO, SYSTEMINFO_FEATURE_API_SYSTEMINFO);
+ ACE_CREATE_FEATURE(FEATURE_SYSTEMMANAGER, SYSTEMINFO_FEATURE_API_SYSTEMMANAGER);
+
+ ACE_CREATE_FEATURE_LIST(SYSTEMINFO_FEATURES_SYSTEMINFO);
+ ACE_ADD_API_FEATURE(SYSTEMINFO_FEATURES_SYSTEMINFO, FEATURE_MASTER);
+ ACE_ADD_API_FEATURE(SYSTEMINFO_FEATURES_SYSTEMINFO, FEATURE_SYSTEMINFO);
+
+ ACE_CREATE_FEATURE_LIST(SYSTEMINFO_FEATURES_SYSTEMMANAGER);
+ ACE_ADD_API_FEATURE(SYSTEMINFO_FEATURES_SYSTEMMANAGER, FEATURE_MASTER);
+ ACE_ADD_API_FEATURE(SYSTEMINFO_FEATURES_SYSTEMMANAGER, FEATURE_SYSTEMMANAGER);
+
+ /**
+ * Functions
+ */
+ FunctionMapping SysteminfoFunctions;
+
+ AceFunction getCapabilitiesFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_GET_CAPABILITIES,
+ SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES,
+ SYSTEMINFO_FEATURES_SYSTEMINFO,
+ DEVICE_LIST_SYSTEMINFO);
+ SysteminfoFunctions.insert(std::make_pair(SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES, getCapabilitiesFunc));
+
+ AceFunction getPropertyPartnerValueFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_GET_PROPERTY_PARTNER_VALUE,
+ SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE,
+ SYSTEMINFO_FEATURES_SYSTEMMANAGER,
+ DEVICE_LIST_SYSTEMINFO);
+ SysteminfoFunctions.insert(std::make_pair(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE, getPropertyPartnerValueFunc));
+
+ AceFunction getPropertySimValueFunc = ACE_CREATE_FUNCTION(
+ FUNCTION_GET_PROPERTY_SIM_VALUE,
+ SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE,
+ SYSTEMINFO_FEATURES_SYSTEMINFO,
+ DEVICE_LIST_SYSTEMINFO);
+ SysteminfoFunctions.insert(std::make_pair(SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE, getPropertySimValueFunc));
+
+ return SysteminfoFunctions;
+}
+}
+}
+
+#undef SYSTEMINFO_FEATURE_API
diff --git a/mobile_src/Systeminfo/plugin_config.h b/mobile_src/Systeminfo/plugin_config.h
new file mode 100755
index 0000000..bc0884d
--- /dev/null
+++ b/mobile_src/Systeminfo/plugin_config.h
@@ -0,0 +1,39 @@
+//
+// 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 _SYSTEMINFO_PLUGIN_CONFIG_H_
+#define _SYSTEMINFO_PLUGIN_CONFIG_H_
+
+#include <Commons/FunctionDeclaration.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+extern const char* SYSTEMINFO_FUNCTION_API_GET_CAPABILITIES;
+extern const char* SYSTEMINFO_FUNCTION_API_GET_PROPERTY_PARTNER_VALUE;
+extern const char* SYSTEMINFO_FUNCTION_API_GET_PROPERTY_SIM_VALUE;
+
+DECLARE_FUNCTION_GETTER(Systeminfo);
+
+#define SYSTEMINFO_CHECK_ACCESS(functionName) \
+ aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+ getSysteminfoFunctionData, \
+ functionName)
+}
+}
+
+#endif
diff --git a/mobile_src/Systeminfo/plugin_initializer.cpp b/mobile_src/Systeminfo/plugin_initializer.cpp
new file mode 100644
index 0000000..3c3465e
--- /dev/null
+++ b/mobile_src/Systeminfo/plugin_initializer.cpp
@@ -0,0 +1,87 @@
+//
+// 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 <TimeTracer.h>
+#include "SysteminfoAsyncCallbackManager.h"
+#include "SysteminfoListenerManager.h"
+#include "JSSysteminfo.h"
+#include <Logger.h>
+
+namespace DeviceAPI {
+namespace Systeminfo {
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
+
+void on_widget_start_callback(int widgetId)
+{
+ LoggerD("[Tizen\\Systeminfo ] on_widget_start_callback (" << widgetId << ")");
+ TIME_TRACER_INIT();
+ Try
+ {
+ WrtAccessSingleton::Instance().initialize(widgetId);
+ }
+ Catch(Commons::Exception)
+ {
+ LoggerE("WrtAccess initialization failed");
+ }
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+ LoggerD("[Tizen\\Systeminfo ] on_widget_stop_callback (" << widgetId << ")");
+ TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE,"SystemInfo");
+ TIME_TRACER_RELEASE();
+ Try
+ {
+ WrtAccessSingleton::Instance().deinitialize(widgetId);
+ }
+ Catch(Commons::Exception)
+ {
+ LoggerE("WrtAccess deinitialization failed");
+ }
+}
+
+void on_frame_load_callback(const void * context)
+{
+ LoggerD("[Tizen\\systeminfo] on_frame_load_callback (" << context << ")");
+}
+
+void on_frame_unload_callback(const void * context)
+{
+ LoggerD("[Tizen\\systeminfo] on_frame_unload_callback (" << context << ")");
+
+ DeviceAPI::Systeminfo::SysteminfoAsyncCallbackManagerSingleton::Instance().unregisterContext(static_cast<JSContextRef>(context));
+ DeviceAPI::Systeminfo::SysteminfoListenerManagerSingleton::Instance().unregisterContext(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, "systeminfo", (js_class_template_getter)DeviceAPI::Systeminfo::JSSysteminfo::getClassRef, NULL)
+PLUGIN_CLASS_MAP_END
+
+} // Systeminfo
+} // DeviceAPI
+