+
+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;
+}
+
+void netconfig_plugin_init()
+{
+ handle_headed = dlopen(HEADED_PLUGIN_FILEPATH, RTLD_NOW);
+ if (!handle_headed) {
+ ERR("Can't load %s: %s", HEADED_PLUGIN_FILEPATH, dlerror());
+ } else {
+ headed_plugin = dlsym(handle_headed, "netconfig_headed_plugin");
+ if (!headed_plugin) {
+ ERR("Can't load symbol: %s", dlerror());
+ dlclose(handle_headed);
+ } else {
+ netconfig_plugin_headed_enabled = TRUE;
+ }
+ }
+
+ handle_telephony = dlopen(TELEPHONY_PLUGIN_FILEPATH, RTLD_NOW);
+ if (!handle_telephony) {
+ ERR("Can't load %s: %s", TELEPHONY_PLUGIN_FILEPATH, dlerror());
+ } else {
+ telephony_plugin = dlsym(handle_telephony, "netconfig_telephony_plugin");
+ if (!telephony_plugin) {
+ ERR("Can't load symbol: %s", dlerror());
+ dlclose(handle_telephony);
+ } else {
+ netconfig_plugin_telephony_enabled = TRUE;
+ }
+ }
+}
+
+void netconfig_plugin_deinit()
+{
+ if (netconfig_plugin_headed_enabled) {
+ netconfig_plugin_headed_enabled = FALSE;
+ dlclose(handle_headed);
+ }
+
+ if (netconfig_plugin_telephony_enabled) {
+ netconfig_plugin_telephony_enabled = FALSE;
+ dlclose(handle_telephony);
+ }
+}
+
+gboolean netconfig_get_headed_plugin_flag()
+{
+ return netconfig_plugin_headed_enabled;
+}
+
+gboolean netconfig_get_telephony_plugin_flag()
+{
+ return netconfig_plugin_telephony_enabled;
+}
+
+bool netconfig_check_feature_supported(netconfig_supported_feature_e feature)
+{
+ const char *key = NULL;
+
+ if (!is_feature_checked[feature]) {
+ switch (feature) {
+ case NETCONFIG_SUPPORTED_FEATURE_ETHERNET:
+ key = ETHERNET_FEATURE;
+ break;
+ case NETCONFIG_SUPPORTED_FEATURE_TETHERING:
+ key = TETHERING_FEATURE;
+ break;
+ case NETCONFIG_SUPPORTED_FEATURE_WIFI_DIRECT:
+ key = WIFI_DIRECT_FEATURE;
+ break;
+ case NETCONFIG_SUPPORTED_FEATURE_WIFI_SOFTAP:
+ key = WIFI_SOFTAP_FEATURE;
+ break;
+ default:
+ ERR("Uknown feature");
+ return false;
+ }
+
+ if (system_info_get_platform_bool(key, &feature_supported[feature]) < 0) {
+ ERR("Get feature is failed");
+ return false;
+ }
+ is_feature_checked[feature] = true;
+ }
+ return feature_supported[feature];
+}