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.
18 * @file FNetNetAccountInfo.cpp
19 * @brief This is the implementation for the FNetNetAccountInfo class.
22 #include <unique_ptr.h>
23 #include <FBaseString.h>
24 #include <FBaseUtilStringUtil.h>
25 #include <FNetNetTypes.h>
26 #include <FNetNetEndPoint.h>
27 #include <FNetNetAccountInfo.h>
28 #include <FNetNetAccountManager.h>
29 #include <FBaseSysLog.h>
30 #include "FNet_NetTypes.h"
31 #include "FNet_NetAccountInfoImpl.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Utility;
37 namespace Tizen { namespace Net
40 NetAccountInfo::NetAccountInfo(void)
41 : __pNetAccountInfoImpl(null)
45 NetAccountInfo::~NetAccountInfo(void)
47 delete __pNetAccountInfoImpl;
48 __pNetAccountInfoImpl = null;
52 NetAccountInfo::Construct(const NetAccountInfo& netAccountInfo)
55 const _NetAccountInfoImpl* pOtherNetAccountInfoImpl = _NetAccountInfoImpl::GetInstance(netAccountInfo);
57 SysAssertf(__pNetAccountInfoImpl == null,
58 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
60 SysTryReturnResult(NID_NET, pOtherNetAccountInfoImpl != null, E_INVALID_ARG,
61 "[%s] Invalid argument is used. The specified netAccountInfo is invalid.", GetErrorMessage(E_INVALID_ARG));
63 unique_ptr<_NetAccountInfoImpl> pNetAccountInfoImpl(new (std::nothrow) _NetAccountInfoImpl());
64 SysTryReturnResult(NID_NET, pNetAccountInfoImpl != null, E_OUT_OF_MEMORY,
65 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
67 r = pNetAccountInfoImpl->Construct(*pOtherNetAccountInfoImpl);
68 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
70 __pNetAccountInfoImpl = pNetAccountInfoImpl.release();
76 NetAccountInfo::Construct(void)
80 SysAssertf(__pNetAccountInfoImpl == null,
81 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
83 unique_ptr<_NetAccountInfoImpl> pNetAccountInfoImpl(new (std::nothrow) _NetAccountInfoImpl());
84 SysTryReturnResult(NID_NET, pNetAccountInfoImpl != null, E_OUT_OF_MEMORY,
85 "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
87 r = pNetAccountInfoImpl->Construct();
88 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
90 __pNetAccountInfoImpl = pNetAccountInfoImpl.release();
96 NetAccountInfo::GetAccountId(void) const
98 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
100 return __pNetAccountInfoImpl->GetAccountId();
104 NetAccountInfo::GetAccountName(void) const
106 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
108 return __pNetAccountInfoImpl->GetAccountName();
112 NetAccountInfo::SetAccountName(const String& accountName)
114 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
116 return __pNetAccountInfoImpl->SetAccountName(accountName);
120 NetAccountInfo::GetProtocolType(void) const
122 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
124 return __pNetAccountInfoImpl->GetProtocolType();
128 NetAccountInfo::SetProtocolType(const NetProtocolType netProtocolType)
130 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
132 return __pNetAccountInfoImpl->SetProtocolType(netProtocolType);
136 NetAccountInfo::GetAccessPointName(void) const
138 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
140 return __pNetAccountInfoImpl->GetAccessPointName();
144 NetAccountInfo::SetAccessPointName(const String& accessPointName)
146 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
148 return __pNetAccountInfoImpl->SetAccessPointName(accessPointName);
152 NetAccountInfo::GetLocalAddressScheme(void) const
154 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
156 return __pNetAccountInfoImpl->GetLocalAddressScheme();
160 NetAccountInfo::GetLocalAddress(void) const
162 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
164 return __pNetAccountInfoImpl->GetLocalAddress();
168 NetAccountInfo::SetLocalAddress(NetAddressScheme localAddrScheme, const IpAddress* pLocalAddress)
170 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
172 return __pNetAccountInfoImpl->SetLocalAddress(localAddrScheme, pLocalAddress);
176 NetAccountInfo::GetProxyAddress(void) const
178 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
180 return __pNetAccountInfoImpl->GetProxyAddress();
184 NetAccountInfo::SetProxyAddress(const NetEndPoint* pProxyEndPoint)
186 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
188 return __pNetAccountInfoImpl->SetProxyAddress(pProxyEndPoint);
192 NetAccountInfo::GetDnsAddressScheme(void) const
194 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
196 return __pNetAccountInfoImpl->GetDnsAddressScheme();
200 NetAccountInfo::GetPrimaryDnsAddress(void) const
202 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
204 return __pNetAccountInfoImpl->GetPrimaryDnsAddress();
208 NetAccountInfo::GetSecondaryDnsAddress(void) const
210 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
212 return __pNetAccountInfoImpl->GetSecondaryDnsAddress();
216 NetAccountInfo::SetDnsAddress(NetAddressScheme dnsAddressScheme, const IpAddress* pPrimaryDnsAddress,
217 const IpAddress* pSecondaryDnsAddress)
219 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
221 return __pNetAccountInfoImpl->SetDnsAddress(dnsAddressScheme, pPrimaryDnsAddress, pSecondaryDnsAddress);
225 NetAccountInfo::GetAuthenticationInfo(NetNapAuthType& authenticationType, String& id, String& password) const
227 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
229 return __pNetAccountInfoImpl->GetAuthenticationInfo(authenticationType, id, password);
233 NetAccountInfo::SetAuthenticationInfo(NetNapAuthType authenticationType, const String& id, const String& password)
235 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
237 return __pNetAccountInfoImpl->SetAuthenticationInfo(authenticationType, id, password);
241 NetAccountInfo::GetBearerType(void) const
243 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
245 return __pNetAccountInfoImpl->GetBearerType();
249 NetAccountInfo::GetHomeUrl(void) const
251 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
253 return __pNetAccountInfoImpl->GetHomeUrl();
257 NetAccountInfo::SetHomeUrl(const String& homeUrl)
259 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
261 __pNetAccountInfoImpl->SetHomeUrl(homeUrl);
265 NetAccountInfo::GetMaximumLengthOfId(void) const
267 return _MAX_AUTH_ID_LENGTH;
271 NetAccountInfo::GetMaximumLengthOfPassword(void) const
273 return _MAX_AUTH_PASSWORD_LENGTH;
277 NetAccountInfo::GetMaximumLengthOfAccountName(void) const
279 return _MAX_ACCOUNT_NAME_LENGTH;
283 NetAccountInfo::IsReadOnly(void) const
285 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
287 return __pNetAccountInfoImpl->IsReadOnly();
291 NetAccountInfo::Equals(const Object& rhs) const
293 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
295 const NetAccountInfo* pRhs = dynamic_cast<const NetAccountInfo*>(&rhs);
301 const _NetAccountInfoImpl* pRhsImpl = _NetAccountInfoImpl::GetInstance(*pRhs);
302 if (pRhsImpl == null)
307 return __pNetAccountInfoImpl->Equals(*pRhsImpl);
311 NetAccountInfo::GetHashCode(void) const
313 SysAssertf(__pNetAccountInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
315 return __pNetAccountInfoImpl->GetHashCode();