From 5c968a124280a60e64298809e3e78e5d3783d59c Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 13 Jul 2013 22:11:30 +0200 Subject: - added the ability to connect to the internet through a proxy - integrated fomod installer now supports the or-operator for page conditions - integrated fomod installer now caches condition results to speed up tests --- src/main.cpp | 23 ++--------------------- src/mainwindow.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 3 +++ src/settings.cpp | 40 ++++++++++++++++++++++++---------------- src/settings.h | 5 +++++ src/settingsdialog.ui | 13 +++++++++++++ 6 files changed, 88 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 583992d1..b92bb538 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -62,7 +62,6 @@ along with Mod Organizer. If not, see . #include #include #include -#include #include #include #include @@ -181,7 +180,7 @@ void cleanupDir() "QtXml4.dll", "QtWebKit4.dll", "qjpeg4.dll", - "dlls/phonon4.dll", +/* "dlls/phonon4.dll", "dlls/QtCore4.dll", "dlls/QtGui4.dll", "dlls/QtNetwork4.dll", @@ -190,7 +189,7 @@ void cleanupDir() "dlls/QtWebKit4.dll", "dlls/QtDeclarative4.dll", "dlls/QtScript4.dll", - "dlls/QtSql4.dll" + "dlls/QtSql4.dll"*/ }; static const int NUM_FILES = sizeof(fileNames) / sizeof(QString); @@ -274,21 +273,6 @@ LONG WINAPI MyUnhandledExceptionFilter(struct _EXCEPTION_POINTERS *exceptionPtrs } -void setupNetworkProxy() -{ - QNetworkProxyQuery query(QUrl("http://www.google.com"), QNetworkProxyQuery::UrlRequest); - query.setProtocolTag("http"); - - QList proxies = QNetworkProxyFactory::systemProxyForQuery(query); - if ((proxies.size() > 0) && (proxies.at(0).type() != QNetworkProxy::NoProxy)) { - qDebug("Using proxy: %s", qPrintable(proxies.at(0).hostName())); - QNetworkProxy::setApplicationProxy(proxies[0]); - } else { - qDebug("Not using proxy"); - } -} - - void registerMetaTypes() { registerExecutable(); @@ -297,11 +281,8 @@ void registerMetaTypes() int main(int argc, char *argv[]) { MOApplication application(argc, argv); - qApp->addLibraryPath(application.applicationDirPath() + "/dlls"); - setupNetworkProxy(); - SetUnhandledExceptionFilter(MyUnhandledExceptionFilter); LogBuffer::init(20, QtDebugMsg, application.applicationDirPath() + "/logs/mo_interface.log"); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f001f3b2..969a5454 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -95,6 +95,8 @@ along with Mod Organizer. If not, see . #include #include #include +#include +#include using namespace MOBase; @@ -1757,6 +1759,36 @@ void MainWindow::fixCategories() } +void MainWindow::setupNetworkProxy(bool activate) +{ + QNetworkProxyFactory::setUseSystemConfiguration(activate); +/* QNetworkProxyQuery query(QUrl("http://www.google.com"), QNetworkProxyQuery::UrlRequest); + query.setProtocolTag("http"); + QList proxies = QNetworkProxyFactory::systemProxyForQuery(query); + if ((proxies.size() > 0) && (proxies.at(0).type() != QNetworkProxy::NoProxy)) { + qDebug("Using proxy: %s", qPrintable(proxies.at(0).hostName())); + QNetworkProxy::setApplicationProxy(proxies[0]); + } else { + qDebug("Not using proxy"); + }*/ +} + + +void MainWindow::activateProxy(bool activate) +{ + QProgressDialog busyDialog(tr("Activating Network Proxy"), QString(), 0, 0, parentWidget()); + busyDialog.setWindowFlags(busyDialog.windowFlags() & ~Qt::WindowContextHelpButtonHint); + busyDialog.setWindowModality(Qt::WindowModal); + busyDialog.show(); + QFuture future = QtConcurrent::run(MainWindow::setupNetworkProxy, activate); + while (!future.isFinished()) { + QCoreApplication::processEvents(); + ::Sleep(100); + } + busyDialog.hide(); +} + + void MainWindow::readSettings() { QSettings settings(ToQString(GameInfo::instance().getIniFilename()), QSettings::IniFormat); @@ -1772,6 +1804,10 @@ void MainWindow::readSettings() languageChange(m_Settings.language()); int selectedExecutable = settings.value("selected_executable").toInt(); setExecutableIndex(selectedExecutable); + + if (settings.value("Settings/use_proxy", false).toBool()) { + activateProxy(true); + } } @@ -3422,6 +3458,7 @@ void MainWindow::on_actionSettings_triggered() { QString oldModDirectory(m_Settings.getModDirectory()); QString oldCacheDirectory(m_Settings.getCacheDirectory()); + bool proxy = m_Settings.useProxy(); m_Settings.query(this); fixCategories(); refreshFilters(); @@ -3443,6 +3480,10 @@ void MainWindow::on_actionSettings_triggered() NexusInterface::instance()->setCacheDirectory(m_Settings.getCacheDirectory()); } + if (proxy != m_Settings.useProxy()) { + activateProxy(m_Settings.useProxy()); + } + NexusInterface::instance()->setNMMVersion(m_Settings.getNMMVersion()); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 61157f13..f9e3bddc 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -230,6 +230,9 @@ private: void updateESPLock(bool locked); + static void setupNetworkProxy(bool activate); + void activateProxy(bool activate); + private: Ui::MainWindow *ui; diff --git a/src/settings.cpp b/src/settings.cpp index 2bfdc0a6..61c8dd6d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -237,6 +237,11 @@ bool Settings::enableQuickInstaller() return m_Settings.value("Settings/enable_quick_installer").toBool(); } +bool Settings::useProxy() +{ + return m_Settings.value("Settings/use_proxy", false).toBool(); +} + void Settings::setMotDHash(uint hash) { @@ -395,16 +400,7 @@ void Settings::query(QWidget *parent) connect(&dialog, SIGNAL(resetDialogs()), this, SLOT(resetDialogs())); - QCheckBox *hideUncheckedBox = dialog.findChild("hideUncheckedBox"); - QCheckBox *forceEnableBox = dialog.findChild("forceEnableBox"); - QComboBox *mechanismBox = dialog.findChild("mechanismBox"); - - QCheckBox *loginCheckBox = dialog.findChild("loginCheckBox"); - QLineEdit *usernameEdit = dialog.findChild("usernameEdit"); - QLineEdit *passwordEdit = dialog.findChild("passwordEdit"); - - QLineEdit *appIDEdit = dialog.findChild("appIDEdit"); - + // General Page QComboBox *languageBox = dialog.findChild("languageBox"); QComboBox *styleBox = dialog.findChild("styleBox"); QComboBox *logLevelBox = dialog.findChild("logLevelBox"); @@ -414,14 +410,27 @@ void Settings::query(QWidget *parent) QLineEdit *modDirEdit = dialog.findChild("modDirEdit"); QLineEdit *cacheDirEdit = dialog.findChild("cacheDirEdit"); + // nexus page + QCheckBox *loginCheckBox = dialog.findChild("loginCheckBox"); + QLineEdit *usernameEdit = dialog.findChild("usernameEdit"); + QLineEdit *passwordEdit = dialog.findChild("passwordEdit"); QCheckBox *offlineBox = dialog.findChild("offlineBox"); - QLineEdit *nmmVersionEdit = dialog.findChild("nmmVersionEdit"); - - QListWidget *pluginsList = dialog.findChild("pluginsList"); + QCheckBox *proxyBox = dialog.findChild("proxyBox"); QListWidget *knownServersList = dialog.findChild("knownServersList"); QListWidget *preferredServersList = dialog.findChild("preferredServersList"); + // plugis page + QListWidget *pluginsList = dialog.findChild("pluginsList"); + + // workarounds page + QCheckBox *forceEnableBox = dialog.findChild("forceEnableBox"); + QComboBox *mechanismBox = dialog.findChild("mechanismBox"); + QLineEdit *appIDEdit = dialog.findChild("appIDEdit"); + QLineEdit *nmmVersionEdit = dialog.findChild("nmmVersionEdit"); + QCheckBox *hideUncheckedBox = dialog.findChild("hideUncheckedBox"); + + // // set up current settings // @@ -496,6 +505,7 @@ void Settings::query(QWidget *parent) modDirEdit->setText(getModDirectory()); cacheDirEdit->setText(getCacheDirectory()); offlineBox->setChecked(m_Settings.value("Settings/offline_mode", false).toBool()); + proxyBox->setChecked(m_Settings.value("Settings/use_proxy", false).toBool()); nmmVersionEdit->setText(m_Settings.value("Settings/nmm_version", "0.33.1").toString()); logLevelBox->setCurrentIndex(logLevel()); @@ -576,10 +586,8 @@ void Settings::query(QWidget *parent) m_Settings.remove("Settings/nexus_username"); m_Settings.remove("Settings/nexus_password"); } -/* if (nxmHandler != handleNXMBox->isChecked()) { - setNXMHandlerActive(handleNXMBox->isChecked(), registryWritable); - }*/ m_Settings.setValue("Settings/offline_mode", offlineBox->isChecked()); + m_Settings.setValue("Settings/use_proxy", proxyBox->isChecked()); m_Settings.setValue("Settings/nmm_version", nmmVersionEdit->text()); diff --git a/src/settings.h b/src/settings.h index 2d66fd59..f1d29bd7 100644 --- a/src/settings.h +++ b/src/settings.h @@ -162,6 +162,11 @@ public: **/ bool enableQuickInstaller(); + /** + * @return true if the user configured the use of a network proxy + */ + bool useProxy(); + /** * @brief sets the new motd hash **/ diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 590f30e0..b63965f9 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -328,6 +328,19 @@ p, li { white-space: pre-wrap; } + + + + Use a proxy for network connections. + + + Use a proxy for network connections. This uses the system-wide settings which can be configured in Internet Explorer. Please note that MO will start up a few seconds slower on some systems when using a proxy. + + + Use HTTP Proxy (Uses System Settings) + + + -- cgit v1.3.1