rewrite netctlautowindow

This commit is contained in:
arcan1s 2014-08-09 20:48:12 +04:00
parent 172624b494
commit 558a206a8d
3 changed files with 109 additions and 34 deletions

View File

@ -143,7 +143,7 @@ bool MainWindow::forceStopHelper()
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Close"),
QList<QVariant>(), true);
QList<QVariant>(), true, debug);
return !responce.isEmpty();
}
@ -190,7 +190,7 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
if (useHelper)
interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
QList<QVariant>(), true)[0].toStringList();
QList<QVariant>(), true, debug)[0].toStringList();
else
interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty())
@ -228,15 +228,15 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
args.append(settingsList);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Create"),
args, true);
args, true, debug);
args.clear();
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"),
args, true);
args, true, debug);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else {
QString profileTempName = netctlProfile->createProfile(profile, settings);
@ -375,10 +375,10 @@ void MainWindow::mainTabEnableProfile()
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Enable"),
args, true);
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else {
netctlCommand->enableProfile(profile);
@ -406,7 +406,7 @@ void MainWindow::mainTabRemoveProfile()
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Remove"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else
status = netctlProfile->removeProfile(profile);
@ -435,10 +435,10 @@ void MainWindow::mainTabRestartProfile()
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Restart"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else {
netctlCommand->restartProfile(profile);
@ -470,10 +470,10 @@ void MainWindow::mainTabStartProfile()
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"),
args, true);
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else {
netctlCommand->startProfile(profile);
@ -664,7 +664,7 @@ void MainWindow::profileTabClear()
if (useHelper)
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true));
QList<QVariant>(), true, debug), debug);
else
profiles = netctlCommand->getProfileList();
for (int i=0; i<profiles.count(); i++)
@ -858,7 +858,7 @@ void MainWindow::profileTabCreateProfile()
args.append(settingsList);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Create"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else {
QString profileTempName = netctlProfile->createProfile(profile, settings);
@ -886,7 +886,7 @@ void MainWindow::profileTabLoadProfile()
args.append(profile);
QStringList settingsList = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("Profile"),
args, true)[0].toStringList();
args, true, debug)[0].toStringList();
for (int i=0; i<settingsList.count(); i++) {
QString key = settingsList[i].split(QString("=="))[0];
QString value = settingsList[i].split(QString("=="))[1];
@ -958,7 +958,7 @@ void MainWindow::profileTabRemoveProfile()
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Remove"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else
status = netctlProfile->removeProfile(profile);
@ -1068,15 +1068,15 @@ void MainWindow::wifiTabStart()
args.append(profile);
QString profileName = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileByEssid"),
args, true)[0].toString();
args, true, debug)[0].toString();
args.clear();
args.append(profileName);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"),
args, true);
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true)[0].toBool();
args, true, debug)[0].toBool();
}
else {
QString profileName = wpaCommand->existentProfile(profile);

View File

@ -125,7 +125,7 @@ QString MainWindow::getInformation()
if (useHelper) {
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("Information"),
QList<QVariant>(), true)[0].toStringList();
QList<QVariant>(), true, debug)[0].toStringList();
profile = request[0];
status = request[1];
}
@ -165,7 +165,7 @@ bool MainWindow::isHelperActive()
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("Active"),
QList<QVariant>(), true);
QList<QVariant>(), true, debug);
return (!responce.isEmpty());
}
@ -605,10 +605,10 @@ void MainWindow::updateMainTab()
if (useHelper) {
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true)[0].toBool();
QList<QVariant>(), true, debug)[0].toBool();
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true));
QList<QVariant>(), true, debug), debug);
}
else {
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
@ -700,7 +700,7 @@ void MainWindow::updateWifiTab()
if (useHelper)
scanResults = parseOutputWifi(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("WiFi"),
QList<QVariant>(), true));
QList<QVariant>(), true, debug), debug);
else
scanResults = wpaCommand->scanWifi();

View File

@ -169,12 +169,26 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
ui->tableWidget->setDisabled(true);
// actions
if (netctlCommand->isNetctlAutoEnabled())
bool enabled = false;
bool running = false;
if (useHelper) {
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
QList<QVariant>(), true, debug)[0].toBool();
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoRunning"),
QList<QVariant>(), true, debug)[0].toBool();
}
else {
enabled = netctlCommand->isNetctlAutoEnabled();
running = netctlCommand->isNetctlAutoRunning();
}
if (enabled)
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true);
if (netctlCommand->isNetctlAutoRunning()) {
if (running) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionDisableAll->setVisible(true);
@ -190,7 +204,13 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
netctlAutoRefreshButtons(0, 0);
return;
}
QList<netctlProfileInfo> profiles = netctlCommand->getProfileListFromNetctlAuto();
QList<netctlProfileInfo> profiles;
if (useHelper)
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true, debug), debug);
else
profiles = netctlCommand->getProfileListFromNetctlAuto();
ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1);
@ -257,7 +277,14 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoDisableAllProfiles())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoDisableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -274,7 +301,17 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoEnableProfile(profile))
bool status = false;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoEnable"),
args, true, debug)[0].toBool();
}
else
status = netctlCommand->autoEnableProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -288,7 +325,14 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoEnableAllProfiles())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoEnableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -305,7 +349,17 @@ void NetctlAutoWindow::netctlAutoStartProfile()
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoStartProfile(profile))
bool status = false;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoStart"),
args, true, debug)[0].toBool();
}
else
status = netctlCommand->autoStartProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -318,7 +372,14 @@ void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableService]";
if (netctlCommand->autoEnableService())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoEnableService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -331,7 +392,14 @@ void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRestartService]";
if (netctlCommand->autoRestartService())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoRestartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -344,7 +412,14 @@ void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartService]";
if (netctlCommand->autoStartService())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CONTROL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoStartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));