- 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)
- It is recommended to distinguish features/profiles at runtime.
unless it incurs too much overhead, which requires you to
create multiple binaries and subpackages.
ps. There was no code using TIZEN_WEARABLE/TIZEN_MOBILE
and there was only one effective code block for TIZEN_TV.
ps2. I really doubt whether you need capi-appfw-application
in this package.
Change-Id: Ie70acdf66e5cde1ca4932d3e30bb6f8e35a4e64f
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
SET(dependents "dlog vconf capi-base-common capi-system-info glib-2.0 gio-2.0 gthread-2.0 ")
SET(pc_dependents "capi-base-common")
-IF(TIZEN_WEARABLE)
- ADD_DEFINITIONS(-DTIZEN_WEARABLE)
-ENDIF(TIZEN_WEARABLE)
-IF(TIZEN_MOBILE)
- ADD_DEFINITIONS(-DTIZEN_MOBILE)
-ENDIF(TIZEN_MOBILE)
-
-IF(TIZEN_TV)
- ADD_DEFINITIONS(-DTIZEN_TV)
-ENDIF(TIZEN_TV)
-
INCLUDE(FindPkgConfig)
pkg_check_modules(${fw_name} REQUIRED ${dependents} ${APPFW_REQUIRED_PKGS})
FOREACH(flag ${${fw_name}_CFLAGS})
int _net_dbus_get_passpoint(int *enabled);
int _net_dbus_set_passpoint(int enable);
-#if defined TIZEN_TV
int _net_dbus_cancel_wps(void);
int _net_dbus_open_connection_without_ssid();
int _net_dbus_open_pin_connection_without_ssid(const char *pin);
int _net_dbus_set_agent_wps_pbc(void);
int _net_dbus_set_agent_wps_pin(const char *wps_pin);
-#endif
-
int _net_dbus_tdls_disconnect(const char* peer_mac_addr);
int _net_dbus_tdls_connected_peer(char** peer_mac_addr);
int net_wifi_get_passpoint(int *enable);
int net_wifi_set_passpoint(int enable);
-#if defined TIZEN_TV
int net_wifi_cancel_wps(void);
-#endif
int net_open_connection_with_wifi_info(const net_wifi_connection_info_s *wifi_info);
int net_scan_wifi(void);
int net_check_get_privilege(void);
int net_check_profile_privilege(void);
-#if defined TIZEN_TV
int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_s *wps_info);
-#endif
int net_wifi_tdls_disconnect(const char* peer_mac_addr);
int net_wifi_tdls_connected_peer(char** peer_mac_addr);
#define NETCONFIG_NETWORK_PATH "/net/netconfig/network"
#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
-#if defined TIZEN_TV
#define NETCONFIG_TV_PROFILE_INTERFACE NETCONFIG_SERVICE ".tv_profile"
-#endif
#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"
#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"
/* WIFI Handle Check */
bool __wifi_check_handle_validity(wifi_manager_h wifi);
+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 _get_tizen_profile();
#ifdef __cplusplus
}
#endif /* __cplusplus */
BuildRequires: pkgconfig(gthread-2.0)
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-appfw-application)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
-%if "%{profile}" == "wearable"
-BuildRequires: pkgconfig(capi-appfw-application)
-%endif
-
%description
Network Wi-Fi Manager library in Tizen C API
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
-DLIB_PATH=%{_lib} \
-%if "%{profile}" == "wearable"
- -DTIZEN_WEARABLE=1 \
-%else
-%if "%{profile}" == "mobile"
- -DTIZEN_MOBILE=1 \
-%else
-%if "%{profile}" == "tv"
- -DTIZEN_TV=1 \
-%endif
-%endif
-%endif
.
make %{?_smp_mflags}
return Error;
}
-#if defined TIZEN_TV
static void __net_wps_cancel_reply(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
__NETWORK_FUNC_EXIT__;
return NET_ERR_NONE;
}
-#endif
int _net_dbus_tdls_disconnect(const char* peer_mac_addr)
{
return Error;
}
-#if defined TIZEN_TV
int net_wifi_cancel_wps(void)
{
__NETWORK_FUNC_ENTER__;
__NETWORK_FUNC_EXIT__;
return Error;
}
-#endif
int net_get_wifi_state(net_wifi_state_e *current_state)
{
}
//LCOV_EXCL_START
-#if defined TIZEN_TV
int net_wifi_enroll_wps_without_ssid(net_wifi_wps_info_s *wps_info)
{
__NETWORK_FUNC_ENTER__;
__NETWORK_FUNC_EXIT__;
return Error;
}
-#endif
int net_wifi_tdls_disconnect(const char* peer_mac_addr)
{
#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
+#include <system_info.h>
#include "wifi_internal.h"
set_last_result(WIFI_MANAGER_ERROR_NONE);
return WIFI_MANAGER_ERROR_NONE;
}
+
+tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ if (__builtin_expect(profile != 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 = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: // common or unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
return WIFI_MANAGER_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
}
-#if defined TIZEN_TV
- FILE *fp = NULL;
- char buf[WIFI_MAC_ADDR_LENGTH + 1];
- if (0 == access(WIFI_MAC_ADDR_PATH, F_OK))
- fp = fopen(WIFI_MAC_ADDR_PATH, "r");
-
- if (fp == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to open file" //LCOV_EXCL_LINE
- " %s\n", WIFI_MAC_ADDR_PATH);
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- }
+ if (_get_tizen_profile() == TIZEN_PROFILE_TV) {
+ FILE *fp = NULL;
+ char buf[WIFI_MAC_ADDR_LENGTH + 1];
+ if (0 == access(WIFI_MAC_ADDR_PATH, F_OK))
+ fp = fopen(WIFI_MAC_ADDR_PATH, "r");
+
+ if (fp == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to open file" //LCOV_EXCL_LINE
+ " %s\n", WIFI_MAC_ADDR_PATH);
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
- if (fgets(buf, sizeof(buf), fp) == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get MAC"
- " info from %s\n", WIFI_MAC_ADDR_PATH); //LCOV_EXCL_LINE
- fclose(fp); //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
- }
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get MAC"
+ " info from %s\n", WIFI_MAC_ADDR_PATH); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
- WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADDR_PATH, buf);
+ WIFI_LOG(WIFI_INFO, "%s : %s\n", WIFI_MAC_ADDR_PATH, buf);
- *mac_address = strndup(buf, WIFI_MAC_ADDR_LENGTH + 1);
- if (*mac_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "strndup() failed"); //LCOV_EXCL_LINE
- fclose(fp); //LCOV_EXCL_LINE
- return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
- }
+ *mac_address = strndup(buf, WIFI_MAC_ADDR_LENGTH + 1);
+ if (*mac_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "strndup() failed"); //LCOV_EXCL_LINE
+ fclose(fp); //LCOV_EXCL_LINE
+ return WIFI_MANAGER_ERROR_OUT_OF_MEMORY; //LCOV_EXCL_LINE
+ }
- fclose(fp);
-#else
- *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+ fclose(fp);
+ } else {
+ *mac_address = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
- if (*mac_address == NULL) {
- WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE
- " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
- return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ if (*mac_address == NULL) {
+ WIFI_LOG(WIFI_ERROR, "Failed to get vconf" //LCOV_EXCL_LINE
+ " from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ return WIFI_MANAGER_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+ }
}
-#endif
return WIFI_MANAGER_ERROR_NONE;
}