summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2012-12-04 10:11:35 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-12-04 11:51:30 (GMT)
commit3b2a5153a79ec627113223222ed61190bcb3a7e3 (patch)
treef6636f5ef54a444cf5f8ccf0761e0545ea6811cb /Swift/QtUI/QtConnectionSettingsWindow.cpp
parentfff7ba50011f25fc050329c5db9d0ff8fe11abfa (diff)
downloadswift-contrib-3b2a5153a79ec627113223222ed61190bcb3a7e3.zip
swift-contrib-3b2a5153a79ec627113223222ed61190bcb3a7e3.tar.bz2
Add validation for BOSH URLs in the connection dialog.
Change-Id: I967565abb867279238919f0e5eae6ebe0641d195 Resolves: #1186
Diffstat (limited to 'Swift/QtUI/QtConnectionSettingsWindow.cpp')
-rw-r--r--Swift/QtUI/QtConnectionSettingsWindow.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Swift/QtUI/QtConnectionSettingsWindow.cpp b/Swift/QtUI/QtConnectionSettingsWindow.cpp
index ea693cf..2da527a 100644
--- a/Swift/QtUI/QtConnectionSettingsWindow.cpp
+++ b/Swift/QtUI/QtConnectionSettingsWindow.cpp
@@ -17,7 +17,10 @@
#include <QTextEdit>
#include <QFile>
#include <QTextStream>
+#include <QMessageBox>
+
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtURLValidator.h>
namespace Swift {
@@ -43,6 +46,11 @@ QtConnectionSettingsWindow::QtConnectionSettingsWindow(const ClientOptions& opti
connect(ui.manual_proxyType, SIGNAL(currentIndexChanged(int)), SLOT(handleProxyTypeChanged(int)));
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(handleAcceptRequested()));
+
+ QtURLValidator* urlValidator = new QtURLValidator(this);
+ ui.bosh_uri->setValidator(urlValidator);
+
ui.manual_useTLS->setCurrentIndex(2);
ui.manual_proxyType->setCurrentIndex(0);
@@ -101,6 +109,15 @@ void QtConnectionSettingsWindow::handleProxyTypeChanged(int index) {
ui.manual_manualProxyPort->setVisible(proxySettingsVisible);
}
+void QtConnectionSettingsWindow::handleAcceptRequested() {
+ if (ui.connectionMethod->currentIndex() != 2 || ui.bosh_uri->hasAcceptableInput()) {
+ accept();
+ }
+ else {
+ QMessageBox::critical(this, tr("Configuration invalid"), tr("The provided BOSH URL is not valid."));
+ }
+}
+
ClientOptions QtConnectionSettingsWindow::getOptions() {
ClientOptions options;
if (ui.connectionMethod->currentIndex() > 0) {