summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-10-24 16:22:40 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-10-24 16:22:40 +0900
commit264829e4cbd3d10ba5925bd6022ceaf6e4140ff4 (patch)
treec6c13b421cf8051c278f9394cdd240183db69627 /src
parent3b319fd12772adcf57d31b5f4fc564af6ed7ff4e (diff)
downloadconnection-264829e4cbd3d10ba5925bd6022ceaf6e4140ff4.tar.gz
connection-264829e4cbd3d10ba5925bd6022ceaf6e4140ff4.tar.bz2
connection-264829e4cbd3d10ba5925bd6022ceaf6e4140ff4.zip
Diffstat (limited to 'src')
-rwxr-xr-xsrc/connection.c206
-rwxr-xr-xsrc/connection_profile.c20
-rwxr-xr-xsrc/libnetwork.c90
3 files changed, 290 insertions, 26 deletions
diff --git a/src/connection.c b/src/connection.c
index 0cb4f82..da5e609 100755
--- a/src/connection.c
+++ b/src/connection.c
@@ -21,15 +21,6 @@
#include "net_connection_private.h"
-typedef struct _connection_handle_s {
- connection_type_changed_cb type_changed_callback;
- connection_address_changed_cb ip_changed_callback;
- connection_address_changed_cb proxy_changed_callback;
- void *type_changed_user_data;
- void *ip_changed_user_data;
- void *proxy_changed_user_data;
-} connection_handle_s;
-
static __thread GSList *conn_handle_list = NULL;
static int __connection_convert_net_state(int status)
@@ -129,6 +120,33 @@ static void __connection_cb_type_change_cb(keynode_t *node, void *user_data)
}
}
+static void __connection_cb_ethernet_cable_state_changed_cb(connection_ethernet_cable_state_e state)
+{
+ CONNECTION_LOG(CONNECTION_INFO, "Ethernet Cable state Indication");
+
+ GSList *list;
+
+ for (list = conn_handle_list; list; list = list->next) {
+ connection_handle_s *local_handle = (connection_handle_s *)list->data;
+ if (local_handle->ethernet_cable_state_changed_callback)
+ local_handle->ethernet_cable_state_changed_callback(state,
+ local_handle->ethernet_cable_state_changed_user_data);
+ }
+}
+
+static int __connection_get_ethernet_cable_state_changed_callback_count(void)
+{
+ GSList *list;
+ int count = 0;
+
+ for (list = conn_handle_list; list; list = list->next) {
+ connection_handle_s *local_handle = (connection_handle_s *)list->data;
+ if (local_handle->ethernet_cable_state_changed_callback) count++;
+ }
+
+ return count;
+}
+
static int __connection_set_type_changed_callback(connection_h connection,
void *callback, void *user_data)
{
@@ -340,6 +358,26 @@ static int __connection_set_proxy_changed_callback(connection_h connection,
return CONNECTION_ERROR_NONE;
}
+static int __connection_set_ethernet_cable_state_changed_cb(connection_h connection,
+ connection_ethernet_cable_state_chaged_cb callback, void *user_data)
+{
+ connection_handle_s *local_handle = (connection_handle_s *)connection;
+
+ if (callback) {
+ if (__connection_get_ethernet_cable_state_changed_callback_count() == 0)
+ _connection_libnet_set_ethernet_cable_state_changed_cb(
+ __connection_cb_ethernet_cable_state_changed_cb);
+
+ } else {
+ if (__connection_get_ethernet_cable_state_changed_callback_count() == 1)
+ _connection_libnet_set_ethernet_cable_state_changed_cb(NULL);
+ }
+
+ local_handle->ethernet_cable_state_changed_callback = callback;
+ local_handle->ethernet_cable_state_changed_user_data = user_data;
+ return CONNECTION_ERROR_NONE;
+}
+
static int __connection_get_handle_count(void)
{
return ((int)g_slist_length(conn_handle_list));
@@ -390,6 +428,7 @@ EXPORT_API int connection_destroy(connection_h connection)
__connection_set_type_changed_callback(connection, NULL, NULL);
__connection_set_ip_changed_callback(connection, NULL, NULL);
__connection_set_proxy_changed_callback(connection, NULL, NULL);
+ __connection_set_ethernet_cable_state_changed_cb(connection, NULL, NULL);
conn_handle_list = g_slist_remove(conn_handle_list, connection);
@@ -406,6 +445,9 @@ EXPORT_API int connection_destroy(connection_h connection)
EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type)
{
+ int rv = 0;
+ int status = 0;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (type == NULL || !(__connection_check_handle_validity(connection))) {
@@ -413,8 +455,8 @@ EXPORT_API int connection_get_type(connection_h connection, connection_type_e* t
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- int status = 0;
- if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status)) {
+ rv = vconf_get_int(VCONFKEY_NETWORK_STATUS, &status);
+ if (rv != VCONF_OK) {
CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d", status);
return CONNECTION_ERROR_OPERATION_FAILED;
}
@@ -482,6 +524,100 @@ EXPORT_API int connection_get_proxy(connection_h connection,
return CONNECTION_ERROR_NONE;
}
+EXPORT_API int connection_get_mac_address(connection_h connection, connection_type_e type, char** mac_addr)
+{
+ FILE *fp;
+ char buf[CONNECTION_MAC_INFO_LENGTH + 1];
+
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
+
+ if(type == CONNECTION_TYPE_WIFI)
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+ else if(type == CONNECTION_TYPE_ETHERNET)
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+ if (mac_addr == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (type) {
+ case CONNECTION_TYPE_WIFI:
+#if defined TIZEN_TV
+ fp = fopen(WIFI_MAC_INFO_FILE, "r");
+ if (fp == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", WIFI_MAC_INFO_FILE);
+ fclose(fp);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "%s : %s", WIFI_MAC_INFO_FILE, buf);
+
+ *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
+ if (*mac_addr == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed");
+ fclose(fp);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+ g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
+ fclose(fp);
+#else
+ *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
+
+ if(*mac_addr == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+#endif
+ break;
+ case CONNECTION_TYPE_ETHERNET:
+ fp = fopen(ETHERNET_MAC_INFO_FILE, "r");
+ if (fp == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", ETHERNET_MAC_INFO_FILE);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ if (fgets(buf, sizeof(buf), fp) == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get MAC info from %s", ETHERNET_MAC_INFO_FILE);
+ fclose(fp);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "%s : %s", ETHERNET_MAC_INFO_FILE, buf);
+
+ *mac_addr = (char *)malloc(CONNECTION_MAC_INFO_LENGTH + 1);
+ if (*mac_addr == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "malloc() failed");
+ fclose(fp);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_strlcpy(*mac_addr, buf,CONNECTION_MAC_INFO_LENGTH + 1);
+ fclose(fp);
+
+ break;
+ default:
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ /* Checking Invalid MAC Address */
+ if((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
+ (strcmp(*mac_addr, "ff:ff:ff:ff:ff:ff") == 0)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "MAC Address(%s) is invalid", *mac_addr);
+ return CONNECTION_ERROR_INVALID_OPERATION;
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "MAC Address %s", *mac_addr);
+
+ return CONNECTION_ERROR_NONE;
+}
+
EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
{
int rv = 0;
@@ -580,6 +716,45 @@ EXPORT_API int connection_get_ethernet_state(connection_h connection, connection
return _connection_libnet_get_ethernet_state(state);
}
+EXPORT_API int connection_get_ethernet_cable_state(connection_h connection, connection_ethernet_cable_state_e *state)
+{
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+ if (state == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_get_ethernet_cable_state(state);
+}
+
+EXPORT_API int connection_set_ethernet_cable_state_chaged_cb(connection_h connection,
+ connection_ethernet_cable_state_chaged_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+ if (callback == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return __connection_set_ethernet_cable_state_changed_cb(connection,
+ callback, user_data);
+}
+
+EXPORT_API int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection)
+{
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
+ if ( !(__connection_check_handle_validity(connection)) ) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return __connection_set_ethernet_cable_state_changed_cb(connection,
+ NULL, NULL);
+}
+
EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e* state)
{
CHECK_FEATURE_SUPPORTED(TETHERING_BLUETOOTH_FEATURE);
@@ -740,7 +915,7 @@ EXPORT_API int connection_update_profile(connection_h connection, connection_pro
int rv = 0;
net_profile_info_t *profile_info = profile;
- CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
!(_connection_libnet_check_profile_validity(profile))) {
@@ -780,18 +955,21 @@ EXPORT_API int connection_profile_iterator_next(connection_profile_iterator_h pr
connection_profile_h* profile)
{
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
return _connection_libnet_get_iterator_next(profile_iterator, profile);
}
EXPORT_API bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator)
{
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
return _connection_libnet_iterator_has_next(profile_iterator);
}
EXPORT_API int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator)
{
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
return _connection_libnet_destroy_iterator(profile_iterator);
}
@@ -923,7 +1101,7 @@ EXPORT_API int connection_remove_route(connection_h connection, const char* inte
EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
{
- CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
interface_name == NULL || host_address == NULL) {
@@ -936,7 +1114,7 @@ EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *in
EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
{
- CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, ETHERNET_FEATURE);
if (!(__connection_check_handle_validity(connection)) ||
interface_name == NULL || host_address == NULL) {
diff --git a/src/connection_profile.c b/src/connection_profile.c
index d6a9f49..3005b69 100755
--- a/src/connection_profile.c
+++ b/src/connection_profile.c
@@ -411,6 +411,8 @@ EXPORT_API int connection_profile_get_network_interface_name(connection_profile_
EXPORT_API int connection_profile_refresh(connection_profile_h profile)
{
+ int rv;
+
CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (!(_connection_libnet_check_profile_validity(profile))) {
@@ -421,7 +423,7 @@ EXPORT_API int connection_profile_refresh(connection_profile_h profile)
net_profile_info_t profile_info_local;
net_profile_info_t *profile_info = profile;
- int rv = net_get_profile_info(profile_info->ProfileName, &profile_info_local);
+ rv = net_get_profile_info(profile_info->ProfileName, &profile_info_local);
if (rv == NET_ERR_ACCESS_DENIED) {
CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
return CONNECTION_ERROR_PERMISSION_DENIED;
@@ -455,9 +457,10 @@ EXPORT_API int connection_profile_get_state(connection_profile_h profile, connec
EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profile,
connection_address_family_e address_family, connection_ip_config_type_e* type)
{
- CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
net_ip_config_type_t profile_type;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
@@ -557,9 +560,10 @@ EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, char** subnet_mask)
{
- CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
char* prefixlen;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
@@ -575,8 +579,11 @@ EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH);
- snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6);
- *subnet_mask = prefixlen;
+ if (prefixlen != NULL) {
+ snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6);
+ *subnet_mask = prefixlen;
+ } else
+ *subnet_mask = NULL;
} else
*subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask,
address_family);
@@ -725,9 +732,10 @@ EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile
EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profile,
connection_address_family_e address_family, connection_ip_config_type_e type)
{
- CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
net_ip_config_type_t *profile_type = NULL;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
diff --git a/src/libnetwork.c b/src/libnetwork.c
index 2ac48ba..cda1205 100755
--- a/src/libnetwork.c
+++ b/src/libnetwork.c
@@ -11,7 +11,7 @@
* 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.
+ * limitations under the License.
*/
#include <glib.h>
@@ -44,6 +44,7 @@ struct _libnet_s {
connection_closed_cb closed_cb;
connection_set_default_cb set_default_cb;
connection_reset_cb reset_profile_cb;
+ libnet_ethernet_cable_state_changed_cb ethernet_cable_state_changed_cb;
void *opened_user_data;
void *closed_user_data;
void *set_default_user_data;
@@ -66,6 +67,8 @@ struct managed_idle_data {
static __thread struct _profile_list_s profile_iterator = {0, 0, NULL};
static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false};
static __thread GSList *managed_idler_list = NULL;
+static __thread bool connection_is_feature_checked[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
+static __thread bool connection_feature_supported[CONNECTION_SUPPORTED_FEATURE_MAX] = {0, };
bool _connection_is_created(void)
{
@@ -295,6 +298,19 @@ static void __libnet_default_cb(connection_error_e result)
_connection_callback_add(__libnet_default_cb_idle, (gpointer)result);
}
+static void __libnet_set_ethernet_cable_state_changed_cb(
+ libnet_ethernet_cable_state_changed_cb user_cb)
+{
+ libnet.ethernet_cable_state_changed_cb = user_cb;
+}
+
+static void __libnet_ethernet_cable_state_changed_cb(
+ connection_ethernet_cable_state_e state)
+{
+ if (libnet.ethernet_cable_state_changed_cb)
+ libnet.ethernet_cable_state_changed_cb(state);
+}
+
static gboolean __libnet_state_changed_cb_idle(gpointer data)
{
struct _state_notify *notify = (struct _state_notify *)data;
@@ -443,6 +459,16 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
result = __libnet_convert_to_cp_error_type(event_cb->Error);
CONNECTION_LOG(CONNECTION_INFO, "Got reset default profile RSP %d", result);
__libnet_reset_profile_cb(result);
+ break;
+ case NET_EVENT_ETHERNET_CABLE_ATTACHED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable Attached Indication\n");
+ __libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_ATTACHED);
+ break;
+ case NET_EVENT_ETHERNET_CABLE_DETACHED:
+ CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable detached Indication\n");
+ __libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_DETACHED);
+ break;
+
default :
break;
}
@@ -660,6 +686,35 @@ int _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state)
return CONNECTION_ERROR_NONE;
}
+int _connection_libnet_get_ethernet_cable_state(connection_ethernet_cable_state_e* state)
+{
+ int rv = 0;
+ int status = 0;
+
+ rv = net_get_ethernet_cable_state(&status);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get ethernet cable state[%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ if(status == 1)
+ *state = CONNECTION_ETHERNET_CABLE_ATTACHED;
+ else
+ *state = CONNECTION_ETHERNET_CABLE_DETACHED;
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_set_ethernet_cable_state_changed_cb(
+ libnet_ethernet_cable_state_changed_cb callback)
+{
+ __libnet_set_ethernet_cable_state_changed_cb(callback);
+
+ return CONNECTION_ERROR_NONE;
+}
+
int _connection_libnet_get_bluetooth_state(connection_bt_state_e* state)
{
int i = 0;
@@ -1300,6 +1355,7 @@ bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
profile_cb_info->callback = callback;
profile_cb_info->user_data = user_data;
+ profile_cb_info->state = _profile_convert_to_cp_state(profile_info->ProfileState);
g_hash_table_replace(profile_cb_table, profile_name, profile_cb_info);
@@ -1463,20 +1519,42 @@ int _connection_libnet_check_profile_privilege()
return CONNECTION_ERROR_NONE;
}
+bool __libnet_check_feature_supported(const char *key, connection_supported_feature_e feature)
+{
+ if(!connection_is_feature_checked[feature]) {
+ if(system_info_get_platform_bool(key, &connection_feature_supported[feature]) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature getting from System Info");
+ set_last_result(CONNECTION_ERROR_OPERATION_FAILED);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ connection_is_feature_checked[feature] = true;
+ }
+ return connection_feature_supported[feature];
+}
+
int _connection_check_feature_supported(const char *feature_name, ...)
{
va_list list;
const char *key;
- bool value, feature_supported = false;
+ bool value = false;
+ bool feature_supported = false;
va_start(list, feature_name);
key = feature_name;
while(1) {
- if(system_info_get_platform_bool(key, &value) < 0) {
- CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature getting from System Info");
- set_last_result(CONNECTION_ERROR_OPERATION_FAILED);
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if((strcmp(key, TELEPHONY_FEATURE) == 0)){
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TELEPHONY);
+ }
+ if((strcmp(key, WIFI_FEATURE) == 0)){
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_WIFI);
+ }
+ if((strcmp(key, TETHERING_BLUETOOTH_FEATURE) == 0)){
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH);
}
+ if((strcmp(key, ETHERNET_FEATURE) == 0)){
+ value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_ETHERNET);
+ }
+
SECURE_CONNECTION_LOG(CONNECTION_INFO, "%s feature is %s", key, (value?"true":"false"));
feature_supported |= value;
key = va_arg(list, const char *);