Remove Profile Build Dependency: do it at runtime 94/103394/2
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 8 Dec 2016 08:03:58 +0000 (17:03 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 29 Dec 2016 07:47:33 +0000 (16:47 +0900)
- This is for Tizen 4.0.

- Please later consider removing TM1 conditions (like next year? :D )

Change-Id: Ia27027290910ecf9abe97b5c2034646a95a12f78
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
CMakeLists.txt
include/mobileap.h
packaging/mobileap-agent.spec
src/mobileap_network.c
src/mobileap_notification.c

index 3be211e..624ec2b 100755 (executable)
@@ -30,7 +30,8 @@ INCLUDE_DIRECTORIES(${INCLUDE_DIR} ${CMAKE_SOURCE_DIR})
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED gio-2.0 gio-unix-2.0 dbus-1 dlog  deviced vconf notification capi-network-connection capi-network-bluetooth syspopup-caller
-               appcore-common capi-network-wifi capi-network-wifi-direct alarm-service appsvc libcrypto key-manager libtzplatform-config dpm)
+               appcore-common capi-network-wifi capi-network-wifi-direct alarm-service appsvc libcrypto key-manager libtzplatform-config dpm
+               capi-system-info)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 258b66a..c934e55 100644 (file)
@@ -202,6 +202,18 @@ typedef struct {
        mobile_ap_station_info_t sta_info[MOBILE_AP_MAX_CONNECTED_STA];
 } mobile_ap_device_info_t;
 
+
+typedef enum {
+       _PROFILE_UNKNOWN = 0,
+       _PROFILE_MOBILE = 0x1,
+       _PROFILE_WEARABLE = 0x2,
+       _PROFILE_TV = 0x4,
+       _PROFILE_IVI = 0x8,
+       _PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+extern tizen_profile_t _get_tizen_profile();
+#define TIZEN_PROFILE_TV (_get_tizen_profile() == _PROFILE_TV)
+
 #ifdef __cplusplus
 }
 #endif
index a9d4797..7d0bfc9 100644 (file)
@@ -22,6 +22,7 @@ BuildRequires:        pkgconfig(bundle)
 BuildRequires: pkgconfig(appcore-common)
 BuildRequires: pkgconfig(capi-network-wifi-direct)
 BuildRequires: pkgconfig(capi-network-wifi)
+BuildRequires:  pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(alarm-service)
 BuildRequires: pkgconfig(appsvc)
 BuildRequires: pkgconfig(libcrypto)
@@ -47,9 +48,6 @@ export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
 %cmake -DCMAKE_BUILD_TYPE="" \
        -DTIZEN_FEATURE_MULTICAST=1 \
-%if "%{?profile}" == "tv"
-       -DTIZEN_PROFILE_TV=1 \
-%endif
 %if "%{?tizen_target_name}" == "TM1"
        -DTIZEN_FEATURE_WLAN_BOARD_SPRD=1 \
 %endif
index 2fc6c6c..473ae00 100644 (file)
@@ -89,11 +89,13 @@ static mobile_ap_error_code_e __get_conn_error(int conn_error)
                err = MOBILE_AP_ERROR_ALREADY_ENABLED;
                break;
 
-#ifndef TIZEN_PROFILE_TV
        case CONNECTION_ERROR_PERMISSION_DENIED:
-               err = MOBILE_AP_ERROR_PERMISSION_DENIED;
-               break;
-#endif
+               if (!TIZEN_PROFILE_TV) {
+                       err = MOBILE_AP_ERROR_PERMISSION_DENIED;
+                       break;
+               } else {
+                       goto _default_;
+               }
 
        case CONNECTION_ERROR_DHCP_FAILED:
                err = MOBILE_AP_ERROR_DHCP;
@@ -102,7 +104,7 @@ static mobile_ap_error_code_e __get_conn_error(int conn_error)
        case CONNECTION_ERROR_NOW_IN_PROGRESS:
                err = MOBILE_AP_ERROR_IN_PROGRESS;
                break;
-
+_default_:
        default:
                ERR("Not defined error : %d\n", conn_error);
                err = MOBILE_AP_ERROR_INTERNAL;
@@ -1188,3 +1190,37 @@ gboolean _deinit_network(void)
 
        return TRUE;
 }
+
+tizen_profile_t _get_tizen_profile()
+{
+       static tizen_profile_t profile = _PROFILE_UNKNOWN;
+
+       if (__builtin_expect(profile == _PROFILE_UNKNOWN, 0)) {
+               char *profileName;
+
+               system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+               switch (*profileName) {
+                       case 'm':
+                       case 'M':
+                               profile = _PROFILE_MOBILE;
+                               break;
+                       case 'w':
+                       case 'W':
+                               profile = _PROFILE_WEARABLE;
+                               break;
+                       case 't':
+                       case 'T':
+                               profile = _PROFILE_TV;
+                               break;
+                       case 'i':
+                       case 'I':
+                               profile = _PROFILE_IVI;
+                               break;
+                       default: // common or unknown ==> ALL ARE COMMON.
+                               profile = _PROFILE_COMMON;
+               }
+               free(profileName);
+       }
+
+       return profile;
+}
index 906bf05..1a594f3 100644 (file)
@@ -27,9 +27,7 @@
 #include <bundle.h>
 #include <bundle_internal.h>
 #include <syspopup_caller.h>
-#ifndef TIZEN_PROFILE_TV
 #include <appsvc.h>
-#endif
 
 #include "mobileap.h"
 #include "mobileap_softap.h"
@@ -316,9 +314,8 @@ int _create_connected_noti(mobile_ap_type_e type, int count)
        b = bundle_create();
        bundle_add(b, "caller", "notification");
 
-#ifndef TIZEN_PROFILE_TV
-       appsvc_set_pkgname(b, "ug-setting-mobileap-efl");
-#endif
+       if (!TIZEN_PROFILE_TV)
+               appsvc_set_pkgname(b, "ug-setting-mobileap-efl");
 
        ret = notification_set_execute_option(noti,
                        NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, "Launch", NULL, b);