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

svn at pcbsd.org svn at pcbsd.org
Wed Aug 1 16:42:40 PDT 2012


Author: kris
Date: 2012-08-01 23:42:40 +0000 (Wed, 01 Aug 2012)
New Revision: 18081

Modified:
   pcbsd/current/src-qt4/warden-gui/dialogconfig.cpp
   pcbsd/current/src-qt4/warden-gui/dialogconfig.h
   pcbsd/current/src-qt4/warden-gui/dialogconfig.ui
Log:

Use a combobox now to select network interfaces in Warden, now user
doesn't have to guess device name



Modified: pcbsd/current/src-qt4/warden-gui/dialogconfig.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogconfig.cpp	2012-08-01 22:35:42 UTC (rev 18080)
+++ pcbsd/current/src-qt4/warden-gui/dialogconfig.cpp	2012-08-01 23:42:40 UTC (rev 18081)
@@ -13,15 +13,53 @@
 #include <qsettings.h>
 #include <qfiledialog.h>
 #include "pcbsd-utils.h"
+#include "pcbsd-netif.h"
 
 
 void dialogConfig::programInit()
 {
+    // Load NICS
+    detectDev();
+
     // Read in the configuration and populate the widget
     readConfig();
 }
 
+void dialogConfig::detectDev()
+{
+    QString tmp;
+    bool foundDev;
 
+    comboNIC->clear();
+    
+    QStringList ifs = NetworkInterface::getInterfaces();
+    for ( QStringList::Iterator it = ifs.begin(); it != ifs.end(); ++it )
+    {
+       foundDev = false;
+
+       QString dev = *it;
+       if (dev.indexOf("lo") == 0 
+	   || dev.indexOf("fwe") == 0
+	   || dev.indexOf("fwip") == 0
+	   || dev.indexOf("ipfw") == 0
+	   || dev.indexOf("lagg") == 0
+	   || dev.indexOf("plip") == 0
+	   || dev.indexOf("pfsync") == 0
+	   || dev.indexOf("pflog") == 0
+	   || dev.indexOf("usbus") == 0
+	   || dev.indexOf("vboxnet") == 0
+	   || dev.indexOf("tun") == 0)
+           continue;
+
+	NetworkInterface ifr(dev);
+        if (ifr.isWireless() && dev.indexOf("wlan") != 0 ) 
+           continue;
+
+       comboNIC->addItem(dev);
+   }
+
+}
+
 void dialogConfig::readConfig()
 {
     QSettings settings("PCBSD");
@@ -30,10 +68,11 @@
     TMPDIR = Utils::getValFromPCConf("/usr/local/etc/warden.conf", "WTMP");
     JailDir = Utils::getValFromPCConf("/usr/local/etc/warden.conf", "JDIR");
     
-    lineNIC->setText(NIC);
     lineJailDir->setText(JailDir);
     lineTMPDIR->setText(TMPDIR);
-    
+    for ( int i = 0; i < comboNIC->count(); ++i )
+      if ( comboNIC->itemText(i) == NIC )
+         comboNIC->setCurrentIndex(i);
 }
 
 
@@ -66,7 +105,7 @@
 void dialogConfig::slotSave()
 {
     
-    Utils::setValPCConf("/usr/local/etc/warden.conf", "NIC", lineNIC->text());
+    Utils::setValPCConf("/usr/local/etc/warden.conf", "NIC", comboNIC->currentText());
     Utils::setValPCConf("/usr/local/etc/warden.conf", "WTMP", lineTMPDIR->text());
     Utils::setValPCConf("/usr/local/etc/warden.conf", "JDIR", lineJailDir->text());
     

Modified: pcbsd/current/src-qt4/warden-gui/dialogconfig.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogconfig.h	2012-08-01 22:35:42 UTC (rev 18080)
+++ pcbsd/current/src-qt4/warden-gui/dialogconfig.h	2012-08-01 23:42:40 UTC (rev 18081)
@@ -25,6 +25,7 @@
     void slotCancel();
 
 private:
+    void detectDev();
     void readConfig();
     QString NIC;
     QString TMPDIR;

Modified: pcbsd/current/src-qt4/warden-gui/dialogconfig.ui
===================================================================
(Binary files differ)



More information about the Commits mailing list