2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FNetWifi_WifiUtility.cpp
20 * @brief This is the implementation file for _WifiUtility class.
23 #include <unique_ptr.h>
24 #include <FBaseColArrayList.h>
25 #include <FBaseColAllElementsDeleter.h>
26 #include <FBaseString.h>
27 #include <FBaseSysLog.h>
28 #include <FNetIpAddress.h>
29 #include <FNetIp4Address.h>
30 #include <FNetWifiWifiBssInfo.h>
31 #include <FNetWifiWifiSecurityInfo.h>
32 #include "FNetWifi_WifiUtility.h"
33 #include "FNetWifi_WifiBssInfoImpl.h"
34 #include "FNetWifi_WifiSecurityInfoImpl.h"
38 using namespace Tizen::Base;
39 using namespace Tizen::Base::Collection;
40 using namespace Tizen::Net;
42 namespace Tizen { namespace Net { namespace Wifi {
44 _WifiUtility::_WifiUtility(void)
48 _WifiUtility::~_WifiUtility(void)
52 WifiAuthenticationType
53 _WifiUtility::ConvertAuthType(wifi_security_type_e securityMode, wifi_encryption_type_e encryptionMode)
55 WifiAuthenticationType authenticationType = WIFI_AUTHENTICATION_OPEN;
59 case WIFI_SECURITY_TYPE_NONE:
60 authenticationType = WIFI_AUTHENTICATION_OPEN;
63 case WIFI_SECURITY_TYPE_WEP:
64 authenticationType = WIFI_AUTHENTICATION_SHARED;
67 case WIFI_SECURITY_TYPE_EAP:
69 if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP)
71 authenticationType = WIFI_AUTHENTICATION_WPA;
73 else if (encryptionMode == WIFI_ENCRYPTION_TYPE_AES
74 || encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED)
76 authenticationType = WIFI_AUTHENTICATION_WPA2;
80 case WIFI_SECURITY_TYPE_WPA_PSK:
81 if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP)
83 authenticationType = WIFI_AUTHENTICATION_WPA_PSK;
85 else if (encryptionMode == WIFI_ENCRYPTION_TYPE_AES)
87 authenticationType = WIFI_AUTHENTICATION_WPA2_PSK;
91 authenticationType = WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK;
98 return authenticationType;
102 _WifiUtility::ConvertSecurityType(WifiAuthenticationType authMode)
104 wifi_security_type_e authenticationType = WIFI_SECURITY_TYPE_NONE;
108 case WIFI_AUTHENTICATION_OPEN:
110 authenticationType = WIFI_SECURITY_TYPE_NONE;
113 case WIFI_AUTHENTICATION_SHARED:
115 authenticationType = WIFI_SECURITY_TYPE_WEP;
118 case WIFI_AUTHENTICATION_WPA:
119 case WIFI_AUTHENTICATION_WPA2:
121 authenticationType = WIFI_SECURITY_TYPE_EAP;
124 case WIFI_AUTHENTICATION_WPA_PSK:
126 authenticationType = WIFI_SECURITY_TYPE_WPA_PSK;
129 case WIFI_AUTHENTICATION_WPA2_PSK:
131 authenticationType = WIFI_SECURITY_TYPE_WPA_PSK;
138 return authenticationType;
142 _WifiUtility::ConvertRadioChannel(int frequency)
144 WifiRadioChannel radioChannel = WIFI_RADIO_CHANNEL_UNKNOWN;
149 radioChannel = WIFI_RADIO_CHANNEL_1;
152 radioChannel = WIFI_RADIO_CHANNEL_2;
155 radioChannel = WIFI_RADIO_CHANNEL_3;
158 radioChannel = WIFI_RADIO_CHANNEL_4;
161 radioChannel = WIFI_RADIO_CHANNEL_5;
164 radioChannel = WIFI_RADIO_CHANNEL_6;
167 radioChannel = WIFI_RADIO_CHANNEL_7;
170 radioChannel = WIFI_RADIO_CHANNEL_8;
173 radioChannel = WIFI_RADIO_CHANNEL_9;
176 radioChannel = WIFI_RADIO_CHANNEL_10;
179 radioChannel = WIFI_RADIO_CHANNEL_11;
182 radioChannel = WIFI_RADIO_CHANNEL_12;
185 radioChannel = WIFI_RADIO_CHANNEL_13;
188 radioChannel = WIFI_RADIO_CHANNEL_14;
191 radioChannel = WIFI_RADIO_CHANNEL_UNKNOWN;
199 _WifiUtility::ConvertPercentagetoRssiValue(char val)
220 _WifiUtility::ConvertLeveltoRssiValue(wifi_rssi_level_e val)
223 SysLog(NID_NET_WIFI, "Enter: [Rssi Level %d]", val);
227 case WIFI_RSSI_LEVEL_4:
230 case WIFI_RSSI_LEVEL_3:
233 case WIFI_RSSI_LEVEL_2:
236 case WIFI_RSSI_LEVEL_1:
243 SysLog(NID_NET_WIFI, "Exit: [Rssi dbm %ld]", rssiValue);
249 _WifiUtility::ConvertEncryptionType(wifi_encryption_type_e encryptionMode)
251 WifiEncryptionType encryptionType = WIFI_ENCRYPTION_NONE;
253 switch (encryptionMode)
255 case WIFI_ENCRYPTION_TYPE_NONE:
257 encryptionType = WIFI_ENCRYPTION_NONE;
260 case WIFI_ENCRYPTION_TYPE_WEP:
262 encryptionType = WIFI_ENCRYPTION_WEP;
265 case WIFI_ENCRYPTION_TYPE_TKIP:
267 encryptionType = WIFI_ENCRYPTION_TKIP;
270 case WIFI_ENCRYPTION_TYPE_AES:
272 encryptionType = WIFI_ENCRYPTION_AES;
275 case WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED:
277 encryptionType = WIFI_ENCRYPTION_TKIP_AES_MIXED;
284 return encryptionType;
287 wifi_encryption_type_e
288 _WifiUtility::ConvertEncryptionType(WifiEncryptionType encryptionMode)
290 wifi_encryption_type_e encryptionType = WIFI_ENCRYPTION_TYPE_NONE;
292 switch (encryptionMode)
294 case WIFI_ENCRYPTION_NONE:
296 encryptionType = WIFI_ENCRYPTION_TYPE_NONE;
299 case WIFI_ENCRYPTION_WEP:
301 encryptionType = WIFI_ENCRYPTION_TYPE_WEP;
304 case WIFI_ENCRYPTION_TKIP:
306 encryptionType = WIFI_ENCRYPTION_TYPE_TKIP;
309 case WIFI_ENCRYPTION_AES:
311 encryptionType = WIFI_ENCRYPTION_TYPE_AES;
314 case WIFI_ENCRYPTION_TKIP_AES_MIXED:
316 encryptionType = WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED;
323 return encryptionType;
327 _WifiUtility::ConvertEapType(wifi_eap_type_e eapType, wifi_eap_auth_type_e eapAuthType)
329 WifiEapType eapReturnType = WIFI_EAP_NONE;
333 case WIFI_EAP_TYPE_PEAP:
334 if (eapAuthType == WIFI_EAP_AUTH_TYPE_MSCHAPV2)
336 eapReturnType = WIFI_EAP_PEAP_MSCHAPV2;
338 else if(eapAuthType == WIFI_EAP_AUTH_TYPE_GTC)
340 eapReturnType = WIFI_EAP_PEAP_GTC;
344 SysLog(NID_NET_WIFI,"Not supported EAP authentication type.");
347 case WIFI_EAP_TYPE_TLS:
348 SysLog(NID_NET_WIFI,"Not supported EAP TLS.");
350 case WIFI_EAP_TYPE_TTLS:
351 if (eapAuthType == WIFI_EAP_AUTH_TYPE_MSCHAPV2)
353 eapReturnType = WIFI_EAP_TTLS_MSCHAPV2;
357 SysLog(NID_NET_WIFI,"Not supported EAP authentication type.");
360 case WIFI_EAP_TYPE_SIM:
361 eapReturnType = WIFI_EAP_SIM;
363 case WIFI_EAP_TYPE_AKA:
364 eapReturnType = WIFI_EAP_AKA;
370 return eapReturnType;
374 _WifiUtility::ConvertEapType(WifiEapType eapType)
376 wifi_eap_type_e eapReturnType = WIFI_EAP_TYPE_PEAP;
380 eapReturnType = WIFI_EAP_TYPE_SIM;
383 eapReturnType = WIFI_EAP_TYPE_AKA;
385 case WIFI_EAP_TTLS_MSCHAPV2:
386 eapReturnType = WIFI_EAP_TYPE_TTLS;
388 case WIFI_EAP_PEAP_MSCHAPV2:
389 eapReturnType = WIFI_EAP_TYPE_PEAP;
391 case WIFI_EAP_PEAP_GTC:
392 eapReturnType = WIFI_EAP_TYPE_PEAP;
395 eapReturnType = WIFI_EAP_TYPE_TLS;
401 return eapReturnType;
405 _WifiUtility::ConvertEapAuthType(WifiEapType eapType)
407 wifi_eap_auth_type_e eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
411 eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
414 eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
416 case WIFI_EAP_TTLS_MSCHAPV2:
417 eapAuthType = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
419 case WIFI_EAP_PEAP_MSCHAPV2:
420 eapAuthType = WIFI_EAP_AUTH_TYPE_MSCHAPV2;
422 case WIFI_EAP_PEAP_GTC:
423 eapAuthType = WIFI_EAP_AUTH_TYPE_GTC;
426 eapAuthType = WIFI_EAP_AUTH_TYPE_NONE;
435 _WifiUtility::ConvertMacAddress(char macAddress[])
437 static const int MAX_MAC_ADDRESS_LENGTH = 17;
438 String convertMacAddress;
440 for (int i = 0; i < MAX_MAC_ADDRESS_LENGTH; i++)
442 if (macAddress[i] == ':')
444 convertMacAddress.Append('-');
448 convertMacAddress.Append(macAddress[i]);
452 return convertMacAddress;
456 _WifiUtility::GetBssIdFromApHandle(wifi_ap_h pApHandle)
459 int error = wifi_ap_get_bssid(pApHandle, &pBssid);
460 SysTryReturn(NID_NET_WIFI, error == WIFI_ERROR_NONE && pBssid != null, String(), E_OPERATION_FAILED,
461 "[E_OPERATION_FAILED] Getting the BSSID of the AP has failed. [0x%08X].", error);
463 String bssId(pBssid);
470 _WifiUtility::CreateWifiBssInfoInstanceN(wifi_ap_h& pApHandle)
472 unique_ptr<WifiBssInfo> pBssInfo;
473 _WifiBssInfoImpl* pBssInfoImpl = null;
474 result r = E_SUCCESS;
475 int apRes = WIFI_ERROR_NONE;
477 WifiSecurityInfo secuInfo;
478 _WifiSecurityInfoImpl* pSecuInfoImpl = null;
480 wifi_ip_config_type_e ipType = WIFI_IP_CONFIG_TYPE_NONE;
481 NetAddressScheme netIpScheme = NET_ADDRESS_SCHEME_NONE;
482 char* pAddrStr = null;
483 unique_ptr<IpAddress> pAddress;
484 wifi_proxy_type_e proxyType = WIFI_PROXY_TYPE_DIRECT;
485 NetProxyType netProxyType = NET_PROXY_TYPE_NONE;
487 pBssInfo.reset(_WifiBssInfoImpl::CreateWifiBssInfoN());
488 SysTryReturn(NID_NET_WIFI, pBssInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
490 pBssInfoImpl = _WifiBssInfoImpl::GetInstance(*pBssInfo);
491 pBssInfoImpl->SetBssHandle(pApHandle);
495 apRes = wifi_ap_get_essid(pApHandle, &pSsid);
496 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
497 "[E_OPERATION_FAILED] Getting the SSID of the AP has failed. [0x%08X].", apRes);
498 pBssInfoImpl->SetSsid(String(pSsid));
503 apRes = wifi_ap_get_bssid(pApHandle, &pBssid);
504 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
505 "[E_OPERATION_FAILED] Getting the BSSID of the AP has failed. [0x%08X].", apRes);
506 pBssInfoImpl->SetBssId(ConvertMacAddress(pBssid));
509 // Security type - Authentication type & Encryption type
510 wifi_security_type_e secType;
511 apRes = wifi_ap_get_security_type(pApHandle, &secType);
512 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
513 "[E_OPERATION_FAILED] Getting the security type of the AP has failed. [0x%08X].", apRes);
515 wifi_encryption_type_e encType;
516 apRes = wifi_ap_get_encryption_type(pApHandle, &encType);
517 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
518 "[E_OPERATION_FAILED] Getting the encryption type of the AP has failed. [0x%08X].", apRes);
520 SysLog(NID_NET_WIFI, "SSID : %ls security type : %d encryption type : %d", pBssInfoImpl->GetSsid().GetPointer(), secType, encType);
522 pSecuInfoImpl = _WifiSecurityInfoImpl::GetInstance(secuInfo);
523 pSecuInfoImpl->SetAuthenticationType(ConvertAuthType(secType, encType));
524 pSecuInfoImpl->SetEncryptionType(ConvertEncryptionType(encType));
525 pBssInfoImpl->SetSecurityInfo(secuInfo);
528 pBssInfoImpl->SetBssType(WIFI_BSS_TYPE_INFRASTRUCTURE);
532 apRes = wifi_ap_get_frequency(pApHandle, &frequency);
533 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
534 "[E_OPERATION_FAILED] Getting the frequency band of the AP has failed. [0x%08X].", apRes);
535 pBssInfoImpl->SetRadioChannel(ConvertRadioChannel(frequency));
539 apRes = wifi_ap_get_rssi(pApHandle, &rssi);
540 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
541 "[E_OPERATION_FAILED] Getting the RSSI value of the AP has failed. [0x%08X].", apRes);
542 pBssInfoImpl->SetRssi(ConvertPercentagetoRssiValue(rssi));
546 apRes = wifi_ap_get_max_speed(pApHandle, &dataRate);
547 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
548 "[E_OPERATION_FAILED] Getting the MAX speed of the AP has failed. [0x%08X].", apRes);
549 pBssInfoImpl->SetDataRate(dataRate);
552 bool isKnown = false;
553 apRes = wifi_ap_is_favorite(pApHandle, &isKnown);
554 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
555 "[E_OPERATION_FAILED] Checking the AP is a known device has failed. [0x%08X].", apRes);
556 pBssInfoImpl->SetKnown(isKnown);
558 // IP Address Scheme. Only IPv4 as the address family is taken into consideration for now.
559 apRes = wifi_ap_get_ip_config_type(pApHandle, WIFI_ADDRESS_FAMILY_IPV4, &ipType);
560 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE && ipType != WIFI_IP_CONFIG_TYPE_NONE, null, E_OPERATION_FAILED,
561 "[E_OPERATION_FAILED] Getting the IP address scheme to AP has failed. [0x%08X].", apRes);
562 netIpScheme = (ipType == WIFI_IP_CONFIG_TYPE_STATIC) ? NET_ADDRESS_SCHEME_STATIC : NET_ADDRESS_SCHEME_DYNAMIC;
563 pBssInfoImpl->SetLocalAddressScheme(netIpScheme);
565 if (netIpScheme == NET_ADDRESS_SCHEME_STATIC)
567 // IP Address. Only IPv4 as the address family is taken into consideration for now.
568 apRes = wifi_ap_get_ip_address(pApHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
569 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
570 "[E_OPERATION_FAILED] Getting the IP address to AP has failed. [0x%08X].", apRes);
571 pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
574 SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
575 "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
576 pBssInfoImpl->SetLocalAddress(pAddress.release()); // ignore result
578 // Subnet Mask. Only IPv4 as the address family is taken into consideration for now.
579 apRes = wifi_ap_get_subnet_mask(pApHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
580 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
581 "[E_OPERATION_FAILED] Getting the subnet mask to AP has failed. [0x%08X].", apRes);
582 pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
585 SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
586 "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
587 pBssInfoImpl->SetSubnetMaskAddress(pAddress.release()); // ignore result
589 // Default Gateway Address. Only IPv4 as the address family is taken into consideration for now.
590 apRes = wifi_ap_get_gateway_address(pApHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
591 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
592 "[E_OPERATION_FAILED] Getting the default gateway address to AP has failed. [0x%08X].", apRes);
593 pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
596 SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
597 "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
598 pBssInfoImpl->SetDefaultGatewayAddress(pAddress.release()); // ignore result
600 // Primary DNS Address. Only IPv4 as the address family is taken into consideration for now.
601 apRes = wifi_ap_get_dns_address(pApHandle, 1, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
602 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
603 "[E_OPERATION_FAILED] Getting the primary DNS address to AP has failed. [0x%08X].", apRes);
604 pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
607 SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
608 "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
609 pBssInfoImpl->SetPrimaryDnsAddress(pAddress.release()); // ignore result
611 // Secondary DNS Address. Only IPv4 as the address family is taken into consideration for now.
612 apRes = wifi_ap_get_dns_address(pApHandle, 2, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
613 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
614 "[E_OPERATION_FAILED] Getting the secondary DNS address to AP has failed. [0x%08X].", apRes);
615 pAddress.reset(new (std::nothrow) Ip4Address(String(pAddrStr)));
618 SysTryReturn(NID_NET_WIFI, pAddress != null && r == E_SUCCESS, null, E_OPERATION_FAILED,
619 "[E_OPERATION_FAILED] Creating an Ip4Address instance has faield. (from [%s])", GetErrorMessage(r));
620 pBssInfoImpl->SetSecondaryDnsAddress(pAddress.release()); // ignore result
624 apRes = wifi_ap_get_proxy_type(pApHandle, &proxyType);
625 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
626 "[E_OPERATION_FAILED] Getting the proxy type to AP has failed. [0x%08X].", apRes);
627 netProxyType = (proxyType == WIFI_PROXY_TYPE_MANUAL) ? NET_PROXY_TYPE_MANUAL : NET_PROXY_TYPE_NONE;
628 pBssInfoImpl->SetProxyType(netProxyType);
630 if (netProxyType != NET_PROXY_TYPE_NONE)
632 // Proxy Address. Only IPv4 as the address family is taken into consideration for now.
633 apRes = wifi_ap_get_proxy_address(pApHandle, WIFI_ADDRESS_FAMILY_IPV4, &pAddrStr);
634 SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
635 "[E_OPERATION_FAILED] Getting the proxy address to AP has failed. [0x%08X].", apRes);
636 pBssInfoImpl->SetProxyAddress(String(pAddrStr)); // ignore result
640 return pBssInfo.release();
644 _WifiUtility::WifiApClone(void*& pDestHandle, void* pSrcHandle)
646 wifi_ap_h& pDestAp = static_cast<wifi_ap_h&>(pDestHandle);
647 wifi_ap_h pSrcAp = static_cast<wifi_ap_h>(pSrcHandle);
648 wifi_ap_clone(&pDestAp, pSrcAp);
652 _WifiUtility::WifiApDestory(void*& pApApHandler)
654 wifi_ap_destroy(pApApHandler);
659 _WifiUtility::CheckAddressEquality(Tizen::Net::IpAddress* pFirstAddress, Tizen::Net::IpAddress* pSecondAddress)
661 if (pFirstAddress == null && pSecondAddress == null)
663 SysLog(NID_NET_WIFI, "if (pFirstAddress == null && pSecondAddress == null) true");
666 else if(pFirstAddress == null && pSecondAddress != null)
668 SysLog(NID_NET_WIFI, "if (pFirstAddress == null && pSecondAddress == null) false");
671 else if(pFirstAddress != null && pSecondAddress == null)
673 SysLog(NID_NET_WIFI, "if (pFirstAddress == null && pSecondAddress == null) false");
677 return pFirstAddress->Equals(*pSecondAddress);
680 Tizen::Base::Collection::IList*
681 _WifiUtility::GetWifiBssInfoListCloneN(const Tizen::Base::Collection::IList* pSrcList)
683 result r = E_SUCCESS;
684 unique_ptr<ArrayList, AllElementsDeleter> pDescList;
687 SysTryReturn(NID_NET_WIFI, pSrcList != null, null, E_FAILURE, "[E_FAILURE] Failed to get the BSS info list.");
689 count = pSrcList->GetCount();
691 pDescList.reset(new (std::nothrow) ArrayList(SingleObjectDeleter));
692 SysTryReturn(NID_NET_WIFI, pDescList != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
694 r = pDescList->Construct(count);
695 r = TransExceptionsExclusive(r, E_FAILURE, E_OUT_OF_MEMORY);
696 SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Failed to construct a new BSS info list.", GetErrorMessage(r));
698 for (int i = 0; i < count; i++)
700 const WifiBssInfo* pSrcBssInfo = dynamic_cast<const WifiBssInfo*>(pSrcList->GetAt(i));
701 SysTryReturn(NID_NET_WIFI, pSrcBssInfo != null, null, E_FAILURE, "[E_FAILURE] Failed to get the BSS Info for the list.");
703 WifiBssInfo* pDescBssInfo = new (std::nothrow) WifiBssInfo(*pSrcBssInfo);
704 SysTryReturn(NID_NET_WIFI, pDescBssInfo != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
706 r = pDescList->Add(*pDescBssInfo);
707 r = TransExceptionsExclusive(r, E_FAILURE, E_OUT_OF_MEMORY);
708 SysTryReturn(NID_NET_WIFI, r == E_SUCCESS, null, r, "[%s] Failed to add a new BSS info to the list.", GetErrorMessage(r));
711 return pDescList.release();
714 } } } // Tizen::Net::Wifi