[ACR-456]Add enumeration for connection type #2
[platform/core/api/connection.git] / src / connection.c
index da5e609..a6b0290 100755 (executable)
@@ -34,6 +34,8 @@ static int __connection_convert_net_state(int status)
                return CONNECTION_TYPE_ETHERNET;
        case VCONFKEY_NETWORK_BLUETOOTH:
                return CONNECTION_TYPE_BT;
+       case VCONFKEY_NETWORK_DEFAULT_PROXY:
+               return CONNECTION_TYPE_NET_PROXY;
        default:
                return CONNECTION_TYPE_DISCONNECTED;
        }
@@ -397,8 +399,7 @@ EXPORT_API int connection_create(connection_h *connection)
        if (rv == NET_ERR_ACCESS_DENIED) {
                CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
                return CONNECTION_ERROR_PERMISSION_DENIED;
-       }
-       else if (rv != NET_ERR_NONE) {
+       } else if (rv != NET_ERR_NONE) {
                CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv);
                return CONNECTION_ERROR_OPERATION_FAILED;
        }
@@ -531,9 +532,9 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 
        CHECK_FEATURE_SUPPORTED(WIFI_FEATURE, ETHERNET_FEATURE);
 
-       if(type == CONNECTION_TYPE_WIFI)
+       if (type == CONNECTION_TYPE_WIFI)
                CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
-       else if(type == CONNECTION_TYPE_ETHERNET)
+       else if (type == CONNECTION_TYPE_ETHERNET)
                CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
        if (mac_addr == NULL || !(__connection_check_handle_validity(connection))) {
@@ -569,7 +570,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
 #else
                *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS);
 
-               if(*mac_addr == NULL) {
+               if (*mac_addr == NULL) {
                        CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS);
                        return CONNECTION_ERROR_OPERATION_FAILED;
                }
@@ -597,7 +598,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
                        return CONNECTION_ERROR_OUT_OF_MEMORY;
                }
 
-               g_strlcpy(*mac_addr, buf,CONNECTION_MAC_INFO_LENGTH + 1);
+               g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1);
                fclose(fp);
 
                break;
@@ -607,7 +608,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
        }
 
        /* Checking Invalid MAC Address */
-       if((strcmp(*mac_addr, "00:00:00:00:00:00") == 0) ||
+       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;
@@ -618,6 +619,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty
        return CONNECTION_ERROR_NONE;
 }
 
+
 EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
 {
        int rv = 0;
@@ -746,7 +748,7 @@ EXPORT_API int connection_unset_ethernet_cable_state_chaged_cb(connection_h conn
 {
        CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
 
-       if ( !(__connection_check_handle_validity(connection)) ) {
+       if (!(__connection_check_handle_validity(connection))) {
                CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
@@ -1065,7 +1067,7 @@ EXPORT_API int connection_reset_profile(connection_h connection,
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
 
-       if(id < 0 || id > 1) {
+       if (id < 0 || id > 1) {
                CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed");
                return CONNECTION_ERROR_INVALID_PARAMETER;
        }
@@ -1207,8 +1209,8 @@ static int __get_cellular_statistic(connection_statistics_type_e statistics_type
                return CONNECTION_ERROR_OPERATION_FAILED;
        }
 
-       *llsize = (long long)(last_size * 1000 + size * 1000);
-       CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", *llsize);
+       *llsize = (long long)(last_size * 1000) + (long long)(size * 1000);
+       CONNECTION_LOG(CONNECTION_INFO, "%lld bytes", *llsize);
 
        return CONNECTION_ERROR_NONE;
 }
@@ -1261,7 +1263,7 @@ static int __get_statistic(connection_type_e connection_type,
                        return CONNECTION_ERROR_OPERATION_FAILED;
                }
 
-               CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", ull_size);
+               CONNECTION_LOG(CONNECTION_INFO, "%lld bytes", ull_size);
                *llsize = (long long)ull_size;
        } else
                return CONNECTION_ERROR_INVALID_PARAMETER;
@@ -1304,7 +1306,7 @@ static int __reset_statistic(connection_type_e connection_type,
        if (rv != CONNECTION_ERROR_NONE)
                return rv;
 
-       CONNECTION_LOG(CONNECTION_INFO,"connection_reset_statistics success");
+       CONNECTION_LOG(CONNECTION_INFO, "connection_reset_statistics success");
 
        return CONNECTION_ERROR_NONE;
 }
@@ -1315,9 +1317,9 @@ EXPORT_API int connection_get_statistics(connection_h connection,
 {
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
 
-       if(connection_type == CONNECTION_TYPE_CELLULAR )
+       if (connection_type == CONNECTION_TYPE_CELLULAR)
                CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
-       else if(connection_type == CONNECTION_TYPE_WIFI)
+       else if (connection_type == CONNECTION_TYPE_WIFI)
                CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!(__connection_check_handle_validity(connection)) || size == NULL) {
@@ -1334,9 +1336,9 @@ EXPORT_API int connection_reset_statistics(connection_h connection,
 {
        CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
 
-       if(connection_type == CONNECTION_TYPE_CELLULAR )
+       if (connection_type == CONNECTION_TYPE_CELLULAR)
                CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
-       else if(connection_type == CONNECTION_TYPE_WIFI)
+       else if (connection_type == CONNECTION_TYPE_WIFI)
                CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
 
        if (!__connection_check_handle_validity(connection)) {