2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 FNet_ManagedNetConnectionImpl.cpp
20 * @brief This is the implementation for the _ManagedNetConnectionImpl class.
23 #include <FNetManagedNetConnection.h>
24 #include <FBaseSysLog.h>
25 #include "FNet_ManagedNetConnectionImpl.h"
26 #include "FNet_NetConnectionManagerImpl.h"
27 #include "FNet_NetUtility.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
32 namespace Tizen { namespace Net {
34 _ManagedNetConnectionImpl::_ManagedNetConnectionImpl(const ManagedNetConnection* pConnection)
36 , __pConnection(pConnection)
41 _ManagedNetConnectionImpl::~_ManagedNetConnectionImpl(void)
44 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
46 if (__pListener != null)
50 r = pManager->RemoveManagedNetConnectionEventListener(*__pListener);
59 pManager->ReleaseManagedNetConnection();
68 _ManagedNetConnectionImpl::SetManagedNetConnectionEventListener(IManagedNetConnectionEventListener* pListener)
71 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
75 if (__pListener != null)
77 r = pManager->RemoveManagedNetConnectionEventListener(*__pListener);
78 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
83 if (pListener != null)
85 r = pManager->AddManagedNetConnectionEventListener(*pListener, __pConnection);
86 SysTryReturnResult(NID_NET, r == E_SUCCESS, r, "Propagating.");
88 __pListener = pListener;
96 _ManagedNetConnectionImpl::Start(void)
99 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
103 if (pManager != null)
105 r = pManager->AddRefManagedNetConnection();
113 SysLogException(NID_NET, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM));
120 ManagedNetConnection*
121 _ManagedNetConnectionImpl::CreateInstanceN(void)
123 ManagedNetConnection* pConnection = null;
125 pConnection = new (std::nothrow) ManagedNetConnection();
126 SysTryReturn(NID_NET, pConnection != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
132 _ManagedNetConnectionImpl::GetConnectionState(void) const
136 NetConnectionState state = NET_CONNECTION_STATE_NONE;
137 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
139 if (pManager != null)
141 state = pManager->GetManagedNetConnectionState();
148 _ManagedNetConnectionImpl::QueryConnectionState(String& devName) const
152 NetConnectionState state = NET_CONNECTION_STATE_NONE;
153 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
155 if (pManager != null)
157 state = pManager->QueryManagedNetConnectionState(devName);
164 _ManagedNetConnectionImpl::GetNetAccountId(void) const
168 NetAccountId netAccountId = INVALID_HANDLE;
169 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
171 if (pManager != null)
173 netAccountId = pManager->GetManagedNetAccountId();
179 const NetConnectionInfo*
180 _ManagedNetConnectionImpl::GetNetConnectionInfo(void) const
184 const NetConnectionInfo* pInfo = null;
185 _NetConnectionManagerImpl* pManager = _NetConnectionManagerImpl::GetInstance();
187 if (pManager != null)
189 pInfo = pManager->GetManagedNetConnectionInfo();
195 _ManagedNetConnectionImpl*
196 _ManagedNetConnectionImpl::GetInstance(ManagedNetConnection& managedNetConnection)
198 return managedNetConnection.__pManagedNetConnectionImpl;
201 const _ManagedNetConnectionImpl*
202 _ManagedNetConnectionImpl::GetInstance(const ManagedNetConnection& managedNetConnection)
204 return managedNetConnection.__pManagedNetConnectionImpl;