| 554 | } |
| 555 | |
| 556 | bool 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 | |
| 610 | bool checkSteam(QWidget* parent, const SpawnParameters& sp, const QDir& gameDirectory, |
| 611 | const QString& steamAppID, const Settings& settings) |
no test coverage detected