net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
__NETWORK_FUNC_EXIT__;
-
return NET_ERR_NONE;
}
static int __net_telephony_init_profile_info(net_telephony_profile_info_t* ProfInfo)
{
__NETWORK_FUNC_ENTER__;
-
+
if (ProfInfo == NULL) {
NETWORK_LOG(NETWORK_ERROR, "Invalid Parameter\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
ProfInfo->DefaultConn = FALSE;
__NETWORK_FUNC_EXIT__;
-
return NET_ERR_NONE;
}
net_err_t Error = NET_ERR_NONE;
DBusMessage* result = NULL;
DBusMessageIter iter, array;
-
+
if (ProfileName == NULL || ProfileInfo == NULL) {
NETWORK_LOG(NETWORK_ERROR, "Invalid parameter!\n");
+
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
if (result == NULL) {
NETWORK_LOG(NETWORK_ERROR, "_net_invoke_dbus_method failed\n");
+
__NETWORK_FUNC_EXIT__;
return Error;
}
if (Error != NET_ERR_NONE) {
dbus_message_unref(result);
- __NETWORK_FUNC_EXIT__;
+ __NETWORK_FUNC_EXIT__;
return Error;
}
if (g_strcmp0(key, "path") == 0) {
dbus_message_iter_get_basic(&entry, &value);
-
+
if (value != NULL)
g_strlcpy(ProfileInfo->ProfileName, value, NET_PROFILE_NAME_LEN_MAX);
} else if (g_strcmp0(key, "apn") == 0) {
dbus_message_iter_get_basic(&entry, &value);
-
+
if (value != NULL)
g_strlcpy(ProfileInfo->Apn, value, NET_PDP_APN_LEN_MAX);
} else if (g_strcmp0(key, "auth_type") == 0) {
net_auth_type_t authType = NET_PDP_AUTH_NONE;
dbus_message_iter_get_basic(&entry, &value);
-
+
if (value != NULL)
authType = atoi(value);
static int __net_extract_wifi_info(DBusMessageIter *array, net_profile_info_t* ProfInfo)
{
- __NETWORK_FUNC_ENTER__;
-
net_err_t Error = NET_ERR_NONE;
net_wifi_profile_info_t *Wlan = &(ProfInfo->ProfileInfo.Wlan);
+ __NETWORK_FUNC_ENTER__;
+
while (dbus_message_iter_get_arg_type(array) == DBUS_TYPE_DICT_ENTRY) {
DBusMessageIter entry, variant, sub_array;
const char *key = NULL;
if (value != NULL)
g_strlcpy(Wlan->security_info.authentication.eap.private_key_passwd,
value, NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1);
-
- } else {
- __net_extract_common_info(key, &variant, ProfInfo);
- }
+ } else
+ Error = __net_extract_common_info(key, &variant, ProfInfo);
dbus_message_iter_next(array);
}
__NETWORK_FUNC_EXIT__;
-
return Error;
}
else
ProfInfo->ProfileInfo.Pdp.SetupRequired = FALSE;
} else
- __net_extract_common_info(key, &variant, ProfInfo);
+ Error = __net_extract_common_info(key, &variant, ProfInfo);
dbus_message_iter_next(array);
}
}
__NETWORK_FUNC_EXIT__;
-
return Error;
}
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &variant);
- __net_extract_common_info(key, &variant, ProfInfo);
+ Error = __net_extract_common_info(key, &variant, ProfInfo);
dbus_message_iter_next(array);
}
__NETWORK_FUNC_EXIT__;
-
return Error;
}
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &variant);
- __net_extract_common_info(key, &variant, ProfInfo);
+ Error = __net_extract_common_info(key, &variant, ProfInfo);
dbus_message_iter_next(array);
}
dbus_message_iter_next(&entry);
dbus_message_iter_recurse(&entry, &dict);
dbus_message_iter_get_basic(&dict, &temp);
+
if (g_strcmp0(temp, "wifi") == 0)
profileType = NET_DEVICE_WIFI;
else if (g_strcmp0(temp, "cellular") == 0)
__NETWORK_FUNC_EXIT__;
return Error;
}
-
+
ProfInfo->profile_type = NET_DEVICE_WIFI;
g_strlcpy(ProfInfo->ProfileName, ProfileName, NET_PROFILE_NAME_LEN_MAX);
g_strlcpy(ProfInfo->ProfileInfo.Wlan.net_info.ProfileName,
ProfileName, NET_PROFILE_NAME_LEN_MAX);
Error = __net_extract_wifi_info(&array, ProfInfo);
-
} else if (profileType == NET_DEVICE_CELLULAR) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_CELLULAR, ProfInfo)) != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
__NETWORK_FUNC_EXIT__;
return Error;
}
-
+
ProfInfo->profile_type = NET_DEVICE_CELLULAR;
g_strlcpy(ProfInfo->ProfileName, ProfileName, NET_PROFILE_NAME_LEN_MAX);
g_strlcpy(ProfInfo->ProfileInfo.Pdp.net_info.ProfileName,
ProfileName, NET_PROFILE_NAME_LEN_MAX);
-
+
Error = __net_extract_mobile_info(&array, ProfInfo);
} else if (profileType == NET_DEVICE_ETHERNET) {
if ((Error = __net_pm_init_profile_info(NET_DEVICE_ETHERNET, ProfInfo)) != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR, "Not supported profile type\n");
__NETWORK_FUNC_EXIT__;
return NET_ERR_NOT_SUPPORTED;
- }
+ }
if (Error != NET_ERR_NONE) {
NETWORK_LOG(NETWORK_ERROR,
const char internet_suffix[] = "_1";
char *suffix = NULL;
const char *obj = NULL;
- net_profile_info_t ProfInfo = {0, };
+ net_device_t device_type;
__NETWORK_FUNC_ENTER__;
- if (array == NULL) {
+ if (array == NULL || ProfilePtr == NULL) {
NETWORK_LOG(NETWORK_ERROR, "Invalid parameter\n");
-
__NETWORK_FUNC_EXIT__;
return NET_ERR_INVALID_PARAM;
}
continue;
}
- if (g_str_has_prefix(obj,
- CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE) {
- suffix = strrchr(obj, '_');
+ if (g_str_has_prefix(obj, CONNMAN_CELLULAR_SERVICE_PROFILE_PREFIX) == TRUE)
+ device_type = NET_DEVICE_CELLULAR;
+ else if (g_str_has_prefix(obj, CONNMAN_WIFI_SERVICE_PROFILE_PREFIX) == TRUE)
+ device_type = NET_DEVICE_WIFI;
+ else if (g_str_has_prefix(obj, CONNMAN_ETHERNET_SERVICE_PROFILE_PREFIX) == TRUE)
+ device_type = NET_DEVICE_ETHERNET;
+ else if (g_str_has_prefix(obj, CONNMAN_BLUETOOTH_SERVICE_PROFILE_PREFIX) == TRUE)
+ device_type = NET_DEVICE_BLUETOOTH;
+ else
+ return NET_ERR_NO_SERVICE;
- if (g_strcmp0(suffix, internet_suffix) == 0) {
- dbus_message_iter_next(&entry);
- dbus_message_iter_recurse(&entry, &next);
+ Error = __net_pm_init_profile_info(device_type, ProfilePtr);
+ if (Error != NET_ERR_NONE) {
+ NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+ }
- Error = __net_pm_init_profile_info(NET_DEVICE_CELLULAR, &ProfInfo);
- if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Failed to init profile\n");
+ ProfilePtr->profile_type = device_type;
+ g_strlcpy(ProfilePtr->ProfileName, obj, NET_PROFILE_NAME_LEN_MAX);
- __NETWORK_FUNC_EXIT__;
- return Error;
- }
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &next);
- ProfInfo.profile_type = NET_DEVICE_CELLULAR;
- g_strlcpy(ProfInfo.ProfileName, obj, NET_PROFILE_NAME_LEN_MAX);
- g_strlcpy(ProfInfo.ProfileInfo.Pdp.net_info.ProfileName,
- obj, NET_PROFILE_NAME_LEN_MAX);
+ if (device_type == NET_DEVICE_CELLULAR) {
+ suffix = strrchr(obj, '_');
- Error = __net_extract_mobile_info(&next, &ProfInfo);
- if (Error != NET_ERR_NONE) {
- NETWORK_LOG(NETWORK_ERROR, "Fail to extract service info\n");
+ if (g_strcmp0(suffix, internet_suffix) == 0) {
+ g_strlcpy(ProfilePtr->ProfileInfo.Pdp.net_info.ProfileName,
+ obj, NET_PROFILE_NAME_LEN_MAX);
- __NETWORK_FUNC_EXIT__;
- return Error;
- }
+ Error = __net_extract_mobile_info(&next, ProfilePtr);
+ break;
+ }
+ } else if (device_type == NET_DEVICE_WIFI) {
+ g_strlcpy(ProfilePtr->ProfileInfo.Wlan.net_info.ProfileName,
+ obj, NET_PROFILE_NAME_LEN_MAX);
- memcpy(ProfilePtr, &ProfInfo, sizeof(net_profile_info_t));
+ Error = __net_extract_wifi_info(&next, ProfilePtr);
+ break;
+ } else if (device_type == NET_DEVICE_ETHERNET) {
+ g_strlcpy(ProfilePtr->ProfileInfo.Ethernet.net_info.ProfileName,
+ obj, NET_PROFILE_NAME_LEN_MAX);
- NETWORK_LOG(NETWORK_HIGH, "Default: %s\n", ProfInfo.ProfileName);
+ Error = __net_extract_ethernet_info(&next, ProfilePtr);
+ break;
+ } else if (device_type == NET_DEVICE_BLUETOOTH) {
+ g_strlcpy(ProfilePtr->ProfileInfo.Bluetooth.net_info.ProfileName,
+ obj, NET_PROFILE_NAME_LEN_MAX);
- goto found;
- }
- } else
- goto found;
+ Error = __net_extract_bluetooth_info(&next, ProfilePtr);
+ break;
+ }
dbus_message_iter_next(array);
}
+ if (Error == NET_ERR_NONE &&
+ (ProfilePtr->ProfileState == NET_STATE_TYPE_READY ||
+ ProfilePtr->ProfileState == NET_STATE_TYPE_ONLINE))
+ goto found;
+
NETWORK_LOG(NETWORK_ERROR, "Fail to find default service\n");
Error = NET_ERR_NO_SERVICE;
+ __NETWORK_FUNC_EXIT__;
+ return Error;
+
found:
+ NETWORK_LOG(NETWORK_HIGH, "Default: %s\n", ProfilePtr->ProfileName);
+
__NETWORK_FUNC_EXIT__;
return Error;
}
int _net_get_default_profile_info(net_profile_info_t *profile_info)
{
- __NETWORK_FUNC_ENTER__;
-
net_err_t Error = NET_ERR_NONE;
DBusMessage *message = NULL;
DBusMessageIter iter, dict;
+ __NETWORK_FUNC_ENTER__;
+
message = _net_invoke_dbus_method(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH,
CONNMAN_MANAGER_INTERFACE, "GetServices", NULL, &Error);
if (message == NULL) {
NETWORK_LOG(NETWORK_ERROR, "Failed to get profile list\n");
-
__NETWORK_FUNC_EXIT__;
- return Error;
+ return NET_ERR_NO_SERVICE;
}
dbus_message_iter_init(message, &iter);
dbus_message_iter_recurse(&iter, &dict);
+
Error = __net_extract_default_profile(&dict, profile_info);
dbus_message_unref(message);