Esempio n. 1
0
void MainApp::onLoginAcceptedCB(std::pair<bool,bool> &loginInfo)
{
	bool saveLoginInfo = loginInfo.first;
	bool autologin = loginInfo.second;

	if (m_wxLoginForm)
	{
		m_wxLoginForm->Show(false);
		m_wxLoginForm->Destroy();
		m_wxLoginForm = nullptr;
	}

	if (saveLoginInfo)
		GetUserCore()->saveLoginInfo();

	GetUserCore()->getAppUpdateProgEvent() += guiDelegate(this, &MainApp::onAppUpdateProg);
	GetUserCore()->getAppUpdateCompleteEvent() += guiDelegate(this, &MainApp::onAppUpdate);
	GetWebCore()->getCookieUpdateEvent() += guiDelegate(this, &MainApp::onCookieUpdate);
	GetWebCore()->getLoggedOutEvent() += delegate(&onLoggedOutEvent);
	GetUserCore()->getPipeDisconnectEvent() += guiDelegate(this, &MainApp::onPipeDisconnect);

	//trigger this so it sets cookies first time around
	onCookieUpdate();


	admin_developer.setValue(GetUserCore()->isAdmin());
	GetCVarManager()->loadUser(GetUserCore()->getUserId());

	gcWString userName(GetUserCore()->getUserName());
	SetCrashDumpSettings(userName.c_str(), gc_uploaddumps.getBool());

	m_bLoggedIn = true;
	m_iMode = APP_MODE::MODE_ONLINE;

	bool showMain = !(autologin && gc_silentlaunch.getBool());
	showMainForm(false, showMain);

	m_pInternalLink = new InternalLink(this);

	if (!m_bQuiteMode)
		GetUserCore()->getItemManager()->checkItems();

	if (m_wxTBIcon)
		m_wxTBIcon->regEvents();

	if (showMain && !m_bQuiteMode)
		showNews();

	if (m_szDesuraCache != "")
	{
		m_pInternalLink->handleInternalLink(m_szDesuraCache.c_str());
		m_szDesuraCache = "";
	}

	onLoginEvent();
}
Esempio n. 2
0
void MainApp::logOut(bool bShowLogin, bool autoLogin, bool webLoggedOut)
{
	gcTrace("");

	m_pInternalLink->closeAll();
	safe_delete(m_pInternalLink);

	closeMainForm();
	wxTheApp->ProcessIdle();

	{
		std::lock_guard<std::mutex> a(m_UserLock);
		if (g_pUserHandle)
		{
			auto user = g_pUserHandle;

			g_pUserHandle = nullptr;
			DesuraJSBinding::gs_pItemManager = nullptr;

			user->getPipeDisconnectEvent() -= guiDelegate(this, &MainApp::onPipeDisconnect);
			user->logOut(!autoLogin);

			user->getAppUpdateProgEvent()				-= guiDelegate(this, &MainApp::onAppUpdateProg);
			user->getAppUpdateCompleteEvent()			-= guiDelegate(this, &MainApp::onAppUpdate);
			user->getWebCore()->getCookieUpdateEvent() -= guiDelegate(this, &MainApp::onCookieUpdate);
			user->getWebCore()->getLoggedOutEvent()		-= delegate(&onLoggedOutEvent);

			user->destroy();
		}
	}

	GetCVarManager()->saveAll();
	GetCVarManager()->cleanUserCvars();

	m_bLoggedIn = false;
	m_iMode = APP_MODE::MODE_UNINT;

	if (bShowLogin)
		showLogin(!autoLogin, webLoggedOut);

	HideLogForm();

	DeleteCookies();
	SetCrashDumpSettings(nullptr, true);
}
Esempio n. 3
0
void MainApp::logOut(bool bShowLogin, bool autoLogin)
{
	m_pInternalLink->closeAll();
	safe_delete(m_pInternalLink);

	{
		Thread::AutoLock a(m_UserLock);
		if (g_pUserHandle)
		{
			UserCore::UserI* user = g_pUserHandle;
			g_pUserHandle = NULL;

			user->logOut(!autoLogin);

			*user->getAppUpdateProgEvent()				-= guiDelegate(this, &MainApp::onAppUpdateProg);
			*user->getAppUpdateCompleteEvent()			-= guiDelegate(this, &MainApp::onAppUpdate);
			*user->getWebCore()->getCookieUpdateEvent() -= guiDelegate(this, &MainApp::onCookieUpdate);
			*user->getPipeDisconnectEvent()				-= guiDelegate(this, &MainApp::onPipeDisconnect);

			safe_delete(user);
		}
	}

	GetCVarManager()->saveAll();
	GetCVarManager()->cleanUserCvars();

	closeMainForm();

	m_bLoggedIn = false;
	m_iMode = MODE_UNINT;

	if (bShowLogin)
		showLogin(!autoLogin);

	HideLogForm();

	DeleteCookies();
	SetCrashDumpSettings(NULL, true);
}