Merge "Add the exception handling when using manual cert mode" into tizen_2.1
[platform/framework/native/net.git] / src / FNetNetConnectionInfo.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file                        FNetNetConnectionInfo.cpp
20  * @brief               This is the implementation for the %NetConnectionInfo class.
21  */
22
23 #include <FBaseUtilStringUtil.h>
24 #include <FNetNetConnectionInfo.h>
25 #include <FNetIp4Address.h>
26 #include <FBaseSysLog.h>
27 #include "FNet_NetConnectionInfoImpl.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Utility;
31
32 namespace Tizen { namespace Net
33 {
34
35 NetConnectionInfo::NetConnectionInfo(void)
36 {
37         __pNetConnectionInfoImpl = new (std::nothrow) _NetConnectionInfoImpl();
38         SysTryReturnVoidResult(NID_NET, __pNetConnectionInfoImpl != null, E_OUT_OF_MEMORY,
39                         "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
40 }
41
42 NetConnectionInfo::~NetConnectionInfo(void)
43 {
44         delete __pNetConnectionInfoImpl;
45         __pNetConnectionInfoImpl = null;
46 }
47
48 NetBearerType
49 NetConnectionInfo::GetBearerType(void) const
50 {
51         return  __pNetConnectionInfoImpl->GetBearerType();
52 }
53
54
55 NetProtocolType
56 NetConnectionInfo::GetProtocolType(void) const
57 {
58         return __pNetConnectionInfoImpl->GetProtocolType();
59 }
60
61
62 String
63 NetConnectionInfo::GetAccessPointName(void) const
64 {
65         return __pNetConnectionInfoImpl->GetAccessPointName();
66 }
67
68 NetAddressScheme
69 NetConnectionInfo::GetLocalAddressScheme(void) const
70 {
71         return __pNetConnectionInfoImpl->GetLocalAddressScheme();
72 }
73
74 const IpAddress*
75 NetConnectionInfo::GetLocalAddress(void) const
76 {
77         return __pNetConnectionInfoImpl->GetLocalAddress();
78 }
79
80
81 NetAddressScheme
82 NetConnectionInfo::GetDnsAddressScheme(void) const
83 {
84         return __pNetConnectionInfoImpl->GetDnsAddressScheme();
85 }
86
87 const IpAddress*
88 NetConnectionInfo::GetPrimaryDnsAddress(void) const
89 {
90         return __pNetConnectionInfoImpl->GetPrimaryDnsAddress();
91 }
92
93 const IpAddress*
94 NetConnectionInfo::GetSecondaryDnsAddress(void) const
95 {
96         return __pNetConnectionInfoImpl->GetSecondaryDnsAddress();
97 }
98
99 const IpAddress*
100 NetConnectionInfo::GetSubnetMaskAddress(void) const
101 {
102         return __pNetConnectionInfoImpl->GetSubnetMaskAddress();
103 }
104
105 const IpAddress*
106 NetConnectionInfo::GetDefaultGatewayAddress(void) const
107 {
108         return __pNetConnectionInfoImpl->GetDefaultGatewayAddress();
109 }
110
111 NetConnectionInfo::NetConnectionInfo(const NetConnectionInfo& rhs)
112 {
113         __pNetConnectionInfoImpl = new (std::nothrow) _NetConnectionInfoImpl(*(rhs.__pNetConnectionInfoImpl));
114         SysTryReturnVoidResult(NID_NET, __pNetConnectionInfoImpl != null, E_OUT_OF_MEMORY,
115                         "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
116 }
117
118 NetConnectionInfo&
119 NetConnectionInfo::operator =(const NetConnectionInfo& rhs)
120 {
121         if (this == &rhs)
122         {
123                 return *this;
124         }
125
126         *__pNetConnectionInfoImpl = *rhs.__pNetConnectionInfoImpl;
127
128         return *this;
129 }
130
131
132 bool
133 NetConnectionInfo::Equals(const Object& rhs) const
134 {
135         const NetConnectionInfo* pRhs = dynamic_cast<const NetConnectionInfo*>(&rhs);
136         if (pRhs == null)
137         {
138                 return false;
139         }
140
141         const _NetConnectionInfoImpl* pRhsImpl = _NetConnectionInfoImpl::GetInstance(*pRhs);
142         if (pRhsImpl == null)
143         {
144                 return false;
145         }
146
147         return __pNetConnectionInfoImpl->Equals(*pRhsImpl);
148 }
149
150 int
151 NetConnectionInfo::GetHashCode(void) const
152 {
153         return __pNetConnectionInfoImpl->GetHashCode();
154 }
155
156 } } // Tizen::Net