mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
Compare commits
29 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a171f6c67 | |||
|
c2e4ea2258 | ||
|
d2714dca02 | ||
|
5efb25dca3 | ||
|
e67493f5c0 | ||
|
32f7b9344c | ||
|
2041e01caa | ||
|
271fdb0d99 | ||
|
45904db741 | ||
|
a216060447 | ||
|
05a613b501 | ||
|
a9c7f98677 | ||
|
5018232c08 | ||
|
aed09bf798 | ||
|
d299e7d9a1 | ||
|
cf7b013726 | ||
|
b65ba2ebe2 | ||
|
69f6a3135b | ||
|
7dc1a5eda3 | ||
|
168a270c98 | ||
|
c3aa3f0c8f | ||
|
e26da85b5f | ||
|
f665a46346 | ||
|
d541d0a755 | ||
|
0f5bf03e38 | ||
|
3695914226 | ||
|
03dbfce482 | ||
|
6a8d2701b0 | ||
|
ff3e000688 |
65
CHANGELOG
65
CHANGELOG
@ -1,3 +1,68 @@
|
||||
Ver.1.4.9
|
||||
---------
|
||||
* library
|
||||
* fix bug with invalid enabled profile definition (#46)
|
||||
* some imrovements inside
|
||||
* plasmoid
|
||||
* change rendering from Qt to native
|
||||
* update plasmoid to recent plasma changes
|
||||
|
||||
Ver.1.4.8
|
||||
---------
|
||||
* gui
|
||||
* update profile tab to netclt 1.10 and 1.11 changes
|
||||
* plasmoid
|
||||
* fix bug with no action on link activation
|
||||
|
||||
Ver.1.4.7
|
||||
---------
|
||||
* all
|
||||
+ implement support of setting of default configuration values while building
|
||||
* fix language component (refer to #45)
|
||||
* gui
|
||||
* more correct work with configuration file
|
||||
* helper
|
||||
* more correct work with configuration file
|
||||
|
||||
Ver.1.4.6
|
||||
---------
|
||||
* all
|
||||
+ implement time logging feature
|
||||
* gui
|
||||
+ implement autoupdate feature
|
||||
- fix invalid profile path for the external editor
|
||||
* library
|
||||
+ implement netctl-auto support to scanWiFi() method (#44)
|
||||
- fix bug with invalid data in netctl-auto profile list output
|
||||
|
||||
Ver.1.4.5
|
||||
---------
|
||||
* plasmoid
|
||||
+ add translation support to plugin part
|
||||
* more correct interface painting
|
||||
* more correct configuration interface painting
|
||||
* move plugin from private
|
||||
|
||||
Ver.1.4.4
|
||||
---------
|
||||
* dataengine
|
||||
- fix profile status definition
|
||||
|
||||
Ver.1.4.3
|
||||
---------
|
||||
* all
|
||||
- fix clang build (#41)
|
||||
- fix WPA_DRIVERS (#40)
|
||||
* library
|
||||
- fix bug in WpaSup class with invalid returning value
|
||||
|
||||
***
|
||||
|
||||
Ver.1.4.2
|
||||
---------
|
||||
* gui
|
||||
* remove Update call to the helper
|
||||
|
||||
Ver.1.4.1
|
||||
---------
|
||||
* all
|
||||
|
@ -3,7 +3,7 @@
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'plasma5-applet-netctl-gui')
|
||||
pkgver=1.4.1
|
||||
pkgver=1.4.9
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||
arch=('i686' 'x86_64')
|
||||
@ -11,8 +11,7 @@ url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('cmake' 'extra-cmake-modules' 'plasma-framework' 'qt5-tools')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('f93be4d72fa63007f39d3b5516ccd3e4')
|
||||
|
||||
md5sums=('64c04c36eea017e7c0ddf687d60de128')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt5}
|
||||
|
@ -1,17 +1,18 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui-qt4
|
||||
_pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.4.1
|
||||
pkgver=1.4.9
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4 GUI for netctl. Also provides a widget for KDE4"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('f93be4d72fa63007f39d3b5516ccd3e4')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${_pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('64c04c36eea017e7c0ddf687d60de128')
|
||||
|
||||
|
||||
prepare() {
|
||||
@ -28,7 +29,7 @@ build() {
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
-DBUILD_KDE4:BOOL=1 \
|
||||
"../${pkgbase}"
|
||||
"../${_pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
@ -38,7 +39,7 @@ build() {
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
"../${_pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
@ -64,7 +65,6 @@ package_libnetctlgui-qt4() {
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui')
|
||||
conflicts=('libnetctlgui')
|
||||
install=""
|
||||
|
||||
cd "${srcdir}/build-qt4/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
|
@ -8,7 +8,7 @@ VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
ARCHIVE="netctl-gui"
|
||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||
IGNORELIST="build *.qm *.cppcheck .git* .kdev4 sources.kdev4"
|
||||
IGNORELIST="build *.qm *.cppcheck .git* *.kdev4"
|
||||
# update submodules
|
||||
git submodule update --init --recursive
|
||||
# create archive
|
||||
@ -16,7 +16,7 @@ git submodule update --init --recursive
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}" "${ARCHIVE}"
|
||||
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
||||
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf {} \;; done
|
||||
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -delete; done
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
||||
rm -rf "${ARCHIVE}"
|
||||
@ -26,5 +26,5 @@ MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD{,-qt4}
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD{,-qt4}
|
||||
# clear
|
||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -exec rm -rf {} \;
|
||||
find arch -type l -xtype l -exec rm -rf {} \;
|
||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -delete
|
||||
find arch -type l -xtype l -delete
|
||||
|
23
sources/.kdev4/netctl-gui.kdev4
Normal file
23
sources/.kdev4/netctl-gui.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x14\x00n\x00e\x00t\x00c\x00t\x00l\x00-\x00g\x00u\x00i)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
||||
Build Type=Release
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
2
sources/3rdparty/language
vendored
2
sources/3rdparty/language
vendored
@ -1 +1 @@
|
||||
Subproject commit 204943574a95d5825fd7190608bfe6d76abf6da3
|
||||
Subproject commit 319125b1fafff9da14c89a94de6ba2852c90c9c2
|
2
sources/3rdparty/language-config.h
vendored
2
sources/3rdparty/language-config.h
vendored
@ -7,6 +7,8 @@
|
||||
#define LANGUAGES "en,ja,ru"
|
||||
// language key in the configuration file
|
||||
#define LANGUAGE_KEY "LANGUAGE"
|
||||
// name of config section in the file if any
|
||||
#define LANGUAGE_SECTION "Common"
|
||||
|
||||
|
||||
#endif /* LANGUAGE_CONFIG_H */
|
||||
|
2
sources/3rdparty/pdebug
vendored
2
sources/3rdparty/pdebug
vendored
@ -1 +1 @@
|
||||
Subproject commit 9c63e102b05e11ead690489ca470c8482b6335b1
|
||||
Subproject commit 75e4a0df83478802bba53345486b42c56713fe09
|
2
sources/3rdparty/task
vendored
2
sources/3rdparty/task
vendored
@ -1 +1 @@
|
||||
Subproject commit d2798204a1a84a23a9510aeda73d5b9b75d2c8eb
|
||||
Subproject commit dd52af08c9d6a2c8652d2d5e21bc2a433efb497a
|
@ -11,7 +11,7 @@ set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 4)
|
||||
set (PROJECT_VERSION_PATCH 1)
|
||||
set (PROJECT_VERSION_PATCH 9)
|
||||
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_YEAR "%Y")
|
||||
@ -23,6 +23,8 @@ message (STATUS "Build date: ${CURRENT_DATE}")
|
||||
# install options
|
||||
option (USE_CAPABILITIES "Use setcap to set capabilities for the helper" ON)
|
||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||
# configuration
|
||||
include (config-defs.cmake)
|
||||
# components
|
||||
option (BUILD_GUI "Build GUI" ON)
|
||||
option (BUILD_HELPER "Build helper" ON)
|
||||
@ -51,12 +53,20 @@ set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus sys
|
||||
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# avoid newer gcc warnings
|
||||
add_definitions (-D_DEFAULT_SOURCE)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# linker flags
|
||||
set (CMAKE_EXE_LINKER_FLAGS "-lc++abi")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "-lc++abi")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-lc++abi")
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
|
41
sources/config-defs.cmake
Normal file
41
sources/config-defs.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
# default configuration options
|
||||
|
||||
# [Common] section
|
||||
set (CFG_LANGUAGE "en" CACHE STRING "LANGUAGE key")
|
||||
set (CFG_MAINUPDATE "0" CACHE STRING "MAINUPDATE key")
|
||||
set (CFG_WIFIUPDATE "0" CACHE STRING "WIFIUPDATE key")
|
||||
set (CFG_SYSTRAY "true" CACHE STRING "SYSTRAY key")
|
||||
set (CFG_CLOSETOTRAY "true" CACHE STRING "CLOSETOTRAY key")
|
||||
set (CFG_STARTTOTRAY "false" CACHE STRING "STARTTOTRAY key")
|
||||
set (CFG_SKIPCOMPONENTS "false" CACHE STRING "SKIPCOMPONENTS key")
|
||||
|
||||
# [Helper] section
|
||||
set (CFG_USE_HELPER "true" CACHE STRING "USE_HELPER key")
|
||||
set (CFG_FORCE_SUDO "false" CACHE STRING "FORCE_SUDO key")
|
||||
set (CFG_CLOSE_HELPER "false" CACHE STRING "CLOSE_HELPER key")
|
||||
set (CFG_HELPER_PATH "netctlgui-helper" CACHE STRING "HELPER_PATH key")
|
||||
set (CFG_HELPER_SERVICE "netctlgui-helper.service" CACHE STRING "HELPER_SERVICE key")
|
||||
|
||||
# [netctl] section
|
||||
set (CFG_SYSTEMCTL_PATH "systemctl" CACHE STRING "SYSTEMCTL_PATH key")
|
||||
set (CFG_NETCTL_PATH "netctl" CACHE STRING "NETCTL_PATH key")
|
||||
set (CFG_NETCTLAUTO_PATH "netctl-auto" CACHE STRING "NETCTLAUTO_PATH key")
|
||||
set (CFG_NETCTLAUTO_SERVICE "netctl-auto" CACHE STRING "NETCTLAUTO_SERVICE key")
|
||||
set (CFG_PROFILE_DIR "/etc/netctl/" CACHE STRING "PROFILE_DIR key")
|
||||
|
||||
# [sudo] section
|
||||
set (CFG_SUDO_PATH "kdesu" CACHE STRING "SUDO_PATH key")
|
||||
|
||||
# [wpa_supplicant] section
|
||||
set (CFG_WPASUP_PATH "wpa_supplicant" CACHE STRING "WPASUP_PATH key")
|
||||
set (CFG_WPACLI_PATH "wpa_cli" CACHE STRING "WPACLI_PATH key")
|
||||
set (CFG_PID_FILE "/run/wpa_supplicant_$i.pid" CACHE STRING "PID_FILE key")
|
||||
set (CFG_WPA_DRIVERS "nl80211,wext" CACHE STRING "WPA_DRIVERS key")
|
||||
set (CFG_CTRL_DIR "/run/wpa_supplicant" CACHE STRING "CTRL_DIR key")
|
||||
set (CFG_CTRL_GROUP "users" CACHE STRING "CTRL_GROUP key")
|
||||
|
||||
# [Other] section
|
||||
set (CFG_EDITOR_PATH "gvim" CACHE STRING "EDITOR_PATH key")
|
||||
set (CFG_IFACE_DIR "/sys/class/net/" CACHE STRING "IFACE_DIR key")
|
||||
set (CFG_RFKILL_DIR "/sys/class/rfkill/" CACHE STRING "RFKILL_DIR key")
|
||||
set (CFG_PREFERED_IFACE "" CACHE STRING "PREFERED_IFACE key")
|
@ -39,7 +39,12 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
if (BUILD_KDE4)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
else ()
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
|
||||
endif ()
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <KStandardDirs>
|
||||
#else
|
||||
#include <QStandardPaths>
|
||||
#include <pdebug/pdebug-time.h>
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
|
||||
@ -44,6 +45,9 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
qInstallMessageHandler(debugString);
|
||||
#endif /* QT_VERSION >= 0x050000 */
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
@ -82,17 +86,16 @@ QStringList Netctl::sources() const
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getCmdOutput(const QString cmd)
|
||||
QString Netctl::getCmdOutput(const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
return QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
}
|
||||
|
||||
|
||||
@ -110,15 +113,15 @@ void Netctl::readConfiguration()
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl")).toString();
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto")).toString();
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("netctl"));
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("netctl-auto"));
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("External IP"));
|
||||
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false")).toString();
|
||||
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com")).toString();
|
||||
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false")).toString();
|
||||
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com")).toString();
|
||||
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false"));
|
||||
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com"));
|
||||
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false"));
|
||||
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com"));
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
@ -132,46 +135,43 @@ bool Netctl::sourceRequestEvent(const QString &name)
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getExtIp(const QString cmd)
|
||||
QString Netctl::getExtIp(const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
// test network connection
|
||||
if (!isNetworkActive()) return QString("N\\A");
|
||||
|
||||
return getCmdOutput(cmd).trimmed();
|
||||
return getCmdOutput(cmd);
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getInfo(const QStringList profiles, const QStringList statuses)
|
||||
QString Netctl::getInfo(const QStringList profiles, const QStringList statuses) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (profiles.count() != statuses.count()) return QString("N\\A");
|
||||
|
||||
QStringList list;
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
list.append(QString("%1 (%2)").arg(profiles[i]).arg(statuses[i]));
|
||||
list.append(QString("%1 (%2)").arg(profiles.at(i)).arg(statuses.at(i)));
|
||||
if (list.isEmpty()) list.append(QString("N\\A"));
|
||||
|
||||
return list.join(QString(" | "));
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getInterfaceList()
|
||||
QStringList Netctl::getInterfaceList() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
||||
QStringList interfacesList;
|
||||
for (int i=0; i<rawList.count(); i++)
|
||||
interfacesList.append(rawList[i].name());
|
||||
foreach(QNetworkInterface interface, rawList)
|
||||
interfacesList.append(interface.name());
|
||||
|
||||
return interfacesList;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -181,11 +181,11 @@ QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
else if (protocol == QAbstractSocket::IPv6Protocol)
|
||||
intIp = QString("::1/128");
|
||||
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||
if (rawList[i].protocol() != protocol) continue;
|
||||
intIp = rawList[i].toString();
|
||||
foreach(QHostAddress address, rawList) {
|
||||
if (address == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||
if (address == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||
if (address.protocol() != protocol) continue;
|
||||
intIp = address.toString();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -197,26 +197,24 @@ QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNet
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoStatus = true;
|
||||
QString output = getCmdOutput(QString("%1 list").arg(cmdNetctlAuto));
|
||||
if (output.isEmpty()) {
|
||||
output = getCmdOutput(QString("%1 list").arg(cmdNetctl));
|
||||
netctlAutoStatus = false;
|
||||
}
|
||||
qDebug() << output;
|
||||
} else
|
||||
netctlAutoStatus = true;
|
||||
|
||||
// parse
|
||||
QStringList currentProfiles;
|
||||
QStringList profileList = output.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
// workaround for first element spaces on which are trimmed
|
||||
QStringList profileList = QString(" %1").arg(output).split(QChar('\n'));
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (profileList[i][0] != QChar('*')) continue;
|
||||
currentProfiles.append(profileList[i]);
|
||||
}
|
||||
// remove first symbols
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
bool isActive = (profileList.at(i)[0] == QChar('*'));
|
||||
profileList[i].remove(0, 2);
|
||||
for (int i=0; i<currentProfiles.count(); i++)
|
||||
currentProfiles[i].remove(0, 2);
|
||||
if (isActive) currentProfiles.append(profileList.at(i));
|
||||
}
|
||||
profileList.sort();
|
||||
currentProfiles.sort();
|
||||
|
||||
// return profiles
|
||||
currentProfile = currentProfiles;
|
||||
@ -225,7 +223,7 @@ QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNet
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl)
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -235,14 +233,11 @@ QStringList Netctl::getProfileStringStatus(const QString cmdNetctl)
|
||||
return status;
|
||||
}
|
||||
|
||||
for (int i=0; i<currentProfile.count(); i++) {
|
||||
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(currentProfile[i]));
|
||||
foreach(QString profile, currentProfile) {
|
||||
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(profile));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
status.append(QString("static"));
|
||||
} else
|
||||
status.append(QString("enabled"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
status.append(process.exitCode == 0 ? QString("enabled") : QString("static"));
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -254,21 +249,8 @@ void Netctl::initSources()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList sourcesList = sources();
|
||||
for (int i=0; i<sourcesList.count(); i++)
|
||||
setData(sourcesList[i], QString("value"), QString("N\\A"));
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isNetworkActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("ping -c 1 google.com");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
foreach(QString source, sourcesList)
|
||||
setData(source, QString("value"), QString("N\\A"));
|
||||
}
|
||||
|
||||
|
||||
@ -283,11 +265,11 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
} else if (source == QString("current")) {
|
||||
value = currentProfile.join(QChar('|'));
|
||||
} else if (source == QString("extip4")) {
|
||||
if (configuration[QString("EXTIP4")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
||||
if (configuration[QString("EXTIP4")].toString() == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")].toString());
|
||||
} else if (source == QString("extip6")) {
|
||||
if (configuration[QString("EXTIP6")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
||||
if (configuration[QString("EXTIP6")].toString() == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")].toString());
|
||||
} else if (source == QString("info")) {
|
||||
value = getInfo(currentProfile, currentStatus);
|
||||
} else if (source == QString("interfaces")) {
|
||||
@ -299,10 +281,10 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
} else if (source == QString("netctlauto")) {
|
||||
value = netctlAutoStatus ? QString("true") : QString("false");
|
||||
} else if (source == QString("profiles")) {
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")].toString(),
|
||||
configuration[QString("NETCTLAUTOCMD")].toString()).join(QChar(','));
|
||||
} else if (source == QString("status")) {
|
||||
currentStatus = getProfileStringStatus(configuration[QString("NETCTLCMD")]);
|
||||
currentStatus = getProfileStringStatus(configuration[QString("NETCTLCMD")].toString());
|
||||
value = currentStatus.join(QChar('|'));
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
|
@ -27,15 +27,14 @@ class Netctl : public Plasma::DataEngine
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Netctl(QObject *parent, const QVariantList &args);
|
||||
~Netctl();
|
||||
QString getExtIp(const QString cmd);
|
||||
QString getInfo(const QStringList profiles, const QStringList statuses);
|
||||
QStringList getInterfaceList();
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||
explicit Netctl(QObject *parent, const QVariantList &args);
|
||||
virtual ~Netctl();
|
||||
QString getExtIp(const QString cmd) const;
|
||||
QString getInfo(const QStringList profiles, const QStringList statuses) const;
|
||||
QStringList getInterfaceList() const;
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const;
|
||||
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl);
|
||||
bool isNetworkActive();
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl) const;
|
||||
|
||||
public slots:
|
||||
void initSources();
|
||||
@ -46,14 +45,15 @@ protected:
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
bool isNetctlCheckRunning = false;
|
||||
bool netctlAutoStatus = false;
|
||||
bool status = false;
|
||||
QStringList currentProfile;
|
||||
QStringList currentStatus;
|
||||
// configuration
|
||||
bool debug;
|
||||
QMap<QString, QString> configuration;
|
||||
QString getCmdOutput(const QString cmd);
|
||||
QVariantMap configuration;
|
||||
QString getCmdOutput(const QString cmd) const;
|
||||
void readConfiguration();
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Netctl commands]
|
||||
NETCTLCMD=/usr/bin/netctl
|
||||
NETCTLAUTOCMD=/usr/bin/netctl-auto
|
||||
NETCTLCMD=netctl
|
||||
NETCTLAUTOCMD=netctl-auto
|
||||
|
||||
[External IP]
|
||||
EXTIP4CMD=curl ip4.telize.com
|
||||
|
@ -14,7 +14,7 @@ X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=netctl
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui/
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/netctl-gui/
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
|
@ -290,12 +290,12 @@ small {
|
||||
</tr>
|
||||
<!-- general information -->
|
||||
<tr>
|
||||
<td>QString ActiveProfile()</td>
|
||||
<td>QStringList ActiveProfile()</td>
|
||||
<td>returns active profile from netctl or netctl-auto</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ActiveProfileStatus()</td>
|
||||
<td>QStringList ActiveProfileStatus()</td>
|
||||
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
@ -305,7 +305,7 @@ small {
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString netctlActiveProfile()</td>
|
||||
<td>QStringList netctlActiveProfile()</td>
|
||||
<td>returns active profile from netctl even if netctl-auto is running</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
@ -464,7 +464,7 @@ small {
|
||||
|
||||
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
|
||||
<ul>
|
||||
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://arcanis.me/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
@ -98,7 +98,7 @@ env -i bash -c "source '<profile>'; for i in ${!<key>[@]}; do ec
|
||||
|
||||
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
|
||||
<ul>
|
||||
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://arcanis.me/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
@ -1,7 +1,14 @@
|
||||
# set files
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
if (USE_QT5)
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
|
||||
else ()
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
endif ()
|
||||
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.h)
|
||||
file (GLOB_RECURSE FORMS *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
|
||||
|
69
sources/gui/src/bondwidget.cpp
Normal file
69
sources/gui/src/bondwidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/***************************************************************************
|
||||
* 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/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "bondwidget.h"
|
||||
#include "ui_bondwidget.h"
|
||||
|
||||
|
||||
BondWidget::BondWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::BondWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
BondWidget::~BondWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void BondWidget::clear()
|
||||
{
|
||||
ui->lineEdit_mode->setText(QString("balance-rr"));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> BondWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->lineEdit_mode->text() != QString("balance-rr"))
|
||||
settings[QString("Mode")] = ui->lineEdit_mode->text();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int BondWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void BondWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("Mode")))
|
||||
ui->lineEdit_mode->setText(settings[QString("Mode")]);
|
||||
}
|
47
sources/gui/src/bondwidget.h
Normal file
47
sources/gui/src/bondwidget.h
Normal file
@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* 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 BONDWIDGET_H
|
||||
#define BONDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class BondWidget;
|
||||
}
|
||||
|
||||
class BondWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BondWidget(QWidget *parent = 0);
|
||||
~BondWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
Ui::BondWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif /* BONDWIDGET_H */
|
71
sources/gui/src/bondwidget.ui
Normal file
71
sources/gui/src/bondwidget.ui
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BondWidget</class>
|
||||
<widget class="QWidget" name="BondWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>46</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_bond">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Bond settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_bond">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The bonding policy. See the kernel documentation on bonding for details</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -177,7 +177,7 @@ InterfaceAnswer connectToEssid(const QString essid, QMap<QString,QString> settin
|
||||
}
|
||||
|
||||
|
||||
netctlInformation generalInformation(NetctlInterface* interface, const bool useHelper,
|
||||
netctlInformation generalInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -204,7 +204,7 @@ netctlInformation generalInformation(NetctlInterface* interface, const bool useH
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> profileInformation(const QString profile, NetctlInterface* interface,
|
||||
QMap<QString, QString> profileInformation(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (!useHelper) return interface->profileSettings(profile);
|
||||
|
@ -124,6 +124,10 @@ QStringList ErrorWindow::getMessage(const int mess)
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "IP address does not match the standard");
|
||||
break;
|
||||
case 21:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Key is required for 'gre' mode");
|
||||
break;
|
||||
default:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
@ -164,6 +168,7 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
case 18:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
default:
|
||||
|
@ -46,6 +46,7 @@ void EthernetWidget::clear()
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
ui->lineEdit_wpaConfig->clear();
|
||||
ui->comboBox_driver->setCurrentIndex(0);
|
||||
ui->spinBox_priority->setValue(1);
|
||||
ui->spinBox_timeoutCarrier->setValue(5);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
|
||||
@ -104,6 +105,8 @@ QMap<QString, QString> EthernetWidget::getSettings()
|
||||
settings[QString("WPAConfigFile")] = QString("'%1'").arg(ui->lineEdit_wpaConfig->text());
|
||||
settings[QString("WPADriver")] = ui->comboBox_driver->currentText();
|
||||
}
|
||||
if (ui->spinBox_priority->value() != 1)
|
||||
settings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
|
||||
if (ui->spinBox_timeoutCarrier->value() != 5)
|
||||
settings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
|
||||
if (ui->spinBox_timeoutWpa->value() != 15)
|
||||
@ -139,6 +142,8 @@ void EthernetWidget::setSettings(const QMap<QString, QString> settings)
|
||||
int index = ui->comboBox_driver->findText(settings[QString("WPADriver")]);
|
||||
ui->comboBox_driver->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("Priority")))
|
||||
ui->spinBox_priority->setValue(settings[QString("Priority")].toInt());
|
||||
if (settings.contains(QString("TimeoutCarrier")))
|
||||
ui->spinBox_timeoutCarrier->setValue(settings[QString("TimeoutCarrier")].toInt());
|
||||
if (settings.contains(QString("TimeoutWPA")))
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>227</height>
|
||||
<height>255</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -301,6 +301,45 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_priority">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_priority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Priority</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_priority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Priority level of the profile. In case of automatic profile selection, profiles are tried in decreasing order of priority</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -59,6 +59,7 @@ void GeneralWidget::clear()
|
||||
ui->listWidget_after->clear();
|
||||
ui->lineEdit_execUpPost->clear();
|
||||
ui->lineEdit_execDownPre->clear();
|
||||
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_debug->setCheckState(Qt::Unchecked);
|
||||
|
||||
@ -139,6 +140,8 @@ QMap<QString, QString> GeneralWidget::getSettings()
|
||||
settings[QString("ExecUpPost")] = QString("'%1'").arg(ui->lineEdit_execUpPost->text());
|
||||
if (!ui->lineEdit_execDownPre->text().isEmpty())
|
||||
settings[QString("ExecDownPre")] = QString("'%1'").arg(ui->lineEdit_execDownPre->text());
|
||||
if (ui->checkBox_exclude->checkState() == Qt::Checked)
|
||||
settings[QString("ExcludeAuto")] = QString("yes");
|
||||
if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
|
||||
settings[QString("ForceConnect")] = QString("yes");
|
||||
if (ui->checkBox_debug->checkState() == Qt::Checked)
|
||||
@ -186,6 +189,9 @@ void GeneralWidget::setSettings(const QMap<QString, QString> settings)
|
||||
ui->lineEdit_execUpPost->setText(settings[QString("ExecUpPost")]);
|
||||
if (settings.contains(QString("ExecDownPre")))
|
||||
ui->lineEdit_execDownPre->setText(settings[QString("ExecDownPre")]);
|
||||
if (settings.contains(QString("ExcludeAuto")))
|
||||
if (settings[QString("ExcludeAuto")] == QString("yes"))
|
||||
ui->checkBox_exclude->setCheckState(Qt::Checked);
|
||||
if (settings.contains(QString("ForceConnect")))
|
||||
if (settings[QString("ForceConnect")] == QString("yes"))
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>452</height>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
@ -417,6 +417,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_exclude">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_exclude">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_exclude">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Whether or not to exclude this profile from automatic profile selection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exclude auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_forceConnect">
|
||||
<item>
|
||||
|
@ -32,6 +32,10 @@
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <pdebug/pdebug-time.h>
|
||||
#endif /* QT_VERSION >= 0x050000 */
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -62,7 +66,7 @@ unsigned int getUidFromSession(const int type = 0)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QMap<QString, QVariant> args = getArgs();
|
||||
QVariantMap args = getArgs();
|
||||
// reading
|
||||
for (int i=1; i<argc; i++) {
|
||||
if (QString(argv[i]) == QString("--detached")) {
|
||||
@ -157,6 +161,9 @@ int main(int argc, char *argv[])
|
||||
// detach from console
|
||||
if (args[QString("detached")].toBool())
|
||||
daemon(0, 0);
|
||||
#if QT_VERSION >= 0x050000
|
||||
qInstallMessageHandler(debugString);
|
||||
#endif
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
// reread translations according to flags
|
||||
|
@ -52,6 +52,10 @@ MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, c
|
||||
actionMenu->addAction(ui->actionEnable);
|
||||
ui->actionStart->setMenu(actionMenu);
|
||||
|
||||
// auto update
|
||||
timer.setSingleShot(true);
|
||||
timer.setInterval(configuration[QString("MAINUPDATE")].toInt() * 1000);
|
||||
|
||||
createActions();
|
||||
}
|
||||
|
||||
@ -90,8 +94,12 @@ void MainWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
updateMainTab();
|
||||
updateMenuMain();
|
||||
if (mainWindow->currentTab() == 0) {
|
||||
updateMainTab();
|
||||
updateMenuMain();
|
||||
}
|
||||
|
||||
if (timer.interval() != 0) return timer.start();
|
||||
}
|
||||
|
||||
|
||||
@ -411,6 +419,7 @@ void MainWidget::createActions()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(&timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
|
||||
connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QTimer>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
@ -68,6 +69,7 @@ private:
|
||||
void createActions();
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
QTimer timer;
|
||||
bool useHelper = true;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
|
@ -51,10 +51,8 @@
|
||||
#include "wifimenuwidget.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent,
|
||||
const QMap<QString, QVariant> args,
|
||||
QTranslator *qtAppTranslator,
|
||||
QTranslator *appTranslator)
|
||||
MainWindow::MainWindow(QWidget *parent, const QVariantMap args,
|
||||
QTranslator *qtAppTranslator, QTranslator *appTranslator)
|
||||
: QMainWindow(parent),
|
||||
configPath(args[QString("config")].toString()),
|
||||
debug(args[QString("debug")].toBool()),
|
||||
@ -106,13 +104,21 @@ MainWindow::~MainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true")))
|
||||
if (configuration[QString("CLOSE_HELPER")] == QString("true"))
|
||||
forceStopHelper();
|
||||
deleteObjects();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
int MainWindow::currentTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return ui->stackedWidget->currentIndex();
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea MainWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
@ -369,13 +375,14 @@ void MainWindow::storeToolBars()
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
void MainWindow::updateConfiguration(const QVariantMap args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
deleteObjects();
|
||||
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
QString actualConfigPath = QFile(configPath).exists() ? configPath : QString("/etc/netctl-gui.conf");
|
||||
settingsWin = new SettingsWindow(this, debug, actualConfigPath);
|
||||
if (args[QString("default")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
@ -383,17 +390,12 @@ void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||
if ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||
(checkExternalApps(QString("helper"), configuration, debug)))
|
||||
useHelper = true;
|
||||
else {
|
||||
useHelper = false;
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
useHelper = ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||
(checkExternalApps(QString("helper"), configuration, debug)));
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
QString language = Language::defineLanguage(configPath, args[QString("options")].toString());
|
||||
QString language = Language::defineLanguage(actualConfigPath, args[QString("options")].toString());
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Language is" << language;
|
||||
qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qApp->installTranslator(qtTranslator);
|
||||
@ -462,9 +464,8 @@ bool MainWindow::checkHelperStatus()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper) useHelper = isHelperActive();
|
||||
if (useHelper)
|
||||
sendRequestToCtrl(QString("Update"), debug);
|
||||
else {
|
||||
if (!useHelper) {
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
configuration[QString("FORCE_SUDO")] = QString("true");
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
|
@ -42,11 +42,12 @@ class MainWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||
QTranslator *qtAppTranslator = 0,
|
||||
QTranslator *appTranslator = 0);
|
||||
explicit MainWindow(QWidget *parent = nullptr,
|
||||
const QVariantMap args = QVariantMap(),
|
||||
QTranslator *qtAppTranslator = nullptr,
|
||||
QTranslator *appTranslator = nullptr);
|
||||
~MainWindow();
|
||||
int currentTab();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
void emitNeedToBeConfigured();
|
||||
QStringList printSettings();
|
||||
@ -82,7 +83,7 @@ public slots:
|
||||
void setTab(int tab);
|
||||
void showMessage(const bool status);
|
||||
void storeToolBars();
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateConfiguration(const QVariantMap args = QVariantMap());
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
signals:
|
||||
|
@ -29,9 +29,9 @@ QString errorMessage()
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> getArgs()
|
||||
QVariantMap getArgs()
|
||||
{
|
||||
QMap<QString, QVariant> args;
|
||||
QVariantMap args;
|
||||
// windows
|
||||
args[QString("detached")] = false;
|
||||
args[QString("minimized")] = static_cast<int>(0);
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
QString errorMessage();
|
||||
QMap<QString, QVariant> getArgs();
|
||||
QVariantMap getArgs();
|
||||
QString helpMessage();
|
||||
QString infoMessage();
|
||||
QString versionMessage();
|
||||
|
@ -46,9 +46,11 @@ void MobileWidget::clear()
|
||||
ui->lineEdit_apn->clear();
|
||||
ui->lineEdit_pin->clear();
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->spinBox_fail->setValue(5);
|
||||
ui->checkBox_route->setCheckState(Qt::Checked);
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
ui->lineEdit_init->setText(QString("ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"));
|
||||
ui->spinBox_fail->setValue(5);
|
||||
ui->lineEdit_chat->clear();
|
||||
ui->lineEdit_options->clear();
|
||||
|
||||
ui->pushButton_mobileAdvanced->setChecked(false);;
|
||||
@ -59,10 +61,22 @@ void MobileWidget::clear()
|
||||
void MobileWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_chat, SIGNAL(clicked(bool)), this, SLOT(selectChatFile()));
|
||||
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::selectChatFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("MobileWidget", "Select chat file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("MobileWidget", "All (*.*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_chat->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::selectOptionsFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
@ -102,12 +116,16 @@ QMap<QString, QString> MobileWidget::getSettings()
|
||||
else
|
||||
settings[QString("PIN")] = QString("None");
|
||||
settings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
settings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (ui->checkBox_route->checkState() == Qt::Unchecked)
|
||||
settings[QString("DefaultRoute")] = QString("false");
|
||||
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
|
||||
settings[QString("UsePeerDNS")] = QString("false");
|
||||
if (ui->lineEdit_init->text() != QString("ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"))
|
||||
settings[QString("Init")] = QString("'%1'").arg(ui->lineEdit_init->text());
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
settings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (!ui->lineEdit_chat->text().isEmpty())
|
||||
settings[QString("ChatScript")] = QString("'%1'").arg(ui->lineEdit_chat->text());
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
settings[QString("OptionsFile")] = QString("'%1'").arg(ui->lineEdit_options->text());
|
||||
|
||||
@ -143,14 +161,18 @@ void MobileWidget::setSettings(const QMap<QString, QString> settings)
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(settings[QString("MaxFail")].toInt());
|
||||
if (settings.contains(QString("DefaultRoute")))
|
||||
if (settings[QString("DefaultRoute")] == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (settings.contains(QString("UsePeerDNS")))
|
||||
if (settings[QString("UsePeerDNS")] == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (settings.contains(QString("Init")))
|
||||
ui->lineEdit_init->setText(settings[QString("Init")]);
|
||||
if (settings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(settings[QString("MaxFail")].toInt());
|
||||
if (settings.contains(QString("ChatScript")))
|
||||
ui->lineEdit_chat->setText(settings[QString("ChatScript")]);
|
||||
if (settings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(settings[QString("OptionsFile")]);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ public slots:
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void selectChatFile();
|
||||
void selectOptionsFile();
|
||||
void showAdvanced();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>445</width>
|
||||
<height>314</height>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -89,9 +89,6 @@
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -125,9 +122,6 @@
|
||||
<property name="toolTip">
|
||||
<string>The access point (apn) to connect on</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -319,6 +313,39 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_init">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_init">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Init</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_init">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An initialization string sent to the modem before dialing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fail">
|
||||
<item>
|
||||
@ -358,6 +385,52 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_chat">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_chat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chat script</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_chat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Path to a chat file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_chat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_options">
|
||||
<item>
|
||||
|
@ -25,8 +25,9 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "bondwidget.h"
|
||||
#include "bridgewidget.h"
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
@ -60,6 +61,8 @@ NewProfileWidget::NewProfileWidget(QWidget *parent, const QMap<QString, QString>
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
ipWid = new IpWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
|
||||
bondWid = new BondWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bondWid);
|
||||
bridgeWid = new BridgeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
|
||||
ethernetWid = new EthernetWidget(this);
|
||||
@ -87,6 +90,7 @@ NewProfileWidget::~NewProfileWidget()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (bondWid != nullptr) delete bondWid;
|
||||
if (bridgeWid != nullptr) delete bridgeWid;
|
||||
if (ethernetWid != nullptr) delete ethernetWid;
|
||||
if (generalWid != nullptr) delete generalWid;
|
||||
@ -168,6 +172,7 @@ void NewProfileWidget::updateProfileTab()
|
||||
|
||||
generalWid->clear();
|
||||
ipWid->clear();
|
||||
bondWid->clear();
|
||||
bridgeWid->clear();
|
||||
ethernetWid->clear();
|
||||
macvlanWid->clear();
|
||||
@ -192,6 +197,7 @@ void NewProfileWidget::profileTabChangeState(const QString current)
|
||||
|
||||
generalWid->setVisible(true);
|
||||
ipWid->setVisible((current != QString("pppoe")) && (current != QString("mobile_ppp")));
|
||||
bondWid->setVisible(current == QString("bond"));
|
||||
bridgeWid->setVisible(current == QString("bridge"));
|
||||
ethernetWid->setVisible((current == QString("ethernet")) ||
|
||||
(current == QString("vlan")) ||
|
||||
@ -250,6 +256,7 @@ void NewProfileWidget::profileTabCreateProfile()
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
else if (wirelessWid->isOk() == 5)
|
||||
return ErrorWindow::showWindow(11, QString(PDEBUG), debug);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bond")) {
|
||||
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
if (pppoeWid->isOk() == 1)
|
||||
@ -269,11 +276,13 @@ void NewProfileWidget::profileTabCreateProfile()
|
||||
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
if (tunnelWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(20, QString(PDEBUG), debug);
|
||||
else if (tunnelWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(21, QString(PDEBUG), debug);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
if (tuntapWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
|
||||
if (tuntapWid->isOk() == 2)
|
||||
else if (tuntapWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
@ -304,17 +313,23 @@ void NewProfileWidget::profileTabCreateProfile()
|
||||
addSettings = wirelessWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if ((generalWid->connectionType->currentText() == QString("bond")) ||
|
||||
(generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
} else if ((generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bond")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = bondWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = bridgeWid->getSettings();
|
||||
addSettings = bridgeWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
@ -388,13 +403,15 @@ void NewProfileWidget::profileTabLoadProfile()
|
||||
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
ipWid->setSettings(settings);
|
||||
wirelessWid->setSettings(settings);
|
||||
} else if ((generalWid->connectionType->currentText() == QString("bond")) ||
|
||||
(generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
} else if ((generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
|
||||
ipWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
ipWid->setSettings(settings);
|
||||
bridgeWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bond")) {
|
||||
ipWid->setSettings(settings);
|
||||
bondWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
pppoeWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
@ -425,7 +442,9 @@ void NewProfileWidget::profileTabOpenInEditor()
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
QString directory = QDir(configuration[QString("PROFILE_DIR")]).absolutePath();
|
||||
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
||||
profile = QString("%1/%2").arg(directory).arg(profile);
|
||||
QString cmd = QString("%1 %2 %3").arg(configuration[QString("SUDO_PATH")])
|
||||
.arg(configuration[QString("EDITOR_PATH")])
|
||||
.arg(profile);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class BondWidget;
|
||||
class BridgeWidget;
|
||||
class EthernetWidget;
|
||||
class GeneralWidget;
|
||||
@ -71,6 +72,7 @@ private:
|
||||
// ui
|
||||
MainWindow *mainWindow;
|
||||
Ui::NewProfileWidget *ui = nullptr;
|
||||
BondWidget *bondWid = nullptr;
|
||||
BridgeWidget *bridgeWid = nullptr;
|
||||
EthernetWidget *ethernetWid = nullptr;
|
||||
GeneralWidget *generalWid = nullptr;
|
||||
|
@ -247,6 +247,8 @@ void SettingsWindow::saveSettings()
|
||||
|
||||
settings.beginGroup(QString("Common"));
|
||||
settings.setValue(QString("LANGUAGE"), config[QString("LANGUAGE")]);
|
||||
settings.setValue(QString("MAINUPDATE"), config[QString("MAINUPDATE")]);
|
||||
settings.setValue(QString("WIFIUPDATE"), config[QString("WIFIUPDATE")]);
|
||||
settings.setValue(QString("SYSTRAY"), config[QString("SYSTRAY")]);
|
||||
settings.setValue(QString("CLOSETOTRAY"), config[QString("CLOSETOTRAY")]);
|
||||
settings.setValue(QString("STARTTOTRAY"), config[QString("STARTTOTRAY")]);
|
||||
@ -458,6 +460,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
config[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
|
||||
config[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
config[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
config[QString("MAINUPDATE")] = QString::number(ui->spinBox_mainAutoUpdate->value());
|
||||
config[QString("MAIN_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_mainToolbar->currentIndex()));
|
||||
config[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
config[QString("NETCTL_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_netctlToolbar->currentIndex()));
|
||||
@ -487,6 +490,7 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
config[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
config[QString("USE_HELPER")] = QString("false");
|
||||
config[QString("WIFIUPDATE")] = QString::number(ui->spinBox_wifiAutoUpdate->value());
|
||||
config[QString("WIFI_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_wifiToolbar->currentIndex()));
|
||||
config[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
config[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
@ -523,6 +527,7 @@ void SettingsWindow::setSettings(const QMap<QString, QString> config)
|
||||
ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]);
|
||||
int index = ui->comboBox_language->findText(config[QString("LANGUAGE")]);
|
||||
ui->comboBox_language->setCurrentIndex(index);
|
||||
ui->spinBox_mainAutoUpdate->setValue(config[QString("MAINUPDATE")].toInt());
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("MAIN_TOOLBAR")].toInt()));
|
||||
ui->comboBox_mainToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]);
|
||||
@ -556,6 +561,7 @@ void SettingsWindow::setSettings(const QMap<QString, QString> config)
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
|
||||
ui->spinBox_wifiAutoUpdate->setValue(config[QString("WIFIUPDATE")].toInt());
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("WIFI_TOOLBAR")].toInt()));
|
||||
ui->comboBox_wifiToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_wpaCliPath->setText(config[QString("WPACLI_PATH")]);
|
||||
@ -585,47 +591,49 @@ QMap<QString, QString> SettingsWindow::getSettings(QString fileName)
|
||||
|
||||
config[QString("LANGUAGE")] = Language::defineLanguage(fileName, QString());
|
||||
settings.beginGroup(QString("Common"));
|
||||
config[QString("LANGUAGE")] = settings.value(QString("LANGUAGE"), QString("en")).toString();
|
||||
config[QString("SYSTRAY")] = settings.value(QString("SYSTRAY"), QString("true")).toString();
|
||||
config[QString("CLOSETOTRAY")] = settings.value(QString("CLOSETOTRAY"), QString("true")).toString();
|
||||
config[QString("STARTTOTRAY")] = settings.value(QString("STARTTOTRAY"), QString("false")).toString();
|
||||
config[QString("SKIPCOMPONENTS")] = settings.value(QString("SKIPCOMPONENTS"), QString("false")).toString();
|
||||
config[QString("LANGUAGE")] = settings.value(QString("LANGUAGE"), config[QString("LANGUAGE")]).toString();
|
||||
config[QString("MAINUPDATE")] = settings.value(QString("MAINUPDATE"), QString(MAINUPDATE)).toString();
|
||||
config[QString("WIFIUPDATE")] = settings.value(QString("WIFIUPDATE"), QString(WIFIUPDATE)).toString();
|
||||
config[QString("SYSTRAY")] = settings.value(QString("SYSTRAY"), QString(SYSTRAY)).toString();
|
||||
config[QString("CLOSETOTRAY")] = settings.value(QString("CLOSETOTRAY"), QString(CLOSETOTRAY)).toString();
|
||||
config[QString("STARTTOTRAY")] = settings.value(QString("STARTTOTRAY"), QString(STARTTOTRAY)).toString();
|
||||
config[QString("SKIPCOMPONENTS")] = settings.value(QString("SKIPCOMPONENTS"), QString(SKIPCOMPONENTS)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Helper"));
|
||||
config[QString("USE_HELPER")] = settings.value(QString("USE_HELPER"), QString("true")).toString();
|
||||
config[QString("FORCE_SUDO")] = settings.value(QString("FORCE_SUDO"), QString("false")).toString();
|
||||
config[QString("CLOSE_HELPER")] = settings.value(QString("CLOSE_HELPER"), QString("false")).toString();
|
||||
config[QString("HELPER_PATH")] = settings.value(QString("HELPER_PATH"), QString("/usr/bin/netctlgui-helper")).toString();
|
||||
config[QString("HELPER_SERVICE")] = settings.value(QString("HELPER_SERVICE"), QString("netctlgui-helper.service")).toString();
|
||||
config[QString("USE_HELPER")] = settings.value(QString("USE_HELPER"), QString(USE_HELPER)).toString();
|
||||
config[QString("FORCE_SUDO")] = settings.value(QString("FORCE_SUDO"), QString(FORCE_SUDO)).toString();
|
||||
config[QString("CLOSE_HELPER")] = settings.value(QString("CLOSE_HELPER"), QString(CLOSE_HELPER)).toString();
|
||||
config[QString("HELPER_PATH")] = settings.value(QString("HELPER_PATH"), QString(HELPER_PATH)).toString();
|
||||
config[QString("HELPER_SERVICE")] = settings.value(QString("HELPER_SERVICE"), QString(HELPER_SERVICE)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("netctl"));
|
||||
config[QString("SYSTEMCTL_PATH")] = settings.value(QString("SYSTEMCTL_PATH"), QString("/usr/bin/systemctl")).toString();
|
||||
config[QString("NETCTL_PATH")] = settings.value(QString("NETCTL_PATH"), QString("/usr/bin/netctl")).toString();
|
||||
config[QString("NETCTLAUTO_PATH")] = settings.value(QString("NETCTLAUTO_PATH"), QString("/usr/bin/netctl-auto")).toString();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = settings.value(QString("NETCTLAUTO_SERVICE"), QString("netctl-auto")).toString();
|
||||
config[QString("PROFILE_DIR")] = settings.value(QString("PROFILE_DIR"), QString("/etc/netctl")).toString();
|
||||
config[QString("SYSTEMCTL_PATH")] = settings.value(QString("SYSTEMCTL_PATH"), QString(SYSTEMCTL_PATH)).toString();
|
||||
config[QString("NETCTL_PATH")] = settings.value(QString("NETCTL_PATH"), QString(NETCTL_PATH)).toString();
|
||||
config[QString("NETCTLAUTO_PATH")] = settings.value(QString("NETCTLAUTO_PATH"), QString(NETCTLAUTO_PATH)).toString();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = settings.value(QString("NETCTLAUTO_SERVICE"), QString(NETCTLAUTO_SERVICE)).toString();
|
||||
config[QString("PROFILE_DIR")] = settings.value(QString("PROFILE_DIR"), QString(PROFILE_DIR)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("sudo"));
|
||||
config[QString("SUDO_PATH")] = settings.value(QString("SUDO_PATH"), QString("/usr/bin/kdesu")).toString();
|
||||
config[QString("SUDO_PATH")] = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("wpa_supplicant"));
|
||||
config[QString("WPASUP_PATH")] = settings.value(QString("WPASUP_PATH"), QString("/usr/bin/wpa_supplicant")).toString();
|
||||
config[QString("WPACLI_PATH")] = settings.value(QString("WPACLI_PATH"), QString("/usr/bin/wpa_cli")).toString();
|
||||
config[QString("PID_FILE")] = settings.value(QString("PID_FILE"), QString("/run/wpa_supplicant_$i.pid")).toString();
|
||||
config[QString("WPA_DRIVERS")] = settings.value(QString("WPA_DRIVERS"), QString("nl80211,wext")).toString();
|
||||
config[QString("CTRL_DIR")] = settings.value(QString("CTRL_DIR"), QString("/run/wpa_supplicant")).toString();
|
||||
config[QString("CTRL_GROUP")] = settings.value(QString("CTRL_GROUP"), QString("users")).toString();
|
||||
config[QString("WPASUP_PATH")] = settings.value(QString("WPASUP_PATH"), QString(WPASUP_PATH)).toString();
|
||||
config[QString("WPACLI_PATH")] = settings.value(QString("WPACLI_PATH"), QString(WPACLI_PATH)).toString();
|
||||
config[QString("PID_FILE")] = settings.value(QString("PID_FILE"), QString(PID_FILE)).toString();
|
||||
config[QString("WPA_DRIVERS")] = settings.value(QString("WPA_DRIVERS"), QString(WPA_DRIVERS)).toString();
|
||||
config[QString("CTRL_DIR")] = settings.value(QString("CTRL_DIR"), QString(CTRL_DIR)).toString();
|
||||
config[QString("CTRL_GROUP")] = settings.value(QString("CTRL_GROUP"), QString(CTRL_GROUP)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Other"));
|
||||
config[QString("EDITOR_PATH")] = settings.value(QString("EDITOR_PATH"), QString("/usr/bin/gvim")).toString();
|
||||
config[QString("IFACE_DIR")] = settings.value(QString("IFACE_DIR"), QString("/sys/class/net/")).toString();
|
||||
config[QString("RFKILL_DIR")] = settings.value(QString("RFKILL_DIR"), QString("/sys/class/rfkill/")).toString();
|
||||
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString("")).toString();
|
||||
config[QString("EDITOR_PATH")] = settings.value(QString("EDITOR_PATH"), QString(EDITOR_PATH)).toString();
|
||||
config[QString("IFACE_DIR")] = settings.value(QString("IFACE_DIR"), QString(IFACE_DIR)).toString();
|
||||
config[QString("RFKILL_DIR")] = settings.value(QString("RFKILL_DIR"), QString(RFKILL_DIR)).toString();
|
||||
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString(PREFERED_IFACE)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
|
@ -190,6 +190,66 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mainAutoUpdate">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mainAutoUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Main tab autoupdate, sec</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_mainAutoUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wifiAutoUpdate">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wifiAutoUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WiFi tab autoupdate, sec</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_wifiAutoUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_enableTray">
|
||||
<item>
|
||||
@ -642,8 +702,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>436</width>
|
||||
<height>173</height>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@ -898,8 +958,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>436</width>
|
||||
<height>45</height>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
@ -983,8 +1043,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>239</width>
|
||||
<height>194</height>
|
||||
<width>542</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
|
@ -42,6 +42,7 @@ void TunnelWidget::clear()
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->lineEdit_local->clear();
|
||||
ui->lineEdit_remote->clear();
|
||||
ui->lineEdit_key->clear();
|
||||
}
|
||||
|
||||
|
||||
@ -62,6 +63,8 @@ QMap<QString, QString> TunnelWidget::getSettings()
|
||||
if (!IpRegExp::checkString(ui->lineEdit_local->text(), IpRegExp::ip4Regex()))
|
||||
settings[QString("Local")] = QString("'%1'").arg(ui->lineEdit_local->text());
|
||||
settings[QString("Remote")] = QString("'%1'").arg(ui->lineEdit_remote->text());
|
||||
if (ui->comboBox_mode->currentText() == QString("gre"))
|
||||
settings[QString("Key")] = QString("'%1'").arg(ui->lineEdit_key->text());
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -71,6 +74,9 @@ int TunnelWidget::isOk()
|
||||
{
|
||||
// ip is not correct
|
||||
if (!IpRegExp::checkString(ui->lineEdit_remote->text(), IpRegExp::ip4Regex())) return 1;
|
||||
// key is empty
|
||||
if (ui->comboBox_mode->currentText() == QString("gre"))
|
||||
if (ui->lineEdit_key->text().isEmpty()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
@ -88,4 +94,6 @@ void TunnelWidget::setSettings(const QMap<QString, QString> settings)
|
||||
ui->lineEdit_local->setText(settings[QString("Local")]);
|
||||
if (settings.contains(QString("Remote")))
|
||||
ui->lineEdit_remote->setText(settings[QString("Remote")]);
|
||||
if (settings.contains(QString("Key")))
|
||||
ui->lineEdit_key->setText(settings[QString("Key")]);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>108</height>
|
||||
<height>137</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -166,6 +166,39 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_key">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_key">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_key">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A key identifying an individual traffic flow within a tunnel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -47,6 +47,10 @@ WiFiMenuWidget::WiFiMenuWidget(QWidget *parent, const QMap<QString, QString> set
|
||||
ui->tableWidget_wifi->setColumnHidden(6, true);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("WIFI_TOOLBAR")].toInt()));
|
||||
|
||||
// auto update
|
||||
timer.setSingleShot(true);
|
||||
timer.setInterval(configuration[QString("WIFIUPDATE")].toInt() * 1000);
|
||||
|
||||
createActions();
|
||||
}
|
||||
|
||||
@ -71,8 +75,12 @@ void WiFiMenuWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
updateWifiTab();
|
||||
updateMenuWifi();
|
||||
if (mainWindow->currentTab() == 2) {
|
||||
updateWifiTab();
|
||||
updateMenuWifi();
|
||||
}
|
||||
|
||||
if (timer.interval() != 0) return timer.start();
|
||||
}
|
||||
|
||||
|
||||
@ -430,6 +438,7 @@ void WiFiMenuWidget::createActions()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(&timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
connect(ui->actionFunc, SIGNAL(triggered(bool)), this, SLOT(wifiTabShowInfo()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateWifiTab()));
|
||||
connect(ui->actionStart, SIGNAL(triggered(bool)), this, SLOT(wifiTabStart()));
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
@ -70,6 +71,7 @@ private:
|
||||
void createActions();
|
||||
bool debug = false;
|
||||
bool hiddenNetwork = false;
|
||||
QTimer timer;
|
||||
bool useHelper = true;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
|
@ -77,7 +77,6 @@ void WirelessWidget::clear()
|
||||
}
|
||||
ui->comboBox_rfkill->setCurrentIndex(0);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_wirelessAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
@ -231,8 +230,6 @@ QMap<QString, QString> WirelessWidget::getSettings()
|
||||
settings[QString("RFKill")] = ui->comboBox_rfkill->currentText();
|
||||
if (ui->spinBox_timeoutWpa->value() != 15)
|
||||
settings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
|
||||
if (ui->checkBox_exclude->checkState() == Qt::Checked)
|
||||
settings[QString("ExcludeAuto")] = QString("yes");
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -310,9 +307,6 @@ void WirelessWidget::setSettings(const QMap<QString, QString> settings)
|
||||
}
|
||||
if (settings.contains(QString("TimeoutWPA")))
|
||||
ui->spinBox_timeoutWpa->setValue(settings[QString("TimeoutWPA")].toInt());
|
||||
if (settings.contains(QString("ExcludeAuto")))
|
||||
if (settings[QString("ExcludeAuto")] == QString("yes"))
|
||||
ui->checkBox_exclude->setCheckState(Qt::Checked);
|
||||
|
||||
changeSecurity(ui->comboBox_security->currentText());
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>584</width>
|
||||
<height>697</height>
|
||||
<height>670</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@ -280,17 +280,11 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wirelessAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_wirelessAdvanced">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pushButton_wirelessAdvanced">
|
||||
@ -313,36 +307,6 @@
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_exclude">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_exclude">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_exclude">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Whether or not to exclude this profile from automatic profile selection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exclude auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_hidden">
|
||||
<item>
|
||||
|
@ -18,13 +18,16 @@ add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||
# build man
|
||||
file (GLOB SUBPROJECT_MAN_IN *.1)
|
||||
file (GLOB SUBPROJECT_MAN5_IN *.5)
|
||||
file (GLOB SUBPROJECT_CONF_IN netctl-gui.conf)
|
||||
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
|
||||
file (RELATIVE_PATH SUBPROJECT_MAN5 ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN5_IN})
|
||||
file (RELATIVE_PATH SUBPROJECT_CONF ${CMAKE_SOURCE_DIR} ${SUBPROJECT_CONF_IN})
|
||||
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
|
||||
configure_file (${SUBPROJECT_MAN5_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN5})
|
||||
configure_file (${SUBPROJECT_CONF_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_CONF})
|
||||
|
||||
install (FILES org.netctlgui.helper.conf DESTINATION ${DBUS_SYSTEMCONF_PATH})
|
||||
install (FILES netctl-gui.conf DESTINATION /etc)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_CONF} DESTINATION /etc)
|
||||
install (FILES netctlgui-helper.service DESTINATION ${SYSTEMD_SERVICE_PATH})
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN5} DESTINATION share/man/man5/)
|
||||
|
@ -5,75 +5,81 @@
|
||||
|
||||
[Common]
|
||||
# application language
|
||||
LANGUAGE=en
|
||||
#LANGUAGE="@CFG_LANGUAGE@"
|
||||
# auto update interval for main tab in seconds
|
||||
# 0 means there is no updates
|
||||
#MAINUPDATE="@CFG_MAINUPDATE@"
|
||||
# auto update interval for wifi tab in seconds
|
||||
# 0 means there is no updates
|
||||
#WIFIUPDATE="@CFG_WIFIUPDATE@"
|
||||
# create system tray icon.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
SYSTRAY=true
|
||||
#SYSTRAY="@CFG_SYSTRAY@"
|
||||
# close helper after GUI application quit.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
CLOSETOTRAY=true
|
||||
#CLOSETOTRAY="@CFG_CLOSETOTRAY@"
|
||||
# start netctl-gui minimized to tray if it is available.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
STARTTOTRAY=false
|
||||
#STARTTOTRAY="@CFG_STARTTOTRAY@"
|
||||
# skip external components checking
|
||||
# This option is not recognized by netctlgui-helper
|
||||
SKIPCOMPONENTS=false
|
||||
#SKIPCOMPONENTS="@CFG_SKIPCOMPONENTS@"
|
||||
|
||||
[Helper]
|
||||
# use netctlgui-helper if it is available.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
USE_HELPER=true
|
||||
#USE_HELPER="@CFG_USE_HELPER@"
|
||||
# force use SUDO_PATH for helper instead of using setuid(3) to child processes
|
||||
FORCE_SUDO=false
|
||||
#FORCE_SUDO="@CFG_FORCE_SUDO@"
|
||||
# hide application to tray on exit if tray is available.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
CLOSE_HELPER=false
|
||||
#CLOSE_HELPER="@CFG_CLOSE_HELPER@"
|
||||
# path to netctlgui-helper.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
HELPER_PATH=/usr/bin/netctlgui-helper
|
||||
#HELPER_PATH="@CFG_HELPER_PATH@"
|
||||
# netctlgui-helper service name.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
HELPER_SERVICE=netctlgui-helper.service
|
||||
#HELPER_SERVICE="@CFG_HELPER_SERVICE@"
|
||||
|
||||
[netctl]
|
||||
# path to systemctl
|
||||
SYSTEMCTL_PATH=/usr/bin/systemctl
|
||||
#SYSTEMCTL_PATH="@CFG_SYSTEMCTL_PATH@"
|
||||
# path to netctl
|
||||
NETCTL_PATH=/usr/bin/netctl
|
||||
#NETCTL_PATH="@CFG_NETCTL_PATH@"
|
||||
# path to netctl-auto
|
||||
NETCTLAUTO_PATH=/usr/bin/netctl-auto
|
||||
#NETCTLAUTO_PATH="@CFG_NETCTLAUTO_PATH@"
|
||||
# netctl-auto service name without .service suffix
|
||||
NETCTLAUTO_SERVICE=netctl-auto
|
||||
#NETCTLAUTO_SERVICE="@CFG_NETCTLAUTO_SERVICE@"
|
||||
# path to netctl profile directory
|
||||
PROFILE_DIR=/etc/netctl/
|
||||
#PROFILE_DIR="@CFG_PROFILE_DIR@"
|
||||
|
||||
[sudo]
|
||||
# path to sudo frontend
|
||||
SUDO_PATH=/usr/bin/sudo
|
||||
#SUDO_PATH="@CFG_SUDO_PATH@"
|
||||
|
||||
[wpa_supplicant]
|
||||
# path to wpa_supplicant
|
||||
WPASUP_PATH=/usr/bin/wpa_supplicant
|
||||
#WPASUP_PATH="@CFG_WPASUP_PATH@"
|
||||
# path to wpa_cli
|
||||
WPACLI_PATH=/usr/bin/wpa_cli
|
||||
#WPACLI_PATH="@CFG_WPACLI_PATH@"
|
||||
# wpa_supplicant PID file
|
||||
# $i is interface
|
||||
PID_FILE=/run/wpa_supplicant_$i.pid
|
||||
#PID_FILE="@CFG_PID_FILE@"
|
||||
# wpa_supplicant drivers for wireless interface comma separated
|
||||
WPA_DRIVERS=nl80211,wext
|
||||
#WPA_DRIVERS="@CFG_WPA_DRIVERS@"
|
||||
# path to control directory which is required by wpa_supplicant
|
||||
CTRL_DIR=/run/wpa_supplicant
|
||||
#CTRL_DIR="@CFG_CTRL_DIR@"
|
||||
# group which is owner of CTRL_DIR
|
||||
CTRL_GROUP=users
|
||||
#CTRL_GROUP="@CFG_CTRL_GROUP@"
|
||||
|
||||
[Other]
|
||||
# path to external editor
|
||||
# This option is not recognized by netctlgui-helper
|
||||
EDITOR_PATH=/usr/bin/gvim
|
||||
#EDITOR_PATH="@CFG_EDITOR_PATH@"
|
||||
# path to directory which contains interface information
|
||||
IFACE_DIR=/sys/class/net/
|
||||
#IFACE_DIR="@CFG_IFACE_DIR@"
|
||||
# path to directory with rfkill devices.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
RFKILL_DIR=/sys/class/rfkill/
|
||||
#RFKILL_DIR="@CFG_RFKILL_DIR@"
|
||||
# prefered wireless interface
|
||||
PREFERED_IFACE=
|
||||
#PREFERED_IFACE="@CFG_PREFERED_IFACE@"
|
||||
|
@ -32,10 +32,10 @@ force use
|
||||
for helper instead of using
|
||||
.BR setuid (3)
|
||||
to child processes
|
||||
.IP "EDITOR_PATH=/usr/bin/gvim"
|
||||
.IP "EDITOR_PATH=gvim"
|
||||
path to an external editor. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "HELPER_PATH=/usr/bin/netctlgui-helper"
|
||||
.IP "HELPER_PATH=netctlgui-helper"
|
||||
path to
|
||||
.BR netctlgui-helper (1)
|
||||
This option is not recognized by
|
||||
@ -48,10 +48,12 @@ service name. This option is not recognized by
|
||||
path to directory which contains interface information
|
||||
.IP "LANGUAGE=en"
|
||||
application language
|
||||
.IP "NETCTL_PATH=/usr/bin/netctl"
|
||||
.IP "MAINUPDATE=0"
|
||||
main tab autoupdate interval in seconds. 0 is disable autoupdate
|
||||
.IP "NETCTL_PATH=netctl"
|
||||
path to
|
||||
.BR netctl (1)
|
||||
.IP "NETCTLAUTO_PATH=/usr/bin/netctl-auto"
|
||||
.IP "NETCTLAUTO_PATH=netctl-auto"
|
||||
path to
|
||||
.BR netctl-auto (1)
|
||||
.IP "NETCTLAUTO_SERVICE=netctl-auto"
|
||||
@ -81,11 +83,11 @@ start
|
||||
.BR netctl-gui (1)
|
||||
minimized to tray if it is available. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "SUDO_PATH=/usr/bin/kdesu"
|
||||
.IP "SUDO_PATH=kdesu"
|
||||
path to
|
||||
.BR sudo (8)
|
||||
frontend
|
||||
.IP "SYSTEMCTL_PATH=/usr/bin/systemctl"
|
||||
.IP "SYSTEMCTL_PATH=systemctl"
|
||||
path to
|
||||
.BR systemctl (1)
|
||||
.IP "SYSTRAY=true"
|
||||
@ -96,10 +98,12 @@ use
|
||||
.BR netctlgui-helper (1)
|
||||
if it is available. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "WPACLI_PATH=/usr/bin/wpa_cli"
|
||||
.IP "WIFIUPDATE=0"
|
||||
WiFi tab autoupdate interval in seconds. 0 is disable autoupdate
|
||||
.IP "WPACLI_PATH=wpa_cli"
|
||||
path to
|
||||
.BR wpa_cli (8)
|
||||
.IP "WPASUP_PATH=/usr/bin/wpa_supplicant"
|
||||
.IP "WPASUP_PATH=wpa_supplicant"
|
||||
path to
|
||||
.BR wpa_supplicant (8)
|
||||
.IP "WPA_DRIVERS=nl80211,wext"
|
||||
|
@ -1,7 +1,14 @@
|
||||
# set files
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
if (USE_QT5)
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
|
||||
else ()
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
endif ()
|
||||
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.h)
|
||||
|
||||
|
@ -112,7 +112,7 @@ QString ControlAdaptor::SecurityDocs()
|
||||
|
||||
bool ControlAdaptor::SelfDestruct(const QString approve)
|
||||
{
|
||||
if (approve == QString("Yes, please")) return SelfDestruct(approve);
|
||||
if (approve == QString("Yes please")) return SelfDestruct(approve);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -32,6 +32,10 @@
|
||||
#include "netctlhelper.h"
|
||||
#include "version.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <pdebug/pdebug-time.h>
|
||||
#endif /* QT_VERSION >= 0x050000 */
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -50,7 +54,7 @@ bool existingSessionOperation(const QString operation)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QMap<QString, QVariant> args = getArgs();
|
||||
QVariantMap args = getArgs();
|
||||
// reading
|
||||
for (int i=1; i<argc; i++) {
|
||||
if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) {
|
||||
@ -115,6 +119,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
QCoreApplication::setSetuidAllowed(true);
|
||||
qInstallMessageHandler(debugString);
|
||||
#endif
|
||||
QCoreApplication a(argc, argv);
|
||||
// reread translations according to flags
|
||||
|
@ -29,14 +29,14 @@ QString errorMessage()
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> getArgs()
|
||||
QVariantMap getArgs()
|
||||
{
|
||||
QMap<QString, QVariant> args;
|
||||
QVariantMap args;
|
||||
args[QString("config")] = QString("%1/.config/netctl-gui.conf").arg(QDir::homePath());
|
||||
args[QString("debug")] = false;
|
||||
args[QString("nodaemon")] = false;
|
||||
args[QString("session")] = false;
|
||||
args[QString("state")] = (int) 0;
|
||||
args[QString("state")] = static_cast<int>(0);
|
||||
args[QString("system")] = false;
|
||||
args[QString("help")] = false;
|
||||
args[QString("info")] = false;
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
QString errorMessage();
|
||||
QMap<QString, QVariant> getArgs();
|
||||
QVariantMap getArgs();
|
||||
QString helpMessage();
|
||||
QString infoMessage();
|
||||
QString versionMessage();
|
||||
|
@ -39,25 +39,25 @@ NetctlAdaptor::~NetctlAdaptor()
|
||||
|
||||
|
||||
// netctlCommand
|
||||
QString NetctlAdaptor::ActiveProfile()
|
||||
QStringList NetctlAdaptor::ActiveProfile()
|
||||
{
|
||||
if (isNetctlAutoActive())
|
||||
return netctlCommand->autoGetActiveProfile();
|
||||
else
|
||||
return netctlCommand->getActiveProfile().join(QChar('|'));
|
||||
return netctlCommand->getActiveProfile();
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdaptor::ActiveProfileStatus()
|
||||
QStringList NetctlAdaptor::ActiveProfileStatus()
|
||||
{
|
||||
if (isNetctlAutoActive())
|
||||
return QString("netctl-auto");
|
||||
return QStringList() << QString("netctl-auto");
|
||||
else {
|
||||
QStringList status;
|
||||
QStringList profiles = ActiveProfile().split(QChar('|'));
|
||||
QStringList profiles = ActiveProfile();
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
status.append(netctlCommand->getProfileStatus(profiles[i]));
|
||||
return status.join(QChar('|'));
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,9 +108,9 @@ bool NetctlAdaptor::isProfileEnabled(const QString profile)
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdaptor::netctlActiveProfile()
|
||||
QStringList NetctlAdaptor::netctlActiveProfile()
|
||||
{
|
||||
return netctlCommand->getActiveProfile().join(QChar('|'));
|
||||
return netctlCommand->getActiveProfile();
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,8 +37,8 @@ public:
|
||||
|
||||
public slots:
|
||||
// netctlCommand
|
||||
QString ActiveProfile();
|
||||
QString ActiveProfileStatus();
|
||||
QStringList ActiveProfile();
|
||||
QStringList ActiveProfileStatus();
|
||||
bool autoIsProfileActive(const QString profile);
|
||||
bool autoIsProfileEnabled(const QString profile);
|
||||
QStringList Information();
|
||||
@ -46,7 +46,7 @@ public slots:
|
||||
bool isNetctlAutoEnabled();
|
||||
bool isProfileActive(const QString profile);
|
||||
bool isProfileEnabled(const QString profile);
|
||||
QString netctlActiveProfile();
|
||||
QStringList netctlActiveProfile();
|
||||
QStringList netctlProfileList();
|
||||
QStringList netctlVerboseProfileList();
|
||||
QStringList ProfileList();
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
NetctlHelper::NetctlHelper(QObject *parent, QMap<QString, QVariant> args)
|
||||
NetctlHelper::NetctlHelper(QObject *parent, QVariantMap args)
|
||||
: QObject(parent),
|
||||
configPath(args[QString("config")].toString()),
|
||||
debug(args[QString("debug")].toBool()),
|
||||
@ -147,47 +147,49 @@ QMap<QString, QString> NetctlHelper::getSettings(const QString file)
|
||||
QSettings settings(file, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Common"));
|
||||
config[QString("LANGUAGE")] = settings.value(QString("LANGUAGE"), QString("en")).toString();
|
||||
config[QString("SYSTRAY")] = settings.value(QString("SYSTRAY"), QString("true")).toString();
|
||||
config[QString("CLOSETOTRAY")] = settings.value(QString("CLOSETOTRAY"), QString("true")).toString();
|
||||
config[QString("STARTTOTRAY")] = settings.value(QString("STARTTOTRAY"), QString("false")).toString();
|
||||
config[QString("SKIPCOMPONENTS")] = settings.value(QString("SKIPCOMPONENTS"), QString("false")).toString();
|
||||
config[QString("LANGUAGE")] = settings.value(QString("LANGUAGE"), QString(LANGUAGE)).toString();
|
||||
config[QString("MAINUPDATE")] = settings.value(QString("MAINUPDATE"), QString(MAINUPDATE)).toString();
|
||||
config[QString("WIFIUPDATE")] = settings.value(QString("WIFIUPDATE"), QString(WIFIUPDATE)).toString();
|
||||
config[QString("SYSTRAY")] = settings.value(QString("SYSTRAY"), QString(SYSTRAY)).toString();
|
||||
config[QString("CLOSETOTRAY")] = settings.value(QString("CLOSETOTRAY"), QString(CLOSETOTRAY)).toString();
|
||||
config[QString("STARTTOTRAY")] = settings.value(QString("STARTTOTRAY"), QString(STARTTOTRAY)).toString();
|
||||
config[QString("SKIPCOMPONENTS")] = settings.value(QString("SKIPCOMPONENTS"), QString(SKIPCOMPONENTS)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Helper"));
|
||||
config[QString("USE_HELPER")] = settings.value(QString("USE_HELPER"), QString("true")).toString();
|
||||
config[QString("FORCE_SUDO")] = settings.value(QString("FORCE_SUDO"), QString("false")).toString();
|
||||
config[QString("CLOSE_HELPER")] = settings.value(QString("CLOSE_HELPER"), QString("false")).toString();
|
||||
config[QString("HELPER_PATH")] = settings.value(QString("HELPER_PATH"), QString("/usr/bin/netctlgui-helper")).toString();
|
||||
config[QString("HELPER_SERVICE")] = settings.value(QString("HELPER_SERVICE"), QString("netctlgui-helper.service")).toString();
|
||||
config[QString("USE_HELPER")] = settings.value(QString("USE_HELPER"), QString(USE_HELPER)).toString();
|
||||
config[QString("FORCE_SUDO")] = settings.value(QString("FORCE_SUDO"), QString(FORCE_SUDO)).toString();
|
||||
config[QString("CLOSE_HELPER")] = settings.value(QString("CLOSE_HELPER"), QString(CLOSE_HELPER)).toString();
|
||||
config[QString("HELPER_PATH")] = settings.value(QString("HELPER_PATH"), QString(HELPER_PATH)).toString();
|
||||
config[QString("HELPER_SERVICE")] = settings.value(QString("HELPER_SERVICE"), QString(HELPER_SERVICE)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("netctl"));
|
||||
config[QString("SYSTEMCTL_PATH")] = settings.value(QString("SYSTEMCTL_PATH"), QString("/usr/bin/systemctl")).toString();
|
||||
config[QString("NETCTL_PATH")] = settings.value(QString("NETCTL_PATH"), QString("/usr/bin/netctl")).toString();
|
||||
config[QString("NETCTLAUTO_PATH")] = settings.value(QString("NETCTLAUTO_PATH"), QString("/usr/bin/netctl-auto")).toString();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = settings.value(QString("NETCTLAUTO_SERVICE"), QString("netctl-auto")).toString();
|
||||
config[QString("PROFILE_DIR")] = settings.value(QString("PROFILE_DIR"), QString("/etc/netctl")).toString();
|
||||
config[QString("SYSTEMCTL_PATH")] = settings.value(QString("SYSTEMCTL_PATH"), QString(SYSTEMCTL_PATH)).toString();
|
||||
config[QString("NETCTL_PATH")] = settings.value(QString("NETCTL_PATH"), QString(NETCTL_PATH)).toString();
|
||||
config[QString("NETCTLAUTO_PATH")] = settings.value(QString("NETCTLAUTO_PATH"), QString(NETCTLAUTO_PATH)).toString();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = settings.value(QString("NETCTLAUTO_SERVICE"), QString(NETCTLAUTO_SERVICE)).toString();
|
||||
config[QString("PROFILE_DIR")] = settings.value(QString("PROFILE_DIR"), QString(PROFILE_DIR)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("sudo"));
|
||||
config[QString("SUDO_PATH")] = settings.value(QString("SUDO_PATH"), QString("/usr/bin/kdesu")).toString();
|
||||
config[QString("SUDO_PATH")] = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("wpa_supplicant"));
|
||||
config[QString("WPASUP_PATH")] = settings.value(QString("WPASUP_PATH"), QString("/usr/bin/wpa_supplicant")).toString();
|
||||
config[QString("WPACLI_PATH")] = settings.value(QString("WPACLI_PATH"), QString("/usr/bin/wpa_cli")).toString();
|
||||
config[QString("PID_FILE")] = settings.value(QString("PID_FILE"), QString("/run/wpa_supplicant_$i.pid")).toString();
|
||||
config[QString("WPA_DRIVERS")] = settings.value(QString("WPA_DRIVERS"), QString("nl80211,wext")).toString();
|
||||
config[QString("CTRL_DIR")] = settings.value(QString("CTRL_DIR"), QString("/run/wpa_supplicant")).toString();
|
||||
config[QString("CTRL_GROUP")] = settings.value(QString("CTRL_GROUP"), QString("users")).toString();
|
||||
config[QString("WPASUP_PATH")] = settings.value(QString("WPASUP_PATH"), QString(WPASUP_PATH)).toString();
|
||||
config[QString("WPACLI_PATH")] = settings.value(QString("WPACLI_PATH"), QString(WPACLI_PATH)).toString();
|
||||
config[QString("PID_FILE")] = settings.value(QString("PID_FILE"), QString(PID_FILE)).toString();
|
||||
config[QString("WPA_DRIVERS")] = settings.value(QString("WPA_DRIVERS"), QString(WPA_DRIVERS)).toString();
|
||||
config[QString("CTRL_DIR")] = settings.value(QString("CTRL_DIR"), QString(CTRL_DIR)).toString();
|
||||
config[QString("CTRL_GROUP")] = settings.value(QString("CTRL_GROUP"), QString(CTRL_GROUP)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Other"));
|
||||
config[QString("EDITOR_PATH")] = settings.value(QString("EDITOR_PATH"), QString("/usr/bin/gvim")).toString();
|
||||
config[QString("IFACE_DIR")] = settings.value(QString("IFACE_DIR"), QString("/sys/class/net/")).toString();
|
||||
config[QString("RFKILL_DIR")] = settings.value(QString("RFKILL_DIR"), QString("/sys/class/rfkill/")).toString();
|
||||
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString("")).toString();
|
||||
config[QString("EDITOR_PATH")] = settings.value(QString("EDITOR_PATH"), QString(EDITOR_PATH)).toString();
|
||||
config[QString("IFACE_DIR")] = settings.value(QString("IFACE_DIR"), QString(IFACE_DIR)).toString();
|
||||
config[QString("RFKILL_DIR")] = settings.value(QString("RFKILL_DIR"), QString(RFKILL_DIR)).toString();
|
||||
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString(PREFERED_IFACE)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
@ -210,7 +212,7 @@ void NetctlHelper::updateConfiguration()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
deleteInterface();
|
||||
if (system)
|
||||
if ((system) || (!QFile(configPath).exists()))
|
||||
configuration = getSettings(QString("/etc/netctl-gui.conf"));
|
||||
else
|
||||
configuration = getSettings(configPath);
|
||||
|
@ -29,7 +29,7 @@ class NetctlHelper : public QObject
|
||||
|
||||
public:
|
||||
explicit NetctlHelper(QObject *parent = 0,
|
||||
QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
QVariantMap args = QVariantMap());
|
||||
~NetctlHelper();
|
||||
QStringList printSettings();
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
|
||||
class NetctlProfile;
|
||||
struct TaskResult;
|
||||
|
||||
/**
|
||||
* @struct netctlProfileInfo
|
||||
@ -92,81 +93,75 @@ public:
|
||||
/**
|
||||
* @brief Netctl class destructor
|
||||
*/
|
||||
~Netctl();
|
||||
virtual ~Netctl();
|
||||
// general information
|
||||
/**
|
||||
* @brief method which returns active profile name
|
||||
* @return profile name or ""
|
||||
* @return Netctl::getActiveProfileTemplate()
|
||||
*/
|
||||
QStringList getActiveProfile();
|
||||
QStringList getActiveProfile() const;
|
||||
/**
|
||||
* @brief method which returns active profile name from netctl-auto
|
||||
* @return profile name or ""
|
||||
* @return Netctl::getActiveProfileTemplate()
|
||||
*/
|
||||
QString autoGetActiveProfile();
|
||||
QStringList autoGetActiveProfile() const;
|
||||
/**
|
||||
* @brief method which returns profile informations from netctl
|
||||
* @return list of profiles
|
||||
* @return Netctl::getProfileListTemplate()
|
||||
*/
|
||||
QList<netctlProfileInfo> getProfileList();
|
||||
QList<netctlProfileInfo> getProfileList() const;
|
||||
/**
|
||||
* @brief method which returns profile informations from netctl-auto
|
||||
* @return list of profiles from netctl-auto
|
||||
* @return Netctl::getProfileListTemplate()
|
||||
*/
|
||||
QList<netctlProfileInfo> getProfileListFromNetctlAuto();
|
||||
/**
|
||||
* @brief method which gets description from profile
|
||||
* @param profile profile name
|
||||
* @return profile description or ""
|
||||
*/
|
||||
Q_DECL_DEPRECATED QString getProfileDescription(const QString profile);
|
||||
QList<netctlProfileInfo> getProfileListFromNetctlAuto() const;
|
||||
/**
|
||||
* @brief method which gets profile status
|
||||
* @param profile profile name
|
||||
* @return profile status. It may be "active (enabled)", "active (static)",
|
||||
* "inactive (enabled)", "inactive (static)"
|
||||
*/
|
||||
QString getProfileStatus(const QString profile);
|
||||
QString getProfileStatus(const QString profile) const;
|
||||
/**
|
||||
* @brief method which checks if profile is active
|
||||
* @param profile profile name
|
||||
* @return false if profile is inactive
|
||||
* @return true if profile is active
|
||||
*/
|
||||
bool isProfileActive(const QString profile);
|
||||
bool isProfileActive(const QString profile) const;
|
||||
/**
|
||||
* @brief method which checks if profile is enabled
|
||||
* @param profile profile name
|
||||
* @return false if profile is disabled
|
||||
* @return true if profile is enabled
|
||||
*/
|
||||
bool isProfileEnabled(const QString profile);
|
||||
bool isProfileEnabled(const QString profile) const;
|
||||
/**
|
||||
* @brief method which checks if profile is active (netctl-auto)
|
||||
* @param profile profile name
|
||||
* @return false if profile is inactive
|
||||
* @return true if profile is active
|
||||
*/
|
||||
bool autoIsProfileActive(const QString profile);
|
||||
bool autoIsProfileActive(const QString profile) const;
|
||||
/**
|
||||
* @brief method which checks if profile is enabled (netctl-auto)
|
||||
* @param profile profile name
|
||||
* @return false if profile is disabled
|
||||
* @return true if profile is enabled
|
||||
*/
|
||||
bool autoIsProfileEnabled(const QString profile);
|
||||
bool autoIsProfileEnabled(const QString profile) const;
|
||||
/**
|
||||
* @brief method which checks netctl-auto autoload status
|
||||
* @return false if netctl-auto is disabled
|
||||
* @return true if netctl-auto is enabled
|
||||
*/
|
||||
bool isNetctlAutoEnabled();
|
||||
bool isNetctlAutoEnabled() const;
|
||||
/**
|
||||
* @brief method which checks netctl-auto status
|
||||
* @return false if netctl-auto is inactive
|
||||
* @return true if netctl-auto is active
|
||||
*/
|
||||
bool isNetctlAutoRunning();
|
||||
bool isNetctlAutoRunning() const;
|
||||
/**
|
||||
* @brief method which check system configuration and return recommended values to keys
|
||||
* @return recommended parametrs
|
||||
@ -176,7 +171,7 @@ public:
|
||||
* @brief method which gets wireless interface list from PREFERED_IFACE and IFACE_DIR
|
||||
* @return interface list. If PREFERED_IFACE is not empty it will be first element
|
||||
*/
|
||||
QStringList getWirelessInterfaceList();
|
||||
QStringList getWirelessInterfaceList() const;
|
||||
|
||||
public slots:
|
||||
// functions
|
||||
@ -187,101 +182,101 @@ public slots:
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool enableProfile(const QString profile);
|
||||
bool enableProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which force starts profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool forceStartProfile(const QString profile);
|
||||
bool forceStartProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which force stops profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool forceStopProfile(const QString profile);
|
||||
bool forceStopProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which reenables profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool reenableProfile(const QString profile);
|
||||
bool reenableProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which restarts profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool restartProfile(const QString profile);
|
||||
bool restartProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which starts or stops profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool startProfile(const QString profile);
|
||||
bool startProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which stops all profiles
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool stopAllProfiles();
|
||||
bool stopAllProfiles() const;
|
||||
/**
|
||||
* @brief method which starts another profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool switchToProfile(const QString profile);
|
||||
bool switchToProfile(const QString profile) const;
|
||||
// netctl-auto
|
||||
/**
|
||||
* @brief method which sets all profiles disabled (netctl-auto)
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoDisableAllProfiles();
|
||||
bool autoDisableAllProfiles() const;
|
||||
/**
|
||||
* @brief method which sets profile disabled or enabled (netctl-auto)
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoEnableProfile(const QString profile);
|
||||
bool autoEnableProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which sets all profiles enabled (netctl-auto)
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoEnableAllProfiles();
|
||||
bool autoEnableAllProfiles() const;
|
||||
/**
|
||||
* @brief method which switchs to profile (netctl-auto)
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoStartProfile(const QString profile);
|
||||
bool autoStartProfile(const QString profile) const;
|
||||
// netctl-auto service
|
||||
/**
|
||||
* @brief method which sets netctl-auto service enabled or disabled
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoEnableService();
|
||||
bool autoEnableService() const;
|
||||
/**
|
||||
* @brief method which restarted netctl-auto service
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoRestartService();
|
||||
bool autoRestartService() const;
|
||||
/**
|
||||
* @brief method which starts or stops netctl-auto service
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool autoStartService();
|
||||
bool autoStartService() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -295,7 +290,7 @@ private:
|
||||
/**
|
||||
* @brief use RootProcess instead of QProcess. Default is true
|
||||
*/
|
||||
bool useSuid = true;
|
||||
bool useSuid;
|
||||
/**
|
||||
* @brief directory with interfaces. Default is "/sys/class/net/"
|
||||
*/
|
||||
@ -303,27 +298,27 @@ private:
|
||||
/**
|
||||
* @brief prefered interface for WiFi. Default is ""
|
||||
*/
|
||||
QString mainInterface = QString("");
|
||||
QString mainInterface;
|
||||
/**
|
||||
* @brief path to netctl command. Default is "/usr/bin/netctl"
|
||||
* @brief path to netctl command. Default is "netctl"
|
||||
*/
|
||||
QString netctlCommand = QString("/usr/bin/netctl");
|
||||
QString netctlCommand;
|
||||
/**
|
||||
* @brief path to netctl-auto command. Default is "/usr/bin/netctl-auto"
|
||||
* @brief path to netctl-auto command. Default is "netctl-auto"
|
||||
*/
|
||||
QString netctlAutoCommand = QString("/usr/bin/netctl-auto");
|
||||
QString netctlAutoCommand;
|
||||
/**
|
||||
* @brief netctl-auto service name. Default is "netctl-auto"
|
||||
*/
|
||||
QString netctlAutoService = QString("netctl-auto");
|
||||
QString netctlAutoService;
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
* @brief path to sudo command. Default is "kdesu"
|
||||
*/
|
||||
QString sudoCommand = QString("/usr/bin/kdesu");
|
||||
QString sudoCommand;
|
||||
/**
|
||||
* @brief path to systemctl command. Default is "/usr/bin/systemctl"
|
||||
* @brief path to systemctl command. Default is "systemctl"
|
||||
*/
|
||||
QString systemctlCommand = QString("/usr/bin/systemctl");
|
||||
QString systemctlCommand;
|
||||
// functions
|
||||
/**
|
||||
* @brief method which calls command
|
||||
@ -331,21 +326,22 @@ private:
|
||||
* @param command command which will be called
|
||||
* @param commandLine command which will be passed to command
|
||||
* @param argument argument which will be passed to commandLine
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
* @return process object
|
||||
*/
|
||||
bool cmdCall(const bool sudo, const QString command,
|
||||
const QString commandLine, const QString argument = 0);
|
||||
TaskResult cmdCall(const bool sudo, const QString command,
|
||||
const QString commandLine, const QString argument = QString()) const;
|
||||
/**
|
||||
* @brief method which calls command and returns its output
|
||||
* @param sudo set true if sudo is needed
|
||||
* @param command command which will be called
|
||||
* @param commandLine command which will be passed to command
|
||||
* @param argument argument which will be passed to commandLine
|
||||
* @return command output
|
||||
* @brief method which parse output for profile data
|
||||
* @param data profile list data
|
||||
* @return list of active profiles if any
|
||||
*/
|
||||
QString getCmdOutput(const bool sudo, const QString command,
|
||||
const QString commandLine, const QString argument = 0);
|
||||
QStringList getActiveProfileTemplate(const QList<netctlProfileInfo> data) const;
|
||||
/**
|
||||
* @brief get profile list from sources
|
||||
* @param isAuto use netctl-auto instead of netctl
|
||||
* @return profile list
|
||||
*/
|
||||
QList<netctlProfileInfo> getProfileListTemplate(const bool isAuto) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
/**
|
||||
* @brief NetctlInterface class destructor
|
||||
*/
|
||||
~NetctlInterface();
|
||||
virtual ~NetctlInterface();
|
||||
// control methods
|
||||
/**
|
||||
* @brief method which creates and copies profile
|
||||
@ -120,7 +120,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is created
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer createProfile(const QString profile, const QMap<QString, QString> settings);
|
||||
InterfaceAnswer createProfile(const QString profile, const QMap<QString, QString> settings) const;
|
||||
/**
|
||||
* @brief method which connects to ESSID
|
||||
* @remark netctl independ
|
||||
@ -130,7 +130,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString, QString> settings);
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString, QString> settings) const;
|
||||
/**
|
||||
* @brief method which connects to existent profile by ESSID
|
||||
* @remark netctl independ
|
||||
@ -139,7 +139,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer connectToKnownEssid(const QString essid);
|
||||
InterfaceAnswer connectToKnownEssid(const QString essid) const;
|
||||
/**
|
||||
* @brief method which creates wireless profile and connects to it
|
||||
* @remark netctl independ
|
||||
@ -149,7 +149,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer connectToUnknownEssid(const QString essid, QMap<QString, QString> settings);
|
||||
InterfaceAnswer connectToUnknownEssid(const QString essid, QMap<QString, QString> settings) const;
|
||||
/**
|
||||
* @brief method which enables or disables selected profile and returns its status
|
||||
* @remark netctl only
|
||||
@ -158,7 +158,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is enabled
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer enableProfile(const QString profile);
|
||||
InterfaceAnswer enableProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which removes selected profile
|
||||
* @remark netctl independ
|
||||
@ -166,7 +166,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile does not exists anymore
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer removeProfile(const QString profile);
|
||||
InterfaceAnswer removeProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which restarts selected profile and returns its status
|
||||
* @remark netctl only
|
||||
@ -175,7 +175,7 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer restartProfile(const QString profile);
|
||||
InterfaceAnswer restartProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which starts/stops or switchs to selected profile and returns its status
|
||||
* @remark netctl only
|
||||
@ -184,14 +184,14 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer startProfile(const QString profile);
|
||||
InterfaceAnswer startProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which stops all profiles
|
||||
* @remark netctl only
|
||||
* @return InterfaceAnswer::True if there are no errors
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer stopAllProfiles();
|
||||
InterfaceAnswer stopAllProfiles() const;
|
||||
/**
|
||||
* @brief method which switchs to selected profile and returns its status
|
||||
* @remark both netctl and netctl-auto
|
||||
@ -200,26 +200,26 @@ public:
|
||||
* @return InterfaceAnswer::True if profile is active
|
||||
* @return InterfaceAnswer::Error if an error occurs
|
||||
*/
|
||||
InterfaceAnswer switchToProfile(const QString profile);
|
||||
InterfaceAnswer switchToProfile(const QString profile) const;
|
||||
// information
|
||||
/**
|
||||
* @brief method which returns general information
|
||||
* @remark both netctl and netctl-auto
|
||||
* @return netctlInformation structure
|
||||
*/
|
||||
netctlInformation information();
|
||||
netctlInformation information() const;
|
||||
/**
|
||||
* @brief method which reads settings from profile
|
||||
* @param profile profile name
|
||||
* @return settings from profile
|
||||
*/
|
||||
QMap<QString, QString> profileSettings(const QString profile);
|
||||
QMap<QString, QString> profileSettings(const QString profile) const;
|
||||
/**
|
||||
* @brief method which returns current status
|
||||
* @remark both netctl and netctl-auto
|
||||
* @return netctlCurrent structure
|
||||
*/
|
||||
netctlCurrent status();
|
||||
netctlCurrent status() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -52,21 +52,21 @@ public:
|
||||
/**
|
||||
* @brief Netctl class destructor
|
||||
*/
|
||||
~NetctlProfile();
|
||||
virtual ~NetctlProfile();
|
||||
/**
|
||||
* @brief method which copies temporary profile to PROFILE_DIR
|
||||
* @param oldPath path to temprorary profile
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool copyProfile(const QString oldPath);
|
||||
bool copyProfile(const QString oldPath) const;
|
||||
/**
|
||||
* @brief method which creates temporary profile
|
||||
* @param profile profile name
|
||||
* @param settings profile configuration. All available keys will be printed to the profile
|
||||
* @return temporary profile name
|
||||
*/
|
||||
QString createProfile(const QString profile, const QMap<QString, QString> settings);
|
||||
QString createProfile(const QString profile, const QMap<QString, QString> settings) const;
|
||||
/**
|
||||
* @brief method which check system configuration and return recommended values to keys
|
||||
* @return recommended parametrs
|
||||
@ -77,28 +77,28 @@ public:
|
||||
* @param profile profile name
|
||||
* @return settings from profile
|
||||
*/
|
||||
QMap<QString, QString> getSettingsFromProfile(const QString profile);
|
||||
QMap<QString, QString> getSettingsFromProfile(const QString profile) const;
|
||||
/**
|
||||
* @brief method which return value from profile by key
|
||||
* @param profile profile name
|
||||
* @param key required key
|
||||
* @return value by key
|
||||
*/
|
||||
QString getValueFromProfile(const QString profile, const QString key);
|
||||
QString getValueFromProfile(const QString profile, const QString key) const;
|
||||
/**
|
||||
* @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);
|
||||
QStringList getValuesFromProfile(const QString profile, const QStringList keys) const;
|
||||
/**
|
||||
* @brief method which removes profile
|
||||
* @param profile profile name
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool removeProfile(const QString profile);
|
||||
bool removeProfile(const QString profile) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -108,15 +108,15 @@ private:
|
||||
/**
|
||||
* @brief use RootProcess instead of QProcess. Default is true
|
||||
*/
|
||||
bool useSuid = true;
|
||||
bool useSuid;
|
||||
/**
|
||||
* @brief directory which contains profiles. Default is "/etc/netctl"
|
||||
*/
|
||||
QDir *profileDirectory = nullptr;
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
* @brief path to sudo command. Default is "kdesu"
|
||||
*/
|
||||
QString sudoCommand = QString("/usr/bin/kdesu");
|
||||
QString sudoCommand;
|
||||
};
|
||||
|
||||
|
||||
|
@ -111,14 +111,14 @@ public:
|
||||
/**
|
||||
* @brief WpaSup class destructor
|
||||
*/
|
||||
~WpaSup();
|
||||
virtual ~WpaSup();
|
||||
// general information
|
||||
/**
|
||||
* @brief method which gets profile name by ESSID
|
||||
* @param essid ESSID name
|
||||
* @return profile name
|
||||
*/
|
||||
QString existentProfile(const QString essid);
|
||||
QString existentProfile(const QString essid) const;
|
||||
/**
|
||||
* @brief method which check system configuration and return recommended values to keys
|
||||
* @return recommended parametrs
|
||||
@ -130,14 +130,7 @@ public:
|
||||
* @return false if profile is inactive
|
||||
* @return true if profile is active
|
||||
*/
|
||||
bool isProfileActive(const QString essid);
|
||||
/**
|
||||
* @brief method which checks profile existence by ESSID
|
||||
* @param essid ESSID name
|
||||
* @return false if profile does not exist
|
||||
* @return true if profile exists
|
||||
*/
|
||||
Q_DECL_DEPRECATED bool isProfileExists(const QString essid);
|
||||
bool isProfileActive(const QString essid) const;
|
||||
|
||||
public slots:
|
||||
// functions
|
||||
@ -145,24 +138,24 @@ public slots:
|
||||
* @brief method which returns active point information
|
||||
* @return current point information
|
||||
*/
|
||||
netctlWifiInfo current();
|
||||
netctlWifiInfo current() const;
|
||||
/**
|
||||
* @brief method which scans WiFi networks
|
||||
* @return list of essids
|
||||
*/
|
||||
QList<netctlWifiInfo> scanWifi();
|
||||
QList<netctlWifiInfo> scanWifi() const;
|
||||
/**
|
||||
* @brief method which calls wpa_supplicant
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool startWpaSupplicant();
|
||||
bool startWpaSupplicant() const;
|
||||
/**
|
||||
* @brief method which send TERMINATE signal to wpa_supplicant
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool stopWpaSupplicant();
|
||||
bool stopWpaSupplicant() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
@ -180,54 +173,54 @@ private:
|
||||
/**
|
||||
* @brief use RootProcess instead of QProcess. Default is true
|
||||
*/
|
||||
bool useSuid = true;
|
||||
bool useSuid;
|
||||
/**
|
||||
* @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant"
|
||||
*/
|
||||
QString ctrlDir = QString("/run/wpa_supplicant");
|
||||
QString ctrlDir;
|
||||
/**
|
||||
* @brief group which is owner of CTRL_DIR. Default is "users"
|
||||
*/
|
||||
QString ctrlGroup = QString("users");
|
||||
QString ctrlGroup;
|
||||
/**
|
||||
* @brief wpa_supplicant PID file. $i is interface. Default is "/run/wpa_supplicant_$i.pid"
|
||||
*/
|
||||
QString pidFile = QString("/run/wpa_supplicant_$i.pid");
|
||||
QString pidFile;
|
||||
/**
|
||||
* @brief path to sudo command. Default is "/usr/bin/kdesu"
|
||||
* @brief path to sudo command. Default is "kdesu"
|
||||
*/
|
||||
QString sudoCommand = QString("/usr/bin/kdesu");
|
||||
QString sudoCommand;
|
||||
/**
|
||||
* @brief path to wpa_cli command. Default is "/usr/bin/wpa_cli"
|
||||
* @brief path to wpa_cli command. Default is "wpa_cli"
|
||||
*/
|
||||
QString wpaCliPath = QString("/usr/bin/wpa_cli");
|
||||
QString wpaCliPath;
|
||||
/**
|
||||
* @brief wpa_supplicant drivers comma separated. Default is "nl80211,wext"
|
||||
*/
|
||||
QString wpaDrivers = QString("nl80211,wext");
|
||||
QString wpaDrivers;
|
||||
/**
|
||||
* @brief path to wpa_supplicant command. Default is "/usr/bin/wpa_supplicant"
|
||||
* @brief path to wpa_supplicant command. Default is "wpa_supplicant"
|
||||
*/
|
||||
QString wpaSupPath = QString("/usr/bin/wpa_supplicant");
|
||||
QString wpaSupPath;
|
||||
// functions
|
||||
/**
|
||||
* @brief method which calls wpa_cli and returns its output
|
||||
* @param commandLine command which will be passed to wpa_cli
|
||||
* @return wpa_cli output
|
||||
*/
|
||||
QString getWpaCliOutput(const QString commandLine);
|
||||
QString getWpaCliOutput(const QString commandLine) const;
|
||||
/**
|
||||
* @brief method which will be called to sleep thread
|
||||
* @param sec time interval, seconds
|
||||
*/
|
||||
bool waitForProcess(const int sec);
|
||||
bool waitForProcess(const int sec) const;
|
||||
/**
|
||||
* @brief method which calls wpa_cli
|
||||
* @param commandLine command which will be passed to wpa_cli
|
||||
* @return false if components are not found or command exit code is not equal to 0
|
||||
* @return true if the method was completed without errors
|
||||
*/
|
||||
bool wpaCliCall(const QString commandLine);
|
||||
bool wpaCliCall(const QString commandLine) const;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
# set files
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
if (USE_QT5)
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
|
||||
else ()
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
endif ()
|
||||
file (GLOB_RECURSE HEADERS *.h ${SUBPROJECT_INCLUDE_DIR}/*h
|
||||
${PROJECT_TRDPARTY_DIR}/task/*.h)
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class Netctl
|
||||
@ -42,27 +44,16 @@ Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
{
|
||||
netctlProfile = new NetctlProfile(debug, settings);
|
||||
|
||||
if (settings.contains(QString("IFACE_DIR")))
|
||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||
else
|
||||
ifaceDirectory = new QDir(QString("/sys/class/net/"));
|
||||
if (settings.contains(QString("PREFERED_IFACE")))
|
||||
mainInterface = settings[QString("PREFERED_IFACE")];
|
||||
if (settings.contains(QString("NETCTL_PATH")))
|
||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
||||
if (settings.contains(QString("NETCTLAUTO_PATH")))
|
||||
netctlAutoCommand = settings[QString("NETCTLAUTO_PATH")];
|
||||
if (settings.contains(QString("NETCTLAUTO_SERVICE")))
|
||||
netctlAutoService = settings[QString("NETCTLAUTO_SERVICE")];
|
||||
if (settings.contains(QString("SUDO_PATH")))
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
if (settings.contains(QString("SYSTEMCTL_PATH")))
|
||||
systemctlCommand = settings[QString("SYSTEMCTL_PATH")];
|
||||
if (settings.contains(QString("FORCE_SUDO")))
|
||||
useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
|
||||
ifaceDirectory = new QDir(settings.value(QString("IFACE_DIR"), QString(IFACE_DIR)));
|
||||
mainInterface = settings.value(QString("PREFERED_IFACE"), QString(PREFERED_IFACE));
|
||||
netctlCommand = settings.value(QString("NETCTL_PATH"), QString(NETCTL_PATH));
|
||||
netctlAutoCommand = settings.value(QString("NETCTLAUTO_PATH"), QString(NETCTLAUTO_PATH));
|
||||
netctlAutoService = settings.value(QString("NETCTLAUTO_SERVICE"), QString(NETCTLAUTO_SERVICE));
|
||||
sudoCommand = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH));
|
||||
systemctlCommand = settings.value(QString("SYSTEMCTL_PATH"), QString(SYSTEMCTL_PATH));
|
||||
useSuid = (settings.value(QString("FORCE_SUDO"), QString("true")) != QString("true"));
|
||||
|
||||
if (useSuid)
|
||||
sudoCommand = QString("");
|
||||
if (useSuid) sudoCommand = QString("");
|
||||
}
|
||||
|
||||
|
||||
@ -78,208 +69,61 @@ Netctl::~Netctl()
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
/**
|
||||
* @fn cmdCall
|
||||
*/
|
||||
bool Netctl::cmdCall(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
||||
if (command.isEmpty()) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
|
||||
return false;
|
||||
}
|
||||
|
||||
QString cmd = QString("");
|
||||
if (sudo)
|
||||
cmd = QString("%1 ").arg(sudoCommand);
|
||||
cmd += QString("%1 %2").arg(command).arg(commandLine);
|
||||
if (!argument.isEmpty())
|
||||
cmd += QString(" \"%1\"").arg(argument);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getCmdOutput
|
||||
*/
|
||||
QString Netctl::getCmdOutput(const bool sudo, const QString command, const QString commandLine, const QString argument)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
||||
if (command.isEmpty()) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find command";
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString cmd = QString("");
|
||||
if (sudo)
|
||||
cmd = QString("%1 ").arg(sudoCommand);
|
||||
cmd += QString("%1 %2").arg(command).arg(commandLine);
|
||||
if (!argument.isEmpty())
|
||||
cmd += QString(" \"%1\"").arg(argument);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return process.output;
|
||||
}
|
||||
|
||||
|
||||
// general information
|
||||
/**
|
||||
* @fn getActiveProfile
|
||||
*/
|
||||
QStringList Netctl::getActiveProfile()
|
||||
QStringList Netctl::getActiveProfile() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList profile;
|
||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileList();
|
||||
for (int i=0; i<fullProfilesInfo.count(); i++)
|
||||
if (fullProfilesInfo[i].active)
|
||||
profile.append(fullProfilesInfo[i].name);
|
||||
|
||||
return profile;
|
||||
return getActiveProfileTemplate(getProfileList());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoGetActiveProfile
|
||||
*/
|
||||
QString Netctl::autoGetActiveProfile()
|
||||
QStringList Netctl::autoGetActiveProfile() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = QString("");
|
||||
QList<netctlProfileInfo> fullProfilesInfo = getProfileListFromNetctlAuto();
|
||||
for (int i=0; i<fullProfilesInfo.count(); i++)
|
||||
if (fullProfilesInfo[i].active) {
|
||||
profile = fullProfilesInfo[i].name;
|
||||
break;
|
||||
}
|
||||
|
||||
return profile;
|
||||
return getActiveProfileTemplate(getProfileListFromNetctlAuto());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getProfileList
|
||||
*/
|
||||
QList<netctlProfileInfo> Netctl::getProfileList()
|
||||
QList<netctlProfileInfo> Netctl::getProfileList() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlProfileInfo> fullProfilesInfo;
|
||||
QStringList output = getCmdOutput(false, netctlCommand, QString("list"))
|
||||
.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<output.count(); i++) {
|
||||
netctlProfileInfo profileInfo;
|
||||
profileInfo.name = output[i].mid(2, -1);
|
||||
profileInfo.active = (output[i][0] == QChar('*'));
|
||||
profileInfo.enabled = isProfileEnabled(profileInfo.name);
|
||||
// external
|
||||
QStringList keys;
|
||||
keys.append(QString("Connection"));
|
||||
keys.append(QString("Description"));
|
||||
keys.append(QString("ESSID"));
|
||||
keys.append(QString("Interface"));
|
||||
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||
keys);
|
||||
profileInfo.description = profileValues[1];
|
||||
profileInfo.essid = profileValues[2];
|
||||
profileInfo.interface = profileValues[3];
|
||||
profileInfo.type = profileValues[0];
|
||||
profileInfo.netctlAuto = false;
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
|
||||
return fullProfilesInfo;
|
||||
return getProfileListTemplate(false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getProfileListFromNetctlAuto
|
||||
*/
|
||||
QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto()
|
||||
QList<netctlProfileInfo> Netctl::getProfileListFromNetctlAuto() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlProfileInfo> fullProfilesInfo;
|
||||
QStringList output = getCmdOutput(false, netctlAutoCommand, QString("list"))
|
||||
.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<output.count(); i++) {
|
||||
netctlProfileInfo profileInfo;
|
||||
profileInfo.name = output[i].mid(2, -1);
|
||||
profileInfo.active = (output[i][0] == QChar('*'));
|
||||
profileInfo.enabled = (output[i][0] != QChar('!'));
|
||||
// external
|
||||
QStringList keys;
|
||||
keys.append(QString("Connection"));
|
||||
keys.append(QString("Description"));
|
||||
keys.append(QString("ESSID"));
|
||||
keys.append(QString("Interface"));
|
||||
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||
keys);
|
||||
profileInfo.description = profileValues[1];
|
||||
profileInfo.essid = profileValues[2];
|
||||
profileInfo.interface = profileValues[3];
|
||||
profileInfo.type = profileValues[0];
|
||||
profileInfo.essid = profileValues[1];
|
||||
profileInfo.netctlAuto = true;
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
|
||||
return fullProfilesInfo;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getProfileDescription
|
||||
*/
|
||||
QString Netctl::getProfileDescription(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
if (netctlProfile == 0) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return QString();
|
||||
}
|
||||
|
||||
return netctlProfile->getValueFromProfile(profile, QString("Description"));
|
||||
return getProfileListTemplate(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getProfileStatus
|
||||
*/
|
||||
QString Netctl::getProfileStatus(const QString profile)
|
||||
QString Netctl::getProfileStatus(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
QString status;
|
||||
if (isProfileActive(profile))
|
||||
status = QString("active");
|
||||
else
|
||||
status = QString("inactive");
|
||||
if (isProfileEnabled(profile))
|
||||
status += QString(" (enabled)");
|
||||
else
|
||||
status += QString(" (static)");
|
||||
QString status = isProfileActive(profile) ? QString("active") : QString("inactive");
|
||||
status += isProfileEnabled(profile) ? QString(" (enabled)") : QString(" (static)");
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -288,42 +132,40 @@ QString Netctl::getProfileStatus(const QString profile)
|
||||
/**
|
||||
* @fn isProfileActive
|
||||
*/
|
||||
bool Netctl::isProfileActive(const QString profile)
|
||||
bool Netctl::isProfileActive(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
QString output = getCmdOutput(false, netctlCommand, QString("status"), profile);
|
||||
|
||||
return (output.contains(QString("Active: active")));
|
||||
return cmdCall(false, netctlCommand, QString("status"), profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn isProfileEnabled
|
||||
*/
|
||||
bool Netctl::isProfileEnabled(const QString profile)
|
||||
bool Netctl::isProfileEnabled(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return cmdCall(false, netctlCommand, QString("is-enabled"), profile);
|
||||
return cmdCall(false, netctlCommand, QString("is-enabled"), profile).output == QString("enabled\n");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoIsProfileActive
|
||||
*/
|
||||
bool Netctl::autoIsProfileActive(const QString profile)
|
||||
bool Netctl::autoIsProfileActive(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool status = false;
|
||||
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
if (profiles[i].name == profile) continue;
|
||||
status = profiles[i].active;
|
||||
foreach(netctlProfileInfo profileInfo, profiles) {
|
||||
if (profileInfo.name != profile) continue;
|
||||
status = profileInfo.active;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -334,16 +176,16 @@ bool Netctl::autoIsProfileActive(const QString profile)
|
||||
/**
|
||||
* @fn autoIsProfileEnabled
|
||||
*/
|
||||
bool Netctl::autoIsProfileEnabled(const QString profile)
|
||||
bool Netctl::autoIsProfileEnabled(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool status = false;
|
||||
QList<netctlProfileInfo> profiles = getProfileListFromNetctlAuto();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
if (profiles[i].name == profile) continue;
|
||||
status = profiles[i].enabled;
|
||||
foreach(netctlProfileInfo profileInfo, profiles) {
|
||||
if (profileInfo.name != profile) continue;
|
||||
status = profileInfo.enabled;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -354,7 +196,7 @@ bool Netctl::autoIsProfileEnabled(const QString profile)
|
||||
/**
|
||||
* @fn isNetctlAutoEnabled
|
||||
*/
|
||||
bool Netctl::isNetctlAutoEnabled()
|
||||
bool Netctl::isNetctlAutoEnabled() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlAutoService.isEmpty()) {
|
||||
@ -367,16 +209,16 @@ bool Netctl::isNetctlAutoEnabled()
|
||||
return false;
|
||||
}
|
||||
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||
|
||||
return cmdCall(false, systemctlCommand, QString("is-enabled"), argument);
|
||||
return cmdCall(false, systemctlCommand, QString("is-enabled"), argument).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn isNetctlAutoRunning
|
||||
*/
|
||||
bool Netctl::isNetctlAutoRunning()
|
||||
bool Netctl::isNetctlAutoRunning() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlAutoService.isEmpty()) {
|
||||
@ -389,9 +231,9 @@ bool Netctl::isNetctlAutoRunning()
|
||||
return false;
|
||||
}
|
||||
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||
|
||||
return cmdCall(false, systemctlCommand, QString("is-active"), argument);
|
||||
return cmdCall(false, systemctlCommand, QString("is-active"), argument).status();
|
||||
}
|
||||
|
||||
|
||||
@ -409,9 +251,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
||||
recommended.clear();
|
||||
recommended.append(QString("netctlgui-helper"));
|
||||
recommended.append(QString("netctlgui-helper-suid"));
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
break;
|
||||
}
|
||||
@ -437,9 +279,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
||||
settings[QString("NETCTL_PATH")] = QString("");
|
||||
recommended.clear();
|
||||
recommended.append("netctl");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("NETCTL_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -449,9 +291,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
||||
settings[QString("NETCTLAUTO_PATH")] = QString("");
|
||||
recommended.clear();
|
||||
recommended.append("netctl-auto");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("NETCTLAUTO_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -479,9 +321,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
||||
recommended.append("sudo");
|
||||
recommended.append("kdesu");
|
||||
recommended.append("gksu");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -491,9 +333,9 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
||||
settings[QString("SYSTEMCTL_PATH")] = QString("");
|
||||
recommended.clear();
|
||||
recommended.append("systemctl");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("SYSTEMCTL_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -506,7 +348,7 @@ QMap<QString, QString> Netctl::getRecommendedConfiguration()
|
||||
/**
|
||||
* @fn getWirelessInterfaceList
|
||||
*/
|
||||
QStringList Netctl::getWirelessInterfaceList()
|
||||
QStringList Netctl::getWirelessInterfaceList() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ifaceDirectory == nullptr) {
|
||||
@ -518,11 +360,11 @@ QStringList Netctl::getWirelessInterfaceList()
|
||||
if (!mainInterface.isEmpty())
|
||||
interfaces.append(mainInterface);
|
||||
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<allInterfaces.count(); i++) {
|
||||
QString dir = QString("%1/%2/wireless").arg(ifaceDirectory->path()).arg(allInterfaces[i]);
|
||||
foreach(QString interface, allInterfaces) {
|
||||
QString dir = QString("%1/%2/wireless").arg(ifaceDirectory->path()).arg(interface);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Check directory" << dir;
|
||||
if (QDir(dir).exists())
|
||||
interfaces.append(allInterfaces[i]);
|
||||
interfaces.append(interface);
|
||||
}
|
||||
|
||||
return interfaces;
|
||||
@ -533,159 +375,156 @@ QStringList Netctl::getWirelessInterfaceList()
|
||||
/**
|
||||
* @fn enableProfile
|
||||
*/
|
||||
bool Netctl::enableProfile(const QString profile)
|
||||
bool Netctl::enableProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (isProfileEnabled(profile))
|
||||
return cmdCall(true, netctlCommand, QString("disable"), profile);
|
||||
else
|
||||
return cmdCall(true, netctlCommand, QString("enable"), profile);
|
||||
return cmdCall(true, netctlCommand,
|
||||
isProfileEnabled(profile) ? QString("disable") : QString("enable"),
|
||||
profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn forceStartProfile
|
||||
*/
|
||||
bool Netctl::forceStartProfile(const QString profile)
|
||||
bool Netctl::forceStartProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return cmdCall(true, netctlCommand, QString("start"), profile);
|
||||
return cmdCall(true, netctlCommand, QString("start"), profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn forceStopProfile
|
||||
*/
|
||||
bool Netctl::forceStopProfile(const QString profile)
|
||||
bool Netctl::forceStopProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return cmdCall(true, netctlCommand, QString("stop"), profile);
|
||||
return cmdCall(true, netctlCommand, QString("stop"), profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn reenableProfile
|
||||
*/
|
||||
bool Netctl::reenableProfile(const QString profile)
|
||||
bool Netctl::reenableProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return cmdCall(true, netctlCommand, QString("reenable"), profile);
|
||||
return cmdCall(true, netctlCommand, QString("reenable"), profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn restartProfile
|
||||
*/
|
||||
bool Netctl::restartProfile(const QString profile)
|
||||
bool Netctl::restartProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return cmdCall(true, netctlCommand, QString("restart"), profile);
|
||||
return cmdCall(true, netctlCommand, QString("restart"), profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn startProfile
|
||||
*/
|
||||
bool Netctl::startProfile(const QString profile)
|
||||
bool Netctl::startProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (isProfileActive(profile))
|
||||
return cmdCall(true, netctlCommand, QString("stop"), profile);
|
||||
else
|
||||
return cmdCall(true, netctlCommand, QString("start"), profile);
|
||||
return cmdCall(true, netctlCommand,
|
||||
isProfileActive(profile) ? QString("stop") : QString("start"),
|
||||
profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn stopAllProfiles
|
||||
*/
|
||||
bool Netctl::stopAllProfiles()
|
||||
bool Netctl::stopAllProfiles() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return cmdCall(true, netctlCommand, QString("stop-all"));
|
||||
return cmdCall(true, netctlCommand, QString("stop-all")).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn switchToProfile
|
||||
*/
|
||||
bool Netctl::switchToProfile(const QString profile)
|
||||
bool Netctl::switchToProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return ((isProfileActive(profile)) ||
|
||||
(cmdCall(true, netctlCommand, QString("switch-to"), profile)));
|
||||
(cmdCall(true, netctlCommand, QString("switch-to"), profile)).status());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoDisableAllProfiles
|
||||
*/
|
||||
bool Netctl::autoDisableAllProfiles()
|
||||
bool Netctl::autoDisableAllProfiles() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return cmdCall(false, netctlAutoCommand, QString("disable-all"));
|
||||
return cmdCall(false, netctlAutoCommand, QString("disable-all")).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoEnableProfile
|
||||
*/
|
||||
bool Netctl::autoEnableProfile(const QString profile)
|
||||
bool Netctl::autoEnableProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (autoIsProfileEnabled(profile))
|
||||
return cmdCall(false, netctlAutoCommand, QString("disable"), profile);
|
||||
else
|
||||
return cmdCall(false, netctlAutoCommand, QString("enable"), profile);
|
||||
return cmdCall(false, netctlAutoCommand,
|
||||
autoIsProfileEnabled(profile) ? QString("disable") : QString("enable"),
|
||||
profile).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoEnableAllProfiles
|
||||
*/
|
||||
bool Netctl::autoEnableAllProfiles()
|
||||
bool Netctl::autoEnableAllProfiles() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return cmdCall(false, netctlAutoCommand, QString("enable-all"));
|
||||
return cmdCall(false, netctlAutoCommand, QString("enable-all")).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoStartProfile
|
||||
*/
|
||||
bool Netctl::autoStartProfile(const QString profile)
|
||||
bool Netctl::autoStartProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
return ((autoIsProfileActive(profile)) ||
|
||||
(cmdCall(false, netctlAutoCommand, QString("switch-to"), profile)));
|
||||
(cmdCall(false, netctlAutoCommand, QString("switch-to"), profile)).status());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoEnableService
|
||||
*/
|
||||
bool Netctl::autoEnableService()
|
||||
bool Netctl::autoEnableService() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlAutoService.isEmpty()) {
|
||||
@ -698,19 +537,18 @@ bool Netctl::autoEnableService()
|
||||
return false;
|
||||
}
|
||||
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||
|
||||
if (isNetctlAutoEnabled())
|
||||
return cmdCall(true, systemctlCommand, QString("disable"), argument);
|
||||
else
|
||||
return cmdCall(true, systemctlCommand, QString("enable"), argument);
|
||||
return cmdCall(true, systemctlCommand,
|
||||
isNetctlAutoEnabled() ? QString("disable") : QString("enable"),
|
||||
argument).status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoRestartService
|
||||
*/
|
||||
bool Netctl::autoRestartService()
|
||||
bool Netctl::autoRestartService() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlAutoService.isEmpty()) {
|
||||
@ -723,17 +561,17 @@ bool Netctl::autoRestartService()
|
||||
return false;
|
||||
}
|
||||
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||
|
||||
return ((!isNetctlAutoRunning()) ||
|
||||
(cmdCall(true, systemctlCommand, QString("restart"), argument)));
|
||||
(cmdCall(true, systemctlCommand, QString("restart"), argument)).status());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn autoStartService
|
||||
*/
|
||||
bool Netctl::autoStartService()
|
||||
bool Netctl::autoStartService() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlAutoService.isEmpty()) {
|
||||
@ -746,10 +584,87 @@ bool Netctl::autoStartService()
|
||||
return false;
|
||||
}
|
||||
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces[0]);
|
||||
QString argument = QString("%1@%2.service").arg(netctlAutoService).arg(interfaces.first());
|
||||
|
||||
if (isNetctlAutoRunning())
|
||||
return cmdCall(true, systemctlCommand, QString("stop"), argument);
|
||||
else
|
||||
return cmdCall(true, systemctlCommand, QString("start"), argument);
|
||||
return cmdCall(true, systemctlCommand,
|
||||
isNetctlAutoRunning() ? QString("stop") : QString("start"),
|
||||
argument).status();
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
/**
|
||||
* @fn cmdCall
|
||||
*/
|
||||
TaskResult Netctl::cmdCall(const bool sudo, const QString command,
|
||||
const QString commandLine, const QString argument) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << command;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command line" << commandLine;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Argument" << argument;
|
||||
|
||||
QString cmd = QString("");
|
||||
if (sudo) cmd = QString("%1 ").arg(sudoCommand);
|
||||
cmd += QString("%1 %2").arg(command).arg(commandLine);
|
||||
if (!argument.isEmpty()) cmd += QString(" \"%1\"").arg(argument);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, (useSuid && sudo));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return process;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @fn getActiveProfileTemplate
|
||||
*/
|
||||
QStringList Netctl::getActiveProfileTemplate(const QList<netctlProfileInfo> data) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList profiles;
|
||||
foreach(netctlProfileInfo profile, data) {
|
||||
if (!profile.active) continue;
|
||||
profiles.append(profile.name);
|
||||
}
|
||||
|
||||
return profiles;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getProfileListTemplate
|
||||
*/
|
||||
QList<netctlProfileInfo> Netctl::getProfileListTemplate(const bool isAuto) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlProfileInfo> fullProfilesInfo;
|
||||
QStringList output = QString(cmdCall(false, isAuto ? netctlAutoCommand : netctlCommand,
|
||||
QString("list")).output)
|
||||
.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
foreach(QString profile, output) {
|
||||
netctlProfileInfo profileInfo;
|
||||
profileInfo.name = profile.mid(2, -1);
|
||||
profileInfo.active = (profile[0] == QChar('*'));
|
||||
profileInfo.enabled = isAuto ? (profile[0] != QChar('!')) : isProfileEnabled(profileInfo.name);
|
||||
// external
|
||||
QStringList keys;
|
||||
keys.append(QString("Connection"));
|
||||
keys.append(QString("Description"));
|
||||
keys.append(QString("ESSID"));
|
||||
keys.append(QString("Interface"));
|
||||
QStringList profileValues = netctlProfile->getValuesFromProfile(profileInfo.name,
|
||||
keys);
|
||||
profileInfo.description = profileValues[1];
|
||||
profileInfo.essid = profileValues[2];
|
||||
profileInfo.interface = profileValues[3];
|
||||
profileInfo.type = profileValues[0];
|
||||
profileInfo.netctlAuto = isAuto;
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
|
||||
return fullProfilesInfo;
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ NetctlInterface::~NetctlInterface()
|
||||
/**
|
||||
* @fn connectToEssid
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::connectToEssid(const QString essid, QMap<QString, QString> settings)
|
||||
InterfaceAnswer NetctlInterface::connectToEssid(const QString essid,
|
||||
QMap<QString, QString> settings) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -83,7 +84,7 @@ InterfaceAnswer NetctlInterface::connectToEssid(const QString essid, QMap<QStrin
|
||||
/**
|
||||
* @fn connectToKnownEssid
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid)
|
||||
InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -105,7 +106,8 @@ InterfaceAnswer NetctlInterface::connectToKnownEssid(const QString essid)
|
||||
/**
|
||||
* @fn connectToUnknownEssid
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap<QString, QString> settings)
|
||||
InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid,
|
||||
QMap<QString, QString> settings) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -121,7 +123,7 @@ InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap
|
||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
if (interfaces.isEmpty()) return InterfaceAnswer::Error;
|
||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||
settings[QString("Interface")] = interfaces[0];
|
||||
settings[QString("Interface")] = interfaces.first();
|
||||
settings[QString("Connection")] = QString("wireless");
|
||||
settings[QString("ESSID")] = QString("'%1'").arg(essid);
|
||||
settings[QString("IP")] = QString("dhcp");
|
||||
@ -139,7 +141,8 @@ InterfaceAnswer NetctlInterface::connectToUnknownEssid(const QString essid, QMap
|
||||
/**
|
||||
* @fn createProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||
InterfaceAnswer NetctlInterface::createProfile(const QString profile,
|
||||
const QMap<QString, QString> settings) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -157,7 +160,7 @@ InterfaceAnswer NetctlInterface::createProfile(const QString profile, const QMap
|
||||
/**
|
||||
* @fn enableProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::enableProfile(const QString profile)
|
||||
InterfaceAnswer NetctlInterface::enableProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -174,7 +177,7 @@ InterfaceAnswer NetctlInterface::enableProfile(const QString profile)
|
||||
/**
|
||||
* @fn removeProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::removeProfile(const QString profile)
|
||||
InterfaceAnswer NetctlInterface::removeProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlProfile == nullptr) {
|
||||
@ -189,7 +192,7 @@ InterfaceAnswer NetctlInterface::removeProfile(const QString profile)
|
||||
/**
|
||||
* @fn restartProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::restartProfile(const QString profile)
|
||||
InterfaceAnswer NetctlInterface::restartProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -206,7 +209,7 @@ InterfaceAnswer NetctlInterface::restartProfile(const QString profile)
|
||||
/**
|
||||
* @fn startProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::startProfile(const QString profile)
|
||||
InterfaceAnswer NetctlInterface::startProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -227,7 +230,7 @@ InterfaceAnswer NetctlInterface::startProfile(const QString profile)
|
||||
/**
|
||||
* @fn stopAllProfiles
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::stopAllProfiles()
|
||||
InterfaceAnswer NetctlInterface::stopAllProfiles() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -242,7 +245,7 @@ InterfaceAnswer NetctlInterface::stopAllProfiles()
|
||||
/**
|
||||
* @fn switchToProfile
|
||||
*/
|
||||
InterfaceAnswer NetctlInterface::switchToProfile(const QString profile)
|
||||
InterfaceAnswer NetctlInterface::switchToProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -267,7 +270,7 @@ InterfaceAnswer NetctlInterface::switchToProfile(const QString profile)
|
||||
/**
|
||||
* @fn information
|
||||
*/
|
||||
netctlInformation NetctlInterface::information()
|
||||
netctlInformation NetctlInterface::information() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -288,7 +291,7 @@ netctlInformation NetctlInterface::information()
|
||||
/**
|
||||
* @fn profileSettings
|
||||
*/
|
||||
QMap<QString, QString> NetctlInterface::profileSettings(const QString profile)
|
||||
QMap<QString, QString> NetctlInterface::profileSettings(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlProfile == nullptr) {
|
||||
@ -303,7 +306,7 @@ QMap<QString, QString> NetctlInterface::profileSettings(const QString profile)
|
||||
/**
|
||||
* @fn status
|
||||
*/
|
||||
netctlCurrent NetctlInterface::status()
|
||||
netctlCurrent NetctlInterface::status() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (netctlCommand == nullptr) {
|
||||
@ -318,11 +321,11 @@ netctlCurrent NetctlInterface::status()
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
else
|
||||
profiles = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
current.profiles.append(profiles[i].name);
|
||||
if (!profiles[i].active) continue;
|
||||
current.current.append(profiles[i].name);
|
||||
current.enables.append(profiles[i].enabled);
|
||||
foreach(netctlProfileInfo profile, profiles) {
|
||||
current.profiles.append(profile.name);
|
||||
if (!profile.active) continue;
|
||||
current.current.append(profile.name);
|
||||
current.enables.append(profile.enabled);
|
||||
}
|
||||
|
||||
return current;
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class NetctlProfile
|
||||
@ -43,17 +45,11 @@
|
||||
NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
: debug(debugCmd)
|
||||
{
|
||||
if (settings.contains(QString("PROFILE_DIR")))
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
else
|
||||
profileDirectory = new QDir(QString("/etc/netctl/"));
|
||||
if (settings.contains(QString("SUDO_PATH")))
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
if (settings.contains(QString("FORCE_SUDO")))
|
||||
useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
|
||||
profileDirectory = new QDir(settings.value(QString("PROFILE_DIR"), QString(PROFILE_DIR)));
|
||||
sudoCommand = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH));
|
||||
useSuid = (settings.value(QString("FORCE_SUDO"), QString("true")) != QString("true"));
|
||||
|
||||
if (useSuid)
|
||||
sudoCommand = QString("");
|
||||
if (useSuid) sudoCommand = QString("");
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +67,7 @@ NetctlProfile::~NetctlProfile()
|
||||
/**
|
||||
* @fn copyProfile
|
||||
*/
|
||||
bool NetctlProfile::copyProfile(const QString oldPath)
|
||||
bool NetctlProfile::copyProfile(const QString oldPath) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Path" << oldPath;
|
||||
@ -87,17 +83,16 @@ bool NetctlProfile::copyProfile(const QString oldPath)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, useSuid);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
return process.status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn createProfile
|
||||
*/
|
||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
@ -108,22 +103,22 @@ QString NetctlProfile::createProfile(const QString profile, const QMap<QString,
|
||||
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return profileTempName;
|
||||
QTextStream out(&profileFile);
|
||||
for (int i=0; i<settings.keys().count(); i++) {
|
||||
out << settings.keys()[i] << QString("=");
|
||||
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
|
||||
(settings.keys()[i] == QString("After")) ||
|
||||
(settings.keys()[i] == QString("Address")) ||
|
||||
(settings.keys()[i] == QString("Routes")) ||
|
||||
(settings.keys()[i] == QString("Address6")) ||
|
||||
(settings.keys()[i] == QString("Routes6")) ||
|
||||
(settings.keys()[i] == QString("IPCustom")) ||
|
||||
(settings.keys()[i] == QString("DNS")) ||
|
||||
(settings.keys()[i] == QString("DNSOptions")) ||
|
||||
(settings.keys()[i] == QString("ScanFrequencies")) ||
|
||||
(settings.keys()[i] == QString("WPAConfigSection")))
|
||||
out << QString("(%1)").arg(settings[settings.keys()[i]]) << endl;
|
||||
foreach(QString key, settings.keys()) {
|
||||
out << key << QString("=");
|
||||
if ((key == QString("BindsToInterfaces")) ||
|
||||
(key == QString("After")) ||
|
||||
(key == QString("Address")) ||
|
||||
(key == QString("Routes")) ||
|
||||
(key == QString("Address6")) ||
|
||||
(key == QString("Routes6")) ||
|
||||
(key == QString("IPCustom")) ||
|
||||
(key == QString("DNS")) ||
|
||||
(key == QString("DNSOptions")) ||
|
||||
(key == QString("ScanFrequencies")) ||
|
||||
(key == QString("WPAConfigSection")))
|
||||
out << QString("(%1)").arg(settings[key]) << endl;
|
||||
else
|
||||
out << settings[settings.keys()[i]] << endl;
|
||||
out << settings[key] << endl;
|
||||
}
|
||||
profileFile.close();
|
||||
|
||||
@ -145,9 +140,9 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
|
||||
recommended.clear();
|
||||
recommended.append(QString("netctlgui-helper"));
|
||||
recommended.append(QString("netctlgui-helper-suid"));
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
break;
|
||||
}
|
||||
@ -172,9 +167,9 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
|
||||
recommended.append("sudo");
|
||||
recommended.append("kdesu");
|
||||
recommended.append("gksu");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -187,7 +182,7 @@ QMap<QString, QString> NetctlProfile::getRecommendedConfiguration()
|
||||
/**
|
||||
* @fn getSettingsFromProfile
|
||||
*/
|
||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
@ -202,13 +197,12 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QStringList output = QString(process.output).trimmed().split(QChar('\n'));
|
||||
QStringList systemVariables;
|
||||
systemVariables.append(QString("PIPESTATUS"));
|
||||
for (int i=0; i<output.count(); i++)
|
||||
systemVariables.append(output[i].split(QChar('='))[0]);
|
||||
foreach(QString str, output)
|
||||
systemVariables.append(str.split(QChar('=')).first());
|
||||
// profile variables
|
||||
QMap<QString, QString> settings;
|
||||
QString profileUrl = QString("%1/%2").arg(profileDirectory->absolutePath()).arg(QFileInfo(profile).fileName());
|
||||
@ -216,20 +210,19 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
output = QString(process.output).trimmed().split(QChar('\n'));
|
||||
|
||||
// read variables
|
||||
QStringList keys;
|
||||
for (int i=0; i<output.count(); i++)
|
||||
if (!systemVariables.contains(output[i].split(QChar('='))[0]))
|
||||
keys.append(output[i].split(QChar('='))[0]);
|
||||
for (int i=0; i<keys.count(); i++){
|
||||
cmd = QString("env -i bash -c \"source '%1'; for i in ${!%2[@]}; do echo ${%2[$i]}; done\"").arg(profileUrl).arg(keys[i]);
|
||||
foreach(QString str, output)
|
||||
if (!systemVariables.contains(str.split(QChar('=')).first()))
|
||||
keys.append(str.split(QChar('=')).first());
|
||||
foreach(QString key, keys) {
|
||||
cmd = QString("env -i bash -c \"source '%1'; for i in ${!%2[@]}; do echo ${%2[$i]}; done\"").arg(profileUrl).arg(key);
|
||||
process = runTask(cmd, false);
|
||||
settings[keys[i]] = process.output.trimmed();
|
||||
if (debug) qDebug() << PDEBUG << ":" << keys[i] << "=" << settings[keys[i]];
|
||||
settings[key] = process.output.trimmed();
|
||||
if (debug) qDebug() << PDEBUG << ":" << key << "=" << settings[key];
|
||||
}
|
||||
|
||||
return settings;
|
||||
@ -239,20 +232,20 @@ QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profi
|
||||
/**
|
||||
* @fn getValueFromProfile
|
||||
*/
|
||||
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key)
|
||||
QString NetctlProfile::getValueFromProfile(const QString profile, const QString key) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||
|
||||
return getValuesFromProfile(profile, QStringList() << key)[0];
|
||||
return getValuesFromProfile(profile, QStringList() << key).first();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getValuesFromProfile
|
||||
*/
|
||||
QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QStringList keys)
|
||||
QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QStringList keys) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
@ -260,8 +253,8 @@ QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QSt
|
||||
|
||||
QMap<QString, QString> settings = getSettingsFromProfile(profile);
|
||||
QStringList values;
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
values.append(settings[keys[i]]);
|
||||
foreach(QString key, keys)
|
||||
values.append(settings[key]);
|
||||
|
||||
return values;
|
||||
}
|
||||
@ -270,7 +263,7 @@ QStringList NetctlProfile::getValuesFromProfile(const QString profile, const QSt
|
||||
/**
|
||||
* @fn removeProfile
|
||||
*/
|
||||
bool NetctlProfile::removeProfile(const QString profile)
|
||||
bool NetctlProfile::removeProfile(const QString profile) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
@ -284,8 +277,7 @@ bool NetctlProfile::removeProfile(const QString profile)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, useSuid);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
return process.status();
|
||||
}
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class WpaSup
|
||||
@ -43,25 +45,16 @@ WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
|
||||
netctlCommand = new Netctl(debug, settings);
|
||||
netctlProfile = new NetctlProfile(debug, settings);
|
||||
|
||||
if (settings.contains(QString("CTRL_DIR")))
|
||||
ctrlDir = settings[QString("CTRL_DIR")];
|
||||
if (settings.contains(QString("CTRL_GROUP")))
|
||||
ctrlGroup = settings[QString("CTRL_GROUP")];
|
||||
if (settings.contains(QString("PID_FILE")))
|
||||
pidFile = settings[QString("PID_FILE")];
|
||||
if (settings.contains(QString("SUDO_PATH")))
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
if (settings.contains(QString("WPACLI_PATH")))
|
||||
wpaCliPath = settings[QString("WPACLI_PATH")];
|
||||
if (settings.contains(QString("WPA_DRIVERS")))
|
||||
wpaDrivers = settings[QString("WPA_DRIVERS")];
|
||||
if (settings.contains(QString("WPASUP_PATH")))
|
||||
wpaSupPath = settings[QString("WPASUP_PATH")];
|
||||
if (settings.contains(QString("FORCE_SUDO")))
|
||||
useSuid = (settings[QString("FORCE_SUDO")] != QString("true"));
|
||||
ctrlDir = settings.value(QString("CTRL_DIR"), QString(CTRL_DIR));
|
||||
ctrlGroup = settings.value(QString("CTRL_GROUP"), QString(CTRL_GROUP));
|
||||
pidFile = settings.value(QString("PID_FILE"), QString(PID_FILE));
|
||||
sudoCommand = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH));
|
||||
wpaCliPath = settings.value(QString("WPACLI_PATH"), QString(WPACLI_PATH));
|
||||
wpaDrivers = settings.value(QString("WPA_DRIVERS"), QString(WPA_DRIVERS));
|
||||
wpaSupPath = settings.value(QString("WPASUP_PATH"), QString(WPASUP_PATH));
|
||||
useSuid = (settings.value(QString("FORCE_SUDO"), QString("true")) != QString("true"));
|
||||
|
||||
if (useSuid)
|
||||
sudoCommand = QString("");
|
||||
if (useSuid) sudoCommand = QString("");
|
||||
}
|
||||
|
||||
|
||||
@ -81,7 +74,7 @@ WpaSup::~WpaSup()
|
||||
/**
|
||||
* @fn existentProfile
|
||||
*/
|
||||
QString WpaSup::existentProfile(const QString essid)
|
||||
QString WpaSup::existentProfile(const QString essid) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||
@ -94,11 +87,11 @@ QString WpaSup::existentProfile(const QString essid)
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString profileFile = QString("");
|
||||
QString profileFile;
|
||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (essid != profileList[i].essid) continue;
|
||||
profileFile = profileList[i].name;
|
||||
foreach(netctlProfileInfo profile, profileList) {
|
||||
if (essid != profile.essid) continue;
|
||||
profileFile = profile.name;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -121,16 +114,16 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
||||
// ctrl group
|
||||
// check group list and find out 'network', 'users', 'root'
|
||||
settings[QString("CTRL_GROUP")] = QString("");
|
||||
gid_t gtpList[99];
|
||||
gid_t gtpList[size];
|
||||
int grpSize = getgroups(size, gtpList);
|
||||
recommended.clear();
|
||||
recommended.append("network");
|
||||
recommended.append("users");
|
||||
recommended.append("root");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
for (int j=0; j<grpSize; j++)
|
||||
if (recommended[i] == QString(getgrgid(gtpList[j])->gr_name)) {
|
||||
settings[QString("CTRL_GROUP")] = recommended[i];
|
||||
foreach(QString rec, recommended) {
|
||||
for (int i=0; i<grpSize; i++)
|
||||
if (rec == QString(getgrgid(gtpList[i])->gr_name)) {
|
||||
settings[QString("CTRL_GROUP")] = rec;
|
||||
break;
|
||||
}
|
||||
if (!settings[QString("CTRL_GROUP")].isEmpty()) break;
|
||||
@ -141,9 +134,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
||||
recommended.clear();
|
||||
recommended.append(QString("netctlgui-helper"));
|
||||
recommended.append(QString("netctlgui-helper-suid"));
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
break;
|
||||
}
|
||||
@ -158,9 +151,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
||||
recommended.append("sudo");
|
||||
recommended.append("kdesu");
|
||||
recommended.append("gksu");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("SUDO_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -170,9 +163,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
||||
settings[QString("WPACLI_PATH")] = QString("true");
|
||||
recommended.clear();
|
||||
recommended.append("wpa_cli");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("WPACLI_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -185,9 +178,9 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
||||
settings[QString("WPASUP_PATH")] = QString("true");
|
||||
recommended.clear();
|
||||
recommended.append("wpa_supplicant");
|
||||
for (int i=0; i<recommended.count(); i++) {
|
||||
process = runTask(QString("which %1").arg(recommended[i]), false);
|
||||
if (process.exitCode == 0) {
|
||||
foreach(QString rec, recommended) {
|
||||
process = runTask(QString("which %1").arg(rec), false);
|
||||
if (process.status()) {
|
||||
settings[QString("WPASUP_PATH")] = process.output.trimmed();
|
||||
break;
|
||||
}
|
||||
@ -200,7 +193,7 @@ QMap<QString, QString> WpaSup::getRecommendedConfiguration()
|
||||
/**
|
||||
* @fn isProfileActive
|
||||
*/
|
||||
bool WpaSup::isProfileActive(const QString essid)
|
||||
bool WpaSup::isProfileActive(const QString essid) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||
@ -213,50 +206,14 @@ bool WpaSup::isProfileActive(const QString essid)
|
||||
return false;
|
||||
}
|
||||
|
||||
QString profileFile;
|
||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (essid != profileList[i].essid) continue;
|
||||
profileFile = profileList[i].name;
|
||||
break;
|
||||
}
|
||||
|
||||
return netctlCommand->isProfileActive(profileFile);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn isProfileExists
|
||||
*/
|
||||
bool WpaSup::isProfileExists(const QString essid)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||
if (netctlCommand == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return false;
|
||||
}
|
||||
if (netctlProfile == nullptr) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find library";
|
||||
return false;
|
||||
}
|
||||
|
||||
bool exists = false;
|
||||
QList<netctlProfileInfo> profileList = netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (essid != profileList[i].essid) continue;
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return exists;
|
||||
return netctlCommand->isProfileActive(existentProfile(essid));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn current
|
||||
*/
|
||||
netctlWifiInfo WpaSup::current()
|
||||
netctlWifiInfo WpaSup::current() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (pidFile.isEmpty()) {
|
||||
@ -269,7 +226,7 @@ netctlWifiInfo WpaSup::current()
|
||||
return netctlWifiInfo();
|
||||
}
|
||||
QString _pidFile = pidFile;
|
||||
_pidFile.replace(QString("$i"), interfaces[0]);
|
||||
_pidFile.replace(QString("$i"), interfaces.first());
|
||||
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
||||
|
||||
netctlWifiInfo current;
|
||||
@ -278,21 +235,21 @@ netctlWifiInfo WpaSup::current()
|
||||
if (!rawText.contains(QString("wpa_state=COMPLETED\n"))) return current;
|
||||
|
||||
QStringList rawList = rawText.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
QStringList line = rawList[i].split(QChar('='));
|
||||
foreach(QString element, rawList) {
|
||||
QStringList line = element.split(QChar('='));
|
||||
if (line.count() != 2) continue;
|
||||
if (line[0] == QString("bssid"))
|
||||
current.macs.append(line[1]);
|
||||
else if (line[0] == QString("freq")) {
|
||||
if ((line[1].toInt() >= 5000) && (line[1].toInt() < 6000))
|
||||
if (line.at(0) == QString("bssid"))
|
||||
current.macs.append(line.at(1));
|
||||
else if (line.at(0) == QString("freq")) {
|
||||
if ((line.at(1).toInt() >= 5000) && (line.at(1).toInt() < 6000))
|
||||
current.type = PointType::FiveG;
|
||||
else if ((line[1].toInt() < 5000) && (line[1].toInt() > 2000))
|
||||
else if ((line.at(1).toInt() < 5000) && (line.at(1).toInt() > 2000))
|
||||
current.type = PointType::TwoG;
|
||||
current.frequencies.append(line[1].toInt());
|
||||
} else if (line[0] == QString("ssid"))
|
||||
current.name = line[1];
|
||||
else if (line[0] == QString("key_mgmt")) {
|
||||
QString security = line[1];
|
||||
current.frequencies.append(line.at(1).toInt());
|
||||
} else if (line.at(0) == QString("ssid"))
|
||||
current.name = line.at(1);
|
||||
else if (line.at(0) == QString("key_mgmt")) {
|
||||
QString security = line.at(1);
|
||||
if (security.contains(QString("WPA2")))
|
||||
security = QString("WPA2");
|
||||
else if (security.contains(QString("WPA")))
|
||||
@ -316,7 +273,7 @@ netctlWifiInfo WpaSup::current()
|
||||
/**
|
||||
* @fn scanWifi
|
||||
*/
|
||||
QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||
QList<netctlWifiInfo> WpaSup::scanWifi() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (pidFile.isEmpty()) {
|
||||
@ -329,7 +286,7 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||
return QList<netctlWifiInfo>();
|
||||
}
|
||||
QString _pidFile = pidFile;
|
||||
_pidFile.replace(QString("$i"), interfaces[0]);
|
||||
_pidFile.replace(QString("$i"), interfaces.first());
|
||||
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
||||
|
||||
bool terminateOnExit = (!QFile(_pidFile).exists());
|
||||
@ -346,26 +303,32 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||
rawList.removeFirst();
|
||||
QStringList names;
|
||||
|
||||
QList<netctlProfileInfo> profiles = netctlCommand->getProfileList();
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
QStringList line = rawList[i].split(QChar('\t'));
|
||||
// init profile list
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (netctlCommand->isNetctlAutoRunning())
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
else
|
||||
profiles = netctlCommand->getProfileList();
|
||||
// iterate by wifi output
|
||||
foreach(QString element, rawList) {
|
||||
QStringList line = element.split(QChar('\t'));
|
||||
if (line.count() != 5) continue;
|
||||
QString name = line[4];
|
||||
QString name = line.at(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].toInt());
|
||||
scanResults[index].macs.append(line[0]);
|
||||
if (scanResults[index].signal < line[2].toInt())
|
||||
scanResults[index].signal = line[2].toInt();
|
||||
scanResults[index].frequencies.append(line.at(1).toInt());
|
||||
scanResults[index].macs.append(line.at(0));
|
||||
if (scanResults[index].signal < line.at(2).toInt())
|
||||
scanResults[index].signal = line.at(2).toInt();
|
||||
// check type
|
||||
if ((line[1].toInt() >= 5000) && (line[1].toInt() < 6000)) {
|
||||
if ((line.at(1).toInt() >= 5000) && (line.at(1).toInt() < 6000)) {
|
||||
if (scanResults[index].type == PointType::None)
|
||||
scanResults[index].type = PointType::FiveG;
|
||||
else if (scanResults[index].type == PointType::TwoG)
|
||||
scanResults[index].type = PointType::TwoAndFiveG;
|
||||
} else if ((line[1].toInt() < 5000) && (line[1].toInt() > 2000)) {
|
||||
} else if ((line.at(1).toInt() < 5000) && (line.at(1).toInt() > 2000)) {
|
||||
if (scanResults[index].type == PointType::None)
|
||||
scanResults[index].type = PointType::TwoG;
|
||||
else if (scanResults[index].type == PointType::FiveG)
|
||||
@ -382,28 +345,28 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||
netctlProfileInfo profile;
|
||||
profile.name = QString("");
|
||||
profile.active = false;
|
||||
for (int j=0; j<profiles.count(); j++) {
|
||||
if (wifiPoint.name != profiles[j].essid) continue;
|
||||
profile = profiles[j];
|
||||
foreach(netctlProfileInfo pr, profiles) {
|
||||
if (wifiPoint.name != pr.essid) continue;
|
||||
profile = pr;
|
||||
break;
|
||||
}
|
||||
wifiPoint.active = profile.active;
|
||||
wifiPoint.exists = (!profile.name.isEmpty());
|
||||
// mac
|
||||
wifiPoint.macs.append(line[0]);
|
||||
wifiPoint.macs.append(line.at(0));
|
||||
// frequencies
|
||||
wifiPoint.frequencies.append(line[1].toInt());
|
||||
wifiPoint.frequencies.append(line.at(1).toInt());
|
||||
// type
|
||||
// check type
|
||||
if ((line[1].toInt() >= 5000) && (line[1].toInt() < 6000)) {
|
||||
if ((line.at(1).toInt() >= 5000) && (line.at(1).toInt() < 6000)) {
|
||||
wifiPoint.type = PointType::FiveG;
|
||||
} else if ((line[1].toInt() < 5000) && (line[1].toInt() > 2000)) {
|
||||
} else if ((line.at(1).toInt() < 5000) && (line.at(1).toInt() > 2000)) {
|
||||
wifiPoint.type = PointType::TwoG;
|
||||
}
|
||||
// point signal
|
||||
wifiPoint.signal = line[2].toInt();
|
||||
wifiPoint.signal = line.at(2).toInt();
|
||||
// point security
|
||||
QString security = line[3];
|
||||
QString security = line.at(3);
|
||||
if (security.contains(QString("WPA2")))
|
||||
security = QString("WPA2");
|
||||
else if (security.contains(QString("WPA")))
|
||||
@ -427,7 +390,7 @@ QList<netctlWifiInfo> WpaSup::scanWifi()
|
||||
/**
|
||||
* @fn startWpaSupplicant
|
||||
*/
|
||||
bool WpaSup::startWpaSupplicant()
|
||||
bool WpaSup::startWpaSupplicant() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ctrlDir.isEmpty()) {
|
||||
@ -460,28 +423,27 @@ bool WpaSup::startWpaSupplicant()
|
||||
return false;
|
||||
}
|
||||
QString _pidFile = pidFile;
|
||||
_pidFile.replace(QString("$i"), interfaces[0]);
|
||||
_pidFile.replace(QString("$i"), interfaces.first());
|
||||
if (debug) qDebug() << PDEBUG << ":" << "PID file" << _pidFile << QFile(_pidFile).exists();
|
||||
|
||||
if (QFile(_pidFile).exists()) return (QFileInfo(ctrlDir).group() == ctrlGroup);
|
||||
QString cmd = QString("%1 %2 -B -P \"%3\" -i %4 -D %5 -C \"DIR=%6 GROUP=%7\"")
|
||||
.arg(sudoCommand).arg(wpaSupPath).arg(_pidFile).arg(interfaces[0])
|
||||
.arg(sudoCommand).arg(wpaSupPath).arg(_pidFile).arg(interfaces.first())
|
||||
.arg(wpaDrivers).arg(ctrlDir).arg(ctrlGroup);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, useSuid);
|
||||
waitForProcess(1);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
return process.status();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn stopWpaSupplicant
|
||||
*/
|
||||
bool WpaSup::stopWpaSupplicant()
|
||||
bool WpaSup::stopWpaSupplicant() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -493,7 +455,7 @@ bool WpaSup::stopWpaSupplicant()
|
||||
/**
|
||||
* @fn getWpaCliOutput
|
||||
*/
|
||||
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||
QString WpaSup::getWpaCliOutput(const QString commandLine) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
||||
@ -508,15 +470,14 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||
QStringList interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
if (interfaces.isEmpty()) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not find interfaces";
|
||||
return false;
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces[0]).arg(ctrlDir).arg(commandLine);
|
||||
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces.first()).arg(ctrlDir).arg(commandLine);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return process.output;
|
||||
}
|
||||
@ -525,7 +486,7 @@ QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||
/**
|
||||
* @fn waitForProcess
|
||||
*/
|
||||
bool WpaSup::waitForProcess(const int sec)
|
||||
bool WpaSup::waitForProcess(const int sec) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Interval" << sec;
|
||||
@ -540,7 +501,7 @@ bool WpaSup::waitForProcess(const int sec)
|
||||
/**
|
||||
* @fn wpaCliCall
|
||||
*/
|
||||
bool WpaSup::wpaCliCall(const QString commandLine)
|
||||
bool WpaSup::wpaCliCall(const QString commandLine) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Command" << commandLine;
|
||||
@ -558,13 +519,12 @@ bool WpaSup::wpaCliCall(const QString commandLine)
|
||||
return false;
|
||||
}
|
||||
|
||||
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces[0]).arg(ctrlDir).arg(commandLine);
|
||||
QString cmd = QString("%1 -i %2 -p %3 %4").arg(wpaCliPath).arg(interfaces.first()).arg(ctrlDir).arg(commandLine);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
waitForProcess(1);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
return process.status();
|
||||
}
|
||||
|
@ -154,8 +154,8 @@ QMap<QString, QString> Netctl::readDataEngineConfiguration()
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl")).toString();
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto")).toString();
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("netctl")).toString();
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("netctl-auto")).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("External IP"));
|
||||
@ -836,12 +836,12 @@ void Netctl::configChanged()
|
||||
KConfigGroup cg = config();
|
||||
|
||||
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
||||
paths[QString("gui")] = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
|
||||
paths[QString("helper")] = cg.readEntry("helperPath", "/usr/bin/netctlgui-helper");
|
||||
paths[QString("netctl")] = cg.readEntry("netctlPath", "/usr/bin/netctl");
|
||||
paths[QString("netctlAuto")] = cg.readEntry("netctlAutoPath", "/usr/bin/netctl-auto");
|
||||
paths[QString("sudo")] = cg.readEntry("sudoPath", "/usr/bin/kdesu");
|
||||
paths[QString("wifi")] = cg.readEntry("wifiPath", "/usr/bin/netctl-gui -t 3");
|
||||
paths[QString("gui")] = cg.readEntry("guiPath", "netctl-gui");
|
||||
paths[QString("helper")] = cg.readEntry("helperPath", "netctlgui-helper");
|
||||
paths[QString("netctl")] = cg.readEntry("netctlPath", "netctl");
|
||||
paths[QString("netctlAuto")] = cg.readEntry("netctlAutoPath", "netctl-auto");
|
||||
paths[QString("sudo")] = cg.readEntry("sudoPath", "kdesu");
|
||||
paths[QString("wifi")] = cg.readEntry("wifiPath", "netctl-gui -t 3");
|
||||
useSudo = cg.readEntry("useSudo", true);
|
||||
useWifi = cg.readEntry("useWifi", false);
|
||||
useHelper = cg.readEntry("useHelper", true);
|
||||
|
@ -12,7 +12,7 @@ X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=netctl
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui/
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/netctl-gui/
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
|
@ -15,7 +15,7 @@ X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=org.kde.plasma.netctl
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/netctl-gui
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
|
@ -11,22 +11,22 @@
|
||||
<default>100</default>
|
||||
</entry>
|
||||
<entry name="guiPath" type="string">
|
||||
<default>/usr/bin/netctl-gui</default>
|
||||
<default>netctl-gui</default>
|
||||
</entry>
|
||||
<entry name="helperPath" type="string">
|
||||
<default>/usr/bin/netctlgui-helper</default>
|
||||
<default>netctlgui-helper</default>
|
||||
</entry>
|
||||
<entry name="netctlPath" type="string">
|
||||
<default>/usr/bin/netctl</default>
|
||||
<default>netctl</default>
|
||||
</entry>
|
||||
<entry name="netctlAutoPath" type="string">
|
||||
<default>/usr/bin/netctl-auto</default>
|
||||
<default>netctl-auto</default>
|
||||
</entry>
|
||||
<entry name="sudoPath" type="string">
|
||||
<default>/usr/bin/kdesu</default>
|
||||
<default>kdesu</default>
|
||||
</entry>
|
||||
<entry name="wifiPath" type="string">
|
||||
<default>/usr/bin/netctl-gui -t 3</default>
|
||||
<default>netctl-gui -t 3</default>
|
||||
</entry>
|
||||
<entry name="useHelper" type="bool">
|
||||
<default>true</default>
|
||||
|
@ -24,16 +24,20 @@ import org.kde.plasma.private.netctl 1.0
|
||||
|
||||
Item {
|
||||
id: aboutPage
|
||||
// backend
|
||||
NetctlAdds {
|
||||
id: netctlAdds;
|
||||
}
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
implicitWidth: pageColumn.implicitWidth
|
||||
implicitHeight: pageColumn.implicitHeight
|
||||
|
||||
property bool debug: NetctlAdds.isDebugEnabled()
|
||||
property bool debug: netctlAdds.isDebugEnabled()
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
QtControls.TabView {
|
||||
height: parent.height
|
||||
width: parent.width
|
||||
@ -44,20 +48,21 @@ Item {
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: NetctlAdds.getAboutText("header")
|
||||
text: netctlAdds.getAboutText("header")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
text: NetctlAdds.getAboutText("description")
|
||||
text: netctlAdds.getAboutText("description")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
textFormat: Text.RichText
|
||||
text: NetctlAdds.getAboutText("links")
|
||||
text: netctlAdds.getAboutText("links")
|
||||
onLinkActivated: Qt.openUrlExternally(link);
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
@ -65,7 +70,7 @@ Item {
|
||||
font.capitalization: Font.SmallCaps
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
textFormat: Text.RichText
|
||||
text: NetctlAdds.getAboutText("copy")
|
||||
text: netctlAdds.getAboutText("copy")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -77,14 +82,15 @@ Item {
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
text: NetctlAdds.getAboutText("translators")
|
||||
text: netctlAdds.getAboutText("translators")
|
||||
}
|
||||
|
||||
QtControls.Label {
|
||||
QtLayouts.Layout.fillWidth: true
|
||||
horizontalAlignment: Text.AlignJustify
|
||||
textFormat: Text.RichText
|
||||
text: NetctlAdds.getAboutText("3rdparty")
|
||||
text: netctlAdds.getAboutText("3rdparty")
|
||||
onLinkActivated: Qt.openUrlExternally(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,16 @@ import org.kde.plasma.private.netctl 1.0
|
||||
|
||||
Item {
|
||||
id: appearancePage
|
||||
// backend
|
||||
NetctlAdds {
|
||||
id: netctlAdds;
|
||||
}
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
implicitWidth: pageColumn.implicitWidth
|
||||
implicitHeight: pageColumn.implicitHeight
|
||||
|
||||
property bool debug: NetctlAdds.isDebugEnabled()
|
||||
property bool debug: netctlAdds.isDebugEnabled()
|
||||
property variant weight: {
|
||||
25: 0,
|
||||
50: 1,
|
||||
@ -52,7 +56,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
@ -110,7 +114,10 @@ Item {
|
||||
id: selectFont
|
||||
width: parent.width * 2 / 3
|
||||
text: plasmoid.configuration.fontFamily
|
||||
onClicked: fontDialog.visible = true
|
||||
onClicked: {
|
||||
fontDialog.setFont()
|
||||
fontDialog.visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,21 +315,28 @@ Item {
|
||||
id: colorDialog
|
||||
title: i18n("Select a color")
|
||||
color: selectColor.text
|
||||
onAccepted: {
|
||||
selectColor.text = colorDialog.color
|
||||
}
|
||||
onAccepted: selectColor.text = colorDialog.color
|
||||
}
|
||||
|
||||
QtDialogs.FontDialog {
|
||||
id: fontDialog
|
||||
title: i18n("Select a font")
|
||||
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
|
||||
signal setFont
|
||||
|
||||
onAccepted: {
|
||||
selectFont.text = fontDialog.font.family
|
||||
fontSize.value = fontDialog.font.pointSize
|
||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||
}
|
||||
onSetFont: {
|
||||
fontDialog.font = Qt.font({
|
||||
family: selectFont.text,
|
||||
pointSize: fontSize.value > 0 ? fontSize.value : 12,
|
||||
italic: fontStyle.currentIndex == 1,
|
||||
weight: Font.Normal,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -26,18 +26,22 @@ import org.kde.plasma.private.netctl 1.0
|
||||
|
||||
Item {
|
||||
id: dataenginePage
|
||||
// backend
|
||||
NetctlAdds {
|
||||
id: netctlAdds;
|
||||
}
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
implicitWidth: pageColumn.implicitWidth
|
||||
implicitHeight: pageColumn.implicitHeight
|
||||
|
||||
property bool debug: NetctlAdds.isDebugEnabled()
|
||||
property bool debug: netctlAdds.isDebugEnabled()
|
||||
|
||||
property variant cfg_dataengine: NetctlAdds.readDataEngineConfiguration()
|
||||
property variant cfg_dataengine: netctlAdds.readDataEngineConfiguration()
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
@ -228,6 +232,6 @@ Item {
|
||||
Component.onDestruction: {
|
||||
cfg_dataengine["EXTIP4"] = extIp4.checked ? "true" : "false"
|
||||
cfg_dataengine["EXTIP6"] = extIp6.checked ? "true" : "false"
|
||||
NetctlAdds.writeDataEngineConfiguration(cfg_dataengine)
|
||||
netctlAdds.writeDataEngineConfiguration(cfg_dataengine)
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import QtQuick 2.4
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Layouts 1.1
|
||||
import org.kde.plasma.plasmoid 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
@ -26,10 +27,14 @@ import org.kde.plasma.private.netctl 1.0
|
||||
|
||||
Item {
|
||||
id: main
|
||||
// backend
|
||||
NetctlAdds {
|
||||
id: netctlAdds;
|
||||
}
|
||||
|
||||
// variables
|
||||
// internal
|
||||
property bool debug: NetctlAdds.isDebugEnabled()
|
||||
property bool debug: netctlAdds.isDebugEnabled()
|
||||
property variant fontWeight: {
|
||||
"light": Font.Light,
|
||||
"normal": Font.Normal,
|
||||
@ -51,8 +56,9 @@ Item {
|
||||
}
|
||||
property string sudoPath: plasmoid.configuration.useSudo ? plasmoid.configuration.sudoPath : ""
|
||||
// signals
|
||||
signal needUpdate
|
||||
signal needMenuUpdate
|
||||
signal needIconUpdate(string newIcon)
|
||||
signal needTextUpdate(string newText, string newToolTip)
|
||||
signal needMenuUpdate(string current, string stringStatus, bool status)
|
||||
|
||||
// init
|
||||
Plasmoid.icon: iconPath["false"]
|
||||
@ -70,13 +76,13 @@ Item {
|
||||
onNewData: {
|
||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||
|
||||
NetctlAdds.setDataBySource(sourceName, data)
|
||||
netctlAdds.setDataBySource(sourceName, data)
|
||||
}
|
||||
}
|
||||
|
||||
// ui
|
||||
Grid {
|
||||
id: mainGrid
|
||||
GridLayout {
|
||||
anchors.fill: parent
|
||||
columns: 2
|
||||
|
||||
Image {
|
||||
@ -91,6 +97,7 @@ Item {
|
||||
font.pointSize: plasmoid.configuration.fontSize
|
||||
font.weight: fontWeight[plasmoid.configuration.fontWeight]
|
||||
horizontalAlignment: align[plasmoid.configuration.textAlign]
|
||||
renderType: Text.NativeRendering
|
||||
textFormat: Text.RichText
|
||||
text: "N\\A"
|
||||
}
|
||||
@ -108,37 +115,30 @@ Item {
|
||||
plasmoid.setAction("restartProfile", i18n("Restart profile"), "view-refresh")
|
||||
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
||||
plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi")
|
||||
// helper
|
||||
if (plasmoid.configuration.useHelper) {
|
||||
NetctlAdds.runCmd(plasmoid.configuration.helperPath)
|
||||
plasmoid.configuration.useHelper = NetctlAdds.checkHelperStatus()
|
||||
}
|
||||
// init submodule
|
||||
Plasmoid.userConfiguringChanged(false)
|
||||
|
||||
NetctlAdds.needToBeUpdated.connect(needUpdate)
|
||||
netctlAdds.needIconToBeUpdated.connect(needIconUpdate)
|
||||
netctlAdds.needMenuUpdate.connect(needMenuUpdate)
|
||||
netctlAdds.needTextToBeUpdated.connect(needTextUpdate)
|
||||
}
|
||||
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
onNeedIconUpdate: {
|
||||
if (debug) console.log("[main::onNeedIconUpdate]")
|
||||
|
||||
var iconStatus = NetctlAdds.valueByKey("active")
|
||||
icon.source = iconPath[iconStatus]
|
||||
Plasmoid.icon = iconPath[iconStatus]
|
||||
text.text = NetctlAdds.parsePattern(plasmoid.configuration.textPattern)
|
||||
Plasmoid.toolTipSubText = NetctlAdds.valueByKey("info")
|
||||
needMenuUpdate()
|
||||
// updae geometry
|
||||
text.update()
|
||||
icon.height = text.contentHeight
|
||||
icon.width = text.contentHeight
|
||||
icon.update()
|
||||
height = text.contentHeight
|
||||
width = icon.paintedWidth + text.contentWidth
|
||||
update()
|
||||
icon.source = iconPath[newIcon]
|
||||
Plasmoid.icon = iconPath[newIcon]
|
||||
}
|
||||
|
||||
onNeedTextUpdate: {
|
||||
if (debug) console.log("[main::onNeedTextUpdate]")
|
||||
|
||||
text.text = newText
|
||||
Plasmoid.toolTipSubText = newToolTip
|
||||
}
|
||||
|
||||
onNeedMenuUpdate: {
|
||||
if (debug) console.log("[main::onNetctlStateChanged]")
|
||||
if (debug) console.log("[main::onNeedMenuUpdate]")
|
||||
|
||||
var titleAction = plasmoid.action("titleAction")
|
||||
var startAction = plasmoid.action("startProfile")
|
||||
@ -149,10 +149,6 @@ Item {
|
||||
var enableAction = plasmoid.action("enableProfile")
|
||||
var wifiAction = plasmoid.action("startWifi")
|
||||
|
||||
var current = NetctlAdds.valueByKey("current")
|
||||
var status = NetctlAdds.valueByKey("active") == "true"
|
||||
var stringStatus = NetctlAdds.valueByKey("status")
|
||||
|
||||
titleAction.iconSource = plasmoid.icon
|
||||
titleAction.text = current + " " + stringStatus
|
||||
|
||||
@ -194,16 +190,29 @@ Item {
|
||||
wifiAction.visible = plasmoid.configuration.useWifi
|
||||
}
|
||||
|
||||
Plasmoid.onUserConfiguringChanged: {
|
||||
if (plasmoid.userConfiguring) return
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
// helper
|
||||
if (plasmoid.configuration.useHelper) {
|
||||
netctlAdds.runCmd(plasmoid.configuration.helperPath)
|
||||
plasmoid.configuration.useHelper = netctlAdds.checkHelperStatus()
|
||||
}
|
||||
// init submodule
|
||||
netctlAdds.setPattern(plasmoid.configuration.textPattern)
|
||||
}
|
||||
|
||||
function action_titleAction() {
|
||||
if (debug) console.log("[main::action_titleAction]")
|
||||
|
||||
NetctlAdds.runCmd(plasmoid.configuration.guiPath)
|
||||
netctlAdds.runCmd(plasmoid.configuration.guiPath)
|
||||
}
|
||||
|
||||
function action_startProfile() {
|
||||
if (debug) console.log("[main::action_startProfile]")
|
||||
|
||||
NetctlAdds.startProfileSlot(plasmoid.configuration.useHelper,
|
||||
netctlAdds.startProfileSlot(plasmoid.configuration.useHelper,
|
||||
plasmoid.configuration.netctlPath,
|
||||
sudoPath)
|
||||
}
|
||||
@ -211,7 +220,7 @@ Item {
|
||||
function action_stopProfile() {
|
||||
if (debug) console.log("[main::action_stopProfile]")
|
||||
|
||||
NetctlAdds.stopProfileSlot(plasmoid.configuration.useHelper,
|
||||
netctlAdds.stopProfileSlot(plasmoid.configuration.useHelper,
|
||||
plasmoid.configuration.netctlPath,
|
||||
sudoPath)
|
||||
}
|
||||
@ -219,7 +228,7 @@ Item {
|
||||
function action_stopAllProfiles() {
|
||||
if (debug) console.log("[main::action_stopAllProfiles]")
|
||||
|
||||
NetctlAdds.stopAllProfilesSlot(plasmoid.configuration.useHelper,
|
||||
netctlAdds.stopAllProfilesSlot(plasmoid.configuration.useHelper,
|
||||
plasmoid.configuration.netctlPath,
|
||||
sudoPath)
|
||||
}
|
||||
@ -227,14 +236,14 @@ Item {
|
||||
function action_switchToProfile() {
|
||||
if (debug) console.log("[main::action_switchToProfile]")
|
||||
|
||||
NetctlAdds.switchToProfileSlot(plasmoid.configuration.useHelper,
|
||||
netctlAdds.switchToProfileSlot(plasmoid.configuration.useHelper,
|
||||
plasmoid.configuration.netctlAutoPath)
|
||||
}
|
||||
|
||||
function action_restartProfile() {
|
||||
if (debug) console.log("[main::action_restartProfile]")
|
||||
|
||||
NetctlAdds.restartProfileSlot(plasmoid.configuration.useHelper,
|
||||
netctlAdds.restartProfileSlot(plasmoid.configuration.useHelper,
|
||||
plasmoid.configuration.netctlPath,
|
||||
sudoPath)
|
||||
}
|
||||
@ -242,7 +251,7 @@ Item {
|
||||
function action_enableProfile() {
|
||||
if (debug) console.log("[main::action_enableProfile]")
|
||||
|
||||
NetctlAdds.enableProfileSlot(plasmoid.configuration.useHelper,
|
||||
netctlAdds.enableProfileSlot(plasmoid.configuration.useHelper,
|
||||
plasmoid.configuration.netctlPath,
|
||||
sudoPath)
|
||||
}
|
||||
@ -250,6 +259,6 @@ Item {
|
||||
function action_startWifi() {
|
||||
if (debug) console.log("[main::action_startWifi]")
|
||||
|
||||
NetctlAdds.runCmd(plasmoid.configuration.wifiPath)
|
||||
netctlAdds.runCmd(plasmoid.configuration.wifiPath)
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,15 @@ import org.kde.plasma.private.netctl 1.0
|
||||
|
||||
Item {
|
||||
id: widgetPage
|
||||
NetctlAdds {
|
||||
id: netctlAdds;
|
||||
}
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
implicitWidth: pageColumn.implicitWidth
|
||||
implicitHeight: pageColumn.implicitHeight
|
||||
|
||||
property bool debug: NetctlAdds.isDebugEnabled()
|
||||
property bool debug: netctlAdds.isDebugEnabled()
|
||||
|
||||
property alias cfg_autoUpdateInterval: autoUpdate.value
|
||||
property alias cfg_guiPath: guiPath.text
|
||||
@ -48,7 +51,7 @@ Item {
|
||||
|
||||
Column {
|
||||
id: pageColumn
|
||||
width: units.gridUnit * 25
|
||||
anchors.fill: parent
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
22
sources/plasmoid-kf5/package/metadata.desktop
Normal file
22
sources/plasmoid-kf5/package/metadata.desktop
Normal file
@ -0,0 +1,22 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Netctl
|
||||
Comment=Plasmoid for netctl
|
||||
Type=Service
|
||||
Icon=netctl-gui-widget
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/main.qml
|
||||
X-Plasma-NotificationArea=true
|
||||
X-Plasma-RemoteLocation=
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=org.kde.plasma.netctl
|
||||
X-KDE-PluginInfo-Version=1.4.9
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/netctl-gui
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
@ -1,4 +1,5 @@
|
||||
set (PLUGIN_NAME netctlplugin)
|
||||
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.netctl\")
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Qml_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||
@ -20,7 +21,7 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${Qt_INCLUDE}
|
||||
${Kf5_INCLUDE})
|
||||
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
|
||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||
|
@ -21,18 +21,9 @@
|
||||
#include "netctladds.h"
|
||||
|
||||
|
||||
static QObject *netctl_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine);
|
||||
Q_UNUSED(scriptEngine);
|
||||
|
||||
return new NetctlAdds();
|
||||
}
|
||||
|
||||
|
||||
void NetctlPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.netctl"));
|
||||
|
||||
qmlRegisterSingletonType<NetctlAdds>(uri, 1, 0, "NetctlAdds", netctl_singletontype_provider);
|
||||
qmlRegisterType<NetctlAdds>(uri, 1, 0, "NetctlAdds");
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ NetctlAdds::NetctlAdds(QObject *parent)
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
connect(this, SIGNAL(needToNotify(bool)), this, SLOT(notifyAboutStatusChanging(bool)));
|
||||
connect(this, SIGNAL(needToBeUpdated()), this, SLOT(parsePattern()));
|
||||
}
|
||||
|
||||
|
||||
@ -48,7 +51,33 @@ NetctlAdds::~NetctlAdds()
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVariant> args)
|
||||
void NetctlAdds::notifyAboutStatusChanging(const bool currentStatus) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << currentStatus;
|
||||
|
||||
if (currentStatus)
|
||||
return NetctlAdds::sendNotification(QString("Info"), i18n("Network status has been changed to active"));
|
||||
else
|
||||
return NetctlAdds::sendNotification(QString("Info"), i18n("Network status has been changed to inactive"));
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::parsePattern() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString parsed = pattern;
|
||||
foreach(QString value, values.keys())
|
||||
parsed.replace(QString("$%1").arg(value), values[value]);
|
||||
// fix newline
|
||||
parsed.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return emit(needTextToBeUpdated(parsed, values[QString("info")]));
|
||||
}
|
||||
|
||||
|
||||
QVariantList NetctlAdds::sendDBusRequest(const QString cmd, const QVariantList args) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
@ -57,26 +86,24 @@ QList<QVariant> NetctlAdds::sendDBusRequest(const QString cmd, const QList<QVari
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, cmd);
|
||||
if (!args.isEmpty())
|
||||
request.setArguments(args);
|
||||
if (!args.isEmpty()) request.setArguments(args);
|
||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
if (arguments.size() == 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
QVariantList arguments = response.arguments();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdds::checkHelperStatus()
|
||||
bool NetctlAdds::checkHelperStatus() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return sendDBusRequest(QString("Active"), QList<QVariant>()).isEmpty();
|
||||
return !sendDBusRequest(QString("Active")).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdds::getAboutText(const QString type)
|
||||
QString NetctlAdds::getAboutText(const QString type) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Type" << type;
|
||||
@ -104,9 +131,9 @@ QString NetctlAdds::getAboutText(const QString type)
|
||||
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<trdPartyList.count(); i++)
|
||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
||||
.arg(trdPartyList[i].split(QChar(','))[0])
|
||||
.arg(trdPartyList[i].split(QChar(','))[1])
|
||||
.arg(trdPartyList[i].split(QChar(','))[2]);
|
||||
.arg(trdPartyList.at(i).split(QChar(',')).at(0))
|
||||
.arg(trdPartyList.at(i).split(QChar(',')).at(1))
|
||||
.arg(trdPartyList.at(i).split(QChar(',')).at(2));
|
||||
text = i18n("This software uses: %1", trdPartyList.join(QString(", ")));
|
||||
}
|
||||
|
||||
@ -114,7 +141,7 @@ QString NetctlAdds::getAboutText(const QString type)
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdds::isDebugEnabled()
|
||||
bool NetctlAdds::isDebugEnabled() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -122,21 +149,7 @@ bool NetctlAdds::isDebugEnabled()
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdds::parsePattern(const QString pattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString parsed = pattern;
|
||||
for (int i=0; i<values.keys().count(); i++)
|
||||
parsed.replace(QString("$%1").arg(values.keys()[i]), valueByKey(values.keys()[i]));
|
||||
// fix newline
|
||||
parsed.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::runCmd(const QString cmd)
|
||||
void NetctlAdds::runCmd(const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
@ -148,7 +161,7 @@ void NetctlAdds::runCmd(const QString cmd)
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::setDataBySource(const QString sourceName, const QMap<QString, QVariant> data)
|
||||
void NetctlAdds::setDataBySource(const QString sourceName, const QVariantMap data)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||
@ -156,35 +169,46 @@ void NetctlAdds::setDataBySource(const QString sourceName, const QMap<QString, Q
|
||||
|
||||
bool needUpdate = (values[sourceName] != data[QString("value")].toString());
|
||||
values[sourceName] = data[QString("value")].toString();
|
||||
if ((needUpdate) && (sourceName == QString("active"))) {
|
||||
if (values[sourceName] == QString("true"))
|
||||
sendNotification(QString("Info"), i18n("Network status has been changed to active"));
|
||||
else
|
||||
sendNotification(QString("Info"), i18n("Network status has been changed to inactive"));
|
||||
}
|
||||
|
||||
if (needUpdate) emit(needToBeUpdated());
|
||||
if (needUpdate) {
|
||||
if (sourceName == QString("active")) {
|
||||
emit(needToNotify(values[QString("active")] == QString("true")));
|
||||
emit(needIconToBeUpdated(values[QString("active")]));
|
||||
}
|
||||
emit(needToBeUpdated());
|
||||
emit(needMenuUpdate(values[QString("current")], values[QString("status")],
|
||||
values[QString("active")] == QString("true")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::setPattern(const QString _pattern)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Pattern" << _pattern;
|
||||
|
||||
pattern = _pattern;
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
||||
{
|
||||
// since it is a static method we need to identify is debug enabled again
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
bool debugLocal = (debugEnv == QString("yes"));
|
||||
|
||||
if (debugLocal) qDebug() << PDEBUG;
|
||||
if (debugLocal) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
||||
if (debugLocal) qDebug() << PDEBUG << ":" << "Message" << message;
|
||||
|
||||
KNotification *notification = KNotification::event(eventId, QString("Netctl ::: %1").arg(eventId), message);
|
||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.netctl"));
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdds::valueByKey(const QString key)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||
|
||||
return values[key];
|
||||
}
|
||||
|
||||
|
||||
// context menu
|
||||
void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||
void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -197,82 +221,75 @@ void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, cons
|
||||
sendNotification(QString("Info"), i18n("Set profile %1 enabled", values[QString("current")]));
|
||||
}
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
QVariantList args;
|
||||
args.append(values[QString("current")]);
|
||||
sendDBusRequest(QString("Enable"), args);
|
||||
} else {
|
||||
QProcess command;
|
||||
QString commandLine = QString("%1 %2%3%4").arg(sudoCmd).arg(cmd).arg(enableStatus).arg(values[QString("current")]);
|
||||
command.startDetached(commandLine);
|
||||
runCmd(QString("%1 %2%3%4").arg(sudoCmd).arg(cmd).arg(enableStatus).arg(values[QString("current")]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::restartProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||
void NetctlAdds::restartProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
sendNotification(QString("Info"), i18n("Restart profile %1", values[QString("current")]));
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
QVariantList args;
|
||||
args.append(values[QString("current")]);
|
||||
sendDBusRequest(QString("Restart"), args);
|
||||
} else {
|
||||
QProcess command;
|
||||
QString commandLine = QString("%1 %2 restart %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]);
|
||||
command.startDetached(commandLine);
|
||||
runCmd(QString("%1 %2 restart %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::startProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||
void NetctlAdds::startProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
||||
bool ok;
|
||||
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
||||
QString profile = QInputDialog::getItem(nullptr, i18n("Select profile"), i18n("Profile:"),
|
||||
profiles, 0, false, &ok);
|
||||
if (!ok || profile.isEmpty()) return;
|
||||
|
||||
sendNotification(QString("Info"), i18n("Start profile %1", profile));
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
QVariantList args;
|
||||
args.append(profile);
|
||||
if (values[QString("active")] == QString("true"))
|
||||
sendDBusRequest(QString("SwitchTo"), args);
|
||||
else
|
||||
sendDBusRequest(QString("Start"), args);
|
||||
} else {
|
||||
QProcess command;
|
||||
QString commandLine = QString("%1 %2").arg(sudoCmd).arg(cmd);
|
||||
if (values[QString("active")] == QString("true"))
|
||||
commandLine += QString(" switch-to %1").arg(profile);
|
||||
else
|
||||
commandLine += QString(" start %1").arg(profile);
|
||||
command.startDetached(commandLine);
|
||||
runCmd(commandLine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::stopProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||
void NetctlAdds::stopProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
sendNotification(QString("Info"), i18n("Stop profile %1", values[QString("current")]));
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
QVariantList args;
|
||||
args.append(values[QString("current")]);
|
||||
sendDBusRequest(QString("Start"), args);
|
||||
} else {
|
||||
QProcess command;
|
||||
QString commandLine = QString("%1 %2 stop %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]);
|
||||
command.startDetached(commandLine);
|
||||
runCmd(QString("%1 %2 stop %3").arg(sudoCmd).arg(cmd).arg(values[QString("current")]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||
void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, const QString sudoCmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -280,49 +297,45 @@ void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, co
|
||||
if (useHelper)
|
||||
sendDBusRequest(QString("StopAll"), QList<QVariant>());
|
||||
else {
|
||||
QProcess command;
|
||||
QString commandLine = QString("%1 %2 stop-all").arg(sudoCmd).arg(cmd);
|
||||
command.startDetached(commandLine);
|
||||
runCmd(QString("%1 %2 stop-all").arg(sudoCmd).arg(cmd));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::switchToProfileSlot(const bool useHelper, const QString cmd)
|
||||
void NetctlAdds::switchToProfileSlot(const bool useHelper, const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
||||
bool ok;
|
||||
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
||||
QString profile = QInputDialog::getItem(nullptr, i18n("Select profile"), i18n("Profile:"),
|
||||
profiles, 0, false, &ok);
|
||||
if (!ok || profile.isEmpty()) return;
|
||||
|
||||
sendNotification(QString("Info"), i18n("Switch to profile %1", profile));
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
QVariantList args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(QString("autoStart"), args);
|
||||
} else {
|
||||
QProcess command;
|
||||
QString commandLine = QString("%1 switch-to %2").arg(cmd).arg(profile);
|
||||
command.startDetached(commandLine);
|
||||
runCmd(QString("%1 switch-to %2").arg(cmd).arg(profile));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> NetctlAdds::readDataEngineConfiguration()
|
||||
QVariantMap NetctlAdds::readDataEngineConfiguration() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QVariant> configuration;
|
||||
QVariantMap configuration;
|
||||
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-netctl.conf"));
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl"));
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("netctl"));
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("netctl-auto"));
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("External IP"));
|
||||
@ -336,7 +349,7 @@ QMap<QString, QVariant> NetctlAdds::readDataEngineConfiguration()
|
||||
}
|
||||
|
||||
|
||||
void NetctlAdds::writeDataEngineConfiguration(const QMap<QString, QVariant> configuration)
|
||||
void NetctlAdds::writeDataEngineConfiguration(const QVariantMap configuration) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
|
@ -32,43 +32,52 @@ public:
|
||||
NetctlAdds(QObject *parent = 0);
|
||||
~NetctlAdds();
|
||||
|
||||
Q_INVOKABLE bool checkHelperStatus();
|
||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||
Q_INVOKABLE void runCmd(const QString cmd);
|
||||
Q_INVOKABLE void setDataBySource(const QString sourceName, const QMap<QString, QVariant> data);
|
||||
Q_INVOKABLE bool checkHelperStatus() const;
|
||||
Q_INVOKABLE QString getAboutText(const QString type = QString("header")) const;
|
||||
Q_INVOKABLE bool isDebugEnabled() const;
|
||||
Q_INVOKABLE void runCmd(const QString cmd) const;
|
||||
Q_INVOKABLE void setDataBySource(const QString sourceName, const QVariantMap data);
|
||||
Q_INVOKABLE void setPattern(const QString _pattern);
|
||||
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message);
|
||||
Q_INVOKABLE QString valueByKey(const QString key);
|
||||
// context menu
|
||||
Q_INVOKABLE void enableProfileSlot(const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl"),
|
||||
const QString sudoCmd = QString(""));
|
||||
const QString cmd = QString("netctl"),
|
||||
const QString sudoCmd = QString("")) const;
|
||||
Q_INVOKABLE void restartProfileSlot(const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl"),
|
||||
const QString sudoCmd = QString(""));
|
||||
const QString cmd = QString("netctl"),
|
||||
const QString sudoCmd = QString("")) const;
|
||||
Q_INVOKABLE void startProfileSlot(const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl"),
|
||||
const QString sudoCmd = QString(""));
|
||||
const QString cmd = QString("netctl"),
|
||||
const QString sudoCmd = QString("")) const;
|
||||
Q_INVOKABLE void stopProfileSlot(const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl"),
|
||||
const QString sudoCmd = QString(""));
|
||||
const QString cmd = QString("netctl"),
|
||||
const QString sudoCmd = QString("")) const;
|
||||
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl"),
|
||||
const QString sudoCmd = QString(""));
|
||||
const QString cmd = QString("netctl"),
|
||||
const QString sudoCmd = QString("")) const;
|
||||
Q_INVOKABLE void switchToProfileSlot(const bool useHelper = true,
|
||||
const QString cmd = QString("/usr/bin/netctl-auto"));
|
||||
const QString cmd = QString("netctl-auto")) const;
|
||||
// dataengine
|
||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||
Q_INVOKABLE QVariantMap readDataEngineConfiguration() const;
|
||||
Q_INVOKABLE void writeDataEngineConfiguration(const QVariantMap configuration) const;
|
||||
|
||||
signals:
|
||||
void needToBeUpdated();
|
||||
void needIconToBeUpdated(const QString newIcon) const;
|
||||
void needMenuUpdate(const QString current, const QString status, const bool isActive) const;
|
||||
void needTextToBeUpdated(const QString newText, const QString newToolTip) const;
|
||||
void needToBeUpdated() const;
|
||||
void needToNotify(const bool currentStatus) const;
|
||||
|
||||
private slots:
|
||||
void notifyAboutStatusChanging(const bool currentStatus) const;
|
||||
void parsePattern() const;
|
||||
|
||||
private:
|
||||
bool debug = false;
|
||||
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
||||
QMap<QString, QString> values;
|
||||
QVariantList sendDBusRequest(const QString cmd,
|
||||
const QVariantList args = QVariantList()) const;
|
||||
QString pattern;
|
||||
QHash<QString, QString> values;
|
||||
};
|
||||
|
||||
|
||||
|
@ -65,6 +65,21 @@
|
||||
<translation>This software uses: %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BondWidget</name>
|
||||
<message>
|
||||
<source>Bond settings</source>
|
||||
<translation>Bond settings</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Mode</source>
|
||||
<translation>Mode</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>The bonding policy. See the kernel documentation on bonding for details</source>
|
||||
<translation>The bonding policy. See the kernel documentation on bonding for details</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BridgeWidget</name>
|
||||
<message>
|
||||
@ -190,6 +205,10 @@
|
||||
<source>IP address does not match the standard</source>
|
||||
<translation>IP address does not match the standard</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Key is required for 'gre' mode</source>
|
||||
<translation>Key is required for 'gre' mode</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EthernetWidget</name>
|
||||
@ -281,6 +300,14 @@
|
||||
<source>Maximum time, in seconds, to wait for 802.1x authentication to succeed</source>
|
||||
<translation>Maximum time, in seconds, to wait for 802.1x authentication to succeed</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Priority</source>
|
||||
<translation>Priority</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Priority level of the profile. In case of automatic profile selection, profiles are tried in decreasing order of priority</source>
|
||||
<translation>Priority level of the profile. In case of automatic profile selection, profiles are tried in decreasing order of priority</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GeneralWidget</name>
|
||||
@ -376,6 +403,14 @@
|
||||
<source>A description of the profile</source>
|
||||
<translation>A description of the profile</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Whether or not to exclude this profile from automatic profile selection</source>
|
||||
<translation>Whether or not to exclude this profile from automatic profile selection</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Exclude auto</source>
|
||||
<translation>Exclude auto</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>IpWidget</name>
|
||||
@ -1519,6 +1554,30 @@ Should be according to standards</translation>
|
||||
<source>Browse</source>
|
||||
<translation>Browse</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select chat file</source>
|
||||
<translation>Select chat file</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>All (*.*)</source>
|
||||
<translation>All (*.*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Init</source>
|
||||
<translation>Init</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>An initialization string sent to the modem before dialing</source>
|
||||
<translation>An initialization string sent to the modem before dialing</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Chat script</source>
|
||||
<translation>Chat script</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Path to a chat file</source>
|
||||
<translation>Path to a chat file</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetctlAutoWindow</name>
|
||||
@ -2285,6 +2344,14 @@ Should be according to standards</translation>
|
||||
<source>External editor</source>
|
||||
<translation>External editor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Main tab autoupdate, sec</source>
|
||||
<translation>Main tab autoupdate, sec</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WiFi tab autoupdate, sec</source>
|
||||
<translation>WiFi tab autoupdate, sec</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TrayIcon</name>
|
||||
@ -2459,6 +2526,14 @@ Should be according to standards</translation>
|
||||
<source>The address of the remote end of the tunnel</source>
|
||||
<translation>The address of the remote end of the tunnel</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Key</source>
|
||||
<translation>Key</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>A key identifying an individual traffic flow within a tunnel</source>
|
||||
<translation>A key identifying an individual traffic flow within a tunnel</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TuntapWidget</name>
|
||||
@ -2801,11 +2876,11 @@ Should be according to standards</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Whether or not to exclude this profile from automatic profile selection</source>
|
||||
<translation>Whether or not to exclude this profile from automatic profile selection</translation>
|
||||
<translation type="vanished">Whether or not to exclude this profile from automatic profile selection</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Exclude auto</source>
|
||||
<translation>Exclude auto</translation>
|
||||
<translation type="vanished">Exclude auto</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Frequency</source>
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -65,6 +65,21 @@
|
||||
<translation>Данное приложение использует: %1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BondWidget</name>
|
||||
<message>
|
||||
<source>Bond settings</source>
|
||||
<translation>Настройки bond соединения</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Mode</source>
|
||||
<translation>Режим</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>The bonding policy. See the kernel documentation on bonding for details</source>
|
||||
<translation>Политка соединения. Обратитесь к документации ядра для более подробной информации</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>BridgeWidget</name>
|
||||
<message>
|
||||
@ -190,6 +205,10 @@
|
||||
<source>IP address does not match the standard</source>
|
||||
<translation>IP адрес не соответствует стандартам</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Key is required for 'gre' mode</source>
|
||||
<translation>Необходимо указать ключ для 'gre' режима</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>EthernetWidget</name>
|
||||
@ -281,6 +300,14 @@
|
||||
<source>Maximum time, in seconds, to wait for 802.1x authentication to succeed</source>
|
||||
<translation>Максимальное время в секундах для ожидания выполнения 802.1x авторизации</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Priority</source>
|
||||
<translation>Приоритет</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Priority level of the profile. In case of automatic profile selection, profiles are tried in decreasing order of priority</source>
|
||||
<translation>Приоритет профиля. В случае автоматического выбора профиля, профили будут выбираться по уменьшению приоритета</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GeneralWidget</name>
|
||||
@ -376,6 +403,14 @@
|
||||
<source>A description of the profile</source>
|
||||
<translation>Описание профиля</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Whether or not to exclude this profile from automatic profile selection</source>
|
||||
<translation>Исключить ли профиль из автоматического выбора</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Exclude auto</source>
|
||||
<translation>Исключить профиль</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>IpWidget</name>
|
||||
@ -1518,6 +1553,30 @@ Should be according to standards</source>
|
||||
<source>Browse</source>
|
||||
<translation>Обзор</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select chat file</source>
|
||||
<translation>Выберете скрипт с настройками чата</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>All (*.*)</source>
|
||||
<translation>Все (*.*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Init</source>
|
||||
<translation>Инициализация</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>An initialization string sent to the modem before dialing</source>
|
||||
<translation>Команда, которая будет послана при инициализации модема</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Chat script</source>
|
||||
<translation>Скрипт</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Path to a chat file</source>
|
||||
<translation>Путь к скрипту с настройками чата</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>NetctlAutoWindow</name>
|
||||
@ -2284,6 +2343,14 @@ Should be according to standards</source>
|
||||
<source>External editor</source>
|
||||
<translation>Внешний редактор</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Main tab autoupdate, sec</source>
|
||||
<translation>Интервал обновления основной вкладки, сек</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>WiFi tab autoupdate, sec</source>
|
||||
<translation>Интервал обновления WiFi вкладки, сек</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TrayIcon</name>
|
||||
@ -2458,6 +2525,14 @@ Should be according to standards</source>
|
||||
<source>The address of the remote end of the tunnel</source>
|
||||
<translation>Адрес удаленного конца туннеля</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Key</source>
|
||||
<translation>Ключ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>A key identifying an individual traffic flow within a tunnel</source>
|
||||
<translation>Ключ, указывающий на отдельные потоки трафика в туннеле</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>TuntapWidget</name>
|
||||
@ -2800,11 +2875,11 @@ Should be according to standards</source>
|
||||
</message>
|
||||
<message>
|
||||
<source>Whether or not to exclude this profile from automatic profile selection</source>
|
||||
<translation>Исключить ли профиль из автоматического выбора</translation>
|
||||
<translation type="vanished">Исключить ли профиль из автоматического выбора</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Exclude auto</source>
|
||||
<translation>Исключить профиль</translation>
|
||||
<translation type="vanished">Исключить профиль</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Frequency</source>
|
||||
|
@ -133,7 +133,7 @@ void TestNetctl::test_getActiveProfile()
|
||||
QStringList result = netctl->getActiveProfile();
|
||||
QStringList dbus;
|
||||
if (helper)
|
||||
dbus = sendDBusRequest(QString("/netctl"), QString("netctlActiveProfile"))[0].toString().split(QChar('|'));
|
||||
dbus = sendDBusRequest(QString("/netctl"), QString("netctlActiveProfile"))[0].toStringList();
|
||||
netctl->startProfile(QString("netctlgui-test-dummy"));
|
||||
delete netctl;
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#define DOCS_PATH "@CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/"
|
||||
|
||||
// links
|
||||
#define HOMEPAGE "http://arcanis.name/projects/netctl-gui/"
|
||||
#define HOMEPAGE "https://arcanis.me/projects/netctl-gui/"
|
||||
#define REPOSITORY "https://github.com/arcan1s/netctl-gui"
|
||||
#define BUGTRACKER "https://github.com/arcan1s/netctl-gui/issues"
|
||||
#define TRANSLATION "https://github.com/arcan1s/netctl-gui/issues/3"
|
||||
@ -52,4 +52,40 @@
|
||||
#define DBUS_INTERFACE_PATH "/interface"
|
||||
#define DBUS_LIB_PATH "/netctl"
|
||||
|
||||
// defaul configuration
|
||||
// [Common] section
|
||||
#define LANGUAGE "@CFG_LANGUAGE@"
|
||||
#define MAINUPDATE "@CFG_MAINUPDATE@"
|
||||
#define WIFIUPDATE "@CFG_WIFIUPDATE@"
|
||||
#define SYSTRAY "@CFG_SYSTRAY@"
|
||||
#define CLOSETOTRAY "@CFG_CLOSETOTRAY@"
|
||||
#define STARTTOTRAY "@CFG_STARTTOTRAY@"
|
||||
#define SKIPCOMPONENTS "@CFG_SKIPCOMPONENTS@"
|
||||
// [Helper] section
|
||||
#define USE_HELPER "@CFG_USE_HELPER@"
|
||||
#define FORCE_SUDO "@CFG_FORCE_SUDO@"
|
||||
#define CLOSE_HELPER "@CFG_CLOSE_HELPER@"
|
||||
#define HELPER_PATH "@CFG_HELPER_PATH@"
|
||||
#define HELPER_SERVICE "@CFG_HELPER_SERVICE@"
|
||||
// [netctl] section
|
||||
#define SYSTEMCTL_PATH "@CFG_SYSTEMCTL_PATH@"
|
||||
#define NETCTL_PATH "@CFG_NETCTL_PATH@"
|
||||
#define NETCTLAUTO_PATH "@CFG_NETCTLAUTO_PATH@"
|
||||
#define NETCTLAUTO_SERVICE "@CFG_NETCTLAUTO_SERVICE@"
|
||||
#define PROFILE_DIR "@CFG_PROFILE_DIR@"
|
||||
// [sudo] section
|
||||
#define SUDO_PATH "@CFG_SUDO_PATH@"
|
||||
// [wpa_supplicant] section
|
||||
#define WPASUP_PATH "@CFG_WPASUP_PATH@"
|
||||
#define WPACLI_PATH "@CFG_WPACLI_PATH@"
|
||||
#define PID_FILE "@CFG_PID_FILE@"
|
||||
#define WPA_DRIVERS "@CFG_WPA_DRIVERS@"
|
||||
#define CTRL_DIR "@CFG_CTRL_DIR@"
|
||||
#define CTRL_GROUP "@CFG_CTRL_GROUP@"
|
||||
// [Other] section
|
||||
#define EDITOR_PATH "@CFG_EDITOR_PATH@"
|
||||
#define IFACE_DIR "@CFG_IFACE_DIR@"
|
||||
#define RFKILL_DIR "@CFG_RFKILL_DIR@"
|
||||
#define PREFERED_IFACE "@CFG_PREFERED_IFACE@"
|
||||
|
||||
#endif /* VERSION_H */
|
||||
|
Loading…
Reference in New Issue
Block a user