[PC-BSD Commits] r2068 - pcbsd/trunk/ethernetconfig
svn at pcbsd.org
svn at pcbsd.org
Mon Jun 9 08:59:28 PDT 2008
Author: tim
Date: 2008-06-09 08:59:28 -0700 (Mon, 09 Jun 2008)
New Revision: 2068
Modified:
pcbsd/trunk/ethernetconfig/CMakeLists.txt
pcbsd/trunk/ethernetconfig/ethernetconfigwidget.cpp
Log:
Refactored ethernetconfig to make use of libpcbsd
Modified: pcbsd/trunk/ethernetconfig/CMakeLists.txt
===================================================================
--- pcbsd/trunk/ethernetconfig/CMakeLists.txt 2008-06-09 15:46:37 UTC (rev 2067)
+++ pcbsd/trunk/ethernetconfig/CMakeLists.txt 2008-06-09 15:59:28 UTC (rev 2068)
@@ -8,7 +8,7 @@
add_definitions(${QT_DEFINITIONS} ${KDE3_DEFINITIONS})
link_directories(${KDE3_LIB_DIR})
-include_directories(${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
+include_directories(${KDE3_INCLUDE_DIR} ${QT_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} /PCBSD/includes)
set (um_SRCS
ethernetconfig.cpp
@@ -26,7 +26,7 @@
kde3_add_executable(ethernetconfig ${um_SRCS})
-target_link_libraries(ethernetconfig ${QT_AND_KDECORE_LIBRARIES} kdeui pthread)
+target_link_libraries(ethernetconfig ${QT_AND_KDECORE_LIBRARIES} kdeui pthread pcbsd)
### INSTALL ###
Modified: pcbsd/trunk/ethernetconfig/ethernetconfigwidget.cpp
===================================================================
--- pcbsd/trunk/ethernetconfig/ethernetconfigwidget.cpp 2008-06-09 15:46:37 UTC (rev 2067)
+++ pcbsd/trunk/ethernetconfig/ethernetconfigwidget.cpp 2008-06-09 15:59:28 UTC (rev 2068)
@@ -36,7 +36,13 @@
#include <qapplication.h>
#include <qtimer.h>
#include <qpushbutton.h>
+#include <qregexp.h>
+
#include <iostream>
+
+#include <netif.h>
+#include <utils.h>
+
#include "ethernetconfig.h"
#include "ethernetconfigwidget.h"
#include "ethernetconfigwidgetbase.h"
@@ -462,63 +468,28 @@
QString ethernetconfigWidget::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");
}
QString ethernetconfigWidget::getIpForIdent( QString ident )
{
- QString command = "ifconfig " +ident + " | grep \"inet \"";
- QString inputLine = getLineFromCommandOutput(command);
- QString ip= "";
-
- if (inputLine != "" && inputLine.find("inet ") != -1){
-
- ip = inputLine.remove(0, inputLine.find("inet ") + 5);
- ip.truncate(ip.find(" "));
-
-
- }
-
- return ip;
+ NetworkInterface ifr(ident);
+ return ifr.ipAsString();
}
QString ethernetconfigWidget::getMacForIdent( QString ident )
{
- QString command = "ifconfig " +ident + " | grep \"ether\"";
- QString inputLine = getLineFromCommandOutput(command);
- QString ether = "";
-
- if (inputLine != "" && inputLine.find("ether") != -1){
-
- ether = inputLine.remove(0, inputLine.find(" ") + 1);
-
- }
-
- return ether;
+ NetworkInterface ifr(ident);
+ return ifr.macAsString();
}
QString ethernetconfigWidget::getStatusForIdent( QString ident )
{
- QString command = "ifconfig " +ident + " | grep \"status\"";
- QString inputLine = getLineFromCommandOutput(command);
- QString status = "";
-
- if (inputLine != "" && inputLine.find("status") != -1){
-
- status = inputLine.remove(0, inputLine.find(" ") + 1);
- status.truncate(inputLine.find("\n") );
-
- }
-
- return status;
+ NetworkInterface ifr(ident);
+ return ifr.mediaStatusAsString();
}
QString ethernetconfigWidget::getInPacketsForIdent(QString ident)
@@ -580,39 +551,8 @@
QString ethernetconfigWidget::getNetmaskForIdent( QString ident )
{
-int num;
- QString RealIP, tmp;
-
- QString command = "ifconfig " +ident + " | grep \"netmask\"";
- QString inputLine = getLineFromCommandOutput(command);
- QString net= "";
-
- if (inputLine != "" && inputLine.find("netmask ") != -1){
-
- net = inputLine.remove(0, inputLine.find("netmask ") + 8);
- net.truncate(net.find(" "));
-
- num = net.mid(2, 2).toInt(0, 16);
- tmp.setNum(num);
- RealIP = tmp;
-
- num = net.mid(4, 2).toInt(0, 16);
- tmp.setNum(num);
- RealIP = RealIP + "." + tmp ;
-
- num = net.mid(6, 2).toInt(0, 16);
- tmp.setNum(num);
- RealIP = RealIP + "." + tmp ;
-
- num = net.mid(8, 2).toInt(0, 16);
- tmp.setNum(num);
- RealIP = RealIP + "." + tmp ;
-
- //QMessageBox::information( this, "Application name", "IP: " + RealIP );
-
- }
-
- return RealIP;
+ NetworkInterface ifr(ident);
+ return ifr.netmaskAsString();
}
QString ethernetconfigWidget::getLineFromCommandOutput( QString command )
More information about the Commits
mailing list