From 0d653684eabd120898b9c8b4524c1d62a0b0c8d7 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Thu, 21 Apr 2016 14:31:05 +0900 Subject: [PATCH] Separate util functions in BasicProvider to the namespace ctx::util Change-Id: I42239d9277ae346dda1a3d4241d392d67c194587 Signed-off-by: Mu-Woong Lee --- CMakeLists.txt | 1 + src/activity/ActivityBase.cpp | 4 ++-- src/call/Call.cpp | 3 ++- src/email/Email.cpp | 3 ++- src/message/Message.cpp | 3 ++- src/shared/BasicProvider.cpp | 8 -------- src/shared/BasicProvider.h | 3 --- src/shared/Util.cpp | 27 +++++++++++++++++++++++++++ src/shared/Util.h | 28 ++++++++++++++++++++++++++++ src/system/Gps.cpp | 3 ++- src/system/Usb.cpp | 3 ++- src/wifi/Wifi.cpp | 3 ++- 12 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 src/shared/Util.cpp create mode 100644 src/shared/Util.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 2865cfa..f776afe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ SET(compile_defs "LOG_TAG=\"CONTEXT\"") # Common Options INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src/shared ) ADD_DEFINITIONS(-O2 -Wall -fPIC -fdata-sections -ffunction-sections -fvisibility=hidden) SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIC -Wl,--as-needed -Wl,--gc-section -Wl,--print-gc-section") diff --git a/src/activity/ActivityBase.cpp b/src/activity/ActivityBase.cpp index 2611aa2..b677b6e 100644 --- a/src/activity/ActivityBase.cpp +++ b/src/activity/ActivityBase.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include +#include #include "ActivityTypes.h" #include "ActivityBase.h" @@ -35,7 +35,7 @@ UserActivityBase::~UserActivityBase() bool UserActivityBase::isSupported() { - return getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); + return util::getSystemInfoBool("tizen.org/feature/sensor.activity_recognition"); } void UserActivityBase::submitTriggerItem() diff --git a/src/call/Call.cpp b/src/call/Call.cpp index 3cc49d6..616914a 100644 --- a/src/call/Call.cpp +++ b/src/call/Call.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Call.h" #define TELEPHONY_NOTI_ID_CNT 8 @@ -50,7 +51,7 @@ SocialStatusCall::~SocialStatusCall() bool SocialStatusCall::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.telephony"); + return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } void SocialStatusCall::submitTriggerItem() diff --git a/src/email/Email.cpp b/src/email/Email.cpp index e16b6d5..b6b9721 100644 --- a/src/email/Email.cpp +++ b/src/email/Email.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "Email.h" using namespace ctx; @@ -32,7 +33,7 @@ SocialStatusEmail::~SocialStatusEmail() bool SocialStatusEmail::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.telephony"); + return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } void SocialStatusEmail::submitTriggerItem() diff --git a/src/message/Message.cpp b/src/message/Message.cpp index 9e8c350..d1873e3 100644 --- a/src/message/Message.cpp +++ b/src/message/Message.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Message.h" #define MAX_ADDR_SIZE 20 @@ -32,7 +33,7 @@ SocialStatusMessage::~SocialStatusMessage() bool SocialStatusMessage::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.telephony"); + return util::getSystemInfoBool("tizen.org/feature/network.telephony"); } void SocialStatusMessage::submitTriggerItem() diff --git a/src/shared/BasicProvider.cpp b/src/shared/BasicProvider.cpp index 95cba6b..28202dd 100644 --- a/src/shared/BasicProvider.cpp +++ b/src/shared/BasicProvider.cpp @@ -89,11 +89,3 @@ int BasicProvider::write(Json &data) { return ERR_NOT_SUPPORTED; } - -bool BasicProvider::getSystemInfoBool(const char *key) -{ - bool supported = false; - int ret = system_info_get_platform_bool(key, &supported); - IF_FAIL_RETURN_TAG(ret == SYSTEM_INFO_ERROR_NONE, false, _E, "system_info_get_platform_bool() failed"); - return supported; -} diff --git a/src/shared/BasicProvider.h b/src/shared/BasicProvider.h index c7a7f5d..84b0838 100644 --- a/src/shared/BasicProvider.h +++ b/src/shared/BasicProvider.h @@ -46,9 +46,6 @@ namespace ctx { virtual int unsubscribe(); virtual int read(); virtual int write(Json &data); - - /* TODO: This function needs to be removed from here */ - static bool getSystemInfoBool(const char *key); }; } diff --git a/src/shared/Util.cpp b/src/shared/Util.cpp new file mode 100644 index 0000000..e25d0db --- /dev/null +++ b/src/shared/Util.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2015 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 +#include +#include "Util.h" + +bool ctx::util::getSystemInfoBool(const char * key) +{ + bool supported = false; + int ret = system_info_get_platform_bool(key, &supported); + IF_FAIL_RETURN_TAG(ret == SYSTEM_INFO_ERROR_NONE, false, _E, "system_info_get_platform_bool() failed"); + return supported; +} diff --git a/src/shared/Util.h b/src/shared/Util.h new file mode 100644 index 0000000..a7c9d74 --- /dev/null +++ b/src/shared/Util.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2015 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 _CONTEXT_UTIL_H_ +#define _CONTEXT_UTIL_H_ + +namespace ctx { +namespace util { + + bool getSystemInfoBool(const char *key); + +} /* namespace util */ +} /* namespace ctx */ + +#endif /* _CONTEXT_UTIL_H_ */ diff --git a/src/system/Gps.cpp b/src/system/Gps.cpp index 9b6d083..fb01f9d 100644 --- a/src/system/Gps.cpp +++ b/src/system/Gps.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Gps.h" using namespace ctx; @@ -47,7 +48,7 @@ DeviceStatusGps::~DeviceStatusGps() bool DeviceStatusGps::isSupported() { - return getSystemInfoBool("tizen.org/feature/location.gps"); + return util::getSystemInfoBool("tizen.org/feature/location.gps"); } void DeviceStatusGps::submitTriggerItem() diff --git a/src/system/Usb.cpp b/src/system/Usb.cpp index c94edf7..935aaeb 100644 --- a/src/system/Usb.cpp +++ b/src/system/Usb.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "Usb.h" using namespace ctx; @@ -29,7 +30,7 @@ DeviceStatusUsb::~DeviceStatusUsb() bool DeviceStatusUsb::isSupported() { - return getSystemInfoBool("tizen.org/feature/usb.host"); + return util::getSystemInfoBool("tizen.org/feature/usb.host"); } void DeviceStatusUsb::submitTriggerItem() diff --git a/src/wifi/Wifi.cpp b/src/wifi/Wifi.cpp index c8a1d02..f5f2b49 100644 --- a/src/wifi/Wifi.cpp +++ b/src/wifi/Wifi.cpp @@ -15,6 +15,7 @@ */ #include +#include #include "Wifi.h" using namespace ctx; @@ -41,7 +42,7 @@ DeviceStatusWifi::~DeviceStatusWifi() bool DeviceStatusWifi::isSupported() { - return getSystemInfoBool("tizen.org/feature/network.wifi"); + return util::getSystemInfoBool("tizen.org/feature/network.wifi"); } void DeviceStatusWifi::submitTriggerItem() -- 2.34.1