add some w\o

This commit is contained in:
arcan1s 2014-10-17 13:52:46 +04:00
parent c2c14c4911
commit fa27b80060
2 changed files with 19 additions and 0 deletions

View File

@ -185,6 +185,8 @@ QString Netctl::getExtIp(const QString cmd)
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
// test network connection
if (!isNetworkActive()) return QString("N\\A");
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
@ -317,6 +319,22 @@ QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
}
bool Netctl::isNetworkActive()
{
if (debug) qDebug() << PDEBUG;
QString cmd = QString("ping -c 1 google.com");
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode == 0)
return true;
else
return false;
}
bool Netctl::updateSourceEvent(const QString &source)
{
if (debug) qDebug() << PDEBUG;

View File

@ -37,6 +37,7 @@ public:
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
bool isNetworkActive();
protected:
bool sourceRequestEvent(const QString &name);