From: hyunuktak Date: Tue, 8 Dec 2015 09:17:58 +0000 (+0900) Subject: Apply coding rule X-Git-Tag: accepted/tizen/mobile/20151210.030338^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F31%2F53631%2F4;p=platform%2Fcore%2Fapi%2Fconnection.git Apply coding rule Change-Id: I8119e081832b83bbd1d7db6ee51c45098907d668 Signed-off-by: Taesub Kim --- diff --git a/capi-network-connection.manifest b/capi-network-connection.manifest index 3ca8395..97e8c31 100755 --- a/capi-network-connection.manifest +++ b/capi-network-connection.manifest @@ -1,7 +1,4 @@ - - - diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index 5c94722..a8172c7 100755 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -1,6 +1,6 @@ Name: capi-network-connection Summary: Network Connection library in TIZEN C API -Version: 1.0.75 +Version: 1.0.76 Release: 1 Group: System/Network License: Apache-2.0 diff --git a/src/connection.c b/src/connection.c index 3d13899..cacbf51 100755 --- a/src/connection.c +++ b/src/connection.c @@ -399,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; } @@ -533,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))) { @@ -590,7 +589,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; @@ -600,7 +599,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; @@ -739,7 +738,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; } @@ -1058,7 +1057,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; } @@ -1201,7 +1200,7 @@ static int __get_cellular_statistic(connection_statistics_type_e statistics_type } *llsize = (long long)(last_size * 1000) + (long long)(size * 1000); - CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", *llsize); + CONNECTION_LOG(CONNECTION_INFO, "%lld bytes", *llsize); return CONNECTION_ERROR_NONE; } @@ -1254,7 +1253,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; @@ -1297,7 +1296,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; } @@ -1308,9 +1307,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) { @@ -1327,9 +1326,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)) { diff --git a/src/connection_profile.c b/src/connection_profile.c index 188c947..f63582e 100755 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -210,9 +210,9 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE); - if(type == CONNECTION_PROFILE_TYPE_CELLULAR) + if (type == CONNECTION_PROFILE_TYPE_CELLULAR) CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE); - else if(type == CONNECTION_PROFILE_TYPE_WIFI) + else if (type == CONNECTION_PROFILE_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); if (type != CONNECTION_PROFILE_TYPE_CELLULAR && @@ -610,7 +610,7 @@ EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profi if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) *gateway_address = __profile_convert_ip_to_string( &net_info->GatewayAddr6, address_family); else @@ -643,10 +643,10 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1], address_family); - else if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) + else if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1], address_family); else @@ -746,12 +746,12 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) profile_type = &net_info->IpConfigType ; else profile_type = &net_info->IpConfigType6 ; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) { switch (type) { case CONNECTION_IP_CONFIG_TYPE_STATIC: *profile_type = NET_IP_CONFIG_TYPE_STATIC; @@ -822,7 +822,7 @@ EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { if (ip_address == NULL) inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6); else if (inet_pton(AF_INET6, ip_address, @@ -856,7 +856,7 @@ EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { if (subnet_mask == NULL) net_info->PrefixLen6 = 0 ; else @@ -864,7 +864,7 @@ EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile, } else { if (subnet_mask == NULL) net_info->SubnetMask.Data.Ipv4.s_addr = 0; - else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1 ) + else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1) return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -888,7 +888,7 @@ EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profi if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { if (gateway_address == NULL) inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6); else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1) @@ -922,7 +922,7 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, if (net_info == NULL) return CONNECTION_ERROR_OPERATION_FAILED; - if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { + if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) { net_info->DnsAddr6[order-1].Type = NET_ADDR_IPV6; if (dns_address == NULL) inet_pton(AF_INET6, "::", &net_info->DnsAddr6[order-1].Data.Ipv6); diff --git a/src/libnetwork.c b/src/libnetwork.c index daf7bff..8f30b58 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -389,7 +389,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) case NET_EVENT_OPEN_IND: result = __libnet_convert_to_cp_error_type(event_cb->Error); CONNECTION_LOG(CONNECTION_INFO, "Connection opened %s[%s]", - (is_requested) ? "RSP":"IND", + (is_requested) ? "RSP" : "IND", __libnet_convert_cp_error_type_to_string(result)); if (is_requested) @@ -416,7 +416,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) case NET_EVENT_CLOSE_IND: result = __libnet_convert_to_cp_error_type(event_cb->Error); CONNECTION_LOG(CONNECTION_INFO, "Connection closed %s[%s]", - (is_requested) ? "RSP":"IND", + (is_requested) ? "RSP" : "IND", __libnet_convert_cp_error_type_to_string(result)); if (is_requested) @@ -469,7 +469,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) __libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_DETACHED); break; - default : + default: break; } } @@ -480,7 +480,7 @@ static int __libnet_check_address_type(int address_family, const char *address) int err = 0; err = inet_pton(address_family, address, &buf); - if(err > 0) + if (err > 0) return 1; return 0; @@ -491,7 +491,7 @@ int __libnet_get_connected_count(struct _profile_list_s *profile_list) int count = 0; int i = 0; - for (;i < profile_list->count;i++) { + for (; i < profile_list->count; i++) { if (profile_list->profiles[i].ProfileState == NET_STATE_TYPE_ONLINE || profile_list->profiles[i].ProfileState == NET_STATE_TYPE_READY) count++; @@ -504,7 +504,7 @@ void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_ { int i = 0; - for (;i < source->count;i++) { + for (; i < source->count; i++) { if (source->profiles[i].ProfileState == NET_STATE_TYPE_ONLINE || source->profiles[i].ProfileState == NET_STATE_TYPE_READY) { memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t)); @@ -518,7 +518,7 @@ int __libnet_get_default_count(struct _profile_list_s *profile_list) int count = 0; int i = 0; - for (;i < profile_list->count;i++) { + for (; i < profile_list->count; i++) { if (profile_list->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE) count++; } @@ -530,7 +530,7 @@ void __libnet_copy_default_profile(net_profile_info_t **dest, struct _profile_li { int i = 0; - for (;i < source->count;i++) { + for (; i < source->count; i++) { if (source->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE) { memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t)); (*dest)++; @@ -591,7 +591,7 @@ bool _connection_libnet_check_profile_validity(connection_profile_h profile) for (list = prof_handle_list; list; list = list->next) if (profile == list->data) return true; - for (;i < profile_iterator.count;i++) + for (; i < profile_iterator.count; i++) if (profile == &profile_iterator.profiles[i]) return true; return false; @@ -641,7 +641,7 @@ int _connection_libnet_get_wifi_state(connection_wifi_state_e *state) case WIFI_DISCONNECTING: *state = CONNECTION_WIFI_STATE_CONNECTED; break; - default : + default: CONNECTION_LOG(CONNECTION_ERROR, "Unknown Wi-Fi state"); return CONNECTION_ERROR_INVALID_OPERATION; } @@ -700,7 +700,7 @@ int _connection_libnet_get_ethernet_cable_state(connection_ethernet_cable_state_ return CONNECTION_ERROR_OPERATION_FAILED; } - if(status == 1) + if (status == 1) *state = CONNECTION_ETHERNET_CABLE_ATTACHED; else *state = CONNECTION_ETHERNET_CABLE_DETACHED; @@ -1196,24 +1196,24 @@ int _connection_libnet_add_route(const char *interface_name, const char *host_ad char *endstr = NULL; int address_family = 0; - if(__libnet_check_address_type(AF_INET, host_address)) + if (__libnet_check_address_type(AF_INET, host_address)) address_family = AF_INET; else return CONNECTION_ERROR_INVALID_PARAMETER; - switch(address_family) { - case AF_INET: - endstr = strrchr(host_address, '.'); - if (endstr == NULL || - strcmp(endstr, ".0") == 0 || - strncmp(host_address, "0.", 2) == 0 || - strstr(host_address, "255") != NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; + switch (address_family) { + case AF_INET: + endstr = strrchr(host_address, '.'); + if (endstr == NULL || + strcmp(endstr, ".0") == 0 || + strncmp(host_address, "0.", 2) == 0 || + strstr(host_address, "255") != NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; } rv = net_add_route(host_address, interface_name, address_family); @@ -1237,19 +1237,19 @@ int _connection_libnet_remove_route(const char *interface_name, const char *host else return CONNECTION_ERROR_INVALID_PARAMETER; - switch(address_family) { - case AF_INET: - endstr = strrchr(host_address, '.'); - if (endstr == NULL || - strcmp(endstr, ".0") == 0 || - strncmp(host_address, "0.", 2) == 0 || - strstr(host_address, ".0.") != NULL ||strstr(host_address, "255") != NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; + switch (address_family) { + case AF_INET: + endstr = strrchr(host_address, '.'); + if (endstr == NULL || + strcmp(endstr, ".0") == 0 || + strncmp(host_address, "0.", 2) == 0 || + strstr(host_address, ".0.") != NULL || strstr(host_address, "255") != NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; } rv = net_remove_route(host_address, interface_name, address_family); @@ -1273,17 +1273,17 @@ int _connection_libnet_add_route_ipv6(const char *interface_name, const char *ho else return CONNECTION_ERROR_INVALID_PARAMETER;*/ - switch(address_family) { - case AF_INET6: - if (strncmp(host_address, "fe80:", 5) == 0 || - strncmp(host_address, "ff00:", 5) == 0 || - strncmp(host_address, "::", 2) == 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; + switch (address_family) { + case AF_INET6: + if (strncmp(host_address, "fe80:", 5) == 0 || + strncmp(host_address, "ff00:", 5) == 0 || + strncmp(host_address, "::", 2) == 0) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; } rv = net_add_route_ipv6(host_address, interface_name, address_family, gateway); @@ -1307,17 +1307,17 @@ int _connection_libnet_remove_route_ipv6(const char *interface_name, const char else return CONNECTION_ERROR_INVALID_PARAMETER;*/ - switch(address_family) { - case AF_INET6: - if (strncmp(host_address, "fe80:", 5) == 0 || - strncmp(host_address, "ff00:", 5) == 0 || - strncmp(host_address, "::", 2) == 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; + switch (address_family) { + case AF_INET6: + if (strncmp(host_address, "fe80:", 5) == 0 || + strncmp(host_address, "ff00:", 5) == 0 || + strncmp(host_address, "::", 2) == 0) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + break; + default: + return CONNECTION_ERROR_OPERATION_FAILED; } rv = net_remove_route_ipv6(host_address, interface_name, address_family, gateway); @@ -1392,7 +1392,7 @@ int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, uns 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) return CONNECTION_ERROR_OPERATION_FAILED; return CONNECTION_ERROR_NONE; @@ -1521,8 +1521,8 @@ int _connection_libnet_check_profile_privilege() 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) { + 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; @@ -1541,21 +1541,17 @@ int _connection_check_feature_supported(const char *feature_name, ...) va_start(list, feature_name); key = feature_name; - while(1) { - if((strcmp(key, TELEPHONY_FEATURE) == 0)){ + while (1) { + if (strcmp(key, TELEPHONY_FEATURE) == 0) value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TELEPHONY); - } - if((strcmp(key, WIFI_FEATURE) == 0)){ + if (strcmp(key, WIFI_FEATURE) == 0) value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_WIFI); - } - if((strcmp(key, TETHERING_BLUETOOTH_FEATURE) == 0)){ + if (strcmp(key, TETHERING_BLUETOOTH_FEATURE) == 0) value = __libnet_check_feature_supported(key, CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH); - } - if((strcmp(key, ETHERNET_FEATURE) == 0)){ + 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")); + SECURE_CONNECTION_LOG(CONNECTION_INFO, "%s feature is %s", key, (value ? "true" : "false")); feature_supported |= value; key = va_arg(list, const char *); if (!key) break; diff --git a/test/connection_test.c b/test/connection_test.c index 569fbe1..8200038 100755 --- a/test/connection_test.c +++ b/test/connection_test.c @@ -25,7 +25,7 @@ #include -#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;} +#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1; } gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data); @@ -48,7 +48,7 @@ static bool test_get_user_string(const char *msg, char *buf, int buf_size) return false; } - buf[rv-1]='\0'; + buf[rv-1] = '\0'; return true; } @@ -192,9 +192,9 @@ static void test_connection_set_default_callback(connection_error_e result, void void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state, void* user_data) { - if(state == CONNECTION_ETHERNET_CABLE_ATTACHED) + if (state == CONNECTION_ETHERNET_CABLE_ATTACHED) printf("Ethernet Cable Connected\n"); - else if(state == CONNECTION_ETHERNET_CABLE_DETACHED) + else if (state == CONNECTION_ETHERNET_CABLE_DETACHED) printf("Ethernet Cable Disconnected\n"); } @@ -245,16 +245,15 @@ static bool test_get_user_selected_profile(connection_profile_h *profile, bool s connection_profile_get_wifi_essid(profile_h, &essid); printf("%d. state:[%s], profile name:%s, essid:%s\n", profile_count, test_print_state(profile_state), - profile_name, (essid)? essid : ""); + profile_name, (essid) ? essid : ""); g_free(essid); profile_list[profile_count] = profile_h; profile_count++; } else { connection_cellular_service_type_e service_type; - if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) { + if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) printf("Fail to get cellular service type!\n"); - } printf("%d. state:[%s], profile name:%s[%d]\n", profile_count, test_print_state(profile_state), profile_name, service_type); @@ -849,16 +848,16 @@ int test_get_current_proxy(void) int test_get_current_ip(void) { char *ip_addr = NULL; - int input; - bool rv; + int input; + bool rv; - rv = test_get_user_int("Input Address type to get" - "(1:IPV4, 2:IPV6):", &input); + rv = test_get_user_int("Input Address type to get" + "(1:IPV4, 2:IPV6):", &input); - if (rv == false) { - printf("Invalid input!!\n"); - return -1; - } + if (rv == false) { + printf("Invalid input!!\n"); + return -1; + } switch (input) { case 1: @@ -894,9 +893,9 @@ int test_get_call_statistics_info(void) connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv); printf("last recv data size [%lld]\n", rv); connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv); - printf("last sent data size [%lld]\n",rv ); + printf("last sent data size [%lld]\n", rv); connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv); - printf("total received data size [%lld]\n",rv ); + printf("total received data size [%lld]\n", rv); connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv); printf("total sent data size [%lld]\n", rv); @@ -910,9 +909,9 @@ int test_get_wifi_call_statistics_info(void) connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv); printf("WiFi last recv data size [%lld]\n", rv); connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv); - printf("WiFi last sent data size [%lld]\n",rv ); + printf("WiFi last sent data size [%lld]\n", rv); connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv); - printf("WiFi total received data size [%lld]\n",rv ); + printf("WiFi total received data size [%lld]\n", rv); connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv); printf("WiFi total sent data size [%lld]\n", rv); @@ -1686,9 +1685,8 @@ int test_reset_profile(void) return -1; } - if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) { + if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) return -1; - } return 1; } @@ -1696,14 +1694,14 @@ int test_reset_profile(void) int main(int argc, char **argv) { GMainLoop *mainloop; - mainloop = g_main_loop_new (NULL, FALSE); + mainloop = g_main_loop_new(NULL, FALSE); GIOChannel *channel = g_io_channel_unix_new(0); - g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL ); + g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread, NULL); printf("Test Thread created...\n"); - g_main_loop_run (mainloop); + g_main_loop_run(mainloop); return 0; } @@ -1728,42 +1726,42 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) if (*a == '\n' || *a == '\r') { printf("\n\n Network Connection API Test App\n\n"); printf("Options..\n"); - printf("1 - Create Handle and set callbacks\n"); - printf("2 - Destroy Handle(unset callbacks automatically)\n"); - printf("3 - Get network state\n"); - printf("4 - Get cellular state (please insert SIM Card)\n"); - printf("5 - Get wifi state (please turn on WiFi)\n"); - printf("6 - Get current proxy address \n"); - printf("7 - Get current Ip address\n"); - printf("8 - Get cellular data call statistics\n"); - printf("9 - Get WiFi data call statistics\n"); - printf("a - Get Profile list\n"); - printf("b - Get Connected Profile list\n"); - printf("c - Get Current profile\n"); - printf("d - Open connection with profile\n"); - printf("e - Get default cellular service by type\n"); - printf("f - Set default cellular service by type\n"); - printf("g - Close connection with profile\n"); - printf("h - Add profile(Cellular and Wifi only)\n"); - printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n"); - printf("j - Update profile\n"); - printf("k - Get profile info\n"); - printf("l - Refresh profile info\n"); - printf("m - Set state changed callback\n"); - printf("n - Unset state changed callback\n"); - printf("o - Reset cellular data call statistics\n"); - printf("p - Reset WiFi data call statistics\n"); - printf("q - Add new route\n"); - printf("r - Remove a route\n"); - printf("s - Get Bluetooth state\n"); - printf("t - Get profile id\n"); - printf("u - Reset profile\n"); - printf("v - Get all cellular default profiles\n"); - printf("w - Get mac address\n"); - printf("x - Get ethernet cable state\n"); - printf("B - Add IPv6 new route\n"); - printf("C - Remove IPv6 route\n"); - printf("0 - Exit \n"); + printf("1 - Create Handle and set callbacks\n"); + printf("2 - Destroy Handle(unset callbacks automatically)\n"); + printf("3 - Get network state\n"); + printf("4 - Get cellular state (please insert SIM Card)\n"); + printf("5 - Get wifi state (please turn on WiFi)\n"); + printf("6 - Get current proxy address \n"); + printf("7 - Get current Ip address\n"); + printf("8 - Get cellular data call statistics\n"); + printf("9 - Get WiFi data call statistics\n"); + printf("a - Get Profile list\n"); + printf("b - Get Connected Profile list\n"); + printf("c - Get Current profile\n"); + printf("d - Open connection with profile\n"); + printf("e - Get default cellular service by type\n"); + printf("f - Set default cellular service by type\n"); + printf("g - Close connection with profile\n"); + printf("h - Add profile(Cellular and Wifi only)\n"); + printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n"); + printf("j - Update profile\n"); + printf("k - Get profile info\n"); + printf("l - Refresh profile info\n"); + printf("m - Set state changed callback\n"); + printf("n - Unset state changed callback\n"); + printf("o - Reset cellular data call statistics\n"); + printf("p - Reset WiFi data call statistics\n"); + printf("q - Add new route\n"); + printf("r - Remove a route\n"); + printf("s - Get Bluetooth state\n"); + printf("t - Get profile id\n"); + printf("u - Reset profile\n"); + printf("v - Get all cellular default profiles\n"); + printf("w - Get mac address\n"); + printf("x - Get ethernet cable state\n"); + printf("B - Add IPv6 new route\n"); + printf("C - Remove IPv6 route\n"); + printf("0 - Exit \n"); printf("ENTER - Show options menu.......\n"); }