Separate util functions in BasicProvider to the namespace ctx::util 90/66790/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 21 Apr 2016 05:31:05 +0000 (14:31 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 21 Apr 2016 05:31:05 +0000 (14:31 +0900)
Change-Id: I42239d9277ae346dda1a3d4241d392d67c194587
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
12 files changed:
CMakeLists.txt
src/activity/ActivityBase.cpp
src/call/Call.cpp
src/email/Email.cpp
src/message/Message.cpp
src/shared/BasicProvider.cpp
src/shared/BasicProvider.h
src/shared/Util.cpp [new file with mode: 0644]
src/shared/Util.h [new file with mode: 0644]
src/system/Gps.cpp
src/system/Usb.cpp
src/wifi/Wifi.cpp

index 2865cfa..f776afe 100644 (file)
@@ -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")
index 2611aa2..b677b6e 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <system_info.h>
+#include <Util.h>
 #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()
index 3cc49d6..616914a 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <Util.h>
 #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()
index e16b6d5..b6b9721 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <email-api-etc.h>
+#include <Util.h>
 #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()
index 9e8c350..d1873e3 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <Util.h>
 #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()
index 95cba6b..28202dd 100644 (file)
@@ -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;
-}
index c7a7f5d..84b0838 100644 (file)
@@ -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 (file)
index 0000000..e25d0db
--- /dev/null
@@ -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 <system_info.h>
+#include <Types.h>
+#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 (file)
index 0000000..a7c9d74
--- /dev/null
@@ -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_ */
index 9b6d083..fb01f9d 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <Util.h>
 #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()
index c94edf7..935aaeb 100644 (file)
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <Util.h>
 #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()
index c8a1d02..f5f2b49 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <SharedVars.h>
+#include <Util.h>
 #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()