[PC-BSD Commits] r542 - in pcbsd/trunk/kcmPFManager: . config

svn at pcbsd.org svn at pcbsd.org
Thu Jul 19 11:11:24 PDT 2007


Author: tim
Date: 2007-07-19 19:11:24 +0100 (Thu, 19 Jul 2007)
New Revision: 542

Modified:
   pcbsd/trunk/kcmPFManager/config/packetfilter.cpp
   pcbsd/trunk/kcmPFManager/config/packetfilter.hpp
   pcbsd/trunk/kcmPFManager/pfmanager.pro
   pcbsd/trunk/kcmPFManager/pfmanagerdlg.cpp
   pcbsd/trunk/kcmPFManager/pfmanagerdlg.hpp
Log:
Added pf status detection. Now, if pf is running only 'Stop' & 'Restart' are enabled. If pf is not running, only 'Start' is enabled. This gives users handy feedback of pf's status

Modified: pcbsd/trunk/kcmPFManager/config/packetfilter.cpp
===================================================================
--- pcbsd/trunk/kcmPFManager/config/packetfilter.cpp	2007-07-19 17:23:48 UTC (rev 541)
+++ pcbsd/trunk/kcmPFManager/config/packetfilter.cpp	2007-07-19 18:11:24 UTC (rev 542)
@@ -228,3 +228,26 @@
     
     op->copy(backup, file);
 }
+
+bool PacketFilter::isRunning(void)
+{
+    QProcess proc;
+    
+    // Query pf
+    proc.addArgument("pfctl");
+    proc.addArgument("-s");
+    proc.addArgument("info");
+    proc.start();
+    
+    while (proc.isRunning() || proc.canReadLineStdout())
+    {
+	if (proc.canReadLineStdout())
+	{
+	    QString line = proc.readLineStdout();
+	    if (line.contains("Enabled") > 0) { return true; }
+	}
+    }
+    
+    return false;
+    
+}

Modified: pcbsd/trunk/kcmPFManager/config/packetfilter.hpp
===================================================================
--- pcbsd/trunk/kcmPFManager/config/packetfilter.hpp	2007-07-19 17:23:48 UTC (rev 541)
+++ pcbsd/trunk/kcmPFManager/config/packetfilter.hpp	2007-07-19 18:11:24 UTC (rev 542)
@@ -45,6 +45,7 @@
     void start ( void );
     void stop ( void );
     void restart ( void );
+    bool isRunning(void);
     
     void add_rule ( const rule& rul );
     

Modified: pcbsd/trunk/kcmPFManager/pfmanager.pro
===================================================================
--- pcbsd/trunk/kcmPFManager/pfmanager.pro	2007-07-19 17:23:48 UTC (rev 541)
+++ pcbsd/trunk/kcmPFManager/pfmanager.pro	2007-07-19 18:11:24 UTC (rev 542)
@@ -1,3 +1,33 @@
+TEMPLATE	= lib
+LANGUAGE	= C++
+
+CONFIG	+= dll
+
+INCLUDEPATH	+= . config
+
+HEADERS	+= config/packetfilter.hpp \
+	config/rcconfig.hpp \
+	pfmanagerdlg.hpp \
+	config/rule.hpp \
+	config/services.hpp \
+	config/interfaces.hpp \
+	pfaddlg.hpp \
+	taggedlistviewitem.hpp
+
+SOURCES	+= main.cpp \
+	config/packetfilter.cpp \
+	config/rcconfig.cpp \
+	pfmanagerdlg.cpp \
+	config/rule.cpp \
+	config/services.cpp \
+	config/interfaces.cpp \
+	pfaddlg.cpp \
+	taggedlistviewitem.cpp
+
+FORMS	= mainwindow.ui \
+	notroot.ui \
+	adddlg.ui
+
 ######################################################################
 # Automatically generated by qmake (1.07a) Wed Jan 10 12:46:27 2007
 ######################################################################
@@ -2,10 +32,7 @@
 
-CONFIG += dll
 #CONFIG += release
 #CONFIG += debug
 TARGET = /usr/local/lib/kde3/kcm_pfmanager
-TEMPLATE = lib
 #TEMPLATE = app 
 DEPENDPATH += config
-INCLUDEPATH += . config
 
@@ -15,13 +42,6 @@
                PFManager_de.ts
 
 # Input
-HEADERS += config/packetfilter.hpp config/rcconfig.hpp pfmanagerdlg.hpp \
-           config/rule.hpp config/services.hpp config/interfaces.hpp \
-           pfaddlg.hpp taggedlistviewitem.hpp
-INTERFACES += mainwindow.ui notroot.ui adddlg.ui
-SOURCES += main.cpp config/packetfilter.cpp config/rcconfig.cpp pfmanagerdlg.cpp \
-           config/rule.cpp config/services.cpp config/interfaces.cpp pfaddlg.cpp \
-           taggedlistviewitem.cpp
 
 unix {
   UI_DIR = .ui

Modified: pcbsd/trunk/kcmPFManager/pfmanagerdlg.cpp
===================================================================
--- pcbsd/trunk/kcmPFManager/pfmanagerdlg.cpp	2007-07-19 17:23:48 UTC (rev 541)
+++ pcbsd/trunk/kcmPFManager/pfmanagerdlg.cpp	2007-07-19 18:11:24 UTC (rev 542)
@@ -37,6 +37,9 @@
     // Delete stuff
     QPushButton::connect(pbRestore, SIGNAL(clicked()),
                          this, SLOT(restoreClicked()));
+    
+    //Show if pf is running or not
+    refreshStatus();
 }
 
 PFManagerDlg::~PFManagerDlg ( void )
@@ -72,16 +75,19 @@
 void PFManagerDlg::startClicked ( void )
 {
     _firewall.start();
+    refreshStatus();
 }
 
 void PFManagerDlg::stopClicked ( void )
 {
     _firewall.stop();
+    refreshStatus();
 }
 
 void PFManagerDlg::restartClicked ( void )
 {
     _firewall.restart();
+    refreshStatus();
 }
 
 // WARNING: Make sure you only store TaggedListViewItem
@@ -187,4 +193,20 @@
     cbEnable->setChecked(_firewall.isEnabled());
     // Fill list with services
     refreshList();
+}	    
+
+void PFManagerDlg::refreshStatus(void)
+{
+    if (_firewall.isRunning())
+    {
+	pbStart->setEnabled(false);
+	pbStop->setEnabled(true);
+	pbRestart->setEnabled(true);
+    }
+    else
+    {
+	pbStart->setEnabled(true);
+	pbStop->setEnabled(false);
+	pbRestart->setEnabled(false);
+    }
 }

Modified: pcbsd/trunk/kcmPFManager/pfmanagerdlg.hpp
===================================================================
--- pcbsd/trunk/kcmPFManager/pfmanagerdlg.hpp	2007-07-19 17:23:48 UTC (rev 541)
+++ pcbsd/trunk/kcmPFManager/pfmanagerdlg.hpp	2007-07-19 18:11:24 UTC (rev 542)
@@ -32,6 +32,7 @@
     void load ( void );
     
     void refreshList ( void );
+    void refreshStatus(void);
 };
 
 #endif



More information about the Commits mailing list