summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Tanner <trtanner@btinternet.com>2015-11-26 17:48:50 +0000
committerThomas Tanner <trtanner@btinternet.com>2015-11-26 17:48:50 +0000
commitdd37152eae382ee95535b289b17b0a727e4038f5 (patch)
tree5e88903380163a31c4c1edc1989d600f3859026a
parent82e6c98043bd18f5329e8b6d0a6f99c4d28cc0a2 (diff)
This removes getNexusPage from GameInfo and is currently in the game plugin.
I'm looking to move it to the nexus interface though as it doesn't really relate to the game plugin. I've also removed the MananagementURL as - you can log into nexus without needing to specify the game - See above - it doesn't belong with the game plugin This gets rid of all dependencies bar game saving and logging in
-rw-r--r--src/mainwindow.cpp25
-rw-r--r--src/modinfodialog.cpp14
-rw-r--r--src/nexusinterface.cpp13
-rw-r--r--src/nxmaccessmanager.cpp35
-rw-r--r--src/nxmaccessmanager.h6
-rw-r--r--src/shared/fallout3info.cpp9
-rw-r--r--src/shared/fallout3info.h2
-rw-r--r--src/shared/falloutnvinfo.cpp10
-rw-r--r--src/shared/falloutnvinfo.h2
-rw-r--r--src/shared/gameinfo.h2
-rw-r--r--src/shared/oblivioninfo.cpp14
-rw-r--r--src/shared/oblivioninfo.h2
-rw-r--r--src/shared/skyriminfo.cpp11
-rw-r--r--src/shared/skyriminfo.h4
14 files changed, 46 insertions, 103 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 3a2da562..3f3d5286 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -19,6 +19,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "mainwindow.h"
#include "ui_mainwindow.h"
+
#include "spawn.h"
#include "report.h"
#include "modlist.h"
@@ -68,7 +69,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <questionboxmemory.h>
#include <taskprogressmanager.h>
#include <util.h>
-#include "gameinfo.h"
+#include <scopeguard.h>
#include <QTime>
#include <QInputDialog>
@@ -95,10 +96,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QtPlugin>
#include <QIdentityProxyModel>
#include <QClipboard>
-#include <Psapi.h>
-#include <shlobj.h>
-#include <ShellAPI.h>
-#include <TlHelp32.h>
#include <QNetworkInterface>
#include <QNetworkProxy>
#include <QJsonDocument>
@@ -113,7 +110,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#endif
#include <QCoreApplication>
#include <QProgressDialog>
-#include <scopeguard.h>
#ifndef Q_MOC_RUN
#include <boost/thread.hpp>
@@ -123,6 +119,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <boost/assign.hpp>
#endif
+#include <Psapi.h>
+#include <shlobj.h>
+#include <ShellAPI.h>
+#include <TlHelp32.h>
+
#include <sstream>
#include <regex>
#include <functional>
@@ -2528,7 +2529,7 @@ void MainWindow::visitOnNexus_clicked()
{
int modID = m_OrganizerCore.modList()->data(m_OrganizerCore.modList()->index(m_ContextRow, 0), Qt::UserRole).toInt();
if (modID > 0) {
- nexusLinkActivated(QString("%1/mods/%2").arg(ToQString(GameInfo::instance().getNexusPage(false))).arg(modID));
+ nexusLinkActivated(QString("%1/mods/%2").arg(m_OrganizerCore.managedGame()->getNexusDisplayURL()).arg(modID));
} else {
MessageDialog::showMessage(tr("Nexus ID for this Mod is unknown"), this);
}
@@ -3420,7 +3421,9 @@ void MainWindow::on_actionSettings_triggered()
void MainWindow::on_actionNexus_triggered()
{
- ::ShellExecuteW(nullptr, L"open", GameInfo::instance().getNexusPage(false).c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+ ::ShellExecuteW(nullptr, L"open",
+ m_OrganizerCore.managedGame()->getNexusDisplayURL().toStdWString().c_str(),
+ nullptr, nullptr, SW_SHOWNORMAL);
}
@@ -3814,11 +3817,11 @@ void MainWindow::on_actionUpdate_triggered()
void MainWindow::on_actionEndorseMO_triggered()
{
if (QMessageBox::question(this, tr("Endorse Mod Organizer"),
- tr("Do you want to endorse Mod Organizer on %1 now?").arg(ToQString(GameInfo::instance().getNexusPage())),
+ tr("Do you want to endorse Mod Organizer on %1 now?").arg(
+ m_OrganizerCore.managedGame()->getNexusDisplayURL()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
- //Why pass an empty variant if we're toggling an endorsement?
NexusInterface::instance()->requestToggleEndorsement(
- m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), "");
+ m_OrganizerCore.managedGame()->getNexusModOrganizerID(), true, this, QVariant(), QString());
}
}
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp
index 35da228b..c4acb31e 100644
--- a/src/modinfodialog.cpp
+++ b/src/modinfodialog.cpp
@@ -20,6 +20,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "modinfodialog.h"
#include "ui_modinfodialog.h"
+#include "iplugingame.h"
#include "report.h"
#include "utility.h"
#include "messagedialog.h"
@@ -36,9 +37,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QMessageBox>
#include <QMenu>
#include <QFileSystemModel>
+#include <QInputDialog>
+
#include <Shlwapi.h>
+
#include <sstream>
-#include <QInputDialog>
using namespace MOBase;
@@ -688,7 +691,9 @@ void ModInfoDialog::on_visitNexusLabel_linkActivated(const QString &link)
void ModInfoDialog::linkClicked(const QUrl &url)
{
- if (url.toString().startsWith(ToQString(GameInfo::instance().getNexusPage(false)))) {
+ //FIXME: See elsewhere. This needs to be a property of the installed mod.
+ IPluginGame *game = qApp->property("managed_game").value<IPluginGame*>();
+ if (game->isRelatedURL(url)) {
this->close();
emit nexusLinkActivated(url.toString());
} else {
@@ -832,7 +837,10 @@ void ModInfoDialog::activateNexusTab()
QLineEdit *modIDEdit = findChild<QLineEdit*>("modIDEdit");
int modID = modIDEdit->text().toInt();
if (modID != 0) {
- QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(ToQString(GameInfo::instance().getNexusPage(false))).arg(modID);
+ //FIXME: We should remember the game for which this mod was installed in the
+ //modInfo and get the web page via that.
+ IPluginGame *game = qApp->property("managed_game").value<IPluginGame*>();
+ QString nexusLink = QString("%1/downloads/file.php?id=%2").arg(game->getNexusDisplayURL()).arg(modID);
QLabel *visitNexusLabel = findChild<QLabel*>("visitNexusLabel");
visitNexusLabel->setText(tr("<a href=\"%1\">Visit on Nexus</a>").arg(nexusLink));
visitNexusLabel->setToolTip(nexusLink);
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index 8a7c88b6..b6843c57 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -555,9 +555,14 @@ void NexusInterface::requestTimeout()
void NexusInterface::managedGameChanged(IPluginGame const *game)
{
m_Game = game;
- m_AccessManager->managedGameChanged(game);
}
+namespace {
+ QString get_management_url(MOBase::IPluginGame const *game)
+ {
+ return "http://nmm.nexusmods.com/" + game->getNexusName().toLower();
+ }
+}
NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, NexusInterface::NXMRequestInfo::Type type
@@ -573,7 +578,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, m_Timeout(nullptr)
, m_Reroute(false)
, m_ID(s_NextID.fetchAndAddAcquire(1))
- , m_URL(game->getNexusManagementURL())
+ , m_URL(get_management_url(game))
, m_SubModule(subModule)
, m_NexusGameID(game->getNexusGameID())
, m_Endorse(false)
@@ -594,7 +599,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(std::vector<int> modIDList
, m_Timeout(nullptr)
, m_Reroute(false)
, m_ID(s_NextID.fetchAndAddAcquire(1))
- , m_URL(game->getNexusManagementURL())
+ , m_URL(get_management_url(game))
, m_SubModule(subModule)
, m_NexusGameID(game->getNexusGameID())
, m_Endorse(false)
@@ -615,7 +620,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, m_Timeout(nullptr)
, m_Reroute(false)
, m_ID(s_NextID.fetchAndAddAcquire(1))
- , m_URL(game->getNexusManagementURL())
+ , m_URL(get_management_url(game))
, m_SubModule(subModule)
, m_NexusGameID(game->getNexusGameID())
, m_Endorse(false)
diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp
index 08572d50..c37131eb 100644
--- a/src/nxmaccessmanager.cpp
+++ b/src/nxmaccessmanager.cpp
@@ -26,7 +26,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "selfupdater.h"
#include "persistentcookiejar.h"
#include "settings.h"
-#include <gameinfo.h>
#include <json.h>
#include <QMessageBox>
@@ -42,10 +41,11 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QJsonDocument>
#include <QJsonArray>
-
using namespace MOBase;
-using namespace MOShared;
+namespace {
+ QString const Nexus_Management_URL("http://nmm.nexusmods.com");
+}
// unfortunately Nexus doesn't seem to document these states, all I know is all these listed
// are considered premium (27 should be lifetime premium)
@@ -99,8 +99,7 @@ QNetworkReply *NXMAccessManager::createRequest(
void NXMAccessManager::showCookies() const
{
- QUrl url(ToQString(GameInfo::instance().getNexusPage()) + "/");
-
+ QUrl url(Nexus_Management_URL + "/");
for (const QNetworkCookie &cookie : cookieJar()->cookiesForUrl(url)) {
qDebug("%s - %s (expires: %s)",
cookie.name().constData(), cookie.value().constData(),
@@ -113,7 +112,7 @@ void NXMAccessManager::startLoginCheck()
{
if (hasLoginCookies()) {
qDebug("validating login cookies");
- QNetworkRequest request(ToQString(GameInfo::instance().getNexusPage()) + "/Sessions/?Validate");
+ QNetworkRequest request(Nexus_Management_URL + "/Sessions/?Validate");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
request.setRawHeader("User-Agent", userAgent().toUtf8());
@@ -131,12 +130,7 @@ void NXMAccessManager::retrieveCredentials()
{
qDebug("retrieving credentials");
- //This may be overkill as
- //www.nexusmods.com/Core/Libs/Flamework/Entities/User?GetCredentials
- //seems to work fine.
- QNetworkRequest request(m_Game->getNexusManagementURL()
- + QString("/Core/Libs/Flamework/Entities/User?GetCredentials&game_id=%1"
- ).arg(m_Game->getNexusGameID()));
+ QNetworkRequest request(Nexus_Management_URL + "/Core/Libs/Flamework/Entities/User?GetCredentials");
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
request.setRawHeader("User-Agent", userAgent().toUtf8());
@@ -231,8 +225,9 @@ QString NXMAccessManager::userAgent(const QString &subModule) const
void NXMAccessManager::pageLogin()
{
qDebug("logging %s in on Nexus", qPrintable(m_Username));
- QString requestString = (ToQString(GameInfo::instance().getNexusPage()) + "/Sessions/?Login&uri=%1")
- .arg(QString(QUrl::toPercentEncoding(ToQString(GameInfo::instance().getNexusPage()))));
+
+ QString requestString = (Nexus_Management_URL + "/Sessions/?Login&uri=%1")
+ .arg(QString(QUrl::toPercentEncoding(Nexus_Management_URL)));
QNetworkRequest request(requestString);
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
@@ -296,15 +291,14 @@ void NXMAccessManager::loginError(QNetworkReply::NetworkError)
bool NXMAccessManager::hasLoginCookies() const
{
- bool sidCookie = false;
- QUrl url(ToQString(GameInfo::instance().getNexusPage()) + "/");
+ QUrl url(Nexus_Management_URL + "/");
QList<QNetworkCookie> cookies = cookieJar()->cookiesForUrl(url);
for (const QNetworkCookie &cookie : cookies) {
if (cookie.name() == "sid") {
- sidCookie = true;
+ return true;
}
}
- return sidCookie;
+ return false;
}
@@ -345,8 +339,3 @@ void NXMAccessManager::loginChecked()
m_LoginReply->deleteLater();
m_LoginReply = nullptr;
}
-
-void NXMAccessManager::managedGameChanged(MOBase::IPluginGame const *game)
-{
- m_Game = game;
-}
diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h
index 2a016cad..82bd2bd5 100644
--- a/src/nxmaccessmanager.h
+++ b/src/nxmaccessmanager.h
@@ -85,10 +85,6 @@ private slots:
void loginError(QNetworkReply::NetworkError errorCode);
void loginTimeout();
-public:
- //This would be a slot but the NexusInterface code calls this
- void managedGameChanged(MOBase::IPluginGame const *game);
-
protected:
virtual QNetworkReply *createRequest(
@@ -130,8 +126,6 @@ private:
LOGIN_VALID
} m_LoginState = LOGIN_NOT_CHECKED;
- MOBase::IPluginGame const *m_Game;
-
};
#endif // NXMACCESSMANAGER_H
diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp
index cb2a3adf..043a25dc 100644
--- a/src/shared/fallout3info.cpp
+++ b/src/shared/fallout3info.cpp
@@ -78,15 +78,6 @@ std::wstring Fallout3Info::getReferenceDataFile()
return L"Fallout - Meshes.bsa";
}
-std::wstring Fallout3Info::getNexusPage(bool nmmScheme)
-{
- if (nmmScheme) {
- return L"http://nmm.nexusmods.com/fallout3";
- } else {
- return L"http://www.nexusmods.com/fallout3";
- }
-}
-
bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h
index e6064825..ed525588 100644
--- a/src/shared/fallout3info.h
+++ b/src/shared/fallout3info.h
@@ -49,8 +49,6 @@ public:
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getNexusPage(bool nmmScheme = true);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
// get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp
index bfc31c0b..88985ad6 100644
--- a/src/shared/falloutnvinfo.cpp
+++ b/src/shared/falloutnvinfo.cpp
@@ -78,16 +78,6 @@ std::wstring FalloutNVInfo::getReferenceDataFile()
return L"Fallout - Meshes.bsa";
}
-std::wstring FalloutNVInfo::getNexusPage(bool nmmScheme)
-{
- if (nmmScheme) {
- return L"http://nmm.nexusmods.com/newvegas";
- } else {
- return L"http://www.nexusmods.com/newvegas";
- }
-}
-
-
bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h
index aa187fb3..ee67ac17 100644
--- a/src/shared/falloutnvinfo.h
+++ b/src/shared/falloutnvinfo.h
@@ -49,8 +49,6 @@ public:
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getNexusPage(bool nmmScheme = true);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
// get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h
index b6a4f142..de3af8b4 100644
--- a/src/shared/gameinfo.h
+++ b/src/shared/gameinfo.h
@@ -82,8 +82,6 @@ public:
//**USED ONLY IN HOOKDLL
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0;
- virtual std::wstring getNexusPage(bool nmmScheme = true) = 0;
-
//**USED IN HOOKDLL and everywhere that uses GameInfo
static GameInfo& instance();
diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp
index 9bd5f4b1..a3dc3986 100644
--- a/src/shared/oblivioninfo.cpp
+++ b/src/shared/oblivioninfo.cpp
@@ -77,20 +77,6 @@ std::vector<std::wstring> OblivionInfo::getIniFileNames()
return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini");
}
-
-
-
-
-std::wstring OblivionInfo::getNexusPage(bool nmmScheme)
-{
- if (nmmScheme) {
- return L"http://nmm.nexusmods.com/oblivion";
- } else {
- return L"http://www.nexusmods.com/oblivion";
- }
-}
-
-
bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", nullptr };
diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h
index f9045703..00048930 100644
--- a/src/shared/oblivioninfo.h
+++ b/src/shared/oblivioninfo.h
@@ -47,8 +47,6 @@ public:
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getNexusPage(bool nmmScheme = true);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
// get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp
index 9b192902..869ac47d 100644
--- a/src/shared/skyriminfo.cpp
+++ b/src/shared/skyriminfo.cpp
@@ -88,17 +88,6 @@ std::wstring SkyrimInfo::getReferenceDataFile()
return L"Skyrim - Meshes.bsa";
}
-
-std::wstring SkyrimInfo::getNexusPage(bool nmmScheme)
-{
- if (nmmScheme) {
- return L"http://nmm.nexusmods.com/skyrim";
- } else {
- return L"http://www.nexusmods.com/skyrim";
- }
-}
-
-
bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath)
{
static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr };
diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h
index 47a35b3e..afba1974 100644
--- a/src/shared/skyriminfo.h
+++ b/src/shared/skyriminfo.h
@@ -49,10 +49,6 @@ public:
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getNexusPage(bool nmmScheme = true);
-
- static int getNexusGameIDStatic() { return 110; }
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
private: