MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / startSteam

Function startSteam

src/spawn.cpp:556–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

554}
555
556bool startSteam(QWidget* parent)
557{
558 const QString keyName = "HKEY_CURRENT_USER\\Software\\Valve\\Steam";
559 const QString valueName = "SteamExe";
560
561 const QSettings steamSettings(keyName, QSettings::NativeFormat);
562 const QString exe = steamSettings.value(valueName, "").toString();
563
564 if (exe.isEmpty()) {
565 return (dialogs::badSteamReg(parent, keyName, valueName) == QMessageBox::Yes);
566 }
567
568 SpawnParameters sp;
569 sp.binary = QFileInfo(exe);
570
571 // See if username and password supplied. If so, pass them into steam.
572 QString username, password;
573 if (Settings::instance().steam().login(username, password)) {
574 if (username.length() > 0)
575 MOBase::log::getDefault().addToBlacklist(username.toStdString(),
576 "STEAM_USERNAME");
577 if (password.length() > 0)
578 MOBase::log::getDefault().addToBlacklist(password.toStdString(),
579 "STEAM_PASSWORD");
580 sp.arguments = makeSteamArguments(username, password);
581 }
582
583 log::debug("starting steam process:\n"
584 " . program: '{}'\n"
585 " . username={}, password={}",
586 sp.binary.filePath().toStdString(), (username.isEmpty() ? "no" : "yes"),
587 (password.isEmpty() ? "no" : "yes"));
588
589 HANDLE ph = INVALID_HANDLE_VALUE;
590 const auto e = spawn(sp, ph);
591 ::CloseHandle(ph);
592
593 if (e != ERROR_SUCCESS) {
594 // make sure username and passwords are not shown
595 sp.arguments = makeSteamArguments((username.isEmpty() ? "" : "USERNAME"),
596 (password.isEmpty() ? "" : "PASSWORD"));
597
598 const auto r = dialogs::startSteamFailed(parent, keyName, valueName, exe, sp, e);
599
600 return (r == QMessageBox::Yes);
601 }
602
603 QMessageBox::information(
604 parent, QObject::tr("Waiting"),
605 QObject::tr("Please press OK once you're logged into steam."));
606
607 return true;
608}
609
610bool checkSteam(QWidget* parent, const SpawnParameters& sp, const QDir& gameDirectory,
611 const QString& steamAppID, const Settings& settings)

Callers 1

checkSteamFunction · 0.85

Calls 8

badSteamRegFunction · 0.85
makeSteamArgumentsFunction · 0.85
spawnFunction · 0.85
startSteamFailedFunction · 0.85
loginMethod · 0.80
toStringMethod · 0.45
valueMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected