From 9fe2f6126dc7b9396d188b57ccb097f0035f57b7 Mon Sep 17 00:00:00 2001 From: Silarn Date: Mon, 20 Aug 2018 18:34:31 -0500 Subject: Initial Nexus API changes: - Switch to SSO with WebSocket - Update endpoints (all but version checking) --- src/nxmaccessmanager.h | 61 ++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 37 deletions(-) (limited to 'src/nxmaccessmanager.h') diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index c58c4cc3..b316ef77 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -43,12 +43,12 @@ public: void setNMMVersion(const QString &nmmVersion); - bool loggedIn() const; + bool validated() const; - bool loginAttempted() const; - bool loginWaiting() const; + bool validateAttempted() const; + bool validateWaiting() const; - void login(const QString &username, const QString &password); + void apiCheck(const QString &apiKey); void showCookies() const; @@ -56,9 +56,11 @@ public: QString userAgent(const QString &subModule = QString()) const; - void startLoginCheck(); + QString apiKey() const; - void refuseLogin(); + void startValidationCheck(); + + void refuseValidation(); signals: @@ -74,18 +76,17 @@ signals: * * @param necessary true if a login was necessary and succeeded, false if the user is still logged in **/ - void loginSuccessful(bool necessary); + void validateSuccessful(bool necessary); - void loginFailed(const QString &message); + void validateFailed(const QString &message); void credentialsReceived(const QString &userName, bool premium); private slots: - void loginChecked(); - void loginFinished(); - void loginError(QNetworkReply::NetworkError errorCode); - void loginTimeout(); + void validateFinished(); + void validateError(QNetworkReply::NetworkError errorCode); + void validateTimeout(); protected: @@ -95,38 +96,24 @@ protected: private: - void pageLogin(); -// void dlLogin(); - - bool hasLoginCookies() const; - - void retrieveCredentials(); - -private: - - static const std::set s_PremiumAccountStates; - -private: - - QTimer m_LoginTimeout; - QNetworkReply *m_LoginReply; + QTimer m_ValidateTimeout; + QNetworkReply *m_ValidateReply; QProgressDialog *m_ProgressDialog { nullptr }; QString m_MOVersion; QString m_NMMVersion; - QString m_Username; - QString m_Password; + QString m_ApiKey; - bool m_LoginAttempted; + bool m_ValidateAttempted; enum { - LOGIN_NOT_CHECKED, - LOGIN_CHECKING, - LOGIN_NOT_VALID, - LOGIN_ATTEMPT_FAILED, - LOGIN_REFUSED, - LOGIN_VALID - } m_LoginState = LOGIN_NOT_CHECKED; + VALIDATE_NOT_CHECKED, + VALIDATE_CHECKING, + VALIDATE_NOT_VALID, + VALIDATE_ATTEMPT_FAILED, + VALIDATE_REFUSED, + VALIDATE_VALID + } m_ValidateState = VALIDATE_NOT_CHECKED; }; -- cgit v1.3.1 From ef286a938d79f74947a392d049068e4818ccf7fd Mon Sep 17 00:00:00 2001 From: Silarn Date: Tue, 29 Jan 2019 15:12:59 -0600 Subject: Multiple fixes: * Uses current daily/hourly rate limits * Fixed issue with translating API game string to mod game string ** Corrects issues with update checks and downloads --- src/downloadmanager.cpp | 29 +++++- src/downloadmanager.h | 3 + src/mainwindow.cpp | 20 ++-- src/mainwindow.h | 3 +- src/nexusinterface.cpp | 56 +++++------ src/nexusinterface.h | 11 ++- src/nxmaccessmanager.cpp | 10 +- src/nxmaccessmanager.h | 240 +++++++++++++++++++++++------------------------ 8 files changed, 201 insertions(+), 171 deletions(-) (limited to 'src/nxmaccessmanager.h') diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 2ba46d74..f5e4d688 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -19,11 +19,11 @@ along with Mod Organizer. If not, see . #include "downloadmanager.h" +#include "organizercore.h" #include "nxmurl.h" #include "nexusinterface.h" #include "nxmaccessmanager.h" #include "iplugingame.h" -#include "downloadmanager.h" #include #include #include "utility.h" @@ -203,6 +203,7 @@ QString DownloadManager::DownloadInfo::currentURL() DownloadManager::DownloadManager(NexusInterface *nexusInterface, QObject *parent) : IDownloadManager(parent), m_NexusInterface(nexusInterface), m_DirWatcher(), m_ShowHidden(false) { + m_OrganizerCore = dynamic_cast(parent); connect(&m_DirWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(directoryChanged(QString))); m_TimeoutTimer.setSingleShot(false); //connect(&m_TimeoutTimer, SIGNAL(timeout()), this, SLOT(checkDownloadTimeout())); @@ -1532,7 +1533,16 @@ void DownloadManager::nxmFileInfoAvailable(QString gameName, int modID, int file info->description = BBCode::convertToHTML(result["changelog_html"].toString()); info->repository = "Nexus"; - info->gameName = gameName; + + QStringList games(m_ManagedGame->validShortNames()); + games += m_ManagedGame->gameShortName(); + for (auto game : games) { + MOBase::IPluginGame *gamePlugin = m_OrganizerCore->getGame(game); + if (gamePlugin->gameNexusName().compare(gameName, Qt::CaseInsensitive) == 0) { + info->gameName = gamePlugin->gameShortName(); + } + } + info->modID = modID; info->fileID = fileID; @@ -1597,10 +1607,21 @@ void DownloadManager::nxmDownloadURLsAvailable(QString gameName, int modID, int m_RequestIDs.erase(idIter); } + QString gameShortName; + QStringList games(m_ManagedGame->validShortNames()); + games += m_ManagedGame->gameShortName(); + for (auto game : games) { + MOBase::IPluginGame *gamePlugin = m_OrganizerCore->getGame(game); + if (gamePlugin->gameNexusName() == gameName) { + gameShortName = gamePlugin->gameShortName(); + break; + } + } + ModRepositoryFileInfo *info = qobject_cast(qvariant_cast(userData)); QVariantList resultList = resultData.toList(); if (resultList.length() == 0) { - removePending(gameName, modID, fileID); + removePending(gameShortName, modID, fileID); emit showMessage(tr("No download server available. Please try again later.")); return; } @@ -1614,7 +1635,7 @@ void DownloadManager::nxmDownloadURLsAvailable(QString gameName, int modID, int foreach (const QVariant &server, resultList) { URLs.append(server.toMap()["URI"].toString()); } - addDownload(URLs, gameName, modID, fileID, info); + addDownload(URLs, gameShortName, modID, fileID, info); } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index 3c36143e..841a9fbc 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -40,6 +40,7 @@ namespace MOBase { class IPluginGame; } class NexusInterface; class PluginContainer; +class OrganizerCore; /*! * \brief manages downloading of files and provides progress information for gui elements @@ -532,6 +533,8 @@ private: NexusInterface *m_NexusInterface; + OrganizerCore *m_OrganizerCore; + QVector> m_PendingDownloads; QVector m_ActiveDownloads; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 02720d44..094a44af 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -402,9 +402,9 @@ MainWindow::MainWindow(QSettings &initSettings connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(validateFailed(QString)), this, SLOT(validationFailed(QString))); connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const QString&, bool)), this, SLOT(updateWindowTitle(const QString&, bool))); - connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const QString&, bool)), - NexusInterface::instance(&m_PluginContainer), SLOT(setRateMax(const QString&, bool))); - connect(NexusInterface::instance(&pluginContainer), SIGNAL(requestsChanged(int, int)), this, SLOT(updateAPICounter(int, int))); + connect(NexusInterface::instance(&pluginContainer)->getAccessManager(), SIGNAL(credentialsReceived(const QString&, bool, std::tuple)), + NexusInterface::instance(&m_PluginContainer), SLOT(setRateMax(const QString&, bool, std::tuple))); + connect(NexusInterface::instance(&pluginContainer), SIGNAL(requestsChanged(int, std::tuple)), this, SLOT(updateAPICounter(int, std::tuple))); connect(&TutorialManager::instance(), SIGNAL(windowTutorialFinished(QString)), this, SLOT(windowTutorialFinished(QString))); connect(ui->tabWidget, SIGNAL(currentChanged(int)), &TutorialManager::instance(), SIGNAL(tabChanged(int))); @@ -439,11 +439,6 @@ MainWindow::MainWindow(QSettings &initSettings connect(&m_SaveMetaTimer, SIGNAL(timeout()), this, SLOT(saveModMetas())); m_SaveMetaTimer.start(5000); - m_NexusLimitTimer.setTimerType(Qt::TimerType::PreciseTimer); - m_NexusLimitTimer.setSingleShot(false); - connect(&m_NexusLimitTimer, SIGNAL(timeout()), NexusInterface::instance(&m_PluginContainer), SLOT(calculateRequests())); - m_NexusLimitTimer.start(1000); - setCategoryListVisible(initSettings.value("categorylist_visible", true).toBool()); FileDialogMemory::restore(initSettings); @@ -5640,14 +5635,15 @@ void MainWindow::nxmRequestFailed(QString gameName, int modID, int, QVariant, in } -void MainWindow::updateAPICounter(int queueCount, int requestsRemaining) +void MainWindow::updateAPICounter(int queueCount, std::tuple limits) { - ui->apiRequests->setText(QString("API: Q: %1 | T: %2").arg(queueCount).arg(requestsRemaining)); - if (requestsRemaining > 150) { + ui->apiRequests->setText(QString("API: Q: %1 | D: %2 | H: %3").arg(queueCount).arg(std::get<0>(limits)).arg(std::get<2>(limits))); + int requestsRemaining = std::get<0>(limits) + std::get<2>(limits); + if (requestsRemaining > 300) { QPalette palette = ui->apiRequests->palette(); palette.setColor(ui->apiRequests->backgroundRole(), Qt::darkGreen); ui->apiRequests->setPalette(palette); - } else if (requestsRemaining < 50) { + } else if (requestsRemaining < 150) { QPalette palette = ui->apiRequests->palette(); palette.setColor(ui->apiRequests->backgroundRole(), Qt::darkRed); ui->apiRequests->setPalette(palette); diff --git a/src/mainwindow.h b/src/mainwindow.h index 900f7cba..b3490d07 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -348,7 +348,6 @@ private: QTimer m_CheckBSATimer; QTimer m_SaveMetaTimer; QTimer m_UpdateProblemsTimer; - QTimer m_NexusLimitTimer; QFuture m_MetaSave; @@ -515,7 +514,7 @@ private slots: void nxmDownloadURLs(QString, int modID, int fileID, QVariant userData, QVariant resultData, int requestID); void nxmRequestFailed(QString gameName, int modID, int fileID, QVariant userData, int requestID, QNetworkReply::NetworkError error, const QString &errorString); - void updateAPICounter(int queueCount, int requestsRemaining); + void updateAPICounter(int queueCount, std::tuple limits); void editCategories(); void deselectFilters(); diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index 1e50f0b2..7481cf96 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -148,7 +148,7 @@ QAtomicInt NexusInterface::NXMRequestInfo::s_NextID(0); NexusInterface::NexusInterface(PluginContainer *pluginContainer) - : m_NMMVersion(), m_PluginContainer(pluginContainer), m_RemainingRequests(300), m_MaxRequests(300) + : m_NMMVersion(), m_PluginContainer(pluginContainer), m_RemainingDailyRequests(0), m_RemainingHourlyRequests(0), m_MaxDailyRequests(0), m_MaxHourlyRequests(0) { m_MOVersion = createVersionInfo(); @@ -194,16 +194,13 @@ void NexusInterface::loginCompleted() nextRequest(); } -void NexusInterface::setRateMax(const QString &userName, bool isPremium) +void NexusInterface::setRateMax(const QString&, bool, std::tuple limits) { - if (isPremium) { - m_MaxRequests = 600; - m_RemainingRequests = 600; - } else { - m_MaxRequests = 300; - m_RemainingRequests = 300; - } - emit requestsChanged(m_RequestQueue.size(), m_RemainingRequests); + m_RemainingDailyRequests = std::get<0>(limits); + m_MaxDailyRequests = std::get<1>(limits); + m_RemainingHourlyRequests = std::get<2>(limits); + m_MaxHourlyRequests = std::get<3>(limits); + emit requestsChanged(m_RequestQueue.size(), limits); } void NexusInterface::interpretNexusFileName(const QString &fileName, QString &modName, int &modID, bool query) @@ -474,10 +471,16 @@ void NexusInterface::nextRequest() return; } - if (m_RemainingRequests <= 0) { - qWarning() << tr("You've exceeded the Nexus API rate limit and requests are now being throttled."); - if (!m_RetryTimer.isActive()) - m_RetryTimer.start(); + if (m_RemainingDailyRequests + m_RemainingHourlyRequests <= 0) { + if (!m_RetryTimer.isActive()) { + QTime time = QTime::currentTime(); + QTime targetTime; + targetTime.setHMS((time.hour() + 1) % 23, 0, 5); + m_RetryTimer.start(time.msecsTo(targetTime)); + QString warning("You've exceeded the Nexus API rate limit and requests are now being throttled. " + "Your next batch of requests will be available in approximately %1 minutes and %2 seconds."); + qWarning() << warning.arg(time.secsTo(targetTime) / 60).arg(time.secsTo(targetTime) % 60); + } return; } @@ -490,8 +493,6 @@ void NexusInterface::nextRequest() } } - m_RemainingRequests--; - NXMRequestInfo info = m_RequestQueue.dequeue(); info.m_Timeout = new QTimer(this); info.m_Timeout->setInterval(60000); @@ -545,7 +546,6 @@ void NexusInterface::nextRequest() connect(info.m_Timeout, SIGNAL(timeout()), this, SLOT(requestTimeout())); info.m_Timeout->start(); m_ActiveRequest.push_back(info); - emit requestsChanged(m_RequestQueue.size(), m_RemainingRequests); } @@ -561,8 +561,6 @@ void NexusInterface::requestFinished(std::list::iterator iter) if (reply->error() != QNetworkReply::NoError) { int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if (statusCode == 429) { - m_RemainingRequests = 0; - emit requestsChanged(m_RequestQueue.size(), m_RemainingRequests); qWarning("Requests have hit the rate limit threshold and are now being throttled. This request will be retried."); qWarning("Error: %s", reply->errorString().toUtf8().constData()); m_RequestQueue.enqueue(*iter); @@ -617,6 +615,18 @@ void NexusInterface::requestFinished(std::list::iterator iter) } } } + + m_RemainingDailyRequests = reply->rawHeader("x-rl-daily-remaining").toInt(); + m_MaxDailyRequests = reply->rawHeader("x-rl-daily-limit").toInt(); + m_RemainingHourlyRequests = reply->rawHeader("x-rl-hourly-remaining").toInt(); + m_MaxHourlyRequests = reply->rawHeader("x-rl-hourly-limit").toInt(); + + emit requestsChanged(m_RequestQueue.size(), std::tuple(std::make_tuple( + m_RemainingDailyRequests, + m_MaxDailyRequests, + m_RemainingHourlyRequests, + m_MaxHourlyRequests + ))); } @@ -668,14 +678,6 @@ void NexusInterface::requestTimeout() } } -void NexusInterface::calculateRequests() -{ - if (m_RemainingRequests < m_MaxRequests) { - m_RemainingRequests++; - emit requestsChanged(m_RequestQueue.size(), m_RemainingRequests); - } -} - namespace { QString get_management_url(MOBase::IPluginGame const *game) { diff --git a/src/nexusinterface.h b/src/nexusinterface.h index a68948e6..e60ebf3f 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -348,12 +348,11 @@ signals: void nxmDownloadURLsAvailable(QString gameName, int modID, int fileID, QVariant userData, QVariant resultData, int requestID); void nxmEndorsementToggled(QString gameName, int modID, QVariant userData, QVariant resultData, int requestID); void nxmRequestFailed(QString gameName, int modID, int fileID, QVariant userData, int requestID, QNetworkReply::NetworkError error, const QString &errorString); - void requestsChanged(int queueCount, int requestsRemaining); + void requestsChanged(int queueCount, std::tuple requestsRemaining); public slots: - void setRateMax(const QString &userName, bool isPremium); - void calculateRequests(); + void setRateMax(const QString&, bool, std::tuple limits); private slots: @@ -426,8 +425,10 @@ private: QTimer m_RetryTimer; - int m_RemainingRequests; - int m_MaxRequests; + int m_RemainingDailyRequests; + int m_RemainingHourlyRequests; + int m_MaxDailyRequests; + int m_MaxHourlyRequests; }; diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 6847ba25..d9bb2905 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -252,7 +252,15 @@ void NXMAccessManager::validateFinished() QString test = jdoc.toJson(); QString name = credentialsData.value("name").toString(); bool premium = credentialsData.value("is_premium?").toBool(); - emit credentialsReceived(name, premium); + + std::tuple limits(std::make_tuple( + m_ValidateReply->rawHeader("x-rl-daily-remaining").toInt(), + m_ValidateReply->rawHeader("x-rl-daily-limit").toInt(), + m_ValidateReply->rawHeader("x-rl-hourly-remaining").toInt(), + m_ValidateReply->rawHeader("x-rl-hourly-limit").toInt() + )); + + emit credentialsReceived(name, premium, limits); m_ValidateReply->deleteLater(); m_ValidateReply = nullptr; diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index b316ef77..7fdb508f 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -1,120 +1,120 @@ -/* -Copyright (C) 2012 Sebastian Herbord. All rights reserved. - -This file is part of Mod Organizer. - -Mod Organizer is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -Mod Organizer is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Mod Organizer. If not, see . -*/ - -#ifndef NXMACCESSMANAGER_H -#define NXMACCESSMANAGER_H - - -#include -#include -#include -#include -#include - -namespace MOBase { class IPluginGame; } - -/** - * @brief access manager extended to handle nxm links - **/ -class NXMAccessManager : public QNetworkAccessManager -{ - Q_OBJECT -public: - - explicit NXMAccessManager(QObject *parent, const QString &moVersion); - - ~NXMAccessManager(); - - void setNMMVersion(const QString &nmmVersion); - - bool validated() const; - - bool validateAttempted() const; - bool validateWaiting() const; - - void apiCheck(const QString &apiKey); - - void showCookies() const; - - void clearCookies(); - - QString userAgent(const QString &subModule = QString()) const; - - QString apiKey() const; - - void startValidationCheck(); - - void refuseValidation(); - -signals: - - /** - * @brief emitted when a nxm:// link is opened - * - * @param url the nxm-link - **/ - void requestNXMDownload(const QString &url); - - /** - * @brief emitted after a successful login or if login was not necessary - * - * @param necessary true if a login was necessary and succeeded, false if the user is still logged in - **/ - void validateSuccessful(bool necessary); - - void validateFailed(const QString &message); - - void credentialsReceived(const QString &userName, bool premium); - -private slots: - - void validateFinished(); - void validateError(QNetworkReply::NetworkError errorCode); - void validateTimeout(); - -protected: - - virtual QNetworkReply *createRequest( - QNetworkAccessManager::Operation operation, const QNetworkRequest &request, - QIODevice *device); - -private: - - QTimer m_ValidateTimeout; - QNetworkReply *m_ValidateReply; - QProgressDialog *m_ProgressDialog { nullptr }; - - QString m_MOVersion; - QString m_NMMVersion; - - QString m_ApiKey; - - bool m_ValidateAttempted; - enum { - VALIDATE_NOT_CHECKED, - VALIDATE_CHECKING, - VALIDATE_NOT_VALID, - VALIDATE_ATTEMPT_FAILED, - VALIDATE_REFUSED, - VALIDATE_VALID - } m_ValidateState = VALIDATE_NOT_CHECKED; - -}; - -#endif // NXMACCESSMANAGER_H +/* +Copyright (C) 2012 Sebastian Herbord. All rights reserved. + +This file is part of Mod Organizer. + +Mod Organizer is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Mod Organizer is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Mod Organizer. If not, see . +*/ + +#ifndef NXMACCESSMANAGER_H +#define NXMACCESSMANAGER_H + + +#include +#include +#include +#include +#include + +namespace MOBase { class IPluginGame; } + +/** + * @brief access manager extended to handle nxm links + **/ +class NXMAccessManager : public QNetworkAccessManager +{ + Q_OBJECT +public: + + explicit NXMAccessManager(QObject *parent, const QString &moVersion); + + ~NXMAccessManager(); + + void setNMMVersion(const QString &nmmVersion); + + bool validated() const; + + bool validateAttempted() const; + bool validateWaiting() const; + + void apiCheck(const QString &apiKey); + + void showCookies() const; + + void clearCookies(); + + QString userAgent(const QString &subModule = QString()) const; + + QString apiKey() const; + + void startValidationCheck(); + + void refuseValidation(); + +signals: + + /** + * @brief emitted when a nxm:// link is opened + * + * @param url the nxm-link + **/ + void requestNXMDownload(const QString &url); + + /** + * @brief emitted after a successful login or if login was not necessary + * + * @param necessary true if a login was necessary and succeeded, false if the user is still logged in + **/ + void validateSuccessful(bool necessary); + + void validateFailed(const QString &message); + + void credentialsReceived(const QString &userName, bool premium, std::tuple limits); + +private slots: + + void validateFinished(); + void validateError(QNetworkReply::NetworkError errorCode); + void validateTimeout(); + +protected: + + virtual QNetworkReply *createRequest( + QNetworkAccessManager::Operation operation, const QNetworkRequest &request, + QIODevice *device); + +private: + + QTimer m_ValidateTimeout; + QNetworkReply *m_ValidateReply; + QProgressDialog *m_ProgressDialog { nullptr }; + + QString m_MOVersion; + QString m_NMMVersion; + + QString m_ApiKey; + + bool m_ValidateAttempted; + enum { + VALIDATE_NOT_CHECKED, + VALIDATE_CHECKING, + VALIDATE_NOT_VALID, + VALIDATE_ATTEMPT_FAILED, + VALIDATE_REFUSED, + VALIDATE_VALID + } m_ValidateState = VALIDATE_NOT_CHECKED; + +}; + +#endif // NXMACCESSMANAGER_H -- cgit v1.3.1 From ef80a8bacaab525be21b9beae4992955f5e907d0 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Fri, 22 Feb 2019 04:33:21 -0600 Subject: Remove the spoofed NMM version The new API does not require this and it serves no purpose to keep it. --- src/mainwindow.cpp | 3 +-- src/nexusinterface.cpp | 8 +------- src/nexusinterface.h | 7 ------- src/nxmaccessmanager.cpp | 6 ------ src/nxmaccessmanager.h | 3 --- src/organizercore.cpp | 1 - src/settings.cpp | 13 ------------- src/settings.h | 6 ------ src/settingsdialog.ui | 48 ------------------------------------------------ 9 files changed, 2 insertions(+), 93 deletions(-) (limited to 'src/nxmaccessmanager.h') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 282c9674..602c32df 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1878,6 +1878,7 @@ void MainWindow::processUpdates() { instance.remove("nexus_login"); instance.remove("nexus_api_key"); instance.remove("ask_for_nexuspw"); + instance.remove("nmm_version"); instance.endGroup(); instance.beginGroup("Servers"); instance.remove(""); @@ -4905,8 +4906,6 @@ void MainWindow::on_actionSettings_triggered() activateProxy(settings.useProxy()); } - NexusInterface::instance(&m_PluginContainer)->setNMMVersion(settings.getNMMVersion()); - updateDownloadView(); m_OrganizerCore.updateVFSParams(settings.logLevel(), settings.crashDumpsType(), settings.executablesBlacklist()); diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp index ee40be22..23dd7dbe 100644 --- a/src/nexusinterface.cpp +++ b/src/nexusinterface.cpp @@ -156,7 +156,7 @@ QAtomicInt NexusInterface::NXMRequestInfo::s_NextID(0); NexusInterface::NexusInterface(PluginContainer *pluginContainer) - : m_NMMVersion(), m_PluginContainer(pluginContainer), m_RemainingDailyRequests(2500), m_RemainingHourlyRequests(100), m_MaxDailyRequests(2500), m_MaxHourlyRequests(100) + : m_PluginContainer(pluginContainer), m_RemainingDailyRequests(2500), m_RemainingHourlyRequests(100), m_MaxDailyRequests(2500), m_MaxHourlyRequests(100) { m_MOVersion = createVersionInfo(); @@ -187,12 +187,6 @@ void NexusInterface::setCacheDirectory(const QString &directory) m_AccessManager->setCache(m_DiskCache); } -void NexusInterface::setNMMVersion(const QString &nmmVersion) -{ - m_NMMVersion = nmmVersion; - m_AccessManager->setNMMVersion(nmmVersion); -} - void NexusInterface::loginCompleted() { nextRequest(); diff --git a/src/nexusinterface.h b/src/nexusinterface.h index c18c7103..c1f9da41 100644 --- a/src/nexusinterface.h +++ b/src/nexusinterface.h @@ -335,12 +335,6 @@ public: **/ void setCacheDirectory(const QString &directory); - /** - * MO has to send a "Nexus Client Vx.y.z" as part of the user agent to be allowed to use the API - * @param nmmVersion the version of nmm to impersonate - **/ - void setNMMVersion(const QString &nmmVersion); - /** * @brief called when the log-in completes. This was, requests waiting for the log-in can be run */ @@ -485,7 +479,6 @@ private: QQueue m_RequestQueue; MOBase::VersionInfo m_MOVersion; - QString m_NMMVersion; PluginContainer *m_PluginContainer; diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index aca1d785..428aa3f3 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -69,11 +69,6 @@ NXMAccessManager::~NXMAccessManager() } } -void NXMAccessManager::setNMMVersion(const QString &nmmVersion) -{ - m_NMMVersion = nmmVersion; -} - QNetworkReply *NXMAccessManager::createRequest( QNetworkAccessManager::Operation operation, const QNetworkRequest &request, QIODevice *device) @@ -202,7 +197,6 @@ QString NXMAccessManager::userAgent(const QString &subModule) const else comments << QSysInfo::kernelType().left(1).toUpper() + QSysInfo::kernelType().mid(1) << QSysInfo::productType().left(1).toUpper() + QSysInfo::kernelType().mid(1) + " " + QSysInfo::productVersion(); - comments << "Nexus Client v" + m_NMMVersion; if (!subModule.isEmpty()) { comments << "module: " + subModule; } diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index 7fdb508f..da7736cc 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -41,8 +41,6 @@ public: ~NXMAccessManager(); - void setNMMVersion(const QString &nmmVersion); - bool validated() const; bool validateAttempted() const; @@ -101,7 +99,6 @@ private: QProgressDialog *m_ProgressDialog { nullptr }; QString m_MOVersion; - QString m_NMMVersion; QString m_ApiKey; diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 2f75439d..caad45c9 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -292,7 +292,6 @@ OrganizerCore::OrganizerCore(const QSettings &initSettings) m_DownloadManager.setPreferredServers(m_Settings.getPreferredServers()); NexusInterface::instance(m_PluginContainer)->setCacheDirectory(m_Settings.getCacheDirectory()); - NexusInterface::instance(m_PluginContainer)->setNMMVersion(m_Settings.getNMMVersion()); MOBase::QuestionBoxMemory::init(initSettings.fileName()); diff --git a/src/settings.cpp b/src/settings.cpp index 67a84c0a..942005f8 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -353,16 +353,6 @@ QString Settings::getOverwriteDirectory(bool resolve) const ToQString(AppConfig::overwritePath()), resolve); } -QString Settings::getNMMVersion() const -{ - static const QString MIN_NMM_VERSION = "0.65.2"; - QString result = m_Settings.value("Settings/nmm_version", MIN_NMM_VERSION).toString(); - if (VersionInfo(result) < VersionInfo(MIN_NMM_VERSION)) { - result = MIN_NMM_VERSION; - } - return result; -} - bool Settings::getNexusApiKey(QString &apiKey) const { QString tempKey = deObfuscate("APIKEY"); @@ -1179,7 +1169,6 @@ Settings::WorkaroundsTab::WorkaroundsTab(Settings *m_parent, : Settings::SettingsTab(m_parent, m_dialog) , m_appIDEdit(m_dialog.findChild("appIDEdit")) , m_mechanismBox(m_dialog.findChild("mechanismBox")) - , m_nmmVersionEdit(m_dialog.findChild("nmmVersionEdit")) , m_hideUncheckedBox(m_dialog.findChild("hideUncheckedBox")) , m_forceEnableBox(m_dialog.findChild("forceEnableBox")) , m_displayForeignBox(m_dialog.findChild("displayForeignBox")) @@ -1214,7 +1203,6 @@ Settings::WorkaroundsTab::WorkaroundsTab(Settings *m_parent, m_mechanismBox->setCurrentIndex(index); - m_nmmVersionEdit->setText(m_parent->getNMMVersion()); m_hideUncheckedBox->setChecked(m_parent->hideUncheckedPlugins()); m_forceEnableBox->setChecked(m_parent->forceEnableCoreFiles()); m_displayForeignBox->setChecked(m_parent->displayForeign()); @@ -1233,7 +1221,6 @@ void Settings::WorkaroundsTab::update() m_Settings.remove("Settings/app_id"); } m_Settings.setValue("Settings/load_mechanism", m_mechanismBox->itemData(m_mechanismBox->currentIndex()).toInt()); - m_Settings.setValue("Settings/nmm_version", m_nmmVersionEdit->text()); m_Settings.setValue("Settings/hide_unchecked_plugins", m_hideUncheckedBox->isChecked()); m_Settings.setValue("Settings/force_enable_core_files", m_forceEnableBox->isChecked()); m_Settings.setValue("Settings/display_foreign", m_displayForeignBox->isChecked()); diff --git a/src/settings.h b/src/settings.h index 2cd3f0b6..3744a493 100644 --- a/src/settings.h +++ b/src/settings.h @@ -152,11 +152,6 @@ public: **/ QString getModDirectory(bool resolve = true) const; - /** - * returns the version of nmm to impersonate when connecting to nexus - **/ - QString getNMMVersion() const; - /** * retrieve the directory where the web cache is stored (with native separators) **/ @@ -525,7 +520,6 @@ private: private: QLineEdit *m_appIDEdit; QComboBox *m_mechanismBox; - QLineEdit *m_nmmVersionEdit; QCheckBox *m_hideUncheckedBox; QCheckBox *m_forceEnableBox; QCheckBox *m_displayForeignBox; diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 127c94c7..e56b3435 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -959,53 +959,6 @@ If you use the Steam version of Oblivion the default will NOT work. In this case - - - - - - NMM Version - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - The Version of Nexus Mod Manager to impersonate. - - - Mod Organizer uses an API provided by the Nexus to provide features like checking for updates and downloading files. Unfortunately this API has not been made available officially to third party tools like MO so we have to impersonate the Nexus Mod Manager to be allowed in. -On top of this Nexus has used the client identification to lock out outdated versions of NMM to force users to update. This means that MO also needs to impersonate the new version of NMM even if MO doesn't need an update. Therefore you can configure the version to identify as here. -Please note that MO does identify itself as MO to the webserver, it's not lying about what it is. It is merely adding a "compatible" NMM version to the user agent. - -tl;dr-version: If Nexus-features don't work, insert the current version number of NMM here and try again. - - - 009.009.009 - - - Qt::AlignCenter - - - - - - - - @@ -1388,7 +1341,6 @@ programs you are intentionally running. pluginBlacklist appIDEdit mechanismBox - nmmVersionEdit bsaDateBtn tabWidget -- cgit v1.3.1