rewrite gui to use pdebug

This commit is contained in:
arcan1s 2014-08-13 07:12:32 +04:00
parent dba3eeabaa
commit 5c8dca22d0
18 changed files with 315 additions and 253 deletions

View File

@ -1,6 +1,7 @@
Ver.1.3.0
---------
* all:
+ add processes error messages
* some bug fixes and refactoring
* dataengine:
+ add new sources: intIp6, extIp6, netctlAutoStatus
@ -27,6 +28,9 @@ Ver.1.3.0
+ add custom structures netctlWifiInfo and netctlProfileInfo
+ add methods getActiveProfile(), autoGetActiveProfile()
+ add slot switchToProfile()
+ add slot stopAllProfiles()
+ add slot reenableProfile()
+ add double quotes to profile names
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
* rename getInterfaceList() to getWirelessInterfaceList()
- remove functions getProfileDescriptions() and getProfileStatuses()

45
sources/3rdparty/pdebug/pdebug.h vendored Normal file
View File

@ -0,0 +1,45 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef PRETTY_DEBUG_H
#define PRETTY_DEBUG_H
inline const char *pDebug(const std::string prettyFunction)
{
return prettyFunction.c_str();
}
inline std::string pFuncInfo(const std::string prettyFunction)
{
size_t colons = prettyFunction.find("::");
// workaround for functions which are not belong to any class
if (colons == std::string::npos)
colons = prettyFunction.rfind("(");
size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
size_t end = prettyFunction.rfind("(") - begin;
return "[" + prettyFunction.substr(begin, end) + "]";
}
#define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__))
#endif /* PRETTY_DEBUG_H */

View File

@ -10,10 +10,10 @@
<ol>
<li><a href="#description">Description</a></li>
<li><a href="#arch">Architecture</a></li>
<li><a href="#library">Library security</a></li>
<li><a href="#helper">Helper security</a></li>
<li><a href="#gui">Graphical interface security</a></li>
<li><a href="#kde">KDE components security</a></li>
<li><a href="#library">Library</a></li>
<li><a href="#helper">Helper</a></li>
<li><a href="#gui">Graphical interface</a></li>
<li><a href="#kde">KDE components</a></li>
<li><a href="#links">External links</a></li>
</ol>
</head>
@ -25,7 +25,7 @@
<h2><a href="#arch" class="anchor" name="arch"></a>Architecture</h2>
<img src="architecture.png" alt="architecture" align="middle">
<h2><a href="#library" class="anchor" name="library"></a>Library security</h2>
<h2><a href="#library" class="anchor" name="library"></a>Library</h2>
<p>According to <a href="#arch">the scheme<a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
<ul>
<li>Netctl control module</li>
@ -46,17 +46,17 @@
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
<h2><a href="#helper" class="anchor" name="helper"></a>Helper security</h2>
<h2><a href="#helper" class="anchor" name="helper"></a>Helper</h2>
<p>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>netcwork</code> group by default (or must be root). But you may change it by editing <code>$DBUS_SYSTEMCONF_PATH/org.netctlgui.helper.conf</code> policy file (<code>/etc/dbus-1/system.d/org.netctlgui.helper.conf</code> by default). Please refer to DBus documentation to do it.</p>
<p>There are two binaries <code>netctgui-helper</code> and <code>netctlgui-helper-suid</code>. They are the same, but the second one has SUID bit, so it can be running by normal user without any password. Please note that <b>it is dangerous</b> and recommended way is to use systemd daemon. In this case you may not install <code>netctlgui-helper-suid</code> binary.</p>
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
<h2><a href="#gui" class="anchor" name="gui"></a>Graphical interface security</h2>
<h2><a href="#gui" class="anchor" name="gui"></a>Graphical interface</h2>
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
<h2><a href="#kde" class="anchor" name="kde"></a>KDE components security</h2>
<h2><a href="#kde" class="anchor" name="kde"></a>KDE components</h2>
<p>There are two netctl-based commands which are run from the DataEngine</p>
<ul>
<li><code>&lt;cmd&gt; list</code></li>

View File

@ -22,6 +22,7 @@
#include <QDialogButtonBox>
#include <QPushButton>
#include "pdebug.h"
#include "version.h"
@ -38,7 +39,7 @@ AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
AboutWindow::~AboutWindow()
{
if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]";
if (debug) qDebug() << PDEBUG;
delete uiAbout;
delete ui;
@ -47,7 +48,7 @@ AboutWindow::~AboutWindow()
void AboutWindow::createText()
{
if (debug) qDebug() << "[AboutWindow]" << "[createText]";
if (debug) qDebug() << PDEBUG;
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
for (int i=0; i<trdPartyList.count(); i++)
@ -74,7 +75,7 @@ void AboutWindow::createText()
void AboutWindow::createUi()
{
if (debug) qDebug() << "[AboutWindow]" << "[createUi]";
if (debug) qDebug() << PDEBUG;
QWidget *aboutWidget = new QWidget();
uiAbout = new Ui::About;
@ -89,7 +90,7 @@ void AboutWindow::createUi()
// ESC press event
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]";
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Escape)
close();

View File

@ -21,11 +21,13 @@
#include <QDBusMessage>
#include <QDebug>
#include "pdebug.h"
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
const bool debug)
{
if (debug) qDebug() << "[parseOutputNetctl]";
if (debug) qDebug() << PDEBUG;
QList<netctlProfileInfo> profileInfo;
if (raw.size() == 0)
@ -47,7 +49,7 @@ QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
const bool debug)
{
if (debug) qDebug() << "[MainWindow]" << "[parseOutputNetctl]";
if (debug) qDebug() << PDEBUG;
QList<netctlWifiInfo> wifiInfo;
if (raw.size() == 0)
@ -72,13 +74,13 @@ QList<QVariant> sendDBusRequest(const QString service, const QString path,
const QList<QVariant> args, const bool system,
const bool debug)
{
if (debug) qDebug() << "[sendDBusRequest]";
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Service" << service;
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Path" << path;
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Interface" << interface;
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "cmd" << cmd;
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "args" << args;
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "is system bus" << system;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Service" << service;
if (debug) qDebug() << PDEBUG << ":" << "Path" << path;
if (debug) qDebug() << PDEBUG << ":" << "Interface" << interface;
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
QList<QVariant> arguments;
QDBusMessage response;
@ -97,7 +99,7 @@ QList<QVariant> sendDBusRequest(const QString service, const QString path,
}
arguments = response.arguments();
if (arguments.size() == 0)
if (debug) qDebug() << "[sendDBusRequest]" << ":" << "Error message" << response.errorMessage();
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
return arguments;
}

View File

@ -22,6 +22,8 @@
#include <QSpacerItem>
#include <QDebug>
#include "pdebug.h"
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
: debug(debugCmd)
@ -31,15 +33,15 @@ ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
ErrorWindow::~ErrorWindow()
{
if (debug) qDebug() << "[ErrorWindow]" << "[~ErrorWindow]";
if (debug) qDebug() << PDEBUG;
}
QStringList ErrorWindow::getMessage(const int mess, const QString custom)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]";
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess;
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Custom message" << custom;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QString message, title;
switch(mess) {
@ -136,8 +138,8 @@ QStringList ErrorWindow::getMessage(const int mess, const QString custom)
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]";
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]" << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
QMessageBox::Icon icon;
switch(mess) {
@ -173,10 +175,10 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom)
{
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]";
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess;
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender;
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Custom message" << custom;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QStringList message = getMessage(mess, custom);
QMessageBox messageBox;

View File

@ -33,6 +33,7 @@
#include "macvlanwidget.h"
#include "mobilewidget.h"
#include "passwdwidget.h"
#include "pdebug.h"
#include "pppoewidget.h"
#include "tunnelwidget.h"
#include "tuntapwidget.h"
@ -43,7 +44,7 @@
void MainWindow::reportABug()
{
if (debug) qDebug() << "[MainWindow]" << "[reportABug]";
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(BUGTRACKER))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
@ -55,8 +56,8 @@ void MainWindow::reportABug()
// menu update slots
void MainWindow::setMenuActionsShown(const bool state)
{
if (debug) qDebug() << "[MainWindow]" << "[setMenuActionsShown]";
if (debug) qDebug() << "[MainWindow]" << "[setMenuActionsShown]" << ":" << "State" << state;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
// main
ui->actionMainEdit->setVisible(state);
@ -78,7 +79,7 @@ void MainWindow::setMenuActionsShown(const bool state)
void MainWindow::updateMenuMain()
{
if (debug) qDebug() << "[MainWindow]" << "[updateMenuMain]";
if (debug) qDebug() << PDEBUG;
ui->actionMainRefresh->setVisible(true);
if (ui->tableWidget_main->currentItem() == 0) return;
@ -107,7 +108,7 @@ void MainWindow::updateMenuMain()
void MainWindow::updateMenuProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[updateMenuProfile]";
if (debug) qDebug() << PDEBUG;
ui->actionProfileClear->setVisible(true);
if (ui->comboBox_profile->currentText().isEmpty()) {
@ -124,7 +125,7 @@ void MainWindow::updateMenuProfile()
void MainWindow::updateMenuWifi()
{
if (debug) qDebug() << "[MainWindow]" << "[updateMenuWifi]";
if (debug) qDebug() << PDEBUG;
ui->actionWifiRefresh->setVisible(true);
if (ui->tableWidget_wifi->currentItem() == 0) return;
@ -147,9 +148,9 @@ void MainWindow::updateMenuWifi()
// tab update slots
void MainWindow::updateMainTab()
{
if (debug) qDebug() << "[MainWindow]" << "[updateMainTab]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("netctl")))
return errorWin->showWindow(1, QString("[MainWindow] : [updateMainTab]"));
return errorWin->showWindow(1, QString(PDEBUG));
ui->tabWidget->setDisabled(true);
QList<netctlProfileInfo> profiles;
@ -228,7 +229,7 @@ void MainWindow::updateMainTab()
void MainWindow::updateProfileTab()
{
if (debug) qDebug() << "[MainWindow]" << "[updateProfileTab]";
if (debug) qDebug() << PDEBUG;
ui->tabWidget->setDisabled(true);
profileTabClear();
@ -241,10 +242,10 @@ void MainWindow::updateProfileTab()
void MainWindow::updateWifiTab()
{
if (debug) qDebug() << "[MainWindow]" << "[updateWifiTab]";
if (debug) qDebug() << PDEBUG;
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
if (!checkExternalApps(QString("wpasup")))
return errorWin->showWindow(1, QString("[MainWindow] : [updateWifiTab]"));
return errorWin->showWindow(1, QString(PDEBUG));
ui->tabWidget->setDisabled(true);
QList<netctlWifiInfo> scanResults;
@ -322,7 +323,7 @@ void MainWindow::updateWifiTab()
// main tab slots
void MainWindow::mainTabContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget_main->currentItem() == 0)
return;
@ -362,22 +363,22 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
// actions
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
if (action == refreshTable) {
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Refresh table";
if (debug) qDebug() << PDEBUG << ":" << "Refresh table";
updateMainTab();
} else if (action == startProfile) {
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Start profile";
if (debug) qDebug() << PDEBUG << ":" << "Start profile";
mainTabStartProfile();
} else if (action == restartProfile) {
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Restart profile";
if (debug) qDebug() << PDEBUG << ":" << "Restart profile";
mainTabRestartProfile();
} else if (action == enableProfile) {
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Enable profile";
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
mainTabEnableProfile();
} else if (action == editProfile) {
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Edit profile";
if (debug) qDebug() << PDEBUG << ":" << "Edit profile";
mainTabEditProfile();
} else if (action == removeProfile) {
if (debug) qDebug() << "[MainWindow]" << "[mainTabContextualMenu]" << "Remove profile";
if (debug) qDebug() << PDEBUG << ":" << "Remove profile";
mainTabRemoveProfile();
}
}
@ -385,7 +386,7 @@ void MainWindow::mainTabContextualMenu(const QPoint &pos)
void MainWindow::mainTabEditProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[mainTabEditProfile]";
if (debug) qDebug() << PDEBUG;
ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
@ -397,9 +398,9 @@ void MainWindow::mainTabEditProfile()
void MainWindow::mainTabEnableProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("netctl")))
return errorWin->showWindow(1, QString("[MainWindow] : [mainTabEnableProfile]"));
return errorWin->showWindow(1, QString(PDEBUG));
if (ui->tableWidget_main->currentItem() == 0) return;
ui->tabWidget->setDisabled(true);
@ -417,7 +418,7 @@ void MainWindow::mainTabEnableProfile()
void MainWindow::mainTabRemoveProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[mainTabRemoveProfile]";
if (debug) qDebug() << PDEBUG;
ui->tabWidget->setDisabled(true);
// call netctlprofile
@ -442,9 +443,9 @@ void MainWindow::mainTabRemoveProfile()
void MainWindow::mainTabRestartProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("netctl")))
return errorWin->showWindow(1, QString("[MainWindow] : [mainTabRestartProfile]"));
return errorWin->showWindow(1, QString(PDEBUG));
if (ui->tableWidget_main->currentItem() == 0) return;
ui->tabWidget->setDisabled(true);
@ -461,9 +462,9 @@ void MainWindow::mainTabRestartProfile()
void MainWindow::mainTabStartProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("netctl")))
return errorWin->showWindow(1, QString("[MainWindow] : [mainTabStartProfile]"));
return errorWin->showWindow(1, QString(PDEBUG));
if (ui->tableWidget_main->currentItem() == 0) return;
ui->tabWidget->setDisabled(true);
@ -482,9 +483,9 @@ void MainWindow::mainTabStartProfile()
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("netctl")))
return errorWin->showWindow(1, QString("[MainWindow] : [mainTabRefreshButtons]"));
return errorWin->showWindow(1, QString(PDEBUG));
if (current == 0) {
ui->pushButton_mainRestart->setDisabled(true);
ui->pushButton_mainStart->setDisabled(true);
@ -508,8 +509,8 @@ void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetIt
// profile tab slots
void MainWindow::profileTabChangeState(const QString current)
{
if (debug) qDebug() << "[MainWindow]" << "[profileTabChangeState]";
if (debug) qDebug() << "[MainWindow]" << "[profileTabChangeState]" << ":" << "Current type" << current;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Current type" << current;
if (current == QString("ethernet")) {
generalWid->setShown(true);
@ -639,7 +640,7 @@ void MainWindow::profileTabChangeState(const QString current)
void MainWindow::profileTabClear()
{
if (debug) qDebug() << "[MainWindow]" << "[profileTabClear]";
if (debug) qDebug() << PDEBUG;
ui->comboBox_profile->clear();
QList<netctlProfileInfo> profiles;
@ -671,15 +672,15 @@ void MainWindow::profileTabClear()
void MainWindow::profileTabCreateProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
if (debug) qDebug() << PDEBUG;
// error checking
if (ui->comboBox_profile->currentText().isEmpty())
return errorWin->showWindow(3, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(3, QString(PDEBUG));
if (generalWid->isOk() == 1)
return errorWin->showWindow(4, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(4, QString(PDEBUG));
else if (generalWid->isOk() == 2)
return errorWin->showWindow(5, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(5, QString(PDEBUG));
if ((generalWid->connectionType->currentText() == QString("ethernet")) ||
(generalWid->connectionType->currentText() == QString("wireless")) ||
(generalWid->connectionType->currentText() == QString("bond")) ||
@ -691,55 +692,55 @@ void MainWindow::profileTabCreateProfile()
(generalWid->connectionType->currentText() == QString("macvlan")) ||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
if (ipWid->isOk() == 1)
return errorWin->showWindow(6, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(6, QString(PDEBUG));
else if (ipWid->isOk() == 2)
return errorWin->showWindow(6, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(6, QString(PDEBUG));
}
if (generalWid->connectionType->currentText() == QString("ethernet")) {
if (ethernetWid->isOk() == 1)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(7, QString(PDEBUG));
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
if (wirelessWid->isOk() == 1)
return errorWin->showWindow(8, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(8, QString(PDEBUG));
else if (wirelessWid->isOk() == 2)
return errorWin->showWindow(9, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(9, QString(PDEBUG));
else if (wirelessWid->isOk() == 3)
return errorWin->showWindow(10, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(10, QString(PDEBUG));
else if (wirelessWid->isOk() == 4)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(7, QString(PDEBUG));
else if (wirelessWid->isOk() == 5)
return errorWin->showWindow(11, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(11, QString(PDEBUG));
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
if (pppoeWid->isOk() == 1)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(7, QString(PDEBUG));
else if (pppoeWid->isOk() == 2)
return errorWin->showWindow(12, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(12, QString(PDEBUG));
else if (pppoeWid->isOk() == 3)
return errorWin->showWindow(13, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(13, QString(PDEBUG));
else if (pppoeWid->isOk() == 4)
return errorWin->showWindow(12, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(12, QString(PDEBUG));
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
if (mobileWid->isOk() == 1)
return errorWin->showWindow(14, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(14, QString(PDEBUG));
if (mobileWid->isOk() == 2)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(7, QString(PDEBUG));
}
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
}
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
if (tuntapWid->isOk() == 1)
return errorWin->showWindow(15, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(15, QString(PDEBUG));
if (tuntapWid->isOk() == 2)
return errorWin->showWindow(15, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(15, QString(PDEBUG));
}
else if (generalWid->connectionType->currentText() == QString("vlan")) {
if (ethernetWid->isOk() == 1)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(7, QString(PDEBUG));
}
else if (generalWid->connectionType->currentText() == QString("macvlan")) {
if (ethernetWid->isOk() == 1)
return errorWin->showWindow(7, QString("[MainWindow] : [profileTabCreateProfile]"));
return errorWin->showWindow(7, QString(PDEBUG));
}
ui->tabWidget->setDisabled(true);
@ -845,7 +846,7 @@ void MainWindow::profileTabCreateProfile()
void MainWindow::profileTabLoadProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
if (debug) qDebug() << PDEBUG;
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
if (profile.isEmpty())
@ -869,7 +870,7 @@ void MainWindow::profileTabLoadProfile()
if (settings.isEmpty())
return errorWin->showWindow(17, QString("[MainWindow] : [profileTabLoadProfile]"));
return errorWin->showWindow(17, QString(PDEBUG));
generalWid->setSettings(settings);
if (generalWid->connectionType->currentText() == QString("ethernet")) {
@ -909,7 +910,7 @@ void MainWindow::profileTabLoadProfile()
void MainWindow::profileTabRemoveProfile()
{
if (debug) qDebug() << "[MainWindow]" << "[profileTabRemoveProfile]";
if (debug) qDebug() << PDEBUG;
ui->tabWidget->setDisabled(true);
// call netctlprofile
@ -935,7 +936,7 @@ void MainWindow::profileTabRemoveProfile()
// wifi tab slots
void MainWindow::wifiTabContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget_wifi->currentItem() == 0) return;
// create menu
@ -962,10 +963,10 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos)
// actions
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
if (action == refreshTable) {
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]" << "Refresh WiFi";
if (debug) qDebug() << PDEBUG << "Refresh WiFi";
updateWifiTab();
} else if (action == startWifi) {
if (debug) qDebug() << "[MainWindow]" << "[wifiTabContextualMenu]" << "Start WiFi";
if (debug) qDebug() << PDEBUG << "Start WiFi";
wifiTabStart();
}
}
@ -973,8 +974,8 @@ void MainWindow::wifiTabContextualMenu(const QPoint &pos)
void MainWindow::wifiTabSetEnabled(const bool state)
{
if (debug) qDebug() << "[MainWindow]" << "[wifiTabSetEnables]";
if (debug) qDebug() << "[MainWindow]" << "[wifiTabSetEnables]" << ":" << "State" << state;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
if (state) {
ui->tableWidget_wifi->show();
@ -991,9 +992,9 @@ void MainWindow::wifiTabSetEnabled(const bool state)
void MainWindow::wifiTabStart()
{
if (debug) qDebug() << "[MainWindow]" << "[wifiTabStart]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("wpasup")))
return errorWin->showWindow(1, QString("[MainWindow] : [wifiTabStart]"));
return errorWin->showWindow(1, QString(PDEBUG));
if (ui->tableWidget_wifi->currentItem() == 0) return;
ui->tabWidget->setDisabled(true);
@ -1066,9 +1067,9 @@ void MainWindow::wifiTabStart()
void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("wpasup")))
return errorWin->showWindow(1, QString("[MainWindow] : [wifiTabRefreshButtons]"));
return errorWin->showWindow(1, QString(PDEBUG));
if (current == 0) {
ui->pushButton_wifiStart->setDisabled(true);
return;

View File

@ -30,6 +30,7 @@
#include "language.h"
#include "netctlautowindow.h"
#include "passwdwidget.h"
#include "pdebug.h"
#include "settingswindow.h"
#include "taskadds.h"
#include "trayicon.h"
@ -38,7 +39,7 @@
void MainWindow::closeMainWindow()
{
if (debug) qDebug() << "[MainWindow]" << "[closeMainWindow]";
if (debug) qDebug() << PDEBUG;
qApp->quit();
}
@ -46,7 +47,7 @@ void MainWindow::closeMainWindow()
void MainWindow::showAboutWindow()
{
if (debug) qDebug() << "[MainWindow]" << "[showAboutWindow]";
if (debug) qDebug() << PDEBUG;
aboutWin->show();
}
@ -54,7 +55,7 @@ void MainWindow::showAboutWindow()
void MainWindow::showMainWindow()
{
if (debug) qDebug() << "[MainWindow]" << "[showMainWindow]";
if (debug) qDebug() << PDEBUG;
if (isHidden()) {
updateTabs(ui->tabWidget->currentIndex());
@ -66,7 +67,7 @@ void MainWindow::showMainWindow()
void MainWindow::showNetctlAutoWindow()
{
if (debug) qDebug() << "[MainWindow]" << "[showNetctlAutoWindow]";
if (debug) qDebug() << PDEBUG;
netctlAutoWin->showWindow();
}
@ -74,7 +75,7 @@ void MainWindow::showNetctlAutoWindow()
void MainWindow::showSettingsWindow()
{
if (debug) qDebug() << "[MainWindow]" << "[showSettingsWindow]";
if (debug) qDebug() << PDEBUG;
settingsWin->showWindow();
}
@ -82,8 +83,8 @@ void MainWindow::showSettingsWindow()
bool MainWindow::enableProfileSlot(const QString profile)
{
if (debug) qDebug() << "[MainWindow]" << "[enableProfileSlot]";
if (debug) qDebug() << "[MainWindow]" << "[enableProfileSlot]" << ":" << "Profile" << profile;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool current;
if (useHelper) {
@ -106,8 +107,8 @@ bool MainWindow::enableProfileSlot(const QString profile)
bool MainWindow::restartProfileSlot(const QString profile)
{
if (debug) qDebug() << "[MainWindow]" << "[restartProfileSlot]";
if (debug) qDebug() << "[MainWindow]" << "[restartProfileSlot]" << ":" << "Profile" << profile;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool current;
if (useHelper) {
@ -130,8 +131,8 @@ bool MainWindow::restartProfileSlot(const QString profile)
bool MainWindow::startProfileSlot(const QString profile)
{
if (debug) qDebug() << "[MainWindow]" << "[startProfileSlot]";
if (debug) qDebug() << "[MainWindow]" << "[startProfileSlot]" << ":" << "Profile" << profile;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool current;
if (useHelper) {
@ -164,8 +165,8 @@ bool MainWindow::startProfileSlot(const QString profile)
bool MainWindow::switchToProfileSlot(const QString profile)
{
if (debug) qDebug() << "[MainWindow]" << "[switchToProfileSlot]";
if (debug) qDebug() << "[MainWindow]" << "[switchToProfileSlot]" << ":" << "Profile" << profile;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool netctlAutoStatus = false;
if (useHelper)
@ -212,7 +213,7 @@ bool MainWindow::switchToProfileSlot(const QString profile)
void MainWindow::showApi()
{
if (debug) qDebug() << "[MainWindow]" << "[showApi]";
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html"))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
@ -223,7 +224,7 @@ void MainWindow::showApi()
void MainWindow::showLibrary()
{
if (debug) qDebug() << "[MainWindow]" << "[showLibrary]";
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("html/index.html"))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
@ -234,7 +235,7 @@ void MainWindow::showLibrary()
void MainWindow::showSecurityNotes()
{
if (debug) qDebug() << "[MainWindow]" << "[showSecurityNotes]";
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
@ -245,16 +246,16 @@ void MainWindow::showSecurityNotes()
bool MainWindow::forceStartHelper()
{
if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]";
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("helper"))) {
errorWin->showWindow(1, QString("[MainWindow] : [forceStartHelper]"));
errorWin->showWindow(1, QString(PDEBUG));
return false;
}
QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath;
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << cmd;
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false);
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode == 0)
return true;
@ -265,7 +266,7 @@ bool MainWindow::forceStartHelper()
bool MainWindow::forceStopHelper()
{
if (debug) qDebug() << "[MainWindow]" << "[forceStartHelper]";
if (debug) qDebug() << PDEBUG;
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Close"),
@ -277,7 +278,7 @@ bool MainWindow::forceStopHelper()
bool MainWindow::startHelper()
{
if (debug) qDebug() << "[MainWindow]" << "[startHelper]";
if (debug) qDebug() << PDEBUG;
if (isHelperActive())
return forceStopHelper();
@ -288,8 +289,8 @@ bool MainWindow::startHelper()
void MainWindow::setTab(int tab)
{
if (debug) qDebug() << "[MainWindow]" << "[setTab]";
if (debug) qDebug() << "[MainWindow]" << "[setTab]" << ":" << "Update tab" << tab;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
switch (tab) {
case 0:
@ -308,7 +309,7 @@ void MainWindow::setTab(int tab)
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
{
if (debug) qDebug() << "[MainWindow]" << "[updateConfiguration]";
if (debug) qDebug() << PDEBUG;
deleteObjects();
@ -368,7 +369,7 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
void MainWindow::updateMenu()
{
if (debug) qDebug() << "[MainWindow]" << "[updateMenu]";
if (debug) qDebug() << PDEBUG;
int tab = ui->tabWidget->currentIndex();
setMenuActionsShown(false);
@ -384,8 +385,8 @@ void MainWindow::updateMenu()
void MainWindow::updateTabs(const int tab)
{
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]";
if (debug) qDebug() << "[MainWindow]" << "[updateTabs]" << ":" << "Update tab" << tab;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
if (tab == 0)
updateMainTab();
@ -399,7 +400,7 @@ void MainWindow::updateTabs(const int tab)
void MainWindow::connectToUnknownEssid(const QString passwd)
{
if (debug) qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
if (debug) qDebug() << PDEBUG;
if (passwdWid != 0)
delete passwdWid;
@ -470,8 +471,8 @@ void MainWindow::connectToUnknownEssid(const QString passwd)
void MainWindow::setHiddenName(const QString name)
{
if (debug) qDebug() << "[MainWindow]" << "[setHiddenName]";
if (debug) qDebug() << "[MainWindow]" << "[setHiddenName]" << ":" << "Set name" << name;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Set name" << name;
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);

View File

@ -34,6 +34,7 @@
#include "netctlautowindow.h"
#include "netctlguiadaptor.h"
#include "passwdwidget.h"
#include "pdebug.h"
#include "pppoewidget.h"
#include "settingswindow.h"
#include "taskadds.h"
@ -55,18 +56,18 @@ MainWindow::MainWindow(QWidget *parent,
qtTranslator(qtAppTranslator),
translator(appTranslator)
{
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "about" << args[QString("about")].toBool();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "auto" << args[QString("auto")].toBool();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "config" << configPath;
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "debug" << debug;
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "defaults" << args[QString("defaults")].toBool();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "essid" << args[QString("essid")].toString();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "minimized" << args[QString("minimized")].toInt();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "open" << args[QString("open")].toString();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "options" << args[QString("options")].toString();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "select" << args[QString("select")].toString();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "settings" << args[QString("settings")].toBool();
if (debug) qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << "tab" << args[QString("tab")].toInt();
if (debug) qDebug() << PDEBUG << ":" << "about" << args[QString("about")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "auto" << args[QString("auto")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "config" << configPath;
if (debug) qDebug() << PDEBUG << ":" << "debug" << debug;
if (debug) qDebug() << PDEBUG << ":" << "defaults" << args[QString("defaults")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "essid" << args[QString("essid")].toString();
if (debug) qDebug() << PDEBUG << ":" << "minimized" << args[QString("minimized")].toInt();
if (debug) qDebug() << PDEBUG << ":" << "open" << args[QString("open")].toString();
if (debug) qDebug() << PDEBUG << ":" << "options" << args[QString("options")].toString();
if (debug) qDebug() << PDEBUG << ":" << "select" << args[QString("select")].toString();
if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt();
if (args[QString("minimized")].toInt() == 1)
isDaemon = true;
@ -80,7 +81,7 @@ MainWindow::MainWindow(QWidget *parent,
if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString())
ui->tableWidget_wifi->setCurrentCell(i, 0);
if (ui->tableWidget_wifi->currentItem() == 0)
errorWin->showWindow(18, QString("[MainWindow] : [MainWindow]"));
errorWin->showWindow(18, QString(PDEBUG));
} else if (args[QString("open")].toString() != QString("PROFILE")) {
ui->comboBox_profile->addItem(args[QString("open")].toString());
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
@ -89,7 +90,7 @@ MainWindow::MainWindow(QWidget *parent,
if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString())
ui->tableWidget_main->setCurrentCell(i, 0);
if (ui->tableWidget_main->currentItem() == 0)
errorWin->showWindow(17, QString("[MainWindow] : [MainWindow]"));
errorWin->showWindow(17, QString(PDEBUG));
}
// show windows
@ -106,7 +107,7 @@ MainWindow::MainWindow(QWidget *parent,
MainWindow::~MainWindow()
{
if (debug) qDebug() << "[MainWindow]" << "[~MainWindow]";
if (debug) qDebug() << PDEBUG;
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true")))
forceStopHelper();
@ -116,7 +117,7 @@ MainWindow::~MainWindow()
QStringList MainWindow::printInformation()
{
if (debug) qDebug() << "[MainWindow]" << "[printInformation]";
if (debug) qDebug() << PDEBUG;
QString profile;
QString status;
@ -145,7 +146,7 @@ QStringList MainWindow::printInformation()
QStringList MainWindow::printSettings()
{
if (debug) qDebug() << "[MainWindow]" << "[printSettings]";
if (debug) qDebug() << PDEBUG;
QStringList settingsList;
for (int i=0; i<configuration.keys().count(); i++)
@ -158,7 +159,7 @@ QStringList MainWindow::printSettings()
QStringList MainWindow::printTrayInformation()
{
if (debug) qDebug() << "[MainWindow]" << "[printTrayInformation]";
if (debug) qDebug() << PDEBUG;
QStringList information;
QString current;
@ -212,7 +213,7 @@ QStringList MainWindow::printTrayInformation()
bool MainWindow::isHelperActive()
{
if (debug) qDebug() << "[MainWindow]" << "[isHelperActive]";
if (debug) qDebug() << PDEBUG;
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Active"),
@ -224,13 +225,13 @@ bool MainWindow::isHelperActive()
bool MainWindow::isHelperServiceActive()
{
if (debug) qDebug() << "[MainWindow]" << "[isHelperServiceActive]";
if (debug) qDebug() << PDEBUG;
QString cmd = configuration[QString("SYSTEMCTL_PATH")] + QString(" is-active ") +
configuration[QString("HELPER_SERVICE")];
if (debug) qDebug() << "[MainWindow]" << "[isHelperServiceActive]" << ":" << "Run cmd" << cmd;
if (debug) qDebug() << PDEBUG << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false);
if (debug) qDebug() << "[MainWindow]" << "[isHelperServiceActive]" << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
return false;
@ -241,7 +242,7 @@ bool MainWindow::isHelperServiceActive()
void MainWindow::closeEvent(QCloseEvent *event)
{
if (debug) qDebug() << "[MainWindow]" << "[closeEvent]";
if (debug) qDebug() << PDEBUG;
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
(configuration[QString("SYSTRAY")] == QString("true"))) {
@ -254,7 +255,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
{
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]";
if (debug) qDebug() << PDEBUG;
QStringList cmd;
cmd.append("which");
@ -274,9 +275,9 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
cmd.append(configuration[QString("WPASUP_PATH")]);
}
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << cmd.join(QChar(' '));
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd.join(QChar(' '));
TaskResult process = runTask(cmd.join(QChar(' ')), false);
if (debug) qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
return false;
@ -287,7 +288,7 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
bool MainWindow::checkHelperStatus()
{
if (debug) qDebug() << "[MainWindow]" << "[checkHelperStatus]";
if (debug) qDebug() << PDEBUG;
if (useHelper) useHelper = isHelperActive();
if (useHelper)
@ -305,9 +306,9 @@ bool MainWindow::checkHelperStatus()
QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << "[MainWindow]" << "[checkStatus]";
if (debug) qDebug() << "[MainWindow]" << "[checkStatus]" << ":" << "Status" << statusBool;
if (debug) qDebug() << "[MainWindow]" << "[checkStatus]" << ":" << "Return null false" << nullFalse;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool)
return QApplication::translate("MainWindow", "yes");
@ -321,7 +322,7 @@ QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
// window signals
void MainWindow::createActions()
{
if (debug) qDebug() << "[MainWindow]" << "[createActions]";
if (debug) qDebug() << PDEBUG;
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
connect(ui->actionAbout, SIGNAL(triggered(bool)), this, SLOT(showAboutWindow()));
@ -374,25 +375,25 @@ void MainWindow::createActions()
void MainWindow::createDBusSession()
{
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]";
if (debug) qDebug() << PDEBUG;
QDBusConnection bus = QDBusConnection::sessionBus();
if (!bus.registerService(DBUS_SERVICE)) {
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register service";
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << bus.lastError().message();
if (debug) qDebug() << PDEBUG << ":" << "Could not register service";
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
}
if (!bus.registerObject(DBUS_OBJECT_PATH,
new NetctlGuiAdaptor(this),
QDBusConnection::ExportAllContents)) {
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << "Could not register GUI object";
if (debug) qDebug() << "[MainWindow]" << "[createDBusSession]" << ":" << bus.lastError().message();
if (debug) qDebug() << PDEBUG << ":" << "Could not register GUI object";
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
}
}
void MainWindow::createObjects()
{
if (debug) qDebug() << "[MainWindow]" << "[createObjects]";
if (debug) qDebug() << PDEBUG;
// error messages
errorWin = new ErrorWindow(this, debug);
@ -400,7 +401,7 @@ void MainWindow::createObjects()
createDBusSession();
if (useHelper)
if (!forceStartHelper()) {
errorWin->showWindow(19, QString("[MainWindow] : [createObjects]"));
errorWin->showWindow(19, QString(PDEBUG));
useHelper = false;
}
checkHelperStatus();
@ -448,7 +449,7 @@ void MainWindow::createObjects()
void MainWindow::deleteObjects()
{
if (debug) qDebug() << "[MainWindow]" << "[deleteObjects]";
if (debug) qDebug() << PDEBUG;
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
@ -479,7 +480,7 @@ void MainWindow::deleteObjects()
void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[MainWindow]" << "[keyPressEvent]";
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Return)
if (ui->comboBox_profile->hasFocus())
@ -489,7 +490,7 @@ void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
QMap<QString, QString> MainWindow::parseOptions(const QString options)
{
if (debug) qDebug() << "[MainWindow]" << "[parseOptions]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
for (int i=0; i<options.split(QChar(',')).count(); i++) {
@ -498,8 +499,7 @@ QMap<QString, QString> MainWindow::parseOptions(const QString options)
options.split(QChar(','))[i].split(QChar('='))[1];
}
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[MainWindow]" << "[parseOptions]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}

View File

@ -23,6 +23,7 @@
#include <netctlgui/netctlgui.h>
#include "dbusoperation.h"
#include "pdebug.h"
#include "version.h"
@ -47,7 +48,7 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
NetctlAutoWindow::~NetctlAutoWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[~NetctlAutoWindow]";
if (debug) qDebug() << PDEBUG;
delete ui;
delete netctlCommand;
@ -56,9 +57,9 @@ NetctlAutoWindow::~NetctlAutoWindow()
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[checkStatus]";
if (debug) qDebug() << "[NetctlAutoWindow]" << "[checkStatus]" << ":" << "Status" << statusBool;
if (debug) qDebug() << "[NetctlAutoWindow]" << "[checkStatus]" << ":" << "Return null false" << nullFalse;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool)
return QApplication::translate("NetctlAutoWindow", "yes");
@ -71,7 +72,7 @@ QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFals
void NetctlAutoWindow::createActions()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]";
if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
@ -99,7 +100,7 @@ void NetctlAutoWindow::createActions()
void NetctlAutoWindow::showWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
if (debug) qDebug() << PDEBUG;
netctlAutoUpdateTable();
@ -109,7 +110,7 @@ void NetctlAutoWindow::showWindow()
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
@ -143,16 +144,16 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
// actions
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (action == startProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
if (debug) qDebug() << PDEBUG << ":" << "Switch to profile";
netctlAutoStartProfile();
} else if (action == enableProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
netctlAutoEnableProfile();
} else if (action == enableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
if (debug) qDebug() << PDEBUG << ":" << "Enable all profiles";
netctlAutoEnableAllProfiles();
} else if (action == disableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
if (debug) qDebug() << PDEBUG << ":" << "Disable all profiles";
netctlAutoDisableAllProfiles();
}
}
@ -160,7 +161,7 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
void NetctlAutoWindow::netctlAutoUpdateTable()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
// actions
@ -267,7 +268,7 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
bool status = false;
@ -288,7 +289,7 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
void NetctlAutoWindow::netctlAutoEnableProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableProfile]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
@ -314,7 +315,7 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
bool status = false;
@ -335,7 +336,7 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
void NetctlAutoWindow::netctlAutoStartProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartProfile]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
@ -361,7 +362,7 @@ void NetctlAutoWindow::netctlAutoStartProfile()
void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableService]";
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper)
@ -381,7 +382,7 @@ void NetctlAutoWindow::netctlAutoEnableService()
void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRestartService]";
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper)
@ -401,7 +402,7 @@ void NetctlAutoWindow::netctlAutoRestartService()
void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartService]";
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper)
@ -422,7 +423,7 @@ void NetctlAutoWindow::netctlAutoStartService()
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRefreshButtons]";
if (debug) qDebug() << PDEBUG;
if (current == 0) {
// buttons

1
sources/gui/src/pdebug.h Symbolic link
View File

@ -0,0 +1 @@
../../3rdparty/pdebug/pdebug.h

View File

@ -25,6 +25,7 @@
#include "language.h"
#include "mainwindow.h"
#include "pdebug.h"
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
@ -41,7 +42,7 @@ SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QStri
SettingsWindow::~SettingsWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
if (debug) qDebug() << PDEBUG;
delete ui;
}
@ -49,7 +50,7 @@ SettingsWindow::~SettingsWindow()
void SettingsWindow::createActions()
{
if (debug) qDebug() << "[SettingsWindow]" << "[createActions]";
if (debug) qDebug() << PDEBUG;
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
@ -76,7 +77,7 @@ void SettingsWindow::createActions()
// ESC press event
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Escape)
close();
@ -85,7 +86,7 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
void SettingsWindow::addLanguages()
{
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
if (debug) qDebug() << PDEBUG;
ui->comboBox_language->clear();
ui->comboBox_language->addItems(Language::getAvailableLanguages());
@ -95,7 +96,7 @@ void SettingsWindow::addLanguages()
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous)
if (debug) qDebug() << "[SettingsWindow]" << "[changePage]";
if (debug) qDebug() << PDEBUG;
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
if (current == ui->treeWidget->topLevelItem(i)) {
@ -107,7 +108,7 @@ void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previ
void SettingsWindow::closeWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[closeWindow]";
if (debug) qDebug() << PDEBUG;
saveSettings();
close();
@ -117,7 +118,7 @@ void SettingsWindow::closeWindow()
void SettingsWindow::saveSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings = readSettings();
QFile configFile(file);
@ -132,7 +133,7 @@ void SettingsWindow::saveSettings()
void SettingsWindow::setTray()
{
if (debug) qDebug() << "[SettingsWindow]" << "[setTray]";
if (debug) qDebug() << PDEBUG;
if (ui->checkBox_enableTray->checkState() == 0) {
ui->checkBox_closeToTray->setDisabled(true);
@ -146,7 +147,7 @@ void SettingsWindow::setTray()
void SettingsWindow::restoreSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[restoreSettings]";
if (debug) qDebug() << PDEBUG;
setSettings(getSettings());
}
@ -154,7 +155,7 @@ void SettingsWindow::restoreSettings()
void SettingsWindow::setDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
if (debug) qDebug() << PDEBUG;
setSettings(getDefault());
if (sender() != ui->buttonBox->button(QDialogButtonBox::Reset))
@ -164,7 +165,7 @@ void SettingsWindow::setDefault()
void SettingsWindow::selectAbstractSomething()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectAbstractSomething]";
if (debug) qDebug() << PDEBUG;
bool isDir = false;
QString path = QString("/usr/bin");
@ -221,7 +222,7 @@ void SettingsWindow::selectAbstractSomething()
void SettingsWindow::showWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
if (debug) qDebug() << PDEBUG;
setSettings(getSettings());
setTray();
@ -233,7 +234,7 @@ void SettingsWindow::showWindow()
QMap<QString, QString> SettingsWindow::readSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
if (ui->checkBox_helperClose->checkState() == 2)
@ -279,8 +280,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
@ -288,7 +288,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
{
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
if (debug) qDebug() << PDEBUG;
if (settings[QString("CLOSE_HELPER")] == QString("true"))
ui->checkBox_helperClose->setCheckState(Qt::Checked);
@ -336,14 +336,13 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
}
QMap<QString, QString> SettingsWindow::getDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
settings[QString("CLOSE_HELPER")] = QString("false");
@ -371,8 +370,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
@ -380,7 +378,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
QMap<QString, QString> SettingsWindow::getSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings = getDefault();
QFile configFile(file);
@ -398,8 +396,7 @@ QMap<QString, QString> SettingsWindow::getSettings()
}
configFile.close();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
@ -407,7 +404,7 @@ QMap<QString, QString> SettingsWindow::getSettings()
void SettingsWindow::startHelper()
{
if (debug) qDebug() << "[SettingsWindow]" << "[startHelper]";
if (debug) qDebug() << PDEBUG;
((MainWindow *)parent())->startHelper();
updateHelper();
@ -416,7 +413,7 @@ void SettingsWindow::startHelper()
void SettingsWindow::updateHelper()
{
if (debug) qDebug() << "[SettingsWindow]" << "[updateHelper]";
if (debug) qDebug() << PDEBUG;
if (((MainWindow *)parent())->isHelperServiceActive()) {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active (systemd)"));

View File

@ -22,6 +22,7 @@
#include <QMessageBox>
#include "mainwindow.h"
#include "pdebug.h"
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
@ -36,7 +37,7 @@ TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
TrayIcon::~TrayIcon()
{
if (debug) qDebug() << "[TrayIcon]" << "[~TrayIcon]";
if (debug) qDebug() << PDEBUG;
setContextMenu(0);
startProfileMenu->clear();
@ -52,7 +53,7 @@ TrayIcon::~TrayIcon()
int TrayIcon::showInformation()
{
if (debug) qDebug() << "[TrayIcon]" << "[showInformation]";
if (debug) qDebug() << PDEBUG;
if (supportsMessages()) {
QString title = QApplication::translate("TrayIcon", "netctl status");
@ -69,7 +70,7 @@ int TrayIcon::showInformation()
int TrayIcon::showInformationInWindow()
{
if (debug) qDebug() << "[TrayIcon]" << "[showInformationInWindow]";
if (debug) qDebug() << PDEBUG;
QString title = QApplication::translate("TrayIcon", "netctl status");
QStringList info = mainWindow->printInformation();
@ -82,7 +83,7 @@ int TrayIcon::showInformationInWindow()
void TrayIcon::updateMenu()
{
if (debug) qDebug() << "[TrayIcon]" << "[showInformationInWindow]";
if (debug) qDebug() << PDEBUG;
QStringList info = mainWindow->printTrayInformation();
bool netctlAutoStatus = info[0].toInt();
@ -148,7 +149,7 @@ void TrayIcon::updateMenu()
void TrayIcon::createActions()
{
if (debug) qDebug() << "[TrayIcon]" << "[createActions]";
if (debug) qDebug() << PDEBUG;
menuActions = new QMenu();
@ -201,7 +202,7 @@ void TrayIcon::createActions()
void TrayIcon::init()
{
if (debug) qDebug() << "[TrayIcon]" << "[init]";
if (debug) qDebug() << PDEBUG;
setIcon(QIcon(":icon"));
setToolTip(QString("netctl-gui"));
@ -217,8 +218,8 @@ void TrayIcon::init()
void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
{
if (debug) qDebug() << "[TrayIcon]" << "[itemActivated]";
if (debug) qDebug() << "[TrayIcon]" << "[itemActivated]" << ":" << "Reason" << reason;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Reason" << reason;
switch (reason) {
case QSystemTrayIcon::Trigger:
@ -238,7 +239,7 @@ void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
bool TrayIcon::enableProfileSlot()
{
if (debug) qDebug() << "[TrayIcon]" << "[enableProfileSlot]";
if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0];
@ -248,7 +249,7 @@ bool TrayIcon::enableProfileSlot()
bool TrayIcon::restartProfileSlot()
{
if (debug) qDebug() << "[TrayIcon]" << "[restartProfileSlot]";
if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0];
@ -258,7 +259,7 @@ bool TrayIcon::restartProfileSlot()
bool TrayIcon::startProfileSlot(QAction *action)
{
if (debug) qDebug() << "[TrayIcon]" << "[startProfileSlot]";
if (debug) qDebug() << PDEBUG;
QString profile = action->text().remove(QChar('&'));
@ -268,7 +269,7 @@ bool TrayIcon::startProfileSlot(QAction *action)
bool TrayIcon::stopProfileSlot()
{
if (debug) qDebug() << "[TrayIcon]" << "[stopProfileSlot]";
if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0];
@ -278,7 +279,7 @@ bool TrayIcon::stopProfileSlot()
bool TrayIcon::switchToProfileSlot(QAction *action)
{
if (debug) qDebug() << "[TrayIcon]" << "[switchToProfileSlot]";
if (debug) qDebug() << PDEBUG;
QString profile = action->text().remove(QChar('&'));

View File

@ -24,22 +24,23 @@
#include "version.h"
ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const QMap<QString, QString> configuration)
ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const bool debugCmd, const QMap<QString, QString> configuration)
: QDBusAbstractAdaptor(parent),
debug(debugCmd),
helper(parent)
{
netctlCommand = new Netctl(false, configuration);
netctlProfile = new NetctlProfile(false, configuration);
wpaCommand = new WpaSup(false, configuration);
netctlCommand = new Netctl(debug, configuration);
netctlProfile = new NetctlProfile(debug, configuration);
wpaCommand = new WpaSup(debug, configuration);
}
ControlAdaptor::~ControlAdaptor()
{
delete netctlCommand;
delete netctlProfile;
delete wpaCommand;
if (netctlCommand != nullptr) delete netctlCommand;
if (netctlProfile != nullptr) delete netctlProfile;
if (wpaCommand != nullptr) delete wpaCommand;
}

View File

@ -32,6 +32,7 @@ class ControlAdaptor : public QDBusAbstractAdaptor
public:
explicit ControlAdaptor(NetctlHelper *parent = 0,
const bool debugCmd = false,
const QMap<QString, QString> configuration = QMap<QString, QString>());
~ControlAdaptor();
@ -65,10 +66,11 @@ public slots:
QStringList WiFi();
private:
bool debug;
NetctlHelper *helper;
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
Netctl *netctlCommand = nullptr;
NetctlProfile *netctlProfile = nullptr;
WpaSup *wpaCommand = nullptr;
};

View File

@ -18,20 +18,21 @@
#include "netctladaptor.h"
NetctlAdaptor::NetctlAdaptor(QObject *parent, const QMap<QString, QString> configuration)
: QDBusAbstractAdaptor(parent)
NetctlAdaptor::NetctlAdaptor(QObject *parent, const bool debugCmd, const QMap<QString, QString> configuration)
: QDBusAbstractAdaptor(parent),
debug(debugCmd)
{
netctlCommand = new Netctl(false, configuration);
netctlProfile = new NetctlProfile(false, configuration);
wpaCommand = new WpaSup(false, configuration);
netctlCommand = new Netctl(debug, configuration);
netctlProfile = new NetctlProfile(debug, configuration);
wpaCommand = new WpaSup(debug, configuration);
}
NetctlAdaptor::~NetctlAdaptor()
{
delete netctlCommand;
delete netctlProfile;
delete wpaCommand;
if (netctlCommand != nullptr) delete netctlCommand;
if (netctlProfile != nullptr) delete netctlProfile;
if (wpaCommand != nullptr) delete wpaCommand;
}

View File

@ -31,6 +31,7 @@ class NetctlAdaptor : public QDBusAbstractAdaptor
public:
explicit NetctlAdaptor(QObject *parent = 0,
const bool debugCmd = false,
const QMap<QString, QString> configuration = QMap<QString, QString>());
~NetctlAdaptor();
@ -54,9 +55,10 @@ public slots:
QStringList WirelessInterfaces();
private:
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
bool debug;
Netctl *netctlCommand = nullptr;
NetctlProfile *netctlProfile = nullptr;
WpaSup *wpaCommand = nullptr;
};

View File

@ -74,14 +74,14 @@ void NetctlHelper::createInterface()
return quitHelper();
}
if (!bus.registerObject(DBUS_LIB_PATH,
new NetctlAdaptor(this, configuration),
new NetctlAdaptor(this, debug, configuration),
QDBusConnection::ExportAllContents)) {
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << "Could not register library object";
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << bus.lastError().message();
return quitHelper();
}
if (!bus.registerObject(DBUS_CTRL_PATH,
new ControlAdaptor(this, configuration),
new ControlAdaptor(this, debug, configuration),
QDBusConnection::ExportAllContents)) {
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << "Could not register control object";
if (debug) qDebug() << "[NetctlHelper]" << "[createInterface]" << ":" << bus.lastError().message();