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(); }
void GCUpdateInfo::setInfo(uint32 appver) { if (appver == 0) appver = BUILDID_PUBLIC; m_ieBrowser->loadUrl(gcWString(L"{0}/{1}", GetWebCore()->getUrl(WebCore::AppChangeLog), appver)); }
void ChangeLogForm::setInfo(UserCore::Item::ItemInfoI* item) { if (!item) return; if (item->getIcon() && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(item->getIcon()))) setIcon(item->getIcon()); m_uiItemId = item->getId(); gcWString title(Managers::GetString(L"#CL_TITLE"), item->getName()); SetTitle(title); gcWString type = gcWString(m_uiItemId.getTypeString()); gcWString shortName(item->getShortName()); gcWString url(L"{0}/{1}/{2}/changelog", GetWebCore()->getUrl(WebCore::Root), type, shortName); if (item->getCurrentBranch()) url += gcWString(L"/{0}", item->getCurrentBranch()->getBranchId()); m_ieBrowser->loadUrl(url); #ifdef NIX Refresh(false); #endif }
void SetCookies() { if (!g_bLoaded || !GetWebCore()) return; ChromiumDLL::CookieI* cookie = g_pChromiumController->CreateCookie(); if (!cookie) { Warning("Cef failed to create cookie. Failed to set cookies. :(\n"); return; } gcString urlRoot; { std::lock_guard<std::mutex> a(g_RootUrlMutex); if (GetWebCore()) g_strRootUrl = GetWebCore()->getUrl(WebCore::Root); urlRoot = g_strRootUrl; } if (urlRoot.find("http://") == 0) urlRoot = urlRoot.substr(7); if (urlRoot.find("www") == 0) urlRoot = urlRoot.substr(3); else urlRoot = gcString(".") + urlRoot; cookie->SetDomain(urlRoot.c_str()); cookie->SetPath("/"); std::function<void(const char*, const char*, const char*)> cookieCallback = [&](const char* szRootUrl, const char* szName, const char* szValue) { cookie->SetName(szName); cookie->SetData(szValue); g_pChromiumController->SetCookie(szRootUrl, cookie); }; GetWebCore()->setCookies(cookieCallback); cookie->destroy(); }
void TBIUpdateMenu::onMenuSelect(wxCommandEvent& event) { switch (event.GetId()) { case mcMENU_MESSAGE: g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Inbox).c_str(), COMMUNITY); break; case mcMENU_UPDATE: g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Updates).c_str(), COMMUNITY); break; case mcMENU_CART: g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Cart).c_str(), COMMUNITY); break; case mcMENU_GAMEUPDATE: case mcMENU_MODUPDATE: g_pMainApp->handleInternalLink(DesuraId(), ACTION_PLAY); break; } }
void ChangeLogForm::setInfo(uint32 version) { m_bApp = true; m_uiItemId = 0; SetTitle(Managers::GetString(L"#CL_TITLE")); gcWString wUrl(L"{0}/{1}", GetWebCore()->getUrl(WebCore::AppChangeLog), version); m_ieBrowser->loadUrl(wUrl); #ifdef NIX Refresh(false); #endif }
void TaskBarIcon::onBallonClick(wxTaskBarIconEvent &event) { if (m_iLastBallon == BALLON_GIFTS) { g_pMainApp->showNews(); } else if (m_iLastBallon == BALLON_APPUPDATE) { g_pMainApp->handleInternalLink(DesuraId(m_AppUpdateVer.build, 0), ACTION_APPUPDATELOG); } else if (m_iLastBallon == BALLON_GAMEUPDATE) { g_pMainApp->loadUrl(GetWebCore()->getUrl(WebCore::Updates).c_str(), COMMUNITY); } m_iLastBallon = BALLON_NONE; }
bool ExternalLoaderScheme::processRequest(ChromiumDLL::SchemeRequestI* request, bool* redirect) { char wurl[255]; request->getURL(wurl, 255); // desura://external/ is 18 chars! gcString url = wurl; url = url.substr(18); if (url == "play.js") { m_szRedirectUrl = GetWebCore()->getUrl(WebCore::WebCoreUrl::PlayJavaScript); *redirect = true; return true; } else { return false; } }
AltLoginDialog::AltLoginDialog(wxWindow* parent, const char* szProvider, const char* szApiUrl) : gcDialog(parent, wxID_ANY, wxT("#ALTLOGIN_TITLE"), wxDefaultPosition, wxSize(500, 665), wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL) { SetTitle(gcString(Managers::GetString(L"#ALTLOGIN_TITLE"), szProvider)); GetWebCore(); gcString strUrl; if (!gcString(szApiUrl).empty()) strUrl = gcString("http://www.{0}/members/loginext/{1}", szApiUrl, szProvider); else strUrl = gcString("http://www.desura.com/members/loginext/{0}", szProvider); m_pBrowser = new gcWebControl(this, strUrl.c_str()); wxFlexGridSizer* fgSizer2 = new wxFlexGridSizer(2, 1, 0, 0); fgSizer2->AddGrowableCol(0); fgSizer2->AddGrowableRow(0); fgSizer2->SetFlexibleDirection(wxBOTH); fgSizer2->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); fgSizer2->Add(m_pBrowser, 1, wxEXPAND | wxTOP | wxRIGHT | wxLEFT, 5); this->SetSizer(fgSizer2); this->Layout(); gcString strProvider(szProvider); if (strProvider == "google") SetSize(wxSize(900, 525)); else if (strProvider == "facebook") SetSize(wxSize(1050, 600)); else if (strProvider == "steam") SetSize(wxSize(1000, 850)); CenterOnParent(); }
bool InternalLink::processItemLink(bool &badLink, std::vector<gcString> &list, const char* link) { if (list.size() < 3) { badLink = true; return true; } std::string key = list[1] + list[2]; std::map<gcString, gcFrame*>::iterator it = m_mWaitingItemFromMap.find(key); if (it != m_mWaitingItemFromMap.end()) { it->second->Raise(); return false; } UI::Forms::ItemForm *form = new UI::Forms::ItemForm(m_pParent, list[0].c_str(), list[2].c_str()); m_mWaitingItemFromMap[key] = form; form->Show(); DesuraId id; try { id = GetWebCore()->nameToId(list[2].c_str(), list[1].c_str()); } catch (gcException &e) { DesuraId idAsNum(list[2].c_str(), list[1].c_str()); if (idAsNum.getItem() == 0) { Warning(gcString("Failed to resolve item name {0} for link {2}: {1}\n", list[2], e, link)); gcErrorBox(form, Managers::GetString("#MF_ERRTITLE"), Managers::GetString("#MF_NAMERESOLVE"), e); m_mWaitingItemFromMap.erase(m_mWaitingItemFromMap.find(key)); form->Show(false); form->Destroy(); return false; } else { id = idAsNum; } } m_mWaitingItemFromMap.erase(m_mWaitingItemFromMap.find(key)); bool destroyForm = false; std::vector<std::string> argList; if (id.isOk()) { UI::Forms::ItemForm *formFind = findForm<UI::Forms::ItemForm>(id, m_vSubForms); if (!formFind) { form->setItemId(id); regForm(id, form); } else { formFind->SetPosition(form->GetPosition()); form->Show(false); destroyForm = true; } if (list[0] == "install" || list[0] == "launch") { std::string branch; if (list.size() >= 4) branch = list[3]; if (branch.size() > 0) { argList.push_back(std::string("global=") + branch); handleInternalLink(id, ACTION_INSTALL, argList); } else { bool isInstall = (list[0] == "install"); handleInternalLink(id, isInstall?ACTION_INSTALL:ACTION_LAUNCH, argList); } } else if (list[0] == "uninstall" || list[0] == "remove") { handleInternalLink(id, ACTION_UNINSTALL); } else if (list[0] == "verify") { handleInternalLink(id, ACTION_VERIFY); } else if (list[0] == "upload") { destroyForm = true; handleInternalLink(id, ACTION_UPLOAD); } else if (list[0] == "resumeupload" && list.size() >= 4) { destroyForm = true; argList.push_back(std::string("key=") + list[3]); handleInternalLink(id, ACTION_RESUPLOAD, argList); // } else if (list[0] == "makemcf") { destroyForm = true; handleInternalLink(id, ACTION_CREATE); } else if (list[0] == "test" && list.size() >= 5) { argList.push_back(std::string("branch=") + list[3]); argList.push_back(std::string("build=") + list[4]); handleInternalLink(id, ACTION_TEST, argList); } else { badLink = true; } } else { badLink = true; } if (badLink || destroyForm) { closeForm(form->GetId()); form->Show(false); form->Destroy(); } return true; }