Revise net_get_progile_list() 74/12974/1
authortaesub.kim <taesub.kim@samsung.com>
Wed, 27 Nov 2013 05:18:08 +0000 (14:18 +0900)
committertaesub.kim <taesub.kim@samsung.com>
Wed, 27 Nov 2013 05:19:08 +0000 (14:19 +0900)
Change-Id: I895fe63d95bc834f4598d11f124fababad7e7a4d
Signed-off-by: Taesub Kim <taesub.kim@samsung.com>
packaging/libnet-client.spec
src/include/network-internal.h
src/network-profile-intf.c
test/main.c

index 99d69a6..e0ef1de 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libnet-client
 Summary:    Network Client library (Shared library)
-Version:    0.1.77_46
+Version:    0.1.77_47
 Release:    1
 Group:      System/Network
 License:    Flora License
index 474821a..eca3c11 100644 (file)
@@ -104,6 +104,7 @@ extern "C" {
 #define CONNMAN_WIFI_SERVICE_PROFILE_PREFIX            CONNMAN_PATH "/service/wifi_"
 #define CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX                CONNMAN_PATH "/service/ethernet_"
 #define CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX       CONNMAN_PATH "/service/bluetooth_"
+#define CONNMAN_SERVICE_PROFILE_PREFIX                 CONNMAN_PATH "/service/"
 
 /** Network related Daemon Signals */
 #define NETCONFIG_SIGNAL_POWERON_COMPLETED     "PowerOnCompleted"
index 8d69879..fb6089a 100644 (file)
@@ -177,6 +177,20 @@ static int __net_telephony_init_profile_info(net_telephony_profile_info_t* ProfI
        return NET_ERR_NONE;
 }
 
+static int __net_get_service_type(gchar *obj_path)
+{
+       if (g_str_has_prefix(obj_path, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
+               return NET_DEVICE_WIFI;
+       else if (g_str_has_prefix(obj_path, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE)
+               return NET_DEVICE_CELLULAR;
+       else if (g_str_has_prefix(obj_path, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE)
+               return NET_DEVICE_ETHERNET;
+       else if (g_str_has_prefix(obj_path, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE)
+               return NET_DEVICE_BLUETOOTH;
+       else
+               return NET_DEVICE_UNKNOWN;
+}
+
 static int __net_telephony_get_profile_info(net_profile_name_t* ProfileName, net_telephony_profile_info_t *ProfileInfo)
 {
        __NETWORK_FUNC_ENTER__;
@@ -487,8 +501,7 @@ static int __net_extract_mobile_services(GVariantIter *iter,
 }
 
 static int __net_extract_all_services(GVariantIter *array,
-               net_device_t device_type, const char *service_prefix,
-               int *prof_count, net_profile_info_t **ProfilePtr)
+               const char *service_prefix, int *prof_count, net_profile_info_t **ProfilePtr)
 {
        int count = 0;
        net_profile_info_t ProfInfo = {0, };
@@ -510,12 +523,17 @@ static int __net_extract_all_services(GVariantIter *array,
                        continue;
 
                if (g_str_has_prefix(obj, service_prefix) == TRUE) {
-                       if (device_type == NET_DEVICE_WIFI &&
+                       net_device_t local_device_type = __net_get_service_type(obj);
+
+                       if (local_device_type == NET_DEVICE_UNKNOWN)
+                               continue;
+
+                       if (local_device_type == NET_DEVICE_WIFI &&
                                        g_strrstr(obj + strlen(service_prefix), "hidden") != NULL)
                                continue;
 
                        memset(&ProfInfo, 0, sizeof(net_profile_info_t));
-                       if ((Error = __net_pm_init_profile_info(device_type, &ProfInfo)) != NET_ERR_NONE) {
+                       if ((Error = __net_pm_init_profile_info(local_device_type, &ProfInfo)) != NET_ERR_NONE) {
                                NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
 
                                NET_MEMFREE(*ProfilePtr);
@@ -525,10 +543,10 @@ static int __net_extract_all_services(GVariantIter *array,
                                return Error;
                        }
 
-                       ProfInfo.profile_type = device_type;
+                       ProfInfo.profile_type = local_device_type;
                        g_strlcpy(ProfInfo.ProfileName, obj, NET_PROFILE_NAME_LEN_MAX);
 
-                       switch(device_type) {
+                       switch(local_device_type) {
                        case NET_DEVICE_WIFI:
                                g_strlcpy(ProfInfo.ProfileInfo.Wlan.net_info.ProfileName,
                                                obj, NET_PROFILE_NAME_LEN_MAX);
@@ -618,6 +636,9 @@ static int __net_extract_services(GVariantIter *message, net_device_t device_typ
        case NET_DEVICE_BLUETOOTH :
                service_prefix = CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX;
                break;
+       case NET_DEVICE_MAX :
+               service_prefix = CONNMAN_SERVICE_PROFILE_PREFIX;
+               break;
        default :
                *profile_count = 0;
                *profile_info = NULL;
@@ -626,8 +647,7 @@ static int __net_extract_services(GVariantIter *message, net_device_t device_typ
                break;
        }
 
-       Error = __net_extract_all_services(message, device_type, service_prefix,
-                       &prof_cnt, &ProfilePtr);
+       Error = __net_extract_all_services(message, service_prefix, &prof_cnt, &ProfilePtr);
        if (Error != NET_ERR_NONE) {
                NETWORK_LOG(NETWORK_ERROR, "Failed to extract services from received message\n");
                *profile_count = 0;
@@ -1866,6 +1886,7 @@ int _net_get_profile_list(net_device_t device_type,
        case NET_DEVICE_WIFI:
        case NET_DEVICE_ETHERNET:
        case NET_DEVICE_BLUETOOTH:
+       case NET_DEVICE_MAX:
                g_variant_get(message, "(a(oa{sv}))", &iter);
                Error = __net_extract_services(iter, device_type, profile_info, profile_count);
 
@@ -2165,7 +2186,8 @@ EXPORT_API int net_get_profile_list(net_device_t device_type, net_profile_info_t
        if (device_type != NET_DEVICE_CELLULAR &&
            device_type != NET_DEVICE_WIFI &&
            device_type != NET_DEVICE_ETHERNET &&
-           device_type != NET_DEVICE_BLUETOOTH) {
+           device_type != NET_DEVICE_BLUETOOTH &&
+           device_type != NET_DEVICE_MAX) {
                NETWORK_LOG(NETWORK_ERROR, "Not Supported\n");
                __NETWORK_FUNC_EXIT__;
                return NET_ERR_NOT_SUPPORTED;
index ec521a8..38f73cb 100644 (file)
@@ -1224,7 +1224,7 @@ static gboolean network_main_gthread(gpointer data)
                break;
 
        case 'd':
-               debug_print("Input profile type - 1:wifi, 2:mobile 3:ethernet 4:bluetooth : \n");
+               debug_print("Input profile type - 1:wifi, 2:mobile 3:ethernet 4:bluetooth 5:all : \n");
                scanf("%d", &input_int);
 
                net_device_t deviceType = NET_DEVICE_UNKNOWN;
@@ -1247,6 +1247,9 @@ static gboolean network_main_gthread(gpointer data)
                case 4:
                        deviceType = NET_DEVICE_BLUETOOTH;
                        break;
+               case 5:
+                       deviceType = NET_DEVICE_MAX;
+                       break;
                default:
                        deviceType = NET_DEVICE_UNKNOWN;
                }