isBearerChanged = true;
}
- if (isBearerChanged)
- {
- SysLog(NID_NET, "Invoke stop event, because bearer is changed.");
- pConnection->HandleStopEvent(E_NETWORK_FAILED);
- pConnection->UpdateConnectionInfo(null);
- }
-
- if (pConnection->GetConnectionState() == NET_CONNECTION_STATE_STARTED)
- {
- SysLog(NID_NET, "Ignore the event, because this is already in started state.");
- return;
- }
+ NetConnectionState oldState = pConnection->GetConnectionState();
ret = connection_get_current_profile(connectionHandle, &profileHandle);
SysTryReturnVoidResult(NID_NET, ret == CONNECTION_ERROR_NONE, E_SYSTEM,
"[%s] A system error has been occurred. The return value from connection_get_current_profile() is %d", GetErrorMessage(E_SYSTEM), ret);
pConnection->UpdateConnectionInfo(profileHandle);
- pConnection->HandleStartEvent();
-
connection_profile_destroy(profileHandle);
+
+ if (oldState != NET_CONNECTION_STATE_STARTED)
+ {
+ pConnection->HandleStartEvent();
+ }
+ else if (isBearerChanged)
+ {
+ pConnection->HandleChangedEvent();
+ }
+ else
+ {
+ SysLog(NID_NET, "Ignore the event, because this is already in started state.");
+ }
}
else
{
// Not connected
- pConnection->HandleStopEvent(E_NETWORK_FAILED);
- pConnection->UpdateConnectionInfo(null);
+ if ((pConnection->GetConnectionState() != NET_CONNECTION_STATE_NONE) && (pConnection->GetConnectionState() != NET_CONNECTION_STATE_STOPPED))
+ {
+ pConnection->UpdateConnectionInfo(null);
+ pConnection->HandleStopEvent(E_NETWORK_FAILED);
+ }
+ else
+ {
+ SysLog(NID_NET, "Ignore the event, because this is already in stopped state.");
+ }
}
}
_NetConnectionEvent* pEvent = null;
_NetConnectionEventArg* pEventArg = null;
+ SysLog(NID_NET, "[%ls] Notify started event.", _name.GetPointer());
+
MutexGuard locked(*_pLock);
unique_ptr<IEnumerator> pEnum(_pEventList->GetEnumeratorN());
}
void
+_DefaultSystemNetConnection::HandleStopEvent(result error)
+{
+ _NetConnectionEvent* pEvent = null;
+ _NetConnectionEventArg* pEventArg = null;
+
+ SysLog(NID_NET, "[%ls] Notify stopped event.", _name.GetPointer());
+
+ MutexGuard locked(*_pLock);
+
+ _refCount = 0;
+
+ unique_ptr<IEnumerator> pEnum(_pEventList->GetEnumeratorN());
+ if (pEnum != null)
+ {
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+ if (pEvent != null)
+ {
+ pEvent->SetConnectionState(NET_CONNECTION_STATE_STOPPED);
+ pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_STOPPED, error);
+ if (pEventArg != null)
+ {
+ pEvent->FireAsync(*pEventArg);
+ }
+ }
+ }
+ }
+
+ locked.Unlock();
+}
+
+void
+_DefaultSystemNetConnection::HandleChangedEvent(void)
+{
+ _NetConnectionEvent* pEvent = null;
+ _NetConnectionEventArg* pEventArg = null;
+
+ SysLog(NID_NET, "[%ls] Notify bearer changed event.", _name.GetPointer());
+
+ MutexGuard locked(*_pLock);
+
+ unique_ptr<IEnumerator> pEnum(_pEventList->GetEnumeratorN());
+ if (pEnum != null)
+ {
+ while (pEnum->MoveNext() == E_SUCCESS)
+ {
+ pEvent = dynamic_cast<_NetConnectionEvent*>(pEnum->GetCurrent());
+ if (pEvent != null)
+ {
+ pEvent->SetConnectionState(NET_CONNECTION_STATE_STARTED);
+ pEventArg = new (std::nothrow) _NetConnectionEventArg(_NET_CONNECTION_EVENT_TYPE_CHANGED, E_SUCCESS);
+ if (pEventArg != null)
+ {
+ pEvent->FireAsync(*pEventArg);
+ }
+ }
+ }
+ }
+
+ locked.Unlock();
+}
+
+void
_DefaultSystemNetConnection::UpdateConnectionInfo(void* pData)
{
connection_profile_h profileHandle = pData;
result Construct(void);
virtual void HandleStartEvent(void);
+ virtual void HandleStopEvent(result error);
+
+ void HandleChangedEvent(void);
void UpdateConnectionInfo(void* pData);
void* GetConnectionHandle(void) const;
pManagedNetConnectionEventListener->OnManagedNetConnectionResumed(*pManagedNetConnection);
SysLog(NID_NET, "Called OnManagedNetConnectionResumed().");
break;
+ case _NET_CONNECTION_EVENT_TYPE_CHANGED:
+ SysLog(NID_NET, "Calling OnManagedNetConnectionBearerChanged().");
+ pManagedNetConnectionEventListener->OnManagedNetConnectionBearerChanged(*pManagedNetConnection);
+ SysLog(NID_NET, "Called OnManagedNetConnectionBearerChanged().");
+ break;
default:
break;
}
_NET_CONNECTION_EVENT_TYPE_STARTED,
_NET_CONNECTION_EVENT_TYPE_STOPPED,
_NET_CONNECTION_EVENT_TYPE_SUSPENDED,
- _NET_CONNECTION_EVENT_TYPE_RESUMED
+ _NET_CONNECTION_EVENT_TYPE_RESUMED,
+ _NET_CONNECTION_EVENT_TYPE_CHANGED
};
typedef Tizen::Base::Runtime::IEventListener* _NetListenerKey;
_HttpManagedNetConnectionEventListenerImpl::OnManagedNetConnectionBearerChanged(ManagedNetConnection& managedNetConnection)
{
SysLog(NID_NET_HTTP, "The network state is changed.");
+
+ ProcessUpdateProxy(managedNetConnection);
+
+ SysLog(NID_NET_HTTP, "Called OnManagedNetConnectionBearerChanged()");
}
bool
}
void
+_HttpManagedNetConnectionEventListenerImpl::ProcessUpdateProxy(ManagedNetConnection& managedNetConnection)
+{
+ SysAssertf(__pHttpSessionImpl != null, "The __pHttpSessionImpl must not be null.");
+
+ result r = E_SUCCESS;
+
+ _ManagedNetConnectionImpl* pManagedNetConnectionImpl = _ManagedNetConnectionImpl::GetInstance(managedNetConnection);
+ SysAssertf(pManagedNetConnectionImpl != null, "pConnectionInfo must not be null.");
+
+ const NetConnectionInfo* pConnectionInfo = pManagedNetConnectionImpl->GetNetConnectionInfo();
+ SysAssertf(pConnectionInfo != null, "pConnectionInfo must not be null.");
+
+ const _NetConnectionInfoImpl* pConnectionInfoImpl = _NetConnectionInfoImpl::GetInstance(*pConnectionInfo);
+ SysAssertf(pConnectionInfoImpl != null, "pConnectionInfoImpl must not be null.");
+
+ String proxyAddressOfManagedMode = pConnectionInfoImpl->GetProxyAddress();
+ String deviceName = pConnectionInfoImpl->GetDeviceName();
+ SysLog(NID_NET_HTTP, "[Default Mode] Network is changed. the device name is %ls, the system proxy address is %ls.", deviceName.GetPointer(), proxyAddressOfManagedMode.GetPointer());
+
+ if (__pHttpSessionImpl->IsUserProxy() == true)
+ {
+ proxyAddressOfManagedMode = *__pHttpSessionImpl->GetProxyAddress();
+ SysLog(NID_NET_HTTP, "[Default Mode] Use a specific proxy address[%ls] of application.", proxyAddressOfManagedMode.GetPointer());
+ }
+ else
+ {
+ String* pPorxyAddress = new (std::nothrow) String(proxyAddressOfManagedMode);
+ SysTryReturnVoidResult(NID_NET_HTTP, pPorxyAddress != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
+ __pHttpSessionImpl->SetProxyAddress(pPorxyAddress);
+ }
+}
+
+void
_HttpManagedNetConnectionEventListenerImpl::AbortPendingTransactions(ManagedNetConnection& managedNetConnection)
{
SysAssertf(__pHttpSessionImpl != null, "__pHttpSessionImpl must not be null.");
private:
void ProcessPendingTransactions(ManagedNetConnection& managedNetConnection);
+ void ProcessUpdateProxy(ManagedNetConnection& managedNetConnection);
+
void AbortPendingTransactions(ManagedNetConnection& managedNetConnection);
private:
, __isClosed(false)
, __isAutoRedirectionEnabled(false)
, __isAlreadyResumed(false)
+ , __isUserProxy(false)
, __pHttpMultipleConnectionInfo(null)
, __pCookieStorageMgr(null)
, __pNetConnection(null)
{
SysLog(NID_NET_HTTP, "The proxy address is %ls.", pProxyAddr->GetPointer());
+ __isUserProxy = true;
pProxyAddress.reset(new (std::nothrow) String(*pProxyAddr));
SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY,
"Memory allocation failed.");
{
SysLog(NID_NET_HTTP, "The proxy address %ls.", pProxyAddr->GetPointer());
+ __isUserProxy = true;
pProxyAddress.reset(new (std::nothrow) String(*pProxyAddr));
SysTryReturnResult(NID_NET_HTTP, pProxyAddress != null, E_OUT_OF_MEMORY,
"Memory allocation failed.");
return false;
}
+bool
+_HttpSessionImpl::IsUserProxy(void) const
+{
+ return __isUserProxy;
+}
+
+
void
_HttpSessionImpl::IgnoreSslVerification(void)
{
bool IsConnectionStarted(void) const;
+ bool IsUserProxy(void) const;
+
HttpTransaction* OpenTransactionWithCurlN(CURL* pCurl, bool uncheckedMaxTransactions = false);
HttpTransaction* ReopenTransactionWithAuthN(HttpTransaction& httpTransaction);
bool __isClosed;
bool __isAutoRedirectionEnabled;
bool __isAlreadyResumed;
+ bool __isUserProxy;
class _HttpMultipleConnectionInfo* __pHttpMultipleConnectionInfo;
HttpCookieStorageManager* __pCookieStorageMgr;
Tizen::Net::NetConnection* __pNetConnection;