//call this if a update needs to be downloaded void User::appNeedUpdate(uint32 appver, uint32 appbuild) { if (m_bDownloadingUpdate) return; if (appver == m_uiLastUpdateVer && appbuild <= m_uiLastUpdateBuild) return; m_bDownloadingUpdate = true; std::string szAppid = UTIL::OS::getConfigValue(APPID); if (m_uiLastUpdateVer == 0) { if (szAppid.size() > 0) m_uiLastUpdateVer = atoi(szAppid.c_str()); if (m_uiLastUpdateVer == 0) m_uiLastUpdateVer = 100; } if (m_uiLastUpdateBuild == 0) { std::string szAppBuild = UTIL::OS::getConfigValue(APPBUILD); if (szAppBuild.size() > 0) m_uiLastUpdateBuild = atoi(szAppBuild.c_str()); if (m_uiLastUpdateBuild == 0) m_uiLastUpdateBuild = 0; } uint32 curAppVer=0; if (szAppid.size() > 0) curAppVer = atoi(szAppid.c_str()); //if we changed the appver dont keep downloading updates for the old one if (appver == 0 && m_uiLastUpdateVer != curAppVer) { m_bDownloadingUpdate = false; return; } if (appver != 0) { m_uiLastUpdateVer = appver; m_uiLastUpdateBuild = 0; } UserCore::Task::DownloadUpdateTask *task = new UserCore::Task::DownloadUpdateTask(this, m_uiLastUpdateVer, m_uiLastUpdateBuild); task->onDownloadCompleteEvent += delegate(this, &User::onUpdateComplete); task->onDownloadStartEvent += delegate(this, &User::onUpdateStart); task->onDownloadProgressEvent += delegate(getAppUpdateProgEvent()); m_pThreadPool->forceTask(task); }
DesuraControl::~DesuraControl() { auto userCore = GetUserCore(); if (userCore) { userCore->getNewAvatarEvent() -= guiDelegate(this, &DesuraControl::onNewAvatar); userCore->getAppUpdateProgEvent() -= guiDelegate(this, &DesuraControl::onDesuraUpdate); } }
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); }
DesuraControl::DesuraControl(gcFrame* parent, bool offline, const char* szProvider) : gcPanel(parent) { m_iIndex = -1; m_bDownloadingUpdate = false; m_uiUpdateProgress = 0; this->SetBackgroundColour( wxColor(GetGCThemeManager()->getColor("headerbottomborder", "bg"))); this->SetSizeHints( wxDefaultSize, wxDefaultSize ); auto userCore = GetUserCore(); if (userCore) userCore->getNewAvatarEvent() += guiDelegate(this, &DesuraControl::onNewAvatar); parent->onActiveEvent += guiDelegate(this, &DesuraControl::onActiveToggle); m_pMainMenuButton = new MainMenuButton(this, offline); m_pAvatar = new gcImageButton( this, wxID_ANY, wxDefaultPosition, wxSize( 66,66 ), wxTAB_TRAVERSAL ); #ifdef WIN32 m_pAvatar->SetCursor(wxCURSOR_HAND); #endif const char* szUsername = Managers::GetString("#MP_OFFLINE"); const char* szAvatar = nullptr; if (userCore) { szAvatar = GetUserCore()->getAvatar(); if (!offline) szUsername = GetUserCore()->getUserName(); } if (szAvatar && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(szAvatar))) { gc_lastavatar.setValue(szAvatar); m_pAvatar->setDefaultImage(szAvatar); } else { m_pAvatar->setDefaultImage("#icon_avatar"); } m_pFiller = new DesuraMenuFiller(this); m_pFiller->SetMinSize( wxSize( 25,38 ) ); m_pUsernameBox = new UsernameBox(this, szUsername); m_pMenuStrip = new MenuStrip(this); m_sizerContent = new wxFlexGridSizer( 1, 1, 0, 0 ); m_sizerContent->AddGrowableCol( 0 ); m_sizerContent->AddGrowableRow( 0 ); m_sizerContent->SetFlexibleDirection( wxBOTH ); m_sizerContent->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); wxFlexGridSizer* fgSizer3; fgSizer3 = new wxFlexGridSizer( 1, 4, 0, 0 ); fgSizer3->AddGrowableCol( 2 ); fgSizer3->SetFlexibleDirection( wxBOTH ); fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer3->Add( m_pUsernameBox, 1, wxEXPAND, 5 ); fgSizer3->Add( m_pMenuStrip, 1, wxEXPAND, 5 ); // main buttons across the top fgSizer3->Add( m_pFiller, 1, wxEXPAND, 5 ); m_sizerHeader = new wxBoxSizer( wxVERTICAL ); wxFlexGridSizer* fgSizer4; fgSizer4 = new wxFlexGridSizer( 1, 2, 0, 0 ); fgSizer4->SetFlexibleDirection( wxBOTH ); fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); if (!offline) { m_bButtonStrip = new ButtonStrip( this ); fgSizer4->Add( m_bButtonStrip, 1, wxEXPAND|wxBOTTOM, 1 ); // mail buttons } else { m_bButtonStrip = nullptr; fgSizer4->Add( 5, 0, 1, wxEXPAND, 5 ); } fgSizer4->AddGrowableCol( 1 ); fgSizer4->Add( m_sizerHeader, 1, wxEXPAND, 5 ); // arrows, home button, wxFlexGridSizer* fgSizer2; fgSizer2 = new wxFlexGridSizer( 2, 1, 0, 0 ); fgSizer2->AddGrowableCol( 0 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer2->Add( fgSizer3, 1, wxEXPAND, 5 ); fgSizer2->Add( fgSizer4, 1, wxEXPAND, 5 ); wxFlexGridSizer* fgSizer1; fgSizer1 = new wxFlexGridSizer( 1, 4, 0, 0 ); fgSizer1->AddGrowableCol( 2 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer1->Add( m_pMainMenuButton, 1, 0, 5 ); fgSizer1->Add( m_pAvatar, 1, wxSHAPED, 5 ); fgSizer1->Add( fgSizer2, 1, wxEXPAND, 5 ); wxFlexGridSizer* fgSizer5; fgSizer5 = new wxFlexGridSizer( 3, 1, 0, 0 ); fgSizer5->AddGrowableCol( 0 ); fgSizer5->SetFlexibleDirection( wxBOTH ); fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer5->Add( fgSizer1, 1, wxEXPAND, 5 ); if (gcString(szProvider).size() > 0) { gcString strProv("Warning: Staging Environment {0}. Client Updates Disabled", szProvider); wxStaticText *pText = new wxStaticText(this, wxID_ANY, strProv, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE); pText->SetForegroundColour(*wxBLACK); pText->SetBackgroundColour(wxColour(255, 128, 64)); pText->SetFont(wxFont(16, 70, 90, 90, false, wxEmptyString)); fgSizer5->Add(pText, 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 10); fgSizer5->AddGrowableRow(2); } else { fgSizer5->AddGrowableRow(1); } fgSizer5->Add( m_sizerContent, 1, wxEXPAND, 5 ); this->SetSizer( fgSizer5 ); this->Layout(); if (userCore) userCore->getAppUpdateProgEvent() += guiDelegate(this, &DesuraControl::onDesuraUpdate); m_bOffline = offline; }