Beispiel #1
0
gcRefPtr<WebCore::WebCoreI> GetWebCore()
{
	if (g_pUserHandle)
		return g_pUserHandle->getWebCore();

	return nullptr;
}
Beispiel #2
0
void MainApp::logIn(const char* user, const char* pass)
{
	gcTrace("User: {0}", user);

	std::lock_guard<std::mutex> a(m_UserLock);

	safe_delete(g_pUserHandle);

	gcString path = UTIL::OS::getAppDataPath();

	g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE);
	g_pUserHandle->init(path.c_str(), m_strServiceProvider.c_str());


	try
	{
		//need to do this here as news items will be passed onlogin
		g_pUserHandle->getNewsUpdateEvent() += delegate(this, &MainApp::onNewsUpdate);
		g_pUserHandle->getGiftUpdateEvent() += delegate((MainAppNoUI*)this, &MainAppNoUI::onGiftUpdate);
		g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar);

		g_pUserHandle->lockDelete();
		g_pUserHandle->logIn(user, pass);
		g_pUserHandle->unlockDelete();

#ifndef DEBUG
		if (gc_enable_api_debugging.getBool())
			g_pUserHandle->getWebCore()->enableDebugging();
#endif
	}
	catch (gcException)
	{
		g_pUserHandle->logOut();

		g_pUserHandle->getNewsUpdateEvent() -= delegate(this, &MainApp::onNewsUpdate);
		g_pUserHandle->getGiftUpdateEvent() -= delegate((MainAppNoUI*)this, &MainAppNoUI::onGiftUpdate);
		g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar);

		g_pUserHandle->unlockDelete();

		g_pUserHandle->logOut(false, false);
		safe_delete(g_pUserHandle);
		throw;
	}
}