diff --git a/account.cpp b/account.cpp index c0da6fb..b17ff97 100644 --- a/account.cpp +++ b/account.cpp @@ -49,8 +49,3 @@ NostaleAuth *Account::getAuthenticator() const { return authenticator; } - -void Account::setGfVersion(QString ver) -{ - authenticator->setGfVersion(ver); -} diff --git a/account.h b/account.h index d2ac3e1..5c8ee3f 100644 --- a/account.h +++ b/account.h @@ -28,8 +28,6 @@ class Account : public QObject NostaleAuth *getAuthenticator() const; - void setGfVersion(QString ver); - private: QString gameforgeAccountUsername; NostaleAuth* authenticator; diff --git a/mainwindow.cpp b/mainwindow.cpp index 8059ba5..44d549c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -22,7 +22,6 @@ MainWindow::MainWindow(QWidget *parent) connect(settingsDialog, &SettingsDialog::autoLoginStateChanged, ui->characterLabel, &QLabel::setEnabled); connect(settingsDialog, &SettingsDialog::profilesPathSelected, this, &MainWindow::loadAccountProfiles); connect(settingsDialog, &SettingsDialog::identityPathSelected, this, &MainWindow::loadIdentity); - connect(settingsDialog, &SettingsDialog::gfVersionChanged, this, &MainWindow::updateGfVersion); loadSettings(); } @@ -37,7 +36,6 @@ void MainWindow::on_openAccountsButton_clicked() if (ui->accountsListWidget->currentRow() < 0) return; if (!checkGameClientPath()) return; if (!checkIdentityPath()) return; - if (!checkGfVersion()) return; int openInterval = settingsDialog->getOpenInterval(); QString gameforgeAccountUsername = ui->gameforgeAccountComboBox->currentText(); @@ -115,7 +113,6 @@ void MainWindow::loadSettings() settingsDialog->setServer(settings.value("server", 0).toInt()); ui->channelComboBox->setCurrentIndex(settings.value("channel", 0).toInt()); ui->characterComboBox->setCurrentIndex(settings.value("character", 0).toInt()); - settingsDialog->setGfClientVersion(settings.value("gfver").toString()); settings.endGroup(); @@ -149,7 +146,6 @@ void MainWindow::saveSettings() settings.setValue("server", settingsDialog->getServer()); settings.setValue("channel", ui->channelComboBox->currentIndex()); settings.setValue("character", ui->characterComboBox->currentIndex()); - settings.setValue("gfver", settingsDialog->getGfClientVersion()); settings.endGroup(); settings.beginGroup("Gameforge Accounts"); @@ -302,7 +298,7 @@ void MainWindow::displayProfiles(const QString &gameforgeAccount) void MainWindow::addGameforgeAccount(const QString &email, const QString &password) { - NostaleAuth* nostaleAuth = new NostaleAuth(identity, settingsDialog->getGfClientVersion(), this); + NostaleAuth* nostaleAuth = new NostaleAuth(identity, this); bool captcha = false; bool wrongCredentials = false; QString gfChallengeId; @@ -350,25 +346,6 @@ void MainWindow::loadIdentity(const QString &path) identity->load(path); } -void MainWindow::updateGfVersion(QString gfver) -{ - for (auto accs : accounts) - { - accs->setGfVersion(gfver); - } -} - -bool MainWindow::checkGfVersion() -{ - if (settingsDialog->getGfClientVersion().isEmpty()) - { - QMessageBox::critical(this, "Error", "Gameforge Client version is empty. Please set it up on Options > Settings"); - return false; - } - - return true; -} - void MainWindow::createTrayIcon() { QAction* showAction = new QAction("Show", this); diff --git a/mainwindow.h b/mainwindow.h index 7a3d869..b8dff64 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -89,8 +89,6 @@ private slots: void displayProfiles(const QString& gameforgeAccount); void addGameforgeAccount(const QString& email, const QString& password); void loadIdentity(const QString& path); - void updateGfVersion(QString gfver); - bool checkGfVersion(); Ui::MainWindow *ui; SettingsDialog* settingsDialog; diff --git a/nostaleauth.cpp b/nostaleauth.cpp index a3003c5..f5434b1 100644 --- a/nostaleauth.cpp +++ b/nostaleauth.cpp @@ -1,11 +1,11 @@ #include "nostaleauth.h" -NostaleAuth::NostaleAuth(const std::shared_ptr &id, const QString &gfver, QObject *parent) : QObject(parent), identity(id) +NostaleAuth::NostaleAuth(const std::shared_ptr &id, QObject *parent) : QObject(parent), identity(id) { this->locale = QLocale().name(); this->browserUserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"; - setGfVersion(gfver); + initGfVersion(); initCert(); initInstallationId(); initAllCerts(); @@ -60,6 +60,10 @@ bool NostaleAuth::authenthicate(const QString &email, const QString &password, b request.setRawHeader("Origin", "spark://www.gameforge.com"); request.setRawHeader("Connection", "Keep-Alive"); + identity->update(); + BlackBox blackbox(identity, QJsonValue::Null); + + content["blackbox"] = blackbox.encoded(); content["email"] = email; content["locale"] = locale; content["password"] = password; @@ -140,12 +144,6 @@ QString NostaleAuth::getToken(const QString &accountId) return jsonResponse["code"].toString(); } -void NostaleAuth::setGfVersion(QString ver) -{ - this->chromeVersion = "C" + ver; - this->gameforgeVersion = ver.left(ver.lastIndexOf(".")); -} - QChar NostaleAuth::getFirstNumber(QString uuid) { for (const auto& c : uuid) @@ -332,3 +330,25 @@ void NostaleAuth::initPrivateKey() this->privateKey = QSslKey(key, QSsl::Rsa); } + +void NostaleAuth::initGfVersion() +{ + QJsonObject jsonResponse; + QNetworkRequest request(QUrl("http://dl.tnt.gameforge.com/tnt/final-ms3/clientversioninfo.json")); + SyncNetworAccesskManager networkManager(this); + QNetworkReply* reply = nullptr; + + + reply = networkManager.get(request); + reply->deleteLater(); + + QByteArray response = reply->readAll(); + + if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() != 200) + return; + + jsonResponse = QJsonDocument::fromJson(response).object(); + + this->chromeVersion = "C" + jsonResponse["version"].toString(); + this->gameforgeVersion = jsonResponse["minimumVersionForDelayedUpdate"].toString(); +} diff --git a/nostaleauth.h b/nostaleauth.h index c13922a..624fad7 100644 --- a/nostaleauth.h +++ b/nostaleauth.h @@ -20,7 +20,7 @@ class NostaleAuth : public QObject { Q_OBJECT public: - explicit NostaleAuth(const std::shared_ptr& id, const QString& gfver, QObject *parent = nullptr); + explicit NostaleAuth(const std::shared_ptr& id, QObject *parent = nullptr); QMap getAccounts(); @@ -28,8 +28,6 @@ class NostaleAuth : public QObject QString getToken(const QString& accountId); - void setGfVersion(QString ver); - signals: void captchaStart(); void captchaEnd(); @@ -53,6 +51,8 @@ class NostaleAuth : public QObject void initPrivateKey(); + void initGfVersion(); + QString locale; QString installationId; QString chromeVersion; diff --git a/settingsdialog.cpp b/settingsdialog.cpp index e4782c4..af6ab54 100644 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -60,11 +60,6 @@ bool SettingsDialog::autoLogIn() const return ui->autoLogInCheckBox->isChecked(); } -QString SettingsDialog::getGfClientVersion() const -{ - return ui->gfClientVersionEdit->text(); -} - void SettingsDialog::setGameClientPath(const QString &path) { ui->gameClientPathLineEdit->setText(path); @@ -106,11 +101,6 @@ void SettingsDialog::setAutoLogin(bool login) ui->autoLogInCheckBox->setChecked(login); } -void SettingsDialog::setGfClientVersion(const QString &version) -{ - ui->gfClientVersionEdit->setText(version); -} - void SettingsDialog::on_selectGamePathButton_clicked() { QString path = QFileDialog::getOpenFileName(this, "Select NostaleClientX.exe", QDir::rootPath(), "NostaleClientX.exe (NostaleClientX.exe)"); @@ -169,8 +159,3 @@ void SettingsDialog::on_selectIdentityButton_clicked() } -void SettingsDialog::on_gfClientVersionEdit_textChanged(const QString &arg1) -{ - emit gfVersionChanged(arg1); -} - diff --git a/settingsdialog.h b/settingsdialog.h index e2af550..7671993 100644 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -34,8 +34,6 @@ class SettingsDialog : public QDialog bool autoLogIn() const; - QString getGfClientVersion() const; - void setGameClientPath(const QString& path); void setProfilesPath(const QString& path); @@ -52,8 +50,6 @@ class SettingsDialog : public QDialog void setAutoLogin(bool login); - void setGfClientVersion(const QString& version); - signals: void autoLoginStateChanged(bool); @@ -61,8 +57,6 @@ class SettingsDialog : public QDialog void identityPathSelected(QString); - void gfVersionChanged(QString); - private slots: void on_selectGamePathButton_clicked(); @@ -72,8 +66,6 @@ private slots: void on_selectIdentityButton_clicked(); - void on_gfClientVersionEdit_textChanged(const QString &arg1); - private: void initLanguageComboBox(); diff --git a/settingsdialog.ui b/settingsdialog.ui index 3ef4629..a49cc6d 100644 --- a/settingsdialog.ui +++ b/settingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 391 - 297 + 388 + 267 @@ -16,24 +16,24 @@ - - + + - Nostale path: + Identity path: - - + + - + true - + Select @@ -41,52 +41,6 @@ - - - - Game language: - - - - - - - - 80 - 0 - - - - - - - - - - - Open interval: - - - - - - - - 80 - 0 - - - - Qt::AlignCenter - - - secs - - - 0 - - - @@ -112,24 +66,24 @@ - - + + - Identity path: + Nostale path: - - + + - + true - + Select @@ -138,14 +92,50 @@ - + - GF client version: + Game language: - + + + + 80 + 0 + + + + + + + + + + + Open interval: + + + + + + + + 80 + 0 + + + + Qt::AlignCenter + + + secs + + + 0 + +