[PC-BSD Commits] r17613 - pcbsd/current/src-qt4/warden-gui

svn at pcbsd.org svn at pcbsd.org
Tue Jul 3 11:59:47 PDT 2012


Author: kris
Date: 2012-07-03 18:59:47 +0000 (Tue, 03 Jul 2012)
New Revision: 17613

Modified:
   pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp
   pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp
Log:

Add validators for proper IPV4 and IPV6 addresses



Modified: pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp	2012-07-03 18:54:47 UTC (rev 17612)
+++ pcbsd/current/src-qt4/warden-gui/dialogEditIP.cpp	2012-07-03 18:59:47 UTC (rev 17613)
@@ -14,7 +14,9 @@
 #include <QProcess>
 #include <QString>
 #include <QFileDialog>
+#include <QMessageBox>
 #include <QDebug>
+#include "pcbsd-utils.h"
 
 // Local Includes
 #include "dialogEditIP.h"
@@ -82,8 +84,15 @@
 	QString url = QInputDialog::getText(this, tr("Add IP"),
 					tr("IP Address:"), QLineEdit::Normal,
 					QString(), &ok);
-	if ( ok )
-		listIP->addItem(url);
+	if ( ok ) {
+          if ( Utils::validateIPV4(url) || Utils::validateIPV6(url) )
+	    listIP->addItem(url);
+          else
+	    QMessageBox::critical(this, tr("Warden"), \
+                                tr("Please enter a valid IPV4 or IPV6 address!"), \
+                                QMessageBox::Ok, \
+                                QMessageBox::Ok);
+        }
 }
 
 void dialogEditIP::slotRemClicked()

Modified: pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp	2012-07-03 18:54:47 UTC (rev 17612)
+++ pcbsd/current/src-qt4/warden-gui/wizardNewJail.cpp	2012-07-03 18:59:47 UTC (rev 17613)
@@ -10,6 +10,8 @@
 ** destructor.
 *****************************************************************************/
 #include "wizardNewJail.h"
+#include "pcbsd-utils.h"
+#include <QDebug>
 #include <QFileDialog>
 
 
@@ -46,9 +48,14 @@
 {
   switch (currentId()) {
      case Page_IP:
-         // Add validator here for IPv4 and IPv6 addresses
-         button(QWizard::NextButton)->setEnabled(true);
-         return true;
+         // Check if we have a good IPV4 or IPV6 address
+	 if ( Utils::validateIPV4(lineIP->text()) || Utils::validateIPV6(lineIP->text()) ) {
+           button(QWizard::NextButton)->setEnabled(true);
+           return true;
+         } else {
+           button(QWizard::NextButton)->setEnabled(false);
+           return false;
+         }
      case Page_Root:
 	 if ( lineRoot->text().isEmpty() || lineRoot->text() != lineRoot2->text() ) {
            button(QWizard::NextButton)->setEnabled(false);



More information about the Commits mailing list