Fix DNS address setting.
authorJaemin Ahn <j.m.ahn@samsung.com>
Wed, 8 May 2013 10:52:21 +0000 (19:52 +0900)
committerJaemin Ahn <j.m.ahn@samsung.com>
Wed, 8 May 2013 10:52:21 +0000 (19:52 +0900)
Change-Id: I2514be67c911c14d4f689fcab0b433e2b3d57c72
Signed-off-by: Jaemin Ahn <j.m.ahn@samsung.com>
src/NetService.cpp

index 8925e39..7d8fa9a 100644 (file)
@@ -417,33 +417,6 @@ NetService::ConvertToProfileInfo(void* pProfileHandle, const NetAccountInfo& net
 
        if (ipConfigType != CONNECTION_IP_CONFIG_TYPE_FIXED)
        {
-               if (netAccountInfo.GetDnsAddressScheme() == NET_ADDRESS_SCHEME_STATIC)
-               {
-                       if (netAccountInfo.GetPrimaryDnsAddress() != null)
-                       {
-                               pDnsAddr = _StringConverter::CopyToCharArrayN(netAccountInfo.GetPrimaryDnsAddress()->ToString());
-                               SysTryCatch(NID_NET, pDnsAddr != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-                               ret = connection_profile_set_dns_address(profileHandle, 1, CONNECTION_ADDRESS_FAMILY_IPV4, pDnsAddr);
-                               delete[] pDnsAddr;
-                               SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
-                                               "[%s] A system error has been occurred. The return value from connection_profile_set_dns_address() is %d", GetErrorMessage(E_SYSTEM), ret);
-                       }
-
-                       if (netAccountInfo.GetSecondaryDnsAddress() != null)
-                       {
-                               pDnsAddr = _StringConverter::CopyToCharArrayN(netAccountInfo.GetSecondaryDnsAddress()->ToString());
-                               SysTryCatch(NID_NET, pDnsAddr != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
-                                               "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
-
-                               ret = connection_profile_set_dns_address(profileHandle, 2, CONNECTION_ADDRESS_FAMILY_IPV4, pDnsAddr);
-                               delete[] pDnsAddr;
-                               SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
-                                               "[%s] A system error has been occurred. The return value from connection_profile_set_dns_address() is %d", GetErrorMessage(E_SYSTEM), ret);
-                       }
-               }
-
                if (netAccountInfo.GetLocalAddressScheme() == NET_ADDRESS_SCHEME_STATIC)
                {
                        ret = connection_profile_set_ip_config_type(profileHandle, CONNECTION_ADDRESS_FAMILY_IPV4, CONNECTION_IP_CONFIG_TYPE_STATIC);
@@ -470,6 +443,34 @@ NetService::ConvertToProfileInfo(void* pProfileHandle, const NetAccountInfo& net
                }
        }
 
+       if (netAccountInfo.GetDnsAddressScheme() == NET_ADDRESS_SCHEME_STATIC)
+       {
+               if (netAccountInfo.GetPrimaryDnsAddress() != null)
+               {
+                       pDnsAddr = _StringConverter::CopyToCharArrayN(netAccountInfo.GetPrimaryDnsAddress()->ToString());
+                       SysTryCatch(NID_NET, pDnsAddr != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       ret = connection_profile_set_dns_address(profileHandle, 1, CONNECTION_ADDRESS_FAMILY_IPV4, pDnsAddr);
+                       delete[] pDnsAddr;
+                       pDnsAddr = null;
+                       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_set_dns_address() is %d", GetErrorMessage(E_SYSTEM), ret);
+               }
+
+               if (netAccountInfo.GetSecondaryDnsAddress() != null)
+               {
+                       pDnsAddr = _StringConverter::CopyToCharArrayN(netAccountInfo.GetSecondaryDnsAddress()->ToString());
+                       SysTryCatch(NID_NET, pDnsAddr != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                                       "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+                       ret = connection_profile_set_dns_address(profileHandle, 2, CONNECTION_ADDRESS_FAMILY_IPV4, pDnsAddr);
+                       delete[] pDnsAddr;
+                       SysTryCatch(NID_NET, ret == CONNECTION_ERROR_NONE, r = E_SYSTEM, E_SYSTEM,
+                                       "[%s] A system error has been occurred. The return value from connection_profile_set_dns_address() is %d", GetErrorMessage(E_SYSTEM), ret);
+               }
+       }
+
        if (netAccountInfo.GetProxyAddress() != null)
        {
                proxyAddr = netAccountInfo.GetProxyAddress()->GetNetEndPoint();