gcString MCFManager::getMcfPath(gcRefPtr<UserCore::Item::ItemInfoI> item, bool isUnAuthed) { if (!item || !item->getCurrentBranch()) return ""; return getMcfPath(item->getId(), item->getCurrentBranch()->getBranchId(), item->getInstalledBuild(), isUnAuthed); }
bool InstalledWizardThread::selectBranch(gcRefPtr<UserCore::Item::ItemInfoI> &item) { std::vector<uint32> vBranchIdList; for (uint32 x=0; x<item->getBranchCount(); x++) { auto bi = item->getBranch(x); if (!bi) continue; uint32 flags = bi->getFlags(); if (HasAnyFlags(flags, UserCore::Item::BranchInfoI::BF_NORELEASES|UserCore::Item::BranchInfoI::BF_DEMO|UserCore::Item::BranchInfoI::BF_TEST)) continue; if (!HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_ONACCOUNT)) { if (HasAnyFlags(flags, (UserCore::Item::BranchInfoI::BF_MEMBERLOCK|UserCore::Item::BranchInfoI::BF_REGIONLOCK))) continue; } if (!HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_ONACCOUNT) && !(HasAllFlags(flags, UserCore::Item::BranchInfoI::BF_FREE))) continue; vBranchIdList.push_back(bi->getBranchId()); } if (vBranchIdList.size() == 0) return false; //select the first free branch item->setInstalledMcf(MCFBranch::BranchFromInt(vBranchIdList[0])); return true; }
void GameDiskForm::setInfo(DesuraId id, gcRefPtr<UserCore::ItemManagerI> pItemManager) { if (!pItemManager) pItemManager = GetUserCore()->getItemManager(); m_pItem = pItemManager->findItemInfo(id); if (!m_pItem) { Close(); return; } gcRefPtr<UserCore::Item::ItemInfoI> parent = m_pItem; if (m_pItem->getId().getType() == DesuraId::TYPE_MOD && m_pItem->getParentId().isOk()) parent = pItemManager->findItemInfo(m_pItem->getParentId()); if (!parent) parent = m_pItem; SetTitle(gcWString(Managers::GetString(L"#GD_TITLE"), m_pItem->getName())); m_labInfo->SetLabel(gcWString(Managers::GetString(L"#GD_INFO"), m_pItem->getName(), parent->getName())); m_labInfo->Wrap( 360 ); }
void UserThreadManager::setUpThread(gcRefPtr<UserCore::Thread::MCFThreadI> thread) { auto um = m_pUserCore->getUploadManager(); thread->setThreadManager(gcRefPtr<UserThreadManager>(this)); thread->setUpLoadManager(um); thread->setWebCore(m_pUserCore->getWebCore()); thread->setUserCore(m_pUserCore); }
void ToolManager::addJSTool(gcRefPtr<UserCore::Item::ItemInfo> item, uint32 branchId, gcString name, gcString exe, gcString args, gcString res) { if (!item) return; auto branch = item->getBranchById(branchId); if (!branch) return; auto realBranch = gcRefPtr<UserCore::Item::BranchInfo>::dyn_cast(branch); if (!realBranch) return; bool found = false; gcRefPtr<JSToolInfo> jsinfo; BaseManager<ToolInfo>::for_each([&](gcRefPtr<ToolInfo> info) { auto temp = gcRefPtr<JSToolInfo>::dyn_cast(info); if (!temp) return; if (item->getId() == temp->getItemId() && name == info->getName() && temp->getBranchId() == branchId) { jsinfo = temp; found = true; } }); if (found) { if (!jsinfo->isRealyInstalled()) jsinfo->setExePath(exe.c_str()); return; } DesuraId toolId(m_iLastCustomToolId, DesuraId::TYPE_TOOL); m_iLastCustomToolId--; auto tool = gcRefPtr<JSToolInfo>::create(item->getId(), realBranch->getBranchId(), toolId, name, exe, args, res); realBranch->addJSTool(toolId); addItem(tool); }
void ChangeLogForm::setInfo(gcRefPtr<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 }
gcRefPtr<UserCore::Item::ItemInfoI> DesuraJSUploadInfo::getItem(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { if (!GetUserCore() || !GetUserCore()->getItemManager()) return nullptr; return GetUserCore()->getItemManager()->findItemInfo(upload->getItemId()); }
gcRefPtr<WebCore::WebCoreI> GetWebCore() { if (g_pUserHandle) return g_pUserHandle->getWebCore(); return nullptr; }
void LaunchItemDialog::setInfo(gcRefPtr<UserCore::Item::ItemInfoI> item) { if (!item) { Close(); return; } if (item->getIcon() && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(item->getIcon()))) setIcon(item->getIcon()); m_uiInternId = item->getId(); m_labItemName->SetLabel(gcWString(Managers::GetString(L"#LI_LABEL"), m_uiInternId.getTypeString(), item->getName())); SetTitle(gcWString(L"{0} {1}..", Managers::GetString(L"#LAUNCH"), item->getName())); }
void BranchInstallInfo::extractInstallChecks(const XML::gcXMLElement &icsNode, gcRefPtr<WildcardManager> &pWildCard, std::vector<InsCheck> &vInsChecks) { icsNode.for_each_child("installlocation", [&vInsChecks, pWildCard, this](const XML::gcXMLElement &icNode) { const gcString iCheck = icNode.GetChild("check"); const gcString iPath = icNode.GetChild("path"); if (iCheck.empty() || iPath.empty()) return; try { gcString strCheckRes = pWildCard->constructPath(iCheck.c_str()); if (isInstalled()) { if (!updateInstallCheck(strCheckRes, iPath)) return; vInsChecks.push_back(InsCheck(strCheckRes.c_str(), m_szPath.c_str())); } else { vInsChecks.push_back(InsCheck(strCheckRes.c_str(), iPath.c_str())); } } catch (...) { } }); }
BranchInstallInfo::BranchInstallInfo(uint32 biId, gcRefPtr<BranchItemInfoI> itemInfo, UTIL::FS::UtilFSI* pFileSystem) : m_BiId(biId) , m_pItem(itemInfo) , m_ItemId(itemInfo->getId()) , m_uiInstallSize(0) , m_uiDownloadSize(0) , m_pFileSystem(pFileSystem) { }
std::vector<gcRefPtr<UserCore::Item::ItemInfoI>> DesuraJSBinding::getMods(gcRefPtr<UserCore::Item::ItemInfoI> game) { auto im = getItemManager(); if (!game || !im) return std::vector<gcRefPtr<UserCore::Item::ItemInfoI>>(); std::vector<gcRefPtr<UserCore::Item::ItemInfoI>> mList; im->getModList(game->getId(), mList); return mList; }
void InstalledWizardThread::onItemFound(gcRefPtr<UserCore::Item::ItemInfoI> &item) { bool verify = (item->isInstalled() && item->isDownloadable() && !(item->getStatus()&UserCore::Item::ItemInfoI::STATUS_LINK)); if (verify) { if (!m_pTaskGroup) { auto im = gcRefPtr<UserCore::ItemManager>::dyn_cast(getUserCore()->getItemManager()); gcAssert(im); m_pTaskGroup = im->newTaskGroup(UserCore::Item::ItemTaskGroupI::A_VERIFY); m_pTaskGroup->start(); } item->addSFlag(UserCore::Item::ItemInfoI::STATUS_ONCOMPUTER|UserCore::Item::ItemInfoI::STATUS_VERIFING); auto handle = getUserCore()->getItemManager()->findItemHandle(item->getId()); handle->setPauseOnError(true); m_pTaskGroup->addItem(item); } DesuraId id = item->getId(); onItemFoundEvent(id); }
void DesuraJSUploadInfo::exploreMcf(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { const char* file = upload->getFile(); if (file) { UTIL::FS::Path path(file, "", true); #ifdef WIN32 ShellExecuteA(nullptr, "explore" , path.getFolderPath().c_str(), nullptr, nullptr, SW_SHOWNORMAL); #else UTIL::LIN::launchFolder(path.getFolderPath().c_str()); #endif } }
void MainApp::offlineMode() { if (m_iMode == APP_MODE::MODE_OFFLINE) return; if (m_bLoggedIn) logOut(false); closeMainForm(); { std::lock_guard<std::mutex> a(m_UserLock); gcString path = UTIL::OS::getAppDataPath(); if (g_pUserHandle) g_pUserHandle->destroy(); g_pUserHandle = (UserCore::UserI*)UserCore::FactoryBuilderUC(USERCORE); g_pUserHandle->init(path.c_str()); try { g_pUserHandle->getNeedCvarEvent() += delegate(this, &MainApp::onNeedCvar); g_pUserHandle->getItemManager()->loadItems(); } catch (gcException &) { g_pUserHandle->getNeedCvarEvent() -= delegate(this, &MainApp::onNeedCvar); g_pUserHandle->logOut(); g_pUserHandle->destroy(); throw; } } GetCVarManager()->loadUser(GetUserCore()->getUserId()); m_iMode = APP_MODE::MODE_OFFLINE; showMainWindow(); m_pInternalLink = new InternalLink(this); }
gcString DesuraJSBranchInfo::getBranchId(gcRefPtr<UserCore::Item::BranchInfoI> branch) { return gcString("{0}", branch->getBranchId()); }
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; } }
void UserThreadManager::setUpThread(gcRefPtr<UserCore::Thread::UserThreadI> thread) { thread->setThreadManager(gcRefPtr<UserThreadManager>(this)); thread->setWebCore(m_pUserCore->getWebCore()); thread->setUserCore(m_pUserCore); }
gcString DesuraJSBranchInfo::getBranchCost(gcRefPtr<UserCore::Item::BranchInfoI> branch) { return branch->getCost(); }
gcString DesuraJSUploadInfo::getItemId(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { return upload->getItemId().toString(); }
void DesuraJSUploadInfo::setDeleteMcf(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload, bool del) { upload->setDelMcf(del); }
gcString DesuraJSUploadInfo::getFileName(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { UTIL::FS::Path path = UTIL::FS::PathWithFile(upload->getFile()); return path.getFile().getFile(); }
bool DesuraJSUploadInfo::hasStarted(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { return upload->hasStarted(); }
int32 DesuraJSUploadInfo::getProgress(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { return upload->getProgress(); }
void DesuraJSUploadInfo::cancel(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { upload->stop(); GetUploadMng()->removeUpload(upload->getKey()); }
bool DesuraJSUploadInfo::isPaused(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { return upload->isPaused(); }
void DesuraJSUploadInfo::remove(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { GetUploadMng()->removeUpload(upload->getKey(), true); }
gcString DesuraJSUploadInfo::getUploadId(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { return gcString("{0}", upload->getHash()); }
void DesuraJSUploadInfo::unpause(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { upload->unpause(); }
bool DesuraJSUploadInfo::shouldDeleteMcf(gcRefPtr<UserCore::Misc::UploadInfoThreadI> upload) { return upload->shouldDelMcf(); }