static const char _WIFI_LIBRARY_NAME[] = "libosp-wifi.so";
+_NetProfileInfo::_NetProfileInfo(void)
+{
+}
+
+_NetProfileInfo::_NetProfileInfo(const String& profileName, const String& profileDisplayName)
+ : __profileName(profileName)
+ , __profileDisplayName(profileDisplayName)
+{
+}
+
+_NetProfileInfo::~_NetProfileInfo(void)
+{
+}
+
+String
+_NetProfileInfo::GetProfileName(void) const
+{
+ return __profileName;
+}
+
+String
+_NetProfileInfo::GetProfileDisplayName(void) const
+{
+ return __profileDisplayName;
+}
+
_NetAccountManagerImpl::_NetAccountManagerImpl(void)
: __pConnectionHandle(null)
{
char* pTempProfileName = null;
String tempProfileName;
- ret = connection_profile_get_name(profileHandle, &pTempProfileName);
+ ret = connection_profile_get_id(profileHandle, &pTempProfileName);
SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+ "[%s] A system error has been occurred. The return value from connection_profile_get_id() is %d",
GetErrorMessage(E_SYSTEM), ret);
tempProfileName = String(pTempProfileName);
return matchingProfileHandle;
}
-String
-_NetAccountManagerImpl::GetInternetProfileName(void)
+_NetProfileInfo
+_NetAccountManagerImpl::GetInternetProfileInfo(void)
{
ClearLastResult();
- String profileName;
+ _NetProfileInfo profileInfo;
int ret = CONNECTION_ERROR_NONE;
connection_h connectionHandle = null;
- connection_profile_iterator_h iterator = null;
connection_profile_h profileHandle = null;
- connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_WIFI;
ret = connection_create(&connectionHandle);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileInfo, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_create() is %d",
GetErrorMessage(E_SYSTEM), ret);
unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
- ret = connection_get_profile_iterator(connectionHandle,
- CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
+ ret = connection_get_default_cellular_service_profile(connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET, &profileHandle);
+ if ((ret != CONNECTION_ERROR_NONE) || (profileHandle == null))
+ {
+ SysLog(NID_NET, "Internet profile is not found, so search a prepaid-Internet profile.");
+
+ ret = connection_get_default_cellular_service_profile(connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET, &profileHandle);
+ }
+ SysTryReturn(NID_NET, profileHandle != null, profileInfo, E_INVALID_ACCOUNT,
+ "[%s] Internet(incl. prepaid) profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+ unique_ptr<void, _ProfileDeleter> pProfileHandle(profileHandle);
+
+ char* pProfileName = null;
+ char* pProfileDisplayName = null;
+ String profileName;
+ String profileDisplayName;
+
+ ret = connection_profile_get_id(profileHandle, &pProfileName);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileInfo, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_profile_get_id() is %d",
GetErrorMessage(E_SYSTEM), ret);
- unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
- ret = connection_profile_iterator_next(iterator, &profileHandle);
- while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
- {
- char* pProfileName = null;
+ profileName = String(pProfileName);
+ free(pProfileName);
- ret = connection_profile_get_type(profileHandle, &profileType);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
- GetErrorMessage(E_SYSTEM), ret);
+ ret = connection_profile_get_name(profileHandle, &pProfileDisplayName);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileInfo, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+ GetErrorMessage(E_SYSTEM), ret);
- if (profileType == CONNECTION_PROFILE_TYPE_CELLULAR)
- {
- connection_cellular_service_type_e serviceType = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+ profileDisplayName = String(pProfileDisplayName);
+ free(pProfileDisplayName);
- ret = connection_profile_get_cellular_service_type(profileHandle, &serviceType);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_profile_get_cellular_service_type() is %d",
- GetErrorMessage(E_SYSTEM), ret);
+ profileInfo = _NetProfileInfo(profileName, profileDisplayName);
- ret = connection_profile_get_name(profileHandle, &pProfileName);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
- GetErrorMessage(E_SYSTEM), ret);
+ SysLog(NID_NET, "GetInternetProfileInfo() has been succeeded with profile[%ls][%ls]", profileInfo.GetProfileDisplayName().GetPointer(), profileInfo.GetProfileName().GetPointer());
- profileName = String(pProfileName);
- free(pProfileName);
+ return profileInfo;
+}
- if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET)
- || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET))
- {
- SysLog(NID_NET, "Internet profile is found.");
- break;
- }
- else
- {
- profileName.Clear();
- }
- }
- else
- {
- SysLog(NID_NET, "Ignore non-cellular profile.");
- }
+_NetProfileInfo
+_NetAccountManagerImpl::GetMmsProfileInfo(void)
+{
+ ClearLastResult();
- profileHandle = null;
- ret = connection_profile_iterator_next(iterator, &profileHandle);
+ _NetProfileInfo profileInfo;
+ int ret = CONNECTION_ERROR_NONE;
+ connection_h connectionHandle = null;
+ connection_profile_h profileHandle = null;
+
+ ret = connection_create(&connectionHandle);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileInfo, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_create() is %d",
+ GetErrorMessage(E_SYSTEM), ret);
+ unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
+
+ ret = connection_get_default_cellular_service_profile(connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_MMS, &profileHandle);
+ if ((ret != CONNECTION_ERROR_NONE) || (profileHandle == null))
+ {
+ SysLog(NID_NET, "MMS profile is not found, so search a prepaid-MMS profile.");
+
+ ret = connection_get_default_cellular_service_profile(connectionHandle, CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS, &profileHandle);
}
+ SysTryReturn(NID_NET, profileHandle != null, profileInfo, E_INVALID_ACCOUNT,
+ "[%s] MMS(incl. prepaid) profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+ unique_ptr<void, _ProfileDeleter> pProfileHandle(profileHandle);
+
+ char* pProfileName = null;
+ char* pProfileDisplayName = null;
+ String profileName;
+ String profileDisplayName;
+
+ ret = connection_profile_get_id(profileHandle, &pProfileName);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileInfo, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_profile_get_id() is %d",
+ GetErrorMessage(E_SYSTEM), ret);
- SysTryReturn(NID_NET, !profileName.IsEmpty(), profileName, E_INVALID_ACCOUNT,
- "[%s] Internet profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
+ profileName = String(pProfileName);
+ free(pProfileName);
- SysLog(NID_NET, "GetInternetProfileName() has been succeeded with profile:%ls", profileName.GetPointer());
+ ret = connection_profile_get_name(profileHandle, &pProfileDisplayName);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileInfo, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
+ GetErrorMessage(E_SYSTEM), ret);
+
+ profileDisplayName = String(pProfileDisplayName);
+ free(pProfileDisplayName);
+
+ profileInfo = _NetProfileInfo(profileName, profileDisplayName);
- return profileName;
+ SysLog(NID_NET, "GetMmsProfileInfo() has been succeeded with profile[%ls][%ls]", profileInfo.GetProfileDisplayName().GetPointer(), profileInfo.GetProfileName().GetPointer());
+
+ return profileInfo;
}
-String
-_NetAccountManagerImpl::GetMmsProfileName(void)
+IList*
+_NetAccountManagerImpl::GetAppProfileNamesN(void)
{
ClearLastResult();
- String profileName;
+ result r = E_SUCCESS;
int ret = CONNECTION_ERROR_NONE;
connection_h connectionHandle = null;
connection_profile_iterator_h iterator = null;
connection_profile_type_e profileType = CONNECTION_PROFILE_TYPE_WIFI;
ret = connection_create(&connectionHandle);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_create() is %d",
GetErrorMessage(E_SYSTEM), ret);
unique_ptr<void, _ConnectionDeleter> pConnectionHandle(connectionHandle);
- ret = connection_get_profile_iterator(connectionHandle,
- CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+ unique_ptr<ArrayList, _CollectionDeleter> pList(new (std::nothrow) ArrayList());
+ SysTryReturn(NID_NET, pList != null, null, E_OUT_OF_MEMORY,
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = pList->Construct();
+ SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+
+ ret = connection_get_profile_iterator(connectionHandle, CONNECTION_ITERATOR_TYPE_REGISTERED, &iterator);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_get_profile_iterator() is %d",
GetErrorMessage(E_SYSTEM), ret);
unique_ptr<void, _ProfileIteratorDeleter> pIterator(iterator);
char* pProfileName = null;
ret = connection_profile_get_type(profileHandle, &profileType);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
- GetErrorMessage(E_SYSTEM), ret);
+ GetErrorMessage(E_SYSTEM), ret);
if (profileType == CONNECTION_PROFILE_TYPE_CELLULAR)
{
connection_cellular_service_type_e serviceType = CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
- ret = connection_profile_get_cellular_service_type(profileHandle,
- &serviceType);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
+ ret = connection_profile_get_cellular_service_type(profileHandle, &serviceType);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_profile_get_cellular_service_type() is %d",
GetErrorMessage(E_SYSTEM), ret);
- ret = connection_profile_get_name(profileHandle, &pProfileName);
- SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, profileName, E_SYSTEM,
- "[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
- GetErrorMessage(E_SYSTEM), ret);
+ if (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION)
+ {
+ ret = connection_profile_get_id(profileHandle, &pProfileName);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_profile_get_id() is %d",
+ GetErrorMessage(E_SYSTEM), ret);
- profileName = String(pProfileName);
- free(pProfileName);
+ unique_ptr<String> pProfileNameString(new (std::nothrow) String(pProfileName));
+ free(pProfileName);
+ SysTryReturn(NID_NET, pProfileNameString != null, null, E_OUT_OF_MEMORY,
+ "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
- if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_MMS)
- || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS))
- {
- SysLog(NID_NET, "MMS profile is found.");
- break;
+ r = pList->Add(*pProfileNameString);
+ SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ pProfileNameString.release();
}
else
{
- profileName.Clear();
+ SysLog(NID_NET, "Ignore non-app profile.");
}
}
else
ret = connection_profile_iterator_next(iterator, &profileHandle);
}
- SysTryReturn(NID_NET, !profileName.IsEmpty(), profileName, E_INVALID_ACCOUNT,
- "[%s] MMS profile is not found.", GetErrorMessage(E_INVALID_ACCOUNT));
-
- SysLog(NID_NET, "GetMmsProfileName() has been succeeded with profile:%ls", profileName.GetPointer());
+ SysLog(NID_NET, "GetAppProfileNamesN() has been succeeded with profiles count:%d", pList->GetCount());
- return profileName;
+ return pList.release();
}
IList*
-_NetAccountManagerImpl::GetAppProfileNamesN(void)
+_NetAccountManagerImpl::GetAllProfileInfosN(void)
{
ClearLastResult();
ret = connection_profile_iterator_next(iterator, &profileHandle);
while ((ret == CONNECTION_ERROR_NONE) && (profileHandle != null))
{
- char* pProfileName = null;
-
ret = connection_profile_get_type(profileHandle, &profileType);
SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_profile_get_type() is %d",
"[%s] A system error has been occurred. The return value from connection_profile_get_cellular_service_type() is %d",
GetErrorMessage(E_SYSTEM), ret);
- if (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION)
+ if ((serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET)
+ || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET)
+ || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_MMS)
+ || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS)
+ || (serviceType == CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION))
{
- ret = connection_profile_get_name(profileHandle, &pProfileName);
+ char* pProfileName = null;
+ char* pProfileDisplayName = null;
+ String profileName;
+ String profileDisplayName;
+
+ ret = connection_profile_get_id(profileHandle, &pProfileName);
+ SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
+ "[%s] A system error has been occurred. The return value from connection_profile_get_id() is %d",
+ GetErrorMessage(E_SYSTEM), ret);
+ profileName = String(pProfileName);
+ free(pProfileName);
+
+ ret = connection_profile_get_name(profileHandle, &pProfileDisplayName);
SysTryReturn(NID_NET, ret == CONNECTION_ERROR_NONE, null, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_profile_get_name() is %d",
GetErrorMessage(E_SYSTEM), ret);
+ profileDisplayName = String(pProfileDisplayName);
+ free(pProfileDisplayName);
- unique_ptr<String> pProfileNameString(new (std::nothrow) String(pProfileName));
- free(pProfileName);
- SysTryReturn(NID_NET, pProfileNameString != null, null, E_OUT_OF_MEMORY,
- "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ unique_ptr<_NetProfileInfo> pProfileInfo(new (std::nothrow) _NetProfileInfo(profileName, profileDisplayName));
- r = pList->Add(*pProfileNameString);
+ SysLog(NID_NET, "Cellular profile is found: [%d][%ls][%ls].", serviceType, profileDisplayName.GetPointer(), profileName.GetPointer());
+
+ r = pList->Add(*pProfileInfo);
SysTryReturn(NID_NET, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
- pProfileNameString.release();
+ pProfileInfo.release();
}
else
{
ret = connection_profile_iterator_next(iterator, &profileHandle);
}
- SysLog(NID_NET, "GetAppProfileNamesN() has been succeeded with profiles count:%d", pList->GetCount());
+ SysLog(NID_NET, "GetAllProfileInfosN() has been succeeded with profiles count:%d", pList->GetCount());
return pList.release();
}