Example #1
0
BOOL CWaveSession::Login(wstring szUsername, wstring szPassword)
{
	ASSERT(!szUsername.empty() && !szPassword.empty());

	if (m_nState != WSS_OFFLINE)
	{
		LOG("Not offline");
		return FALSE;
	}

	if (m_lpRequest != NULL)
	{
		LOG("Requesting login while a request is running");
		return FALSE;
	}

	m_nState = WSS_CONNECTING;

	SignalProgress(WCS_BEGIN_LOGON);

	m_szUsername = szUsername;
	m_szPassword = szPassword;

	return Reconnect();
}
Example #2
0
void CWaveSession::InitiateReconnect()
{
	m_lpReconnectTimer->SetInterval(TIMER_RECONNECT_INTERVAL_INITIAL);
	m_lpReconnectTimer->SetRunning(TRUE);

	m_nState = WSS_RECONNECTING;

	SignalProgress(WCS_RECONNECTING);
}
Example #3
0
void CWaveSession::ProcessAuthKeyResponse()
{
	ASSERT(m_lpRequest != NULL);

	CCurlUTF8StringReader * lpReader = (CCurlUTF8StringReader *)m_lpRequest->GetReader();

	ASSERT(lpReader != NULL);

	if (m_lpRequest->GetResult() != CURLE_OK)
	{
		m_nLoginError = WLE_NETWORK;
	}
	else
	{
		m_szAuthKey = GetAuthKeyFromRequest(lpReader->GetString());

		m_nLoginError = m_szAuthKey.empty() ? WLE_AUTHENTICATE : WLE_SUCCESS;
	}
	
	delete lpReader;
	delete m_lpRequest;

	m_lpRequest = NULL;
	m_nRequesting = WSR_NONE;

	if (m_nLoginError == WLE_SUCCESS)
	{
		SignalProgress(WCS_GOT_KEY);

		PostAuthCookieRequest();
	}
	else if (m_nState == WSS_RECONNECTING)
	{
		NextReconnect();
	}
	else
	{
		m_nState = WSS_OFFLINE;

		SignalProgress(WCS_FAILED);
	}
}
Example #4
0
void CWaveSession::ProcessCookieResponse()
{
	ASSERT(m_lpRequest != NULL);

	if (m_lpRequest->GetResult() != CURLE_OK)
	{
		m_nLoginError = WLE_NETWORK;
	}
	else
	{
		SetCookies(m_lpRequest->GetCookies());

		m_nLoginError = m_lpCookies == NULL ? WLE_AUTHENTICATE : WLE_SUCCESS;
	}
	
	delete m_lpRequest;

	m_lpRequest = NULL;
	m_nRequesting = WSR_NONE;

	if (m_nLoginError == WLE_SUCCESS)
	{
		SignalProgress(WCS_GOT_COOKIE);

		PostSessionDetailsRequest();
	}
	else if (m_nState == WSS_RECONNECTING)
	{
		NextReconnect();
	}
	else
	{
		m_nState = WSS_OFFLINE;

		SignalProgress(WCS_FAILED);
	}
}
Example #5
0
void CWaveSession::ProcessSignOutResponse()
{
	m_nState = WSS_OFFLINE;

	SignalProgress(WCS_SIGNED_OUT);

	if (m_lpCookies != NULL)
	{
		delete m_lpCookies;
	}

	m_lpCookies = NULL;

	m_szStickySessionID = L"";

	ASSERT(m_lpRequest != NULL);

	delete m_lpRequest;

	m_lpRequest = NULL;
	m_nRequesting = WSR_NONE;
}
Example #6
0
void CWaveSession::StopReconnecting()
{
	if (m_nState != WSS_RECONNECTING)
	{
		LOG("StopReconnecting called while not reconnecting");
	}
	else
	{
		if (m_lpCookies != NULL)
		{
			delete m_lpCookies;
		}

		m_lpCookies = NULL;

		m_nState = WSS_OFFLINE;

		SignalProgress(WCS_SIGNED_OUT);

		m_lpReconnectTimer->SetRunning(FALSE);
	}
}
Example #7
0
void CWaveSession::SignOut()
{
	if (m_nState == WSS_RECONNECTING)
	{
		StopReconnecting();
	}
	else if (m_nState == WSS_ONLINE)
	{
		m_nState = WSS_DISCONNECTING;

		SignalProgress(WCS_BEGIN_SIGNOUT);

		if (m_lpPostRequest != NULL)
		{
			CNotifierApp::Instance()->CancelRequest(m_lpPostRequest);

			// We do not need to flush the request queue anymore.

			m_vOwnedRequests.push_back(m_lpPostRequest);

			m_lpPostRequest = NULL;
		}

		if (m_lpChannelRequest != NULL)
		{
			CNotifierApp::Instance()->CancelRequest(m_lpChannelRequest);

			// We do not need to process the channel response anymore.

			m_vOwnedRequests.push_back(m_lpChannelRequest);

			m_lpChannelRequest = NULL;
		}

		PostSignOutRequest();
	}
}
Example #8
0
/**
 * Documentation
 * @brief Sets the current amount of progress to current progress + steps.
 * @param steps the number of steps done since last Progress(int steps) call.
 */
void QmitkProgressBar::Progress(unsigned int steps)
{
  emit SignalProgress(steps);
}
Example #9
0
void CWaveSession::ProcessSIDResponse()
{
	ASSERT(m_lpRequest != NULL);

	CCurlUTF8StringReader * lpReader = (CCurlUTF8StringReader *)m_lpRequest->GetReader();

	ASSERT(lpReader != NULL);
	
	if (m_lpRequest->GetResult() != CURLE_OK)
	{
		m_nLoginError = WLE_NETWORK;
	}
	else
	{
		SetCookies(m_lpRequest->GetCookies());

		wstring szChannelResponse(ExtractChannelResponse(lpReader->GetString()));

		if (
			!szChannelResponse.empty() &&
			ParseChannelResponse(szChannelResponse)
		) {
			m_nLoginError = WLE_SUCCESS;
		}
		else
		{
			m_nLoginError = WLE_AUTHENTICATE;
		}
	}
	
	delete lpReader;
	delete m_lpRequest;

	m_lpRequest = NULL;
	m_nRequesting = WSR_NONE;

	if (m_nLoginError == WLE_SUCCESS)
	{
		m_nState = WSS_ONLINE;

		SignalProgress(WCS_LOGGED_ON);

		PostChannelRequest();

		FlushRequestQueue();
	}
	else
	{
		// When we were not able to log retireve the SID session, it could be
		// that the sticky session ID is not valid anymore. Invalidate.

		m_szStickySessionID = L"";

		if (m_nState == WSS_RECONNECTING)
		{
			NextReconnect();
		}
		else
		{
			m_nState = WSS_OFFLINE;

			SignalProgress(WCS_FAILED);
		}
	}
}
Example #10
0
void CWaveSession::ProcessSessionDetailsResponse()
{
	ASSERT(m_lpRequest != NULL);

	CCurlUTF8StringReader * lpReader = (CCurlUTF8StringReader *)m_lpRequest->GetReader();

	ASSERT(lpReader != NULL);

	if (m_lpRequest->GetResult() != CURLE_OK)
	{
		m_nLoginError = WLE_NETWORK;
	}
	else
	{
		wstring szResponse(lpReader->GetString());
		wstring szSessionData(GetSessionData(szResponse));

		if (szSessionData.empty())
		{
			m_nLoginError = WLE_AUTHENTICATE;
		}
		else
		{
			m_szEmailAddress = GetKeyFromSessionResponse(L"username", szSessionData);
			m_szSessionID = GetKeyFromSessionResponse(L"sessionid", szSessionData);
			m_szProfileID = GetKeyFromSessionResponse(L"id", szSessionData);

			// The sticky session ID must survive log off and log on requests. If
			// we fail to retrieve the SID, the sticky session ID is cleared and
			// we retrieve it here on the next retry.

			if (m_szStickySessionID.empty())
			{
				m_szStickySessionID = GetKeyFromSessionResponse(L"sticky_session", szSessionData);
			}

			if (
				!m_szEmailAddress.empty() &&
				!m_szSessionID.empty() &&
				!m_szStickySessionID.empty() &&
				!m_szProfileID.empty()
			) {
				m_nLoginError = WLE_SUCCESS;
			}
			else
			{
				m_nLoginError = WLE_AUTHENTICATE;
			}
		}
	}
	
	delete lpReader;
	delete m_lpRequest;

	m_lpRequest = NULL;
	m_nRequesting = WSR_NONE;

	if (m_nLoginError == WLE_SUCCESS)
	{
		SignalProgress(WCS_GOT_SESSION_DETAILS);

		ResetChannelParameters();

		PostSIDRequest();
	}
	else if (m_nState == WSS_RECONNECTING)
	{
		NextReconnect();
	}
	else
	{
		m_nState = WSS_OFFLINE;

		SignalProgress(WCS_FAILED);
	}
}