Remove Profile Build Dependency: Do it at runtime 26/97426/11
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 14 Nov 2016 07:03:51 +0000 (16:03 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 23 Jan 2017 08:52:49 +0000 (17:52 +0900)
- This is for Tizen 4.0.

  : Tizen 4.0 Configurability and Build Blocks require
  to remove all profile-depending build options in spec files.
  (No More profile macros!)

  : Note that _WEARABLE and _MOBILE were completely useless because
  no code was using it.
  : _TV was used only once at daemon/ServiceManager.cpp, which
  is replaced by runtime profile probing.

  : INTERNAL_ACL has been always 1 in Tizen.org Public and INTERNAL_ACL
  has been 0 only in Tizen-TV Product. So, I've changed the condition
  more clearly.

  : daemon/discovery_provider/WifiDirectDiscoveryProvider.cpp has
  a ifdef condition that is always FALSE in public.

- Merge conflicts resolved.

Change-Id: I4ce56ef62d81e542067abc2847c674a4bdd61f7f
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
daemon/CMakeLists.txt
daemon/ServiceManager.cpp
daemon/Util.cpp
daemon/Util.h
daemon/discovery_provider/WifiDirectDiscoveryProvider.cpp
lib/CMakeLists.txt
packaging/d2d-conv-manager.spec

index 06711a43f66ca8b1ba3c8e68bb76c90d39212aa8..9b7f96b232d33408b508245cdc6e9813b6ce47c9 100755 (executable)
@@ -14,26 +14,11 @@ FILE(GLOB DAEMON_SRCS ${DAEMON_SRCS} discovery_provider/smartview/*.cpp)
 FILE(GLOB DAEMON_SRCS ${DAEMON_SRCS} ../msf_tizen_client/src/*.cpp)
 
 SET(provider_deps "glib-2.0 dlog json-glib-1.0 jsoncpp iotcon capi-appfw-app-manager vconf capi-network-bluetooth capi-appfw-application bundle capi-network-connection cynara-creds-gdbus cynara-client cynara-session capi-appfw-package-manager sqlite3 syspopup-caller")
-SET(provider_deps "${provider_deps} openssl libwebsockets libcurl nsd-dns-sd")
-#SET(provider_deps "${provider_deps} capi-network-wifi-direct")
-
-# Wearable profile
-IF("${PROFILE}" STREQUAL "wearable")
-       ADD_DEFINITIONS("-D_WEARABLE_")
-ENDIF("${PROFILE}" STREQUAL "wearable")
-
-# Mobile profile
-IF("${PROFILE}" STREQUAL "mobile")
-       ADD_DEFINITIONS("-D_MOBILE_")
-ENDIF("${PROFILE}" STREQUAL "mobile")
-
-# TV profile
-IF("${PROFILE}" STREQUAL "tv")
-       ADD_DEFINITIONS("-D_TV_")
-    IF(${D2D_INTERNAL_ACL} EQUAL 0)
-        SET(provider_deps "${provider_deps} capi-register-device")
-    ENDIF(${D2D_INTERNAL_ACL} EQUAL 0)
-ENDIF("${PROFILE}" STREQUAL "tv")
+SET(provider_deps "${provider_deps} openssl libwebsockets libcurl nsd-dns-sd capi-system-info")
+
+IF(${D2D_INTERNAL_ACL} EQUAL 0)
+    SET(provider_deps "${provider_deps} capi-register-device")
+ENDIF(${D2D_INTERNAL_ACL} EQUAL 0)
 
 IF(${D2D_INTERNAL_ACL} EQUAL 1)
     ADD_DEFINITIONS("-D_D2D_INTERNAL_ACL_")
index 2ebac3b220b4555fbcda94faf33482866815aea2..4a386c7950d393dde4c7a2c0e93f009302fa9969 100755 (executable)
@@ -316,19 +316,21 @@ static iotcon_representation_h _get_d2d_service_representation(conv::ServiceMana
        _D("device name : %s", deviceName);
        iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_ID, deviceId);
        iotcon_attributes_add_str(attributes, CONV_JSON_DEVICE_NAME, deviceName);
-#if defined(_TV_)
-       _D("device type : TV");
-       string deviceTypeStr(CONV_DEVICE_TYPE_TV);
-#elif defined(_MOBILE_)
-       _D("device type : MOBILE");
-       string deviceTypeStr(CONV_DEVICE_TYPE_MOBILE);
-#elif defined(_WEARABLE_)
-       _D("device type : WEARABLE");
-       string deviceTypeStr(CONV_DEVICE_TYPE_WEARABLE);
-#else
-       _D("device type : UNKNOWN");
-       string deviceTypeStr(CONV_DEVICE_TYPE_UNKNOWN);
-#endif
+
+       string deviceTypeStr;
+       if (conv::util::getTizenProfile() == conv::util::TIZEN_PROFILE_TV) {
+               _D("device type : TV");
+               deviceTypeStr = string(CONV_DEVICE_TYPE_TV);
+       } else if (conv::util::getTizenProfile() == conv::util::TIZEN_PROFILE_MOBILE) {
+               _D("device type : MOBILE");
+               deviceTypeStr = string(CONV_DEVICE_TYPE_MOBILE);
+       } else if (conv::util::getTizenProfile() == conv::util::TIZEN_PROFILE_WEARABLE) {
+               _D("device type : WEARABLE");
+               deviceTypeStr = string(CONV_DEVICE_TYPE_WEARABLE);
+       } else {
+               _D("device type : UNKNOWN");
+               deviceTypeStr = string(CONV_DEVICE_TYPE_UNKNOWN);
+       }
        char* deviceType = new char[deviceTypeStr.size() + 1];
 
        memset(deviceType, 0, deviceTypeStr.size() + 1);
index 597ce5744f2b289bfff352e46a9d7d2ed6f7247d..330eb0299b0c02cb444784f94eef5a4dca94ffdc 100755 (executable)
 #include <glib.h>
 #include <pthread.h>
 #include "Service.h"
+#include <system_info.h>
 
 #define FRONT_PROTOCOL_SIZE 7 // coap://
 
 using namespace std;
 
+conv::util::tizen_profile_t conv::util::getTizenProfile()
+{
+       static conv::util::tizen_profile_t profile = conv::util::TIZEN_PROFILE_UNKNOWN;
+       if (__builtin_expect(profile != conv::util::TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       char *profileName;
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+       case 'm':
+       case 'M':
+               profile = conv::util::TIZEN_PROFILE_MOBILE;
+               break;
+       case 'w':
+       case 'W':
+               profile = conv::util::TIZEN_PROFILE_WEARABLE;
+               break;
+       case 't':
+       case 'T':
+               profile = conv::util::TIZEN_PROFILE_TV;
+               break;
+       case 'i':
+       case 'I':
+               profile = conv::util::TIZEN_PROFILE_IVI;
+               break;
+       default: // common or unknown ==> ALL ARE COMMON.
+               profile = conv::util::TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+
 std::string conv::util::getDeviceType()
 {
-#if defined(_TV_)
-       return CONV_DEVICE_TYPE_TV;
-#elif defined(_MOBILE_)
-       return CONV_DEVICE_TYPE_MOBILE;
-#elif defined(_WEARABLE_)
-       return CONV_DEVICE_TYPE_WEARABLE;
-#else
-       return CONV_DEVICE_TYPE_UNKNOWN;
-#endif
+       switch (conv::util::getTizenProfile()) {
+       case conv::util::TIZEN_PROFILE_TV:
+               return CONV_DEVICE_TYPE_TV;
+       case conv::util::TIZEN_PROFILE_MOBILE:
+               return CONV_DEVICE_TYPE_MOBILE;
+       case conv::util::TIZEN_PROFILE_WEARABLE:
+               return CONV_DEVICE_TYPE_WEARABLE;
+       default:
+               return CONV_DEVICE_TYPE_UNKNOWN;
+       }
 }
 
 std::string conv::util::getBtMacAddress()
@@ -70,10 +105,15 @@ std::string conv::util::getBtMacAddress()
 std::string conv::util::getDeviceName()
 {
        std::string __deviceName;
-#if defined(_TV_) || defined(TIZEN_PROFILE_TV) || defined(TIZEN_TV) || defined(TIZEN_PRODUCT_TV)
+#if defined(TIZEN_PROFILE_TV) || defined(TIZEN_TV) || defined(TIZEN_PRODUCT_TV)
        char* deviceName = vconf_get_str("db/menu/network/devicename/tv_name");
 #else
-       char* deviceName = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
+       char* deviceName;
+
+       if (conv::util::getTizenProfile() == conv::util::TIZEN_PROFILE_TV)
+               deviceName  = vconf_get_str("db/menu/network/devicename/tv_name");
+       else
+               deviceName = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
 #endif
        if (deviceName == NULL) {
                __deviceName = "Tizen";
@@ -175,12 +215,16 @@ std::string conv::util::getDeviceId()
        if(__deviceId.empty()) {
                __deviceId = Service::getUniqueId("127.0.0.1:8001");
 
-               if(__deviceId.empty())
-#if defined(_TV_) || defined(TIZEN_PROFILE_TV) || defined(TIZEN_TV) || defined(TIZEN_PRODUCT_TV)
+               if(__deviceId.empty()) {
+#if defined(TIZEN_PROFILE_TV) || defined(TIZEN_TV) || defined(TIZEN_PRODUCT_TV)
                        __deviceId = getBtMacAddress();
 #else
-                       __deviceId = getP2pMacAddress();
+                       if (conv::util::getTizenProfile() == conv::util::TIZEN_PROFILE_TV)
+                               __deviceId = getBtMacAddress();
+                       else
+                               __deviceId = getP2pMacAddress();
 #endif
+               }
        }
        _D("device id : %s", __deviceId.c_str());
 
@@ -278,4 +322,4 @@ std::string conv::util::getIpAddress(std::string hostAddress)
        std::string sub = hostAddress.substr(FRONT_PROTOCOL_SIZE, pos - FRONT_PROTOCOL_SIZE);
 
        return sub;
-}
\ No newline at end of file
+}
index 8aff3628e7e81e85af9a2314399116109bcfa018..7765d0356c09c7f676c0e177748b75f8a67deb0e 100644 (file)
@@ -35,6 +35,16 @@ namespace conv {
                void miscStopTimer(int timer);
                bool getPeerMac(const std::string &remoteIP, const int remotePort, char *buf);
                std::string getIpAddress(std::string hostAddress);
+
+               typedef enum {
+                       TIZEN_PROFILE_UNKNOWN = 0,
+                       TIZEN_PROFILE_MOBILE = 0x1,
+                       TIZEN_PROFILE_WEARABLE = 0x2,
+                       TIZEN_PROFILE_TV = 0x4,
+                       TIZEN_PROFILE_IVI = 0x8,
+                       TIZEN_PROFILE_COMMON = 0x10,
+               } tizen_profile_t;
+               extern tizen_profile_t getTizenProfile();
        }
 }
 #endif
index 9816c200106ee14ccc9eacdcd214ac02f258db7c..699c310425e393fa67786cbd57b8c7582da9d32b 100755 (executable)
@@ -266,6 +266,7 @@ int init_wfd_client(void* disc_provider)
        ret = wifi_direct_set_connection_state_changed_cb(_cb_connection, (void*)NULL);
        _D("wifi_direct_set_connection_state_changed_cb() result=[%d]", ret);
 
+// CAUTION: TIZEN_TV and TIZEN_TV_PRODUCT has been deadcode in Tizen.org
 #if defined(TIZEN_TV) && defined(TIZEN_PRODUCT_TV) && defined(ENABLE_EXTRA_INFO)
        ret = wifi_direct_set_peer_info_connection_state_changed_cb(_cb_peer_info_connection, (void*)NULL);
        _D("wifi_direct_set_peer_info_connection_state_changed_cb() result=[%d]", ret);
index fd6176bc36de07c9cd871c94f2fa7a7f167762aa..835a71e7819186a0b26ec8b3dcf57399d6470e3d 100644 (file)
@@ -5,16 +5,6 @@ FILE(GLOB CLIENT_SRCS *.cpp)
 
 SET(client_depends "gio-2.0 dlog json-glib-1.0 capi-appfw-application bundle capi-system-info")
 
-IF("${PROFILE}" STREQUAL "mobile")
-ADD_DEFINITIONS("-D_MOBILE_")
-#SET(client_depends "${client_depends} security-server")
-ENDIF("${PROFILE}" STREQUAL "mobile")
-
-IF("${PROFILE}" STREQUAL "tv")
-ADD_DEFINITIONS("-D_TV_")
-SET(client_depends "${client_depends}")
-ENDIF("${PROFILE}" STREQUAL "tv")
-
 pkg_check_modules(client_pkgs REQUIRED ${client_depends})
 INCLUDE_DIRECTORIES(${client_pkgs_INCLUDE_DIRS})
 LINK_DIRECTORIES(${client_pkgs_LIBRARY_DIRS})
index 061d71ca51492ed04871075a617abb12428da2c5..05ee1a03db37217002f5282b0e63819600a92e0c 100755 (executable)
@@ -10,9 +10,6 @@ Source2:    %{name}.conf
 Source1001:    %{name}.manifest
 Source1002:    lib%{name}.manifest
 
-%define BUILD_PROFILE %{?profile}%{!?profile:%{?tizen_profile_name}}
-%define INTERNAL_ACL %{?TIZEN_PROFILE_TV:0}%{!?TIZEN_PROFILE_TV:1}
-
 BuildRequires: cmake
 BuildRequires: pkgconfig(gio-2.0)
 BuildRequires: pkgconfig(glib-2.0)
@@ -45,10 +42,11 @@ BuildRequires: openssl-devel
 BuildRequires: curl
 BuildRequires: libcurl-devel
 
-%if "%{?BUILD_PROFILE}" == "tv"
-%if %{?INTERNAL_ACL} == 0
+%if "%{?TIZEN_PRODUCT_TV}" == "1"
 BuildRequires: pkgconfig(capi-register-device)
-%endif
+%define INTERNAL_ACL 0
+%else
+%define INTERNAL_ACL 1
 %endif
 
 %define _userdatadir /opt/usr/data/d2d-conv-manager
@@ -82,7 +80,7 @@ D2D Convergence Manager development kit.
 
 %build
 MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DBIN_INSTALL_DIR:PATH=%{_bindir} -DPROFILE=%{?BUILD_PROFILE} -DD2D_INTERNAL_ACL=%{?INTERNAL_ACL}
+%cmake . -DMAJORVER=${MAJORVER} -DFULLVER=%{version} -DBIN_INSTALL_DIR:PATH=%{_bindir} -DD2D_INTERNAL_ACL=%{?INTERNAL_ACL}
 
 
 %install