23 #include "doomseekerconfig.h" 25 #include "configuration/queryspeed.h" 26 #include "gui/models/serverlistproxymodel.h" 28 #include "ini/inisection.h" 29 #include "ini/inivariable.h" 30 #include "ini/settingsproviderqt.h" 31 #include "pathfinder/filealias.h" 32 #include "pathfinder/filesearchpath.h" 33 #include "plugins/engineplugin.h" 34 #include "updater/updatechannel.h" 35 #include "wadseeker/wadseeker.h" 36 #include "datapaths.h" 37 #include "fileutils.h" 38 #include "localizationinfo.h" 41 #include "strings.hpp" 48 static PatternList readPre1Point2BuddiesList(
const QString &configEntry)
52 Scanner listReader(configEntry.toUtf8().constData(), configEntry.length());
54 while (listReader.tokensLeft())
56 if (!listReader.checkToken(TK_Identifier))
61 QRegExp::PatternSyntax syntax;
62 if (listReader->str().compare(
"basic") == 0)
63 syntax = QRegExp::Wildcard;
65 syntax = QRegExp::RegExp;
67 if (!listReader.checkToken(TK_StringConst))
72 QRegExp pattern(listReader->str(), Qt::CaseInsensitive, syntax);
73 if (pattern.isValid())
78 if (!listReader.checkToken(
';'))
88 DoomseekerConfig::DoomseekerConfig()
90 this->dummySection =
new IniSection(NULL, QString());
93 DoomseekerConfig::~DoomseekerConfig()
95 delete this->dummySection;
100 if (instance == NULL)
110 if (instance != NULL)
119 if (pluginName.isEmpty())
121 gLog << QObject::tr(
"DoomseekerConfig.iniSectionForPlugin(): empty plugin name has been specified, returning dummy IniSection.");
122 return *dummySection;
125 if (!isValidPluginName(pluginName))
127 gLog << QObject::tr(
"DoomseekerConfig.iniSectionForPlugin(): plugin name is invalid: %1").arg(pluginName);
128 return *dummySection;
131 if (this->pIni == NULL)
136 QString sectionName = pluginName;
137 sectionName = sectionName.replace(
' ',
"");
138 return this->pIni->section(sectionName);
146 bool DoomseekerConfig::isValidPluginName(
const QString& pluginName)
const 148 QString invalids[] = {
"doomseeker",
"wadseeker",
"" };
150 for (
int i = 0; !invalids[i].isEmpty(); ++i)
152 if (pluginName.compare(invalids[i], Qt::CaseInsensitive) == 0)
168 IniSection sectionDoomseeker = pIni->section(doomseeker.SECTION_NAME);
169 doomseeker.load(sectionDoomseeker);
171 IniSection sectionServerFilter = pIni->section(serverFilter.SECTION_NAME);
172 serverFilter.load(sectionServerFilter);
174 IniSection sectionWadseeker = pIni->section(wadseeker.SECTION_NAME);
175 wadseeker.load(sectionWadseeker);
177 IniSection sectionAutoUpdates = pIni->section(autoUpdates.SECTION_NAME);
178 autoUpdates.load(sectionAutoUpdates);
199 IniSection sectionDoomseeker = pIni->section(doomseeker.SECTION_NAME);
200 doomseeker.save(sectionDoomseeker);
202 IniSection sectionServerFilter = pIni->section(serverFilter.SECTION_NAME);
203 serverFilter.save(sectionServerFilter);
205 IniSection sectionWadseeker = pIni->section(wadseeker.SECTION_NAME);
206 wadseeker.save(sectionWadseeker);
208 IniSection sectionAutoUpdates = pIni->section(autoUpdates.SECTION_NAME);
209 autoUpdates.save(sectionAutoUpdates);
212 if (this->settings->isWritable())
214 this->settings->sync();
224 this->settingsProvider.reset();
225 this->settings.reset();
227 gLog << QObject::tr(
"Setting INI file: %1").arg(filePath);
229 this->settings.reset(
new QSettings(filePath, QSettings::IniFormat));
231 this->pIni.reset(
new Ini(this->settingsProvider.data()));
236 section = this->pIni->section(doomseeker.SECTION_NAME);
237 doomseeker.
init(section);
239 section = this->pIni->section(serverFilter.SECTION_NAME);
240 serverFilter.init(section);
242 section = this->pIni->section(wadseeker.SECTION_NAME);
243 wadseeker.
init(section);
245 section = this->pIni->section(autoUpdates.SECTION_NAME);
246 autoUpdates.init(section);
251 QList<FileSearchPath> DoomseekerConfig::combinedWadseekPaths()
const 253 QList<FileSearchPath> paths = doomseeker.wadPaths;
254 paths << wadseeker.targetDirectory;
259 DClass<DoomseekerConfig::DoomseekerCfg>
265 QString slotStyle()
const 270 const int NUM_SLOTSTYLES = 2;
271 const char* indexedSlotStyles[NUM_SLOTSTYLES] = {
"marines",
"blocks" };
273 int numeric = section[
"SlotStyle"].
value().toInt(&isInt);
274 if (isInt && numeric >= 0 && numeric < NUM_SLOTSTYLES)
276 return indexedSlotStyles[numeric];
280 return section[
"SlotStyle"].valueString();
287 const QString DoomseekerConfig::DoomseekerCfg::SECTION_NAME =
"Doomseeker";
289 DoomseekerConfig::DoomseekerCfg::DoomseekerCfg()
291 this->bBotsAreNotPlayers =
true;
292 this->bCloseToTrayIcon =
false;
293 this->bColorizeServerConsole =
true;
294 this->bDrawGridInServerTable =
false;
295 this->bHidePasswords =
false;
296 this->bGroupServersWithPlayersAtTheTopOfTheList =
true;
297 this->bIP2CountryAutoUpdate =
true;
298 this->bLookupHosts =
true;
299 this->bQueryAutoRefreshDontIfActive =
true;
300 this->bQueryAutoRefreshEnabled =
false;
301 this->bQueryBeforeLaunch =
true;
302 this->bQueryOnStartup =
true;
303 this->bRecordDemo =
false;
304 this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn =
true;
305 this->bUseTrayIcon =
false;
306 this->bMarkServersWithBuddies =
true;
307 this->buddyServersColor =
"#5ecf75";
308 this->customServersColor =
"#ffaa00";
309 this->lanServersColor =
"#92ebe5";
311 this->mainWindowState =
"";
312 this->mainWindowGeometry =
"";
313 this->queryAutoRefreshEverySeconds = 180;
314 setQuerySpeed(QuerySpeed::aggressive());
315 this->previousCreateServerConfigDir =
"";
316 this->previousCreateServerExecDir =
"";
317 this->previousCreateServerWadDir =
"";
319 this->serverListSortIndex = -1;
320 this->serverListSortDirection = Qt::DescendingOrder;
321 this->wadPaths = FileSearchPath::fromStringList(gDefaultDataPaths->defaultWadPaths());
324 DoomseekerConfig::DoomseekerCfg::~DoomseekerCfg()
328 QList<ColumnSort> DoomseekerConfig::DoomseekerCfg::additionalSortColumns()
const 330 QList<ColumnSort> list;
331 QVariantList varList = d->section.value(
"AdditionalSortColumns").toList();
332 foreach (
const QVariant &var, varList)
334 list << ColumnSort::deserializeQVariant(var);
339 void DoomseekerConfig::DoomseekerCfg::setAdditionalSortColumns(
const QList<ColumnSort> &val)
341 QVariantList varList;
344 varList << elem.serializeQVariant();
346 d->section.setValue(
"AdditionalSortColumns", varList);
352 d->section = section;
354 section.
createSetting(
"BotsAreNotPlayers", this->bBotsAreNotPlayers);
355 section.
createSetting(
"CloseToTrayIcon", this->bCloseToTrayIcon);
356 section.
createSetting(
"ColorizeServerConsole", this->bColorizeServerConsole);
357 section.
createSetting(
"DrawGridInServerTable", this->bDrawGridInServerTable);
358 section.
createSetting(
"HidePasswords", this->bHidePasswords);
359 section.
createSetting(
"GroupServersWithPlayersAtTheTopOfTheList", this->bGroupServersWithPlayersAtTheTopOfTheList);
360 section.
createSetting(
"IP2CAutoUpdate", this->bIP2CountryAutoUpdate);
362 section.
createSetting(
"QueryAutoRefreshDontIfActive", this->bQueryAutoRefreshDontIfActive);
363 section.
createSetting(
"QueryAutoRefreshEnabled", this->bQueryAutoRefreshEnabled);
364 section.
createSetting(
"QueryOnStartup", this->bQueryOnStartup);
366 section.
createSetting(
"TellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn", this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn);
368 section.
createSetting(
"MarkServersWithBuddies", this->bMarkServersWithBuddies);
369 section.
createSetting(
"BuddyServersColor", this->buddyServersColor);
370 section.
createSetting(
"CustomServersColor", this->customServersColor);
371 section.
createSetting(
"LanServersColor", this->lanServersColor);
372 section.
createSetting(
"QueryAutoRefreshEverySeconds", this->queryAutoRefreshEverySeconds);
373 section.
createSetting(
"QueryServerInterval", this->querySpeed().intervalBetweenServers);
374 section.
createSetting(
"QueryServerTimeout", this->querySpeed().delayBetweenSingleServerAttempts);
375 section.
createSetting(
"QueryAttemptsPerServer", this->querySpeed().attemptsPerServer);
377 section.
createSetting(
"ServerListSortIndex", this->serverListSortIndex);
378 section.
createSetting(
"ServerListSortDirection", this->serverListSortDirection);
379 section.
createSetting(
"WadPaths", FileSearchPath::toVariantList(this->wadPaths));
384 void DoomseekerConfig::DoomseekerCfg::initWadAlias()
386 if (!d->section.hasSetting(
"WadAliases"))
392 void DoomseekerConfig::DoomseekerCfg::load(
IniSection& section)
394 this->localization = (
const QString&)section[
"Localization"];
395 this->bBotsAreNotPlayers = section[
"BotsAreNotPlayers"];
396 this->bCloseToTrayIcon = section[
"CloseToTrayIcon"];
397 this->bColorizeServerConsole = section[
"ColorizeServerConsole"];
398 this->bDrawGridInServerTable = section[
"DrawGridInServerTable"];
399 this->bHidePasswords = section[
"HidePasswords"];
400 this->bGroupServersWithPlayersAtTheTopOfTheList = section[
"GroupServersWithPlayersAtTheTopOfTheList"];
401 this->bIP2CountryAutoUpdate = section[
"IP2CAutoUpdate"];
402 this->bLookupHosts = section[
"LookupHosts"];
403 this->bQueryAutoRefreshDontIfActive = section[
"QueryAutoRefreshDontIfActive"];
404 this->bQueryAutoRefreshEnabled = section[
"QueryAutoRefreshEnabled"];
405 this->bQueryBeforeLaunch = section[
"QueryBeforeLaunch"];
406 this->bQueryOnStartup = section[
"QueryOnStartup"];
407 this->bRecordDemo = section[
"RecordDemo"];
408 this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn = section[
"TellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn"];
409 this->bUseTrayIcon = section[
"UseTrayIcon"];
410 this->bMarkServersWithBuddies = section[
"MarkServersWithBuddies"];
411 this->buddyServersColor = (
const QString &)section[
"BuddyServersColor"];
412 this->customServersColor = (
const QString &)section[
"CustomServersColor"];
413 this->lanServersColor = (
const QString &)section[
"LanServersColor"];
414 this->mainWindowState = (
const QString &)section[
"MainWindowState"];
415 this->mainWindowGeometry = section.
value(
"MainWindowGeometry",
"").toByteArray();
416 this->queryAutoRefreshEverySeconds = section[
"QueryAutoRefreshEverySeconds"];
417 d->querySpeed.intervalBetweenServers = section[
"QueryServerInterval"];
418 d->querySpeed.delayBetweenSingleServerAttempts = section[
"QueryServerTimeout"];
419 d->querySpeed.attemptsPerServer = section[
"QueryAttemptsPerServer"];
420 this->previousCreateServerConfigDir = (
const QString &)section[
"PreviousCreateServerConfigDir"];
421 this->previousCreateServerExecDir = (
const QString &)section[
"PreviousCreateServerExecDir"];
422 this->previousCreateServerWadDir = (
const QString &)section[
"PreviousCreateServerWadDir"];
423 this->serverListColumnState = (
const QString &)section[
"ServerListColumnState"];
424 this->serverListSortIndex = section[
"ServerListSortIndex"];
425 this->serverListSortDirection = section[
"ServerListSortDirection"];
426 this->slotStyle = d->slotStyle();
436 QList<CustomServerInfo> customServersList;
438 QList<CustomServerInfo> backwardCompatibleServers;
440 foreach (
const CustomServerInfo &backwardCompatibleServer, backwardCompatibleServers)
452 customServersList << backwardCompatibleServer;
454 this->customServers = customServersList.toVector();
458 QVariant variantWadPaths = section[
"WadPaths"].
value();
459 if (variantWadPaths.isValid() && variantWadPaths.toList().isEmpty())
463 QStringList paths = variantWadPaths.toString().split(
";");
464 foreach (
const QString& path, paths)
472 wadPaths = FileSearchPath::fromVariantList(section[
"WadPaths"].value().toList());
479 this->buddies = PatternList::deserializeQVariant(section.
value(
"Buddies"));
484 this->buddies = readPre1Point2BuddiesList(section[
"BuddiesList"]);
488 void DoomseekerConfig::DoomseekerCfg::save(
IniSection& section)
490 section[
"Localization"] = this->localization;
491 section[
"BotsAreNotPlayers"] = this->bBotsAreNotPlayers;
492 section[
"CloseToTrayIcon"] = this->bCloseToTrayIcon;
493 section[
"ColorizeServerConsole"] = this->bColorizeServerConsole;
494 section[
"DrawGridInServerTable"] = this->bDrawGridInServerTable;
495 section[
"HidePasswords"] = this->bHidePasswords;
496 section[
"GroupServersWithPlayersAtTheTopOfTheList"] = this->bGroupServersWithPlayersAtTheTopOfTheList;
497 section[
"IP2CAutoUpdate"] = this->bIP2CountryAutoUpdate;
498 section[
"LookupHosts"] = this->bLookupHosts;
499 section[
"QueryAutoRefreshDontIfActive"] = this->bQueryAutoRefreshDontIfActive;
500 section[
"QueryAutoRefreshEnabled"] = this->bQueryAutoRefreshEnabled;
501 section[
"QueryBeforeLaunch"] = this->bQueryBeforeLaunch;
502 section[
"QueryOnStartup"] = this->bQueryOnStartup;
503 section[
"RecordDemo"] = this->bRecordDemo;
504 section[
"TellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn"] = this->bTellMeWhereAreTheWADsWhenIHoverCursorOverWADSColumn;
505 section[
"UseTrayIcon"] = this->bUseTrayIcon;
506 section[
"MarkServersWithBuddies"] = this->bMarkServersWithBuddies;
507 section[
"BuddyServersColor"] = this->buddyServersColor;
508 section[
"CustomServersColor"] = this->customServersColor;
509 section[
"LanServersColor"] = this->lanServersColor;
510 section[
"MainWindowState"] = this->mainWindowState;
511 section.
setValue(
"MainWindowGeometry", this->mainWindowGeometry);
512 section[
"QueryAutoRefreshEverySeconds"] = this->queryAutoRefreshEverySeconds;
513 section[
"QueryServerInterval"] = this->querySpeed().intervalBetweenServers;
514 section[
"QueryServerTimeout"] = this->querySpeed().delayBetweenSingleServerAttempts;
515 section[
"QueryAttemptsPerServer"] = this->querySpeed().attemptsPerServer;
516 section[
"PreviousCreateServerConfigDir"] = this->previousCreateServerConfigDir;
517 section[
"PreviousCreateServerExecDir"] = this->previousCreateServerExecDir;
518 section[
"PreviousCreateServerWadDir"] = this->previousCreateServerWadDir;
519 section[
"ServerListColumnState"] = this->serverListColumnState;
520 section[
"ServerListSortIndex"] = this->serverListSortIndex;
521 section[
"ServerListSortDirection"] = this->serverListSortDirection;
522 section[
"SlotStyle"] = this->slotStyle;
527 QStringList allCustomServers;
528 QStringList allCustomServers2;
531 QString engineName = QUrl::toPercentEncoding(customServer.engine,
"",
"()");
532 QString address = QUrl::toPercentEncoding(customServer.host,
"",
"()");
534 QString customServerStringPrefix = QString(
"(%1;%2;%3")
535 .arg(engineName).arg(address)
536 .arg(customServer.port);
537 QString customServerString2 = QString(
"%1;%2)")
538 .arg(customServerStringPrefix)
539 .arg(customServer.enabled ? 1 : 0);
541 allCustomServers << customServerStringPrefix +
")";
542 allCustomServers2 << customServerString2;
544 section[
"CustomServers"] = allCustomServers.join(
";");
545 section[
"CustomServers2"] = allCustomServers2.join(
";");
547 section[
"WadPaths"].
setValue(FileSearchPath::toVariantList(this->wadPaths));
548 section[
"Buddies"].
setValue(this->buddies.serializeQVariant());
551 const QuerySpeed &DoomseekerConfig::DoomseekerCfg::querySpeed()
const 553 return d->querySpeed;
556 void DoomseekerConfig::DoomseekerCfg::setQuerySpeed(
const QuerySpeed &val)
561 QList<FileAlias> DoomseekerConfig::DoomseekerCfg::wadAliases()
const 563 QList<FileAlias> list;
564 QVariantList varList = d->section.value(
"WadAliases").toList();
565 foreach (
const QVariant &var, varList)
567 list << FileAlias::deserializeQVariant(var);
569 return FileAliasList::mergeDuplicates(list);
572 void DoomseekerConfig::DoomseekerCfg::setWadAliases(
const QList<FileAlias> &val)
574 QVariantList varList;
577 varList << elem.serializeQVariant();
579 d->section.setValue(
"WadAliases", varList);
582 void DoomseekerConfig::DoomseekerCfg::enableFreedoomInstallation(
const QString &dir)
586 wadPaths.prepend(dir);
588 QList<FileAlias> aliases = wadAliases();
589 aliases << FileAlias::freeDoom1Aliases();
590 aliases << FileAlias::freeDoom2Aliases();
591 aliases = FileAliasList::mergeDuplicates(aliases);
592 setWadAliases(aliases);
595 QStringList DoomseekerConfig::DoomseekerCfg::wadPathsOnly()
const 600 result << path.path();
605 const QString DoomseekerConfig::AutoUpdates::SECTION_NAME =
"Doomseeker_AutoUpdates";
607 void DoomseekerConfig::AutoUpdates::init(
IniSection& section)
611 section.
createSetting(
"LastKnownUpdateRevisions", QVariant());
615 void DoomseekerConfig::AutoUpdates::load(
IniSection& section)
617 updateChannelName = (
const QString &)section[
"UpdateChannelName"];
618 updateMode = (UpdateMode)section[
"UpdateMode"].value().toInt();
619 QVariantMap lastKnownUpdateRevisionsVariant = section[
"LastKnownUpdateRevisions"].
value().toMap();
620 lastKnownUpdateRevisions.clear();
621 foreach (
const QString& package, lastKnownUpdateRevisionsVariant.keys())
623 QVariant revisionVariant = lastKnownUpdateRevisionsVariant[package];
624 lastKnownUpdateRevisions.insert(package, revisionVariant.toString());
626 bPerformUpdateOnNextRun = section[
"bPerformUpdateOnNextRun"].
value().toBool();
629 void DoomseekerConfig::AutoUpdates::save(
IniSection& section)
631 section[
"UpdateChannelName"] = updateChannelName;
632 section[
"UpdateMode"] = updateMode;
633 QVariantMap revisionsVariantMap;
634 foreach (
const QString& package, lastKnownUpdateRevisions.keys())
636 revisionsVariantMap.insert(package, lastKnownUpdateRevisions[package]);
638 section[
"LastKnownUpdateRevisions"].
setValue(revisionsVariantMap);
639 section[
"bPerformUpdateOnNextRun"].
setValue(bPerformUpdateOnNextRun);
642 const QString DoomseekerConfig::ServerFilter::SECTION_NAME =
"ServerFilter";
644 void DoomseekerConfig::ServerFilter::init(
IniSection& section)
654 section.
createSetting(
"TestingServers", Doomseeker::Indifferent);
659 void DoomseekerConfig::ServerFilter::load(
IniSection& section)
661 info.bEnabled = section[
"bEnabled"];
662 info.bShowEmpty = section[
"bShowEmpty"];
663 info.bShowFull = section[
"bShowFull"];
664 info.bShowOnlyValid = section[
"bShowOnlyValid"];
665 info.gameModes = section[
"GameModes"].
value().toStringList();
666 info.gameModesExcluded = section[
"GameModesExcluded"].
value().toStringList();
667 info.maxPing = section[
"MaxPing"];
668 info.serverName = (
const QString &)section[
"ServerName"];
669 info.testingServers =
static_cast<Doomseeker::ShowMode
>(section.
value(
"TestingServers").toInt());
670 info.wads = section[
"WADs"].
value().toStringList();
671 info.wadsExcluded = section[
"WADsExcluded"].
value().toStringList();
674 void DoomseekerConfig::ServerFilter::save(
IniSection& section)
676 section[
"bEnabled"] = info.bEnabled;
677 section[
"bShowEmpty"] = info.bShowEmpty;
678 section[
"bShowFull"] = info.bShowFull;
679 section[
"bShowOnlyValid"] = info.bShowOnlyValid;
680 section[
"GameModes"].
setValue(info.gameModes);
681 section[
"GameModesExcluded"].
setValue(info.gameModesExcluded);
682 section[
"MaxPing"] = info.maxPing;
683 section[
"ServerName"] = info.serverName;
684 section[
"TestingServers"] = info.testingServers;
685 section[
"WADs"].
setValue(info.wads);
686 section[
"WADsExcluded"].
setValue(info.wadsExcluded);
689 const QString DoomseekerConfig::WadseekerCfg::SECTION_NAME =
"Wadseeker";
691 DoomseekerConfig::WadseekerCfg::WadseekerCfg()
693 this->bAlwaysUseDefaultSites =
true;
694 this->bSearchInIdgames =
true;
695 this->bSearchInWadArchive =
true;
696 this->colorMessageCriticalError =
"#ff0000";
697 this->colorMessageError =
"#ff0000";
698 this->colorMessageNotice =
"#000000";
699 this->connectTimeoutSeconds = WADSEEKER_CONNECT_TIMEOUT_SECONDS_DEFAULT;
700 this->downloadTimeoutSeconds = WADSEEKER_DOWNLOAD_TIMEOUT_SECONDS_DEFAULT;
701 this->idgamesURL = Wadseeker::defaultIdgamesUrl();
702 this->maxConcurrentSiteDownloads = 3;
703 this->maxConcurrentWadDownloads = 2;
704 this->targetDirectory = gDefaultDataPaths->programsDataDirectoryPath();
713 section.
createSetting(
"AlwaysUseDefaultSites", this->bAlwaysUseDefaultSites);
714 section.
createSetting(
"SearchInIdgames", this->bSearchInIdgames);
715 section.
createSetting(
"SearchInWadArchive", this->bSearchInWadArchive);
716 section.
createSetting(
"ColorMessageCriticalError", this->colorMessageCriticalError);
717 section.
createSetting(
"ColorMessageError", this->colorMessageError);
718 section.
createSetting(
"ColorMessageNotice", this->colorMessageNotice);
719 section.
createSetting(
"ConnectTimeoutSeconds", this->connectTimeoutSeconds);
720 section.
createSetting(
"DownloadTimeoutSeconds", this->downloadTimeoutSeconds);
722 section.
createSetting(
"MaxConcurrentSiteDownloads", this->maxConcurrentSiteDownloads);
723 section.
createSetting(
"MaxConcurrentWadDownloads", this->maxConcurrentWadDownloads);
724 section.
createSetting(
"SearchURLs", Wadseeker::defaultSitesListEncoded().join(
";"));
725 section.
createSetting(
"TargetDirectory", this->targetDirectory);
728 void DoomseekerConfig::WadseekerCfg::load(
IniSection& section)
730 this->bAlwaysUseDefaultSites = section[
"AlwaysUseDefaultSites"];
731 this->bSearchInIdgames = section[
"SearchInIdgames"];
732 this->bSearchInWadArchive = section[
"SearchInWadArchive"];
733 this->colorMessageCriticalError = (
const QString &)section[
"ColorMessageCriticalError"];
734 this->colorMessageError = (
const QString &)section[
"ColorMessageError"];
735 this->colorMessageNotice = (
const QString &)section[
"ColorMessageNotice"];
736 this->connectTimeoutSeconds = section[
"ConnectTimeoutSeconds"];
737 this->downloadTimeoutSeconds = section[
"DownloadTimeoutSeconds"];
738 this->idgamesURL = (
const QString &)section[
"IdgamesApiURL"];
739 this->maxConcurrentSiteDownloads = section[
"MaxConcurrentSiteDownloads"];
740 this->maxConcurrentWadDownloads = section[
"MaxConcurrentWadDownloads"];
741 this->targetDirectory = (
const QString &)section[
"TargetDirectory"];
744 this->searchURLs.clear();
745 QStringList urlList = section[
"SearchURLs"].valueString().split(
";", QString::SkipEmptyParts);
746 foreach (
const QString& url, urlList)
748 this->searchURLs << QUrl::fromPercentEncoding(url.toUtf8());
752 void DoomseekerConfig::WadseekerCfg::save(
IniSection& section)
754 section[
"AlwaysUseDefaultSites"] = this->bAlwaysUseDefaultSites;
755 section[
"SearchInIdgames"] = this->bSearchInIdgames;
756 section[
"SearchInWadArchive"] = this->bSearchInWadArchive;
757 section[
"ColorMessageCriticalError"] = this->colorMessageCriticalError;
758 section[
"ColorMessageError"] = this->colorMessageError;
759 section[
"ColorMessageNotice"] = this->colorMessageNotice;
760 section[
"ConnectTimeoutSeconds"] = this->connectTimeoutSeconds;
761 section[
"DownloadTimeoutSeconds"] = this->downloadTimeoutSeconds;
762 section[
"IdgamesApiURL"] = this->idgamesURL;
763 section[
"MaxConcurrentSiteDownloads"] = this->maxConcurrentSiteDownloads;
764 section[
"MaxConcurrentWadDownloads"] = this->maxConcurrentWadDownloads;
765 section[
"TargetDirectory"] = this->targetDirectory;
768 QStringList urlEncodedList;
769 foreach (
const QString& url, this->searchURLs)
771 urlEncodedList << QUrl::toPercentEncoding(url);
773 section[
"SearchURLs"] = urlEncodedList.join(
";");
IniVariable createSetting(const QString &name, const QVariant &data)
Inits specified variable with specified data.
void init(IniSection §ion)
Initializes values that are not present in the section yet.
bool saveToFile()
Saves current settings to ini file. This file must be previously set by setIniFile() method...
QString localeName
Compliant with language_country standard. See QLocale::name()
This Singleton holds entire Doomseeker configuration in memory.
static bool containsPath(const QStringList &candidates, const QString &path)
Uses QFileInfo::operator== to see if 'path' is on 'candidates' list.
QVariant value(const QString &key) const
Retrieves a variable directly; omits the IniVariable system.
IniSection iniSectionForPlugin(const QString &pluginName)
This will assume that the .ini file is initialized.
static QList< FileAlias > standardWadAliases()
Standard/default aliases for configuration init.
bool hasSetting(const QString &name) const
true if setting of given name exists within the section.
static void decodeConfigEntries(const QString &str, QList< CustomServerInfo > &outCustomServerInfoList)
bool isSameServer(const CustomServerInfo &other) const
void init(IniSection §ion)
Initializes values that are not present in the section yet.
bool readFromFile()
Reads settings from ini file. This file must be previously set by setIniFile() method.
static UpdateChannel mkStable()
Creates "stable" channel object.
static DoomseekerConfig & config()
Returns the Singleton.
void setValue(const QString &key, const QVariant &value)
Sets a variable directly. Omits the IniVariable system.
INI section representation.
Scanner reads scripts by checking individual tokens.
bool setIniFile(const QString &filePath)
Initializes the Ini class instance to point to a file.
static void dispose()
Disposes of the Singleton.
static const LocalizationInfo SYSTEM_FOLLOW