merge with master
[framework/osp/net.git] / src / FNet_SystemNetConnection.cpp
index 89d817d..8c5a8ad 100644 (file)
@@ -398,6 +398,7 @@ _SystemNetConnection::InitializeNetworkFrameworkOnce(void)
 {
        result r = E_SUCCESS;
        NetAccountId accountId = INVALID_HANDLE;
+       String accountName;
 
        __pPsSystemConnectionMap = new (std::nothrow) HashMap();
        SysTryReturnVoidResult(NID_NET, __pPsSystemConnectionMap != null, E_OUT_OF_MEMORY,
@@ -413,12 +414,12 @@ _SystemNetConnection::InitializeNetworkFrameworkOnce(void)
        SysTryReturnVoidResult(NID_NET, r == E_SUCCESS, r,
                        "[%s] A system error has been occurred. Failed to initialize the network database.", GetErrorMessage(r));
 
-       String internetProfileName = _NetAccountManagerImpl::GetInternetProfileName();
-       String mmsProfileName = _NetAccountManagerImpl::GetMmsProfileName();
+       _NetProfileInfo internetProfileInfo = _NetAccountManagerImpl::GetInternetProfileInfo();
+       _NetProfileInfo mmsProfileInfo = _NetAccountManagerImpl::GetMmsProfileInfo();
        String profileName;
 
        r = _NetAccountDatabase::GetProfileName(_DEFAULT_PS_ACCOUNT_ID, profileName);
-       if (internetProfileName.IsEmpty())
+       if (internetProfileInfo.GetProfileName().IsEmpty())
        {
                SysLog(NID_NET, "Internet profile is not found.");
 
@@ -430,23 +431,29 @@ _SystemNetConnection::InitializeNetworkFrameworkOnce(void)
        }
        else
        {
-               if (internetProfileName != profileName)
+               if (internetProfileInfo.GetProfileName() != profileName)
                {
-                       SysLog(NID_NET, "Internet profile is changed. [%ls] -> [%ls]", profileName.GetPointer(), internetProfileName.GetPointer());
+                       SysLog(NID_NET, "Internet profile is changed. [%ls] -> [%ls]", profileName.GetPointer(), internetProfileInfo.GetProfileName().GetPointer());
 
                        if (!profileName.IsEmpty())
                        {
                                r = _NetAccountDatabase::RemoveAccountByAccountId(_DEFAULT_PS_ACCOUNT_ID);
                        }
 
-                       r = _NetAccountDatabase::AddAccount(internetProfileName, internetProfileName, _NET_ACCOUNT_OWNER_SYSTEM_INTERNET, accountId);
+                       r = _NetAccountDatabase::RemoveAccountByProfileName(internetProfileInfo.GetProfileName());
+
+                       accountName.Clear();
+                       accountName.Append(internetProfileInfo.GetProfileDisplayName());
+                       accountName.Append(internetProfileInfo.GetProfileName());
+
+                       r = _NetAccountDatabase::AddAccount(accountName, internetProfileInfo.GetProfileName(), _NET_ACCOUNT_OWNER_SYSTEM_INTERNET, accountId);
                }
        }
 
        profileName.Clear();
 
        r = _NetAccountDatabase::GetProfileName(_DEFAULT_MMS_ACCOUNT_ID, profileName);
-       if (mmsProfileName.IsEmpty())
+       if (mmsProfileInfo.GetProfileName().IsEmpty())
        {
                SysLog(NID_NET, "MMS profile is not found.");
 
@@ -458,21 +465,27 @@ _SystemNetConnection::InitializeNetworkFrameworkOnce(void)
        }
        else
        {
-               if (mmsProfileName != profileName)
+               if (mmsProfileInfo.GetProfileName() != profileName)
                {
-                       SysLog(NID_NET, "MMS profile is changed. [%ls] -> [%ls]", profileName.GetPointer(), mmsProfileName.GetPointer());
+                       SysLog(NID_NET, "MMS profile is changed. [%ls] -> [%ls]", profileName.GetPointer(), mmsProfileInfo.GetProfileName().GetPointer());
 
                        if (!profileName.IsEmpty())
                        {
                                r = _NetAccountDatabase::RemoveAccountByAccountId(_DEFAULT_MMS_ACCOUNT_ID);
                        }
 
-                       r = _NetAccountDatabase::AddAccount(mmsProfileName, mmsProfileName, _NET_ACCOUNT_OWNER_SYSTEM_MMS, accountId);
+                       r = _NetAccountDatabase::RemoveAccountByProfileName(mmsProfileInfo.GetProfileName());
+
+                       accountName.Clear();
+                       accountName.Append(mmsProfileInfo.GetProfileDisplayName());
+                       accountName.Append(mmsProfileInfo.GetProfileName());
+
+                       r = _NetAccountDatabase::AddAccount(accountName, mmsProfileInfo.GetProfileName(), _NET_ACCOUNT_OWNER_SYSTEM_MMS, accountId);
                }
        }
 
-       unique_ptr<IList, _CollectionDeleter> pAccountList(_NetAccountDatabase::GetAppProfileNamesN());
-       unique_ptr<IList, _CollectionDeleter> pProfileList(_NetAccountManagerImpl::GetAppProfileNamesN());
+       unique_ptr<IList, _CollectionDeleter> pAccountList(_NetAccountDatabase::GetProfileNamesN());
+       unique_ptr<IList, _CollectionDeleter> pProfileList(_NetAccountManagerImpl::GetAllProfileInfosN());
 
        if (pProfileList != null)
        {
@@ -483,22 +496,26 @@ _SystemNetConnection::InitializeNetworkFrameworkOnce(void)
                        unique_ptr<IEnumerator> pEnum(pProfileList->GetEnumeratorN());
                        if (pEnum != null)
                        {
-                               String* pProfileName = null;
+                               _NetProfileInfo* pProfileInfo = null;
                                while (pEnum->MoveNext() == E_SUCCESS)
                                {
-                                       pProfileName = dynamic_cast<String*>(pEnum->GetCurrent());
-                                       if (pProfileName != null)
+                                       pProfileInfo = dynamic_cast<_NetProfileInfo*>(pEnum->GetCurrent());
+                                       if (pProfileInfo != null)
                                        {
-                                               if (pAccountList->Contains(*pProfileName))
+                                               if (pAccountList->Contains(pProfileInfo->GetProfileName()))
                                                {
-                                                       SysLog(NID_NET, "ProfileName[%ls] is already on DB.", pProfileName->GetPointer());
-                                                       pAccountList->Remove(*pProfileName, true);
+                                                       SysLog(NID_NET, "ProfileName[%ls] is already on DB.", pProfileInfo->GetProfileName().GetPointer());
+                                                       pAccountList->Remove(pProfileInfo->GetProfileName(), true);
                                                }
                                                else
                                                {
-                                                       // OSP account
-                                                       SysLog(NID_NET, "ProfileName[%ls] is not found on DB, so add it.", pProfileName->GetPointer());
-                                                       r = _NetAccountDatabase::AddAccount(*pProfileName, *pProfileName, _NET_ACCOUNT_OWNER_OTHER, accountId);
+                                                       // OSP or Non-default account
+                                                       accountName.Clear();
+                                                       accountName.Append(pProfileInfo->GetProfileDisplayName());
+                                                       accountName.Append(pProfileInfo->GetProfileName());
+
+                                                       SysLog(NID_NET, "ProfileName[%ls] is not found on DB, so add it.", pProfileInfo->GetProfileName().GetPointer());
+                                                       r = _NetAccountDatabase::AddAccount(accountName, pProfileInfo->GetProfileName(), _NET_ACCOUNT_OWNER_OTHER, accountId);
                                                }
                                        }
                                }