Compare commits
172 Commits
Author | SHA1 | Date | |
---|---|---|---|
d41a34673b | |||
b199b43f58 | |||
6d212efe1e | |||
d32486d882 | |||
5afa65ce68 | |||
5b46247df2 | |||
bda5433716 | |||
835e82ca63 | |||
98cdb18d62 | |||
cd59a9b294 | |||
4780433c4d | |||
28a4934a82 | |||
4e8bbeed35 | |||
f86ef0514b | |||
4c004af1ae | |||
66e3a737d4 | |||
9cf6552c71 | |||
f18e74917b | |||
b909222db9 | |||
0c7868536a | |||
fc3956caf1 | |||
4cf3c85070 | |||
6e57baccaf | |||
5ed704e676 | |||
eb3753ab25 | |||
f9d71577f3 | |||
814f2c7904 | |||
ceca889be4 | |||
696283b1e1 | |||
15cc3a8595 | |||
e8c3441f29 | |||
2de7b26f66 | |||
8f35aeb88f | |||
b49188c104 | |||
f8bf8830be | |||
6e6c547460 | |||
d287f52ba5 | |||
8cc02a07fb | |||
28d51484b1 | |||
e7d2e0bd38 | |||
999914926a | |||
e21b2201ab | |||
d65ded6072 | |||
16662f697b | |||
35d740b778 | |||
0a16364a7a | |||
e9090ab4a9 | |||
8bf33d4369 | |||
4e76d52671 | |||
47dc016da2 | |||
8b58f6d383 | |||
709431ead2 | |||
f90b2d97a7 | |||
5416ef841f | |||
e4cff2baf4 | |||
d047eaf2f2 | |||
56f4a75b25 | |||
dd05782f80 | |||
2c2919160b | |||
d7c8490724 | |||
1930eeb33c | |||
4cc9d0ec11 | |||
a7911d48d1 | |||
012c725e12 | |||
1907d3ac2f | |||
87376f1a5c | |||
f238ba3a6a | |||
abbc5641cd | |||
82c3690dcb | |||
d3e1c4bca0 | |||
b63d883eb2 | |||
529e2dd995 | |||
1d34a65f38 | |||
fea0bedef0 | |||
ec8fc79dd7 | |||
07e07ee777 | |||
5c8dca22d0 | |||
dba3eeabaa | |||
eabfac7323 | |||
3b1701f8b5 | |||
b65f761520 | |||
fddd4703cc | |||
f4e3848fa7 | |||
3e0ae6d4cc | |||
80f6ccf1d1 | |||
863b49eaec | |||
4785e358ec | |||
f0adbb60e5 | |||
61d814d9a2 | |||
d166668feb | |||
db3bfe9ad7 | |||
d2ea9d96d9 | |||
d4c82fce0c | |||
fe672aa8cc | |||
501b43002e | |||
43ed28de52 | |||
f7352f5c59 | |||
d112446d87 | |||
b863eedd96 | |||
e19c9fef53 | |||
10499691b3 | |||
bf6d7cd53b | |||
11db0fcf8d | |||
d44979e95e | |||
41f58c1448 | |||
2ff76e9c8e | |||
0b2cc3ba79 | |||
fb430b036e | |||
42194295cc | |||
558a206a8d | |||
172624b494 | |||
e64e8810f8 | |||
23f4a7f141 | |||
d01bb8834a | |||
0989a6584b | |||
c75f5ec135 | |||
d0a0b0eb4a | |||
6b7d5d3800 | |||
6a3e3b14b3 | |||
1ae30b0821 | |||
c15e387472 | |||
d04a0b0920 | |||
e8e0c71c05 | |||
516c4b5a22 | |||
4e027ec19f | |||
4788ad0081 | |||
891b3b43ef | |||
dee47b0ffc | |||
86753070e8 | |||
ff78d390ae | |||
447bcf8a0e | |||
e8a7865e99 | |||
fdb5b46ea1 | |||
0432579f5b | |||
2aa6b43e61 | |||
0bade9c42f | |||
067115280c | |||
873f84c447 | |||
4c9c7b00a1 | |||
64937105c6 | |||
297a18d530 | |||
8c0226c9db | |||
1abc4a5ac9 | |||
7ed3e4e01b | |||
dc81a44034 | |||
7febf94233 | |||
3a0f0c252e | |||
209c3b9616 | |||
a79cbd4429 | |||
eb6bd34489 | |||
ccc62ffb67 | |||
fc2d338450 | |||
eefe196b69 | |||
c1e23d38a9 | |||
e9c10e262e | |||
0d26d6230e | |||
0aa162b71b | |||
78a4aeb0eb | |||
ec5dff4b75 | |||
0070f910cc | |||
6cba836d98 | |||
4600aae8bc | |||
79e7aa1926 | |||
32683a89b9 | |||
43de4e5738 | |||
099b4e3792 | |||
389726379c | |||
9c0dcfe621 | |||
75a95661f8 | |||
31f52e5d22 | |||
78827d833d | |||
c0207a108e |
2
.gitignore
vendored
@ -25,3 +25,5 @@ usr/
|
||||
# translations
|
||||
*.qm
|
||||
|
||||
# temporary bckps
|
||||
*~
|
||||
|
12
.gitmodules
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
[submodule "sources/3rdparty/tasks"]
|
||||
path = sources/3rdparty/tasks
|
||||
url = https://github.com/mhogomchungu/tasks.git
|
||||
[submodule "sources/3rdparty/pdebug"]
|
||||
path = sources/3rdparty/pdebug
|
||||
url = https://github.com/arcan1s/qtadds-pdebug.git
|
||||
[submodule "sources/3rdparty/language"]
|
||||
path = sources/3rdparty/language
|
||||
url = https://github.com/arcan1s/qtadds-language.git
|
||||
[submodule "sources/3rdparty/task"]
|
||||
path = sources/3rdparty/task
|
||||
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
|
3
AUTHORS
@ -1,2 +1,5 @@
|
||||
Current developers:
|
||||
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
|
||||
|
||||
Translators:
|
||||
@nosada (Japanese translation)
|
||||
|
221
CHANGELOG
@ -1,60 +1,179 @@
|
||||
Ver.1.2.0:
|
||||
+ [all] added icons
|
||||
+ [all] added support of netctl-auto
|
||||
+ [gui] added suppoort of macvlan
|
||||
+ [gui] added ability to remove profile
|
||||
+ [gui] added support of hidden wifi network
|
||||
+ [gui] added contextual menu to tables
|
||||
+ [gui] added actions menu
|
||||
+ [gui] added clear() function to profileTab
|
||||
+ [gui] added about window
|
||||
+ [gui] more command line options
|
||||
+ [gui] added workaround for wireless-wep example
|
||||
+ [lib] detached backend from frontend
|
||||
+ [lib] added error checking
|
||||
+ [lib] added doxygen documentation
|
||||
+ [plasmoid] added dataengine configuration
|
||||
+ [plasmoid] added about window
|
||||
* [all] changes in the project architecture
|
||||
* [all] refactoring
|
||||
* [gui] more debug information
|
||||
* [gui] changed lineEdit_profile to comboBox
|
||||
* [gui] refactoring of configuration interface
|
||||
* [gui] changed setting of the interface to profile tab
|
||||
* [gui] rewrited ErrorWindow class
|
||||
* [lib] more debug information
|
||||
* [lib] rewrited getSettingsFromProfile() function
|
||||
* [plasmoid] edited configuration interface
|
||||
* [plasmoid] changed double click event to click event
|
||||
Ver.1.3.1
|
||||
---------
|
||||
* gui:
|
||||
* more correct calls of boolean DBus methods
|
||||
* edit helper icon
|
||||
* helper:
|
||||
* more correct calls of boolean DBus methods
|
||||
* more correct systemd service
|
||||
* add ability to create session bus
|
||||
|
||||
Ver.1.1.0 (netctl-1.7 update):
|
||||
+ [gui] added frequency
|
||||
+ [plasmoid] added menu title
|
||||
* [dataengine] changed definition if profile is enabled
|
||||
* [gui] changed definition if profile is enabled
|
||||
***
|
||||
|
||||
Ver.1.0.6:
|
||||
* [gui] fix error checking
|
||||
Ver.1.3.0
|
||||
---------
|
||||
* all:
|
||||
+ add processes error messages
|
||||
+ add support of several active profiles
|
||||
* some bug fixes and refactoring
|
||||
* rewrite debug messages
|
||||
* dataengine:
|
||||
+ add new sources: intIp6, extIp6, netctlAutoStatus
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* change default command to define external IP
|
||||
* change interface list definition
|
||||
* change internal IP definition
|
||||
* gui:
|
||||
+ add 3rd party license information
|
||||
+ add system tray icon as an alternative to the plasmoid
|
||||
+ add DBus session interface org.netctlgui.netctlgui
|
||||
+ add dynamic settings load
|
||||
+ add support of openvswitch
|
||||
+ add security notes and API descriptions
|
||||
+ add ability to use helper
|
||||
+ add ability to start minimized/maximized/detached
|
||||
+ add ability to don't save profile from WiFi tab
|
||||
+ add ability to skip external components checking
|
||||
- remove buttons
|
||||
* more correct actions into SettingsWindow
|
||||
* update to library changes
|
||||
* rewrite tables to use toolTip
|
||||
* edit about window
|
||||
* change menuBar
|
||||
* helper:
|
||||
+ create daemon DBus system interface org.netctlgui.helper to the library:
|
||||
self control slots, netctl control slots and netctl information slots
|
||||
+ add tests
|
||||
* library:
|
||||
+ add custom structures netctlWifiInfo and netctlProfileInfo
|
||||
+ add methods getActiveProfile(), autoGetActiveProfile()
|
||||
+ add slot switchToProfile()
|
||||
+ add slot stopAllProfiles()
|
||||
+ add slot reenableProfile()
|
||||
+ add slots getRecommendedConfiguration()
|
||||
+ add slots forceStartProfile() and forceStopProfile()
|
||||
+ add double quotes to profile names
|
||||
+ add tests
|
||||
- remove functions getProfileDescriptions() and getProfileStatuses()
|
||||
- remove SleepThread class
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* rename getInterfaceList() to getWirelessInterfaceList()
|
||||
* change temporary directory from $HOME/.cache to system one
|
||||
* plasmoid:
|
||||
+ add 3rd party license information
|
||||
+ allow plasmoid to use system tray
|
||||
+ add ability to use helper
|
||||
* change all running processes to detached (see #7)
|
||||
* rewrite text label to use tags
|
||||
* update to dataengine changes
|
||||
* edit about window
|
||||
|
||||
Ver.1.0.5:
|
||||
+ [plasmoid] added "Start WiFi menu" function
|
||||
* [plasmoid] refactoring
|
||||
* [plasmoid] edited icon
|
||||
***
|
||||
|
||||
Ver.1.0.4:
|
||||
+ [gui] added Qt5 gui (by default)
|
||||
+ [plasmoid] added notifications
|
||||
* [plasmoid] fix run command with sudo from plasmoid
|
||||
Ver.1.2.0
|
||||
---------
|
||||
* all:
|
||||
+ add icons
|
||||
+ add support of netctl-auto
|
||||
* changes in the project architecture
|
||||
* refactoring
|
||||
* dataengine:
|
||||
+ add debug information (NETCTLGUI_DEBUG=yes)
|
||||
* gui:
|
||||
+ add support of macvlan
|
||||
+ add ability to remove profile
|
||||
+ add support of hidden wifi network
|
||||
+ add contextual menu to tables
|
||||
+ add actions menu
|
||||
+ add clear() function to profileTab
|
||||
+ add about window
|
||||
+ more command line options
|
||||
+ add workaround for wireless-wep example
|
||||
+ add shell completions
|
||||
+ add "Report a bug" action
|
||||
- fix possible segfaults with null arrays (#5)
|
||||
* more debug information
|
||||
* change lineEdit_profile to comboBox
|
||||
* refactoring of configuration interface
|
||||
* change setting of the interface to profile tab
|
||||
* rewrite ErrorWindow class
|
||||
* library:
|
||||
+ detach backend from frontend
|
||||
+ add error checking
|
||||
+ add doxygen documentation
|
||||
* more debug information
|
||||
* rewrite getSettingsFromProfile() function
|
||||
* plasmoid:
|
||||
+ add dataengine configuration
|
||||
+ add about window
|
||||
+ add debug information (NETCTLGUI_DEBUG=yes)
|
||||
* edit configuration interface
|
||||
* change double click event to click event
|
||||
* change class from Applet to PopupApplet
|
||||
|
||||
Ver.1.0.3:
|
||||
+ [plasmoid] edited russian translation
|
||||
* [all] refactoring
|
||||
***
|
||||
|
||||
Ver.1.0.2:
|
||||
* [plasmoid] fix layout margins
|
||||
Ver.1.1.0 (netctl-1.7 update)
|
||||
-----------------------------
|
||||
* dataengine:
|
||||
* change definition if profile is enabled
|
||||
* gui:
|
||||
+ add frequency
|
||||
* change definition if profile is enabled
|
||||
* plasmoid:
|
||||
+ add menu title
|
||||
|
||||
Ver.1.0.1:
|
||||
- [all] removed scripts
|
||||
***
|
||||
|
||||
Ver.1.0:
|
||||
Ver.1.0.6
|
||||
---------
|
||||
* gui:
|
||||
* fix error checking
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.5
|
||||
---------
|
||||
* plasmoid:
|
||||
+ add "Start WiFi menu" function
|
||||
* refactoring
|
||||
* edit icon
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.4
|
||||
---------
|
||||
* gui:
|
||||
+ add Qt5 gui (by default)
|
||||
* plasmoid:
|
||||
+ add notifications
|
||||
* fix run command with sudo from plasmoid
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.3
|
||||
---------
|
||||
* all:
|
||||
* refactoring
|
||||
* plasmoid:
|
||||
+ edit russian translation
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.2
|
||||
---------
|
||||
* plasmoid:
|
||||
- fix layout margins
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.1
|
||||
---------
|
||||
* all:
|
||||
- remove scripts
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0
|
||||
-------
|
||||
First release
|
||||
|
86
PKGBUILD
@ -1,86 +0,0 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('netctl-gui' 'netctl-gui-qt4' 'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.2.0
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
||||
optdepends=('kdebase-runtime: sudo support'
|
||||
'kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'sudo: sudo support'
|
||||
'wpa_actiond: netctl-auto support'
|
||||
'wpa_supplicant: wifi support')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
install="${pkgbase}.install"
|
||||
md5sums=('5b3105a64bc162d30a41a2b3bcb06f0a')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
|
||||
mkdir "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DOCS:BOOL=0 \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DOCS:BOOL=0 \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DOCS:BOOL=0 \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
optdepends=('kdebase-runtime: sudo support'
|
||||
'netctl-gui: graphical front-end'
|
||||
'netctl-gui-qt4: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
package_netctl-gui() {
|
||||
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt5-base' 'xdg-utils')
|
||||
provides=('netctl-gui-qt4')
|
||||
conflicts=('netctl-gui-qt4')
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
package_netctl-gui-qt4() {
|
||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt4')
|
||||
provides=('netctl-gui')
|
||||
conflicts=('netctl-gui')
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
28
README.md
@ -11,7 +11,12 @@ Qt4/Qt5 graphical interface for netctl. It may work with profiles and may create
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
It is recommended to use graphical interface for widget and DataEngine configuration. All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface.
|
||||
It is recommended to use graphical interface for configuration. Configuration files are:
|
||||
|
||||
* `$HOME/.config/netctl-gui.conf` - GUI/helper user configuration
|
||||
* `/etc/netctl-gui.conf` - helper system-wide configuration
|
||||
* `$KDEHOME/share/config/netctl.conf` - DataEngine user configuration
|
||||
* `$KDESYSTEM/share/config/netctl.conf` - DataEngine system-wide configuration
|
||||
|
||||
Instruction
|
||||
===========
|
||||
@ -27,7 +32,6 @@ Optional dependencies
|
||||
|
||||
* kdebase-workspace (widget)
|
||||
* sudo (sudo support)
|
||||
* wpa_actiond (netctl-auto support)
|
||||
* wpa_supplicant (WiFi support)
|
||||
|
||||
Make dependencies
|
||||
@ -51,12 +55,20 @@ Installation
|
||||
|
||||
Available cmake flags:
|
||||
|
||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
||||
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
|
||||
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
||||
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
||||
* components:
|
||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
||||
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
|
||||
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
|
||||
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
||||
* additional components:
|
||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
|
||||
* project properties:
|
||||
* `-DDBUS_SYSTEMCONF_PATH=/etc/dbus-1/system.d/` - path to dbus system configuration files
|
||||
* `-DSYSTEMD_SERVICE_PATH=lib/systemd/system` - path to systemd services
|
||||
* `-DUSE_CAPABILITIES:BOOL=0` - do not use setcap to get privileges to the helper
|
||||
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
||||
|
||||
Additional information
|
||||
======================
|
||||
|
152
arch/PKGBUILD
Normal file
@ -0,0 +1,152 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.3.1
|
||||
pkgrel=2
|
||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('d57bf3773f6cd9ead91c2669a02360fb')
|
||||
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'netctlgui-helper-qt4: DBus helper daemon'
|
||||
'netctl-gui: graphical front-end'
|
||||
'netctl-gui-qt4: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="kdeplasma-applets-netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui() {
|
||||
pkgdesc="Qt5 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt5-base')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui-qt4')
|
||||
conflicts=('libnetctlgui-qt4')
|
||||
|
||||
cd "${srcdir}/build-qt5/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=('libnetctlgui')
|
||||
provides=('netctlgui-helper-qt4')
|
||||
conflicts=('netctlgui-helper-qt4')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui() {
|
||||
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('libnetctlgui' 'xdg-utils')
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'netctlgui-helper: DBus helper daemon')
|
||||
provides=('netctl-gui-qt4')
|
||||
conflicts=('netctl-gui-qt4')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui-qt4() {
|
||||
pkgdesc="Qt4 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt4')
|
||||
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui')
|
||||
conflicts=('libnetctlgui')
|
||||
install=""
|
||||
|
||||
cd "${srcdir}/build-qt4/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper-qt4() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=('libnetctlgui-qt4')
|
||||
provides=('netctlgui-helper')
|
||||
conflicts=('netctlgui-helper')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui-qt4() {
|
||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('libnetctlgui-qt4')
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'netctlgui-helper-qt4: DBus helper daemon')
|
||||
provides=('netctl-gui')
|
||||
conflicts=('netctl-gui')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
14
arch/kdeplasma-applets-netctl-gui.install
Normal file
@ -0,0 +1,14 @@
|
||||
post_install() {
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
11
arch/libnetctlgui.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
true
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
@ -4,9 +4,9 @@ post_install() {
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install
|
||||
post_install "$1"
|
||||
}
|
11
arch/netctlgui-helper.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
setcap cap_setuid=ep usr/bin/netctlgui-helper 2>/dev/null || chmod +s usr/bin/netctlgui-helper
|
||||
cat << EOF
|
||||
Note: users should be in network group if you want to get them access to the system bus
|
||||
See http://arcanis.name/devs/netctl-gui-security-notes.html#helper
|
||||
EOF
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
@ -3,10 +3,12 @@
|
||||
ARCHIVE="netctl-gui"
|
||||
SRCDIR="sources"
|
||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||
IGNORELIST="build en.qm ru.qm netctl-gui.qm *.cppcheck"
|
||||
IGNORELIST="build *.qm *.cppcheck .git*"
|
||||
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
|
||||
# update submodules
|
||||
git submodule update --init --recursive
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
@ -14,8 +16,12 @@ 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
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
||||
rm -rf "${ARCHIVE}"
|
||||
# update md5sum
|
||||
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD
|
||||
# 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 {} \;
|
||||
|
Before Width: | Height: | Size: 51 KiB |
BIN
screenshots/de-main.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
screenshots/gui-about.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
screenshots/gui-main_tab.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
screenshots/gui-netctl-auto.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
screenshots/gui-profile_tab.png
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
screenshots/gui-settings.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
screenshots/gui-wifi_tab.png
Normal file
After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 45 KiB |
BIN
screenshots/plasmoid-config_1.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
screenshots/plasmoid-config_2.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
screenshots/plasmoid-config_3.png
Normal file
After Width: | Height: | Size: 45 KiB |
BIN
screenshots/plasmoid-main.png
Normal file
After Width: | Height: | Size: 114 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 52 KiB |
Before Width: | Height: | Size: 47 KiB |
218
sources/3rdparty/about/about.ui
vendored
Normal file
@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>About</class>
|
||||
<widget class="QWidget" name="About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_About">
|
||||
<attribute name="title">
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_about">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_about">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_version">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_links">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_about">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_ackn">
|
||||
<attribute name="title">
|
||||
<string>Acknowledgement</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_ackn">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_ackn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_translators">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_trdparty">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_ackn">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>229</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_license">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
1
sources/3rdparty/language
vendored
Submodule
12
sources/3rdparty/language-config.h
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef LANGUAGE_CONFIG_H
|
||||
#define LANGUAGE_CONFIG_H
|
||||
|
||||
|
||||
// put your languages here comma separated
|
||||
// the first language is default language
|
||||
#define LANGUAGES "en,ru"
|
||||
// language key in the configuration file
|
||||
#define LANGUAGE_KEY "LANGUAGE"
|
||||
|
||||
|
||||
#endif /* LANGUAGE_CONFIG_H */
|
1
sources/3rdparty/pdebug
vendored
Submodule
1
sources/3rdparty/task
vendored
Submodule
1
sources/3rdparty/tasks
vendored
Submodule
@ -10,8 +10,8 @@ set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 2)
|
||||
set (PROJECT_VERSION_PATCH 0)
|
||||
set (PROJECT_VERSION_MINOR 3)
|
||||
set (PROJECT_VERSION_PATCH 2)
|
||||
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")
|
||||
@ -21,28 +21,37 @@ message (STATUS "Version: ${PROJECT_VERSION}")
|
||||
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)
|
||||
# components
|
||||
option (BUILD_GUI "Build GUI" ON)
|
||||
option (BUILD_HELPER "Build helper" ON)
|
||||
option (BUILD_LIBRARY "Build library" ON)
|
||||
option (BUILD_DATAENGINE "Build data engine" ON)
|
||||
option (BUILD_DATAENGINE "Build DataEngine" ON)
|
||||
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||
if (BUILD_GUI)
|
||||
if (BUILD_GUI OR BUILD_HELPER)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
if (BUILD_PLASMOID)
|
||||
set (BUILD_DATAENGINE ON)
|
||||
endif ()
|
||||
# documentation
|
||||
option (BUILD_DOCS "Build documentation and install headers" ON)
|
||||
option (BUILD_DOCS "Build Doxygen documentation" OFF)
|
||||
if (BUILD_DOCS)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# test
|
||||
option (BUILD_TEST "Build unit tests" OFF)
|
||||
if (BUILD_TEST)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# FIXME: dbus path
|
||||
set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus system configuration files")
|
||||
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
else ()
|
||||
@ -52,6 +61,7 @@ endif ()
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
# resources
|
||||
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||
set (PROJECT_LIBRARY netctlgui)
|
||||
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||
@ -59,7 +69,14 @@ add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||
# components
|
||||
if (BUILD_LIBRARY)
|
||||
add_subdirectory (${PROJECT_LIBRARY})
|
||||
endif()
|
||||
endif ()
|
||||
if (BUILD_HELPER)
|
||||
add_subdirectory (helper)
|
||||
endif ()
|
||||
if (BUILD_TEST)
|
||||
enable_testing ()
|
||||
add_subdirectory (test)
|
||||
endif ()
|
||||
if (BUILD_GUI)
|
||||
add_subdirectory (gui)
|
||||
endif ()
|
||||
|
@ -7,20 +7,27 @@ find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
@ -2,19 +2,16 @@
|
||||
|
||||
## Commands
|
||||
# command
|
||||
CMD=/usr/bin/netctl
|
||||
NETCTLCMD=/usr/bin/netctl
|
||||
# netctl-auto command
|
||||
NETCTLAUTOCMD=/usr/bin/netctl-auto
|
||||
# ip command
|
||||
IPCMD=/usr/bin/ip
|
||||
|
||||
## Network
|
||||
# path to list of network devices
|
||||
NETDIR=/sys/class/net/
|
||||
|
||||
## External IP
|
||||
# external ip check command
|
||||
EXTIPCMD=wget -qO- http://ifconfig.me/ip
|
||||
# 'true' - check external IP
|
||||
EXTIP=false
|
||||
|
||||
# external IPv4 check command
|
||||
EXTIP4CMD=curl ip4.telize.com
|
||||
# 'true' - check external IPv4
|
||||
EXTIP4=false
|
||||
# external IPv6 check command
|
||||
EXTIP6CMD=curl ip6.telize.com
|
||||
# 'true' - check external IPv6
|
||||
EXTIP6=false
|
||||
|
@ -20,33 +20,56 @@
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#include <Plasma/DataContainer>
|
||||
#include <QDir>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
: Plasma::DataEngine(parent, args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("NETCTLGUI_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
debug = false;
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
}
|
||||
|
||||
|
||||
Netctl::~Netctl()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::sources() const
|
||||
{
|
||||
QStringList sources;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
sources.append(QString("currentProfile"));
|
||||
sources.append(QString("extIp"));
|
||||
QStringList sources;
|
||||
sources.append(QString("active"));
|
||||
sources.append(QString("current"));
|
||||
sources.append(QString("extip4"));
|
||||
sources.append(QString("extip6"));
|
||||
sources.append(QString("interfaces"));
|
||||
sources.append(QString("intIp"));
|
||||
sources.append(QString("intip4"));
|
||||
sources.append(QString("intip6"));
|
||||
sources.append(QString("netctlauto"));
|
||||
sources.append(QString("profiles"));
|
||||
sources.append(QString("statusBool"));
|
||||
sources.append(QString("statusString"));
|
||||
sources.append(QString("status"));
|
||||
|
||||
return sources;
|
||||
}
|
||||
@ -54,43 +77,50 @@ QStringList Netctl::sources() const
|
||||
|
||||
void Netctl::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// default configuration
|
||||
QMap<QString, QString> rawConfig;
|
||||
rawConfig[QString("CMD")] = QString("/usr/bin/netctl");
|
||||
rawConfig[QString("EXTIP")] = QString("false");
|
||||
rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
|
||||
rawConfig[QString("IPCMD")] = QString("/usr/bin/ip");
|
||||
rawConfig[QString("NETDIR")] = QString("/sys/class/net/");
|
||||
rawConfig[QString("EXTIP4")] = QString("false");
|
||||
rawConfig[QString("EXTIP4CMD")] = QString("curl ip4.telize.com");
|
||||
rawConfig[QString("EXTIP6")] = QString("false");
|
||||
rawConfig[QString("EXTIP6CMD")] = QString("curl ip6.telize.com");
|
||||
rawConfig[QString("NETCTLCMD")] = QString("/usr/bin/netctl");
|
||||
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
|
||||
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
|
||||
QFile confFile(fileName);
|
||||
if (!confFile.open(QIODevice::ReadOnly)) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile configFile(fileName);
|
||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
return;
|
||||
}
|
||||
QString fileStr;
|
||||
QStringList value;
|
||||
while (true) {
|
||||
fileStr = QString(confFile.readLine()).trimmed();
|
||||
if (fileStr[0] == QChar('#')) continue;
|
||||
if (fileStr[0] == QChar(';')) continue;
|
||||
if (!fileStr.contains(QChar('='))) continue;
|
||||
value.clear();
|
||||
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
||||
value.append(fileStr.split(QChar('='))[i]);
|
||||
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
||||
if (confFile.atEnd())
|
||||
break;
|
||||
fileStr = QString(configFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('='))) {
|
||||
value.clear();
|
||||
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
||||
value.append(fileStr.split(QChar('='))[i]);
|
||||
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
||||
}
|
||||
if (configFile.atEnd()) break;
|
||||
}
|
||||
confFile.close();
|
||||
configFile.close();
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> config;
|
||||
QString key, value;
|
||||
// remove spaces and copy source map
|
||||
@ -98,159 +128,233 @@ QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString>
|
||||
key = rawConfig.keys()[i];
|
||||
value = rawConfig[key];
|
||||
key.remove(QChar(' '));
|
||||
if ((key != QString("CMD")) &&
|
||||
(key != QString("EXTIPCMD")) &&
|
||||
(key != QString("IPCMD")) &&
|
||||
if ((key != QString("EXTIP4CMD")) &&
|
||||
(key != QString("EXTIP6CMD")) &&
|
||||
(key != QString("NETCTLCMD")) &&
|
||||
(key != QString("NETCTLAUTOCMD")))
|
||||
value.remove(QChar(' '));
|
||||
config[key] = value;
|
||||
}
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + config[config.keys()[i]];
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source name" << name;
|
||||
|
||||
return updateSourceEvent(name);
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getCurrentProfile(const QString cmd)
|
||||
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
QProcess command;
|
||||
QString profile = QString("");
|
||||
command.start(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString cmd;
|
||||
if (netctlAutoStatus)
|
||||
cmd = cmdNetctlAuto;
|
||||
else
|
||||
cmd = cmdNetctl;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QStringList currentProfile;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i][0] == QChar('*')) {
|
||||
profile = profileList[i];
|
||||
break;
|
||||
}
|
||||
profile.remove(0, 1);
|
||||
return profile;
|
||||
if (profileList[i][0] == QChar('*'))
|
||||
currentProfile.append(profileList[i]);
|
||||
for (int i=0; i<currentProfile.count(); i++)
|
||||
currentProfile[i].remove(0, 2);
|
||||
|
||||
return currentProfile;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getExtIp(const QString cmd)
|
||||
{
|
||||
QProcess command;
|
||||
QString extIp = QString("");
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
extIp = cmdOutput.trimmed();
|
||||
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;
|
||||
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
|
||||
return extIp;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getInterfaceList(const QString dir)
|
||||
QStringList Netctl::getInterfaceList()
|
||||
{
|
||||
QStringList interfaceList;
|
||||
if (QDir(dir).exists())
|
||||
interfaceList = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
return interfaceList;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
||||
QStringList interfacesList;
|
||||
for (int i=0; i<rawList.count(); i++)
|
||||
interfacesList.append(rawList[i].name());
|
||||
|
||||
return interfacesList;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getIntIp(const QString cmd, const QString dir)
|
||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
{
|
||||
QProcess command;
|
||||
QString intIp = QString("127.0.0.1/8");
|
||||
QStringList interfaceList = getInterfaceList(dir);
|
||||
for (int i=0; i<interfaceList.count(); i++)
|
||||
if (interfaceList[i] != QString("lo")) {
|
||||
command.start(cmd + QString(" addr show ") + interfaceList[i]);
|
||||
command.waitForFinished(-1);
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
QStringList deviceInfo = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int j=0; j<deviceInfo.count(); j++)
|
||||
if (deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[0] == QString("inet"))
|
||||
intIp = deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[1];
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString intIp = QString("");
|
||||
if (protocol == QAbstractSocket::IPv4Protocol)
|
||||
intIp = QString("127.0.0.1/8");
|
||||
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) {
|
||||
intIp = rawList[i].toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return intIp;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileList(const QString cmd)
|
||||
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
|
||||
{
|
||||
QProcess command;
|
||||
command.start(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
profileList[i].remove(0, 1);
|
||||
return profileList;
|
||||
}
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString status;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
if (cmdOutput.isEmpty()) {
|
||||
netctlAutoStatus = false;
|
||||
status = QString("false");
|
||||
} else {
|
||||
netctlAutoStatus = true;
|
||||
status = QString("true");
|
||||
}
|
||||
|
||||
bool Netctl::getProfileStatus(const QString cmd)
|
||||
{
|
||||
bool status = false;
|
||||
QString cmdOutput = getCurrentProfile(cmd);
|
||||
if (!cmdOutput.isEmpty())
|
||||
status = true;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
QProcess command;
|
||||
QString status = QString("static");
|
||||
// check netctl-auto
|
||||
if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
|
||||
status = QString("netctl-auto");
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString cmd;
|
||||
if (netctlAutoStatus)
|
||||
cmd = cmdNetctlAuto;
|
||||
else
|
||||
cmd = cmdNetctl;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
profileList[i].remove(0, 2);
|
||||
|
||||
return profileList;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QStringList status;
|
||||
if (netctlAutoStatus)
|
||||
status.append(QString("netctl-auto"));
|
||||
else {
|
||||
// check netctl
|
||||
command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
|
||||
command.waitForFinished(-1);
|
||||
if (command.exitCode() == 0)
|
||||
status = QString("enabled");
|
||||
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (process.exitCode == 0)
|
||||
status.append(QString("enabled"));
|
||||
else
|
||||
status.append(QString("static"));
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString status = QString("false");
|
||||
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
if (!currentProfile.isEmpty())
|
||||
status = QString("true");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::updateSourceEvent(const QString &source)
|
||||
{
|
||||
QString key = QString("value");
|
||||
QString value = QString("");
|
||||
if (source == QString("currentProfile")) {
|
||||
value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
|
||||
if (value.isEmpty())
|
||||
value = getCurrentProfile(configuration[QString("CMD")]);
|
||||
}
|
||||
else if (source == QString("extIp")) {
|
||||
if (configuration[QString("EXTIP")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIPCMD")]);
|
||||
}
|
||||
else if (source == QString("interfaces")) {
|
||||
value = getInterfaceList(configuration[QString("NETDIR")]).join(QChar(','));
|
||||
}
|
||||
else if (source == QString("intIp")) {
|
||||
value = getIntIp(configuration[QString("IPCMD")], configuration[QString("NETDIR")]);
|
||||
}
|
||||
else if (source == QString("profiles")) {
|
||||
value = getProfileList(configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
|
||||
if (value.isEmpty())
|
||||
value = getProfileList(configuration[QString("CMD")]).join(QChar(','));
|
||||
}
|
||||
else if (source == QString("statusBool")) {
|
||||
if (getProfileStatus(configuration[QString("NETCTLAUTOCMD")]))
|
||||
value = QString("true");
|
||||
else if (getProfileStatus(configuration[QString("CMD")]))
|
||||
value = QString("true");
|
||||
else
|
||||
value = QString("false");
|
||||
}
|
||||
else if (source == QString("statusString")) {
|
||||
value = getProfileStringStatus(configuration[QString("CMD")],
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source name" << source;
|
||||
|
||||
QString value = QString("N\\A");
|
||||
if (source == QString("active")) {
|
||||
value = getStatus(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")]);
|
||||
} else if (source == QString("current")) {
|
||||
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar('|'));
|
||||
} else if (source == QString("extip4")) {
|
||||
if (configuration[QString("EXTIP4")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
||||
} else if (source == QString("extip6")) {
|
||||
if (configuration[QString("EXTIP6")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
||||
} else if (source == QString("interfaces")) {
|
||||
value = getInterfaceList().join(QChar(','));
|
||||
} else if (source == QString("intip4")) {
|
||||
value = getIntIp(QAbstractSocket::IPv4Protocol);
|
||||
} else if (source == QString("intip6")) {
|
||||
value = getIntIp(QAbstractSocket::IPv6Protocol);
|
||||
} else if (source == QString("netctlauto")) {
|
||||
value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]);
|
||||
} else if (source == QString("profiles")) {
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar(','));
|
||||
} else if (source == QString("status")) {
|
||||
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar('|'));
|
||||
}
|
||||
setData(source, key, value);
|
||||
setData(source, QString("value"), value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define NETCTL_DE_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QAbstractSocket>
|
||||
|
||||
|
||||
class Netctl : public Plasma::DataEngine
|
||||
@ -27,13 +28,15 @@ class Netctl : public Plasma::DataEngine
|
||||
|
||||
public:
|
||||
Netctl(QObject *parent, const QVariantList &args);
|
||||
QString getCurrentProfile(const QString cmd);
|
||||
~Netctl();
|
||||
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QString getExtIp(const QString cmd);
|
||||
QStringList getInterfaceList(const QString dir);
|
||||
QString getIntIp(const QString cmd, const QString dir);
|
||||
QStringList getProfileList(const QString cmd);
|
||||
bool getProfileStatus(const QString cmd);
|
||||
QString getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QStringList getInterfaceList();
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
|
||||
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &name);
|
||||
@ -41,8 +44,10 @@ protected:
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
bool isNetctlAutoRunning();
|
||||
bool netctlAutoStatus;
|
||||
QString currentProfile;
|
||||
// configuration
|
||||
bool debug;
|
||||
QMap<QString, QString> configuration;
|
||||
void readConfiguration();
|
||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||
|
@ -5,6 +5,7 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
# set directories
|
||||
set (SUBPROJECT_BINARY_DIR bin)
|
||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set (SUBPROJECT_DOCS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
|
||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
|
||||
# executable path
|
||||
@ -15,6 +16,7 @@ set (TARGETS "")
|
||||
set (HEADERS "")
|
||||
|
||||
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||
add_subdirectory (${SUBPROJECT_DOCS_DIR})
|
||||
# build man
|
||||
file (GLOB SUBPROJECT_MAN_IN *.1)
|
||||
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
|
||||
@ -22,3 +24,5 @@ configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MA
|
||||
|
||||
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
|
||||
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
|
||||
install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT})
|
||||
|
115
sources/gui/bash-completions
Normal file
@ -0,0 +1,115 @@
|
||||
###########################################################################
|
||||
# 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/ #
|
||||
###########################################################################
|
||||
|
||||
|
||||
# variables
|
||||
_netctl_gui_arglist=(
|
||||
'--detached'
|
||||
'--maximized'
|
||||
'--minimized'
|
||||
'--about'
|
||||
'--netctl-auto'
|
||||
'--settings'
|
||||
'-e'
|
||||
'--essid'
|
||||
'-o'
|
||||
'--open'
|
||||
'-s'
|
||||
'--select'
|
||||
'-c'
|
||||
'--config'
|
||||
'-d'
|
||||
'--debug'
|
||||
'--default'
|
||||
'--set-opts'
|
||||
'-t'
|
||||
'--tab'
|
||||
'-v'
|
||||
'--version'
|
||||
'-i'
|
||||
'--info'
|
||||
'-h'
|
||||
'--help'
|
||||
)
|
||||
|
||||
_netctl_gui_settings=(
|
||||
'CLOSE_HELPER'
|
||||
'CLOSETOTRAY'
|
||||
'CTRL_DIR'
|
||||
'CTRL_GROUP'
|
||||
'FORCE_SUDO'
|
||||
'HELPER_PATH'
|
||||
'HELPER_SERVICE'
|
||||
'IFACE_DIR'
|
||||
'LANGUAGE'
|
||||
'NETCTL_PATH'
|
||||
'NETCTLAUTO_PATH'
|
||||
'NETCTLAUTO_SERVICE'
|
||||
'PID_FILE'
|
||||
'PREFERED_IFACE'
|
||||
'PROFILE_DIR'
|
||||
'RFKILL_DIR'
|
||||
'SKIPCOMPONENTS'
|
||||
'STARTTOTRAY'
|
||||
'SUDO_PATH'
|
||||
'SYSTEMCTL_PATH'
|
||||
'SYSTRAY'
|
||||
'USE_HELPER'
|
||||
'WPACLI_PATH'
|
||||
'WPASUP_PATH'
|
||||
'WPA_DRIVERS'
|
||||
)
|
||||
|
||||
_netctl_gui_tabs=(
|
||||
'1'
|
||||
'2'
|
||||
'3'
|
||||
)
|
||||
|
||||
_netctl_profiles() {
|
||||
echo $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
|
||||
}
|
||||
|
||||
|
||||
# work block
|
||||
_netctl_gui() {
|
||||
COMPREPLY=()
|
||||
wantfiles='-@(c|-config)'
|
||||
wantprofiles='-@(o|-open|s|-select)'
|
||||
wantsettings='-@(-set-opts)'
|
||||
wantstring='-@(e|-essid)'
|
||||
wanttabs='-@(t|-tab)'
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
|
||||
if [[ $prev = $wantfiles ]]; then
|
||||
_filedir
|
||||
elif [[ $prev = $wantprofiles ]]; then
|
||||
COMPREPLY=($(compgen -W '$(_netctl_profiles)' -- "$cur"))
|
||||
elif [[ $prev = $wantsettings ]]; then
|
||||
COMPREPLY=($(compgen -S ',' -W '${_netctl_gui_settings[@]}' -- "$cur"))
|
||||
elif [[ $prev = $wantstring ]]; then
|
||||
COMPREPLY=()
|
||||
elif [[ $prev = $wanttabs ]]; then
|
||||
COMPREPLY=($(compgen -W '${_netctl_gui_tabs[@]}' -- "$cur"))
|
||||
else
|
||||
COMPREPLY=($(compgen -W '${_netctl_gui_arglist[@]}' -- "$cur"))
|
||||
fi
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
complete -F _netctl_gui netctl-gui
|
12
sources/gui/docs/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# build pages
|
||||
file (GLOB SUBPROJECT_DOCS_IN *.html)
|
||||
file (GLOB SUBPROJECT_IMGS *.png)
|
||||
foreach (DOC_IN ${SUBPROJECT_DOCS_IN})
|
||||
file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN})
|
||||
configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
endforeach ()
|
||||
|
||||
|
||||
install (FILES ${SUBPROJECT_DOCS} DESTINATION share/doc/${PROJECT_NAME})
|
||||
install (FILES ${SUBPROJECT_IMGS} DESTINATION share/doc/${PROJECT_NAME})
|
BIN
sources/gui/docs/architecture.png
Normal file
After Width: | Height: | Size: 40 KiB |
381
sources/gui/docs/netctl-gui-dbus-api.html
Normal file
@ -0,0 +1,381 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>netctl-gui DBus API desription</title>
|
||||
<style type="text/css">
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th, td {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #000000;
|
||||
};
|
||||
td {
|
||||
text-align: justify;
|
||||
}
|
||||
th {
|
||||
text-align: center;
|
||||
}
|
||||
th.sub {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
small {
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>netctl-gui DBus API description</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#api">DBus API</a></li>
|
||||
<li><a href="#helper">Helper API</a></li>
|
||||
<li><a href="#ctrl">Helper ctrl API</a></li>
|
||||
<li><a href="#netctl">Helper netctl API</a></li>
|
||||
<li><a href="#gui">GUI API</a></li>
|
||||
<li><a href="#netctlgui">GUI netctlgui API</a></li>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
|
||||
<h2><a href="#api" class="anchor" id="api"></a>DBus API</h2>
|
||||
<table>
|
||||
<tbody><tr>
|
||||
<th>method</th>
|
||||
<th>responce</th>
|
||||
<th>run as root</th>
|
||||
</tr>
|
||||
<!-- helper service -->
|
||||
<tr>
|
||||
<th colspan="3"><a href="#helper" class="anchor" id="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th>
|
||||
</tr>
|
||||
<!-- /ctrl path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#ctrl" class="anchor" id="ctrl"></a><code>/ctrl</code> path</th>
|
||||
</tr>
|
||||
<!-- helper actions -->
|
||||
<tr>
|
||||
<td>bool Active()</td>
|
||||
<td><code>true</code> if the helper is active</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ApiDocs()</td>
|
||||
<td>returns path to this API documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Close()</td>
|
||||
<td><code>true</code> and closes the helper</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList FindSettings()</td>
|
||||
<td>scans system and suggests the recommended configuration which will be used by the library</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString LibraryDocs()</td>
|
||||
<td>returns path to the library documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString Pony()</td>
|
||||
<td>prints Pinkie Pie to stdout. Really, just try</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString SecurityDocs()</td>
|
||||
<td>returns path to the security documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Settings()</td>
|
||||
<td>current helper settings <code>KEY==VALUE</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList UIDs()</td>
|
||||
<td>returns the helper process UIDs <code>[UID, EUID]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Update()</td>
|
||||
<td>calls update the helper configuration. Returns <code>true</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- netctl actions -->
|
||||
<tr>
|
||||
<td>bool Enable(QString profile)</td>
|
||||
<td>enables or disables the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool forceStart(QString profile)</td>
|
||||
<td>force starts the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool forceStop(QString profile)</td>
|
||||
<td>force stops the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Reenable(QString profile)</td>
|
||||
<td>reenables the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Restart(QString profile)</td>
|
||||
<td>restarts the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Start(QString profile)</td>
|
||||
<td>starts or stops the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool StopAll()</td>
|
||||
<td>stops all active profiles. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool SwitchTo(QString profile)</td>
|
||||
<td>switchs to the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Create(QString profile, QStringList settingsList)</td>
|
||||
<td>creates the profile with specified settings. Settings should be given in the format <code>KEY==VALUE</code>. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Remove(QString profile)</td>
|
||||
<td>removes the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- netctl-auto actions -->
|
||||
<tr>
|
||||
<td>bool autoDisableAll()</td>
|
||||
<td>disables all profiles (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoEnable(QString profile)</td>
|
||||
<td>enables or disables the profile (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoEnableAll()</td>
|
||||
<td>enables all profiles (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoStart(QString profile)</td>
|
||||
<td>switchs to the profile (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<!-- netctl-auto service actions -->
|
||||
<tr>
|
||||
<td>bool autoServiceEnable()</td>
|
||||
<td>enables or disables netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoServiceRestart()</td>
|
||||
<td>restarts netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoServiceStart()</td>
|
||||
<td>starts or stops netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- wpa_supplicant actions -->
|
||||
<tr>
|
||||
<td>QStringList WiFi()</td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- /netctl path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th>
|
||||
</tr>
|
||||
<!-- general information -->
|
||||
<tr>
|
||||
<td>QString ActiveProfile()</td>
|
||||
<td>returns active profile from netctl or netctl-auto</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString 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>
|
||||
<tr>
|
||||
<td>QStringList Information()</td>
|
||||
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList ProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList WirelessInterface()</td>
|
||||
<td>returns wireless interfaces</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- netctl specific information -->
|
||||
<tr>
|
||||
<td>bool isProfileActive(QString profile)</td>
|
||||
<td>returns <code>true</code> if the profile is active</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool isProfileEnabled(QString profile)</td>
|
||||
<td>returns <code>true</code> if the profile is enabled</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- netctl-auto specific information -->
|
||||
<tr>
|
||||
<td>bool autoIsProfileActive(QString profile)</td>
|
||||
<td>returns <code>true</code> if the profile is active (netctl-auto)</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoIsProfileEnabled(QString profile)</td>
|
||||
<td>returns <code>true</code> if the profile is enabled (netctl-auto)</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool isNetctlAutoActive()</td>
|
||||
<td>returns <code>true</code> if netctl-auto is active</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool isNetctlAutoEnabled()</td>
|
||||
<td>returns <code>true</code> if netctl-auto is enabled</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- profile information -->
|
||||
<tr>
|
||||
<td>QStringList Profile(QString profile)</td>
|
||||
<td>returns the profile settings in format <code>KEY==VALUE</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ProfileByEssid(QString essid)</td>
|
||||
<td>returns the profile name by the given ESSID or empty line</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ProfileValue(QString profile, QString key)</td>
|
||||
<td>returns value of the key by the given profile or empty line</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- gui service -->
|
||||
<tr>
|
||||
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
|
||||
</tr>
|
||||
<!-- /netctlgui path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
|
||||
</tr>
|
||||
<!-- gui actions -->
|
||||
<tr>
|
||||
<td>bool Active()</td>
|
||||
<td><code>true</code> if the application is active</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>void ApiDocs()</td>
|
||||
<td>opens this API documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Close()</td>
|
||||
<td><code>true</code> and closes the application</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString Information()</td>
|
||||
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>void LibraryDocs()</td>
|
||||
<td>opens the library documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString Pony()</td>
|
||||
<td>prints Pinkie Pie to stdout. Really, just try</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Restore()</td>
|
||||
<td><code>true</code> and restores the application</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>void SecurityDocs()</td>
|
||||
<td>opens the security documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Settings()</td>
|
||||
<td>current application settings <code>KEY==VALUE</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool ShowAbout()</td>
|
||||
<td><code>true</code> and shows about window</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool ShowMain()</td>
|
||||
<td><code>true</code> and shows main window</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool ShowNetctlAuto()</td>
|
||||
<td><code>true</code> and shows netctl-auto window</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool ShowSettings()</td>
|
||||
<td><code>true</code> and shows settings window</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList UIDs()</td>
|
||||
<td>returns the application process UIDs <code>[UID, EUID]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList VerboseInformation()</td>
|
||||
<td>returns information in format <code>[isNetctlAutoActive, ProfileList, ActiveProfile, isProfileEnabled/autoIsProfileEnabled]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<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://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
||||
<small>
|
||||
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||
This software is licensed under @PROJECT_LICENSE@
|
||||
</small>
|
||||
|
||||
</body>
|
||||
</html>
|
112
sources/gui/docs/netctl-gui-security-notes.html
Normal file
@ -0,0 +1,112 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>netctl-gui secutiry notes</title>
|
||||
<style type="text/css">
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
small {
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>netctl-gui security notes</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#arch">Architecture</a></li>
|
||||
<li><a href="#library">Library</a></li>
|
||||
<li><a href="#helper">Helper</a></li>
|
||||
<li><a href="#gui">Graphical interface</a></li>
|
||||
<li><a href="#kde">KDE components</a></li>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
|
||||
<h2><a href="#description" class="anchor" id="description"></a>Description</h2>
|
||||
<p></p>
|
||||
|
||||
<h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
|
||||
<img src="architecture.png" alt="architecture">
|
||||
|
||||
<h2><a href="#library" class="anchor" id="library"></a>Library</h2>
|
||||
<p>According to <a href="#arch">the scheme</a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
|
||||
<ul>
|
||||
<li>Netctl control module</li>
|
||||
<li><ul>
|
||||
<li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable <profile></code>. They are commands which provide a general control to netctl.</li>
|
||||
<li><code>systemctl start|restart|enable <netctl-auto@service></code>. They are commands which provide ability to control netctl-auto systemd service.</li>
|
||||
</ul></li>
|
||||
<li>Netctl profiles module</li>
|
||||
<li><ul>
|
||||
<li>Copying of a temporary profile from home directory to netctl profiles directory. <code>cp</code> command is used for it.</li>
|
||||
<li>Removal of a profile. <code>rm</code> command is used for it.</li>
|
||||
</ul></li>
|
||||
<li>WiFi module</li>
|
||||
<li><ul>
|
||||
<li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
|
||||
|
||||
<p>Profiles reading should be described. Since profiles has shell-like syntax some variables (which provide an array) cannot be reading by usual ways. To do it library uses bash:</p>
|
||||
<pre>
|
||||
# define system variables
|
||||
env -i bash -c "set"
|
||||
# get profile and system variable list
|
||||
env -i bash -c "source '<profile>'; set"
|
||||
# get profile variables
|
||||
env -i bash -c "source '<profile>'; for i in ${!<key>[@]}; do echo ${<key>[$i]}; done"
|
||||
</pre>
|
||||
|
||||
<h2><a href="#helper" class="anchor" id="helper"></a>Helper</h2>
|
||||
<p>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>network</code> group by default (or must be root). But you may change it by editing <code>$DBUS_SYSTEMCONF_PATH/org.netctlgui.helper.conf</code> policy file (<code>/etc/dbus-1/system.d/org.netctlgui.helper.conf</code> by default). Please refer to DBus documentation to do it.</p>
|
||||
|
||||
<p>By default <code>netctgui-helper</code> binary has capabilities to set UID to the children processes (<code>CAP_SETUID</code>). If you do not want to get these capabilities you may use <code>-DUSE_CAPABILITIES</code> cmake flag. Please refer to <code>man 7 capabilities</code> for more details.</p>
|
||||
|
||||
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
|
||||
|
||||
<h2><a href="#gui" class="anchor" id="gui"></a>Graphical interface</h2>
|
||||
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
|
||||
|
||||
<h2><a href="#kde" class="anchor" id="kde"></a>KDE components</h2>
|
||||
<p>There are two netctl-based commands which are run from the DataEngine</p>
|
||||
<ul>
|
||||
<li><code><cmd> list</code></li>
|
||||
<li><code>netctl is-enabled <profile></code></li>
|
||||
</ul>
|
||||
<p>Both of them do not require any additional privileges normally. Also DataEngine has two other command which will be run from; they should define external IP. According to the idea that user can set <b>any</b> command to run, this module is not secure. But running commands will not do more than user can do from console himself.</p>
|
||||
|
||||
<p>The widget gets information from DataEngine, thus it does not require any additional permissions to show information. But netctl calls are used to control netctl. In this case used commands are</p>
|
||||
<ul>
|
||||
<li><code>netctl enable <profile></code></li>
|
||||
<li><code>netctl disable <profile></code></li>
|
||||
<li><code>netctl restart <profile></code></li>
|
||||
<li><code>netctl start <profile></code></li>
|
||||
<li><code>netctl stop <profile></code></li>
|
||||
<li><code>netctl stop-all</code></li>
|
||||
<li><code>netctl switch-to <profile></code></li>
|
||||
<li><code>netctl-auto switch-to <profile></code></li>
|
||||
</ul>
|
||||
<p>All netctl-based commands <b>require</b> root privileges and <code>sudo</code> (and any other alternatives) is used normally as prefix to the commands. The netctl-auto command <b>does not require</b> additional permissions.</p>
|
||||
|
||||
<p>The other way is to use DBus communication with <a href="#helper">the helper</a>. In this case user should have rights to start the helper.</p>
|
||||
|
||||
<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://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
||||
<small>
|
||||
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||
This software is licensed under @PROJECT_LICENSE@
|
||||
</small>
|
||||
|
||||
</body>
|
||||
</html>
|
BIN
sources/gui/docs/rawscheme.ppt
Normal file
@ -1,63 +1,78 @@
|
||||
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "USER COMMANDS"
|
||||
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "General Commands Manual"
|
||||
.SH NAME
|
||||
netctl-gui is a graphical interface for netctl
|
||||
.SH SYNOPSIS
|
||||
.B netctl-gui
|
||||
[ --about ] [ --netctl-auto ] [ --settings ]
|
||||
[ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]
|
||||
[ -s PROFILE | --select PROFILE ]
|
||||
[ --config FILE ] [ -d | --debug ] [ --default ]
|
||||
[ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]
|
||||
[ -v | --version ] [ -i | --info ] [ -h | --help]
|
||||
[ options ]
|
||||
.SH DESCRIPTION
|
||||
Graphical user interface for netctl written on C++ using Qt toolkit. Provides shared library for interaction with netctl and Plasmoid and DataEngine for KDE.
|
||||
.B netctl-gui
|
||||
is a project which provides graphical user interface for
|
||||
.B netctl
|
||||
written on C++ using Qt toolkit. It provides shared library and DBus API (through helper daemon) and Plasmoid and DataEngine for KDE.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
--about
|
||||
.IP "--detached"
|
||||
run detached from console
|
||||
.IP "--maximized"
|
||||
run maximized
|
||||
.IP "--minimized"
|
||||
run to system tray if it is available
|
||||
.IP "--about"
|
||||
show about window
|
||||
.TP
|
||||
--netctl-auto
|
||||
.IP "--netctl-auto"
|
||||
show netctl-auto window
|
||||
.TP
|
||||
--settings
|
||||
.IP "--settings"
|
||||
show settings window
|
||||
.TP
|
||||
-e, --essid ESSID
|
||||
select ESSID ESSID. This option will set tab to 3 automatically
|
||||
.TP
|
||||
-o, --open PROFILE
|
||||
open profile PROFILE. This option will set tab to 2 automatically
|
||||
.TP
|
||||
-s, --select PROFILE
|
||||
select profile PROFILE. This option will set tab to 1 automatically
|
||||
.TP
|
||||
--config FILE
|
||||
read configuration from file FILE
|
||||
.TP
|
||||
-d, --debug
|
||||
.IP "-e, --essid ESSID"
|
||||
select ESSID
|
||||
.I ESSID
|
||||
This option will set tab to 3 automatically
|
||||
.IP "-o, --open PROFILE"
|
||||
open profile
|
||||
.I PROFILE
|
||||
This option will set tab to 2 automatically
|
||||
.IP "-s, --select PROFILE"
|
||||
select profile
|
||||
.I PROFILE
|
||||
This option will set tab to 1 automatically
|
||||
.IP "-c, --config FILE"
|
||||
read configuration from file
|
||||
.I FILE
|
||||
.IP "-d, --debug"
|
||||
print debug information
|
||||
.TP
|
||||
--default
|
||||
.IP "--default"
|
||||
start with default settings
|
||||
.TP
|
||||
--set-opts OPTIONS
|
||||
set options OPTIONS for this run, comma separated. Example "LANGUAGE=en,NETCTL_PATH=/usr/bin/netctl"
|
||||
.TP
|
||||
-t, --tab NUM
|
||||
open a tab with number NUM
|
||||
.TP
|
||||
-v, --version
|
||||
.IP "--set-opts OPTIONS"
|
||||
set options
|
||||
.I OPTIONS
|
||||
for this run, comma separated. Example:
|
||||
.nf
|
||||
LANGUAGE=en,NETCTL_PATH=/path/to/ponies
|
||||
.fi
|
||||
.IP "-t, --tab NUM"
|
||||
open a tab with number
|
||||
.I NUM
|
||||
.IP "-v, --version"
|
||||
show version and exit
|
||||
.TP
|
||||
-i, --info
|
||||
.IP "-i, --info"
|
||||
show build information and exit
|
||||
.TP
|
||||
-h, --help
|
||||
.IP "-h, --help"
|
||||
show this help and exit
|
||||
.SH FILES
|
||||
.TP
|
||||
$HOME/.config/netctl-gui.conf
|
||||
.I $HOME/.config/netctl-gui.conf
|
||||
.RS
|
||||
Configuration file
|
||||
.RE
|
||||
.SH SEE ALSO
|
||||
.BR netctlgui-helper (1)
|
||||
.BR netctl-gui.conf (5)
|
||||
.SH STANDARDS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html
|
||||
for more details.
|
||||
.SH SECURITY CONSIDERATIONS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html
|
||||
for more details.
|
||||
.SH AUTHOR
|
||||
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
|
||||
.SH LICENSE
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=Netctl GUI
|
||||
Comment=GUI written on Qt4 for netctl
|
||||
Comment=Qt graphical user interface for netctl
|
||||
Exec=netctl-gui
|
||||
Icon=netctl-gui.png
|
||||
Terminal=false
|
||||
|
@ -1,7 +1,9 @@
|
||||
# set files
|
||||
file (GLOB SOURCES *.cpp)
|
||||
file (GLOB HEADERS *.h)
|
||||
file (GLOB FORMS *.ui)
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp)
|
||||
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)
|
||||
|
||||
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
|
||||
@ -11,16 +13,15 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/includ
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||
|
||||
if (USE_QT5)
|
||||
find_package(Qt5Core REQUIRED)
|
||||
find_package(Qt5Widgets REQUIRED)
|
||||
find_package(Qt5LinguistTools REQUIRED)
|
||||
add_definitions(${Qt5Core_DEFINITIONS})
|
||||
add_definitions(${Qt5Widgets_DEFINITIONS})
|
||||
add_definitions(${Qt5LinguistTools_DEFINITIONS})
|
||||
find_package(Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
|
||||
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
@ -34,17 +35,10 @@ if (USE_QT5)
|
||||
endforeach ()
|
||||
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
|
||||
else ()
|
||||
find_package (Qt4 REQUIRED)
|
||||
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
@ -58,14 +52,9 @@ else ()
|
||||
endforeach ()
|
||||
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
||||
endif()
|
||||
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||
# install properties
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
|
@ -1,105 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>About</class>
|
||||
<widget class="QWidget" name="About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>390</width>
|
||||
<height>290</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_version">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="spacer_about">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_links">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_license">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -22,6 +22,8 @@
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
@ -38,7 +40,7 @@ AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
|
||||
|
||||
AboutWindow::~AboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete uiAbout;
|
||||
delete ui;
|
||||
@ -47,45 +49,58 @@ AboutWindow::~AboutWindow()
|
||||
|
||||
void AboutWindow::createText()
|
||||
{
|
||||
if (debug) qDebug() << "[AboutWindow]" << "[createText]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// 1st tab
|
||||
uiAbout->label_name->setText(QString(NAME));
|
||||
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
|
||||
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
|
||||
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
|
||||
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(QApplication::translate("AboutWindow", "Homepage")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(QApplication::translate("AboutWindow", "Repository")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(QApplication::translate("AboutWindow", "Bugtracker")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(QApplication::translate("AboutWindow", "Translation issue")) +\
|
||||
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES)).arg(QApplication::translate("AboutWindow", "AUR packages")));
|
||||
uiAbout->label_license->setText(QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE))
|
||||
.arg(QApplication::translate("AboutWindow", "Homepage")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY))
|
||||
.arg(QApplication::translate("AboutWindow", "Repository")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER))
|
||||
.arg(QApplication::translate("AboutWindow", "Bugtracker")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION))
|
||||
.arg(QApplication::translate("AboutWindow", "Translation issue")) +\
|
||||
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES))
|
||||
.arg(QApplication::translate("AboutWindow", "AUR packages")));
|
||||
uiAbout->label_license->setText(QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>")
|
||||
.arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
|
||||
QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) +
|
||||
QString("</small>"));
|
||||
// 2nd tab
|
||||
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]);
|
||||
uiAbout->label_translators->setText(QApplication::translate("AboutWindow", "Translators: %1").arg(QString(TRANSLATORS)));
|
||||
uiAbout->label_trdparty->setText(QApplication::translate("AboutWindow", "This software uses: %1").arg(trdPartyList.join(QString(", "))));
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::createUi()
|
||||
{
|
||||
if (debug) qDebug() << "[AboutWindow]" << "[createUi]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QWidget *aboutWidget = new QWidget();
|
||||
uiAbout = new Ui::About;
|
||||
uiAbout->setupUi(aboutWidget);
|
||||
ui->verticalLayout->addWidget(aboutWidget);
|
||||
ui->verticalLayout->insertWidget(0, aboutWidget);
|
||||
createText();
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox;
|
||||
buttonBox->addButton(QDialogButtonBox::Close);
|
||||
ui->verticalLayout->addWidget(buttonBox);
|
||||
connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (pressedKey->key() == Qt::Key_Escape)
|
||||
close();
|
||||
|
@ -6,15 +6,23 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>380</width>
|
||||
<height>307</height>
|
||||
<width>516</width>
|
||||
<height>431</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
105
sources/gui/src/dbusoperation.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/***************************************************************************
|
||||
* 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 "dbusoperation.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlProfileInfo> profileInfo;
|
||||
if (raw.size() == 0)
|
||||
return profileInfo;
|
||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||
netctlProfileInfo profile;
|
||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||
profile.name = info[0];
|
||||
profile.description = info[1];
|
||||
profile.active = info[2].toInt();
|
||||
profile.enabled = info[3].toInt();
|
||||
profileInfo.append(profile);
|
||||
}
|
||||
|
||||
return profileInfo;
|
||||
}
|
||||
|
||||
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlWifiInfo> wifiInfo;
|
||||
if (raw.size() == 0)
|
||||
return wifiInfo;
|
||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||
netctlWifiInfo wifi;
|
||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||
wifi.name = info[0];
|
||||
wifi.security = info[1];
|
||||
wifi.signal = info[2];
|
||||
wifi.active = info[3].toInt();
|
||||
wifi.exists = info[4].toInt();
|
||||
wifiInfo.append(wifi);
|
||||
}
|
||||
|
||||
return wifiInfo;
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd,
|
||||
const QList<QVariant> args, const bool system,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Service" << service;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Path" << path;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Interface" << interface;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
|
||||
|
||||
QList<QVariant> arguments;
|
||||
QDBusMessage response;
|
||||
if (system) {
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
if (!args.isEmpty())
|
||||
request.setArguments(args);
|
||||
response = bus.call(request, QDBus::BlockWithGui);
|
||||
} else {
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
if (!args.isEmpty())
|
||||
request.setArguments(args);
|
||||
response = bus.call(request, QDBus::BlockWithGui);
|
||||
}
|
||||
arguments = response.arguments();
|
||||
if (arguments.size() == 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
|
||||
return arguments;
|
||||
}
|
36
sources/gui/src/dbusoperation.h
Normal file
@ -0,0 +1,36 @@
|
||||
/***************************************************************************
|
||||
* 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 DBUSOPERATION_H
|
||||
#define DBUSOPERATION_H
|
||||
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||
const bool debug = false);
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||
const bool debug = false);
|
||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd,
|
||||
const QList<QVariant> args = QList<QVariant>(),
|
||||
const bool system = true, const bool debug = false);
|
||||
|
||||
|
||||
#endif /* DBUSOPERATION_H */
|
@ -22,6 +22,8 @@
|
||||
#include <QSpacerItem>
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
||||
: debug(debugCmd)
|
||||
@ -31,14 +33,15 @@ ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
||||
|
||||
ErrorWindow::~ErrorWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[~ErrorWindow]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
QStringList ErrorWindow::getMessage(const int mess)
|
||||
QStringList ErrorWindow::getMessage(const int mess, const QString custom)
|
||||
{
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]";
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||
|
||||
QString message, title;
|
||||
switch(mess) {
|
||||
@ -114,11 +117,17 @@ QStringList ErrorWindow::getMessage(const int mess)
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
|
||||
break;
|
||||
case 19:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not run helper");
|
||||
break;
|
||||
default:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
break;
|
||||
}
|
||||
if (!custom.isEmpty())
|
||||
message = custom;
|
||||
|
||||
QStringList fullMessage;
|
||||
fullMessage.append(title);
|
||||
@ -129,63 +138,30 @@ QStringList ErrorWindow::getMessage(const int mess)
|
||||
|
||||
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
{
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]";
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]" << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
|
||||
QMessageBox::Icon icon;
|
||||
switch(mess) {
|
||||
case 1:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 2:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 3:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 4:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 5:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 6:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 7:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 8:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 9:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 10:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 11:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 12:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 13:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 14:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 15:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 16:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 17:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
case 18:
|
||||
case 19:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
default:
|
||||
@ -197,13 +173,14 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
}
|
||||
|
||||
|
||||
void ErrorWindow::showWindow(const int mess, const QString sender)
|
||||
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom)
|
||||
{
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]";
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||
|
||||
QStringList message = getMessage(mess);
|
||||
QStringList message = getMessage(mess, custom);
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(message[0]);
|
||||
messageBox.setInformativeText(message[1]);
|
||||
|
@ -33,11 +33,12 @@ public:
|
||||
|
||||
public slots:
|
||||
void showWindow(const int mess = 0,
|
||||
const QString sender = QString());
|
||||
const QString sender = QString(),
|
||||
const QString custom = QString());
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QStringList getMessage(const int mess);
|
||||
QStringList getMessage(const int mess, const QString custom = QString());
|
||||
QMessageBox::Icon getIcon(const int mess);
|
||||
};
|
||||
|
||||
|
@ -88,8 +88,7 @@ void EthernetWidget::showAdvanced()
|
||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||
ui->widget_ethernetAdvanced->setHidden(false);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_ethernetAdvanced->setHidden(true);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
|
||||
}
|
||||
|
@ -114,8 +114,7 @@ void GeneralWidget::showAdvanced()
|
||||
if (ui->pushButton_generalAdvanced->isChecked()) {
|
||||
ui->widget_generalAdvanced->setHidden(false);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_generalAdvanced->setHidden(true);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
|
||||
}
|
||||
@ -162,7 +161,9 @@ int GeneralWidget::isOk()
|
||||
// bind interfaces is not set
|
||||
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("vlan")))
|
||||
(ui->comboBox_connection->currentText() == QString("vlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
||||
if (ui->listWidget_bindto->count() == 0)
|
||||
return 1;
|
||||
// empty description
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>429</width>
|
||||
<height>535</height>
|
||||
<width>425</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -123,6 +123,11 @@
|
||||
<string notr="true">macvlan</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">openvswitch</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -315,8 +315,7 @@ void IpWidget::ipEnable(const int state)
|
||||
ui->comboBox_ip->setDisabled(true);
|
||||
ui->widget_ip->setDisabled(true);
|
||||
ui->widget_ipRoutes->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->comboBox_ip->setEnabled(true);
|
||||
ui->widget_ip->setEnabled(true);
|
||||
ui->widget_ipRoutes->setEnabled(true);
|
||||
@ -341,8 +340,7 @@ void IpWidget::ip6Enable(const int state)
|
||||
ui->comboBox_ip6->setDisabled(true);
|
||||
ui->widget_ip6->setDisabled(true);
|
||||
ui->widget_ipRoutes6->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->comboBox_ip6->setEnabled(true);
|
||||
ui->widget_ip6->setEnabled(true);
|
||||
ui->widget_ipRoutes6->setEnabled(true);
|
||||
@ -355,8 +353,7 @@ void IpWidget::changeDhcpClient(const QString currentText)
|
||||
if (currentText == QString("dhcpcd")) {
|
||||
ui->widget_dhcpcdOpt->setHidden(false);
|
||||
ui->widget_dhclientOpt->setHidden(true);
|
||||
}
|
||||
else if (currentText == QString("dhclient")) {
|
||||
} else if (currentText == QString("dhclient")) {
|
||||
ui->widget_dhcpcdOpt->setHidden(true);
|
||||
ui->widget_dhclientOpt->setHidden(false);
|
||||
}
|
||||
@ -368,8 +365,7 @@ void IpWidget::showAdvanced()
|
||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||
ui->widget_ipAdvanced->setHidden(false);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_ipAdvanced->setHidden(true);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
|
||||
}
|
||||
@ -398,8 +394,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Routes")] = routes.join(QChar(' '));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
ipSettings[QString("IP")] = QString("no");
|
||||
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
||||
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
||||
@ -417,8 +412,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
ipSettings[QString("IP6")] = QString("no");
|
||||
if (ui->listWidget_custom->count() > 0) {
|
||||
QStringList custom;
|
||||
@ -433,8 +427,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
|
||||
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
|
||||
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'");
|
||||
}
|
||||
else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
} else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
||||
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
|
||||
|
@ -1,113 +0,0 @@
|
||||
/***************************************************************************
|
||||
* 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 "language.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QLocale>
|
||||
|
||||
|
||||
Language::Language()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
|
||||
{
|
||||
QStringList availableLanguages = getAvailableLanguages();
|
||||
for (int i=0; i<availableLanguages.count(); i++)
|
||||
if (language == availableLanguages[i])
|
||||
return availableLanguages[i];
|
||||
for (int i=0; i<availableLanguages.count(); i++)
|
||||
if (language.contains(availableLanguages[i] + QChar('_')))
|
||||
return availableLanguages[i];
|
||||
|
||||
return defaultLanguage;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguage(const QString configPath, const QString options)
|
||||
{
|
||||
QMap<QString, QString> optionsDict = parseOptions(options);
|
||||
if (optionsDict.contains(QString("LANGUAGE")))
|
||||
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
|
||||
return optionsDict[QString("LANGUAGE")];
|
||||
|
||||
QString language;
|
||||
language = defineLanguageFromFile(configPath);
|
||||
if (language.isEmpty())
|
||||
language = defineLanguageFromLocale();
|
||||
language = checkLanguage(language, QString("en"));
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguageFromFile(const QString configPath)
|
||||
{
|
||||
QString language;
|
||||
if (configPath.isEmpty())
|
||||
return language;
|
||||
QFile configFile(configPath);
|
||||
QString fileStr;
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
return language;
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine());
|
||||
if (fileStr[0] == QChar('#')) continue;
|
||||
if (fileStr.contains(QString("LANGUAGE=")))
|
||||
language = fileStr.split(QChar('='))[1]
|
||||
.remove(QChar(' '))
|
||||
.trimmed();
|
||||
if (configFile.atEnd())
|
||||
break;
|
||||
}
|
||||
configFile.close();
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguageFromLocale()
|
||||
{
|
||||
return QLocale::system().name();
|
||||
}
|
||||
|
||||
|
||||
QStringList Language::getAvailableLanguages()
|
||||
{
|
||||
QStringList languages;
|
||||
languages.append(QString("en"));
|
||||
languages.append(QString("ru"));
|
||||
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> Language::parseOptions(const QString options)
|
||||
{
|
||||
QMap<QString, QString> optionsDict;
|
||||
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
|
||||
continue;
|
||||
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
|
||||
options.split(QChar(','))[i].split(QChar('='))[1];
|
||||
}
|
||||
|
||||
return optionsDict;
|
||||
}
|
@ -17,259 +17,178 @@
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <language/language.h>
|
||||
|
||||
#include "language.h"
|
||||
#include "mainwindow.h"
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
QChar isParametrEnable(const bool parametr)
|
||||
bool existingSessionOperation(const QString operation)
|
||||
{
|
||||
if (parametr)
|
||||
return QChar('*');
|
||||
else
|
||||
return QChar(' ');
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
|
||||
DBUS_INTERFACE, operation);
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return (!arguments.isEmpty() && bool(arguments[0].toInt()));
|
||||
}
|
||||
|
||||
|
||||
unsigned int getUidFromSession(const int type = 0)
|
||||
{
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
|
||||
DBUS_INTERFACE, QString("UIDs"));
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return arguments[0].toStringList()[type].toUInt();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QMap<QString, QVariant> args = getArgs();
|
||||
// reading
|
||||
for (int i=1; i<argc; i++) {
|
||||
if (QString(argv[i]) == QString("--detached")) {
|
||||
// detached
|
||||
args[QString("detached")] = true;
|
||||
} else if (QString(argv[i]) == QString("--maximized")) {
|
||||
// maximized
|
||||
args[QString("minimized")] = (int) 1;
|
||||
} else if (QString(argv[i]) == QString("--minimized")) {
|
||||
// minimized
|
||||
args[QString("minimized")] = (int) 2;
|
||||
} else if (QString(argv[i]) == QString("--about")) {
|
||||
// about
|
||||
args[QString("about")] = true;
|
||||
} else if (QString(argv[i]) == QString("--netctl-auto")) {
|
||||
// netctl-auto
|
||||
args[QString("auto")] = true;
|
||||
} else if (QString(argv[i]) == QString("--settings")) {
|
||||
// settings
|
||||
args[QString("settings")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
|
||||
// select ESSID
|
||||
args[QString("essid")] = QString(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
|
||||
// open profile
|
||||
args[QString("open")] = QString(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
|
||||
// select profile
|
||||
args[QString("select")] = QString(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) {
|
||||
// config path
|
||||
args[QString("config")] = QDir().absoluteFilePath(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
|
||||
// debug
|
||||
args[QString("debug")] = true;
|
||||
} else if (QString(argv[i]) == QString("--default")) {
|
||||
// default settings
|
||||
args[QString("default")] = true;
|
||||
} else if (QString(argv[i]) == QString("--set-opts")) {
|
||||
// options
|
||||
args[QString("options")] = QString(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
|
||||
// tab number
|
||||
if (atoi(argv[i+1]) > 3)
|
||||
args[QString("tab")] = (int) 3;
|
||||
else if (atoi(argv[i+1]) < 1)
|
||||
args[QString("tab")] = (int) 1;
|
||||
else
|
||||
args[QString("tab")] = atoi(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
|
||||
// help message
|
||||
args[QString("help")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
|
||||
// info message
|
||||
args[QString("info")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
|
||||
// version message
|
||||
args[QString("version")] = true;
|
||||
} else {
|
||||
args[QString("error")] = true;
|
||||
}
|
||||
}
|
||||
if ((args[QString("debug")].toBool()) ||
|
||||
(args[QString("help")].toBool()) ||
|
||||
(args[QString("info")].toBool()) ||
|
||||
(args[QString("version")].toBool()) ||
|
||||
(args[QString("error")].toBool()))
|
||||
args[QString("detached")] = false;
|
||||
if (args[QString("essid")].toString() != QString("ESSID"))
|
||||
args[QString("tab")] = (int) 3;
|
||||
if (args[QString("open")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = (int) 2;
|
||||
if (args[QString("select")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = (int) 1;
|
||||
|
||||
// translation
|
||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
||||
QDir::separator() + QString("netctl-gui.conf");
|
||||
QString language = Language::defineLanguage(configPath);
|
||||
// detach from console
|
||||
if (args[QString("detached")].toBool())
|
||||
daemon(0, 0);
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
// reread translations according to flags
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
a.installTranslator(&qtTranslator);
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations/") + language);
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// reading command line flags
|
||||
bool error = false;
|
||||
// windows
|
||||
bool showAbout = false;
|
||||
bool showNetctlAuto = false;
|
||||
bool showSettings = false;
|
||||
// main functions
|
||||
QString selectEssid = QString("ESSID");
|
||||
QString openProfile = QString("PROFILE");
|
||||
QString selectProfile = QString("PROFILE");
|
||||
// additional functions
|
||||
bool debug = false;
|
||||
bool defaultSettings = false;
|
||||
QString options = QString("OPTIONS");
|
||||
int tabNumber = 1;
|
||||
// messages
|
||||
bool showVersion = false;
|
||||
bool showInfo = false;
|
||||
bool showHelp = false;
|
||||
// reading
|
||||
for (int i=1; i<argc; i++) {
|
||||
// windows
|
||||
// about
|
||||
if (QString(argv[i]) == QString("--about")) {
|
||||
showAbout = true;
|
||||
}
|
||||
// netctl-auto
|
||||
else if (QString(argv[i]) == QString("--netctl-auto")) {
|
||||
showNetctlAuto = true;
|
||||
}
|
||||
// settings
|
||||
else if (QString(argv[i]) == QString("--settings")) {
|
||||
showSettings = true;
|
||||
}
|
||||
// main functions
|
||||
// select ESSID
|
||||
else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
|
||||
selectEssid = QString(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// open profile
|
||||
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
|
||||
openProfile = QString(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// select profile
|
||||
else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
|
||||
selectProfile = QString(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// additional functions
|
||||
// config path
|
||||
else if (QString(argv[i]) == QString("--config")) {
|
||||
configPath = QString(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// debug
|
||||
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
|
||||
debug = true;
|
||||
}
|
||||
// default settings
|
||||
else if (QString(argv[i]) == QString("--default")) {
|
||||
defaultSettings = true;
|
||||
}
|
||||
// options
|
||||
else if (QString(argv[i]) == QString("--set-opts")) {
|
||||
options = QString(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// tab number
|
||||
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
|
||||
if (atoi(argv[i+1]) > 3)
|
||||
tabNumber = 3;
|
||||
else if (atoi(argv[i+1]) < 1)
|
||||
tabNumber = 1;
|
||||
else
|
||||
tabNumber = atoi(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// messages
|
||||
// version message
|
||||
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
|
||||
showVersion = true;
|
||||
}
|
||||
// info message
|
||||
else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
|
||||
showInfo = true;
|
||||
}
|
||||
// help message
|
||||
else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
|
||||
showHelp = true;
|
||||
}
|
||||
else {
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
if (selectEssid != QString("ESSID"))
|
||||
tabNumber = 3;
|
||||
if (openProfile != QString("PROFILE"))
|
||||
tabNumber = 2;
|
||||
if (selectProfile != QString("PROFILE"))
|
||||
tabNumber = 1;
|
||||
|
||||
// messages
|
||||
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
|
||||
|
||||
QString helpMessage = QString("");
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
|
||||
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
|
||||
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
|
||||
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
|
||||
helpMessage += QString(" [ --config FILE ] [ -d | --debug ] [ --default ]\n");
|
||||
helpMessage += QString(" [ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]\n");
|
||||
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
|
||||
// windows
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
||||
helpMessage += QString("%1 --about - %2\n")
|
||||
.arg(isParametrEnable(showAbout))
|
||||
.arg(QApplication::translate("MainWindow", "show about window"));
|
||||
helpMessage += QString("%1 --netctl-auto - %2\n")
|
||||
.arg(isParametrEnable(showNetctlAuto))
|
||||
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
||||
helpMessage += QString("%1 --settings - %2\n")
|
||||
.arg(isParametrEnable(showSettings))
|
||||
.arg(QApplication::translate("MainWindow", "show settings window"));
|
||||
// main functions
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Functions:"));
|
||||
helpMessage += QString(" -e %1 --essid %1 - %2\n")
|
||||
.arg(selectEssid, -10)
|
||||
.arg(QApplication::translate("MainWindow", "select ESSID %1").arg(selectEssid));
|
||||
helpMessage += QString(" -o %1 --open %1 - %2\n")
|
||||
.arg(openProfile, -10)
|
||||
.arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
|
||||
helpMessage += QString(" -s %1 --select %1 - %2\n")
|
||||
.arg(selectProfile, -10)
|
||||
.arg(QApplication::translate("MainWindow", "select profile %1").arg(selectProfile));
|
||||
// additional functions
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
|
||||
helpMessage += QString(" --config %1\n")
|
||||
.arg(configPath, -10);
|
||||
helpMessage += QString(" - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
|
||||
helpMessage += QString("%1 -d --debug - %2\n")
|
||||
.arg(isParametrEnable(debug))
|
||||
.arg(QApplication::translate("MainWindow", "print debug information"));
|
||||
helpMessage += QString("%1 --default - %2\n")
|
||||
.arg(isParametrEnable(defaultSettings))
|
||||
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||
helpMessage += QString(" --set-opts %1\n")
|
||||
.arg(options, -10);
|
||||
helpMessage += QString(" - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
|
||||
helpMessage += QString(" -t %1 --tab %1 - %2\n")
|
||||
.arg(QString::number(tabNumber), -3)
|
||||
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
|
||||
// messages
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
|
||||
helpMessage += QString(" -v --version - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show version and exit"));
|
||||
helpMessage += QString(" -i --info - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show build information and exit"));
|
||||
helpMessage += QString(" -h --help - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show this help and exit"));
|
||||
|
||||
QString infoMessage = QString("");
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
|
||||
arg(QString(BUILD_DATE));
|
||||
infoMessage += QString("\n%1\n").arg(QApplication::translate("MainWindow", "cmake flags:"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
|
||||
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1 \\\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
|
||||
|
||||
QString versionMessage = QString("");
|
||||
versionMessage += QString("%1\n").arg(QString(NAME));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QApplication::translate("MainWindow", "Version"))
|
||||
.arg(QString(VERSION));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QApplication::translate("MainWindow", "Author"))
|
||||
.arg(QString(AUTHOR));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QApplication::translate("MainWindow", "License"))
|
||||
.arg(QString(LICENSE));
|
||||
|
||||
// reread translations
|
||||
a.removeTranslator(&translator);
|
||||
language = Language::defineLanguage(configPath, options);
|
||||
translator.load(QString(":/translations/") + language);
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// running
|
||||
if (error) {
|
||||
cout << errorMessage.toUtf8().data() << endl;
|
||||
cout << helpMessage.toUtf8().data();
|
||||
if (args[QString("error")].toBool()) {
|
||||
cout << errorMessage().toUtf8().data() << endl;
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 127;
|
||||
}
|
||||
if (showInfo) {
|
||||
cout << versionMessage.toUtf8().data() << endl;
|
||||
cout << infoMessage.toUtf8().data();
|
||||
} else if (args[QString("help")].toBool()) {
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 0;
|
||||
} else if (args[QString("info")].toBool()) {
|
||||
cout << versionMessage().toUtf8().data() << endl;
|
||||
cout << infoMessage().toUtf8().data();
|
||||
return 0;
|
||||
} else if (args[QString("version")].toBool()) {
|
||||
cout << versionMessage().toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
if (showHelp) {
|
||||
cout << helpMessage.toUtf8().data();
|
||||
return 0;
|
||||
|
||||
// check if exists
|
||||
if (existingSessionOperation(QString("Active"))) {
|
||||
if ((getuid() == getUidFromSession(0)) && (geteuid() == getUidFromSession(1))) {
|
||||
// restore session
|
||||
cout << QCoreApplication::translate("MainWindow", "Restore existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
existingSessionOperation(QString("Restore"));
|
||||
return 0;
|
||||
} else if ((getuid() == getUidFromSession(0)) && (geteuid() != getUidFromSession(1))) {
|
||||
cout << QCoreApplication::translate("MainWindow", "Close existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
existingSessionOperation(QString("Close"));
|
||||
}
|
||||
}
|
||||
if (showVersion) {
|
||||
cout << versionMessage.toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
MainWindow w(0,
|
||||
showAbout, showNetctlAuto, showSettings,
|
||||
selectEssid, openProfile, selectProfile,
|
||||
configPath, debug, defaultSettings, options, tabNumber);
|
||||
w.show();
|
||||
MainWindow w(0, args, &qtTranslator, &translator);
|
||||
return a.exec();
|
||||
}
|
||||
|
1127
sources/gui/src/mainprivateslots.cpp
Normal file
523
sources/gui/src/mainpublicslots.cpp
Normal file
@ -0,0 +1,523 @@
|
||||
/***************************************************************************
|
||||
* 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 "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
#include <language/language.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "trayicon.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
void MainWindow::closeMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showAboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
aboutWin->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHidden()) {
|
||||
updateTabs(ui->tabWidget->currentIndex());
|
||||
show();
|
||||
} else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showNetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
settingsWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::enableProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Enable"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->enableProfile(profile);
|
||||
current = netctlCommand->isProfileEnabled(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::restartProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Restart"),
|
||||
args, true, debug)[0].toBool();
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->restartProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
QStringList currentProfile = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
|
||||
QList<QVariant>(), true, debug)[0]
|
||||
.toString().split(QChar('|'));
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Start"),
|
||||
args, true, debug);
|
||||
else
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
QStringList currentProfile = netctlCommand->getActiveProfile();
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
netctlCommand->startProfile(profile);
|
||||
else
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::stopAllProfilesSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper)
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("StopAll"),
|
||||
QList<QVariant>(), true, debug);
|
||||
else
|
||||
netctlCommand->stopAllProfiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::switchToProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool netctlAutoStatus = false;
|
||||
if (useHelper)
|
||||
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
|
||||
bool current;
|
||||
if (netctlAutoStatus) {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->autoStartProfile(profile);
|
||||
current = netctlCommand->autoIsProfileActive(profile);
|
||||
}
|
||||
} else {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showApi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html"))))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showLibrary()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("html/index.html"))))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSecurityNotes()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"))))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("helper"))) {
|
||||
errorWin->showWindow(1, QString(PDEBUG));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath;
|
||||
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 (process.exitCode == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStopHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Close"),
|
||||
QList<QVariant>(), true, debug);
|
||||
|
||||
return !responce.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHelperActive())
|
||||
return forceStopHelper();
|
||||
else
|
||||
return forceStartHelper();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setTab(int tab)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
||||
|
||||
switch (tab) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
tab = 0;
|
||||
break;
|
||||
}
|
||||
ui->tabWidget->setCurrentIndex(tab);
|
||||
|
||||
updateTabs(tab);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
deleteObjects();
|
||||
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
if (args[QString("default")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
delete settingsWin;
|
||||
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"))))
|
||||
useHelper = true;
|
||||
else {
|
||||
useHelper = false;
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
QString language = Language::defineLanguage(configPath,
|
||||
args[QString("options")].toString());
|
||||
qtTranslator->load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qApp->installTranslator(qtTranslator);
|
||||
translator->load(QString(":/translations/") + language);
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
createObjects();
|
||||
createActions();
|
||||
createToolBars();
|
||||
|
||||
// tray
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
|
||||
(configuration[QString("SYSTRAY")] == QString("true")))
|
||||
trayIcon->setVisible(true);
|
||||
else
|
||||
trayIcon->setVisible(false);
|
||||
if (trayIcon->isVisible()) {
|
||||
if (configuration[QString("STARTTOTRAY")] == QString("true"))
|
||||
hide();
|
||||
else
|
||||
show();
|
||||
if (args[QString("minimized")].toInt() == 1)
|
||||
show();
|
||||
else if (args[QString("minimized")].toInt() == 2)
|
||||
hide();
|
||||
}
|
||||
else
|
||||
show();
|
||||
|
||||
// update ui
|
||||
setTab(args[QString("tab")].toInt() - 1);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateMenu()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
int tab = ui->tabWidget->currentIndex();
|
||||
setMenuActionsShown(false);
|
||||
|
||||
if (tab == 0)
|
||||
updateMenuMain();
|
||||
else if (tab == 1)
|
||||
updateMenuProfile();
|
||||
else if (tab == 2)
|
||||
updateMenuWifi();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateTabs(const int tab)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
||||
|
||||
if (tab == 0)
|
||||
updateMainTab();
|
||||
else if (tab == 1)
|
||||
updateProfileTab();
|
||||
else if (tab == 2)
|
||||
updateWifiTab();
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::connectToUnknownEssid(const QString passwd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (passwdWid != 0)
|
||||
delete passwdWid;
|
||||
QStringList interfaces;
|
||||
if (useHelper)
|
||||
interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
|
||||
QList<QVariant>(), true, debug)[0].toStringList();
|
||||
else
|
||||
interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
if (interfaces.isEmpty()) return;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||
settings[QString("Interface")] = interfaces[0];
|
||||
settings[QString("Connection")] = QString("wireless");
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text();
|
||||
if (security.contains(QString("WPA")))
|
||||
settings[QString("Security")] = QString("wpa");
|
||||
else if (security.contains(QString("WEP")))
|
||||
settings[QString("Security")] = QString("wep");
|
||||
else
|
||||
settings[QString("Security")] = QString("none");
|
||||
settings[QString("ESSID")] = QString("'") +
|
||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
|
||||
QString("'");
|
||||
if (!passwd.isEmpty())
|
||||
settings[QString("Key")] = QString("'") + passwd + QString("'");
|
||||
settings[QString("IP")] = QString("dhcp");
|
||||
if (hiddenNetwork)
|
||||
settings[QString("Hidden")] = QString("yes");
|
||||
|
||||
QString profile = QString("netctl-gui-") + settings[QString("ESSID")];
|
||||
profile.remove(QChar('"')).remove(QChar('\''));
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
settingsList.append(settings.keys()[i] + QString("==") + settings[settings.keys()[i]]);
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
args.append(settingsList);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Create"),
|
||||
args, true, debug);
|
||||
args.clear();
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Start"),
|
||||
args, true, debug);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
netctlProfile->copyProfile(profileTempName);
|
||||
netctlCommand->startProfile(profile);
|
||||
status = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
QString message;
|
||||
if (status) {
|
||||
message = QApplication::translate("MainWindow", "Connection is successfully.");
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
} else {
|
||||
message = QApplication::translate("MainWindow", "Connection failed.");
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
message += QString("\n");
|
||||
message += QApplication::translate("MainWindow", "Do you want to save profile %1?").arg(profile);
|
||||
int select = QMessageBox::question(this, QApplication::translate("MainWindow", "WiFi menu"),
|
||||
message, QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save);
|
||||
switch (select) {
|
||||
case QMessageBox::Save:
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
default:
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Remove"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
netctlProfile->removeProfile(profile);
|
||||
break;
|
||||
}
|
||||
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setHiddenName(const QString name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Set name" << name;
|
||||
|
||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
|
||||
|
||||
wifiTabStart();
|
||||
}
|
@ -20,7 +20,12 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QShortcut>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class AboutWindow;
|
||||
@ -31,17 +36,15 @@ class GeneralWidget;
|
||||
class IpWidget;
|
||||
class MacvlanWidget;
|
||||
class MobileWidget;
|
||||
class Netctl;
|
||||
class NetctlAutoWindow;
|
||||
class NetctlProfile;
|
||||
class PasswdWidget;
|
||||
class PppoeWidget;
|
||||
class SettingsWindow;
|
||||
class TrayIcon;
|
||||
class TunnelWidget;
|
||||
class TuntapWidget;
|
||||
class VlanWidget;
|
||||
class WirelessWidget;
|
||||
class WpaSup;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -53,32 +56,57 @@ class MainWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const bool showAbout = false,
|
||||
const bool showNetctlAuto = false,
|
||||
const bool showSettings = false,
|
||||
const QString selectEssid = QString("ESSID"),
|
||||
const QString openProfile = QString("PROFILE"),
|
||||
const QString selectProfile = QString("PROFILE"),
|
||||
const QString configPath = QString(""),
|
||||
const bool debugCmd = false,
|
||||
const bool defaultSettings = false,
|
||||
const QString options = QString("OPTIONS"),
|
||||
const int tabNum = 1);
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||
QTranslator *qtAppTranslator = 0,
|
||||
QTranslator *appTranslator = 0);
|
||||
~MainWindow();
|
||||
QStringList printInformation();
|
||||
QStringList printSettings();
|
||||
QStringList printTrayInformation();
|
||||
bool isHelperActive();
|
||||
bool isHelperServiceActive();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
public slots:
|
||||
// actions from trayicon
|
||||
void closeMainWindow();
|
||||
void showAboutWindow();
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// trayicon control slots
|
||||
bool enableProfileSlot(const QString profile);
|
||||
bool startProfileSlot(const QString profile);
|
||||
bool stopAllProfilesSlot();
|
||||
bool switchToProfileSlot(const QString profile);
|
||||
bool restartProfileSlot(const QString profile);
|
||||
// open docs
|
||||
void showApi();
|
||||
void showLibrary();
|
||||
void showSecurityNotes();
|
||||
// helper
|
||||
bool forceStartHelper();
|
||||
bool forceStopHelper();
|
||||
bool startHelper();
|
||||
// main
|
||||
void setTab(int tab);
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateMenu();
|
||||
void updateTabs(const int tab);
|
||||
void updateMenu(const int tab);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
void setHiddenName(const QString name);
|
||||
|
||||
private slots:
|
||||
void reportABug();
|
||||
// menu update slots
|
||||
void setMenuActionsShown(const bool state = true);
|
||||
void updateMenuMain();
|
||||
void updateMenuProfile();
|
||||
void updateMenuWifi();
|
||||
void updateToolBars();
|
||||
// tab update slots
|
||||
void updateMainTab();
|
||||
void updateProfileTab();
|
||||
@ -86,11 +114,13 @@ private slots:
|
||||
// main tab slots
|
||||
void mainTabContextualMenu(const QPoint &pos);
|
||||
void mainTabEditProfile();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabEnableProfile();
|
||||
QStringList mainTabGetActiveProfiles();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
void mainTabStopAllProfiles();
|
||||
void mainTabSwitchToProfile();
|
||||
// profile tab slots
|
||||
void profileTabChangeState(const QString current);
|
||||
void profileTabClear();
|
||||
@ -101,38 +131,52 @@ private slots:
|
||||
void wifiTabContextualMenu(const QPoint &pos);
|
||||
void wifiTabSetEnabled(const bool state);
|
||||
void wifiTabStart();
|
||||
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
|
||||
private:
|
||||
// ui
|
||||
Ui::MainWindow *ui;
|
||||
AboutWindow *aboutWin;
|
||||
ErrorWindow *errorWin;
|
||||
NetctlAutoWindow *netctlAutoWin;
|
||||
PasswdWidget *passwdWid;
|
||||
SettingsWindow *settingsWin;
|
||||
BridgeWidget *bridgeWid;
|
||||
EthernetWidget *ethernetWid;
|
||||
GeneralWidget *generalWid;
|
||||
IpWidget *ipWid;
|
||||
MacvlanWidget *macvlanWid;
|
||||
MobileWidget *mobileWid;
|
||||
PppoeWidget *pppoeWid;
|
||||
TunnelWidget *tunnelWid;
|
||||
TuntapWidget *tuntapWid;
|
||||
VlanWidget *vlanWid;
|
||||
WirelessWidget *wirelessWid;
|
||||
TrayIcon *trayIcon = nullptr;
|
||||
QMap<QString, QShortcut *> appShortcuts;
|
||||
QMap<QString, QAction *> toolBarActions;
|
||||
QToolButton *actionMenu = nullptr;
|
||||
QToolBar *actionToolBar = nullptr;
|
||||
QToolBar *helpToolBar = nullptr;
|
||||
QToolBar *mainToolBar = nullptr;
|
||||
Ui::MainWindow *ui = nullptr;
|
||||
AboutWindow *aboutWin = nullptr;
|
||||
ErrorWindow *errorWin = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
PasswdWidget *passwdWid = nullptr;
|
||||
SettingsWindow *settingsWin = nullptr;
|
||||
BridgeWidget *bridgeWid = nullptr;
|
||||
EthernetWidget *ethernetWid = nullptr;
|
||||
GeneralWidget *generalWid = nullptr;
|
||||
IpWidget *ipWid = nullptr;
|
||||
MacvlanWidget *macvlanWid = nullptr;
|
||||
MobileWidget *mobileWid = nullptr;
|
||||
PppoeWidget *pppoeWid = nullptr;
|
||||
TunnelWidget *tunnelWid = nullptr;
|
||||
TuntapWidget *tuntapWid = nullptr;
|
||||
VlanWidget *vlanWid = nullptr;
|
||||
WirelessWidget *wirelessWid = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand;
|
||||
NetctlProfile *netctlProfile;
|
||||
WpaSup *wpaCommand;
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
bool checkExternalApps(const QString apps);
|
||||
bool checkState(const QString state, const QString item);
|
||||
bool checkHelperStatus();
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
void createObjects();
|
||||
void createToolBars();
|
||||
void deleteObjects();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
void setIconsToButtons();
|
||||
bool debug;
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
bool hiddenNetwork;
|
||||
bool useHelper = true;
|
||||
QTranslator *qtTranslator = nullptr;
|
||||
QTranslator *translator = nullptr;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QMap<QString, QString> parseOptions(const QString options);
|
||||
|
@ -6,21 +6,59 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>479</width>
|
||||
<height>507</height>
|
||||
<width>469</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Netctl GUI</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="centralLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_menus">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_menu">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: none;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_action">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: none;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: none;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_main">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Connect to profile</string>
|
||||
</attribute>
|
||||
@ -68,6 +106,9 @@
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
@ -90,72 +131,10 @@
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mainButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRefresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRestart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_new">
|
||||
@ -165,6 +144,11 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Create a new profile</string>
|
||||
</attribute>
|
||||
@ -206,8 +190,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>96</width>
|
||||
<height>26</height>
|
||||
<width>437</width>
|
||||
<height>368</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -220,42 +204,15 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_newProfileButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileClear">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_newProfileButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_wifi">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Connect to Wi-Fi</string>
|
||||
<string>WiFi menu</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
@ -285,6 +242,9 @@
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
@ -295,293 +255,46 @@
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Signal</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wifiButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiRefresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_wifiButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>479</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMenu">
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionNetctlAuto"/>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuActions">
|
||||
<property name="title">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
<addaction name="actionMainRefresh"/>
|
||||
<addaction name="actionWifiRefresh"/>
|
||||
<addaction name="actionProfileClear"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainStart"/>
|
||||
<addaction name="actionMainRestart"/>
|
||||
<addaction name="actionMainEnable"/>
|
||||
<addaction name="actionProfileLoad"/>
|
||||
<addaction name="actionProfileSave"/>
|
||||
<addaction name="actionWifiStart"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainEdit"/>
|
||||
<addaction name="actionMainRemove"/>
|
||||
<addaction name="actionProfileRemove"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
<addaction name="menuActions"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset theme="configure">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainStart">
|
||||
<property name="icon">
|
||||
<iconset theme="dialog-apply">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRestart">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainEdit">
|
||||
<property name="icon">
|
||||
<iconset theme="edit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileClear">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWifiRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileLoad">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileSave">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWifiStart">
|
||||
<property name="icon">
|
||||
<iconset theme="dialog-apply">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Wi-Fi</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctlAuto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>tableWidget_main</tabstop>
|
||||
<tabstop>pushButton_mainRefresh</tabstop>
|
||||
<tabstop>pushButton_mainRestart</tabstop>
|
||||
<tabstop>pushButton_mainStart</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>pushButton_profileClear</tabstop>
|
||||
<tabstop>pushButton_profileSave</tabstop>
|
||||
<tabstop>tableWidget_wifi</tabstop>
|
||||
<tabstop>pushButton_wifiRefresh</tabstop>
|
||||
<tabstop>pushButton_wifiStart</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
177
sources/gui/src/messages.cpp
Normal file
@ -0,0 +1,177 @@
|
||||
/***************************************************************************
|
||||
* 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 <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
QString errorMessage()
|
||||
{
|
||||
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> getArgs()
|
||||
{
|
||||
QMap<QString, QVariant> args;
|
||||
// windows
|
||||
args[QString("detached")] = false;
|
||||
args[QString("minimized")] = (int) 0;
|
||||
args[QString("about")] = false;
|
||||
args[QString("auto")] = false;
|
||||
args[QString("settings")] = false;
|
||||
// main functions
|
||||
args[QString("essid")] = QString("ESSID");
|
||||
args[QString("open")] = QString("PROFILE");
|
||||
args[QString("select")] = QString("PROFILE");
|
||||
// additional functions
|
||||
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf"));
|
||||
args[QString("debug")] = false;
|
||||
args[QString("defaults")] = false;
|
||||
args[QString("options")] = QString("OPTIONS");
|
||||
args[QString("tab")] = (int) 1;
|
||||
// messages
|
||||
args[QString("error")] = false;
|
||||
args[QString("help")] = false;
|
||||
args[QString("info")] = false;
|
||||
args[QString("version")] = false;
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
QString helpMessage()
|
||||
{
|
||||
QString helpMessage = QString("");
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
|
||||
helpMessage += QString("netctl-gui [ options ]\n");
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
|
||||
// windows
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
||||
helpMessage += QString(" --detached - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start detached from console"));
|
||||
helpMessage += QString(" --maximized - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start maximized"));
|
||||
helpMessage += QString(" --minimized - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start minimized to tray"));
|
||||
helpMessage += QString(" --about - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show about window"));
|
||||
helpMessage += QString(" --netctl-auto - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
||||
helpMessage += QString(" --settings - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show settings window"));
|
||||
// main functions
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
|
||||
helpMessage += QString(" -e, --essid <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "select this ESSID"));
|
||||
helpMessage += QString(" -o, --open <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "open this profile"));
|
||||
helpMessage += QString(" -s, --select <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "select this profile"));
|
||||
// additional functions
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
|
||||
helpMessage += QString(" -c, --config <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
|
||||
helpMessage += QString(" -d, --debug - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "print debug information"));
|
||||
helpMessage += QString(" --default - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||
helpMessage += QString(" --set-opts <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
|
||||
helpMessage += QString(" -t, --tab <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "open a tab with this number"));
|
||||
// messages
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
|
||||
helpMessage += QString(" -v, --version - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show version and exit"));
|
||||
helpMessage += QString(" -i, --info - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show build information and exit"));
|
||||
helpMessage += QString(" -h, --help - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show this help and exit"));
|
||||
|
||||
return helpMessage;
|
||||
}
|
||||
|
||||
|
||||
QString infoMessage()
|
||||
{
|
||||
QString infoMessage = QString("");
|
||||
// build information
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
|
||||
arg(QString(BUILD_DATE));
|
||||
// cmake
|
||||
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
|
||||
// cmake properties
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "cmake properties"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
// components
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Components"));
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QString("\t-DBUILD_GUI=%1\n").arg(QString(PROJECT_BUILD_GUI));
|
||||
infoMessage += QString("\t-DBUILD_HELPER=%1\n").arg(QString(PROJECT_BUILD_HELPER));
|
||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
|
||||
// additional components
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Additional components"));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
infoMessage += QString("\t-DBUILD_TEST=%1\n").arg(QString(PROJECT_BUILD_TEST));
|
||||
// project properties
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Project properties"));
|
||||
infoMessage += QString("\t-DDBUS_SYSTEMCONF_PATH=%1\n").arg(QString(PROJECT_DBUS_SYSTEMCONF_PATH));
|
||||
infoMessage += QString("\t-DSYSTEMD_SERVICE_PATH=%1\n").arg(QString(PROJECT_SYSTEMD_SERVICE_PATH));
|
||||
infoMessage += QString("\t-DUSE_CAPABILITIES=%1\n").arg(QString(PROJECT_USE_CAPABILITIES));
|
||||
infoMessage += QString("\t-DUSE_QT5=%1\n").arg(QString(PROJECT_USE_QT5));
|
||||
// transport information
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
|
||||
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
|
||||
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
infoMessage += QString("\tDBUS_HELPER_SERVICE=%1\n").arg(QString(DBUS_HELPER_SERVICE));
|
||||
infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH));
|
||||
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
|
||||
// docs path
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Documentation"));
|
||||
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
|
||||
|
||||
return infoMessage;
|
||||
}
|
||||
|
||||
|
||||
QString versionMessage()
|
||||
{
|
||||
QString versionMessage = QString("");
|
||||
versionMessage += QString("%1\n").arg(QString(NAME));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QApplication::translate("MainWindow", "Version"))
|
||||
.arg(QString(VERSION));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QApplication::translate("MainWindow", "Author"))
|
||||
.arg(QString(AUTHOR));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QApplication::translate("MainWindow", "License"))
|
||||
.arg(QString(LICENSE));
|
||||
|
||||
return versionMessage;
|
||||
}
|
34
sources/gui/src/messages.h
Normal file
@ -0,0 +1,34 @@
|
||||
/***************************************************************************
|
||||
* 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 MESSAGES_H
|
||||
#define MESSAGES_H
|
||||
|
||||
#include <QChar>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
QString errorMessage();
|
||||
QMap<QString, QVariant> getArgs();
|
||||
QString helpMessage();
|
||||
QString infoMessage();
|
||||
QString versionMessage();
|
||||
|
||||
|
||||
#endif /* MESSAGES_H */
|
@ -89,8 +89,7 @@ void MobileWidget::showAdvanced()
|
||||
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||
ui->widget_mobileAdvanced->setHidden(false);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_mobileAdvanced->setHidden(true);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
|
||||
}
|
||||
|
@ -20,7 +20,11 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <netctlgui/netctlinteract.h>
|
||||
#include <netctlgui/netctlgui.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "dbusoperation.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
|
||||
@ -28,7 +32,13 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
|
||||
ui(new Ui::NetctlAutoWindow),
|
||||
debug(debugCmd)
|
||||
{
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
useHelper = true;
|
||||
else
|
||||
useHelper = false;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget->setColumnHidden(2, true);
|
||||
ui->tableWidget->setColumnHidden(3, true);
|
||||
netctlCommand = new Netctl(debug, settings);
|
||||
|
||||
createActions();
|
||||
@ -38,16 +48,31 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
|
||||
|
||||
NetctlAutoWindow::~NetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[~NetctlAutoWindow]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
delete netctlCommand;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
|
||||
|
||||
if (statusBool)
|
||||
return QApplication::translate("NetctlAutoWindow", "yes");
|
||||
if (nullFalse)
|
||||
return QString("");
|
||||
else
|
||||
return QApplication::translate("NetctlAutoWindow", "no");
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::createActions()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||
@ -75,7 +100,7 @@ void NetctlAutoWindow::createActions()
|
||||
|
||||
void NetctlAutoWindow::showWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
|
||||
@ -83,31 +108,103 @@ void NetctlAutoWindow::showWindow()
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("system-run"));
|
||||
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||
menu.addSeparator();
|
||||
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
||||
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
|
||||
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
||||
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
||||
// set text
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
|
||||
enableProfile->setVisible(false);
|
||||
startProfile->setVisible(false);
|
||||
} else {
|
||||
enableProfile->setVisible(true);
|
||||
startProfile->setVisible(true);
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
||||
} else {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
if (netctlCommand->isNetctlAutoEnabled())
|
||||
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||
if (action == startProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Switch to profile";
|
||||
netctlAutoStartProfile();
|
||||
} else if (action == enableProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
|
||||
netctlAutoEnableProfile();
|
||||
} else if (action == enableAllProfiles) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Enable all profiles";
|
||||
netctlAutoEnableAllProfiles();
|
||||
} else if (action == disableAllProfiles) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Disable all profiles";
|
||||
netctlAutoDisableAllProfiles();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
// actions
|
||||
bool enabled = false;
|
||||
bool running = false;
|
||||
if (useHelper) {
|
||||
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
} else {
|
||||
enabled = netctlCommand->isNetctlAutoEnabled();
|
||||
running = netctlCommand->isNetctlAutoRunning();
|
||||
}
|
||||
if (enabled)
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
||||
else
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
|
||||
ui->actionEnableService->setVisible(true);
|
||||
if (netctlCommand->isNetctlAutoRunning()) {
|
||||
if (running) {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
|
||||
ui->actionDisableAll->setVisible(true);
|
||||
ui->actionEnableAll->setVisible(true);
|
||||
ui->actionRestartService->setVisible(true);
|
||||
}
|
||||
else {
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
|
||||
ui->actionRestartService->setVisible(false);
|
||||
} else {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
|
||||
ui->actionDisableAll->setVisible(false);
|
||||
ui->actionEnableAll->setVisible(false);
|
||||
ui->actionRestartService->setVisible(false);
|
||||
netctlAutoRefreshButtons(0, 0);
|
||||
return;
|
||||
}
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (useHelper)
|
||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
||||
QList<QVariant>(), true, debug), debug);
|
||||
else
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
|
||||
ui->tableWidget->setSortingEnabled(false);
|
||||
ui->tableWidget->selectRow(-1);
|
||||
@ -124,45 +221,43 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(profiles[i].active);
|
||||
font.setItalic(profiles[i].enabled);
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled));
|
||||
// name
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i][0]));
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
|
||||
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
if (profiles[i][2] == QString("*")) {
|
||||
QFont font;
|
||||
font.setBold(true);
|
||||
ui->tableWidget->item(i, 0)->setFont(font);
|
||||
}
|
||||
else if (profiles[i][2] == QString("!")) {
|
||||
QFont font;
|
||||
font.setItalic(true);
|
||||
ui->tableWidget->item(i, 0)->setFont(font);
|
||||
}
|
||||
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
|
||||
ui->tableWidget->item(i, 0)->setFont(font);
|
||||
// description
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
|
||||
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
if (profiles[i][2] == QString("*")) {
|
||||
// active
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
else
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString("")));
|
||||
if (profiles[i][2] == QString("!")) {
|
||||
// disabled
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
|
||||
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
else
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QString("")));
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
|
||||
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
|
||||
// active
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// enabled
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
|
||||
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget->setSortingEnabled(true);
|
||||
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
ui->tableWidget->resizeColumnsToContents();
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#else
|
||||
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
ui->tableWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
|
||||
|
||||
@ -171,68 +266,19 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("dialog-apply"));
|
||||
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||
menu.addSeparator();
|
||||
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
||||
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
|
||||
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
||||
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
||||
// set text
|
||||
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text() == QString("yes")) {
|
||||
enableProfile->setVisible(false);
|
||||
startProfile->setVisible(false);
|
||||
}
|
||||
else {
|
||||
enableProfile->setVisible(true);
|
||||
startProfile->setVisible(true);
|
||||
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text() == QString("yes")) {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
||||
}
|
||||
else {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||
if (action == startProfile) {
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
|
||||
netctlAutoStartProfile();
|
||||
}
|
||||
else if (action == enableProfile) {
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
|
||||
netctlAutoEnableProfile();
|
||||
}
|
||||
else if (action == enableAllProfiles) {
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
|
||||
netctlAutoEnableAllProfiles();
|
||||
}
|
||||
else if (action == disableAllProfiles) {
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
|
||||
netctlAutoDisableAllProfiles();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
if (netctlCommand->autoDisableAllProfiles())
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoDisableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -243,13 +289,22 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableProfile]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
if (netctlCommand->autoEnableProfile(profile))
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoEnable"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoEnableProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -260,10 +315,17 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
if (netctlCommand->autoEnableAllProfiles())
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoEnableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -274,13 +336,22 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
|
||||
void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartProfile]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
if (netctlCommand->autoStartProfile(profile))
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoStartProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -291,9 +362,16 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableService()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableService]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand->autoEnableService())
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoEnableService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -304,9 +382,16 @@ void NetctlAutoWindow::netctlAutoEnableService()
|
||||
|
||||
void NetctlAutoWindow::netctlAutoRestartService()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRestartService]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand->autoRestartService())
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoRestartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -317,9 +402,16 @@ void NetctlAutoWindow::netctlAutoRestartService()
|
||||
|
||||
void NetctlAutoWindow::netctlAutoStartService()
|
||||
{
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartService]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (netctlCommand->autoStartService())
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoStartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
@ -331,7 +423,7 @@ void NetctlAutoWindow::netctlAutoStartService()
|
||||
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRefreshButtons]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (current == 0) {
|
||||
// buttons
|
||||
@ -342,30 +434,28 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
||||
ui->actionSwitch->setVisible(false);
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget->item(current->row(), 2)->text() == QString("yes")) {
|
||||
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
|
||||
// buttons
|
||||
ui->pushButton_enable->setDisabled(true);
|
||||
ui->pushButton_switch->setDisabled(true);
|
||||
// menu
|
||||
ui->actionEnable->setVisible(false);
|
||||
ui->actionSwitch->setVisible(false);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// buttons
|
||||
ui->pushButton_enable->setEnabled(true);
|
||||
ui->pushButton_switch->setEnabled(true);
|
||||
// menu
|
||||
ui->actionEnable->setVisible(true);
|
||||
ui->actionSwitch->setVisible(true);
|
||||
if (ui->tableWidget->item(current->row(), 3)->text() == QString("yes")) {
|
||||
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
||||
// buttons
|
||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
|
||||
// menu
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// buttons
|
||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
@ -58,9 +58,11 @@ private slots:
|
||||
void netctlAutoStartService();
|
||||
|
||||
private:
|
||||
Netctl *netctlCommand;
|
||||
Ui::NetctlAutoWindow *ui;
|
||||
bool debug;
|
||||
Netctl *netctlCommand = nullptr;
|
||||
Ui::NetctlAutoWindow *ui = nullptr;
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<height>343</height>
|
||||
<width>428</width>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -42,6 +42,9 @@
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
@ -58,16 +61,8 @@
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Disabled</string>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -105,6 +100,9 @@
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -116,7 +114,7 @@
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="dialog-apply">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
@ -131,7 +129,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>432</width>
|
||||
<width>428</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -168,7 +166,7 @@
|
||||
</action>
|
||||
<action name="actionSwitch">
|
||||
<property name="icon">
|
||||
<iconset theme="dialog-apply">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
|
142
sources/gui/src/netctlguiadaptor.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
/***************************************************************************
|
||||
* 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 "netctlguiadaptor.h"
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlGuiAdaptor::NetctlGuiAdaptor(MainWindow *parent)
|
||||
: QDBusAbstractAdaptor(parent),
|
||||
mainWindow(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetctlGuiAdaptor::~NetctlGuiAdaptor()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::Active()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void NetctlGuiAdaptor::ApiDocs()
|
||||
{
|
||||
return mainWindow->showApi();
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::Close()
|
||||
{
|
||||
mainWindow->closeMainWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlGuiAdaptor::Information()
|
||||
{
|
||||
return mainWindow->printInformation();
|
||||
}
|
||||
|
||||
|
||||
void NetctlGuiAdaptor::LibraryDocs()
|
||||
{
|
||||
return mainWindow->showLibrary();
|
||||
}
|
||||
|
||||
|
||||
QString NetctlGuiAdaptor::Pony()
|
||||
{
|
||||
QString pony;
|
||||
QFile ponyFile(QString(":pinkiepie"));
|
||||
if (!ponyFile.open(QIODevice::ReadOnly))
|
||||
return pony;
|
||||
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
|
||||
ponyFile.close();
|
||||
|
||||
return pony;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::Restore()
|
||||
{
|
||||
mainWindow->show();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void NetctlGuiAdaptor::SecurityDocs()
|
||||
{
|
||||
return mainWindow->showSecurityNotes();
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlGuiAdaptor::Settings()
|
||||
{
|
||||
return mainWindow->printSettings();
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::ShowAbout()
|
||||
{
|
||||
mainWindow->showAboutWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::ShowMain()
|
||||
{
|
||||
mainWindow->showMainWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::ShowNetctlAuto()
|
||||
{
|
||||
mainWindow->showNetctlAutoWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlGuiAdaptor::ShowSettings()
|
||||
{
|
||||
mainWindow->showSettingsWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlGuiAdaptor::UIDs()
|
||||
{
|
||||
QStringList uids;
|
||||
uids.append(QString::number(getuid()));
|
||||
uids.append(QString::number(geteuid()));
|
||||
|
||||
return uids;
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlGuiAdaptor::VerboseInformation()
|
||||
{
|
||||
return mainWindow->printTrayInformation();
|
||||
}
|
58
sources/gui/src/netctlguiadaptor.h
Normal file
@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* 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 NETCTLGUIADAPTOR_H
|
||||
#define NETCTLGUIADAPTOR_H
|
||||
|
||||
#include <QDBusAbstractAdaptor>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class NetctlGuiAdaptor : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.netctlgui.netctlgui")
|
||||
|
||||
public:
|
||||
explicit NetctlGuiAdaptor(MainWindow *parent = 0);
|
||||
~NetctlGuiAdaptor();
|
||||
|
||||
public slots:
|
||||
bool Active();
|
||||
void ApiDocs();
|
||||
bool Close();
|
||||
QStringList Information();
|
||||
void LibraryDocs();
|
||||
QString Pony();
|
||||
bool Restore();
|
||||
void SecurityDocs();
|
||||
QStringList Settings();
|
||||
bool ShowAbout();
|
||||
bool ShowMain();
|
||||
bool ShowNetctlAuto();
|
||||
bool ShowSettings();
|
||||
QStringList UIDs();
|
||||
QStringList VerboseInformation();
|
||||
|
||||
private:
|
||||
MainWindow *mainWindow;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLGUIADAPTOR_H */
|
@ -66,8 +66,7 @@ void PasswdWidget::setPassword(const bool mode)
|
||||
if (mode) {
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
||||
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
||||
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
|
||||
}
|
||||
|
@ -117,8 +117,7 @@ void PppoeWidget::showAdvanced()
|
||||
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
||||
ui->widget_pppoeAdvanced->setHidden(false);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_pppoeAdvanced->setHidden(true);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
|
||||
}
|
||||
|
@ -23,7 +23,10 @@
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "language.h"
|
||||
#include <language/language.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
|
||||
@ -40,7 +43,7 @@ SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QStri
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
@ -48,33 +51,34 @@ SettingsWindow::~SettingsWindow()
|
||||
|
||||
void SettingsWindow::createActions()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[createActions]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(restoreSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
|
||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
||||
// buttons
|
||||
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
|
||||
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), SLOT(selectNetctlAutoPath()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
|
||||
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath()));
|
||||
connect(ui->pushButton_wpaActiondPath, SIGNAL(clicked(bool)), SLOT(selectWpaActiondPath()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
|
||||
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_interfacesDir, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_status, SIGNAL(clicked(bool)), this, SLOT(startHelper()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (pressedKey->key() == Qt::Key_Escape)
|
||||
close();
|
||||
@ -83,7 +87,7 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
|
||||
void SettingsWindow::addLanguages()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->comboBox_language->clear();
|
||||
ui->comboBox_language->addItems(Language::getAvailableLanguages());
|
||||
@ -93,7 +97,7 @@ void SettingsWindow::addLanguages()
|
||||
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[changePage]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
|
||||
if (current == ui->treeWidget->topLevelItem(i)) {
|
||||
@ -103,9 +107,19 @@ void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previ
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::closeWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
saveSettings();
|
||||
close();
|
||||
((MainWindow *)parent())->updateConfiguration();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::saveSettings()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings = readSettings();
|
||||
QFile configFile(file);
|
||||
@ -118,158 +132,102 @@ void SettingsWindow::saveSettings()
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setTray()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->checkBox_enableTray->checkState() == 0) {
|
||||
ui->checkBox_closeToTray->setDisabled(true);
|
||||
ui->checkBox_startToTray->setDisabled(true);
|
||||
} else if (ui->checkBox_enableTray->checkState() == 2) {
|
||||
ui->checkBox_closeToTray->setEnabled(true);
|
||||
ui->checkBox_startToTray->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::restoreSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setSettings(getSettings());
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setDefault()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setSettings(getDefault());
|
||||
saveSettings();
|
||||
if (sender() != ui->buttonBox->button(QDialogButtonBox::Reset))
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectIfaceDir()
|
||||
void SettingsWindow::selectAbstractSomething()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectIfaceDir]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
|
||||
QString("/sys/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_interfacesDir->setText(directory);
|
||||
}
|
||||
bool isDir = false;
|
||||
QString path = QString("/usr/bin");
|
||||
QString text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||
QLineEdit *lineEdit = ui->lineEdit_helperPath;
|
||||
if (sender() == ui->pushButton_helperPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||
lineEdit = ui->lineEdit_helperPath;
|
||||
} else if (sender() == ui->pushButton_interfacesDir) {
|
||||
isDir = true;
|
||||
text = QApplication::translate("SettingsWindow", "Select path to directory with interfaces");
|
||||
path = QString("/sys");
|
||||
lineEdit = ui->lineEdit_interfacesDir;
|
||||
} else if (sender() == ui->pushButton_netctlPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select netctl command");
|
||||
lineEdit = ui->lineEdit_netctlPath;
|
||||
} else if (sender() == ui->pushButton_netctlAutoPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select netctl-auto command");
|
||||
lineEdit = ui->lineEdit_netctlAutoPath;
|
||||
} else if (sender() == ui->pushButton_profilePath) {
|
||||
isDir = true;
|
||||
text = QApplication::translate("SettingsWindow", "Select path to profile directory");
|
||||
path = QString("/etc");
|
||||
lineEdit = ui->lineEdit_profilePath;
|
||||
} else if (sender() == ui->pushButton_rfkill) {
|
||||
isDir = true;
|
||||
text = QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices");
|
||||
path = QString("/sys");
|
||||
lineEdit = ui->lineEdit_rfkill;
|
||||
} else if (sender() == ui->pushButton_sudo) {
|
||||
text = QApplication::translate("SettingsWindow", "Select sudo command");
|
||||
lineEdit = ui->lineEdit_sudo;
|
||||
} else if (sender() == ui->pushButton_systemctlPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select systemctl command");
|
||||
lineEdit = ui->lineEdit_systemctlPath;
|
||||
} else if (sender() == ui->pushButton_wpaCliPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select wpa_cli command");
|
||||
lineEdit = ui->lineEdit_wpaCliPath;
|
||||
} else if (sender() == ui->pushButton_wpaSupPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select wpa_supplicant command");
|
||||
lineEdit = ui->lineEdit_wpaSupPath;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectNetctlPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select netctl command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
QString filename;
|
||||
if (isDir)
|
||||
filename = QFileDialog::getExistingDirectory(this, text, path);
|
||||
else
|
||||
filename = QFileDialog::getOpenFileName(this, text, path,
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_netctlPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectNetctlAutoPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlAutoPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select netctl-auto command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_netctlAutoPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectProfileDir()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectProfileDir]";
|
||||
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to profile directory"),
|
||||
QString("/etc/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_profilePath->setText(directory);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectRfkillDir()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectRfkillDir]";
|
||||
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
|
||||
QString("/sys/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_rfkill->setText(directory);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectSudoPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectSudoPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select sudo command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_sudo->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectSystemctlPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectSystemctlPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select systemctl command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_systemctlPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectWpaActiondPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaActiondPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select wpa_actiond command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaActiondPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectWpaCliPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaCliPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaCliPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectWpaSupPath()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaSupPath]";
|
||||
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaSupPath->setText(filename);
|
||||
lineEdit->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::showWindow()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setSettings(getSettings());
|
||||
ui->label_info->hide();
|
||||
setTray();
|
||||
updateHelper();
|
||||
|
||||
show();
|
||||
}
|
||||
@ -277,11 +235,25 @@ void SettingsWindow::showWindow()
|
||||
|
||||
QMap<QString, QString> SettingsWindow::readSettings()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
if (ui->checkBox_helperClose->checkState() == 2)
|
||||
settings[QString("CLOSE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
if (ui->checkBox_closeToTray->checkState() == 2)
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
if (ui->checkBox_forceSudo->checkState() == 2)
|
||||
settings[QString("FORCE_SUDO")] = QString("true");
|
||||
else
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
|
||||
settings[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
|
||||
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
@ -291,15 +263,29 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||
if (ui->checkBox_components->checkState() == 2)
|
||||
settings[QString("SKIPCOMPONENTS")] = QString("true");
|
||||
else
|
||||
settings[QString("SKIPCOMPONENTS")] = QString("false");
|
||||
if (ui->checkBox_startToTray->checkState() == 2)
|
||||
settings[QString("STARTTOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
|
||||
settings[QString("WPAACTIOND_PATH")] = ui->lineEdit_wpaActiondPath->text();
|
||||
if (ui->checkBox_enableTray->checkState() == 2)
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("SYSTRAY")] = QString("false");
|
||||
if (ui->checkBox_useHelper->checkState() == 2)
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("USE_HELPER")] = QString("false");
|
||||
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -307,10 +293,24 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
|
||||
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (settings[QString("CLOSE_HELPER")] == QString("true"))
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("CLOSETOTRAY")] == QString("true"))
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]);
|
||||
ui->lineEdit_helperService->setText(settings[QString("HELPER_SERVICE")]);
|
||||
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||
ui->comboBox_language->setCurrentIndex(0);
|
||||
for (int i=0; i<ui->comboBox_language->count(); i++)
|
||||
@ -323,25 +323,44 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
||||
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
||||
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
||||
if (settings[QString("SKIPCOMPONENTS")] == QString("true"))
|
||||
ui->checkBox_components->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_components->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("STARTTOTRAY")] == QString("true"))
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
|
||||
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
|
||||
ui->lineEdit_wpaActiondPath->setText(settings[QString("WPAACTIOND_PATH")]);
|
||||
if (settings[QString("SYSTRAY")] == QString("true"))
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
||||
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getDefault()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||
settings[QString("CTRL_GROUP")] = QString("users");
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
|
||||
settings[QString("HELPER_SERVICE")] = QString("netctlgui-helper.service");
|
||||
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
||||
settings[QString("LANGUAGE")] = QString("en");
|
||||
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
||||
@ -351,15 +370,17 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
settings[QString("PREFERED_IFACE")] = QString("");
|
||||
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
||||
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
||||
settings[QString("SKIPCOMPONENTS")] = QString("false");
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
||||
settings[QString("WPAACTIOND_PATH")] = QString("/usr/bin/wpa_actiond");
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -367,7 +388,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getSettings()
|
||||
{
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings = getDefault();
|
||||
QFile configFile(file);
|
||||
@ -376,17 +397,48 @@ QMap<QString, QString> SettingsWindow::getSettings()
|
||||
return settings;
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine()).trimmed();
|
||||
if (fileStr[0] == QChar('#')) continue;
|
||||
if (fileStr[0] == QChar(';')) continue;
|
||||
if (!fileStr.contains(QChar('='))) continue;
|
||||
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
||||
if (configFile.atEnd())
|
||||
break;
|
||||
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('=')))
|
||||
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
||||
if (configFile.atEnd()) break;
|
||||
}
|
||||
configFile.close();
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
((MainWindow *)parent())->startHelper();
|
||||
updateHelper();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::updateHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (((MainWindow *)parent())->isHelperServiceActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active (systemd)"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
ui->pushButton_status->setDisabled(true);
|
||||
} else if (((MainWindow *)parent())->isHelperActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
ui->pushButton_status->setEnabled(true);
|
||||
} else {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Inactive"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Start"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("system-run"));
|
||||
ui->pushButton_status->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,8 @@ public:
|
||||
QMap<QString, QString> getSettings();
|
||||
|
||||
public slots:
|
||||
void closeWindow();
|
||||
void restoreSettings();
|
||||
void setDefault();
|
||||
void showWindow();
|
||||
|
||||
@ -49,17 +51,11 @@ private slots:
|
||||
void addLanguages();
|
||||
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void saveSettings();
|
||||
void setTray();
|
||||
void updateHelper();
|
||||
// buttons
|
||||
void selectIfaceDir();
|
||||
void selectNetctlPath();
|
||||
void selectNetctlAutoPath();
|
||||
void selectProfileDir();
|
||||
void selectRfkillDir();
|
||||
void selectSudoPath();
|
||||
void selectSystemctlPath();
|
||||
void selectWpaActiondPath();
|
||||
void selectWpaCliPath();
|
||||
void selectWpaSupPath();
|
||||
void selectAbstractSomething();
|
||||
void startHelper();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>670</width>
|
||||
<height>331</height>
|
||||
<width>678</width>
|
||||
<height>395</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -67,6 +67,15 @@
|
||||
</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Helper</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon-helper.png</normaloff>:/icon-helper.png</iconset>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>netctl</string>
|
||||
@ -127,8 +136,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>270</height>
|
||||
<width>462</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
@ -151,12 +160,30 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<widget class="QCheckBox" name="checkBox_enableTray">
|
||||
<property name="text">
|
||||
<string>You will need to restart the application</string>
|
||||
<string>Enable system tray</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_closeToTray">
|
||||
<property name="text">
|
||||
<string>Minimize to tray instead of closing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_startToTray">
|
||||
<property name="text">
|
||||
<string>Start minimized to tray</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_components">
|
||||
<property name="text">
|
||||
<string>Skip components checking</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -179,6 +206,173 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_helper">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_helper">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>462</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_helperInfo">
|
||||
<property name="text">
|
||||
<string>It is recommended to use systemd integration. See `man 1 netctlgui-helper` for more details.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_status">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_statusText">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Helper status</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_status">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_status">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_status">
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_useHelper">
|
||||
<property name="text">
|
||||
<string>Use helper</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_forceSudo">
|
||||
<property name="text">
|
||||
<string>Force use sudo in helper</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_helperClose">
|
||||
<property name="text">
|
||||
<string>Close helper after exit (doesn't work while systemd service is active)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_helperPath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_helperPath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Helper command</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_helperPath"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_helperPath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_helperService">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_helperService">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Helper service</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_helperService">
|
||||
<property name="toolTip">
|
||||
<string>Name of netctlgui-helper service</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_helper">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_netctl">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
@ -194,8 +388,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>270</height>
|
||||
<width>436</width>
|
||||
<height>173</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
@ -381,8 +575,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>270</height>
|
||||
<width>436</width>
|
||||
<height>45</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
@ -451,8 +645,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>270</height>
|
||||
<width>277</width>
|
||||
<height>194</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
@ -518,37 +712,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaActiondPath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaActiondPath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>wpa_actiond path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaActiondPath">
|
||||
<property name="toolTip">
|
||||
<string>Path to wpa_actiond</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaActiondPath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pid">
|
||||
<item>
|
||||
@ -679,8 +842,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>270</height>
|
||||
<width>436</width>
|
||||
<height>107</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||
@ -707,7 +870,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_interfaceDir">
|
||||
<widget class="QPushButton" name="pushButton_interfacesDir">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
@ -796,7 +959,7 @@
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
323
sources/gui/src/trayicon.cpp
Normal file
@ -0,0 +1,323 @@
|
||||
/***************************************************************************
|
||||
* 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 "trayicon.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
|
||||
: QSystemTrayIcon(parent),
|
||||
debug(debugCmd)
|
||||
{
|
||||
mainWindow = (MainWindow *)parent;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
TrayIcon::~TrayIcon()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setContextMenu(0);
|
||||
startProfileMenu->clear();
|
||||
switchToProfileMenu->clear();
|
||||
menuActions->clear();
|
||||
delete startProfileMenu;
|
||||
delete switchToProfileMenu;
|
||||
delete menuActions;
|
||||
for (int i=0; i<contextMenu.keys().count(); i++)
|
||||
delete contextMenu[contextMenu.keys()[i]];
|
||||
}
|
||||
|
||||
|
||||
int TrayIcon::showInformation()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (supportsMessages()) {
|
||||
QString title = QApplication::translate("TrayIcon", "netctl status");
|
||||
QStringList info = mainWindow->printInformation();
|
||||
QString message = QString("%1: %2\n").arg(QApplication::translate("TrayIcon", "Profile")).arg(info[0]);
|
||||
message += QString("%1: %2").arg(QApplication::translate("TrayIcon", "Status")).arg(info[1]);
|
||||
showMessage(title, message, QSystemTrayIcon::Information);
|
||||
}
|
||||
else
|
||||
return showInformationInWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int TrayIcon::showInformationInWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString title = QApplication::translate("TrayIcon", "netctl status");
|
||||
QStringList info = mainWindow->printInformation();
|
||||
QString message = QString("%1: %2\n").arg(QApplication::translate("TrayIcon", "Profile")).arg(info[0]);
|
||||
message += QString("%1: %2").arg(QApplication::translate("TrayIcon", "Status")).arg(info[1]);
|
||||
|
||||
return QMessageBox::information(0, title, message);
|
||||
}
|
||||
|
||||
|
||||
void TrayIcon::updateMenu()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList info = mainWindow->printTrayInformation();
|
||||
bool netctlAutoStatus = info[0].toInt();
|
||||
QStringList profiles = info[1].split(QChar('|'));
|
||||
QString current = info[2];
|
||||
QString enabled = info[3];
|
||||
|
||||
if (current.isEmpty()) {
|
||||
contextMenu[QString("title")]->setIcon(QIcon(QString(":network-offline-64x64")));
|
||||
contextMenu[QString("title")]->setText(QApplication::translate("TrayIcon", "(inactive)"));
|
||||
} else {
|
||||
contextMenu[QString("title")]->setIcon(QIcon(QString(":network-idle-64x64")));
|
||||
QStringList currentProfiles, status;
|
||||
if (netctlAutoStatus) {
|
||||
currentProfiles.append(current);
|
||||
status.append(QApplication::translate("TrayIcon", "(netctl-auto)"));
|
||||
} else {
|
||||
for (int i=0; i<enabled.split(QChar('|')).count(); i++) {
|
||||
currentProfiles.append(current.split(QChar('|'))[i]);
|
||||
if (enabled.split(QChar('|'))[i] == QString("0"))
|
||||
status.append(QApplication::translate("TrayIcon", "static"));
|
||||
else
|
||||
status.append(QApplication::translate("TrayIcon", "enabled"));
|
||||
}
|
||||
}
|
||||
QStringList profiles;
|
||||
for (int i=0; i<currentProfiles.count(); i++)
|
||||
profiles.append(currentProfiles[i] + QString(" (") + status[i] + QString(")"));
|
||||
contextMenu[QString("title")]->setText(profiles.join(QString(" | ")));
|
||||
}
|
||||
|
||||
if (netctlAutoStatus) {
|
||||
contextMenu[QString("start")]->setVisible(false);
|
||||
contextMenu[QString("stop")]->setVisible(false);
|
||||
contextMenu[QString("stopall")]->setVisible(false);
|
||||
contextMenu[QString("switch")]->setVisible(true);
|
||||
contextMenu[QString("restart")]->setVisible(false);
|
||||
contextMenu[QString("enable")]->setVisible(false);
|
||||
switchToProfileMenu->clear();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QAction *profile = new QAction(profiles[i], this);
|
||||
switchToProfileMenu->addAction(profile);
|
||||
}
|
||||
} else {
|
||||
if (current.contains(QChar('|'))) {
|
||||
contextMenu[QString("start")]->setVisible(true);
|
||||
contextMenu[QString("stop")]->setVisible(false);
|
||||
contextMenu[QString("stopall")]->setVisible(true);
|
||||
contextMenu[QString("switch")]->setVisible(false);
|
||||
contextMenu[QString("restart")]->setVisible(false);
|
||||
contextMenu[QString("enable")]->setVisible(false);
|
||||
} else {
|
||||
contextMenu[QString("start")]->setVisible(true);
|
||||
contextMenu[QString("stop")]->setVisible(!current.isEmpty());
|
||||
contextMenu[QString("switch")]->setVisible(false);
|
||||
contextMenu[QString("stopall")]->setVisible(false);
|
||||
contextMenu[QString("restart")]->setVisible(!current.isEmpty());
|
||||
contextMenu[QString("enable")]->setVisible(!current.isEmpty());
|
||||
}
|
||||
if (!current.isEmpty()) {
|
||||
contextMenu[QString("start")]->setText(QApplication::translate("TrayIcon", "Start another profile"));
|
||||
contextMenu[QString("stop")]->setText(QApplication::translate("TrayIcon", "Stop %1").arg(current));
|
||||
contextMenu[QString("restart")]->setText(QApplication::translate("TrayIcon", "Restart %1").arg(current));
|
||||
if (enabled.split(QChar('|'))[0].toInt())
|
||||
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Disable %1").arg(current));
|
||||
else
|
||||
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Enable %1").arg(current));
|
||||
} else
|
||||
contextMenu[QString("start")]->setText(QApplication::translate("TrayIcon", "Start profile"));
|
||||
startProfileMenu->clear();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QAction *profile = new QAction(profiles[i], this);
|
||||
startProfileMenu->addAction(profile);
|
||||
}
|
||||
}
|
||||
|
||||
if (mainWindow->isHidden())
|
||||
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Show"));
|
||||
else
|
||||
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Hide"));
|
||||
|
||||
setContextMenu(menuActions);
|
||||
}
|
||||
|
||||
|
||||
void TrayIcon::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
menuActions = new QMenu();
|
||||
|
||||
contextMenu[QString("title")] = new QAction(QIcon(":icon"), QApplication::translate("TrayIcon", "Status"), this);
|
||||
menuActions->addAction(contextMenu[QString("title")]);
|
||||
connect(contextMenu[QString("title")], SIGNAL(triggered(bool)), this, SLOT(showInformationInWindow()));
|
||||
|
||||
menuActions->addSeparator();
|
||||
|
||||
contextMenu[QString("start")] = new QAction(QIcon::fromTheme("system-run"), QApplication::translate("TrayIcon", "Start profile"), this);
|
||||
startProfileMenu = new QMenu();
|
||||
contextMenu[QString("start")]->setMenu(startProfileMenu);
|
||||
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(startProfileSlot(QAction *)));
|
||||
menuActions->addAction(contextMenu[QString("start")]);
|
||||
|
||||
contextMenu[QString("stop")] = new QAction(QIcon::fromTheme("process-stop"), QApplication::translate("TrayIcon", "Stop profile"), this);
|
||||
connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
|
||||
menuActions->addAction(contextMenu[QString("stop")]);
|
||||
|
||||
contextMenu[QString("stopall")] = new QAction(QIcon::fromTheme("process-stop"), QApplication::translate("TrayIcon", "Stop all profiles"), this);
|
||||
connect(contextMenu[QString("stopall")], SIGNAL(triggered(bool)), this, SLOT(stopAllProfilesSlot()));
|
||||
menuActions->addAction(contextMenu[QString("stopall")]);
|
||||
|
||||
contextMenu[QString("switch")] = new QAction(QIcon::fromTheme("system-run"), QApplication::translate("TrayIcon", "Switch to profile"), this);
|
||||
switchToProfileMenu = new QMenu();
|
||||
contextMenu[QString("switch")]->setMenu(switchToProfileMenu);
|
||||
connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchToProfileSlot(QAction *)));
|
||||
menuActions->addAction(contextMenu[QString("switch")]);
|
||||
|
||||
contextMenu[QString("restart")] = new QAction(QIcon::fromTheme("stock-refresh"), QApplication::translate("TrayIcon", "Restart profile"), this);
|
||||
connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
|
||||
menuActions->addAction(contextMenu[QString("restart")]);
|
||||
|
||||
contextMenu[QString("enable")] = new QAction(QApplication::translate("TrayIcon", "Enable profile"), this);
|
||||
connect(contextMenu[QString("enable")], SIGNAL(triggered(bool)), this, SLOT(enableProfileSlot()));
|
||||
menuActions->addAction(contextMenu[QString("enable")]);
|
||||
|
||||
menuActions->addSeparator();
|
||||
|
||||
contextMenu[QString("gui")] = new QAction(QApplication::translate("TrayIcon", "Show"), this);
|
||||
connect(contextMenu[QString("gui")], SIGNAL(triggered(bool)), mainWindow, SLOT(showMainWindow()));
|
||||
menuActions->addAction(contextMenu[QString("gui")]);
|
||||
|
||||
contextMenu[QString("auto")] = new QAction(QApplication::translate("TrayIcon", "Show netctl-auto"), this);
|
||||
connect(contextMenu[QString("auto")], SIGNAL(triggered(bool)), mainWindow, SLOT(showNetctlAutoWindow()));
|
||||
menuActions->addAction(contextMenu[QString("auto")]);
|
||||
|
||||
menuActions->addSeparator();
|
||||
|
||||
contextMenu[QString("quit")] = new QAction(QApplication::translate("TrayIcon", "Quit"), this);
|
||||
connect(contextMenu[QString("quit")], SIGNAL(triggered(bool)), mainWindow, SLOT(closeMainWindow()));
|
||||
menuActions->addAction(contextMenu[QString("quit")]);
|
||||
}
|
||||
|
||||
|
||||
void TrayIcon::init()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setIcon(QIcon(":icon"));
|
||||
setToolTip(QString("netctl-gui"));
|
||||
|
||||
createActions();
|
||||
|
||||
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||
this, SLOT(itemActivated(QSystemTrayIcon::ActivationReason)));
|
||||
}
|
||||
|
||||
|
||||
void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Reason" << reason;
|
||||
|
||||
switch (reason) {
|
||||
case QSystemTrayIcon::Trigger:
|
||||
showInformation();
|
||||
break;
|
||||
case QSystemTrayIcon::DoubleClick:
|
||||
mainWindow->showMainWindow();
|
||||
break;
|
||||
case QSystemTrayIcon::Context:
|
||||
// clear menu before update
|
||||
setContextMenu(0);
|
||||
updateMenu();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::enableProfileSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = mainWindow->printInformation()[0];
|
||||
|
||||
return mainWindow->enableProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::restartProfileSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = mainWindow->printInformation()[0];
|
||||
|
||||
return mainWindow->restartProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::startProfileSlot(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = action->text().remove(QChar('&'));
|
||||
|
||||
return mainWindow->switchToProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::stopProfileSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = mainWindow->printInformation()[0];
|
||||
|
||||
return mainWindow->startProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::stopAllProfilesSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return mainWindow->stopAllProfilesSlot();
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::switchToProfileSlot(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = action->text().remove(QChar('&'));
|
||||
|
||||
return mainWindow->switchToProfileSlot(profile);
|
||||
}
|
65
sources/gui/src/trayicon.h
Normal file
@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* 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 TRAYICON_H
|
||||
#define TRAYICON_H
|
||||
|
||||
#include <QAction>
|
||||
#include <QObject>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class TrayIcon : public QSystemTrayIcon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TrayIcon(QObject *parent = 0,
|
||||
const bool debugCmd = false);
|
||||
~TrayIcon();
|
||||
|
||||
public slots:
|
||||
int showInformation();
|
||||
int showInformationInWindow();
|
||||
void updateMenu();
|
||||
|
||||
private slots:
|
||||
void itemActivated(const QSystemTrayIcon::ActivationReason reason);
|
||||
bool enableProfileSlot();
|
||||
bool restartProfileSlot();
|
||||
bool startProfileSlot(QAction *action);
|
||||
bool stopProfileSlot();
|
||||
bool stopAllProfilesSlot();
|
||||
bool switchToProfileSlot(QAction *action);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
MainWindow *mainWindow;
|
||||
// contextual actions
|
||||
QMenu *menuActions;
|
||||
QMenu *startProfileMenu;
|
||||
QMenu *switchToProfileMenu;
|
||||
QMap<QString, QAction*> contextMenu;
|
||||
// functions
|
||||
void createActions();
|
||||
void init();
|
||||
};
|
||||
|
||||
|
||||
#endif /* TRAYICON_H */
|
@ -63,6 +63,7 @@ void WirelessWidget::clear()
|
||||
ui->comboBox_drivers->setCurrentIndex(0);
|
||||
ui->listWidget_drivers->setCurrentRow(-1);
|
||||
ui->listWidget_drivers->clear();
|
||||
ui->comboBox_rfkill->clear();
|
||||
ui->comboBox_rfkill->addItem(QString("auto"));
|
||||
if (rfkillDirectory->exists()) {
|
||||
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
@ -158,21 +159,18 @@ void WirelessWidget::changeSecurity(const QString currentText)
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if ((currentText == QString("wep")) ||
|
||||
} else if ((currentText == QString("wep")) ||
|
||||
(currentText == QString("wpa"))) {
|
||||
ui->widget_essid->setHidden(false);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(false);
|
||||
}
|
||||
else if (currentText == QString("wpa-configsection")) {
|
||||
} else if (currentText == QString("wpa-configsection")) {
|
||||
ui->widget_essid->setHidden(true);
|
||||
ui->widget_wpaConfigSection->setHidden(false);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if (currentText == QString("wpa-config")) {
|
||||
} else if (currentText == QString("wpa-config")) {
|
||||
ui->widget_essid->setHidden(true);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(false);
|
||||
@ -198,8 +196,7 @@ void WirelessWidget::showAdvanced()
|
||||
if (ui->pushButton_wirelessAdvanced->isChecked()) {
|
||||
ui->widget_wirelessAdvanced->setHidden(false);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_wirelessAdvanced->setHidden(true);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
|
||||
}
|
||||
@ -220,8 +217,7 @@ QMap<QString, QString> WirelessWidget::getSettings()
|
||||
wirelessSettings[QString("Key")] = ui->lineEdit_key->text();
|
||||
else
|
||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||
}
|
||||
else if (ui->comboBox_security->currentText() == QString("wpa"))
|
||||
} else if (ui->comboBox_security->currentText() == QString("wpa"))
|
||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
|
||||
QStringList section;
|
||||
|
105
sources/gui/zsh-completions
Normal file
@ -0,0 +1,105 @@
|
||||
#compdef netctl-gui
|
||||
###########################################################################
|
||||
# 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/ #
|
||||
###########################################################################
|
||||
|
||||
|
||||
# variables
|
||||
_netctl_gui_arglist=(
|
||||
{'--detached','--detached'}'[start detached from console]'
|
||||
{'--maximized','--maximized'}'[start maximized]'
|
||||
{'--minimized','--minimized'}'[start minimized to tray]'
|
||||
{'--about','--about'}'[show about window]'
|
||||
{'--netctl-auto','--netctl-auto'}'[show netctl-auto window]'
|
||||
{'--settings','--settings'}'[show settings window]'
|
||||
{'(--essid)-e','(-e)--essid'}'[select ESSID]:type ESSID:->essid'
|
||||
{'(--open)-o','(-o)--open'}'[open profile]:select profile:->profiles'
|
||||
{'(--select)-s','(-s)--select'}'[select profile]:select profile:->profiles'
|
||||
{'(--config)-c','(-c)--config'}'[read configuration from this file]:select file:->files'
|
||||
{'(--debug)-d','(-d)--debug'}'[print debug information]'
|
||||
{'--default','--default'}'[start with default settings]'
|
||||
{'--set-opts','--set-opts'}'[set options for this run, comma separated]:comma separated:->settings'
|
||||
{'(--tab)-t','(-t)--tab'}'[open a tab with specified number]:select tab:->tab'
|
||||
{'(--version)-v','(-v)--version'}'[show version and exit]'
|
||||
{'(--info)-i','(-i)--info'}'[show build information and exit]'
|
||||
{'(--help)-h','(-h)--help'}'[show help and exit]'
|
||||
)
|
||||
|
||||
_netctl_gui_settings=(
|
||||
'CLOSE_HELPER'
|
||||
'CLOSETOTRAY'
|
||||
'CTRL_DIR'
|
||||
'CTRL_GROUP'
|
||||
'FORCE_SUDO'
|
||||
'HELPER_PATH'
|
||||
'HELPER_SERVICE'
|
||||
'IFACE_DIR'
|
||||
'LANGUAGE'
|
||||
'NETCTL_PATH'
|
||||
'NETCTLAUTO_PATH'
|
||||
'NETCTLAUTO_SERVICE'
|
||||
'PID_FILE'
|
||||
'PREFERED_IFACE'
|
||||
'PROFILE_DIR'
|
||||
'RFKILL_DIR'
|
||||
'SKIPCOMPONENTS'
|
||||
'STARTTOTRAY'
|
||||
'SUDO_PATH'
|
||||
'SYSTEMCTL_PATH'
|
||||
'SYSTRAY'
|
||||
'USE_HELPER'
|
||||
'WPACLI_PATH'
|
||||
'WPASUP_PATH'
|
||||
'WPA_DRIVERS'
|
||||
)
|
||||
|
||||
_netctl_gui_tabs=(
|
||||
'1'
|
||||
'2'
|
||||
'3'
|
||||
)
|
||||
|
||||
_netctl_profiles() {
|
||||
print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
|
||||
}
|
||||
|
||||
|
||||
# work block
|
||||
_netctl-gui() {
|
||||
_arguments $_netctl_gui_arglist
|
||||
case "$state" in
|
||||
essid)
|
||||
;;
|
||||
files)
|
||||
_files
|
||||
;;
|
||||
profiles)
|
||||
_values 'profiles' $(_netctl_profiles)
|
||||
;;
|
||||
settings)
|
||||
_values -s ',' 'settings' $_netctl_gui_settings
|
||||
;;
|
||||
tab)
|
||||
_values 'tab' $_netctl_gui_tabs
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
case "$service" in
|
||||
netctl-gui)
|
||||
_netctl-gui "$@" && return 0
|
||||
;;
|
||||
esac
|
32
sources/helper/CMakeLists.txt
Normal file
@ -0,0 +1,32 @@
|
||||
# set project name
|
||||
set (SUBPROJECT netctlgui-helper)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# set directories
|
||||
set (SUBPROJECT_BINARY_DIR bin)
|
||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
|
||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations-helper)
|
||||
# executable path
|
||||
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
|
||||
|
||||
# additional targets
|
||||
set (TARGETS "")
|
||||
set (HEADERS "")
|
||||
|
||||
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||
# build man
|
||||
file (GLOB SUBPROJECT_MAN_IN *.1)
|
||||
file (GLOB SUBPROJECT_MAN5_IN *.5)
|
||||
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
|
||||
file (RELATIVE_PATH SUBPROJECT_MAN5 ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN5_IN})
|
||||
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
|
||||
configure_file (${SUBPROJECT_MAN5_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN5})
|
||||
|
||||
install (FILES org.netctlgui.helper.conf DESTINATION ${DBUS_SYSTEMCONF_PATH})
|
||||
install (FILES netctl-gui.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/)
|
||||
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
|
||||
install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT})
|
53
sources/helper/bash-completions
Normal file
@ -0,0 +1,53 @@
|
||||
###########################################################################
|
||||
# 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/ #
|
||||
###########################################################################
|
||||
|
||||
|
||||
# variables
|
||||
_netctlgui_helper_arglist=(
|
||||
'-c'
|
||||
'--config'
|
||||
'-d'
|
||||
'--debug'
|
||||
'--nodaemon'
|
||||
'--replace'
|
||||
'--restore'
|
||||
'--session'
|
||||
'--system'
|
||||
'-v'
|
||||
'--version'
|
||||
'-i'
|
||||
'--info'
|
||||
'-h'
|
||||
'--help'
|
||||
)
|
||||
|
||||
# work block
|
||||
_netctlgui_helper() {
|
||||
COMPREPLY=()
|
||||
wantfiles='-@(c|-config)'
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
|
||||
if [[ $prev = $wantfiles ]]; then
|
||||
_filedir
|
||||
else
|
||||
COMPREPLY=($(compgen -W '${_netctlgui_helper[@]}' -- "$cur"))
|
||||
fi
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
complete -F _netctlgui_helper netctlgui-helper
|
63
sources/helper/netctl-gui.conf
Normal file
@ -0,0 +1,63 @@
|
||||
# Configuration file for Netctl GUI project
|
||||
# /etc/netctl-gui.conf - system-wide configuration
|
||||
# $HOME/.config/netctl-gui.conf - user configuration
|
||||
|
||||
# close helper after GUI application quit.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
CLOSETOTRAY=true
|
||||
# hide application to tray on exit if tray is available.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
CLOSE_HELPER=false
|
||||
# path to control directory which is required by wpa_supplicant
|
||||
CTRL_DIR=/run/wpa_supplicant_netctl-gui
|
||||
# group which is owner of CTRL_DIR
|
||||
CTRL_GROUP=users
|
||||
# force use SUDO_PATH for helper instead of using setuid(3) to child processes
|
||||
FORCE_SUDO=false
|
||||
# path to netctlgui-helper.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
HELPER_PATH=/usr/bin/netctlgui-helper
|
||||
# netctlgui-helper service name.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
HELPER_SERVICE=netctlgui-helper.service
|
||||
# path to directory which contains interface information
|
||||
IFACE_DIR=/sys/class/net/
|
||||
# application language
|
||||
LANGUAGE=en
|
||||
# path to netctl-auto
|
||||
NETCTLAUTO_PATH=/usr/bin/netctl-auto
|
||||
# netctl-auto service name without .service suffix
|
||||
NETCTLAUTO_SERVICE=netctl-auto
|
||||
# path to netctl
|
||||
NETCTL_PATH=/usr/bin/netctl
|
||||
# wpa_supplicant PID file
|
||||
PID_FILE=/run/wpa_supplicant_netctl-gui.pid
|
||||
# prefered wireless interface
|
||||
PREFERED_IFACE=
|
||||
# path to netctl profile directory
|
||||
PROFILE_DIR=/etc/netctl/
|
||||
# path to directory with rfkill devices.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
RFKILL_DIR=/sys/class/rfkill/
|
||||
# skip external components checking
|
||||
# This option is not recognized by netctlgui-helper
|
||||
SKIPCOMPONENTS=false
|
||||
# start netctl-gui minimized to tray if it is available.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
STARTTOTRAY=false
|
||||
# path to sudo frontend
|
||||
SUDO_PATH=/usr/bin/sudo
|
||||
# path to systemctl
|
||||
SYSTEMCTL_PATH=/usr/bin/systemctl
|
||||
# create system tray icon.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
SYSTRAY=true
|
||||
# use netctlgui-helper if it is available.
|
||||
# This option is not recognized by netctlgui-helper
|
||||
USE_HELPER=true
|
||||
# path to wpa_cli
|
||||
WPACLI_PATH=/usr/bin/wpa_cli
|
||||
# path to wpa_supplicant
|
||||
WPASUP_PATH=/usr/bin/wpa_supplicant
|
||||
# wpa_supplicant drivers for wireless interface comma separated
|
||||
WPA_DRIVERS=nl80211,wext
|
107
sources/helper/netctl-gui.conf.5
Normal file
@ -0,0 +1,107 @@
|
||||
.TH netctl-gui.conf 5 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "File Formats Manual"
|
||||
.SH NAME
|
||||
netctl-gui.conf is a configuration file of Netctl GUI project
|
||||
.SH SYNOPSIS
|
||||
.B /etc/netctl-gui.conf
|
||||
for system-wide configuration or
|
||||
.B $HOME/.config/netctl-gui.conf
|
||||
for user one
|
||||
.SH DESCRIPTION
|
||||
.B netctl-gui.conf
|
||||
is a file which contains parameters for
|
||||
.BR netctlgui-helper (1)
|
||||
and may be used as template for
|
||||
.BR netctl-gui (1)
|
||||
configuration also.
|
||||
.SH OPTIONS
|
||||
.IP "CLOSE_HELPER=false"
|
||||
close helper after GUI application quit. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "CLOSETOTRAY=true"
|
||||
hide application to tray on exit if tray is available. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "CTRL_DIR=/run/wpa_supplicant_netctl-gui"
|
||||
path to control directory which is required by
|
||||
.BR wpa_supplicant (8)
|
||||
.IP "CTRL_GROUP=users"
|
||||
group which is owner of
|
||||
.B CTRL_DIR
|
||||
.IP "FORCE_SUDO=false"
|
||||
force use
|
||||
.B SUDO_PATH
|
||||
for helper instead of using
|
||||
.BR setuid (3)
|
||||
to child processes
|
||||
.IP "HELPER_PATH=/usr/bin/netctlgui-helper"
|
||||
path to
|
||||
.BR netctlgui-helper (1)
|
||||
This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "HELPER_SERVICE=netctlgui-helper.service"
|
||||
.BR netctlgui-helper (1)
|
||||
service name. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "IFACE_DIR=/sys/class/net/"
|
||||
path to directory which contains interface information
|
||||
.IP "LANGUAGE=en"
|
||||
application language
|
||||
.IP "NETCTL_PATH=/usr/bin/netctl"
|
||||
path to
|
||||
.BR netctl (1)
|
||||
.IP "NETCTLAUTO_PATH=/usr/bin/netctl-auto"
|
||||
path to
|
||||
.BR netctl-auto (1)
|
||||
.IP "NETCTLAUTO_SERVICE=netctl-auto"
|
||||
.BR netctl-auto (1)
|
||||
service name without
|
||||
.I .service
|
||||
suffix
|
||||
.IP "PID_FILE=/run/wpa_supplicant_netctl-gui.pid"
|
||||
.BR wpa_supplicant (8)
|
||||
PID file
|
||||
.IP "PREFERED_IFACE="
|
||||
prefered wireless interface
|
||||
.IP "PROFILE_DIR=/etc/netctl/"
|
||||
path to
|
||||
.BR netctl (1)
|
||||
profile directory
|
||||
.IP "RFKILL_DIR=/sys/class/rfkill/"
|
||||
path to directory with
|
||||
.BR rfkill (8)
|
||||
devices. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "SKIPCOMPONENTS=false"
|
||||
skip external components checking. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "STARTTOTRAY=false"
|
||||
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"
|
||||
path to
|
||||
.BR sudo (8)
|
||||
frontend
|
||||
.IP "SYSTEMCTL_PATH=/usr/bin/systemctl"
|
||||
path to
|
||||
.BR systemctl (1)
|
||||
.IP "SYSTRAY=true"
|
||||
create system tray icon. This option is not recognized by
|
||||
.BR netctlgui-helper (1)
|
||||
.IP "USE_HELPER=true"
|
||||
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"
|
||||
path to
|
||||
.BR wpa_cli (8)
|
||||
.IP "WPASUP_PATH=/usr/bin/wpa_supplicant"
|
||||
path to
|
||||
.BR wpa_supplicant (8)
|
||||
.IP "WPA_DRIVERS=nl80211,wext"
|
||||
.BR wpa_supplicant (8)
|
||||
drivers for wireless interface comma separated
|
||||
.SH SEE ALSO
|
||||
.BR netctl-gui (1)
|
||||
.BR netctlgui-helper (1)
|
81
sources/helper/netctlgui-helper.1
Normal file
@ -0,0 +1,81 @@
|
||||
.TH netctlgui-helper 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "General Commands Manual"
|
||||
.SH NAME
|
||||
netctlgui-helper is a helper daemon for netctl-gui
|
||||
.SH SYNOPSIS
|
||||
.B netctlgui-helper
|
||||
[ options ]
|
||||
.SH DESCRIPTION
|
||||
.B netctlgui-helper
|
||||
is a Qt based helper daemon which provides a DBus interface for interaction with
|
||||
.B netctl
|
||||
without any additional permissions. To have access to DBus interface user should have group
|
||||
.B network
|
||||
.SH OPTIONS
|
||||
.IP "-c, --config FILE"
|
||||
read configuration from file
|
||||
.I FILE
|
||||
instead of default user configuration
|
||||
.IP "-d, --debug"
|
||||
print debug information
|
||||
.IP "--nodaemon"
|
||||
do not run as daemon
|
||||
.IP "--replace"
|
||||
force replace the existing session
|
||||
.IP "--restore"
|
||||
force restore the existing session
|
||||
.IP "--session"
|
||||
force create user DBus session
|
||||
.IP "--system"
|
||||
do not read user configuration
|
||||
.IP "-v, --version"
|
||||
show version and exit
|
||||
.IP "-i, --info"
|
||||
show build information and exit
|
||||
.IP "-h, --help"
|
||||
show this help and exit
|
||||
.SH FILES
|
||||
.I $HOME/.config/netctl-gui.conf
|
||||
,
|
||||
.I /etc/netctl-gui.conf
|
||||
.RS
|
||||
Configuration files
|
||||
.RE
|
||||
.I /usr/lib/systemd/system/netctlgui-helper.service
|
||||
.RS
|
||||
Systemd service file
|
||||
.RE
|
||||
.I /etc/dbus-1/system.d/org.netctlgui.helper.conf
|
||||
.RS
|
||||
DBus policy configuration file
|
||||
.RE
|
||||
.SH USAGE WITH SYSTEMD
|
||||
It is a recommended way to use this daemon. To start helper as systemd daemon type:
|
||||
.nf
|
||||
# systemctl start netctlgui-helper
|
||||
.fi
|
||||
If you want to setup non-standard configuration file edit source service file and replace the following line:
|
||||
.nf
|
||||
ExecStart=/usr/bin/netctlgui-helper
|
||||
.fi
|
||||
to
|
||||
.nf
|
||||
ExecStart=/usr/bin/netctlgui-helper -c /path/to/your/file
|
||||
.fi
|
||||
By the way it is highly recommended to copy source service file before to
|
||||
.B /etc/systemd/system
|
||||
and edit copied file to avoid upgrade problems.
|
||||
.SH SEE ALSO
|
||||
.BR netctl-gui (1)
|
||||
.BR netctl-gui.conf (5)
|
||||
.SH STANDARDS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html
|
||||
for more details.
|
||||
.SH SECURITY CONSIDERATIONS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html
|
||||
for more details.
|
||||
.SH AUTHOR
|
||||
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
|
||||
.SH LICENSE
|
||||
This software is licensed under @PROJECT_LICENSE@
|
11
sources/helper/netctlgui-helper.service
Normal file
@ -0,0 +1,11 @@
|
||||
[Unit]
|
||||
Description=netctlgui-helper daemon
|
||||
Documentation=man:netctlgui-helper(1) man:netctl-gui.conf(5)
|
||||
|
||||
[Service]
|
||||
Type=dbus
|
||||
BusName=org.netctlgui.helper
|
||||
ExecStart=/usr/bin/netctlgui-helper --nodaemon --system
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
16
sources/helper/org.netctlgui.helper.conf
Normal file
@ -0,0 +1,16 @@
|
||||
<!DOCTYPE busconfig PUBLIC
|
||||
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<!-- allow everything to users of the group "network" -->
|
||||
<policy group="network">
|
||||
<allow own="org.netctlgui.helper"/>
|
||||
<allow send_destination="org.netctlgui.helper"/>
|
||||
<allow receive_sender="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
<policy user="root">
|
||||
<allow own="org.netctlgui.helper"/>
|
||||
<allow send_destination="org.netctlgui.helper"/>
|
||||
<allow receive_sender="org.netctlgui.helper"/>
|
||||
</policy>
|
||||
</busconfig>
|
60
sources/helper/src/CMakeLists.txt
Normal file
@ -0,0 +1,60 @@
|
||||
# set files
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp)
|
||||
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.h)
|
||||
|
||||
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources-helper.qrc)
|
||||
|
||||
# include_path
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||
|
||||
if (USE_QT5)
|
||||
find_package(Qt5 COMPONENTS Core DBus LinguistTools REQUIRED)
|
||||
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
|
||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES})
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
foreach (LANGUAGE ${LANGUAGES})
|
||||
set (TS ${LANGUAGE})
|
||||
string (REPLACE ".ts" ".qm" QM ${TS})
|
||||
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
|
||||
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
|
||||
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
||||
endforeach ()
|
||||
add_custom_target (translations-helper COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations-helper COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
else ()
|
||||
find_package (Qt4 COMPONENTS QtCore QtDBus REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
foreach (LANGUAGE ${LANGUAGES})
|
||||
set (TS ${LANGUAGE})
|
||||
string (REPLACE ".ts" ".qm" QM ${TS})
|
||||
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
|
||||
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
|
||||
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
||||
endforeach ()
|
||||
add_custom_target (translations-helper COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations-helper COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
endif()
|
||||
|
||||
add_executable (${SUBPROJECT} ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||
# install properties
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
if (USE_CAPABILITIES)
|
||||
install (CODE "exec_program (setcap ARGS \"cap_setuid=ep\" \"$ENV{DESTDIR}/bin/${SUBPROJECT}\")")
|
||||
endif ()
|
269
sources/helper/src/controladaptor.cpp
Normal file
@ -0,0 +1,269 @@
|
||||
/***************************************************************************
|
||||
* 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 "controladaptor.h"
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "netctlhelper.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
ControlAdaptor::ControlAdaptor(NetctlHelper *parent, const bool debugCmd, const QMap<QString, QString> configuration)
|
||||
: QDBusAbstractAdaptor(parent),
|
||||
debug(debugCmd),
|
||||
helper(parent)
|
||||
|
||||
{
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
}
|
||||
|
||||
|
||||
ControlAdaptor::~ControlAdaptor()
|
||||
{
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
}
|
||||
|
||||
|
||||
// helper
|
||||
bool ControlAdaptor::Active()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QString ControlAdaptor::ApiDocs()
|
||||
{
|
||||
return (QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html"));
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Close()
|
||||
{
|
||||
helper->quitHelper();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QStringList ControlAdaptor::FindSettings()
|
||||
{
|
||||
QMap<QString, QString> configuration;
|
||||
// apply settings from Netctl class
|
||||
QMap<QString, QString> librarySettings = netctlCommand->getRecommendedConfiguration();
|
||||
for (int i=0; i<librarySettings.keys().count(); i++)
|
||||
configuration[librarySettings.keys()[i]] = librarySettings[librarySettings.keys()[i]];
|
||||
// apply settings from NetctlProfile class
|
||||
librarySettings = netctlProfile->getRecommendedConfiguration();
|
||||
for (int i=0; i<librarySettings.keys().count(); i++)
|
||||
configuration[librarySettings.keys()[i]] = librarySettings[librarySettings.keys()[i]];
|
||||
// apply settings from WpaSup class
|
||||
librarySettings = wpaCommand->getRecommendedConfiguration();
|
||||
for (int i=0; i<librarySettings.keys().count(); i++)
|
||||
configuration[librarySettings.keys()[i]] = librarySettings[librarySettings.keys()[i]];
|
||||
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<configuration.keys().count(); i++)
|
||||
settingsList.append(configuration.keys()[i] + QString("==") +
|
||||
configuration[configuration.keys()[i]]);
|
||||
|
||||
return settingsList;
|
||||
}
|
||||
|
||||
|
||||
QString ControlAdaptor::LibraryDocs()
|
||||
{
|
||||
return (QString(DOCS_PATH) + QString("html/index.html"));
|
||||
}
|
||||
|
||||
|
||||
QString ControlAdaptor::Pony()
|
||||
{
|
||||
QString pony;
|
||||
QFile ponyFile(QString(":pinkiepie"));
|
||||
if (!ponyFile.open(QIODevice::ReadOnly))
|
||||
return pony;
|
||||
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
|
||||
ponyFile.close();
|
||||
|
||||
return pony;
|
||||
}
|
||||
|
||||
|
||||
QString ControlAdaptor::SecurityDocs()
|
||||
{
|
||||
return (QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"));
|
||||
}
|
||||
|
||||
|
||||
QStringList ControlAdaptor::Settings()
|
||||
{
|
||||
return helper->printSettings();
|
||||
}
|
||||
|
||||
|
||||
QStringList ControlAdaptor::UIDs()
|
||||
{
|
||||
QStringList uids;
|
||||
uids.append(QString::number(getuid()));
|
||||
uids.append(QString::number(geteuid()));
|
||||
|
||||
return uids;
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Update()
|
||||
{
|
||||
helper->updateConfiguration();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// netctlCommand
|
||||
bool ControlAdaptor::autoDisableAll()
|
||||
{
|
||||
return netctlCommand->autoDisableAllProfiles();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoEnable(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoEnableProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoEnableAll()
|
||||
{
|
||||
return netctlCommand->autoEnableAllProfiles();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoStart(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoStartProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoServiceEnable()
|
||||
{
|
||||
return netctlCommand->autoEnableService();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoServiceRestart()
|
||||
{
|
||||
return netctlCommand->autoRestartService();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::autoServiceStart()
|
||||
{
|
||||
return netctlCommand->autoStartService();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Enable(const QString profile)
|
||||
{
|
||||
return netctlCommand->enableProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::forceStart(const QString profile)
|
||||
{
|
||||
return netctlCommand->forceStartProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::forceStop(const QString profile)
|
||||
{
|
||||
return netctlCommand->forceStopProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Reenable(const QString profile)
|
||||
{
|
||||
return netctlCommand->reenableProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Restart(const QString profile)
|
||||
{
|
||||
return netctlCommand->restartProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Start(const QString profile)
|
||||
{
|
||||
return netctlCommand->startProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::StopAll()
|
||||
{
|
||||
return netctlCommand->stopAllProfiles();
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::SwitchTo(const QString profile)
|
||||
{
|
||||
return netctlCommand->switchToProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
// netctlProfile
|
||||
bool ControlAdaptor::Create(const QString profile, const QStringList settingsList)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<settingsList.count(); i++) {
|
||||
if (!settingsList[i].contains(QString("=="))) continue;
|
||||
QString key = settingsList[i].split(QString("=="))[0];
|
||||
QString value = settingsList[i].split(QString("=="))[1];
|
||||
settings[key] = value;
|
||||
}
|
||||
QString temporaryProfile = netctlProfile->createProfile(profile, settings);
|
||||
|
||||
return netctlProfile->copyProfile(temporaryProfile);
|
||||
}
|
||||
|
||||
|
||||
bool ControlAdaptor::Remove(const QString profile)
|
||||
{
|
||||
return netctlProfile->removeProfile(profile);
|
||||
}
|
||||
|
||||
|
||||
// wpaCommand
|
||||
QStringList ControlAdaptor::WiFi()
|
||||
{
|
||||
QList<netctlWifiInfo> wifiPoints = wpaCommand->scanWifi();
|
||||
QStringList info;
|
||||
for (int i=0; i<wifiPoints.count(); i++) {
|
||||
QStringList point;
|
||||
point.append(wifiPoints[i].name);
|
||||
point.append(wifiPoints[i].security);
|
||||
point.append(wifiPoints[i].signal);
|
||||
point.append(QString::number(wifiPoints[i].active));
|
||||
point.append(QString::number(wifiPoints[i].exists));
|
||||
info.append(point.join(QChar('|')));
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
82
sources/helper/src/controladaptor.h
Normal file
@ -0,0 +1,82 @@
|
||||
/***************************************************************************
|
||||
* 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 CONTROLADAPTOR_H
|
||||
#define CONTROLADAPTOR_H
|
||||
|
||||
#include <QDBusAbstractAdaptor>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class NetctlHelper;
|
||||
|
||||
class ControlAdaptor : public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.netctlgui.helper")
|
||||
|
||||
public:
|
||||
explicit ControlAdaptor(NetctlHelper *parent = 0,
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||
~ControlAdaptor();
|
||||
|
||||
public slots:
|
||||
// helper
|
||||
bool Active();
|
||||
QString ApiDocs();
|
||||
bool Close();
|
||||
QStringList FindSettings();
|
||||
QString LibraryDocs();
|
||||
QString Pony();
|
||||
QString SecurityDocs();
|
||||
QStringList Settings();
|
||||
QStringList UIDs();
|
||||
bool Update();
|
||||
// netctlCommand
|
||||
bool autoDisableAll();
|
||||
bool autoEnable(const QString profile);
|
||||
bool autoEnableAll();
|
||||
bool autoStart(const QString profile);
|
||||
bool autoServiceEnable();
|
||||
bool autoServiceRestart();
|
||||
bool autoServiceStart();
|
||||
bool Enable(const QString profile);
|
||||
bool forceStart(const QString profile);
|
||||
bool forceStop(const QString profile);
|
||||
bool Reenable(const QString profile);
|
||||
bool Restart(const QString profile);
|
||||
bool Start(const QString profile);
|
||||
bool StopAll();
|
||||
bool SwitchTo(const QString profile);
|
||||
// netctlProfile
|
||||
bool Create(const QString profile, const QStringList settingsList);
|
||||
bool Remove(const QString profile);
|
||||
// wpaCommand
|
||||
QStringList WiFi();
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
NetctlHelper *helper;
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif /* CONTROLADAPTOR_H */
|
164
sources/helper/src/main.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/***************************************************************************
|
||||
* 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 <QCoreApplication>
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <language/language.h>
|
||||
|
||||
#include "messages.h"
|
||||
#include "netctlhelper.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
bool existingSessionOperation(const QString operation)
|
||||
{
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, operation);
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return (!arguments.isEmpty() && bool(arguments[0].toInt()));
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QMap<QString, QVariant> args = getArgs();
|
||||
// reading
|
||||
for (int i=1; i<argc; i++) {
|
||||
if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) {
|
||||
// config path
|
||||
args[QString("config")] = QDir().absoluteFilePath(argv[i+1]);
|
||||
i++;
|
||||
} else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
|
||||
// debug
|
||||
args[QString("debug")] = true;
|
||||
} else if (QString(argv[i]) == QString("--nodaemon")) {
|
||||
// daemonized
|
||||
args[QString("nodaemon")] = true;
|
||||
} else if (QString(argv[i]) == QString("--replace")) {
|
||||
// replace
|
||||
args[QString("state")] = (int) 1;
|
||||
} else if (QString(argv[i]) == QString("--restore")) {
|
||||
// restore
|
||||
args[QString("state")] = (int) 2;
|
||||
} else if (QString(argv[i]) == QString("--session")) {
|
||||
// session
|
||||
args[QString("session")] = true;
|
||||
} else if (QString(argv[i]) == QString("--system")) {
|
||||
// system
|
||||
args[QString("system")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
|
||||
// help message
|
||||
args[QString("help")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
|
||||
// info message
|
||||
args[QString("info")] = true;
|
||||
} else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
|
||||
// version message
|
||||
args[QString("version")] = true;
|
||||
} else {
|
||||
args[QString("error")] = true;
|
||||
}
|
||||
}
|
||||
if ((args[QString("debug")].toBool()) ||
|
||||
(args[QString("help")].toBool()) ||
|
||||
(args[QString("info")].toBool()) ||
|
||||
(args[QString("version")].toBool()) ||
|
||||
(args[QString("error")].toBool()))
|
||||
args[QString("nodaemon")] = true;
|
||||
// check euid
|
||||
if (geteuid() != 0) {
|
||||
cout << QCoreApplication::translate("NetctlHelper", "The helper is running with EUID %1. Some functions may not be available.")
|
||||
.arg(QString::number(geteuid())).toUtf8().data() << endl;
|
||||
cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.")
|
||||
.toUtf8().data() << endl;
|
||||
args[QString("session")] = true;
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
QCoreApplication::setSetuidAllowed(true);
|
||||
#endif
|
||||
QCoreApplication a(argc, argv);
|
||||
// reread translations according to flags
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
a.installTranslator(&qtTranslator);
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations-helper/") + language);
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// running
|
||||
if (args[QString("error")].toBool()) {
|
||||
cout << errorMessage().toUtf8().data() << endl;
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 127;
|
||||
} else if (args[QString("help")].toBool()) {
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 0;
|
||||
} else if (args[QString("info")].toBool()) {
|
||||
cout << versionMessage().toUtf8().data() << endl;
|
||||
cout << infoMessage().toUtf8().data();
|
||||
return 0;
|
||||
} else if (args[QString("version")].toBool()) {
|
||||
cout << versionMessage().toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check if exists
|
||||
if (existingSessionOperation(QString("Active"))) {
|
||||
if (args[QString("state")].toInt() == 1) {
|
||||
// replace session
|
||||
cout << QCoreApplication::translate("NetctlHelper", "Replace existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
existingSessionOperation(QString("Close"));
|
||||
} else if (args[QString("state")].toInt() == 2) {
|
||||
// restore session
|
||||
cout << QCoreApplication::translate("NetctlHelper", "Restore existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
return 0;
|
||||
}
|
||||
else if (geteuid() == 0) {
|
||||
// replace if running as root
|
||||
cout << QCoreApplication::translate("NetctlHelper", "Replace existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
existingSessionOperation(QString("Close"));
|
||||
}
|
||||
else {
|
||||
// restore if running as non-root
|
||||
cout << QCoreApplication::translate("NetctlHelper", "Restore existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
NetctlHelper w(0, args);
|
||||
return a.exec();
|
||||
}
|
146
sources/helper/src/messages.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
/***************************************************************************
|
||||
* 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 <QCoreApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
QString errorMessage()
|
||||
{
|
||||
QString errorMessage = QCoreApplication::translate("NetctlHelper", "Unknown flag\n");
|
||||
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> getArgs()
|
||||
{
|
||||
QMap<QString, QVariant> args;
|
||||
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf"));
|
||||
args[QString("debug")] = false;
|
||||
args[QString("nodaemon")] = false;
|
||||
args[QString("session")] = false;
|
||||
args[QString("state")] = (int) 0;
|
||||
args[QString("system")] = false;
|
||||
args[QString("help")] = false;
|
||||
args[QString("info")] = false;
|
||||
args[QString("version")] = false;
|
||||
args[QString("error")] = false;
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
QString helpMessage()
|
||||
{
|
||||
QString helpMessage = QString("");
|
||||
helpMessage += QString("%1\n").arg(QCoreApplication::translate("NetctlHelper", "Usage:"));
|
||||
helpMessage += QString("netctlgui-helper [ options ]\n");
|
||||
helpMessage += QString("%1\n").arg(QCoreApplication::translate("NetctlHelper", "Options:"));
|
||||
// windows
|
||||
helpMessage += QString(" -c, --config <arg> - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "read configuration from this file"));
|
||||
helpMessage += QString(" -d, --debug - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "print debug information"));
|
||||
helpMessage += QString(" --nodaemon - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "do not start as daemon"));
|
||||
helpMessage += QString(" --replace - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "force replace the existing session"));
|
||||
helpMessage += QString(" --restore - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "force restore the existing session"));
|
||||
helpMessage += QString(" --session - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "force create user DBus session"));
|
||||
helpMessage += QString(" --system - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "do not read user configuration, system-wide only"));
|
||||
helpMessage += QString(" %1\n").arg(QCoreApplication::translate("NetctlHelper", "Show messages:"));
|
||||
helpMessage += QString(" -v, --version - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "show version and exit"));
|
||||
helpMessage += QString(" -i, --info - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "show build information and exit"));
|
||||
helpMessage += QString(" -h, --help - %1\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "show this help and exit"));
|
||||
|
||||
return helpMessage;
|
||||
}
|
||||
|
||||
|
||||
QString infoMessage()
|
||||
{
|
||||
QString infoMessage = QString("");
|
||||
// build information
|
||||
infoMessage += QCoreApplication::translate("NetctlHelper", "Build date: %1").
|
||||
arg(QString(BUILD_DATE));
|
||||
// cmake
|
||||
infoMessage += QString("\n%1:\n").arg(QCoreApplication::translate("NetctlHelper", "cmake flags"));
|
||||
// cmake properties
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "cmake properties"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
// components
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "Components"));
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QString("\t-DBUILD_GUI=%1\n").arg(QString(PROJECT_BUILD_GUI));
|
||||
infoMessage += QString("\t-DBUILD_HELPER=%1\n").arg(QString(PROJECT_BUILD_HELPER));
|
||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
|
||||
// additional components
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "Additional components"));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
infoMessage += QString("\t-DBUILD_TEST=%1\n").arg(QString(PROJECT_BUILD_TEST));
|
||||
// project properties
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "Project properties"));
|
||||
infoMessage += QString("\t-DDBUS_SYSTEMCONF_PATH=%1\n").arg(QString(PROJECT_DBUS_SYSTEMCONF_PATH));
|
||||
infoMessage += QString("\t-DSYSTEMD_SERVICE_PATH=%1\n").arg(QString(PROJECT_SYSTEMD_SERVICE_PATH));
|
||||
infoMessage += QString("\t-DUSE_CAPABILITIES=%1\n").arg(QString(PROJECT_USE_CAPABILITIES));
|
||||
infoMessage += QString("\t-DUSE_QT5=%1\n").arg(QString(PROJECT_USE_QT5));
|
||||
// transport information
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "DBus configuration"));
|
||||
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
|
||||
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
infoMessage += QString("\tDBUS_HELPER_SERVICE=%1\n").arg(QString(DBUS_HELPER_SERVICE));
|
||||
infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH));
|
||||
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
|
||||
// docs path
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("NetctlHelper", "Documentation"));
|
||||
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
|
||||
|
||||
return infoMessage;
|
||||
}
|
||||
|
||||
|
||||
QString versionMessage()
|
||||
{
|
||||
QString versionMessage = QString("");
|
||||
versionMessage += QString("%1\n").arg(QString(NAME));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "Version"))
|
||||
.arg(QString(VERSION));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "Author"))
|
||||
.arg(QString(AUTHOR));
|
||||
versionMessage += QString("%1 : %2\n")
|
||||
.arg(QCoreApplication::translate("NetctlHelper", "License"))
|
||||
.arg(QString(LICENSE));
|
||||
|
||||
return versionMessage;
|
||||
}
|
34
sources/helper/src/messages.h
Normal file
@ -0,0 +1,34 @@
|
||||
/***************************************************************************
|
||||
* 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 MESSAGES_H
|
||||
#define MESSAGES_H
|
||||
|
||||
#include <QChar>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
QString errorMessage();
|
||||
QMap<QString, QVariant> getArgs();
|
||||
QString helpMessage();
|
||||
QString infoMessage();
|
||||
QString versionMessage();
|
||||
|
||||
|
||||
#endif /* MESSAGES_H */
|
159
sources/helper/src/netctladaptor.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
/***************************************************************************
|
||||
* 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 "netctladaptor.h"
|
||||
|
||||
|
||||
NetctlAdaptor::NetctlAdaptor(QObject *parent, const bool debugCmd, const QMap<QString, QString> configuration)
|
||||
: QDBusAbstractAdaptor(parent),
|
||||
debug(debugCmd)
|
||||
{
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
}
|
||||
|
||||
|
||||
NetctlAdaptor::~NetctlAdaptor()
|
||||
{
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
}
|
||||
|
||||
|
||||
// netctlCommand
|
||||
QString NetctlAdaptor::ActiveProfile()
|
||||
{
|
||||
if (isNetctlAutoActive())
|
||||
return netctlCommand->autoGetActiveProfile();
|
||||
else
|
||||
return netctlCommand->getActiveProfile().join(QChar('|'));
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdaptor::ActiveProfileStatus()
|
||||
{
|
||||
if (isNetctlAutoActive())
|
||||
return QString("netctl-auto");
|
||||
else {
|
||||
QStringList status;
|
||||
QStringList profiles = ActiveProfile().split(QChar('|'));
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
status.append(netctlCommand->getProfileStatus(profiles[i]));
|
||||
return status.join(QChar('|'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::autoIsProfileActive(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoIsProfileActive(profile);
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::autoIsProfileEnabled(const QString profile)
|
||||
{
|
||||
return netctlCommand->autoIsProfileEnabled(profile);
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlAdaptor::Information()
|
||||
{
|
||||
QStringList output;
|
||||
output.append(ActiveProfile());
|
||||
output.append(ActiveProfileStatus());
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::isNetctlAutoActive()
|
||||
{
|
||||
return netctlCommand->isNetctlAutoRunning();
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::isNetctlAutoEnabled()
|
||||
{
|
||||
return netctlCommand->isNetctlAutoEnabled();
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::isProfileActive(const QString profile)
|
||||
{
|
||||
return netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
|
||||
bool NetctlAdaptor::isProfileEnabled(const QString profile)
|
||||
{
|
||||
return netctlCommand->isProfileEnabled(profile);
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlAdaptor::ProfileList()
|
||||
{
|
||||
QList<netctlProfileInfo> profilesInfo;
|
||||
if (isNetctlAutoActive())
|
||||
profilesInfo = netctlCommand->getProfileListFromNetctlAuto();
|
||||
else
|
||||
profilesInfo = netctlCommand->getProfileList();
|
||||
QStringList info;
|
||||
for (int i=0; i<profilesInfo.count(); i++) {
|
||||
QStringList profileInfo;
|
||||
profileInfo.append(profilesInfo[i].name);
|
||||
profileInfo.append(profilesInfo[i].description);
|
||||
profileInfo.append(QString::number(profilesInfo[i].active));
|
||||
profileInfo.append(QString::number(profilesInfo[i].enabled));
|
||||
info.append(profileInfo.join(QChar('|')));
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
// netctlProfile
|
||||
QStringList NetctlAdaptor::Profile(const QString profile)
|
||||
{
|
||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
settingsList.append(settings.keys()[i] + QString("==") +
|
||||
settings[settings.keys()[i]]);
|
||||
|
||||
return settingsList;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdaptor::ProfileValue(const QString profile, const QString key)
|
||||
{
|
||||
return netctlProfile->getValueFromProfile(profile, key);
|
||||
}
|
||||
|
||||
|
||||
// wpaCommand
|
||||
QString NetctlAdaptor::ProfileByEssid(const QString essid)
|
||||
{
|
||||
return wpaCommand->existentProfile(essid);
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlAdaptor::WirelessInterfaces()
|
||||
{
|
||||
return netctlCommand->getWirelessInterfaceList();
|
||||
}
|