bool ExportTemplate::updateAvailable() const { if (remoteVersion().isEmpty() || !isInstalled()) return false; return remoteVersion().toFloat() > version().toFloat(); }
void ToolManager::symLinkTools(std::vector<DesuraId> &list, const char* path) { if (!path) return; UTIL::FS::recMakeFolder(path); for (size_t x=0; x<list.size(); x++) { auto info = findItem(list[x].toInt64()); if (!info || !info->isInstalled()) continue; UTIL::FS::Path fp(info->getExe(), "", true); if (!UTIL::FS::isValidFile(fp)) continue; UTIL::FS::Path dp(path, "", false); dp += fp.getFile(); std::string src = fp.getFullPath(); std::string dest = dp.getFullPath(); int res = symlink(src.c_str(), dest.c_str()); if (res != 0) Debug(gcString("Failed to sym link: [{0}] to [{1}]\n", src, dest)); } }
void CModListView::selectMod(int index) { if (index < 0) { disableModInfo(); } else { enableModInfo(); auto mod = modModel->getMod(modModel->modIndexToName(index)); ui->textBrowser->setHtml(genModInfoText(mod)); bool hasInvalidDeps = !findInvalidDependencies(modModel->modIndexToName(index)).empty(); bool hasBlockingMods = !findBlockingMods(modModel->modIndexToName(index)).empty(); bool hasDependentMods = !findDependentMods(modModel->modIndexToName(index), true).empty(); ui->disableButton->setVisible(mod.isEnabled()); ui->enableButton->setVisible(mod.isDisabled()); ui->installButton->setVisible(mod.isAvailable()); ui->uninstallButton->setVisible(mod.isInstalled()); ui->updateButton->setVisible(mod.isUpdateable()); // Block buttons if action is not allowed at this time // TODO: automate handling of some of these cases instead of forcing player // to resolve all conflicts manually. ui->disableButton->setEnabled(!hasDependentMods); ui->enableButton->setEnabled(!hasBlockingMods && !hasInvalidDeps); ui->installButton->setEnabled(!hasInvalidDeps); ui->uninstallButton->setEnabled(!hasDependentMods); ui->updateButton->setEnabled(!hasInvalidDeps && !hasDependentMods); } }
bool CModManager::canEnableMod(QString modname) { auto mod = modList->getMod(modname); if (mod.isEnabled()) return addError(modname, "Mod is already enabled"); if (!mod.isInstalled()) return addError(modname, "Mod must be installed first"); for (auto modEntry : mod.getValue("depends").toStringList()) { if (!modList->hasMod(modEntry)) // required mod is not available return addError(modname, QString("Required mod %1 is missing").arg(modEntry)); if (!modList->getMod(modEntry).isEnabled()) return addError(modname, QString("Required mod %1 is not enabled").arg(modEntry)); } for (QString modEntry : modList->getModList()) { auto mod = modList->getMod(modEntry); // "reverse conflict" - enabled mod has this one as conflict if (mod.isEnabled() && mod.getValue("conflicts").toStringList().contains(modname)) return addError(modname, QString("This mod conflicts with %1").arg(modEntry)); } for (auto modEntry : mod.getValue("conflicts").toStringList()) { if (modList->hasMod(modEntry) && modList->getMod(modEntry).isEnabled()) // conflicting mod installed and enabled return addError(modname, QString("This mod conflicts with %1").arg(modEntry)); } return true; }
void ICheckFinishPage::init() { auto item = getItemHandle()->getItemInfo(); if (item) { gcWString msg; if (item->isInstalled()) { m_butTryAgain->Show(false); m_butCIP->Show(false); msg = gcWString(Managers::GetString(L"#IF_CHECK_FOUND"), item->getName()); } else { m_butLaunch->Show(false); msg = gcWString(Managers::GetString(L"#IF_CHECK_NOTFOUND"), item->getName()); } m_labInfo->SetLabel(msg); m_labInfo->Wrap(350); Layout(); } else { gcException e(ERR_NULLHANDLE, "Null item for install check."); gcErrorBox(this, "#IF_CHECK_ERRTITLE", "#IF_CHECK_ERROR", e); GetParent()->Close(); } }
void MigrateStandaloneTask::doTask() { auto wildc = gcRefPtr<WildcardManager>::create(); wildc->onNeedSpecialEvent += delegate(&getUserCore()->getNeedWildCardEvent()); for (size_t x=0; x<m_vFileList.size(); x++) { AutoDelFile adf(m_vFileList[x]); XML::gcXMLDocument doc(m_vFileList[x].getFullPath().c_str()); if (!doc.IsValid()) continue; auto root = doc.GetRoot("game"); if (!root.IsValid()) continue; gcString path; gcString id; uint32 branch = -1; uint32 build = -1; root.GetChild("path", path); root.GetChild("id", id); root.GetChild("branch", branch); root.GetChild("build", build); if (id == "" || !UTIL::FS::isValidFolder(path)) continue; DesuraId itemId(id.c_str(), "games"); auto info = getUserCore()->getItemManager()->findItemInfo(itemId); if (!info || info->isInstalled()) continue; try { getUserCore()->getCIPManager()->updateItem(itemId, path); getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc); } catch (...) { continue; } info = getUserCore()->getItemManager()->findItemInfo(itemId); auto realInfo = gcRefPtr<UserCore::Item::ItemInfo>::dyn_cast(info); if (!realInfo) continue; realInfo->migrateStandalone(MCFBranch::BranchFromInt(branch), MCFBuild::BuildFromInt(build)); } }
/* < saveconfig */ void saveconfig( struct menuInfo* theSelectedInfo) { if (isInstalled()) { return; } say( Saysaveconfig); say( PleasePressKey); if (getAnswer() != MENU_Yes) { return; } // This menu requires yasr buildConfigurationYasr(&(theSelectedInfo->myTextToSpeech), 1); char* aCommand=TheLine; // sprintf(aCommand, "/usr/sbin/saveconfig"); sprintf(aCommand, "/usr/sbin/knoppix-mkimage"); runYasr( &(theSelectedInfo->myTextToSpeech), theSelectedInfo->myMenuLanguage, aCommand); }
bool CModEntry::isEnabled() const { if (!isInstalled()) return false; return modSettings["active"].toBool(); }
int CModEntry::getModStatus() const { return (isEnabled() ? ModStatus::ENABLED : 0) | (isInstalled() ? ModStatus::INSTALLED : 0) | (isUpdateable()? ModStatus::UPDATEABLE : 0); }
CCObject* EziFacebookFriend::copyWithZone(CCZone *pZone) { CCZone* pNewZone = NULL; EziFacebookFriend* pCopy = NULL; if(pZone && pZone->m_pCopyObject) { //in case of being called at sub class pCopy = (EziFacebookFriend*)(pZone->m_pCopyObject); } else { pCopy = new EziFacebookFriend(); pNewZone = new CCZone(pCopy); } pCopy->setName(getName()); pCopy->setID(getFBID()); pCopy->setScore(getScore()); pCopy->setPhotoPath(getPhotoPath()); pCopy->setInstalled(isInstalled()); pCopy->setPhotoURL(getPhotoURL()); //pCopy->initWithAction((CCActionInterval *)(m_pInner->copy()->autorelease())); CC_SAFE_DELETE(pNewZone); return pCopy; }
bool QtServiceController::start(const QStringList &arguments) { if (!isInstalled()) return false; if (isRunning()) return false; return QProcess::startDetached(serviceFilePath(), arguments); }
void LoadSave::saveVarToConfig(var config_state) { if (!isInstalled()) return; File config_file = getConfigFile(); if (!config_file.exists()) config_file.create(); config_file.replaceWithText(JSON::toString(config_state)); }
enum ShutdownStatus askIfShutdownIsRequired() { ENTER("askIfShutdownIsRequired"); enum ShutdownStatus aStatus=StatusUndefined; say(DoYouWantToShutdown); say(PleasePressKey); if (MENU_Yes == getAnswer()) { // RAF GC /* say(ToEjectCD); */ /* if (MENU_Yes == getAnswer()) */ /* { */ if (!isInstalled()) { sayForce(ThenReturnOnceEjected); } aStatus=StatusEjectCDROMAndShutdown; SHOW("StatusEjectCDROMAndShutdown"); /* } */ /* else */ /* { */ /* aStatus=StatusKeepCDROMAndShutdown; */ /* SHOW("StatusKeepCDROMAndShutdown"); */ /* } */ } else { say(DoYouWantToReboot); if (MENU_Yes == getAnswer()) { if (!isInstalled()) { sayForce(ThenReturnOnceEjected); } aStatus=StatusReboot; SHOW("StatusReboot"); } } clearStoredSentences(); return aStatus; }
bool CModManager::canUninstallMod(QString modname) { auto mod = modList->getMod(modname); if (!mod.isInstalled()) return addError(modname, "Mod is not installed"); if (mod.isEnabled()) return addError(modname, "Mod must be disabled first"); return true; }
bool CModManager::canInstallMod(QString modname) { auto mod = modList->getMod(modname); if (mod.isInstalled()) return addError(modname, "Mod is already installed"); if (!mod.isAvailable()) return addError(modname, "Mod is not available"); return true; }
bool CModEntry::isUpdateable() const { if (!isInstalled()) return false; QString installedVer = localData["installedVersion"].toString(); QString availableVer = repository["latestVersion"].toString(); if (compareVersions(installedVer, availableVer)) return true; return false; }
int CModEntry::getModStatus() const { int status = 0; if(isEnabled()) status |= ModStatus::ENABLED; if(isInstalled()) status |= ModStatus::INSTALLED; if(isUpdateable()) status |= ModStatus::UPDATEABLE; return status; }
void CModListView::on_installButton_clicked() { QString modName = ui->allModsView->currentIndex().data(ModRoles::ModNameRole).toString(); assert(findInvalidDependencies(modName).empty()); for (auto & name : modModel->getRequirements(modName)) { auto mod = modModel->getMod(name); if (!mod.isInstalled()) downloadFile(name + ".zip", mod.getValue("download").toString(), "mods"); } }
void CModListView::on_updateButton_clicked() { QString modName = modModel->modIndexToName(filterModel->mapToSource(ui->allModsView->currentIndex()).row()); assert(findInvalidDependencies(modName).empty()); for (auto & name : modModel->getRequirements(modName)) { auto mod = modModel->getMod(name); // update required mod, install missing (can be new dependency) if (mod.isUpdateable() || !mod.isInstalled()) downloadFile(name + ".zip", mod.getValue("download").toString(), "mods"); } }
QStringList CModListView::findDependentMods(QString mod, bool excludeDisabled) { QStringList ret; for (QString modName : modModel->getModList()) { auto current = modModel->getMod(modName); if (!current.isInstalled()) continue; if (current.getValue("depends").toStringList().contains(mod) && !(current.isDisabled() && excludeDisabled)) ret += modName; } return ret; }
bool CModManager::canDisableMod(QString modname) { auto mod = modList->getMod(modname); if(mod.isDisabled()) return addError(modname, "Mod is already disabled"); if(!mod.isInstalled()) return addError(modname, "Mod must be installed first"); for(QString modEntry : modList->getModList()) { auto current = modList->getMod(modEntry); if(current.getValue("depends").toStringList().contains(modname) && current.isEnabled()) return addError(modname, QString("This mod is needed to run %1").arg(modEntry)); } return true; }
File LoadSave::getBankDirectory() { if (!isInstalled()) return File("../../../patches"); File patch_dir = File(""); #ifdef LINUX patch_dir = File(LINUX_BANK_DIRECTORY); #elif defined(__APPLE__) File data_dir = File::getSpecialLocation(File::userApplicationDataDirectory); patch_dir = data_dir.getChildFile(String("Audio/Presets/") + "Helm"); #elif defined(_WIN32) File documents_dir = File::getSpecialLocation(File::userDocumentsDirectory); File parent_dir = documents_dir.getChildFile("Helm"); if (!parent_dir.exists()) parent_dir.createDirectory(); patch_dir = parent_dir.getChildFile("Patches"); #endif if (!patch_dir.exists()) patch_dir.createDirectory(); return patch_dir; }
InstalledPackageVersion* InstalledPackages::findFirstWithMissingDependency() const { InstalledPackageVersion* r = 0; this->mutex.lock(); DBRepository* dbr = DBRepository::getDefault(); QList<InstalledPackageVersion*> all = this->data.values(); for (int i = 0; i < all.count(); i++) { InstalledPackageVersion* ipv = all.at(i); if (ipv->installed()) { QString err; QScopedPointer<PackageVersion> pv(dbr->findPackageVersion_( ipv->package, ipv->version, &err)); // TODO: remove if (!pv.data()) { qDebug() << "cannot find" << ipv->package << ipv->version.getVersionString(); } if (err.isEmpty() && pv.data()) { for (int j = 0; j < pv->dependencies.size(); j++) { if (!isInstalled(*pv->dependencies.at(j))) { r = ipv->clone(); break; } } } } if (r) break; } this->mutex.unlock(); return r; }
void CModListView::selectMod(const QModelIndex & index) { if (!index.isValid()) { disableModInfo(); } else { auto mod = modModel->getMod(index.data(ModRoles::ModNameRole).toString()); ui->modInfoBrowser->setHtml(genModInfoText(mod)); ui->changelogBrowser->setHtml(genChangelogText(mod)); bool hasInvalidDeps = !findInvalidDependencies(index.data(ModRoles::ModNameRole).toString()).empty(); bool hasBlockingMods = !findBlockingMods(index.data(ModRoles::ModNameRole).toString()).empty(); bool hasDependentMods = !findDependentMods(index.data(ModRoles::ModNameRole).toString(), true).empty(); ui->hideModInfoButton->setEnabled(true); ui->showInfoButton->setVisible(!ui->modInfoWidget->isVisible()); ui->disableButton->setVisible(mod.isEnabled()); ui->enableButton->setVisible(mod.isDisabled()); ui->installButton->setVisible(mod.isAvailable() && !mod.getName().contains('.')); ui->uninstallButton->setVisible(mod.isInstalled() && !mod.getName().contains('.')); ui->updateButton->setVisible(mod.isUpdateable()); // Block buttons if action is not allowed at this time // TODO: automate handling of some of these cases instead of forcing player // to resolve all conflicts manually. ui->disableButton->setEnabled(!hasDependentMods); ui->enableButton->setEnabled(!hasBlockingMods && !hasInvalidDeps); ui->installButton->setEnabled(!hasInvalidDeps); ui->uninstallButton->setEnabled(!hasDependentMods); ui->updateButton->setEnabled(!hasInvalidDeps && !hasDependentMods); loadScreenshots(); } }
static inline bool __is_installed(const Version* version) { auto binaryVersion = dynamic_cast< const BinaryVersion* >(version); return (binaryVersion && binaryVersion->isInstalled()); }
bool CModEntry::isAvailable() const { if (isInstalled()) return false; return !repository.isEmpty(); }
bool CModEntry::isDisabled() const { if (!isInstalled()) return false; return !isEnabled(); }
void CModListView::installMods(QStringList archives) { QStringList modNames; for (QString archive : archives) { // get basename out of full file name // remove path remove extension QString modName = archive.section('/', -1, -1).section('.', 0, 0); modNames.push_back(modName); } QStringList modsToEnable; // disable mod(s), to properly recalculate dependencies, if changed for (QString mod : boost::adaptors::reverse(modNames)) { CModEntry entry = modModel->getMod(mod); if (entry.isInstalled()) { // enable mod if installed and enabled if (entry.isEnabled()) modsToEnable.push_back(mod); } else { // enable mod if m if (settings["launcher"]["enableInstalledMods"].Bool()) modsToEnable.push_back(mod); } } // uninstall old version of mod, if installed for (QString mod : boost::adaptors::reverse(modNames)) { if (modModel->getMod(mod).isInstalled()) manager->uninstallMod(mod); } for (int i=0; i<modNames.size(); i++) manager->installMod(modNames[i], archives[i]); std::function<void(QString)> enableMod; enableMod = [&](QString modName) { auto mod = modModel->getMod(modName); if (mod.isInstalled() && !mod.getValue("keepDisabled").toBool()) { if (manager->enableMod(modName)) { for (QString child : modModel->getChildren(modName)) enableMod(child); } } }; for (QString mod : modsToEnable) { enableMod(mod); } for (QString archive : archives) QFile::remove(archive); checkManagerErrors(); }
void Factory::check(const Tag &tag) { if (!isInstalled(tag.getName())) { error(tag); } }