rewrite mainwindow to use helper

This commit is contained in:
arcan1s
2014-08-09 18:08:01 +04:00
parent 23f4a7f141
commit e64e8810f8
14 changed files with 296 additions and 112 deletions

View File

@ -364,12 +364,13 @@ bool Netctl::isNetctlAutoRunning()
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find service";
return false;
}
if (getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not interface";
return false;
}
QString interface = getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString argument = netctlAutoService + QString("@") + interface + QString(".service");
return cmdCall(false, systemctlCommand, QString("is-active"), argument);
@ -523,12 +524,13 @@ bool Netctl::autoEnableService()
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not find service";
return false;
}
if (getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]" << ":" << "Could not interface";
return false;
}
QString interface = getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString argument = netctlAutoService + QString("@") + interface + QString(".service");
if (isNetctlAutoEnabled())
@ -548,12 +550,13 @@ bool Netctl::autoRestartService()
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not find service";
return false;
}
if (getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]" << ":" << "Could not interface";
return false;
}
QString interface = getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString argument = netctlAutoService + QString("@") + interface + QString(".service");
if (isNetctlAutoRunning())
@ -573,12 +576,13 @@ bool Netctl::autoStartService()
if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not find service";
return false;
}
if (getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[Netctl]" << "[autoStartService]" << ":" << "Could not interface";
return false;
}
QString interface = getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString argument = netctlAutoService + QString("@") + interface + QString(".service");
if (isNetctlAutoRunning())

View File

@ -253,14 +253,15 @@ bool WpaSup::startWpaSupplicant()
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find library";
return false;
}
if (netctlCommand->getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find interfaces";
return false;
}
if (QFile(pidFile).exists())
return true;
QString interface = netctlCommand->getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString cmd = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
@ -311,12 +312,13 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find library";
return QString();
}
if (netctlCommand->getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find interfaces";
return QString();
}
QString interface = netctlCommand->getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd;
@ -365,12 +367,13 @@ bool WpaSup::wpaCliCall(const QString commandLine)
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find library";
return false;
}
if (netctlCommand->getWirelessInterfaceList().isEmpty()) {
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty()) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find interfaces";
return false;
}
QString interface = netctlCommand->getWirelessInterfaceList()[0];
QString interface = interfaces[0];
QString cmd = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << cmd;