mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
* edit WiFi and ProfileList calls
* optimization of WifiMenu * small refactoring
This commit is contained in:
parent
9993fee336
commit
2cf876cf32
@ -1,4 +1,4 @@
|
|||||||
cmake_minimum_required (VERSION 2.8.12)
|
wcmake_minimum_required (VERSION 2.8.12)
|
||||||
|
|
||||||
cmake_policy (SET CMP0003 OLD)
|
cmake_policy (SET CMP0003 OLD)
|
||||||
cmake_policy (SET CMP0002 OLD)
|
cmake_policy (SET CMP0002 OLD)
|
||||||
@ -11,7 +11,7 @@ set (PROJECT_CONTACT "esalexeev@gmail.com")
|
|||||||
set (PROJECT_LICENSE "GPLv3")
|
set (PROJECT_LICENSE "GPLv3")
|
||||||
set (PROJECT_VERSION_MAJOR 1)
|
set (PROJECT_VERSION_MAJOR 1)
|
||||||
set (PROJECT_VERSION_MINOR 4)
|
set (PROJECT_VERSION_MINOR 4)
|
||||||
set (PROJECT_VERSION_PATCH 0)
|
set (PROJECT_VERSION_PATCH 1)
|
||||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||||
|
3
sources/gui/docs/.directory
Normal file
3
sources/gui/docs/.directory
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[Dolphin]
|
||||||
|
Timestamp=2015,3,7,17,10,22
|
||||||
|
Version=3
|
@ -198,7 +198,7 @@ small {
|
|||||||
<!-- wpa_supplicant actions -->
|
<!-- wpa_supplicant actions -->
|
||||||
<tr>
|
<tr>
|
||||||
<td>QStringList WiFi()</td>
|
<td>QStringList WiFi()</td>
|
||||||
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
|
<td>returns available WiFi points in format <code>NAME|SECURITY|FREQS|MACS|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||||
<td>yes</td>
|
<td>yes</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- /netctl path -->
|
<!-- /netctl path -->
|
||||||
@ -223,7 +223,7 @@ small {
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>QStringList ProfileList()</td>
|
<td>QStringList ProfileList()</td>
|
||||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code></td>
|
<td>returns available profiles in format <code>NAME|DESCRIPTION|ESSID|ACTIVE|ENABLED</code></td>
|
||||||
<td>no</td>
|
<td>no</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@ -279,6 +279,11 @@ small {
|
|||||||
<td>returns value of the key by the given profile or empty line</td>
|
<td>returns value of the key by the given profile or empty line</td>
|
||||||
<td>no</td>
|
<td>no</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>QStringList ProfileValues(QString profile, QStringList keys)</td>
|
||||||
|
<td>returns values of the keys by the given profile or empty lines</td>
|
||||||
|
<td>no</td>
|
||||||
|
</tr>
|
||||||
<!-- gui service -->
|
<!-- gui service -->
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
|
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
|
||||||
|
@ -33,12 +33,13 @@ QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw)
|
|||||||
QStringList list = raw[0].toStringList();
|
QStringList list = raw[0].toStringList();
|
||||||
for (int i=0; i<list.count(); i++) {
|
for (int i=0; i<list.count(); i++) {
|
||||||
QStringList info = list[i].split(QChar('|'));
|
QStringList info = list[i].split(QChar('|'));
|
||||||
if (info.count() != 4) continue;
|
if (info.count() != 5) continue;
|
||||||
netctlProfileInfo profile;
|
netctlProfileInfo profile;
|
||||||
profile.name = info[0];
|
profile.name = info[0];
|
||||||
profile.description = info[1];
|
profile.description = info[1];
|
||||||
profile.active = info[2].toInt();
|
profile.essid = info[2];
|
||||||
profile.enabled = info[3].toInt();
|
profile.active = info[3].toInt();
|
||||||
|
profile.enabled = info[4].toInt();
|
||||||
profileInfo.append(profile);
|
profileInfo.append(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,13 +54,15 @@ QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw)
|
|||||||
QStringList list = raw[0].toStringList();
|
QStringList list = raw[0].toStringList();
|
||||||
for (int i=0; i<list.count(); i++) {
|
for (int i=0; i<list.count(); i++) {
|
||||||
QStringList info = list[i].split(QChar('|'));
|
QStringList info = list[i].split(QChar('|'));
|
||||||
if (info.count() != 5) continue;
|
if (info.count() != 7) continue;
|
||||||
netctlWifiInfo wifi;
|
netctlWifiInfo wifi;
|
||||||
wifi.name = info[0];
|
wifi.name = info[0];
|
||||||
wifi.security = info[1];
|
wifi.security = info[1];
|
||||||
wifi.signal = info[2];
|
wifi.frequencies = info[2].split(QChar(','));
|
||||||
wifi.active = info[3].toInt();
|
wifi.macs = info[3].split(QChar(','));
|
||||||
wifi.exists = info[4].toInt();
|
wifi.signal = info[4].toInt();
|
||||||
|
wifi.active = info[5].toInt();
|
||||||
|
wifi.exists = info[6].toInt();
|
||||||
wifiInfo.append(wifi);
|
wifiInfo.append(wifi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,7 @@ int EthernetWidget::isOk()
|
|||||||
{
|
{
|
||||||
// file wpa_supplicant doesn't exists
|
// file wpa_supplicant doesn't exists
|
||||||
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
||||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) return 1;
|
||||||
return 1;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -156,11 +156,9 @@ int GeneralWidget::isOk()
|
|||||||
(ui->comboBox_connection->currentText() == QString("vlan")) ||
|
(ui->comboBox_connection->currentText() == QString("vlan")) ||
|
||||||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
|
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
|
||||||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
||||||
if (ui->listWidget_bindto->count() == 0)
|
if (ui->listWidget_bindto->count() == 0) return 1;
|
||||||
return 1;
|
|
||||||
// empty description
|
// empty description
|
||||||
if (ui->lineEdit_description->text().isEmpty())
|
if (ui->lineEdit_description->text().isEmpty()) return 2;
|
||||||
return 2;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -375,15 +375,13 @@ int IpWidget::isOk()
|
|||||||
if ((ui->checkBox_ip->checkState() == Qt::Checked) &&
|
if ((ui->checkBox_ip->checkState() == Qt::Checked) &&
|
||||||
(ui->comboBox_ip->currentText() == QString("static")))
|
(ui->comboBox_ip->currentText() == QString("static")))
|
||||||
if ((ui->listWidget_ipAddress->count() == 0) ||
|
if ((ui->listWidget_ipAddress->count() == 0) ||
|
||||||
(ui->lineEdit_gateway->text().isEmpty()))
|
(ui->lineEdit_gateway->text().isEmpty())) return 1;
|
||||||
return 1;
|
|
||||||
// ipv6 settings is not set
|
// ipv6 settings is not set
|
||||||
if ((ui->checkBox_ip6->checkState() == Qt::Checked) &&
|
if ((ui->checkBox_ip6->checkState() == Qt::Checked) &&
|
||||||
((ui->comboBox_ip6->currentText() == QString("static")) ||
|
((ui->comboBox_ip6->currentText() == QString("static")) ||
|
||||||
(ui->comboBox_ip6->currentText() == QString("stateless"))))
|
(ui->comboBox_ip6->currentText() == QString("stateless"))))
|
||||||
if ((ui->listWidget_ipAddress6->count() == 0) ||
|
if ((ui->listWidget_ipAddress6->count() == 0) ||
|
||||||
(ui->lineEdit_gateway6->text().isEmpty()))
|
(ui->lineEdit_gateway6->text().isEmpty())) return 2;
|
||||||
return 2;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,6 @@ void MainWindow::setMenuActionsShown(const bool state)
|
|||||||
void MainWindow::updateMenuMain()
|
void MainWindow::updateMenuMain()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
setMenuActionsShown(false);
|
|
||||||
actionMenu->setDefaultAction(toolBarActions[QString("mainStart")]);
|
actionMenu->setDefaultAction(toolBarActions[QString("mainStart")]);
|
||||||
|
|
||||||
toolBarActions[QString("netctlAuto")]->setVisible(true);
|
toolBarActions[QString("netctlAuto")]->setVisible(true);
|
||||||
@ -110,7 +109,7 @@ void MainWindow::updateMenuMain()
|
|||||||
toolBarActions[QString("mainEnable")]->setIcon(QIcon::fromTheme("edit-remove"));
|
toolBarActions[QString("mainEnable")]->setIcon(QIcon::fromTheme("edit-remove"));
|
||||||
} else {
|
} else {
|
||||||
toolBarActions[QString("mainEnable")]->setText(QApplication::translate("MainWindow", "Enable"));
|
toolBarActions[QString("mainEnable")]->setText(QApplication::translate("MainWindow", "Enable"));
|
||||||
toolBarActions[QString("mainEnable")]->setIcon(QIcon::fromTheme("edit-add"));
|
toolBarActions[QString("mainEnable")]->setIcon(QIcon::fromTheme("list-add"));
|
||||||
}
|
}
|
||||||
toolBarActions[QString("mainEnable")]->setVisible(true);
|
toolBarActions[QString("mainEnable")]->setVisible(true);
|
||||||
toolBarActions[QString("mainEdit")]->setVisible(true);
|
toolBarActions[QString("mainEdit")]->setVisible(true);
|
||||||
@ -121,7 +120,6 @@ void MainWindow::updateMenuMain()
|
|||||||
void MainWindow::updateMenuProfile()
|
void MainWindow::updateMenuProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
setMenuActionsShown(false);
|
|
||||||
actionMenu->setDefaultAction(toolBarActions[QString("profileSave")]);
|
actionMenu->setDefaultAction(toolBarActions[QString("profileSave")]);
|
||||||
|
|
||||||
toolBarActions[QString("profileClear")]->setVisible(true);
|
toolBarActions[QString("profileClear")]->setVisible(true);
|
||||||
@ -134,7 +132,6 @@ void MainWindow::updateMenuProfile()
|
|||||||
void MainWindow::updateMenuWifi()
|
void MainWindow::updateMenuWifi()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
setMenuActionsShown(false);
|
|
||||||
actionMenu->setDefaultAction(toolBarActions[QString("wifiStart")]);
|
actionMenu->setDefaultAction(toolBarActions[QString("wifiStart")]);
|
||||||
|
|
||||||
toolBarActions[QString("wifiRefresh")]->setVisible(true);
|
toolBarActions[QString("wifiRefresh")]->setVisible(true);
|
||||||
@ -204,9 +201,9 @@ void MainWindow::updateMainTab()
|
|||||||
font.setItalic(profiles[i].enabled);
|
font.setItalic(profiles[i].enabled);
|
||||||
// tooltip
|
// tooltip
|
||||||
QString toolTip = QString("");
|
QString toolTip = QString("");
|
||||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Profile")).arg(profiles[i].name);
|
|
||||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Active")).arg(checkStatus(profiles[i].active));
|
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Active")).arg(checkStatus(profiles[i].active));
|
||||||
toolTip += QString("%1: %2").arg(QApplication::translate("MainWindow", "Enabled")).arg(checkStatus(profiles[i].enabled));
|
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Enabled")).arg(checkStatus(profiles[i].enabled));
|
||||||
|
toolTip += QString("%1: %2").arg(QApplication::translate("MainWindow", "Is wireless")).arg(checkStatus(!profiles[i].essid.isEmpty()));
|
||||||
// name
|
// name
|
||||||
ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
|
ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
|
||||||
ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||||
@ -294,7 +291,8 @@ void MainWindow::updateWifiTab()
|
|||||||
font.setItalic(scanResults[i].exists);
|
font.setItalic(scanResults[i].exists);
|
||||||
// tooltip
|
// tooltip
|
||||||
QString toolTip = QString("");
|
QString toolTip = QString("");
|
||||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "ESSID")).arg(scanResults[i].name);
|
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "MAC")).arg(scanResults[i].macs.join(QString(", ")));
|
||||||
|
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Frequency")).arg(scanResults[i].frequencies.join(QString(", ")));
|
||||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Active")).arg(checkStatus(scanResults[i].active));
|
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWindow", "Active")).arg(checkStatus(scanResults[i].active));
|
||||||
toolTip += QString("%1: %2").arg(QApplication::translate("MainWindow", "Exists")).arg(checkStatus(scanResults[i].exists));
|
toolTip += QString("%1: %2").arg(QApplication::translate("MainWindow", "Exists")).arg(checkStatus(scanResults[i].exists));
|
||||||
// name
|
// name
|
||||||
@ -303,7 +301,7 @@ void MainWindow::updateWifiTab()
|
|||||||
ui->tableWidget_wifi->item(i, 0)->setToolTip(toolTip);
|
ui->tableWidget_wifi->item(i, 0)->setToolTip(toolTip);
|
||||||
ui->tableWidget_wifi->item(i, 0)->setFont(font);
|
ui->tableWidget_wifi->item(i, 0)->setFont(font);
|
||||||
// signal
|
// signal
|
||||||
ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(scanResults[i].signal));
|
ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(QString::number(scanResults[i].signal)));
|
||||||
ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
ui->tableWidget_wifi->item(i, 1)->setToolTip(toolTip);
|
ui->tableWidget_wifi->item(i, 1)->setToolTip(toolTip);
|
||||||
// security
|
// security
|
||||||
@ -372,7 +370,7 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
|
|||||||
enableProfile->setIcon(QIcon::fromTheme("edit-remove"));
|
enableProfile->setIcon(QIcon::fromTheme("edit-remove"));
|
||||||
} else {
|
} else {
|
||||||
enableProfile->setText(QApplication::translate("MainWindow", "Enable profile"));
|
enableProfile->setText(QApplication::translate("MainWindow", "Enable profile"));
|
||||||
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
enableProfile->setIcon(QIcon::fromTheme("list-add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
|
@ -301,12 +301,13 @@ bool MainWindow::startHelper()
|
|||||||
void MainWindow::setTab(int tab)
|
void MainWindow::setTab(int tab)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
if (debug) qDebug() << PDEBUG << ":" << "Set tab" << tab;
|
||||||
|
|
||||||
if (tab > 2) tab = 0;
|
if (tab > 2) tab = 0;
|
||||||
ui->tabWidget->setCurrentIndex(tab);
|
if (tab == ui->tabWidget->currentIndex())
|
||||||
|
|
||||||
updateTabs(tab);
|
updateTabs(tab);
|
||||||
|
else
|
||||||
|
ui->tabWidget->setCurrentIndex(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,7 +338,7 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
QString language = Language::defineLanguage(configPath, args[QString("options")].toString());
|
QString language = Language::defineLanguage(configPath, args[QString("options")].toString());
|
||||||
qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||||
qApp->installTranslator(qtTranslator);
|
qApp->installTranslator(qtTranslator);
|
||||||
translator->load(QString(":/translations/") + language);
|
translator->load(QString(":/translations/%1").arg(language));
|
||||||
qApp->installTranslator(translator);
|
qApp->installTranslator(translator);
|
||||||
|
|
||||||
createObjects();
|
createObjects();
|
||||||
@ -345,11 +346,7 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
|||||||
createToolBars();
|
createToolBars();
|
||||||
|
|
||||||
// tray
|
// tray
|
||||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
|
trayIcon->setVisible(QSystemTrayIcon::isSystemTrayAvailable() && (configuration[QString("SYSTRAY")] == QString("true")));
|
||||||
(configuration[QString("SYSTRAY")] == QString("true")))
|
|
||||||
trayIcon->setVisible(true);
|
|
||||||
else
|
|
||||||
trayIcon->setVisible(false);
|
|
||||||
if (trayIcon->isVisible()) {
|
if (trayIcon->isVisible()) {
|
||||||
if (configuration[QString("STARTTOTRAY")] == QString("true"))
|
if (configuration[QString("STARTTOTRAY")] == QString("true"))
|
||||||
hide();
|
hide();
|
||||||
@ -375,12 +372,18 @@ void MainWindow::updateMenu()
|
|||||||
int tab = ui->tabWidget->currentIndex();
|
int tab = ui->tabWidget->currentIndex();
|
||||||
setMenuActionsShown(false);
|
setMenuActionsShown(false);
|
||||||
|
|
||||||
if (tab == 0)
|
switch (tab) {
|
||||||
updateMenuMain();
|
case 1:
|
||||||
else if (tab == 1)
|
|
||||||
updateMenuProfile();
|
updateMenuProfile();
|
||||||
else if (tab == 2)
|
break;
|
||||||
|
case 2:
|
||||||
updateMenuWifi();
|
updateMenuWifi();
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
updateMenuMain();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -389,12 +392,18 @@ void MainWindow::updateTabs(const int tab)
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
||||||
|
|
||||||
if (tab == 0)
|
switch (tab) {
|
||||||
updateMainTab();
|
case 1:
|
||||||
else if (tab == 1)
|
|
||||||
updateProfileTab();
|
updateProfileTab();
|
||||||
else if (tab == 2)
|
break;
|
||||||
|
case 2:
|
||||||
updateWifiTab();
|
updateWifiTab();
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
updateMainTab();
|
||||||
|
break;
|
||||||
|
}
|
||||||
updateMenu();
|
updateMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -479,7 +479,7 @@ void MainWindow::createToolBars()
|
|||||||
toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("view-refresh")),
|
toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("view-refresh")),
|
||||||
QApplication::translate("MainWindow", "Restart"),
|
QApplication::translate("MainWindow", "Restart"),
|
||||||
this, SLOT(mainTabRestartProfile()));
|
this, SLOT(mainTabRestartProfile()));
|
||||||
toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("edit-add")),
|
toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("list-add")),
|
||||||
QApplication::translate("MainWindow", "Enable"),
|
QApplication::translate("MainWindow", "Enable"),
|
||||||
this, SLOT(mainTabEnableProfile()));
|
this, SLOT(mainTabEnableProfile()));
|
||||||
toolBarActions[QString("mainStopAll")] = menu->addAction(QIcon::fromTheme(QString("process-stop")),
|
toolBarActions[QString("mainStopAll")] = menu->addAction(QIcon::fromTheme(QString("process-stop")),
|
||||||
|
@ -118,12 +118,10 @@ QMap<QString, QString> MobileWidget::getSettings()
|
|||||||
int MobileWidget::isOk()
|
int MobileWidget::isOk()
|
||||||
{
|
{
|
||||||
// APN is not set
|
// APN is not set
|
||||||
if (ui->lineEdit_apn->text().isEmpty())
|
if (ui->lineEdit_apn->text().isEmpty()) return 1;
|
||||||
return 1;
|
|
||||||
// config file doesn't exist
|
// config file doesn't exist
|
||||||
if (!ui->lineEdit_options->text().isEmpty())
|
if (!ui->lineEdit_options->text().isEmpty())
|
||||||
if (!QFile(ui->lineEdit_options->text()).exists())
|
if (!QFile(ui->lineEdit_options->text()).exists()) return 2;
|
||||||
return 2;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -145,25 +145,19 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
|||||||
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
||||||
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
|
enableAllProfiles->setIcon(QIcon::fromTheme("list-add"));
|
||||||
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
||||||
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
|
|
||||||
// set text
|
// set text
|
||||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
|
startProfile->setVisible(ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty());
|
||||||
enableProfile->setVisible(false);
|
|
||||||
startProfile->setVisible(false);
|
|
||||||
} else {
|
|
||||||
enableProfile->setVisible(true);
|
|
||||||
startProfile->setVisible(true);
|
|
||||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||||
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
enableProfile->setIcon(QIcon::fromTheme("list-add"));
|
||||||
} else {
|
} else {
|
||||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||||
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||||
@ -227,7 +221,7 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
ui->actionDisableAll->setVisible(false);
|
ui->actionDisableAll->setVisible(false);
|
||||||
ui->actionEnableAll->setVisible(false);
|
ui->actionEnableAll->setVisible(false);
|
||||||
ui->actionRestartService->setVisible(false);
|
ui->actionRestartService->setVisible(false);
|
||||||
netctlAutoRefreshButtons(0, 0);
|
netctlAutoRefreshButtons(nullptr, nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QList<netctlProfileInfo> profiles;
|
QList<netctlProfileInfo> profiles;
|
||||||
@ -288,10 +282,11 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ui->tableWidget->setCurrentCell(-1, -1);
|
||||||
ui->tableWidget->setEnabled(true);
|
ui->tableWidget->setEnabled(true);
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
|
||||||
|
|
||||||
netctlAutoRefreshButtons(0, 0);
|
netctlAutoRefreshButtons(nullptr, nullptr);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,8 +320,7 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == 0)
|
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||||
return;
|
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||||
bool status = false;
|
bool status = false;
|
||||||
@ -380,8 +374,7 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == nullptr)
|
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||||
return;
|
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||||
bool status = false;
|
bool status = false;
|
||||||
@ -492,27 +485,17 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
|||||||
ui->actionSwitch->setVisible(false);
|
ui->actionSwitch->setVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
|
toolBarActions[QString("switch")]->setEnabled(ui->tableWidget->item(current->row(), 2)->text().isEmpty());
|
||||||
// buttons
|
ui->actionSwitch->setVisible(ui->tableWidget->item(current->row(), 2)->text().isEmpty());
|
||||||
toolBarActions[QString("enable")]->setDisabled(true);
|
|
||||||
toolBarActions[QString("switch")]->setDisabled(true);
|
|
||||||
// menu
|
|
||||||
ui->actionEnable->setVisible(false);
|
|
||||||
ui->actionSwitch->setVisible(false);
|
|
||||||
} else {
|
|
||||||
// buttons
|
|
||||||
toolBarActions[QString("enable")]->setEnabled(true);
|
toolBarActions[QString("enable")]->setEnabled(true);
|
||||||
toolBarActions[QString("switch")]->setEnabled(true);
|
|
||||||
// menu
|
|
||||||
ui->actionEnable->setVisible(true);
|
ui->actionEnable->setVisible(true);
|
||||||
ui->actionSwitch->setVisible(true);
|
|
||||||
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
||||||
// buttons
|
// buttons
|
||||||
toolBarActions[QString("enable")]->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
toolBarActions[QString("enable")]->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||||
toolBarActions[QString("enable")]->setIcon(QIcon::fromTheme("edit-add"));
|
toolBarActions[QString("enable")]->setIcon(QIcon::fromTheme("list-add"));
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
|
||||||
} else {
|
} else {
|
||||||
// buttons
|
// buttons
|
||||||
toolBarActions[QString("enable")]->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
toolBarActions[QString("enable")]->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||||
@ -521,5 +504,4 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
|||||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
|
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
|
||||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
<widget class="QStatusBar" name="statusBar"/>
|
<widget class="QStatusBar" name="statusBar"/>
|
||||||
<action name="actionEnable">
|
<action name="actionEnable">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-add">
|
<iconset theme="list-add">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
@ -127,7 +127,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionEnableAll">
|
<action name="actionEnableAll">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="edit-add">
|
<iconset theme="list-add">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
|
@ -157,22 +157,18 @@ int PppoeWidget::isOk()
|
|||||||
{
|
{
|
||||||
// config file doesn't exist
|
// config file doesn't exist
|
||||||
if (!ui->lineEdit_options->text().isEmpty())
|
if (!ui->lineEdit_options->text().isEmpty())
|
||||||
if (!QFile(ui->lineEdit_options->text()).exists())
|
if (!QFile(ui->lineEdit_options->text()).exists()) return 1;
|
||||||
return 1;
|
|
||||||
// mac address
|
// mac address
|
||||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
|
if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
|
||||||
if (ui->lineEdit_mac->text().length() != (6 * 2 + 5))
|
if (ui->lineEdit_mac->text().length() != (6 * 2 + 5)) return 2;
|
||||||
return 2;
|
|
||||||
// session id is not set
|
// session id is not set
|
||||||
if (!ui->lineEdit_session->text().remove(QChar(':')).isEmpty())
|
if (!ui->lineEdit_session->text().remove(QChar(':')).isEmpty())
|
||||||
if (ui->lineEdit_session->text().split(QChar(':'))[0].isEmpty())
|
if (ui->lineEdit_session->text().split(QChar(':'))[0].isEmpty()) return 3;
|
||||||
return 3;
|
|
||||||
// session mac address
|
// session mac address
|
||||||
if (!ui->lineEdit_session->text().remove(QChar(':')).isEmpty()) {
|
if (!ui->lineEdit_session->text().remove(QChar(':')).isEmpty()) {
|
||||||
QStringList item = ui->lineEdit_session->text().split(QChar(':'));
|
QStringList item = ui->lineEdit_session->text().split(QChar(':'));
|
||||||
item.removeFirst();
|
item.removeFirst();
|
||||||
if (item.join(QChar(':')).length() != (6 * 2 + 5))
|
if (item.join(QChar(':')).length() != (6 * 2 + 5)) return 4;
|
||||||
return 4;
|
|
||||||
}
|
}
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -70,8 +70,7 @@ QMap<QString, QString> TunnelWidget::getSettings()
|
|||||||
int TunnelWidget::isOk()
|
int TunnelWidget::isOk()
|
||||||
{
|
{
|
||||||
// ip is not correct
|
// ip is not correct
|
||||||
if (!IpRegExp::checkString(ui->lineEdit_remote->text(), IpRegExp::ip4Regex()))
|
if (!IpRegExp::checkString(ui->lineEdit_remote->text(), IpRegExp::ip4Regex())) return 1;
|
||||||
return 1;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -59,11 +59,9 @@ QMap<QString, QString> TuntapWidget::getSettings()
|
|||||||
int TuntapWidget::isOk()
|
int TuntapWidget::isOk()
|
||||||
{
|
{
|
||||||
// empty username
|
// empty username
|
||||||
if (ui->lineEdit_user->text().isEmpty())
|
if (ui->lineEdit_user->text().isEmpty()) return 1;
|
||||||
return 1;
|
|
||||||
// empty group name
|
// empty group name
|
||||||
if (ui->lineEdit_group->text().isEmpty())
|
if (ui->lineEdit_group->text().isEmpty()) return 2;
|
||||||
return 2;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -232,26 +232,21 @@ int WirelessWidget::isOk()
|
|||||||
// empty key
|
// empty key
|
||||||
if ((ui->comboBox_security->currentText() == QString("wep")) ||
|
if ((ui->comboBox_security->currentText() == QString("wep")) ||
|
||||||
(ui->comboBox_security->currentText() == QString("wpa")))
|
(ui->comboBox_security->currentText() == QString("wpa")))
|
||||||
if (ui->lineEdit_key->text().isEmpty())
|
if (ui->lineEdit_key->text().isEmpty()) return 1;
|
||||||
return 1;
|
|
||||||
// empty settings
|
// empty settings
|
||||||
if (ui->comboBox_security->currentText() == QString("wpa-configsection"))
|
if (ui->comboBox_security->currentText() == QString("wpa-configsection"))
|
||||||
if (ui->listWidget_wpaConfigSection->count() == 0)
|
if (ui->listWidget_wpaConfigSection->count() == 0) return 2;
|
||||||
return 2;
|
|
||||||
// file is not set
|
// file is not set
|
||||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||||
if (ui->lineEdit_wpaConfig->text().isEmpty())
|
if (ui->lineEdit_wpaConfig->text().isEmpty()) return 3;
|
||||||
return 3;
|
|
||||||
// file wpa_supplicant doesn't exists
|
// file wpa_supplicant doesn't exists
|
||||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) return 4;
|
||||||
return 4;
|
|
||||||
// essid is not set
|
// essid is not set
|
||||||
if ((ui->comboBox_security->currentText() == QString("none")) ||
|
if ((ui->comboBox_security->currentText() == QString("none")) ||
|
||||||
(ui->comboBox_security->currentText() == QString("wep")) ||
|
(ui->comboBox_security->currentText() == QString("wep")) ||
|
||||||
(ui->comboBox_security->currentText() == QString("wpa")))
|
(ui->comboBox_security->currentText() == QString("wpa")))
|
||||||
if (ui->lineEdit_essid->text().isEmpty())
|
if (ui->lineEdit_essid->text().isEmpty()) return 5;
|
||||||
return 5;
|
|
||||||
// all fine
|
// all fine
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,9 @@ QStringList ControlAdaptor::WiFi()
|
|||||||
QStringList point;
|
QStringList point;
|
||||||
point.append(wifiPoints[i].name);
|
point.append(wifiPoints[i].name);
|
||||||
point.append(wifiPoints[i].security);
|
point.append(wifiPoints[i].security);
|
||||||
point.append(wifiPoints[i].signal);
|
point.append(wifiPoints[i].frequencies.join(QChar(',')));
|
||||||
|
point.append(wifiPoints[i].macs.join(QChar(',')));
|
||||||
|
point.append(QString::number(wifiPoints[i].signal));
|
||||||
point.append(QString::number(wifiPoints[i].active));
|
point.append(QString::number(wifiPoints[i].active));
|
||||||
point.append(QString::number(wifiPoints[i].exists));
|
point.append(QString::number(wifiPoints[i].exists));
|
||||||
info.append(point.join(QChar('|')));
|
info.append(point.join(QChar('|')));
|
||||||
|
@ -118,6 +118,7 @@ QStringList NetctlAdaptor::ProfileList()
|
|||||||
QStringList profileInfo;
|
QStringList profileInfo;
|
||||||
profileInfo.append(profilesInfo[i].name);
|
profileInfo.append(profilesInfo[i].name);
|
||||||
profileInfo.append(profilesInfo[i].description);
|
profileInfo.append(profilesInfo[i].description);
|
||||||
|
profileInfo.append(profilesInfo[i].essid);
|
||||||
profileInfo.append(QString::number(profilesInfo[i].active));
|
profileInfo.append(QString::number(profilesInfo[i].active));
|
||||||
profileInfo.append(QString::number(profilesInfo[i].enabled));
|
profileInfo.append(QString::number(profilesInfo[i].enabled));
|
||||||
info.append(profileInfo.join(QChar('|')));
|
info.append(profileInfo.join(QChar('|')));
|
||||||
@ -146,6 +147,12 @@ QString NetctlAdaptor::ProfileValue(const QString profile, const QString key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList NetctlAdaptor::ProfileValues(const QString profile, const QStringList keys)
|
||||||
|
{
|
||||||
|
return netctlProfile->getValuesFromProfile(profile, keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// wpaCommand
|
// wpaCommand
|
||||||
QString NetctlAdaptor::ProfileByEssid(const QString essid)
|
QString NetctlAdaptor::ProfileByEssid(const QString essid)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +50,7 @@ public slots:
|
|||||||
// netctlProfile
|
// netctlProfile
|
||||||
QStringList Profile(const QString profile);
|
QStringList Profile(const QString profile);
|
||||||
QString ProfileValue(const QString profile, const QString key);
|
QString ProfileValue(const QString profile, const QString key);
|
||||||
|
QStringList ProfileValues(const QString profile, const QStringList keys);
|
||||||
// wpaCommand
|
// wpaCommand
|
||||||
QString ProfileByEssid(const QString essid);
|
QString ProfileByEssid(const QString essid);
|
||||||
QStringList WirelessInterfaces();
|
QStringList WirelessInterfaces();
|
||||||
|
@ -40,6 +40,8 @@ class NetctlProfile;
|
|||||||
* profile name
|
* profile name
|
||||||
* @var netctlProfileInfo::description
|
* @var netctlProfileInfo::description
|
||||||
* profile description
|
* profile description
|
||||||
|
* @var netctlProfileInfo::essid
|
||||||
|
* ESSID if any
|
||||||
* @var netctlProfileInfo::active
|
* @var netctlProfileInfo::active
|
||||||
* whether profile is active
|
* whether profile is active
|
||||||
* @var netctlProfileInfo::enabled
|
* @var netctlProfileInfo::enabled
|
||||||
@ -49,6 +51,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
QString name;
|
QString name;
|
||||||
QString description;
|
QString description;
|
||||||
|
QString essid;
|
||||||
bool active;
|
bool active;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
} netctlProfileInfo;
|
} netctlProfileInfo;
|
||||||
|
@ -85,6 +85,13 @@ public:
|
|||||||
* @return value by key
|
* @return value by key
|
||||||
*/
|
*/
|
||||||
QString getValueFromProfile(const QString profile, const QString key);
|
QString getValueFromProfile(const QString profile, const QString key);
|
||||||
|
/**
|
||||||
|
* @brief method which return values from profile by keys
|
||||||
|
* @param profile profile name
|
||||||
|
* @param keys required keys
|
||||||
|
* @return values by keys
|
||||||
|
*/
|
||||||
|
QStringList getValuesFromProfile(const QString profile, const QStringList keys);
|
||||||
/**
|
/**
|
||||||
* @brief method which removes profile
|
* @brief method which removes profile
|
||||||
* @param profile profile name
|
* @param profile profile name
|
||||||
|
@ -43,6 +43,10 @@ class NetctlProfile;
|
|||||||
* may be "WPA2", "WEP", "WEP", "none"
|
* may be "WPA2", "WEP", "WEP", "none"
|
||||||
* @var netctlWifiInfo::signal
|
* @var netctlWifiInfo::signal
|
||||||
* Wifi point signal
|
* Wifi point signal
|
||||||
|
* @var netctlWifiInfo::macs
|
||||||
|
* point MAC addresses
|
||||||
|
* @var netctlWifiInfo::frequencies
|
||||||
|
* point frequencies
|
||||||
* @var netctlWifiInfo::active
|
* @var netctlWifiInfo::active
|
||||||
* whether associated profile is active
|
* whether associated profile is active
|
||||||
* @var netctlWifiInfo::exists
|
* @var netctlWifiInfo::exists
|
||||||
@ -50,9 +54,11 @@ class NetctlProfile;
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
QStringList frequencies;
|
||||||
|
QStringList macs;
|
||||||
QString name;
|
QString name;
|
||||||
QString security;
|
QString security;
|
||||||
QString signal;
|
int signal;
|
||||||
bool active;
|
bool active;
|
||||||
bool exists;
|
bool exists;
|
||||||
} netctlWifiInfo;
|
} netctlWifiInfo;
|
||||||
|
@ -189,9 +189,16 @@ QList<netctlProfileInfo> Netctl::getProfileList()
|
|||||||
for (int i=0; i<output.count(); i++) {
|
for (int i=0; i<output.count(); i++) {
|
||||||
netctlProfileInfo profileInfo;
|
netctlProfileInfo profileInfo;
|
||||||
profileInfo.name = output[i].mid(2, -1);
|
profileInfo.name = output[i].mid(2, -1);
|
||||||
profileInfo.description = getProfileDescription(profileInfo.name);
|
|
||||||
profileInfo.active = (output[i][0] == QChar('*'));
|
profileInfo.active = (output[i][0] == QChar('*'));
|
||||||
profileInfo.enabled = isProfileEnabled(profileInfo.name);
|
profileInfo.enabled = isProfileEnabled(profileInfo.name);
|
||||||
|
// external
|
||||||
|
QStringList keys;
|
||||||
|
keys.append(QString("Description"));
|
||||||
|
keys.append(QString("ESSID"));
|
||||||
|
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||||
|
keys);
|
||||||
|
profileInfo.description = profileValues[0];
|
||||||
|
profileInfo.essid = profileValues[1];
|
||||||
fullProfilesInfo.append(profileInfo);
|
fullProfilesInfo.append(profileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,9 +219,16 @@ QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
|||||||
for (int i=0; i<output.count(); i++) {
|
for (int i=0; i<output.count(); i++) {
|
||||||
netctlProfileInfo profileInfo;
|
netctlProfileInfo profileInfo;
|
||||||
profileInfo.name = output[i].mid(2, -1);
|
profileInfo.name = output[i].mid(2, -1);
|
||||||
profileInfo.description = getProfileDescription(profileInfo.name);
|
|
||||||
profileInfo.active = (output[i][0] == QChar('*'));
|
profileInfo.active = (output[i][0] == QChar('*'));
|
||||||
profileInfo.enabled = (output[i][0] != QChar('!'));
|
profileInfo.enabled = (output[i][0] != QChar('!'));
|
||||||
|
// external
|
||||||
|
QStringList keys;
|
||||||
|
keys.append(QString("Description"));
|
||||||
|
keys.append(QString("ESSID"));
|
||||||
|
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||||
|
keys);
|
||||||
|
profileInfo.description = profileValues[0];
|
||||||
|
profileInfo.essid = profileValues[1];
|
||||||
fullProfilesInfo.append(profileInfo);
|
fullProfilesInfo.append(profileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn ValueFromProfile
|
* @fn getValueFromProfile
|
||||||
*/
|
*/
|
||||||
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key)
|
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key)
|
||||||
{
|
{
|
||||||
@ -251,6 +251,24 @@ QString NetctlProfile::getValueFromProfile(const QString profile, const QString
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn getValuesFromProfile
|
||||||
|
*/
|
||||||
|
QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QStringList keys)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Keys" << keys;
|
||||||
|
|
||||||
|
QMap<QString, QString> settings = getSettingsFromProfile(profile);
|
||||||
|
QStringList values;
|
||||||
|
for (int i=0; i<keys.count(); i++)
|
||||||
|
values.append(settings[keys[i]]);
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn removeProfile
|
* @fn removeProfile
|
||||||
*/
|
*/
|
||||||
|
@ -264,39 +264,51 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
return scanResults;
|
return scanResults;
|
||||||
}
|
}
|
||||||
if (!wpaCliCall(QString("scan"))) return scanResults;
|
if (!wpaCliCall(QString("scan"))) return scanResults;
|
||||||
waitForProcess(3);
|
waitForProcess(1);
|
||||||
|
|
||||||
QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QChar('\n'), QString::SkipEmptyParts);
|
QStringList rawList = getWpaCliOutput(QString("scan_results")).split(QChar('\n'), QString::SkipEmptyParts);
|
||||||
// remove table header
|
// remove table header
|
||||||
rawOutput.removeFirst();
|
rawList.removeFirst();
|
||||||
// remove duplicates
|
|
||||||
QStringList rawList;
|
|
||||||
QStringList names;
|
QStringList names;
|
||||||
for (int i=0; i<rawOutput.count(); i++) {
|
|
||||||
if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() == 4) {
|
QList<netctlProfileInfo> profiles = netctlCommand->getProfileList();
|
||||||
rawList.append(rawOutput[i]);
|
for (int i=0; i<rawList.count(); i++) {
|
||||||
|
QStringList line = rawList[i].split(QChar('\t'));
|
||||||
|
if (line.count() != 5) continue;
|
||||||
|
QString name = line[4];
|
||||||
|
if (name.isEmpty()) name = QString("<hidden>");
|
||||||
|
// append mac and frequency if exists
|
||||||
|
int index = names.indexOf(name);
|
||||||
|
if ((name != QString("<hidden>")) && (index > -1)) {
|
||||||
|
scanResults[index].frequencies.append(line[1]);
|
||||||
|
scanResults[index].macs.append(line[0]);
|
||||||
|
if (scanResults[index].signal < line[2].toInt())
|
||||||
|
scanResults[index].signal = line[2].toInt();
|
||||||
continue;
|
continue;
|
||||||
} else if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() == 5) {
|
|
||||||
if (names.contains(rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4])) continue;
|
|
||||||
names.append(rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4]);
|
|
||||||
rawList.append(rawOutput[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<rawList.count(); i++) {
|
|
||||||
netctlWifiInfo wifiPoint;
|
|
||||||
// point name
|
// point name
|
||||||
if (rawList[i].split(QChar('\t'), QString::SkipEmptyParts).count() == 5)
|
netctlWifiInfo wifiPoint;
|
||||||
wifiPoint.name = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[4];
|
wifiPoint.name = name;
|
||||||
else
|
|
||||||
wifiPoint.name = QString("<hidden>");
|
|
||||||
// profile status
|
// profile status
|
||||||
wifiPoint.active = isProfileActive(wifiPoint.name);
|
netctlProfileInfo profile;
|
||||||
wifiPoint.exists = isProfileExists(wifiPoint.name);
|
profile.name = QString("");
|
||||||
|
profile.active = false;
|
||||||
|
for (int j=0; j<profiles.count(); j++) {
|
||||||
|
if (wifiPoint.name != profiles[j].essid) continue;
|
||||||
|
profile = profiles[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
wifiPoint.active = profile.active;
|
||||||
|
wifiPoint.exists = (!profile.name.isEmpty());
|
||||||
|
// mac
|
||||||
|
wifiPoint.macs.append(line[0]);
|
||||||
|
// frequencies
|
||||||
|
wifiPoint.frequencies.append(line[1]);
|
||||||
// point signal
|
// point signal
|
||||||
wifiPoint.signal = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2];
|
wifiPoint.signal = line[2].toInt();
|
||||||
// point security
|
// point security
|
||||||
QString security = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[3];
|
QString security = line[3];
|
||||||
if (security.contains(QString("WPA2")))
|
if (security.contains(QString("WPA2")))
|
||||||
security = QString("WPA2");
|
security = QString("WPA2");
|
||||||
else if (security.contains(QString("WPA")))
|
else if (security.contains(QString("WPA")))
|
||||||
@ -306,6 +318,9 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
|||||||
else
|
else
|
||||||
security = QString("none");
|
security = QString("none");
|
||||||
wifiPoint.security = security;
|
wifiPoint.security = security;
|
||||||
|
|
||||||
|
// append
|
||||||
|
names.append(name);
|
||||||
scanResults.append(wifiPoint);
|
scanResults.append(wifiPoint);
|
||||||
}
|
}
|
||||||
stopWpaSupplicant();
|
stopWpaSupplicant();
|
||||||
|
Loading…
Reference in New Issue
Block a user