diff options
| author | Tannin <devnull@localhost> | 2013-07-13 22:11:30 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2013-07-13 22:11:30 +0200 |
| commit | 5c968a124280a60e64298809e3e78e5d3783d59c (patch) | |
| tree | 0910816561ba7e84112a93ccaba34c17b352aeff /src | |
| parent | e09cef39095b8d675f11a41dd4d152cdecac1809 (diff) | |
- 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
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 23 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 41 | ||||
| -rw-r--r-- | src/mainwindow.h | 3 | ||||
| -rw-r--r-- | src/settings.cpp | 40 | ||||
| -rw-r--r-- | src/settings.h | 5 | ||||
| -rw-r--r-- | src/settingsdialog.ui | 13 |
6 files changed, 88 insertions, 37 deletions
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 <http://www.gnu.org/licenses/>. #include <QSplashScreen> #include <QDirIterator> #include <QDesktopServices> -#include <QNetworkProxy> #include <eh.h> #include <windows_error.h> #include <boost/scoped_array.hpp> @@ -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<QNetworkProxy> 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 <http://www.gnu.org/licenses/>. #include <shlobj.h> #include <TlHelp32.h> #include <QNetworkInterface> +#include <QNetworkProxy> +#include <QtConcurrentRun> 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<QNetworkProxy> 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<void> 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<QCheckBox*>("hideUncheckedBox"); - QCheckBox *forceEnableBox = dialog.findChild<QCheckBox*>("forceEnableBox"); - QComboBox *mechanismBox = dialog.findChild<QComboBox*>("mechanismBox"); - - QCheckBox *loginCheckBox = dialog.findChild<QCheckBox*>("loginCheckBox"); - QLineEdit *usernameEdit = dialog.findChild<QLineEdit*>("usernameEdit"); - QLineEdit *passwordEdit = dialog.findChild<QLineEdit*>("passwordEdit"); - - QLineEdit *appIDEdit = dialog.findChild<QLineEdit*>("appIDEdit"); - + // General Page QComboBox *languageBox = dialog.findChild<QComboBox*>("languageBox"); QComboBox *styleBox = dialog.findChild<QComboBox*>("styleBox"); QComboBox *logLevelBox = dialog.findChild<QComboBox*>("logLevelBox"); @@ -414,14 +410,27 @@ void Settings::query(QWidget *parent) QLineEdit *modDirEdit = dialog.findChild<QLineEdit*>("modDirEdit"); QLineEdit *cacheDirEdit = dialog.findChild<QLineEdit*>("cacheDirEdit"); + // nexus page + QCheckBox *loginCheckBox = dialog.findChild<QCheckBox*>("loginCheckBox"); + QLineEdit *usernameEdit = dialog.findChild<QLineEdit*>("usernameEdit"); + QLineEdit *passwordEdit = dialog.findChild<QLineEdit*>("passwordEdit"); QCheckBox *offlineBox = dialog.findChild<QCheckBox*>("offlineBox"); - QLineEdit *nmmVersionEdit = dialog.findChild<QLineEdit*>("nmmVersionEdit"); - - QListWidget *pluginsList = dialog.findChild<QListWidget*>("pluginsList"); + QCheckBox *proxyBox = dialog.findChild<QCheckBox*>("proxyBox"); QListWidget *knownServersList = dialog.findChild<QListWidget*>("knownServersList"); QListWidget *preferredServersList = dialog.findChild<QListWidget*>("preferredServersList"); + // plugis page + QListWidget *pluginsList = dialog.findChild<QListWidget*>("pluginsList"); + + // workarounds page + QCheckBox *forceEnableBox = dialog.findChild<QCheckBox*>("forceEnableBox"); + QComboBox *mechanismBox = dialog.findChild<QComboBox*>("mechanismBox"); + QLineEdit *appIDEdit = dialog.findChild<QLineEdit*>("appIDEdit"); + QLineEdit *nmmVersionEdit = dialog.findChild<QLineEdit*>("nmmVersionEdit"); + QCheckBox *hideUncheckedBox = dialog.findChild<QCheckBox*>("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 @@ -163,6 +163,11 @@ public: bool enableQuickInstaller(); /** + * @return true if the user configured the use of a network proxy + */ + bool useProxy(); + + /** * @brief sets the new motd hash **/ void setMotDHash(uint hash); diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 590f30e0..b63965f9 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -329,6 +329,19 @@ p, li { white-space: pre-wrap; } </widget>
</item>
<item>
+ <widget class="QCheckBox" name="proxyBox">
+ <property name="statusTip">
+ <string>Use a proxy for network connections.</string>
+ </property>
+ <property name="whatsThis">
+ <string>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.</string>
+ </property>
+ <property name="text">
+ <string>Use HTTP Proxy (Uses System Settings)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
|
