[PC-BSD Commits] r2052 - pcbsd/trunk/NetworkManager

svn at pcbsd.org svn at pcbsd.org
Sun Jun 8 11:28:36 PDT 2008


Author: tim
Date: 2008-06-08 11:28:36 -0700 (Sun, 08 Jun 2008)
New Revision: 2052

Modified:
   pcbsd/trunk/NetworkManager/NetworkManager.pro
   pcbsd/trunk/NetworkManager/networkman.ui
   pcbsd/trunk/NetworkManager/networkman.ui.h
Log:
Altered NetworkManager to make use of new library functions

Modified: pcbsd/trunk/NetworkManager/NetworkManager.pro
===================================================================
--- pcbsd/trunk/NetworkManager/NetworkManager.pro	2008-06-08 18:28:00 UTC (rev 2051)
+++ pcbsd/trunk/NetworkManager/NetworkManager.pro	2008-06-08 18:28:36 UTC (rev 2052)
@@ -3,6 +3,10 @@
 
 CONFIG	+= qt warn_on debug release
 
+LIBS	+= -lpcbsd
+
+INCLUDEPATH	+= /PCBSD/includes
+
 HEADERS	+= kcm.h
 
 SOURCES	+= kcm.cpp

Modified: pcbsd/trunk/NetworkManager/networkman.ui
===================================================================
--- pcbsd/trunk/NetworkManager/networkman.ui	2008-06-08 18:28:00 UTC (rev 2051)
+++ pcbsd/trunk/NetworkManager/networkman.ui	2008-06-08 18:28:36 UTC (rev 2052)
@@ -825,6 +825,8 @@
     <include location="local" impldecl="in declaration">kaboutdata.h</include>
     <include location="local" impldecl="in declaration">kpopupmenu.h</include>
     <include location="global" impldecl="in declaration">qregexp.h</include>
+    <include location="global" impldecl="in declaration">netif.h</include>
+    <include location="global" impldecl="in declaration">utils.h</include>
     <include location="local" impldecl="in implementation">networkman.ui.h</include>
 </includes>
 <variables>
@@ -855,7 +857,7 @@
 </signals>
 <slots>
     <slot>Init()</slot>
-    <slot access="private">readDetectDev()</slot>
+    <slot access="private">detectDev()</slot>
     <slot access="private">DevSelectionChanged()</slot>
     <slot access="private">PropertiesSlot()</slot>
     <slot access="private">restartNetwork()</slot>
@@ -874,7 +876,6 @@
     <slot access="private">slotShowInfoConfig()</slot>
 </slots>
 <functions>
-    <function access="private">startDetectDev()</function>
     <function access="private" returnType="QString">getLineFromCommandOutput( QString command )</function>
     <function returnType="QString">getNameForIdent( QString ident )</function>
     <function access="private" returnType="QString">getIpForIdent( QString ident )</function>

Modified: pcbsd/trunk/NetworkManager/networkman.ui.h
===================================================================
--- pcbsd/trunk/NetworkManager/networkman.ui.h	2008-06-08 18:28:00 UTC (rev 2051)
+++ pcbsd/trunk/NetworkManager/networkman.ui.h	2008-06-08 18:28:36 UTC (rev 2052)
@@ -52,81 +52,46 @@
     loadGlobals();
     
      // Start the device detection process
-    startDetectDev();
+    detectDev();
     
 }
 
 
-void NetworkMan::startDetectDev()
+
+void NetworkMan::detectDev()
 {
     listNetDev->clear();
-   //listNetDev->insertItem("Detecting Devices...");
     textGlobalError->setText(tr("Detecting Devices...") );
     pushConfigure->setEnabled(FALSE);
     
-        GetDevList = new QProcess( this );
-        GetDevList->addArgument( "ifconfig" );
-        GetDevList->addArgument( "-l" );	
-        connect( GetDevList, SIGNAL(readyReadStdout()), this, SLOT(readDetectDev() ) );
-        connect( GetDevList, SIGNAL(processExited()), this, SLOT(slotTimerRefresh() ) );	   
-         if ( !GetDevList->start() ) {
-	      
-         }
+    QStringList ifs = NetworkInterface::getInterfaces();
+    uint i = 0;
+    for ( QStringList::Iterator it = ifs.begin(); it != ifs.end(); ++it )
+    {
+       QString dev = *it;
+       if (dev.find("lo0") == -1
+	   && dev.find("fwe") == -1
+	   && dev.find("plip") == -1
+	   && dev.find("pfsync") == -1
+	   && dev.find("pflog") == -1
+	   && dev.find("tun") == -1)
+       {
+	   qDebug("Found device: " + dev);
+	   Devs[i] = dev;
+	   // Determine if its a wireless or wired device
+	   DevsType[i] = getTypeForIdent(Devs[i]);
+	   // Get HW Idtentify line
+	   DevsName[i] = getNameForIdent(Devs[i]);
+	   
+	   if ( DevsType[i] != "Wireless" ) comboPPPOEDev->insertItem(Devs[i]);
+       }
+       i++;
+   }
+     textGlobalError->setText("");
+     slotTimerRefresh();
 }
 
 
-void NetworkMan::readDetectDev()
-{
-    
-    QString Buffer;
-    QString tmp;
-    int i = 0;
-    
-    if (GetDevList->canReadLineStdout() )	 
-    {	 
-	// Read the line
-	Buffer = GetDevList->readLineStdout();
-	
-	Buffer = Buffer + " ";
-	
-	while ( Buffer.length() > 0)
-	{
-	    tmp = Buffer;
-	    tmp.truncate( Buffer.find(" ") );
-	    Devs[i] = tmp;
-	    
-	    Buffer.remove(0, Buffer.find(" ") +1);
-	    
-	    if ( Devs[i].find("lo0") == -1 && Devs[i].find("fwe") == -1 && Devs[i].find("plip") == -1 && Devs[i].find("pfsync") == -1 && Devs[i].find("pflog") == -1 && Devs[i].find("tun") == -1)
-	    {		
-		qDebug("Found device: " + Devs[i]);
-		// Determine if its a wireless or wired device
-		DevsType[i] = getTypeForIdent(Devs[i]);
-		// Get HW Idtentify line
-		DevsName[i] = getNameForIdent(Devs[i]);
-		
-		if ( DevsType[i] != "Wireless" ) {
-		    comboPPPOEDev->insertItem(Devs[i]);
-	              }
-		
-		i++;
-	    } else {
-		Devs[i] = "";
-	    }
-	    
-	    
-	    
-	    
-	    
-	}
-	
-    }
-    
-     textGlobalError->setText("" );
-    
-}
-
-
 QString NetworkMan::getLineFromCommandOutput( QString command )
 {
 	FILE *file = popen(command,"r"); 
@@ -151,16 +116,10 @@
 
 QString NetworkMan::getNameForIdent( QString ident )
 {
-	
-	QString command = "dmesg | grep " + ident;
-	QString inputLine = getLineFromCommandOutput(command);
-	QString name = "";
-	
-	inputLine = inputLine.remove (0, inputLine.find("<") + 1);
-	inputLine.truncate(inputLine.find(">"));
-	name = inputLine;
-	
-	return name;	
+    uint pos = ident.find(QRegExp("[0-9]+$"));
+    QString devNum = ident.mid(pos);
+    ident.truncate(pos);
+    return Utils::sysctl("dev." + ident + "." + devNum + ".%desc");	
 }
 
 



More information about the Commits mailing list