Compare commits
125 Commits
V.1.2.0
...
V.1.3.0-al
Author | SHA1 | Date | |
---|---|---|---|
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 |
205
CHANGELOG
@ -1,60 +1,163 @@
|
|||||||
Ver.1.2.0:
|
Ver.1.3.0
|
||||||
+ [all] added icons
|
---------
|
||||||
+ [all] added support of netctl-auto
|
* all:
|
||||||
+ [gui] added suppoort of macvlan
|
+ add processes error messages
|
||||||
+ [gui] added ability to remove profile
|
+ add support of several active profiles
|
||||||
+ [gui] added support of hidden wifi network
|
* some bug fixes and refactoring
|
||||||
+ [gui] added contextual menu to tables
|
* rewrite debug messages
|
||||||
+ [gui] added actions menu
|
* dataengine:
|
||||||
+ [gui] added clear() function to profileTab
|
+ add new sources: intIp6, extIp6, netctlAutoStatus
|
||||||
+ [gui] added about window
|
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||||
+ [gui] more command line options
|
* change default command to define external IP
|
||||||
+ [gui] added workaround for wireless-wep example
|
* change interface list definition
|
||||||
+ [lib] detached backend from frontend
|
* change internal IP definition
|
||||||
+ [lib] added error checking
|
* gui:
|
||||||
+ [lib] added doxygen documentation
|
+ add 3rd party license information
|
||||||
+ [plasmoid] added dataengine configuration
|
+ add system tray icon as an alternative to the plasmoid
|
||||||
+ [plasmoid] added about window
|
+ add DBus session interface org.netctlgui.netctlgui
|
||||||
* [all] changes in the project architecture
|
+ add dynamic settings load
|
||||||
* [all] refactoring
|
+ add support of openvswitch
|
||||||
* [gui] more debug information
|
+ add security notes and API descriptions
|
||||||
* [gui] changed lineEdit_profile to comboBox
|
+ add ability to use helper
|
||||||
* [gui] refactoring of configuration interface
|
+ add ability to start minimized/maximized/detached
|
||||||
* [gui] changed setting of the interface to profile tab
|
+ add ability to don't save profile from WiFi tab
|
||||||
* [gui] rewrited ErrorWindow class
|
* more correct actions into SettingsWindow
|
||||||
* [lib] more debug information
|
* update to library changes
|
||||||
* [lib] rewrited getSettingsFromProfile() function
|
* rewrite tables to use toolTip
|
||||||
* [plasmoid] edited configuration interface
|
* edit about window
|
||||||
* [plasmoid] changed double click event to click event
|
* 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 double quotes to profile names
|
||||||
|
+ add tests
|
||||||
|
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||||
|
* rename getInterfaceList() to getWirelessInterfaceList()
|
||||||
|
* change temporaty directory from $HOME/.cache to system one
|
||||||
|
- remove functions getProfileDescriptions() and getProfileStatuses()
|
||||||
|
- remove SleepThread class
|
||||||
|
* 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.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:
|
Ver.1.2.0
|
||||||
* [gui] fix error checking
|
---------
|
||||||
|
* 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.5:
|
***
|
||||||
+ [plasmoid] added "Start WiFi menu" function
|
|
||||||
* [plasmoid] refactoring
|
|
||||||
* [plasmoid] edited icon
|
|
||||||
|
|
||||||
Ver.1.0.4:
|
Ver.1.1.0 (netctl-1.7 update)
|
||||||
+ [gui] added Qt5 gui (by default)
|
-----------------------------
|
||||||
+ [plasmoid] added notifications
|
* dataengine:
|
||||||
* [plasmoid] fix run command with sudo from plasmoid
|
* change definition if profile is enabled
|
||||||
|
* gui:
|
||||||
|
+ add frequency
|
||||||
|
* change definition if profile is enabled
|
||||||
|
* plasmoid:
|
||||||
|
+ add menu title
|
||||||
|
|
||||||
Ver.1.0.3:
|
***
|
||||||
+ [plasmoid] edited russian translation
|
|
||||||
* [all] refactoring
|
|
||||||
|
|
||||||
Ver.1.0.2:
|
Ver.1.0.6
|
||||||
* [plasmoid] fix layout margins
|
---------
|
||||||
|
* gui:
|
||||||
|
* fix error checking
|
||||||
|
|
||||||
Ver.1.0.1:
|
***
|
||||||
- [all] removed scripts
|
|
||||||
|
|
||||||
Ver.1.0:
|
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
|
First release
|
||||||
|
103
PKGBUILD
@ -1,42 +1,40 @@
|
|||||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||||
|
|
||||||
pkgbase=netctl-gui
|
pkgbase=netctl-gui
|
||||||
pkgname=('netctl-gui' 'netctl-gui-qt4' 'kdeplasma-applets-netctl-gui')
|
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||||
pkgver=1.2.0
|
'libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||||
|
'kdeplasma-applets-netctl-gui')
|
||||||
|
pkgver=1.3.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
url="http://arcanis.name/projects/netctl-gui"
|
url="http://arcanis.name/projects/netctl-gui"
|
||||||
license=('GPL3')
|
license=('GPL3')
|
||||||
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
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")
|
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||||
install="${pkgbase}.install"
|
install="${pkgbase}.install"
|
||||||
md5sums=('5b3105a64bc162d30a41a2b3bcb06f0a')
|
md5sums=('d99eba4101fee42ebbfa5735aa706bc9')
|
||||||
|
|
||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
rm -rf "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
|
rm -rf "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||||
mkdir "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
|
mkdir "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd "${srcdir}/build-plasmoid"
|
cd "${srcdir}/build-plasmoid"
|
||||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DBUILD_DOCS:BOOL=0 \
|
|
||||||
-DBUILD_GUI:BOOL=0 \
|
-DBUILD_GUI:BOOL=0 \
|
||||||
-DBUILD_LIBRARY:BOOL=0 \
|
-DBUILD_LIBRARY:BOOL=0 \
|
||||||
|
-DBUILD_HELPER:BOOL=0 \
|
||||||
"../${pkgbase}"
|
"../${pkgbase}"
|
||||||
make
|
make
|
||||||
|
|
||||||
cd "${srcdir}/build-qt4"
|
cd "${srcdir}/build-qt4"
|
||||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DBUILD_DOCS:BOOL=0 \
|
|
||||||
-DBUILD_DATAENGINE:BOOL=0 \
|
-DBUILD_DATAENGINE:BOOL=0 \
|
||||||
-DBUILD_PLASMOID:BOOL=0 \
|
-DBUILD_PLASMOID:BOOL=0 \
|
||||||
-DUSE_QT5:BOOL=0 \
|
-DUSE_QT5:BOOL=0 \
|
||||||
@ -46,41 +44,104 @@ build() {
|
|||||||
cd "${srcdir}/build-qt5"
|
cd "${srcdir}/build-qt5"
|
||||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DBUILD_DOCS:BOOL=0 \
|
|
||||||
-DBUILD_DATAENGINE:BOOL=0 \
|
-DBUILD_DATAENGINE:BOOL=0 \
|
||||||
-DBUILD_PLASMOID:BOOL=0 \
|
-DBUILD_PLASMOID:BOOL=0 \
|
||||||
"../${pkgbase}"
|
"../${pkgbase}"
|
||||||
make
|
make
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
package_kdeplasma-applets-netctl-gui() {
|
package_kdeplasma-applets-netctl-gui() {
|
||||||
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||||
depends=('netctl' 'kdebase-workspace')
|
depends=('netctl' 'kdebase-workspace')
|
||||||
optdepends=('kdebase-runtime: sudo support'
|
optdepends=('kdebase-runtime: sudo support'
|
||||||
|
'netctlgui-helper: DBus helper daemon'
|
||||||
|
'netctlgui-helper-qt4: DBus helper daemon'
|
||||||
'netctl-gui: graphical front-end'
|
'netctl-gui: graphical front-end'
|
||||||
'netctl-gui-qt4: graphical front-end'
|
'netctl-gui-qt4: graphical front-end'
|
||||||
'sudo: sudo support')
|
'sudo: sudo support')
|
||||||
|
install="${pkgbase}.install"
|
||||||
|
|
||||||
cd "${srcdir}/build-plasmoid"
|
cd "${srcdir}/build-plasmoid"
|
||||||
make DESTDIR="${pkgdir}" install
|
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"
|
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
|
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/netctlgui-helper.conf')
|
||||||
|
|
||||||
|
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="${pkgbase}.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')
|
||||||
|
|
||||||
|
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/netctlgui-helper.conf')
|
||||||
|
|
||||||
|
cd "${srcdir}/build-qt4/helper"
|
||||||
|
make DESTDIR="${pkgdir}" install
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
package_netctl-gui-qt4() {
|
package_netctl-gui-qt4() {
|
||||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||||
depends=('netctl' 'qt4')
|
depends=('libnetctlgui-qt4')
|
||||||
|
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||||
|
'netctlgui-helper-qt4: DBus helper daemon')
|
||||||
provides=('netctl-gui')
|
provides=('netctl-gui')
|
||||||
conflicts=('netctl-gui')
|
conflicts=('netctl-gui')
|
||||||
|
install="${pkgbase}.install"
|
||||||
|
|
||||||
cd "${srcdir}/build-qt4"
|
cd "${srcdir}/build-qt4/gui"
|
||||||
make DESTDIR="${pkgdir}" install
|
make DESTDIR="${pkgdir}" install
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ Optional dependencies
|
|||||||
|
|
||||||
* kdebase-workspace (widget)
|
* kdebase-workspace (widget)
|
||||||
* sudo (sudo support)
|
* sudo (sudo support)
|
||||||
* wpa_actiond (netctl-auto support)
|
|
||||||
* wpa_supplicant (WiFi support)
|
* wpa_supplicant (WiFi support)
|
||||||
|
|
||||||
Make dependencies
|
Make dependencies
|
||||||
@ -54,8 +53,10 @@ Installation
|
|||||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
* `-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_LIBRARY:BOOL=0` - do not build library
|
||||||
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
||||||
|
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
|
||||||
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
||||||
|
|
||||||
Additional information
|
Additional information
|
||||||
@ -64,6 +65,9 @@ Additional information
|
|||||||
TODO (wish list)
|
TODO (wish list)
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
* remove suid bit from helper (polkit/logind/etc)
|
||||||
|
* check/update documentation
|
||||||
|
|
||||||
Links
|
Links
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
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 |
45
sources/3rdparty/pdebug/pdebug.h
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef PRETTY_DEBUG_H
|
||||||
|
#define PRETTY_DEBUG_H
|
||||||
|
|
||||||
|
|
||||||
|
inline const char *pDebug(const std::string prettyFunction)
|
||||||
|
{
|
||||||
|
return prettyFunction.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::string pFuncInfo(const std::string prettyFunction)
|
||||||
|
{
|
||||||
|
size_t colons = prettyFunction.find("::");
|
||||||
|
// workaround for functions which are not belong to any class
|
||||||
|
if (colons == std::string::npos)
|
||||||
|
colons = prettyFunction.rfind("(");
|
||||||
|
size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
|
||||||
|
size_t end = prettyFunction.rfind("(") - begin;
|
||||||
|
|
||||||
|
return "[" + prettyFunction.substr(begin, end) + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__))
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* PRETTY_DEBUG_H */
|
41
sources/3rdparty/task/README.md
vendored
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
|
||||||
|
Asynchronous programming in Qt/C++ using tasks,continuations and resumable functions.
|
||||||
|
|
||||||
|
This project is inspired by this[1] video on channel9.
|
||||||
|
|
||||||
|
The project seeks to do async based programming in Qt/C++ using modern C++ with lambdas.
|
||||||
|
|
||||||
|
The project has two sets of APIs.
|
||||||
|
|
||||||
|
1. Task::run().then() API provides async based programming with continuation[4].
|
||||||
|
|
||||||
|
2. Task::await() API provides the first API presented in a different way[5].
|
||||||
|
|
||||||
|
Under certain use cases,they can be used interchangeably, and in others,only one or the other can be used.Some of the problems
|
||||||
|
the first API causes and solved by the second API are discussed in this[7] youtube video.
|
||||||
|
|
||||||
|
Example use case for the Task::run().then() API can be found here[0]. Additional example is [2] where an API is
|
||||||
|
declared and [3] where the declared API is used.
|
||||||
|
|
||||||
|
Example use case of the Task::await() API is here[6] where a function call "blocks" waiting for a result without "hanging" the entire GUI application.
|
||||||
|
|
||||||
|
A short tutorial on task/async/await as implemented in C# can be viewed from this[8] link.
|
||||||
|
|
||||||
|
[0] https://github.com/mhogomchungu/tasks/blob/master/example.cpp
|
||||||
|
|
||||||
|
[1] http://channel9.msdn.com/Blogs/Charles/Asynchronous-Programming-for-C-Developers-PPL-Tasks-and-Windows-8
|
||||||
|
|
||||||
|
[2] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/zulumounttask.h#L61
|
||||||
|
|
||||||
|
[3] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/mainwindow.cpp#L812
|
||||||
|
|
||||||
|
[4] Disscussion about this can be found on the following link among other places: http://isocpp.org/files/papers/N3558.pdf
|
||||||
|
|
||||||
|
[5] Disscussion about this can be found on the following link among other places: http://isocpp.org/files/papers/N3564.pdf
|
||||||
|
|
||||||
|
[6] https://github.com/mhogomchungu/zuluCrypt/blob/7123e3c3a7c8c5b3b3b6958464fd92a7f780d827/zuluMount-gui/keydialog.cpp#L511
|
||||||
|
|
||||||
|
[7] https://www.youtube.com/watch?v=Y475RshtAHA
|
||||||
|
|
||||||
|
[8] http://www.youtube.com/watch?v=DqjIQiZ_ql4
|
385
sources/3rdparty/task/task.h
vendored
Normal file
@ -0,0 +1,385 @@
|
|||||||
|
/*
|
||||||
|
* copyright: 2014
|
||||||
|
* name : mhogo mchungu
|
||||||
|
* email: mhogomchungu@gmail.com
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __TASK_H_INCLUDED__
|
||||||
|
#define __TASK_H_INCLUDED__
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
|
#include <future>
|
||||||
|
#include <functional>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Examples on how to use the library are at the end of this file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Task
|
||||||
|
{
|
||||||
|
class Thread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
Thread()
|
||||||
|
{
|
||||||
|
connect( this,SIGNAL( finished() ),this,SLOT( deleteLater() ) ) ;
|
||||||
|
}
|
||||||
|
protected:
|
||||||
|
virtual ~Thread()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
virtual void run( void )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
class future
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
future() : m_function( []( T t ){ Q_UNUSED( t ) ; } )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void setActions( std::function< void( void ) > start,
|
||||||
|
std::function< void( void ) > cancel,
|
||||||
|
std::function< T ( void ) > get )
|
||||||
|
{
|
||||||
|
m_start = std::move( start ) ;
|
||||||
|
m_cancel = std::move( cancel ) ;
|
||||||
|
m_get = std::move( get ) ;
|
||||||
|
}
|
||||||
|
void then( std::function< void( T ) > function )
|
||||||
|
{
|
||||||
|
m_function = std::move( function ) ;
|
||||||
|
m_start() ;
|
||||||
|
}
|
||||||
|
T get()
|
||||||
|
{
|
||||||
|
return m_get() ;
|
||||||
|
}
|
||||||
|
T await()
|
||||||
|
{
|
||||||
|
QEventLoop p ;
|
||||||
|
|
||||||
|
T q ;
|
||||||
|
|
||||||
|
m_function = [ & ]( T r ){ q = std::move( r ) ; p.exit() ; } ;
|
||||||
|
|
||||||
|
m_start() ;
|
||||||
|
|
||||||
|
p.exec() ;
|
||||||
|
|
||||||
|
return q ;
|
||||||
|
}
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
m_start() ;
|
||||||
|
}
|
||||||
|
void cancel()
|
||||||
|
{
|
||||||
|
m_cancel() ;
|
||||||
|
}
|
||||||
|
void run( T r )
|
||||||
|
{
|
||||||
|
m_function( std::move( r ) ) ;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::function< void( T ) > m_function ;
|
||||||
|
std::function< void( void ) > m_start ;
|
||||||
|
std::function< void( void ) > m_cancel ;
|
||||||
|
std::function< T ( void ) > m_get ;
|
||||||
|
};
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
class ThreadHelper : public Thread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ThreadHelper( std::function< T ( void ) >&& function ) : m_function( std::move( function ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
future<T>& Future( void )
|
||||||
|
{
|
||||||
|
m_future.setActions( [ this ](){ this->start() ; },
|
||||||
|
[ this ](){ this->deleteLater() ; },
|
||||||
|
[ this ](){ T r = m_function() ; this->deleteLater() ; return r ; } ) ;
|
||||||
|
return m_future ;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
~ThreadHelper()
|
||||||
|
{
|
||||||
|
m_future.run( std::move( m_cargo ) ) ;
|
||||||
|
}
|
||||||
|
void run( void )
|
||||||
|
{
|
||||||
|
m_cargo = m_function() ;
|
||||||
|
}
|
||||||
|
std::function< T ( void ) > m_function ;
|
||||||
|
future<T> m_future ;
|
||||||
|
T m_cargo ;
|
||||||
|
};
|
||||||
|
|
||||||
|
class future_1
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
future_1() : m_function( [](){} )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void setActions( std::function< void( void ) > start,
|
||||||
|
std::function< void( void ) > cancel,
|
||||||
|
std::function< void( void ) > get )
|
||||||
|
{
|
||||||
|
m_start = std::move( start ) ;
|
||||||
|
m_cancel = std::move( cancel ) ;
|
||||||
|
m_get = std::move( get ) ;
|
||||||
|
}
|
||||||
|
void then( std::function< void( void ) > function )
|
||||||
|
{
|
||||||
|
m_function = std::move( function ) ;
|
||||||
|
m_start() ;
|
||||||
|
}
|
||||||
|
void get()
|
||||||
|
{
|
||||||
|
m_get() ;
|
||||||
|
}
|
||||||
|
void await()
|
||||||
|
{
|
||||||
|
QEventLoop p ;
|
||||||
|
|
||||||
|
m_function = [ & ](){ p.exit() ; } ;
|
||||||
|
|
||||||
|
m_start() ;
|
||||||
|
|
||||||
|
p.exec() ;
|
||||||
|
}
|
||||||
|
void start()
|
||||||
|
{
|
||||||
|
m_start() ;
|
||||||
|
}
|
||||||
|
void run()
|
||||||
|
{
|
||||||
|
m_function() ;
|
||||||
|
}
|
||||||
|
void cancel()
|
||||||
|
{
|
||||||
|
m_cancel() ;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::function< void( void ) > m_function ;
|
||||||
|
std::function< void( void ) > m_start ;
|
||||||
|
std::function< void( void ) > m_cancel ;
|
||||||
|
std::function< void( void ) > m_get ;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ThreadHelper_1 : public Thread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ThreadHelper_1( std::function< void ( void ) >&& function ) : m_function( std::move( function ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
future_1& Future( void )
|
||||||
|
{
|
||||||
|
m_future.setActions( [ this ](){ this->start() ; },
|
||||||
|
[ this ](){ this->deleteLater() ; },
|
||||||
|
[ this ](){ m_function() ; this->deleteLater() ; } ) ;
|
||||||
|
return m_future ;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
~ThreadHelper_1()
|
||||||
|
{
|
||||||
|
m_future.run() ;
|
||||||
|
}
|
||||||
|
void run( void )
|
||||||
|
{
|
||||||
|
m_function() ;
|
||||||
|
}
|
||||||
|
std::function< void ( void ) > m_function ;
|
||||||
|
future_1 m_future ;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Below APIs runs two tasks,the first one will run in a different thread and
|
||||||
|
* the second one will be run on the original thread after the completion of the
|
||||||
|
* first one.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
future<T>& run( std::function< T ( void ) > function )
|
||||||
|
{
|
||||||
|
auto t = new ThreadHelper<T>( std::move( function ) ) ;
|
||||||
|
return t->Future() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline future_1& run( std::function< void( void ) > function )
|
||||||
|
{
|
||||||
|
auto t = new ThreadHelper_1( std::move( function ) ) ;
|
||||||
|
return t->Future() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void exec( std::function< void( void ) > function )
|
||||||
|
{
|
||||||
|
Task::run( std::move( function ) ).start() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Below APIs implements resumable functions where a function will be "blocked"
|
||||||
|
* waiting for the function to return without "hanging" the current thread.
|
||||||
|
*
|
||||||
|
* recommending reading up on C#'s await keyword to get a sense of what is being
|
||||||
|
* discussed below.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline void await( Task::future_1& e )
|
||||||
|
{
|
||||||
|
e.await() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void await( std::function< void( void ) > function )
|
||||||
|
{
|
||||||
|
Task::run( std::move( function ) ).await() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
T await( std::function< T ( void ) > function )
|
||||||
|
{
|
||||||
|
return Task::run<T>( std::move( function ) ).await() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
T await( Task::future<T>& e )
|
||||||
|
{
|
||||||
|
return e.await() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
template< typename T >
|
||||||
|
T await( std::future<T>&& t )
|
||||||
|
{
|
||||||
|
return Task::await<T>( [ & ](){ return t.get() ; } ) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Examples on how to use the library
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* templated version that passes a return value of one function to another function
|
||||||
|
*/
|
||||||
|
auto _a = [](){
|
||||||
|
/*
|
||||||
|
* task _a does what task _a does here.
|
||||||
|
*
|
||||||
|
* This function body will run on a different thread
|
||||||
|
*/
|
||||||
|
return 0 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto _b = []( int r ){
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* task _b does what task _b does here.
|
||||||
|
*
|
||||||
|
* r is a const reference to a value returned by _a
|
||||||
|
*
|
||||||
|
* This function body will run on the original thread
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
Task::run<int>( _a ).then( _b ) ;
|
||||||
|
|
||||||
|
alternatively,
|
||||||
|
|
||||||
|
Task::future<int>& e = Task::run( _a ) ;
|
||||||
|
|
||||||
|
e.then( _b ) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Non templated version that does not pass around return value
|
||||||
|
*/
|
||||||
|
auto _c = [](){
|
||||||
|
/*
|
||||||
|
* task _a does what task _a does here.
|
||||||
|
*
|
||||||
|
* This function body will run on a different thread
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
auto _d = [](){
|
||||||
|
/*
|
||||||
|
* task _b does what task _b does here.
|
||||||
|
*
|
||||||
|
* r is a const reference to a value returned by _a
|
||||||
|
*
|
||||||
|
* This function body will run on the original thread
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
Task::run( _c ).then( _d ) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* if no continuation
|
||||||
|
*/
|
||||||
|
Task::exec( _c ) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Task::await() is used to "block" without "hanging" the calling thread until the function returns.
|
||||||
|
*
|
||||||
|
* Its use case is to do sync programming without hanging the calling thread.
|
||||||
|
*
|
||||||
|
* example use case for it is to "block" on function in a GUI thread withough blocking the GUI thread
|
||||||
|
* hanging the application.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* await example when the called function return no result
|
||||||
|
*/
|
||||||
|
Task::await( _c ) ;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* await example when the called function return a result
|
||||||
|
*/
|
||||||
|
int r = Task::await<int>( _a ) ;
|
||||||
|
|
||||||
|
alternatively,
|
||||||
|
|
||||||
|
Task::future<int>& e = Task::run<int>( _a ) ;
|
||||||
|
|
||||||
|
int r = e.await() ;
|
||||||
|
|
||||||
|
alternatively,
|
||||||
|
|
||||||
|
int r = Task::run<int>( _a ).await() ;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif //__TASK_H_INCLUDED__
|
44
sources/3rdparty/task/taskadds.cpp
vendored
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "taskadds.h"
|
||||||
|
|
||||||
|
|
||||||
|
TaskResult runTask(const QString cmd, const bool useSuid)
|
||||||
|
{
|
||||||
|
return Task::await<TaskResult>( [ & ]() {
|
||||||
|
TaskResult r;
|
||||||
|
if (useSuid) {
|
||||||
|
RootProcess command;
|
||||||
|
command.start(cmd);
|
||||||
|
command.waitForFinished(-1);
|
||||||
|
r.exitCode = command.exitCode();
|
||||||
|
r.output = command.readAllStandardOutput();
|
||||||
|
r.error = command.readAllStandardError();
|
||||||
|
} else {
|
||||||
|
QProcess command;
|
||||||
|
command.start(cmd);
|
||||||
|
command.waitForFinished(-1);
|
||||||
|
r.exitCode = command.exitCode();
|
||||||
|
r.output = command.readAllStandardOutput();
|
||||||
|
r.error = command.readAllStandardError();
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
}
|
47
sources/3rdparty/task/taskadds.h
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* This file is part of netctl-gui *
|
||||||
|
* *
|
||||||
|
* netctl-gui is free software: you can redistribute it and/or *
|
||||||
|
* modify it under the terms of the GNU General Public License as *
|
||||||
|
* published by the Free Software Foundation, either version 3 of the *
|
||||||
|
* License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* netctl-gui is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TASKADDS_H
|
||||||
|
#define TASKADDS_H
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "task.h"
|
||||||
|
|
||||||
|
|
||||||
|
class RootProcess : public QProcess
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
void setupChildProcess()
|
||||||
|
{
|
||||||
|
::setuid(0);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct TaskResult
|
||||||
|
{
|
||||||
|
int exitCode;
|
||||||
|
QByteArray error;
|
||||||
|
QByteArray output;
|
||||||
|
};
|
||||||
|
TaskResult runTask(const QString cmd, const bool useSuid = true);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* TASKADDS_H */
|
@ -10,7 +10,7 @@ set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
|||||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||||
set (PROJECT_LICENSE "GPLv3")
|
set (PROJECT_LICENSE "GPLv3")
|
||||||
set (PROJECT_VERSION_MAJOR 1)
|
set (PROJECT_VERSION_MAJOR 1)
|
||||||
set (PROJECT_VERSION_MINOR 2)
|
set (PROJECT_VERSION_MINOR 3)
|
||||||
set (PROJECT_VERSION_PATCH 0)
|
set (PROJECT_VERSION_PATCH 0)
|
||||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||||
@ -24,25 +24,33 @@ message (STATUS "Build date: ${CURRENT_DATE}")
|
|||||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||||
# components
|
# components
|
||||||
option (BUILD_GUI "Build GUI" ON)
|
option (BUILD_GUI "Build GUI" ON)
|
||||||
|
option (BUILD_HELPER "Build helper" ON)
|
||||||
option (BUILD_LIBRARY "Build library" 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)
|
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||||
if (BUILD_GUI)
|
if (BUILD_GUI OR BUILD_HELPER)
|
||||||
set (BUILD_LIBRARY ON)
|
set (BUILD_LIBRARY ON)
|
||||||
endif ()
|
endif ()
|
||||||
if (BUILD_PLASMOID)
|
if (BUILD_PLASMOID)
|
||||||
set (BUILD_DATAENGINE ON)
|
set (BUILD_DATAENGINE ON)
|
||||||
endif ()
|
endif ()
|
||||||
# documentation
|
# documentation
|
||||||
option (BUILD_DOCS "Build documentation and install headers" ON)
|
option (BUILD_DOCS "Build Doxygen documentation" OFF)
|
||||||
if (BUILD_DOCS)
|
if (BUILD_DOCS)
|
||||||
set (BUILD_LIBRARY ON)
|
set (BUILD_LIBRARY ON)
|
||||||
endif ()
|
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
|
# flags
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set (ADD_CXX_FLAGS "-Wall")
|
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||||
else ()
|
else ()
|
||||||
@ -59,7 +67,14 @@ add_subdirectory (${PROJECT_RESOURCE_DIR})
|
|||||||
# components
|
# components
|
||||||
if (BUILD_LIBRARY)
|
if (BUILD_LIBRARY)
|
||||||
add_subdirectory (${PROJECT_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)
|
if (BUILD_GUI)
|
||||||
add_subdirectory (gui)
|
add_subdirectory (gui)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -13,14 +13,16 @@ set (PLUGIN_NAME ${SUBPROJECT})
|
|||||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||||
|
set (TASK_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/task.h)
|
||||||
file (GLOB SUBPROJECT_CONF *.conf)
|
file (GLOB SUBPROJECT_CONF *.conf)
|
||||||
|
|
||||||
# prepare
|
# prepare
|
||||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||||
|
|
||||||
# make
|
# make
|
||||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
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
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||||
|
@ -2,19 +2,16 @@
|
|||||||
|
|
||||||
## Commands
|
## Commands
|
||||||
# command
|
# command
|
||||||
CMD=/usr/bin/netctl
|
NETCTLCMD=/usr/bin/netctl
|
||||||
# netctl-auto command
|
# netctl-auto command
|
||||||
NETCTLAUTOCMD=/usr/bin/netctl-auto
|
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
|
||||||
# external ip check command
|
# external IPv4 check command
|
||||||
EXTIPCMD=wget -qO- http://ifconfig.me/ip
|
EXTIP4CMD=curl ip4.telize.com
|
||||||
# 'true' - check external IP
|
# 'true' - check external IPv4
|
||||||
EXTIP=false
|
EXTIP4=false
|
||||||
|
# external IPv6 check command
|
||||||
|
EXTIP6CMD=curl ip6.telize.com
|
||||||
|
# 'true' - check external IPv6
|
||||||
|
EXTIP6=false
|
||||||
|
@ -15,38 +15,60 @@
|
|||||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "netctl.h"
|
|
||||||
|
|
||||||
#include <KGlobal>
|
#include <KGlobal>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
#include <Plasma/DataContainer>
|
#include <Plasma/DataContainer>
|
||||||
#include <QDir>
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QNetworkInterface>
|
||||||
|
#include <QProcessEnvironment>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
#include "netctl.h"
|
||||||
|
#include "pdebug.h"
|
||||||
|
#include "taskadds.h"
|
||||||
|
|
||||||
|
|
||||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||||
: Plasma::DataEngine(parent, args)
|
: Plasma::DataEngine(parent, args)
|
||||||
{
|
{
|
||||||
Q_UNUSED(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);
|
setMinimumPollingInterval(333);
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Netctl::~Netctl()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::sources() const
|
QStringList Netctl::sources() const
|
||||||
{
|
{
|
||||||
QStringList sources;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
sources.append(QString("currentProfile"));
|
QStringList sources;
|
||||||
sources.append(QString("extIp"));
|
sources.append(QString("active"));
|
||||||
|
sources.append(QString("current"));
|
||||||
|
sources.append(QString("extip4"));
|
||||||
|
sources.append(QString("extip6"));
|
||||||
sources.append(QString("interfaces"));
|
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("profiles"));
|
||||||
sources.append(QString("statusBool"));
|
sources.append(QString("status"));
|
||||||
sources.append(QString("statusString"));
|
|
||||||
|
|
||||||
return sources;
|
return sources;
|
||||||
}
|
}
|
||||||
@ -54,43 +76,50 @@ QStringList Netctl::sources() const
|
|||||||
|
|
||||||
void Netctl::readConfiguration()
|
void Netctl::readConfiguration()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
// default configuration
|
// default configuration
|
||||||
QMap<QString, QString> rawConfig;
|
QMap<QString, QString> rawConfig;
|
||||||
rawConfig[QString("CMD")] = QString("/usr/bin/netctl");
|
rawConfig[QString("EXTIP4")] = QString("false");
|
||||||
rawConfig[QString("EXTIP")] = QString("false");
|
rawConfig[QString("EXTIP4CMD")] = QString("curl ip4.telize.com");
|
||||||
rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
|
rawConfig[QString("EXTIP6")] = QString("false");
|
||||||
rawConfig[QString("IPCMD")] = QString("/usr/bin/ip");
|
rawConfig[QString("EXTIP6CMD")] = QString("curl ip6.telize.com");
|
||||||
rawConfig[QString("NETDIR")] = QString("/sys/class/net/");
|
rawConfig[QString("NETCTLCMD")] = QString("/usr/bin/netctl");
|
||||||
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
|
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
|
||||||
|
|
||||||
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
|
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
|
||||||
QFile confFile(fileName);
|
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||||
if (!confFile.open(QIODevice::ReadOnly)) {
|
QFile configFile(fileName);
|
||||||
|
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||||
configuration = updateConfiguration(rawConfig);
|
configuration = updateConfiguration(rawConfig);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString fileStr;
|
QString fileStr;
|
||||||
QStringList value;
|
QStringList value;
|
||||||
while (true) {
|
while (true) {
|
||||||
fileStr = QString(confFile.readLine()).trimmed();
|
fileStr = QString(configFile.readLine()).trimmed();
|
||||||
if (fileStr[0] == QChar('#')) continue;
|
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||||
if (fileStr[0] == QChar(';')) continue;
|
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||||
if (!fileStr.contains(QChar('='))) continue;
|
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||||
value.clear();
|
if (fileStr.contains(QChar('='))) {
|
||||||
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
value.clear();
|
||||||
value.append(fileStr.split(QChar('='))[i]);
|
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
||||||
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
value.append(fileStr.split(QChar('='))[i]);
|
||||||
if (confFile.atEnd())
|
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
||||||
break;
|
}
|
||||||
|
if (configFile.atEnd()) break;
|
||||||
}
|
}
|
||||||
confFile.close();
|
configFile.close();
|
||||||
configuration = updateConfiguration(rawConfig);
|
configuration = updateConfiguration(rawConfig);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
|
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QMap<QString, QString> config;
|
QMap<QString, QString> config;
|
||||||
QString key, value;
|
QString key, value;
|
||||||
// remove spaces and copy source map
|
// remove spaces and copy source map
|
||||||
@ -98,159 +127,232 @@ QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString>
|
|||||||
key = rawConfig.keys()[i];
|
key = rawConfig.keys()[i];
|
||||||
value = rawConfig[key];
|
value = rawConfig[key];
|
||||||
key.remove(QChar(' '));
|
key.remove(QChar(' '));
|
||||||
if ((key != QString("CMD")) &&
|
if ((key != QString("EXTIP4CMD")) &&
|
||||||
(key != QString("EXTIPCMD")) &&
|
(key != QString("EXTIP6CMD")) &&
|
||||||
(key != QString("IPCMD")) &&
|
(key != QString("NETCTLCMD")) &&
|
||||||
(key != QString("NETCTLAUTOCMD")))
|
(key != QString("NETCTLAUTOCMD")))
|
||||||
value.remove(QChar(' '));
|
value.remove(QChar(' '));
|
||||||
config[key] = value;
|
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;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Netctl::sourceRequestEvent(const QString &name)
|
bool Netctl::sourceRequestEvent(const QString &name)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Source name" << name;
|
||||||
|
|
||||||
return updateSourceEvent(name);
|
return updateSourceEvent(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getCurrentProfile(const QString cmd)
|
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||||
{
|
{
|
||||||
QProcess command;
|
if (debug) qDebug() << PDEBUG;
|
||||||
QString profile = QString("");
|
getNetctlAutoStatus(cmdNetctlAuto);
|
||||||
command.start(cmd + QString(" list"));
|
|
||||||
command.waitForFinished(-1);
|
QString cmd;
|
||||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
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);
|
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<profileList.count(); i++)
|
for (int i=0; i<profileList.count(); i++)
|
||||||
if (profileList[i][0] == QChar('*')) {
|
if (profileList[i][0] == QChar('*'))
|
||||||
profile = profileList[i];
|
currentProfile.append(profileList[i]);
|
||||||
break;
|
for (int i=0; i<currentProfile.count(); i++)
|
||||||
}
|
currentProfile[i].remove(0, 2);
|
||||||
profile.remove(0, 1);
|
|
||||||
return profile;
|
return currentProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getExtIp(const QString cmd)
|
QString Netctl::getExtIp(const QString cmd)
|
||||||
{
|
{
|
||||||
QProcess command;
|
if (debug) qDebug() << PDEBUG;
|
||||||
QString extIp = QString("");
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||||
command.start(cmd);
|
|
||||||
command.waitForFinished(-1);
|
TaskResult process = runTask(cmd);
|
||||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
extIp = cmdOutput.trimmed();
|
if (process.exitCode != 0)
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||||
|
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||||
|
|
||||||
return extIp;
|
return extIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::getInterfaceList(const QString dir)
|
QStringList Netctl::getInterfaceList()
|
||||||
{
|
{
|
||||||
QStringList interfaceList;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (QDir(dir).exists())
|
|
||||||
interfaceList = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
||||||
return interfaceList;
|
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;
|
if (debug) qDebug() << PDEBUG;
|
||||||
QString intIp = QString("127.0.0.1/8");
|
|
||||||
QStringList interfaceList = getInterfaceList(dir);
|
QString intIp = QString("");
|
||||||
for (int i=0; i<interfaceList.count(); i++)
|
if (protocol == QAbstractSocket::IPv4Protocol)
|
||||||
if (interfaceList[i] != QString("lo")) {
|
intIp = QString("127.0.0.1/8");
|
||||||
command.start(cmd + QString(" addr show ") + interfaceList[i]);
|
else if (protocol == QAbstractSocket::IPv6Protocol)
|
||||||
command.waitForFinished(-1);
|
intIp = QString("::1/128");
|
||||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
|
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
|
||||||
QStringList deviceInfo = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
for (int i=0; i<rawList.count(); i++) {
|
||||||
for (int j=0; j<deviceInfo.count(); j++)
|
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||||
if (deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[0] == QString("inet"))
|
if (rawList[i].protocol() == protocol) {
|
||||||
intIp = deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[1];
|
intIp = rawList[i].toString();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return intIp;
|
return intIp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::getProfileList(const QString cmd)
|
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
|
||||||
{
|
{
|
||||||
QProcess command;
|
if (debug) qDebug() << PDEBUG;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||||
{
|
{
|
||||||
QProcess command;
|
if (debug) qDebug() << PDEBUG;
|
||||||
QString status = QString("static");
|
getNetctlAutoStatus(cmdNetctlAuto);
|
||||||
// check netctl-auto
|
|
||||||
if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
|
QString cmd;
|
||||||
status = QString("netctl-auto");
|
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 {
|
else {
|
||||||
// check netctl
|
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||||
command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
|
for (int i=0; i<profiles.count(); i++) {
|
||||||
command.waitForFinished(-1);
|
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
|
||||||
if (command.exitCode() == 0)
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
status = QString("enabled");
|
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;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Netctl::updateSourceEvent(const QString &source)
|
bool Netctl::updateSourceEvent(const QString &source)
|
||||||
{
|
{
|
||||||
QString key = QString("value");
|
if (debug) qDebug() << PDEBUG;
|
||||||
QString value = QString("");
|
if (debug) qDebug() << PDEBUG << ":" << "Source name" << source;
|
||||||
if (source == QString("currentProfile")) {
|
|
||||||
value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
|
QString value = QString("N\\A");
|
||||||
if (value.isEmpty())
|
if (source == QString("active")) {
|
||||||
value = getCurrentProfile(configuration[QString("CMD")]);
|
value = getStatus(configuration[QString("NETCTLCMD")],
|
||||||
}
|
|
||||||
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")],
|
|
||||||
configuration[QString("NETCTLAUTOCMD")]);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#define NETCTL_DE_H
|
#define NETCTL_DE_H
|
||||||
|
|
||||||
#include <Plasma/DataEngine>
|
#include <Plasma/DataEngine>
|
||||||
|
#include <QAbstractSocket>
|
||||||
|
|
||||||
|
|
||||||
class Netctl : public Plasma::DataEngine
|
class Netctl : public Plasma::DataEngine
|
||||||
@ -27,13 +28,15 @@ class Netctl : public Plasma::DataEngine
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Netctl(QObject *parent, const QVariantList &args);
|
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);
|
QString getExtIp(const QString cmd);
|
||||||
QStringList getInterfaceList(const QString dir);
|
QStringList getInterfaceList();
|
||||||
QString getIntIp(const QString cmd, const QString dir);
|
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||||
QStringList getProfileList(const QString cmd);
|
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
|
||||||
bool getProfileStatus(const QString cmd);
|
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||||
QString getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||||
|
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool sourceRequestEvent(const QString &name);
|
bool sourceRequestEvent(const QString &name);
|
||||||
@ -41,8 +44,10 @@ protected:
|
|||||||
QStringList sources() const;
|
QStringList sources() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isNetctlAutoRunning();
|
bool netctlAutoStatus;
|
||||||
|
QString currentProfile;
|
||||||
// configuration
|
// configuration
|
||||||
|
bool debug;
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||||
|
1
sources/dataengine/pdebug.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../3rdparty/pdebug/pdebug.h
|
1
sources/dataengine/task.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../3rdparty/task/task.h
|
1
sources/dataengine/taskadds.cpp
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../3rdparty/task/taskadds.cpp
|
1
sources/dataengine/taskadds.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../3rdparty/task/taskadds.h
|
@ -5,6 +5,7 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
|||||||
# set directories
|
# set directories
|
||||||
set (SUBPROJECT_BINARY_DIR bin)
|
set (SUBPROJECT_BINARY_DIR bin)
|
||||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
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_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
|
||||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
|
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
|
||||||
# executable path
|
# executable path
|
||||||
@ -15,6 +16,7 @@ set (TARGETS "")
|
|||||||
set (HEADERS "")
|
set (HEADERS "")
|
||||||
|
|
||||||
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||||
|
add_subdirectory (${SUBPROJECT_DOCS_DIR})
|
||||||
# build man
|
# build man
|
||||||
file (GLOB SUBPROJECT_MAN_IN *.1)
|
file (GLOB SUBPROJECT_MAN_IN *.1)
|
||||||
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
|
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 ${SUBPROJECT}.desktop DESTINATION share/applications/)
|
||||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
|
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})
|
||||||
|
114
sources/gui/bash-completions
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
###########################################################################
|
||||||
|
# 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'
|
||||||
|
'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 |
370
sources/gui/docs/netctl-gui-dbus-api.html
Normal file
@ -0,0 +1,370 @@
|
|||||||
|
<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;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<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>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#ctrl">Helper ctrl API</a></li>
|
||||||
|
<li><a href="#netctl">Helper netctl API</a></li>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#gui">GUI API</a></li>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#netctlgui">GUI netctlgui API</a></li>
|
||||||
|
</ul>
|
||||||
|
<li><a href="#links">External links</a></li>
|
||||||
|
</ol>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2><a href="#api" class="anchor" name="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" name="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" name="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 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" name="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" name="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" name="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" name="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>
|
||||||
|
|
||||||
|
<p align="center" style="font-size: 70%">
|
||||||
|
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||||
|
This software is licensed under @PROJECT_LICENSE@
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
95
sources/gui/docs/netctl-gui-security-notes.html
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
|
<title>netctl-gui secutiry notes</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
</style>
|
||||||
|
<h1>netctl-gui security notes</h1>
|
||||||
|
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||||
|
<ol>
|
||||||
|
<li><a href="#description">Description</a></li>
|
||||||
|
<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>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h2><a href="#description" class="anchor" name="description"></a>Description</h2>
|
||||||
|
<p></p>
|
||||||
|
|
||||||
|
<h2><a href="#arch" class="anchor" name="arch"></a>Architecture</h2>
|
||||||
|
<img src="architecture.png" alt="architecture" align="middle">
|
||||||
|
|
||||||
|
<h2><a href="#library" class="anchor" name="library"></a>Library</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>
|
||||||
|
<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>Netctl profiles module</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>WiFi module</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>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<h2><a href="#helper" class="anchor" name="helper"></a>Helper</h2>
|
||||||
|
<p>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>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>There are two binaries <code>netctgui-helper</code> and <code>netctlgui-helper-suid</code>. They are the same, but the second one has SUID bit, so it can be running by normal user without any password. Please note that <b>it is dangerous</b> and recommended way is to use systemd daemon. In this case you may not install <code>netctlgui-helper-suid</code> binary.</p>
|
||||||
|
|
||||||
|
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
|
||||||
|
|
||||||
|
<h2><a href="#gui" class="anchor" name="gui"></a>Graphical interface</h2>
|
||||||
|
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
|
||||||
|
|
||||||
|
<h2><a href="#kde" class="anchor" name="kde"></a>KDE components</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" name="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>
|
||||||
|
|
||||||
|
<p align="center" style="font-size: 70%">
|
||||||
|
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||||
|
This software is licensed under @PROJECT_LICENSE@
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</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
|
.SH NAME
|
||||||
netctl-gui is a graphical interface for netctl
|
netctl-gui is a graphical interface for netctl
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B netctl-gui
|
.B netctl-gui
|
||||||
[ --about ] [ --netctl-auto ] [ --settings ]
|
[ options ]
|
||||||
[ -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]
|
|
||||||
.SH DESCRIPTION
|
.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
|
.SH OPTIONS
|
||||||
.TP
|
.IP "--detached"
|
||||||
--about
|
run detached from console
|
||||||
|
.IP "--maximized"
|
||||||
|
run maximized
|
||||||
|
.IP "--minimized"
|
||||||
|
run to system tray if it is available
|
||||||
|
.IP "--about"
|
||||||
show about window
|
show about window
|
||||||
.TP
|
.IP "--netctl-auto"
|
||||||
--netctl-auto
|
|
||||||
show netctl-auto window
|
show netctl-auto window
|
||||||
.TP
|
.IP "--settings"
|
||||||
--settings
|
|
||||||
show settings window
|
show settings window
|
||||||
.TP
|
.IP "-e, --essid ESSID"
|
||||||
-e, --essid ESSID
|
select ESSID
|
||||||
select ESSID ESSID. This option will set tab to 3 automatically
|
.I ESSID
|
||||||
.TP
|
This option will set tab to 3 automatically
|
||||||
-o, --open PROFILE
|
.IP "-o, --open PROFILE"
|
||||||
open profile PROFILE. This option will set tab to 2 automatically
|
open profile
|
||||||
.TP
|
.I PROFILE
|
||||||
-s, --select PROFILE
|
This option will set tab to 2 automatically
|
||||||
select profile PROFILE. This option will set tab to 1 automatically
|
.IP "-s, --select PROFILE"
|
||||||
.TP
|
select profile
|
||||||
--config FILE
|
.I PROFILE
|
||||||
read configuration from file FILE
|
This option will set tab to 1 automatically
|
||||||
.TP
|
.IP "-c, --config FILE"
|
||||||
-d, --debug
|
read configuration from file
|
||||||
|
.I FILE
|
||||||
|
.IP "-d, --debug"
|
||||||
print debug information
|
print debug information
|
||||||
.TP
|
.IP "--default"
|
||||||
--default
|
|
||||||
start with default settings
|
start with default settings
|
||||||
.TP
|
.IP "--set-opts OPTIONS"
|
||||||
--set-opts OPTIONS
|
set options
|
||||||
set options OPTIONS for this run, comma separated. Example "LANGUAGE=en,NETCTL_PATH=/usr/bin/netctl"
|
.I OPTIONS
|
||||||
.TP
|
for this run, comma separated. Example:
|
||||||
-t, --tab NUM
|
.nf
|
||||||
open a tab with number NUM
|
LANGUAGE=en,NETCTL_PATH=/path/to/ponies
|
||||||
.TP
|
.fi
|
||||||
-v, --version
|
.IP "-t, --tab NUM"
|
||||||
|
open a tab with number
|
||||||
|
.I NUM
|
||||||
|
.IP "-v, --version"
|
||||||
show version and exit
|
show version and exit
|
||||||
.TP
|
.IP "-i, --info"
|
||||||
-i, --info
|
|
||||||
show build information and exit
|
show build information and exit
|
||||||
.TP
|
.IP "-h, --help"
|
||||||
-h, --help
|
|
||||||
show this help and exit
|
show this help and exit
|
||||||
.SH FILES
|
.SH FILES
|
||||||
.TP
|
.I $HOME/.config/netctl-gui.conf
|
||||||
$HOME/.config/netctl-gui.conf
|
.RS
|
||||||
Configuration file
|
Configuration file
|
||||||
|
.RE
|
||||||
|
.SH SEE ALSO
|
||||||
|
.BR netctlgui-helper (1)
|
||||||
|
.BR netctlgui-helper.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
|
.SH AUTHOR
|
||||||
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
|
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
|
||||||
.SH LICENSE
|
.SH LICENSE
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env xdg-open
|
#!/usr/bin/env xdg-open
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Name=Netctl GUI
|
Name=Netctl GUI
|
||||||
Comment=GUI written on Qt4 for netctl
|
Comment=Qt graphical user interface for netctl
|
||||||
Exec=netctl-gui
|
Exec=netctl-gui
|
||||||
Icon=netctl-gui.png
|
Icon=netctl-gui.png
|
||||||
Terminal=false
|
Terminal=false
|
||||||
|
@ -15,12 +15,10 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/includ
|
|||||||
link_directories (${PROJECT_LIBRARY}/src/lib)
|
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||||
|
|
||||||
if (USE_QT5)
|
if (USE_QT5)
|
||||||
find_package(Qt5Core REQUIRED)
|
find_package(Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
|
||||||
find_package(Qt5Widgets REQUIRED)
|
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
|
||||||
find_package(Qt5LinguistTools REQUIRED)
|
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||||
add_definitions(${Qt5Core_DEFINITIONS})
|
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||||
add_definitions(${Qt5Widgets_DEFINITIONS})
|
|
||||||
add_definitions(${Qt5LinguistTools_DEFINITIONS})
|
|
||||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||||
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
||||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
||||||
@ -34,17 +32,10 @@ if (USE_QT5)
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||||
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${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 ()
|
else ()
|
||||||
find_package (Qt4 REQUIRED)
|
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
|
||||||
include (${QT_USE_FILE})
|
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_cpp (MOC_SOURCES ${HEADERS})
|
||||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||||
@ -58,14 +49,9 @@ else ()
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||||
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${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()
|
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 properties
|
||||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||||
|
@ -6,80 +6,190 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>390</width>
|
<width>450</width>
|
||||||
<height>290</height>
|
<height>359</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item row="2" column="0">
|
<item>
|
||||||
<widget class="QLabel" name="label_description">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="text">
|
<property name="currentIndex">
|
||||||
<string/>
|
<number>0</number>
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
<property name="textInteractionFlags">
|
|
||||||
<set>Qt::TextBrowserInteraction</set>
|
|
||||||
</property>
|
</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item>
|
||||||
<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">
|
<widget class="QLabel" name="label_license">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@ -90,6 +200,9 @@
|
|||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="openExternalLinks">
|
<property name="openExternalLinks">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "pdebug.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
|
|||||||
|
|
||||||
AboutWindow::~AboutWindow()
|
AboutWindow::~AboutWindow()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
delete uiAbout;
|
delete uiAbout;
|
||||||
delete ui;
|
delete ui;
|
||||||
@ -47,45 +48,58 @@ AboutWindow::~AboutWindow()
|
|||||||
|
|
||||||
void AboutWindow::createText()
|
void AboutWindow::createText()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[AboutWindow]" << "[createText]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
// 1st tab
|
||||||
uiAbout->label_name->setText(QString(NAME));
|
uiAbout->label_name->setText(QString(NAME));
|
||||||
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
|
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
|
||||||
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
|
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
|
||||||
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
|
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
|
||||||
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
|
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(HOMEPAGE))
|
||||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(QApplication::translate("AboutWindow", "Repository")) +
|
.arg(QApplication::translate("AboutWindow", "Homepage")) +
|
||||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(QApplication::translate("AboutWindow", "Bugtracker")) +
|
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY))
|
||||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(QApplication::translate("AboutWindow", "Translation issue")) +\
|
.arg(QApplication::translate("AboutWindow", "Repository")) +
|
||||||
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES)).arg(QApplication::translate("AboutWindow", "AUR packages")));
|
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER))
|
||||||
uiAbout->label_license->setText(QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
|
.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)) +
|
QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) +
|
||||||
QString("</small>"));
|
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()
|
void AboutWindow::createUi()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[AboutWindow]" << "[createUi]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QWidget *aboutWidget = new QWidget();
|
QWidget *aboutWidget = new QWidget();
|
||||||
uiAbout = new Ui::About;
|
uiAbout = new Ui::About;
|
||||||
uiAbout->setupUi(aboutWidget);
|
uiAbout->setupUi(aboutWidget);
|
||||||
ui->verticalLayout->addWidget(aboutWidget);
|
ui->verticalLayout->insertWidget(0, aboutWidget);
|
||||||
createText();
|
createText();
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox;
|
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||||
buttonBox->addButton(QDialogButtonBox::Close);
|
|
||||||
ui->verticalLayout->addWidget(buttonBox);
|
|
||||||
connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ESC press event
|
// ESC press event
|
||||||
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
|
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (pressedKey->key() == Qt::Key_Escape)
|
if (pressedKey->key() == Qt::Key_Escape)
|
||||||
close();
|
close();
|
||||||
|
@ -6,15 +6,23 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>380</width>
|
<width>516</width>
|
||||||
<height>307</height>
|
<height>431</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>About</string>
|
<string>About</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<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>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<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.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 <QSpacerItem>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "pdebug.h"
|
||||||
|
|
||||||
|
|
||||||
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
||||||
: debug(debugCmd)
|
: debug(debugCmd)
|
||||||
@ -31,14 +33,15 @@ ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
|||||||
|
|
||||||
ErrorWindow::~ErrorWindow()
|
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() << PDEBUG;
|
||||||
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess;
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||||
|
|
||||||
QString message, title;
|
QString message, title;
|
||||||
switch(mess) {
|
switch(mess) {
|
||||||
@ -114,11 +117,17 @@ QStringList ErrorWindow::getMessage(const int mess)
|
|||||||
title = QApplication::translate("ErrorWindow", "Error!");
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
|
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
|
||||||
break;
|
break;
|
||||||
|
case 19:
|
||||||
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
|
message = QApplication::translate("ErrorWindow", "Could not run helper");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
title = QApplication::translate("ErrorWindow", "Error!");
|
title = QApplication::translate("ErrorWindow", "Error!");
|
||||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!custom.isEmpty())
|
||||||
|
message = custom;
|
||||||
|
|
||||||
QStringList fullMessage;
|
QStringList fullMessage;
|
||||||
fullMessage.append(title);
|
fullMessage.append(title);
|
||||||
@ -129,63 +138,30 @@ QStringList ErrorWindow::getMessage(const int mess)
|
|||||||
|
|
||||||
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]" << ":" << "Message" << mess;
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||||
|
|
||||||
QMessageBox::Icon icon;
|
QMessageBox::Icon icon;
|
||||||
switch(mess) {
|
switch(mess) {
|
||||||
case 1:
|
case 1:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 4:
|
case 4:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 5:
|
case 5:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 6:
|
case 6:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 7:
|
case 7:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 8:
|
case 8:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 9:
|
case 9:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 10:
|
case 10:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 11:
|
case 11:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 12:
|
case 12:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 13:
|
case 13:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 14:
|
case 14:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 15:
|
case 15:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 16:
|
case 16:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 17:
|
case 17:
|
||||||
icon = QMessageBox::Critical;
|
|
||||||
break;
|
|
||||||
case 18:
|
case 18:
|
||||||
|
case 19:
|
||||||
icon = QMessageBox::Critical;
|
icon = QMessageBox::Critical;
|
||||||
break;
|
break;
|
||||||
default:
|
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() << PDEBUG;
|
||||||
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess;
|
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||||
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender;
|
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||||
|
|
||||||
QStringList message = getMessage(mess);
|
QStringList message = getMessage(mess, custom);
|
||||||
QMessageBox messageBox;
|
QMessageBox messageBox;
|
||||||
messageBox.setText(message[0]);
|
messageBox.setText(message[0]);
|
||||||
messageBox.setInformativeText(message[1]);
|
messageBox.setInformativeText(message[1]);
|
||||||
|
@ -33,11 +33,12 @@ public:
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showWindow(const int mess = 0,
|
void showWindow(const int mess = 0,
|
||||||
const QString sender = QString());
|
const QString sender = QString(),
|
||||||
|
const QString custom = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug;
|
bool debug;
|
||||||
QStringList getMessage(const int mess);
|
QStringList getMessage(const int mess, const QString custom = QString());
|
||||||
QMessageBox::Icon getIcon(const int mess);
|
QMessageBox::Icon getIcon(const int mess);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,8 +88,7 @@ void EthernetWidget::showAdvanced()
|
|||||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||||
ui->widget_ethernetAdvanced->setHidden(false);
|
ui->widget_ethernetAdvanced->setHidden(false);
|
||||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->widget_ethernetAdvanced->setHidden(true);
|
ui->widget_ethernetAdvanced->setHidden(true);
|
||||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
|
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
|
||||||
}
|
}
|
||||||
|
@ -114,8 +114,7 @@ void GeneralWidget::showAdvanced()
|
|||||||
if (ui->pushButton_generalAdvanced->isChecked()) {
|
if (ui->pushButton_generalAdvanced->isChecked()) {
|
||||||
ui->widget_generalAdvanced->setHidden(false);
|
ui->widget_generalAdvanced->setHidden(false);
|
||||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->widget_generalAdvanced->setHidden(true);
|
ui->widget_generalAdvanced->setHidden(true);
|
||||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
|
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
|
||||||
}
|
}
|
||||||
@ -162,7 +161,9 @@ int GeneralWidget::isOk()
|
|||||||
// bind interfaces is not set
|
// bind interfaces is not set
|
||||||
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
|
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
|
||||||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
|
(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)
|
if (ui->listWidget_bindto->count() == 0)
|
||||||
return 1;
|
return 1;
|
||||||
// empty description
|
// empty description
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>429</width>
|
<width>425</width>
|
||||||
<height>535</height>
|
<height>531</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -123,6 +123,11 @@
|
|||||||
<string notr="true">macvlan</string>
|
<string notr="true">macvlan</string>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">openvswitch</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -315,8 +315,7 @@ void IpWidget::ipEnable(const int state)
|
|||||||
ui->comboBox_ip->setDisabled(true);
|
ui->comboBox_ip->setDisabled(true);
|
||||||
ui->widget_ip->setDisabled(true);
|
ui->widget_ip->setDisabled(true);
|
||||||
ui->widget_ipRoutes->setDisabled(true);
|
ui->widget_ipRoutes->setDisabled(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->comboBox_ip->setEnabled(true);
|
ui->comboBox_ip->setEnabled(true);
|
||||||
ui->widget_ip->setEnabled(true);
|
ui->widget_ip->setEnabled(true);
|
||||||
ui->widget_ipRoutes->setEnabled(true);
|
ui->widget_ipRoutes->setEnabled(true);
|
||||||
@ -341,8 +340,7 @@ void IpWidget::ip6Enable(const int state)
|
|||||||
ui->comboBox_ip6->setDisabled(true);
|
ui->comboBox_ip6->setDisabled(true);
|
||||||
ui->widget_ip6->setDisabled(true);
|
ui->widget_ip6->setDisabled(true);
|
||||||
ui->widget_ipRoutes6->setDisabled(true);
|
ui->widget_ipRoutes6->setDisabled(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->comboBox_ip6->setEnabled(true);
|
ui->comboBox_ip6->setEnabled(true);
|
||||||
ui->widget_ip6->setEnabled(true);
|
ui->widget_ip6->setEnabled(true);
|
||||||
ui->widget_ipRoutes6->setEnabled(true);
|
ui->widget_ipRoutes6->setEnabled(true);
|
||||||
@ -355,8 +353,7 @@ void IpWidget::changeDhcpClient(const QString currentText)
|
|||||||
if (currentText == QString("dhcpcd")) {
|
if (currentText == QString("dhcpcd")) {
|
||||||
ui->widget_dhcpcdOpt->setHidden(false);
|
ui->widget_dhcpcdOpt->setHidden(false);
|
||||||
ui->widget_dhclientOpt->setHidden(true);
|
ui->widget_dhclientOpt->setHidden(true);
|
||||||
}
|
} else if (currentText == QString("dhclient")) {
|
||||||
else if (currentText == QString("dhclient")) {
|
|
||||||
ui->widget_dhcpcdOpt->setHidden(true);
|
ui->widget_dhcpcdOpt->setHidden(true);
|
||||||
ui->widget_dhclientOpt->setHidden(false);
|
ui->widget_dhclientOpt->setHidden(false);
|
||||||
}
|
}
|
||||||
@ -368,8 +365,7 @@ void IpWidget::showAdvanced()
|
|||||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||||
ui->widget_ipAdvanced->setHidden(false);
|
ui->widget_ipAdvanced->setHidden(false);
|
||||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->widget_ipAdvanced->setHidden(true);
|
ui->widget_ipAdvanced->setHidden(true);
|
||||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
|
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("'"));
|
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
|
||||||
ipSettings[QString("Routes")] = routes.join(QChar(' '));
|
ipSettings[QString("Routes")] = routes.join(QChar(' '));
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
ipSettings[QString("IP")] = QString("no");
|
ipSettings[QString("IP")] = QString("no");
|
||||||
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
||||||
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
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("'"));
|
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
|
||||||
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
|
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
ipSettings[QString("IP6")] = QString("no");
|
ipSettings[QString("IP6")] = QString("no");
|
||||||
if (ui->listWidget_custom->count() > 0) {
|
if (ui->listWidget_custom->count() > 0) {
|
||||||
QStringList custom;
|
QStringList custom;
|
||||||
@ -433,8 +427,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
|||||||
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
|
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
|
||||||
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
|
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
|
||||||
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'");
|
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();
|
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||||
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
||||||
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
|
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
|
||||||
|
@ -60,26 +60,28 @@ QString Language::defineLanguage(const QString configPath, const QString options
|
|||||||
|
|
||||||
QString Language::defineLanguageFromFile(const QString configPath)
|
QString Language::defineLanguageFromFile(const QString configPath)
|
||||||
{
|
{
|
||||||
QString language;
|
QMap<QString, QString> settings;
|
||||||
if (configPath.isEmpty())
|
if (configPath.isEmpty())
|
||||||
return language;
|
return QString("");
|
||||||
QFile configFile(configPath);
|
QFile configFile(configPath);
|
||||||
QString fileStr;
|
QString fileStr;
|
||||||
if (!configFile.open(QIODevice::ReadOnly))
|
if (!configFile.open(QIODevice::ReadOnly))
|
||||||
return language;
|
return QString("");
|
||||||
while (true) {
|
while (true) {
|
||||||
fileStr = QString(configFile.readLine());
|
fileStr = QString(configFile.readLine()).trimmed();
|
||||||
if (fileStr[0] == QChar('#')) continue;
|
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||||
if (fileStr.contains(QString("LANGUAGE=")))
|
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||||
language = fileStr.split(QChar('='))[1]
|
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||||
.remove(QChar(' '))
|
if (fileStr.contains(QChar('=')))
|
||||||
.trimmed();
|
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
||||||
if (configFile.atEnd())
|
if (configFile.atEnd()) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
configFile.close();
|
configFile.close();
|
||||||
|
|
||||||
return language;
|
if (settings.contains(QString("LANGUAGE")))
|
||||||
|
return settings[QString("LANGUAGE")];
|
||||||
|
else
|
||||||
|
return QString("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,259 +17,177 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QLibraryInfo>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "messages.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
QChar isParametrEnable(const bool parametr)
|
bool existingSessionOperation(const QString operation)
|
||||||
{
|
{
|
||||||
if (parametr)
|
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||||
return QChar('*');
|
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
|
||||||
else
|
DBUS_INTERFACE, operation);
|
||||||
return QChar(' ');
|
QDBusMessage response = bus.call(request);
|
||||||
|
QList<QVariant> arguments = response.arguments();
|
||||||
|
|
||||||
|
return !arguments.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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[])
|
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
|
// detach from console
|
||||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
if (args[QString("detached")].toBool())
|
||||||
QDir::separator() + QString("netctl-gui.conf");
|
daemon(0, 0);
|
||||||
QString language = Language::defineLanguage(configPath);
|
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;
|
QTranslator translator;
|
||||||
translator.load(QString(":/translations/") + language);
|
translator.load(QString(":/translations/") + language);
|
||||||
a.installTranslator(&translator);
|
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
|
// running
|
||||||
if (error) {
|
if (args[QString("error")].toBool()) {
|
||||||
cout << errorMessage.toUtf8().data() << endl;
|
cout << errorMessage().toUtf8().data() << endl;
|
||||||
cout << helpMessage.toUtf8().data();
|
cout << helpMessage().toUtf8().data();
|
||||||
return 127;
|
return 127;
|
||||||
}
|
} else if (args[QString("help")].toBool()) {
|
||||||
if (showInfo) {
|
cout << helpMessage().toUtf8().data();
|
||||||
cout << versionMessage.toUtf8().data() << endl;
|
return 0;
|
||||||
cout << infoMessage.toUtf8().data();
|
} 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;
|
return 0;
|
||||||
}
|
}
|
||||||
if (showHelp) {
|
|
||||||
cout << helpMessage.toUtf8().data();
|
// check if exists
|
||||||
return 0;
|
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) {
|
MainWindow w(0, args, &qtTranslator, &translator);
|
||||||
cout << versionMessage.toUtf8().data();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
MainWindow w(0,
|
|
||||||
showAbout, showNetctlAuto, showSettings,
|
|
||||||
selectEssid, openProfile, selectProfile,
|
|
||||||
configPath, debug, defaultSettings, options, tabNumber);
|
|
||||||
w.show();
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
1157
sources/gui/src/mainprivateslots.cpp
Normal file
521
sources/gui/src/mainpublicslots.cpp
Normal file
@ -0,0 +1,521 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "aboutwindow.h"
|
||||||
|
#include "dbusoperation.h"
|
||||||
|
#include "errorwindow.h"
|
||||||
|
#include "language.h"
|
||||||
|
#include "netctlautowindow.h"
|
||||||
|
#include "passwdwidget.h"
|
||||||
|
#include "pdebug.h"
|
||||||
|
#include "settingswindow.h"
|
||||||
|
#include "taskadds.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();
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
}
|
@ -22,6 +22,8 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QTableWidgetItem>
|
#include <QTableWidgetItem>
|
||||||
|
|
||||||
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
|
||||||
class AboutWindow;
|
class AboutWindow;
|
||||||
class BridgeWidget;
|
class BridgeWidget;
|
||||||
@ -31,17 +33,15 @@ class GeneralWidget;
|
|||||||
class IpWidget;
|
class IpWidget;
|
||||||
class MacvlanWidget;
|
class MacvlanWidget;
|
||||||
class MobileWidget;
|
class MobileWidget;
|
||||||
class Netctl;
|
|
||||||
class NetctlAutoWindow;
|
class NetctlAutoWindow;
|
||||||
class NetctlProfile;
|
|
||||||
class PasswdWidget;
|
class PasswdWidget;
|
||||||
class PppoeWidget;
|
class PppoeWidget;
|
||||||
class SettingsWindow;
|
class SettingsWindow;
|
||||||
|
class TrayIcon;
|
||||||
class TunnelWidget;
|
class TunnelWidget;
|
||||||
class TuntapWidget;
|
class TuntapWidget;
|
||||||
class VlanWidget;
|
class VlanWidget;
|
||||||
class WirelessWidget;
|
class WirelessWidget;
|
||||||
class WpaSup;
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
@ -53,27 +53,51 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0,
|
explicit MainWindow(QWidget *parent = 0,
|
||||||
const bool showAbout = false,
|
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||||
const bool showNetctlAuto = false,
|
QTranslator *qtAppTranslator = 0,
|
||||||
const bool showSettings = false,
|
QTranslator *appTranslator = 0);
|
||||||
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);
|
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
QStringList printInformation();
|
||||||
|
QStringList printSettings();
|
||||||
|
QStringList printTrayInformation();
|
||||||
|
bool isHelperActive();
|
||||||
|
bool isHelperServiceActive();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
public slots:
|
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 updateTabs(const int tab);
|
||||||
void updateMenu(const int tab);
|
|
||||||
// wifi tab slots
|
// wifi tab slots
|
||||||
void connectToUnknownEssid(const QString passwd);
|
void connectToUnknownEssid(const QString passwd);
|
||||||
void setHiddenName(const QString name);
|
void setHiddenName(const QString name);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void reportABug();
|
||||||
// menu update slots
|
// menu update slots
|
||||||
void setMenuActionsShown(const bool state = true);
|
void setMenuActionsShown(const bool state = true);
|
||||||
void updateMenuMain();
|
void updateMenuMain();
|
||||||
@ -86,10 +110,13 @@ private slots:
|
|||||||
// main tab slots
|
// main tab slots
|
||||||
void mainTabContextualMenu(const QPoint &pos);
|
void mainTabContextualMenu(const QPoint &pos);
|
||||||
void mainTabEditProfile();
|
void mainTabEditProfile();
|
||||||
void mainTabRemoveProfile();
|
|
||||||
void mainTabEnableProfile();
|
void mainTabEnableProfile();
|
||||||
|
QStringList mainTabGetActiveProfiles();
|
||||||
|
void mainTabRemoveProfile();
|
||||||
void mainTabRestartProfile();
|
void mainTabRestartProfile();
|
||||||
void mainTabStartProfile();
|
void mainTabStartProfile();
|
||||||
|
void mainTabStopAllProfiles();
|
||||||
|
void mainTabSwitchToProfile();
|
||||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||||
// profile tab slots
|
// profile tab slots
|
||||||
void profileTabChangeState(const QString current);
|
void profileTabChangeState(const QString current);
|
||||||
@ -105,34 +132,42 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// ui
|
// ui
|
||||||
Ui::MainWindow *ui;
|
TrayIcon *trayIcon = nullptr;
|
||||||
AboutWindow *aboutWin;
|
Ui::MainWindow *ui = nullptr;
|
||||||
ErrorWindow *errorWin;
|
AboutWindow *aboutWin = nullptr;
|
||||||
NetctlAutoWindow *netctlAutoWin;
|
ErrorWindow *errorWin = nullptr;
|
||||||
PasswdWidget *passwdWid;
|
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||||
SettingsWindow *settingsWin;
|
PasswdWidget *passwdWid = nullptr;
|
||||||
BridgeWidget *bridgeWid;
|
SettingsWindow *settingsWin = nullptr;
|
||||||
EthernetWidget *ethernetWid;
|
BridgeWidget *bridgeWid = nullptr;
|
||||||
GeneralWidget *generalWid;
|
EthernetWidget *ethernetWid = nullptr;
|
||||||
IpWidget *ipWid;
|
GeneralWidget *generalWid = nullptr;
|
||||||
MacvlanWidget *macvlanWid;
|
IpWidget *ipWid = nullptr;
|
||||||
MobileWidget *mobileWid;
|
MacvlanWidget *macvlanWid = nullptr;
|
||||||
PppoeWidget *pppoeWid;
|
MobileWidget *mobileWid = nullptr;
|
||||||
TunnelWidget *tunnelWid;
|
PppoeWidget *pppoeWid = nullptr;
|
||||||
TuntapWidget *tuntapWid;
|
TunnelWidget *tunnelWid = nullptr;
|
||||||
VlanWidget *vlanWid;
|
TuntapWidget *tuntapWid = nullptr;
|
||||||
WirelessWidget *wirelessWid;
|
VlanWidget *vlanWid = nullptr;
|
||||||
|
WirelessWidget *wirelessWid = nullptr;
|
||||||
// backend
|
// backend
|
||||||
Netctl *netctlCommand;
|
Netctl *netctlCommand = nullptr;
|
||||||
NetctlProfile *netctlProfile;
|
NetctlProfile *netctlProfile = nullptr;
|
||||||
WpaSup *wpaCommand;
|
WpaSup *wpaCommand = nullptr;
|
||||||
bool checkExternalApps(const QString apps);
|
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 createActions();
|
||||||
|
void createDBusSession();
|
||||||
|
void createObjects();
|
||||||
|
void deleteObjects();
|
||||||
void keyPressEvent(QKeyEvent *pressedKey);
|
void keyPressEvent(QKeyEvent *pressedKey);
|
||||||
void setIconsToButtons();
|
QString configPath;
|
||||||
bool debug;
|
bool debug = false;
|
||||||
bool hiddenNetwork;
|
bool hiddenNetwork;
|
||||||
|
bool useHelper = true;
|
||||||
|
QTranslator *qtTranslator = nullptr;
|
||||||
|
QTranslator *translator = nullptr;
|
||||||
// configuration
|
// configuration
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
QMap<QString, QString> parseOptions(const QString options);
|
QMap<QString, QString> parseOptions(const QString options);
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>479</width>
|
<width>469</width>
|
||||||
<height>507</height>
|
<height>497</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -21,6 +21,10 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab_main">
|
<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">
|
<attribute name="title">
|
||||||
<string>Connect to profile</string>
|
<string>Connect to profile</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -68,6 +72,9 @@
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<attribute name="horizontalHeaderStretchLastSection">
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -90,14 +97,8 @@
|
|||||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
<column/>
|
||||||
<property name="text">
|
<column/>
|
||||||
<string>Status</string>
|
|
||||||
</property>
|
|
||||||
<property name="textAlignment">
|
|
||||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -107,6 +108,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Refresh</string>
|
<string>Refresh</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="stock-refresh">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+R</string>
|
<string>Ctrl+R</string>
|
||||||
</property>
|
</property>
|
||||||
@ -136,6 +142,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Restart</string>
|
<string>Restart</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="stock-refresh">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -149,6 +160,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start</string>
|
<string>Start</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="system-run">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -165,6 +181,11 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="icon">
|
||||||
|
<iconset theme="document-new">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</attribute>
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Create a new profile</string>
|
<string>Create a new profile</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -206,8 +227,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>96</width>
|
<width>437</width>
|
||||||
<height>26</height>
|
<height>338</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@ -227,6 +248,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Clear</string>
|
<string>Clear</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-clear">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -247,6 +273,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-save">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -254,6 +285,10 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_wifi">
|
<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">
|
<attribute name="title">
|
||||||
<string>Connect to Wi-Fi</string>
|
<string>Connect to Wi-Fi</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -285,6 +320,9 @@
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
<attribute name="horizontalHeaderStretchLastSection">
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -295,22 +333,28 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Name</string>
|
<string>Name</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
<property name="textAlignment">
|
||||||
<column>
|
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||||
<property name="text">
|
|
||||||
<string>Status</string>
|
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Signal</string>
|
<string>Signal</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="textAlignment">
|
||||||
|
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||||
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
<column>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Security</string>
|
<string>Security</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="textAlignment">
|
||||||
|
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||||
|
</property>
|
||||||
</column>
|
</column>
|
||||||
|
<column/>
|
||||||
|
<column/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -320,6 +364,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Refresh</string>
|
<string>Refresh</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="stock-refresh">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+R</string>
|
<string>Ctrl+R</string>
|
||||||
</property>
|
</property>
|
||||||
@ -349,6 +398,11 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Start</string>
|
<string>Start</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="system-run">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
<property name="autoDefault">
|
<property name="autoDefault">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -367,7 +421,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>479</width>
|
<width>469</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -388,8 +442,10 @@
|
|||||||
<addaction name="actionProfileClear"/>
|
<addaction name="actionProfileClear"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionMainStart"/>
|
<addaction name="actionMainStart"/>
|
||||||
|
<addaction name="actionMainSwitch"/>
|
||||||
<addaction name="actionMainRestart"/>
|
<addaction name="actionMainRestart"/>
|
||||||
<addaction name="actionMainEnable"/>
|
<addaction name="actionMainEnable"/>
|
||||||
|
<addaction name="actionMainStopAll"/>
|
||||||
<addaction name="actionProfileLoad"/>
|
<addaction name="actionProfileLoad"/>
|
||||||
<addaction name="actionProfileSave"/>
|
<addaction name="actionProfileSave"/>
|
||||||
<addaction name="actionWifiStart"/>
|
<addaction name="actionWifiStart"/>
|
||||||
@ -402,6 +458,11 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Help</string>
|
<string>Help</string>
|
||||||
</property>
|
</property>
|
||||||
|
<addaction name="actionSecurity"/>
|
||||||
|
<addaction name="actionApi"/>
|
||||||
|
<addaction name="actionLibrary"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionReport"/>
|
||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuMenu"/>
|
<addaction name="menuMenu"/>
|
||||||
@ -447,7 +508,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionMainStart">
|
<action name="actionMainStart">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="dialog-apply">
|
<iconset theme="system-run">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
@ -537,7 +598,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionWifiStart">
|
<action name="actionWifiStart">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="dialog-apply">
|
<iconset theme="system-run">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
@ -562,12 +623,60 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionAbout">
|
<action name="actionAbout">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="help-about"/>
|
<iconset theme="help-about">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>About</string>
|
<string>About</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionReport">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="tools-report-bug">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Report a bug</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionApi">
|
||||||
|
<property name="text">
|
||||||
|
<string>DBus API reference</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionSecurity">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="security-medium">
|
||||||
|
<normaloff/>
|
||||||
|
</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Security notes</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionLibrary">
|
||||||
|
<property name="text">
|
||||||
|
<string>Library documentation</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainSwitch">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="system-run"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Switch to profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionMainStopAll">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="process-stop"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop all profiles</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
@ -582,6 +691,8 @@
|
|||||||
<tabstop>pushButton_wifiRefresh</tabstop>
|
<tabstop>pushButton_wifiRefresh</tabstop>
|
||||||
<tabstop>pushButton_wifiStart</tabstop>
|
<tabstop>pushButton_wifiStart</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../resources/resources.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
166
sources/gui/src/messages.cpp
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 += QCoreApplication::translate("MainWindow", "Build date: %1").
|
||||||
|
arg(QString(BUILD_DATE));
|
||||||
|
infoMessage += QString("\n%1:\n").arg(QCoreApplication::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));
|
||||||
|
// transport information
|
||||||
|
infoMessage += QString("%1:\n").arg(QCoreApplication::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(QCoreApplication::translate("MainWindow", "Documentation"));
|
||||||
|
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
|
||||||
|
QStringList docs = QDir(QString(DOCS_PATH)).entryList(QDir::NoDotAndDotDot);
|
||||||
|
for (int i=0; i<docs.count(); i++)
|
||||||
|
infoMessage += QString("\t%1\n").arg(docs[i]);
|
||||||
|
|
||||||
|
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()) {
|
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||||
ui->widget_mobileAdvanced->setHidden(false);
|
ui->widget_mobileAdvanced->setHidden(false);
|
||||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->widget_mobileAdvanced->setHidden(true);
|
ui->widget_mobileAdvanced->setHidden(true);
|
||||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
|
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <netctlgui/netctlinteract.h>
|
#include <netctlgui/netctlgui.h>
|
||||||
|
|
||||||
|
#include "dbusoperation.h"
|
||||||
|
#include "pdebug.h"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
|
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),
|
ui(new Ui::NetctlAutoWindow),
|
||||||
debug(debugCmd)
|
debug(debugCmd)
|
||||||
{
|
{
|
||||||
|
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||||
|
useHelper = true;
|
||||||
|
else
|
||||||
|
useHelper = false;
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
ui->tableWidget->setColumnHidden(2, true);
|
||||||
|
ui->tableWidget->setColumnHidden(3, true);
|
||||||
netctlCommand = new Netctl(debug, settings);
|
netctlCommand = new Netctl(debug, settings);
|
||||||
|
|
||||||
createActions();
|
createActions();
|
||||||
@ -38,16 +48,31 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
|
|||||||
|
|
||||||
NetctlAutoWindow::~NetctlAutoWindow()
|
NetctlAutoWindow::~NetctlAutoWindow()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[~NetctlAutoWindow]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
delete netctlCommand;
|
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()
|
void NetctlAutoWindow::createActions()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
// menu actions
|
// menu actions
|
||||||
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
|
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||||
@ -75,7 +100,7 @@ void NetctlAutoWindow::createActions()
|
|||||||
|
|
||||||
void NetctlAutoWindow::showWindow()
|
void NetctlAutoWindow::showWindow()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
netctlAutoUpdateTable();
|
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);
|
if (ui->tableWidget->currentItem() == 0)
|
||||||
QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto();
|
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
|
// 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"));
|
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
||||||
else
|
else
|
||||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
|
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
|
||||||
ui->actionEnableService->setVisible(true);
|
ui->actionEnableService->setVisible(true);
|
||||||
if (netctlCommand->isNetctlAutoRunning()) {
|
if (running) {
|
||||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
|
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
|
||||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
|
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
|
||||||
|
ui->actionDisableAll->setVisible(true);
|
||||||
|
ui->actionEnableAll->setVisible(true);
|
||||||
ui->actionRestartService->setVisible(true);
|
ui->actionRestartService->setVisible(true);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
|
|
||||||
ui->actionRestartService->setVisible(false);
|
|
||||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
|
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);
|
netctlAutoRefreshButtons(0, 0);
|
||||||
return;
|
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->setSortingEnabled(false);
|
||||||
ui->tableWidget->selectRow(-1);
|
ui->tableWidget->selectRow(-1);
|
||||||
@ -124,45 +221,43 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
|||||||
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
||||||
// create items
|
// create items
|
||||||
for (int i=0; i<profiles.count(); i++) {
|
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
|
// 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);
|
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
if (profiles[i][2] == QString("*")) {
|
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
|
||||||
QFont font;
|
ui->tableWidget->item(i, 0)->setFont(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);
|
|
||||||
}
|
|
||||||
// description
|
// description
|
||||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
|
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
|
||||||
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||||
if (profiles[i][2] == QString("*")) {
|
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
|
||||||
// active
|
// active
|
||||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
|
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
|
||||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
}
|
// enabled
|
||||||
else
|
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
|
||||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString("")));
|
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||||
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->setSortingEnabled(true);
|
ui->tableWidget->setSortingEnabled(true);
|
||||||
|
|
||||||
|
ui->tableWidget->resizeRowsToContents();
|
||||||
|
ui->tableWidget->resizeColumnsToContents();
|
||||||
ui->tableWidget->resizeRowsToContents();
|
ui->tableWidget->resizeRowsToContents();
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
#else
|
#else
|
||||||
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ui->tableWidget->setEnabled(true);
|
ui->tableWidget->setEnabled(true);
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
|
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()
|
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ui->tableWidget->setDisabled(true);
|
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -243,13 +289,22 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
|||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoEnableProfile()
|
void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == 0)
|
if (ui->tableWidget->currentItem() == 0)
|
||||||
return;
|
return;
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||||
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -260,10 +315,17 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
|
|||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ui->tableWidget->setDisabled(true);
|
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -274,13 +336,22 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
|||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoStartProfile()
|
void NetctlAutoWindow::netctlAutoStartProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartProfile]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (ui->tableWidget->currentItem() == 0)
|
if (ui->tableWidget->currentItem() == 0)
|
||||||
return;
|
return;
|
||||||
ui->tableWidget->setDisabled(true);
|
ui->tableWidget->setDisabled(true);
|
||||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||||
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -291,9 +362,16 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
|||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoEnableService()
|
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -304,9 +382,16 @@ void NetctlAutoWindow::netctlAutoEnableService()
|
|||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoRestartService()
|
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -317,9 +402,16 @@ void NetctlAutoWindow::netctlAutoRestartService()
|
|||||||
|
|
||||||
void NetctlAutoWindow::netctlAutoStartService()
|
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"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||||
else
|
else
|
||||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||||
@ -331,7 +423,7 @@ void NetctlAutoWindow::netctlAutoStartService()
|
|||||||
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous);
|
Q_UNUSED(previous);
|
||||||
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRefreshButtons]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (current == 0) {
|
if (current == 0) {
|
||||||
// buttons
|
// buttons
|
||||||
@ -342,30 +434,28 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
|||||||
ui->actionSwitch->setVisible(false);
|
ui->actionSwitch->setVisible(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ui->tableWidget->item(current->row(), 2)->text() == QString("yes")) {
|
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setDisabled(true);
|
ui->pushButton_enable->setDisabled(true);
|
||||||
ui->pushButton_switch->setDisabled(true);
|
ui->pushButton_switch->setDisabled(true);
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setVisible(false);
|
ui->actionEnable->setVisible(false);
|
||||||
ui->actionSwitch->setVisible(false);
|
ui->actionSwitch->setVisible(false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setEnabled(true);
|
ui->pushButton_enable->setEnabled(true);
|
||||||
ui->pushButton_switch->setEnabled(true);
|
ui->pushButton_switch->setEnabled(true);
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setVisible(true);
|
ui->actionEnable->setVisible(true);
|
||||||
ui->actionSwitch->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
|
// buttons
|
||||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
|
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
|
||||||
// menu
|
// menu
|
||||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// buttons
|
// buttons
|
||||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
|
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||||
|
@ -58,9 +58,11 @@ private slots:
|
|||||||
void netctlAutoStartService();
|
void netctlAutoStartService();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Netctl *netctlCommand;
|
Netctl *netctlCommand = nullptr;
|
||||||
Ui::NetctlAutoWindow *ui;
|
Ui::NetctlAutoWindow *ui = nullptr;
|
||||||
bool debug;
|
bool debug = false;
|
||||||
|
bool useHelper = true;
|
||||||
|
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||||
void createActions();
|
void createActions();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>428</width>
|
||||||
<height>343</height>
|
<height>339</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -42,6 +42,9 @@
|
|||||||
<property name="sortingEnabled">
|
<property name="sortingEnabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="columnCount">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<attribute name="horizontalHeaderStretchLastSection">
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
@ -58,16 +61,8 @@
|
|||||||
<string>Description</string>
|
<string>Description</string>
|
||||||
</property>
|
</property>
|
||||||
</column>
|
</column>
|
||||||
<column>
|
<column/>
|
||||||
<property name="text">
|
<column/>
|
||||||
<string>Active</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
<column>
|
|
||||||
<property name="text">
|
|
||||||
<string>Disabled</string>
|
|
||||||
</property>
|
|
||||||
</column>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -105,6 +100,9 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Enable</string>
|
<string>Enable</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-add"/>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -116,7 +114,7 @@
|
|||||||
<string>Switch</string>
|
<string>Switch</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="dialog-apply">
|
<iconset theme="system-run">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
@ -131,7 +129,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>432</width>
|
<width>428</width>
|
||||||
<height>22</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -168,7 +166,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action name="actionSwitch">
|
<action name="actionSwitch">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset theme="dialog-apply">
|
<iconset theme="system-run">
|
||||||
<normaloff/>
|
<normaloff/>
|
||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</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) {
|
if (mode) {
|
||||||
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
||||||
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
|
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
||||||
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
|
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
|
||||||
}
|
}
|
||||||
|
1
sources/gui/src/pdebug.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../3rdparty/pdebug/pdebug.h
|
@ -117,8 +117,7 @@ void PppoeWidget::showAdvanced()
|
|||||||
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
||||||
ui->widget_pppoeAdvanced->setHidden(false);
|
ui->widget_pppoeAdvanced->setHidden(false);
|
||||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->widget_pppoeAdvanced->setHidden(true);
|
ui->widget_pppoeAdvanced->setHidden(true);
|
||||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
|
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "pdebug.h"
|
||||||
|
|
||||||
|
|
||||||
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
|
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
|
||||||
@ -40,7 +42,7 @@ SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QStri
|
|||||||
|
|
||||||
SettingsWindow::~SettingsWindow()
|
SettingsWindow::~SettingsWindow()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
@ -48,33 +50,34 @@ SettingsWindow::~SettingsWindow()
|
|||||||
|
|
||||||
void SettingsWindow::createActions()
|
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::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(closeWindow()));
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(restoreSettings()));
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
|
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||||
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
|
||||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||||
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
||||||
// buttons
|
// buttons
|
||||||
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
|
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
|
connect(ui->pushButton_interfacesDir, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), SLOT(selectNetctlAutoPath()));
|
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
|
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
|
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
|
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath()));
|
connect(ui->pushButton_status, SIGNAL(clicked(bool)), this, SLOT(startHelper()));
|
||||||
connect(ui->pushButton_wpaActiondPath, SIGNAL(clicked(bool)), SLOT(selectWpaActiondPath()));
|
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
|
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
|
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
|
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ESC press event
|
// ESC press event
|
||||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
if (pressedKey->key() == Qt::Key_Escape)
|
if (pressedKey->key() == Qt::Key_Escape)
|
||||||
close();
|
close();
|
||||||
@ -83,7 +86,7 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
|||||||
|
|
||||||
void SettingsWindow::addLanguages()
|
void SettingsWindow::addLanguages()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
ui->comboBox_language->clear();
|
ui->comboBox_language->clear();
|
||||||
ui->comboBox_language->addItems(Language::getAvailableLanguages());
|
ui->comboBox_language->addItems(Language::getAvailableLanguages());
|
||||||
@ -93,7 +96,7 @@ void SettingsWindow::addLanguages()
|
|||||||
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||||
{
|
{
|
||||||
Q_UNUSED(previous)
|
Q_UNUSED(previous)
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[changePage]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
|
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
|
||||||
if (current == ui->treeWidget->topLevelItem(i)) {
|
if (current == ui->treeWidget->topLevelItem(i)) {
|
||||||
@ -103,9 +106,19 @@ void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previ
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SettingsWindow::closeWindow()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
|
saveSettings();
|
||||||
|
close();
|
||||||
|
((MainWindow *)parent())->updateConfiguration();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsWindow::saveSettings()
|
void SettingsWindow::saveSettings()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QMap<QString, QString> settings = readSettings();
|
QMap<QString, QString> settings = readSettings();
|
||||||
QFile configFile(file);
|
QFile configFile(file);
|
||||||
@ -118,158 +131,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()
|
void SettingsWindow::setDefault()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
setSettings(getDefault());
|
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(
|
bool isDir = false;
|
||||||
this,
|
QString path = QString("/usr/bin");
|
||||||
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
|
QString text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||||
QString("/sys/"));
|
QLineEdit *lineEdit = ui->lineEdit_helperPath;
|
||||||
if (!directory.isEmpty())
|
if (sender() == ui->pushButton_helperPath) {
|
||||||
ui->lineEdit_interfacesDir->setText(directory);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString filename;
|
||||||
void SettingsWindow::selectNetctlPath()
|
if (isDir)
|
||||||
{
|
filename = QFileDialog::getExistingDirectory(this, text, path);
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlPath]";
|
else
|
||||||
|
filename = QFileDialog::getOpenFileName(this, text, path,
|
||||||
QString filename = QFileDialog::getOpenFileName(
|
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||||
this,
|
|
||||||
QApplication::translate("SettingsWindow", "Select netctl command"),
|
|
||||||
QString("/usr/bin/"),
|
|
||||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
|
||||||
if (!filename.isEmpty())
|
if (!filename.isEmpty())
|
||||||
ui->lineEdit_netctlPath->setText(filename);
|
lineEdit->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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SettingsWindow::showWindow()
|
void SettingsWindow::showWindow()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
setSettings(getSettings());
|
setSettings(getSettings());
|
||||||
ui->label_info->hide();
|
setTray();
|
||||||
|
updateHelper();
|
||||||
|
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
@ -277,11 +234,25 @@ void SettingsWindow::showWindow()
|
|||||||
|
|
||||||
QMap<QString, QString> SettingsWindow::readSettings()
|
QMap<QString, QString> SettingsWindow::readSettings()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
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_DIR")] = ui->lineEdit_wpaDir->text();
|
||||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->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("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||||
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||||
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||||
@ -291,15 +262,25 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
|||||||
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||||
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||||
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||||
|
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("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||||
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->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("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||||
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||||
for (int i=0; i<settings.keys().count(); i++)
|
for (int i=0; i<settings.keys().count(); i++)
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
|
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
@ -307,10 +288,24 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
|||||||
|
|
||||||
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
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_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
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->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||||
ui->comboBox_language->setCurrentIndex(0);
|
ui->comboBox_language->setCurrentIndex(0);
|
||||||
for (int i=0; i<ui->comboBox_language->count(); i++)
|
for (int i=0; i<ui->comboBox_language->count(); i++)
|
||||||
@ -323,25 +318,40 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
|||||||
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
||||||
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
||||||
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
||||||
|
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_sudo->setText(settings[QString("SUDO_PATH")]);
|
||||||
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_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_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
||||||
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
||||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||||
for (int i=0; i<settings.keys().count(); i++)
|
for (int i=0; i<settings.keys().count(); i++)
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
|
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QMap<QString, QString> SettingsWindow::getDefault()
|
QMap<QString, QString> SettingsWindow::getDefault()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QMap<QString, QString> settings;
|
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_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||||
settings[QString("CTRL_GROUP")] = QString("users");
|
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("IFACE_DIR")] = QString("/sys/class/net/");
|
||||||
settings[QString("LANGUAGE")] = QString("en");
|
settings[QString("LANGUAGE")] = QString("en");
|
||||||
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
||||||
@ -351,15 +361,16 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
|||||||
settings[QString("PREFERED_IFACE")] = QString("");
|
settings[QString("PREFERED_IFACE")] = QString("");
|
||||||
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
||||||
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
||||||
|
settings[QString("STARTTOTRAY")] = QString("false");
|
||||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
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("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||||
for (int i=0; i<settings.keys().count(); i++)
|
for (int i=0; i<settings.keys().count(); i++)
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
|
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
@ -367,7 +378,7 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
|||||||
|
|
||||||
QMap<QString, QString> SettingsWindow::getSettings()
|
QMap<QString, QString> SettingsWindow::getSettings()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QMap<QString, QString> settings = getDefault();
|
QMap<QString, QString> settings = getDefault();
|
||||||
QFile configFile(file);
|
QFile configFile(file);
|
||||||
@ -376,17 +387,48 @@ QMap<QString, QString> SettingsWindow::getSettings()
|
|||||||
return settings;
|
return settings;
|
||||||
while (true) {
|
while (true) {
|
||||||
fileStr = QString(configFile.readLine()).trimmed();
|
fileStr = QString(configFile.readLine()).trimmed();
|
||||||
if (fileStr[0] == QChar('#')) continue;
|
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||||
if (fileStr[0] == QChar(';')) continue;
|
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||||
if (!fileStr.contains(QChar('='))) continue;
|
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||||
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
if (fileStr.contains(QChar('=')))
|
||||||
if (configFile.atEnd())
|
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
||||||
break;
|
if (configFile.atEnd()) break;
|
||||||
}
|
}
|
||||||
configFile.close();
|
configFile.close();
|
||||||
for (int i=0; i<settings.keys().count(); i++)
|
for (int i=0; i<settings.keys().count(); i++)
|
||||||
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
|
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
|
||||||
|
|
||||||
return settings;
|
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();
|
QMap<QString, QString> getSettings();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void closeWindow();
|
||||||
|
void restoreSettings();
|
||||||
void setDefault();
|
void setDefault();
|
||||||
void showWindow();
|
void showWindow();
|
||||||
|
|
||||||
@ -49,17 +51,11 @@ private slots:
|
|||||||
void addLanguages();
|
void addLanguages();
|
||||||
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
void setTray();
|
||||||
|
void updateHelper();
|
||||||
// buttons
|
// buttons
|
||||||
void selectIfaceDir();
|
void selectAbstractSomething();
|
||||||
void selectNetctlPath();
|
void startHelper();
|
||||||
void selectNetctlAutoPath();
|
|
||||||
void selectProfileDir();
|
|
||||||
void selectRfkillDir();
|
|
||||||
void selectSudoPath();
|
|
||||||
void selectSystemctlPath();
|
|
||||||
void selectWpaActiondPath();
|
|
||||||
void selectWpaCliPath();
|
|
||||||
void selectWpaSupPath();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug;
|
bool debug;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>670</width>
|
<width>680</width>
|
||||||
<height>331</height>
|
<height>397</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -67,6 +67,15 @@
|
|||||||
</iconset>
|
</iconset>
|
||||||
</property>
|
</property>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>Helper</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../resources/resources.qrc">
|
||||||
|
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>netctl</string>
|
<string>netctl</string>
|
||||||
@ -127,8 +136,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>464</width>
|
||||||
<height>270</height>
|
<height>336</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
@ -151,12 +160,23 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_info">
|
<widget class="QCheckBox" name="checkBox_enableTray">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>You will need to restart the application</string>
|
<string>Enable system tray</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
</widget>
|
||||||
<set>Qt::AlignCenter</set>
|
</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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -179,6 +199,183 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</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>397</width>
|
||||||
|
<height>322</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>
|
||||||
|
<widget class="QLabel" name="label_helperPathInfo">
|
||||||
|
<property name="text">
|
||||||
|
<string>There are too binaries. `netctlgui-helper` should be running as root (for example from systemd), otherwise interface `/ctrl` will not be available. `netctlgui-helper-suid` may be running as normal user, but you should keep it in mind that it has SUID bit.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</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">
|
<widget class="QWidget" name="page_netctl">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
@ -194,8 +391,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>436</width>
|
||||||
<height>270</height>
|
<height>165</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
@ -381,8 +578,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>436</width>
|
||||||
<height>270</height>
|
<height>43</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
@ -451,8 +648,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>277</width>
|
||||||
<height>270</height>
|
<height>190</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||||
@ -518,37 +715,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_pid">
|
<layout class="QHBoxLayout" name="layout_pid">
|
||||||
<item>
|
<item>
|
||||||
@ -679,8 +845,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>454</width>
|
<width>436</width>
|
||||||
<height>270</height>
|
<height>103</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_11">
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
@ -707,7 +873,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton_interfaceDir">
|
<widget class="QPushButton" name="pushButton_interfacesDir">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Browse</string>
|
<string>Browse</string>
|
||||||
</property>
|
</property>
|
||||||
@ -796,7 +962,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
1
sources/gui/src/task.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../3rdparty/task/task.h
|
1
sources/gui/src/taskadds.cpp
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../3rdparty/task/taskadds.cpp
|
1
sources/gui/src/taskadds.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../3rdparty/task/taskadds.h
|
319
sources/gui/src/trayicon.cpp
Normal file
@ -0,0 +1,319 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 "mainwindow.h"
|
||||||
|
#include "pdebug.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"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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")]);
|
||||||
|
|
||||||
|
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();
|
||||||
|
setContextMenu(menuActions);
|
||||||
|
|
||||||
|
connect(this, SIGNAL(messageClicked()), this, SLOT(showInformationInWindow()));
|
||||||
|
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:
|
||||||
|
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->comboBox_drivers->setCurrentIndex(0);
|
||||||
ui->listWidget_drivers->setCurrentRow(-1);
|
ui->listWidget_drivers->setCurrentRow(-1);
|
||||||
ui->listWidget_drivers->clear();
|
ui->listWidget_drivers->clear();
|
||||||
|
ui->comboBox_rfkill->clear();
|
||||||
ui->comboBox_rfkill->addItem(QString("auto"));
|
ui->comboBox_rfkill->addItem(QString("auto"));
|
||||||
if (rfkillDirectory->exists()) {
|
if (rfkillDirectory->exists()) {
|
||||||
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
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_wpaConfigSection->setHidden(true);
|
||||||
ui->widget_wpaConfig->setHidden(true);
|
ui->widget_wpaConfig->setHidden(true);
|
||||||
ui->widget_key->setHidden(true);
|
ui->widget_key->setHidden(true);
|
||||||
}
|
} else if ((currentText == QString("wep")) ||
|
||||||
else if ((currentText == QString("wep")) ||
|
|
||||||
(currentText == QString("wpa"))) {
|
(currentText == QString("wpa"))) {
|
||||||
ui->widget_essid->setHidden(false);
|
ui->widget_essid->setHidden(false);
|
||||||
ui->widget_wpaConfigSection->setHidden(true);
|
ui->widget_wpaConfigSection->setHidden(true);
|
||||||
ui->widget_wpaConfig->setHidden(true);
|
ui->widget_wpaConfig->setHidden(true);
|
||||||
ui->widget_key->setHidden(false);
|
ui->widget_key->setHidden(false);
|
||||||
}
|
} else if (currentText == QString("wpa-configsection")) {
|
||||||
else if (currentText == QString("wpa-configsection")) {
|
|
||||||
ui->widget_essid->setHidden(true);
|
ui->widget_essid->setHidden(true);
|
||||||
ui->widget_wpaConfigSection->setHidden(false);
|
ui->widget_wpaConfigSection->setHidden(false);
|
||||||
ui->widget_wpaConfig->setHidden(true);
|
ui->widget_wpaConfig->setHidden(true);
|
||||||
ui->widget_key->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_essid->setHidden(true);
|
||||||
ui->widget_wpaConfigSection->setHidden(true);
|
ui->widget_wpaConfigSection->setHidden(true);
|
||||||
ui->widget_wpaConfig->setHidden(false);
|
ui->widget_wpaConfig->setHidden(false);
|
||||||
@ -198,8 +196,7 @@ void WirelessWidget::showAdvanced()
|
|||||||
if (ui->pushButton_wirelessAdvanced->isChecked()) {
|
if (ui->pushButton_wirelessAdvanced->isChecked()) {
|
||||||
ui->widget_wirelessAdvanced->setHidden(false);
|
ui->widget_wirelessAdvanced->setHidden(false);
|
||||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
|
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ui->widget_wirelessAdvanced->setHidden(true);
|
ui->widget_wirelessAdvanced->setHidden(true);
|
||||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
|
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();
|
wirelessSettings[QString("Key")] = ui->lineEdit_key->text();
|
||||||
else
|
else
|
||||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
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("'");
|
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||||
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
|
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
|
||||||
QStringList section;
|
QStringList section;
|
||||||
|
104
sources/gui/zsh-completions
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#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'
|
||||||
|
'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 netctlgui-helper.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})
|
52
sources/helper/bash-completions
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
###########################################################################
|
||||||
|
# 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'
|
||||||
|
'--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
|
79
sources/helper/netctlgui-helper.1
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
.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 "--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/netctlgui-helper.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 netctlgui-helper.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@
|
60
sources/helper/netctlgui-helper.conf
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# Configuration file for Netctl GUI project
|
||||||
|
# /etc/netctlgui-helper.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/
|
||||||
|
# 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
|
104
sources/helper/netctlgui-helper.conf.5
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
.TH netctlgui-helper.conf 5 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "File Formats Manual"
|
||||||
|
.SH NAME
|
||||||
|
netctlgui-helper.conf is a configuration file of Netctl GUI project
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B /etc/netctlgui-helper.conf
|
||||||
|
for system-wide configuration or
|
||||||
|
.B $HOME/.config/netctl-gui.conf
|
||||||
|
for user one
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B netctlgui-helper.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 "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)
|
9
sources/helper/netctlgui-helper.service
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=netctlgui-helper daemon
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
ExecStart=/usr/bin/netctlgui-helper --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>
|
58
sources/helper/src/CMakeLists.txt
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# set files
|
||||||
|
file (GLOB SOURCES *.cpp)
|
||||||
|
file (GLOB HEADERS *.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})
|
||||||
|
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-header COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
|
||||||
|
add_custom_command (TARGET translations-header 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})
|
||||||
|
add_executable (${SUBPROJECT}-suid ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||||
|
target_link_libraries (${SUBPROJECT}-suid ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||||
|
# install properties
|
||||||
|
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||||
|
install (TARGETS ${SUBPROJECT}-suid DESTINATION bin
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)
|
257
sources/helper/src/controladaptor.cpp
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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::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;
|
||||||
|
}
|
80
sources/helper/src/controladaptor.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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 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 */
|
1
sources/helper/src/language.cpp
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../gui/src/language.cpp
|
1
sources/helper/src/language.h
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../gui/src/language.h
|
159
sources/helper/src/main.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 <QCoreApplication>
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusMessage>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QLibraryInfo>
|
||||||
|
#include <QTranslator>
|
||||||
|
#include <iostream>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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("--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 will not be available.")
|
||||||
|
.arg(QString::number(geteuid())).toUtf8().data() << endl;
|
||||||
|
cout << QCoreApplication::translate("NetctlHelper", "See security notes for more details.")
|
||||||
|
.toUtf8().data() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#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();
|
||||||
|
}
|
132
sources/helper/src/messages.cpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* 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("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(" --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));
|
||||||
|
infoMessage += QString("\n%1:\n").arg(QCoreApplication::translate("NetctlHelper", "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));
|
||||||
|
// 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));
|
||||||
|
QStringList docs = QDir(QString(DOCS_PATH)).entryList(QDir::NoDotAndDotDot);
|
||||||
|
for (int i=0; i<docs.count(); i++)
|
||||||
|
infoMessage += QString("\t%1\n").arg(docs[i]);
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|