[PC-BSD Commits] r17259 - pcbsd/current/src-qt4/libpcbsd
svn at pcbsd.org
svn at pcbsd.org
Tue Jun 12 10:01:50 PDT 2012
Author: kris
Date: 2012-06-12 17:01:47 +0000 (Tue, 12 Jun 2012)
New Revision: 17259
Modified:
pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
pcbsd/current/src-qt4/libpcbsd/utils.cpp
Log:
Add new Utils::restartNetworking() function
Modified: pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h 2012-06-12 14:49:35 UTC (rev 17258)
+++ pcbsd/current/src-qt4/libpcbsd/pcbsd-utils.h 2012-06-12 17:01:47 UTC (rev 17259)
@@ -132,6 +132,7 @@
static QString getLineFromCommandOutput( QString cmd );
static QString getValFromSHFile(QString envFile, QString envVal);
static QString getValFromCSHFile(QString envFile, QString envVal);
+ static void restartNetworking();
};
Modified: pcbsd/current/src-qt4/libpcbsd/utils.cpp
===================================================================
--- pcbsd/current/src-qt4/libpcbsd/utils.cpp 2012-06-12 14:49:35 UTC (rev 17258)
+++ pcbsd/current/src-qt4/libpcbsd/utils.cpp 2012-06-12 17:01:47 UTC (rev 17259)
@@ -587,6 +587,44 @@
return outstr;
}
+// Function which displays a info box and restarts networking
+void Utils::restartNetworking()
+{
+
+ QMessageBox infoBox;
+ infoBox.setWindowModality(Qt::ApplicationModal);
+ infoBox.setWindowTitle(QObject::tr("Restarting network..."));
+ infoBox.setInformativeText(QObject::tr("Network is restarting, please wait..."));
+ infoBox.setStandardButtons(QMessageBox::NoButton);
+ infoBox.show();
+
+ QProcess cmd;
+ cmd.start(QString("/etc/rc.d/netif"), QStringList() << "restart" );
+ while ( cmd.state() != QProcess::NotRunning ) {
+ cmd.waitForFinished(100);
+ QCoreApplication::processEvents();
+ }
+
+ // Set the gateway device name
+ QString route = getConfFileValue("/etc/rc.conf", "defaultrouter=", 1);
+ if ( ! route.isEmpty() ) {
+ infoBox.setInformativeText(QObject::tr("Setting default route..."));
+ cmd.start(QString("route"), QStringList() << "delete" << "default" );
+ while ( cmd.state() != QProcess::NotRunning ) {
+ cmd.waitForFinished(100);
+ QCoreApplication::processEvents();
+ }
+
+ cmd.start(QString("route"), QStringList() << "add" << "default" << route );
+ while ( cmd.state() != QProcess::NotRunning ) {
+ cmd.waitForFinished(100);
+ QCoreApplication::processEvents();
+ }
+ }
+
+ infoBox.close();
+}
+
QStringList Utils::listShellCommandSearch( QString command, QString sch)
{
QStringList L = Utils::runShellCommand(command);
More information about the Commits
mailing list