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/QtURLValidator.cpp
parentfff7ba50011f25fc050329c5db9d0ff8fe11abfa (diff)
downloadswift-3b2a5153a79ec627113223222ed61190bcb3a7e3.zip
swift-3b2a5153a79ec627113223222ed61190bcb3a7e3.tar.bz2
Add validation for BOSH URLs in the connection dialog.
Change-Id: I967565abb867279238919f0e5eae6ebe0641d195 Resolves: #1186
Diffstat (limited to 'Swift/QtUI/QtURLValidator.cpp')
-rw-r--r--Swift/QtUI/QtURLValidator.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Swift/QtUI/QtURLValidator.cpp b/Swift/QtUI/QtURLValidator.cpp
new file mode 100644
index 0000000..2df59c4
--- /dev/null
+++ b/Swift/QtUI/QtURLValidator.cpp
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2012 Kevin Smith
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include <Swift/QtUI/QtURLValidator.h>
+
+#include <Swiften/Base/URL.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
+
+namespace Swift {
+QtURLValidator::QtURLValidator(QObject* parent) {
+
+}
+
+QValidator::State QtURLValidator::validate(QString& input, int& pos) const {
+ URL url = URL::fromString(Q2PSTRING(input));
+ bool valid = !url.isEmpty();
+ valid &= (url.getScheme() == "http" || url.getScheme() == "https");
+ return valid ? Acceptable : Intermediate;
+}
+
+}
+