Compare commits
203 Commits
V.1.0.3
...
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 | |||
bb7af8da40 | |||
81ff9340cc | |||
3d040e9bab | |||
3542901781 | |||
8b91f43f0b | |||
7e622ad33b | |||
48a879bd71 | |||
bc8655aaeb | |||
05f9759d47 | |||
51659c7a42 | |||
39b8ff834f | |||
ea522b3864 | |||
79fc70efa1 | |||
5e1a4be134 | |||
63ae04cd8d | |||
4fb02058b1 | |||
e02a6a8ce1 | |||
2f40ae7913 | |||
2e35cd356e | |||
341a19a955 | |||
f7e39c7834 | |||
7660deb787 | |||
3fb847a7b6 | |||
dbb9ba70c4 | |||
ceb7f3bd0f | |||
8ce4b03399 | |||
44f0b6a06a | |||
b37272d875 | |||
ea91aa4ca4 | |||
cc250a643a | |||
9b01fcd4e1 | |||
021a870220 | |||
ae001b4d7f | |||
ec6834d90e | |||
de22663156 | |||
c3f090d9a0 | |||
d17543a075 | |||
ace3a141e4 | |||
06bd1ce198 | |||
9852fb8f68 | |||
eccb6b6578 | |||
c1457d3ef0 | |||
6dab355d87 | |||
e81f7714f9 | |||
2a3011bdef | |||
bf799ce061 | |||
a845e32960 | |||
028546540c | |||
2bf1d0f78e | |||
cce4ef4811 | |||
4051d2f2c8 | |||
8a031f2183 | |||
7c013310ab | |||
d5f0bbc3bf | |||
cb033140ac | |||
d582445597 | |||
3506bd46a9 | |||
727619bb85 | |||
d59345c0e4 | |||
4c1685164c | |||
d515e4a51f | |||
2778f654ef | |||
92ec04cae1 | |||
501151828d | |||
4a788aa05f | |||
2cf91930f8 | |||
4bb5d4925d | |||
10d44f786e | |||
c69ff2165e | |||
4d455d93e8 | |||
046ae119a3 | |||
b958d0b78b | |||
7529cd7af0 | |||
7e85f1f933 | |||
c4c407542f | |||
cc2b3faf85 | |||
b983f4424e | |||
72782a40c2 |
4
.gitignore
vendored
@ -14,11 +14,13 @@
|
||||
|
||||
# Source archive
|
||||
*.tar.xz
|
||||
*.tar.gz
|
||||
*.sig
|
||||
|
||||
# Build directory
|
||||
build/
|
||||
sources/build/
|
||||
tmp/
|
||||
usr/
|
||||
|
||||
# translations
|
||||
*.qm
|
||||
|
167
CHANGELOG
@ -1,12 +1,163 @@
|
||||
Ver.1.0.3:
|
||||
+ [plasmoid] edited russian translation
|
||||
* [all] refactoring
|
||||
Ver.1.3.0
|
||||
---------
|
||||
* all:
|
||||
+ add processes error messages
|
||||
+ add support of several active profiles
|
||||
* some bug fixes and refactoring
|
||||
* rewrite debug messages
|
||||
* dataengine:
|
||||
+ add new sources: intIp6, extIp6, netctlAutoStatus
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* change default command to define external IP
|
||||
* change interface list definition
|
||||
* change internal IP definition
|
||||
* gui:
|
||||
+ add 3rd party license information
|
||||
+ add system tray icon as an alternative to the plasmoid
|
||||
+ add DBus session interface org.netctlgui.netctlgui
|
||||
+ add dynamic settings load
|
||||
+ add support of openvswitch
|
||||
+ add security notes and API descriptions
|
||||
+ add ability to use helper
|
||||
+ add ability to start minimized/maximized/detached
|
||||
+ add ability to don't save profile from WiFi tab
|
||||
* more correct actions into SettingsWindow
|
||||
* update to library changes
|
||||
* rewrite tables to use toolTip
|
||||
* edit about window
|
||||
* 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.0.2:
|
||||
* [plasmoid] fix layout margins
|
||||
***
|
||||
|
||||
Ver.1.0.1:
|
||||
- [all] removed scripts
|
||||
Ver.1.2.0
|
||||
---------
|
||||
* all:
|
||||
+ add icons
|
||||
+ add support of netctl-auto
|
||||
* changes in the project architecture
|
||||
* refactoring
|
||||
* dataengine:
|
||||
+ add debug information (NETCTLGUI_DEBUG=yes)
|
||||
* gui:
|
||||
+ add support of macvlan
|
||||
+ add ability to remove profile
|
||||
+ add support of hidden wifi network
|
||||
+ add contextual menu to tables
|
||||
+ add actions menu
|
||||
+ add clear() function to profileTab
|
||||
+ add about window
|
||||
+ more command line options
|
||||
+ add workaround for wireless-wep example
|
||||
+ add shell completions
|
||||
+ add "Report a bug" action
|
||||
- fix possible segfaults with null arrays (#5)
|
||||
* more debug information
|
||||
* change lineEdit_profile to comboBox
|
||||
* refactoring of configuration interface
|
||||
* change setting of the interface to profile tab
|
||||
* rewrite ErrorWindow class
|
||||
* library:
|
||||
+ detach backend from frontend
|
||||
+ add error checking
|
||||
+ add doxygen documentation
|
||||
* more debug information
|
||||
* rewrite getSettingsFromProfile() function
|
||||
* plasmoid:
|
||||
+ add dataengine configuration
|
||||
+ add about window
|
||||
+ add debug information (NETCTLGUI_DEBUG=yes)
|
||||
* edit configuration interface
|
||||
* change double click event to click event
|
||||
* change class from Applet to PopupApplet
|
||||
|
||||
Ver.1.0:
|
||||
***
|
||||
|
||||
Ver.1.1.0 (netctl-1.7 update)
|
||||
-----------------------------
|
||||
* dataengine:
|
||||
* change definition if profile is enabled
|
||||
* gui:
|
||||
+ add frequency
|
||||
* change definition if profile is enabled
|
||||
* plasmoid:
|
||||
+ add menu title
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.6
|
||||
---------
|
||||
* gui:
|
||||
* fix error checking
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.5
|
||||
---------
|
||||
* plasmoid:
|
||||
+ add "Start WiFi menu" function
|
||||
* refactoring
|
||||
* edit icon
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.4
|
||||
---------
|
||||
* gui:
|
||||
+ add Qt5 gui (by default)
|
||||
* plasmoid:
|
||||
+ add notifications
|
||||
* fix run command with sudo from plasmoid
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.3
|
||||
---------
|
||||
* all:
|
||||
* refactoring
|
||||
* plasmoid:
|
||||
+ edit russian translation
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.2
|
||||
---------
|
||||
* plasmoid:
|
||||
- fix layout margins
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.1
|
||||
---------
|
||||
* all:
|
||||
- remove scripts
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0
|
||||
-------
|
||||
First release
|
||||
|
157
PKGBUILD
@ -1,42 +1,147 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
# comment out needed line if you dont need this component
|
||||
#_build_gui=0
|
||||
#_build_plasmoid=0
|
||||
|
||||
pkgname=netctl-gui
|
||||
pkgver=1.0.3
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.3.0
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4 GUI for netctl. Provides a plasmoid for KDE4"
|
||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPLv3')
|
||||
depends=('netctl' 'qt4')
|
||||
makedepends=('automoc4' 'cmake' 'desktop-file-utils' 'xdg-utils')
|
||||
optdepends=('kdebase-runtime: sudo support'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgname}-${pkgver}-src.tar.xz")
|
||||
install="${pkgname}.install"
|
||||
md5sums=('46371fb9aa75a63499d804b500adaadb')
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
install="${pkgbase}.install"
|
||||
md5sums=('d99eba4101fee42ebbfa5735aa706bc9')
|
||||
|
||||
# flags
|
||||
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release"
|
||||
[[ ${_build_gui} == 0 ]] && _cmakekeys=${_cmakekeys}" -DBUILD_GUI:BOOL=0"
|
||||
[[ ${_build_plasmoid} == 0 ]] && _cmakekeys=${_cmakekeys}" -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0" || depends[1]='kdebase-workspace'
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build"
|
||||
mkdir "${srcdir}/build"
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/build"
|
||||
cmake ${_cmakekeys} "../${pkgname}"
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/build"
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
optdepends=('kdebase-runtime: sudo support'
|
||||
'netctlgui-helper: DBus helper daemon'
|
||||
'netctlgui-helper-qt4: DBus helper daemon'
|
||||
'netctl-gui: graphical front-end'
|
||||
'netctl-gui-qt4: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="${pkgbase}.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui() {
|
||||
pkgdesc="Qt5 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt5-base')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui-qt4')
|
||||
conflicts=('libnetctlgui-qt4')
|
||||
|
||||
cd "${srcdir}/build-qt5/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=('libnetctlgui')
|
||||
provides=('netctlgui-helper-qt4')
|
||||
conflicts=('netctlgui-helper-qt4')
|
||||
backup=('etc/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() {
|
||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('libnetctlgui-qt4')
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'netctlgui-helper-qt4: DBus helper daemon')
|
||||
provides=('netctl-gui')
|
||||
conflicts=('netctl-gui')
|
||||
install="${pkgbase}.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
54
README.md
@ -3,43 +3,42 @@ Netctl GUI
|
||||
|
||||
Information
|
||||
-----------
|
||||
Graphical interface for netctl. Now it may work with profiles and may create new profiles. Also it may create a connection to WiFi. Moreover, it provides a widget and DataEngine for KDE.
|
||||
|
||||
**NOTE** LOOKING FOR TRANSLATORS!
|
||||
Qt4/Qt5 graphical interface for netctl. It may work with profiles and may create new profiles. Also it may create a connection to WiFi. Moreover, it provides a widget and DataEngine for KDE.
|
||||
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/netctl-gui/issues/3)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
It is recommended to use graphical interface for widget configuration. DataEngine settings are stored in `/usr/share/config/netctl.conf`:
|
||||
|
||||
* `CMD` - netctl command. Default value is `/usr/bin/netctl`.
|
||||
* `IPCMD` - ip command. `/usr/bin/ip` by default.
|
||||
* `NETDIR` - a directory, which contains subdirectories with names of network interfaces. Default is `/sys/class/net/`.
|
||||
* `EXTIPCMD` - a command, which returns external IP address. Default value is `wget -qO- http://ifconfig.me/ip`.
|
||||
* `EXTIP` - `true` will enable external IP definition. Default is `false`.
|
||||
|
||||
All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface.
|
||||
It is recommended to use graphical interface for widget and DataEngine configuration. All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface.
|
||||
|
||||
Instruction
|
||||
===========
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* netctl
|
||||
* qt4
|
||||
* qt5-base (if Qt5 is used) or qt4 (if Qt4 is used)
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* kdebase-workspace (widget)
|
||||
* sudo (sudo support)
|
||||
* wpa_supplicant (WiFi support)
|
||||
|
||||
Make dependencies
|
||||
-----------------
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
* qt5-tools (if Qt5 is used)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
* download sources
|
||||
* extract it and install the application:
|
||||
|
||||
@ -49,26 +48,29 @@ Installation
|
||||
make
|
||||
sudo make install
|
||||
|
||||
If you want install it without KDE widget just run:
|
||||
Available cmake flags:
|
||||
|
||||
cd /path/to/extracted/archive
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0 ../
|
||||
make
|
||||
sudo make install
|
||||
|
||||
If you want install it without GUI run:
|
||||
|
||||
cd /path/to/extracted/archive
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI:BOOL=0 ../
|
||||
make
|
||||
sudo make install
|
||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
||||
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
|
||||
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
|
||||
* `-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
|
||||
|
||||
Additional information
|
||||
======================
|
||||
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
* remove suid bit from helper (polkit/logind/etc)
|
||||
* check/update documentation
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://arcanis.name/projects/netctl-gui)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/netctl-gui) package
|
||||
* Page on [kde-apps](http://kde-apps.org/content/show.php?content=164490)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/pkgbase/netctl-gui/) package
|
||||
|
@ -3,20 +3,18 @@
|
||||
ARCHIVE="netctl-gui"
|
||||
SRCDIR="sources"
|
||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||
IGNORELIST="gui/resources/translations/english.qm gui/resources/translations/russian.qm"
|
||||
IGNORELIST="build en.qm ru.qm netctl-gui.qm *.cppcheck"
|
||||
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
|
||||
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}" "${ARCHIVE}"
|
||||
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
||||
for FILE in ${IGNORELIST[*]}; do rm -f "${ARCHIVE}/${FILE}"; done
|
||||
tar cvJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}" > /dev/null
|
||||
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf {} \;; done
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
rm -rf "${ARCHIVE}"
|
||||
|
||||
# update md5sum
|
||||
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
|
||||
|
Before Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 108 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: 105 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: 100 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;
|
||||
});
|
||||
}
|
@ -15,32 +15,33 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SLEEPTHREAD_H
|
||||
#define SLEEPTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#ifndef TASKADDS_H
|
||||
#define TASKADDS_H
|
||||
|
||||
#include <QProcess>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "task.h"
|
||||
|
||||
|
||||
class SleepThread : public QThread
|
||||
class RootProcess : public QProcess
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static void usleep(long iSleepTime)
|
||||
protected:
|
||||
void setupChildProcess()
|
||||
{
|
||||
QThread::usleep(iSleepTime);
|
||||
}
|
||||
|
||||
static void sleep(long iSleepTime)
|
||||
{
|
||||
QThread::sleep(iSleepTime);
|
||||
}
|
||||
|
||||
static void msleep(long iSleepTime)
|
||||
{
|
||||
QThread::msleep(iSleepTime);
|
||||
}
|
||||
::setuid(0);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
#endif /* SLEEPTHREAD_H */
|
||||
struct TaskResult
|
||||
{
|
||||
int exitCode;
|
||||
QByteArray error;
|
||||
QByteArray output;
|
||||
};
|
||||
TaskResult runTask(const QString cmd, const bool useSuid = true);
|
||||
|
||||
|
||||
#endif /* TASKADDS_H */
|
@ -6,40 +6,81 @@ cmake_policy (SET CMP0011 NEW)
|
||||
cmake_policy (SET CMP0015 NEW)
|
||||
|
||||
project (netctl-gui)
|
||||
set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 0)
|
||||
set (PROJECT_VERSION_PATCH 3)
|
||||
set (PROJECT_VERSION_MINOR 3)
|
||||
set (PROJECT_VERSION_PATCH 0)
|
||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||
|
||||
message (STATUS "Project: ${PROJECT_NAME}")
|
||||
message (STATUS "Version: ${PROJECT_VERSION}")
|
||||
message (STATUS "Build date: ${CURRENT_DATE}")
|
||||
|
||||
# install options
|
||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||
# components
|
||||
option (BUILD_GUI "Build GUI" ON)
|
||||
option (BUILD_DATAENGINE "Build data engine" ON)
|
||||
option (BUILD_HELPER "Build helper" ON)
|
||||
option (BUILD_LIBRARY "Build library" ON)
|
||||
option (BUILD_DATAENGINE "Build DataEngine" ON)
|
||||
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||
if (BUILD_GUI OR BUILD_HELPER)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
if (BUILD_PLASMOID)
|
||||
set (BUILD_DATAENGINE ON)
|
||||
endif ()
|
||||
# documentation
|
||||
option (BUILD_DOCS "Build Doxygen documentation" OFF)
|
||||
if (BUILD_DOCS)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# test
|
||||
option (BUILD_TEST "Build unit tests" OFF)
|
||||
if (BUILD_TEST)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# FIXME: dbus path
|
||||
set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus system configuration files")
|
||||
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
|
||||
if (BUILD_PLASMOID)
|
||||
set (BUILD_DATAENGINE ON)
|
||||
endif ()
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
add_subdirectory (icons)
|
||||
# resources
|
||||
set (PROJECT_LIBRARY netctlgui)
|
||||
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||
|
||||
# components
|
||||
if (BUILD_LIBRARY)
|
||||
add_subdirectory (${PROJECT_LIBRARY})
|
||||
endif ()
|
||||
if (BUILD_HELPER)
|
||||
add_subdirectory (helper)
|
||||
endif ()
|
||||
if (BUILD_TEST)
|
||||
enable_testing ()
|
||||
add_subdirectory (test)
|
||||
endif ()
|
||||
if (BUILD_GUI)
|
||||
add_subdirectory (gui)
|
||||
add_subdirectory (gui)
|
||||
endif ()
|
||||
if (BUILD_DATAENGINE)
|
||||
add_subdirectory (dataengine)
|
||||
add_subdirectory (dataengine)
|
||||
endif ()
|
||||
if (BUILD_PLASMOID)
|
||||
add_subdirectory (plasmoid)
|
||||
add_subdirectory (plasmoid)
|
||||
endif ()
|
||||
|
@ -13,14 +13,16 @@ set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
set (TASK_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/task.h)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
6
sources/dataengine/dataengine.cppcheck
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<libraries>
|
||||
<library>qt</library>
|
||||
</libraries>
|
||||
</project>
|
@ -2,17 +2,16 @@
|
||||
|
||||
## Commands
|
||||
# command
|
||||
CMD=/usr/bin/netctl
|
||||
# ip command
|
||||
IPCMD=/usr/bin/ip
|
||||
|
||||
## Network
|
||||
# path to list of network devices
|
||||
NETDIR=/sys/class/net/
|
||||
NETCTLCMD=/usr/bin/netctl
|
||||
# netctl-auto command
|
||||
NETCTLAUTOCMD=/usr/bin/netctl-auto
|
||||
|
||||
## External IP
|
||||
# external ip check command
|
||||
EXTIPCMD=wget -qO- http://ifconfig.me/ip
|
||||
# 'true' - check external IP
|
||||
EXTIP=false
|
||||
|
||||
# external IPv4 check command
|
||||
EXTIP4CMD=curl ip4.telize.com
|
||||
# 'true' - check external IPv4
|
||||
EXTIP4=false
|
||||
# external IPv6 check command
|
||||
EXTIP6CMD=curl ip6.telize.com
|
||||
# 'true' - check external IPv6
|
||||
EXTIP6=false
|
||||
|
@ -15,12 +15,19 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctl.h"
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#include <Plasma/DataContainer>
|
||||
#include <QDir>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "netctl.h"
|
||||
#include "pdebug.h"
|
||||
#include "taskadds.h"
|
||||
|
||||
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
@ -28,185 +35,323 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("NETCTLGUI_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
debug = false;
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
}
|
||||
|
||||
|
||||
Netctl::~Netctl()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::sources() const
|
||||
{
|
||||
QStringList sources;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
sources.append(QString("currentProfile"));
|
||||
sources.append(QString("extIp"));
|
||||
QStringList sources;
|
||||
sources.append(QString("active"));
|
||||
sources.append(QString("current"));
|
||||
sources.append(QString("extip4"));
|
||||
sources.append(QString("extip6"));
|
||||
sources.append(QString("interfaces"));
|
||||
sources.append(QString("intIp"));
|
||||
sources.append(QString("intip4"));
|
||||
sources.append(QString("intip6"));
|
||||
sources.append(QString("netctlauto"));
|
||||
sources.append(QString("profiles"));
|
||||
sources.append(QString("statusBool"));
|
||||
sources.append(QString("statusString"));
|
||||
sources.append(QString("status"));
|
||||
|
||||
return sources;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::readConfiguration()
|
||||
void Netctl::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// default configuration
|
||||
configuration[QString("CMD")] = QString("/usr/bin/netctl");
|
||||
configuration[QString("EXTIP")] = QString("false");
|
||||
configuration[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
|
||||
configuration[QString("IPCMD")] = QString("/usr/bin/ip");
|
||||
configuration[QString("NETDIR")] = QString("/sys/class/net/");
|
||||
QMap<QString, QString> rawConfig;
|
||||
rawConfig[QString("EXTIP4")] = QString("false");
|
||||
rawConfig[QString("EXTIP4CMD")] = QString("curl ip4.telize.com");
|
||||
rawConfig[QString("EXTIP6")] = QString("false");
|
||||
rawConfig[QString("EXTIP6CMD")] = QString("curl ip6.telize.com");
|
||||
rawConfig[QString("NETCTLCMD")] = QString("/usr/bin/netctl");
|
||||
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
|
||||
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile configFile(fileName);
|
||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
return;
|
||||
}
|
||||
QString fileStr;
|
||||
// FIXME: define configuration file
|
||||
QFile confFile(QString(getenv("HOME")) + QString("/.kde4/share/config/netctl.conf"));
|
||||
bool exists = confFile.open(QIODevice::ReadOnly);
|
||||
if (!exists) {
|
||||
confFile.setFileName("/usr/share/config/netctl.conf");
|
||||
exists = confFile.open(QIODevice::ReadOnly);
|
||||
if (!exists)
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList value;
|
||||
while (true) {
|
||||
fileStr = QString(confFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.contains(QString("=")))
|
||||
configuration[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.remove(QString(" "))
|
||||
.trimmed();
|
||||
fileStr = QString(configFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('='))) {
|
||||
value.clear();
|
||||
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
||||
value.append(fileStr.split(QChar('='))[i]);
|
||||
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
||||
}
|
||||
if (confFile.atEnd())
|
||||
break;
|
||||
if (configFile.atEnd()) break;
|
||||
}
|
||||
configFile.close();
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> config;
|
||||
QString key, value;
|
||||
// remove spaces and copy source map
|
||||
for (int i=0; i<rawConfig.keys().count(); i++) {
|
||||
key = rawConfig.keys()[i];
|
||||
value = rawConfig[key];
|
||||
key.remove(QChar(' '));
|
||||
if ((key != QString("EXTIP4CMD")) &&
|
||||
(key != QString("EXTIP6CMD")) &&
|
||||
(key != QString("NETCTLCMD")) &&
|
||||
(key != QString("NETCTLAUTOCMD")))
|
||||
value.remove(QChar(' '));
|
||||
config[key] = value;
|
||||
}
|
||||
|
||||
confFile.close();
|
||||
return true;
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + config[config.keys()[i]];
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source name" << name;
|
||||
|
||||
return updateSourceEvent(name);
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString cmd;
|
||||
if (netctlAutoStatus)
|
||||
cmd = cmdNetctlAuto;
|
||||
else
|
||||
cmd = cmdNetctl;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QStringList currentProfile;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i][0] == QChar('*'))
|
||||
currentProfile.append(profileList[i]);
|
||||
for (int i=0; i<currentProfile.count(); i++)
|
||||
currentProfile[i].remove(0, 2);
|
||||
|
||||
return currentProfile;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getExtIp(const QString cmd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
|
||||
return extIp;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getInterfaceList()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
||||
QStringList interfacesList;
|
||||
for (int i=0; i<rawList.count(); i++)
|
||||
interfacesList.append(rawList[i].name());
|
||||
|
||||
return interfacesList;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString intIp = QString("");
|
||||
if (protocol == QAbstractSocket::IPv4Protocol)
|
||||
intIp = QString("127.0.0.1/8");
|
||||
else if (protocol == QAbstractSocket::IPv6Protocol)
|
||||
intIp = QString("::1/128");
|
||||
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||
if (rawList[i].protocol() == protocol) {
|
||||
intIp = rawList[i].toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return intIp;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString status;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
if (cmdOutput.isEmpty()) {
|
||||
netctlAutoStatus = false;
|
||||
status = QString("false");
|
||||
} else {
|
||||
netctlAutoStatus = true;
|
||||
status = QString("true");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString cmd;
|
||||
if (netctlAutoStatus)
|
||||
cmd = cmdNetctlAuto;
|
||||
else
|
||||
cmd = cmdNetctl;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
profileList[i].remove(0, 2);
|
||||
|
||||
return profileList;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QStringList status;
|
||||
if (netctlAutoStatus)
|
||||
status.append(QString("netctl-auto"));
|
||||
else {
|
||||
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (process.exitCode == 0)
|
||||
status.append(QString("enabled"));
|
||||
else
|
||||
status.append(QString("static"));
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString status = QString("false");
|
||||
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
if (!currentProfile.isEmpty())
|
||||
status = QString("true");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::updateSourceEvent(const QString &source)
|
||||
{
|
||||
QProcess command;
|
||||
QString cmdOutput = QString("");
|
||||
QString value = QString("");
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source name" << source;
|
||||
|
||||
if (source == QString("currentProfile")) {
|
||||
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
|
||||
value = profileList[i].split(QString(" "), QString::SkipEmptyParts)[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("extIp")) {
|
||||
if (configuration[QString("EXTIP")] == QString("true")) {
|
||||
command.start(configuration[QString("EXTIPCMD")]);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (!cmdOutput.isEmpty())
|
||||
value = cmdOutput.split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("interfaces")) {
|
||||
if (QDir(configuration[QString("NETDIR")]).exists())
|
||||
value = QDir(configuration[QString("NETDIR")]).entryList(QDir::Dirs | QDir::NoDotAndDotDot).join(QString(","));
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("intIp")) {
|
||||
if (QDir(configuration[QString("NETDIR")]).exists()) {
|
||||
value = QString("127.0.0.1/8");
|
||||
QStringList netDevices = QDir(configuration[QString("NETDIR")]).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<netDevices.count(); i++)
|
||||
if (netDevices[i] != QString("lo")) {
|
||||
cmdOutput = QString("");
|
||||
command.start(configuration[QString("IPCMD")] + QString(" addr show ") + netDevices[i]);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList deviceInfo = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int j=0; j<deviceInfo.count(); j++)
|
||||
if (deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[0] == QString("inet"))
|
||||
value = deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("profiles")) {
|
||||
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
QStringList list;
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 1)
|
||||
list.append(profileList[i].split(QString(" "), QString::SkipEmptyParts)[0]);
|
||||
else if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2)
|
||||
list.append(profileList[i].split(QString(" "), QString::SkipEmptyParts)[1]);
|
||||
}
|
||||
value = list.join(QString(","));
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("statusBool")) {
|
||||
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
value = QString("false");
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
|
||||
value = QString("true");
|
||||
break;
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("statusString")) {
|
||||
command.start(configuration[QString("CMD")] + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
QString currentProfile;
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
|
||||
currentProfile = profileList[i].split(QString(" "), QString::SkipEmptyParts)[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
command.start(configuration[QString("CMD")] + QString(" status ") + currentProfile);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profile.count(); i++)
|
||||
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
|
||||
if (profile[i].contains(QString("enabled")))
|
||||
value = QString("enabled");
|
||||
else if (profile[i].contains(QString("static")))
|
||||
value = QString("static");
|
||||
break;
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
QString value = QString("N\\A");
|
||||
if (source == QString("active")) {
|
||||
value = getStatus(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")]);
|
||||
} else if (source == QString("current")) {
|
||||
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar('|'));
|
||||
} else if (source == QString("extip4")) {
|
||||
if (configuration[QString("EXTIP4")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
||||
} else if (source == QString("extip6")) {
|
||||
if (configuration[QString("EXTIP6")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
||||
} else if (source == QString("interfaces")) {
|
||||
value = getInterfaceList().join(QChar(','));
|
||||
} else if (source == QString("intip4")) {
|
||||
value = getIntIp(QAbstractSocket::IPv4Protocol);
|
||||
} else if (source == QString("intip6")) {
|
||||
value = getIntIp(QAbstractSocket::IPv6Protocol);
|
||||
} else if (source == QString("netctlauto")) {
|
||||
value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]);
|
||||
} else if (source == QString("profiles")) {
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar(','));
|
||||
} else if (source == QString("status")) {
|
||||
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar('|'));
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define NETCTL_DE_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QAbstractSocket>
|
||||
|
||||
|
||||
class Netctl : public Plasma::DataEngine
|
||||
@ -27,16 +28,29 @@ class Netctl : public Plasma::DataEngine
|
||||
|
||||
public:
|
||||
Netctl(QObject *parent, const QVariantList &args);
|
||||
~Netctl();
|
||||
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QString getExtIp(const QString cmd);
|
||||
QStringList getInterfaceList();
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
|
||||
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
|
||||
protected:
|
||||
bool readConfiguration();
|
||||
bool sourceRequestEvent(const QString &name);
|
||||
bool updateSourceEvent(const QString &source);
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
bool netctlAutoStatus;
|
||||
QString currentProfile;
|
||||
// configuration
|
||||
bool debug;
|
||||
QMap<QString, QString> configuration;
|
||||
void readConfiguration();
|
||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||
};
|
||||
|
||||
|
||||
|
1
sources/dataengine/pdebug.h
Symbolic link
@ -0,0 +1 @@
|
||||
../3rdparty/pdebug/pdebug.h
|
@ -4,7 +4,7 @@ Name=Netctl
|
||||
Comment=Data engine for netctl
|
||||
ServiceTypes=Plasma/DataEngine
|
||||
Type=Service
|
||||
Icon=netctl-gui
|
||||
Icon=netctl-gui-widget
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_netctl
|
||||
|
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,7 +5,8 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
# set directories
|
||||
set (SUBPROJECT_BINARY_DIR bin)
|
||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
set (SUBPROJECT_DOCS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
|
||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
|
||||
# executable path
|
||||
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
|
||||
@ -15,5 +16,13 @@ set (TARGETS "")
|
||||
set (HEADERS "")
|
||||
|
||||
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||
add_subdirectory (${SUBPROJECT_DOCS_DIR})
|
||||
# build man
|
||||
file (GLOB SUBPROJECT_MAN_IN *.1)
|
||||
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
|
||||
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
|
||||
|
||||
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
|
||||
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
|
||||
install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT})
|
||||
|
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
79
sources/gui/netctl-gui.1
Normal file
@ -0,0 +1,79 @@
|
||||
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "General Commands Manual"
|
||||
.SH NAME
|
||||
netctl-gui is a graphical interface for netctl
|
||||
.SH SYNOPSIS
|
||||
.B netctl-gui
|
||||
[ options ]
|
||||
.SH DESCRIPTION
|
||||
.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
|
||||
.IP "--detached"
|
||||
run detached from console
|
||||
.IP "--maximized"
|
||||
run maximized
|
||||
.IP "--minimized"
|
||||
run to system tray if it is available
|
||||
.IP "--about"
|
||||
show about window
|
||||
.IP "--netctl-auto"
|
||||
show netctl-auto window
|
||||
.IP "--settings"
|
||||
show settings window
|
||||
.IP "-e, --essid ESSID"
|
||||
select ESSID
|
||||
.I ESSID
|
||||
This option will set tab to 3 automatically
|
||||
.IP "-o, --open PROFILE"
|
||||
open profile
|
||||
.I PROFILE
|
||||
This option will set tab to 2 automatically
|
||||
.IP "-s, --select PROFILE"
|
||||
select profile
|
||||
.I PROFILE
|
||||
This option will set tab to 1 automatically
|
||||
.IP "-c, --config FILE"
|
||||
read configuration from file
|
||||
.I FILE
|
||||
.IP "-d, --debug"
|
||||
print debug information
|
||||
.IP "--default"
|
||||
start with default settings
|
||||
.IP "--set-opts OPTIONS"
|
||||
set options
|
||||
.I OPTIONS
|
||||
for this run, comma separated. Example:
|
||||
.nf
|
||||
LANGUAGE=en,NETCTL_PATH=/path/to/ponies
|
||||
.fi
|
||||
.IP "-t, --tab NUM"
|
||||
open a tab with number
|
||||
.I NUM
|
||||
.IP "-v, --version"
|
||||
show version and exit
|
||||
.IP "-i, --info"
|
||||
show build information and exit
|
||||
.IP "-h, --help"
|
||||
show this help and exit
|
||||
.SH FILES
|
||||
.I $HOME/.config/netctl-gui.conf
|
||||
.RS
|
||||
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
|
||||
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
|
||||
.SH LICENSE
|
||||
This software is licensed under @PROJECT_LICENSE@
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=Netctl GUI
|
||||
Comment=GUI written on Qt4 for netctl
|
||||
Comment=Qt graphical user interface for netctl
|
||||
Exec=netctl-gui
|
||||
Icon=netctl-gui.png
|
||||
Terminal=false
|
||||
|
@ -1,6 +0,0 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>translations/english.qm</file>
|
||||
<file>translations/russian.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -3,40 +3,55 @@ file (GLOB SOURCES *.cpp)
|
||||
file (GLOB HEADERS *.h)
|
||||
file (GLOB FORMS *.ui)
|
||||
|
||||
set (LANGUAGES english
|
||||
russian)
|
||||
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
|
||||
|
||||
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
|
||||
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
|
||||
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
|
||||
|
||||
# include_path
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
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)
|
||||
|
||||
find_package (Qt4 REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
if (USE_QT5)
|
||||
find_package(Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
|
||||
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
foreach (LANGUAGE ${LANGUAGES})
|
||||
set (TS ${SUBPROJECT_TRANSLATION_DIR}/${LANGUAGE}.ts)
|
||||
set (QM ${SUBPROJECT_TRANSLATION_DIR}/${LANGUAGE}.qm)
|
||||
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 COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
message (STATUS "${SUBPROJECT} Translations: ${TRANSLATIONS_BINARY}")
|
||||
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 COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
else ()
|
||||
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
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 COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
endif()
|
||||
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
||||
|
||||
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||
# install properties
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
|
218
sources/gui/src/about.ui
Normal file
@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>About</class>
|
||||
<widget class="QWidget" name="About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_About">
|
||||
<attribute name="title">
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_about">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_about">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_version">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_links">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_about">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_ackn">
|
||||
<attribute name="title">
|
||||
<string>Acknowledgement</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_ackn">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_ackn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_translators">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_trdparty">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_ackn">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>229</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_license">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
106
sources/gui/src/aboutwindow.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
/***************************************************************************
|
||||
* 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 "aboutwindow.h"
|
||||
#include "ui_aboutwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pdebug.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::AboutWindow),
|
||||
debug(debugCmd)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
createUi();
|
||||
}
|
||||
|
||||
|
||||
AboutWindow::~AboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete uiAbout;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::createText()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// 1st tab
|
||||
uiAbout->label_name->setText(QString(NAME));
|
||||
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
|
||||
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
|
||||
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
|
||||
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE))
|
||||
.arg(QApplication::translate("AboutWindow", "Homepage")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY))
|
||||
.arg(QApplication::translate("AboutWindow", "Repository")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER))
|
||||
.arg(QApplication::translate("AboutWindow", "Bugtracker")) +
|
||||
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION))
|
||||
.arg(QApplication::translate("AboutWindow", "Translation issue")) +\
|
||||
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES))
|
||||
.arg(QApplication::translate("AboutWindow", "AUR packages")));
|
||||
uiAbout->label_license->setText(QString("<small>© %1 <a href=\"mailto:%2\">%3</a><br>")
|
||||
.arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
|
||||
QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) +
|
||||
QString("</small>"));
|
||||
// 2nd tab
|
||||
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<trdPartyList.count(); i++)
|
||||
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
|
||||
.arg(trdPartyList[i].split(QChar(','))[0])
|
||||
.arg(trdPartyList[i].split(QChar(','))[1])
|
||||
.arg(trdPartyList[i].split(QChar(','))[2]);
|
||||
uiAbout->label_translators->setText(QApplication::translate("AboutWindow", "Translators: %1").arg(QString(TRANSLATORS)));
|
||||
uiAbout->label_trdparty->setText(QApplication::translate("AboutWindow", "This software uses: %1").arg(trdPartyList.join(QString(", "))));
|
||||
}
|
||||
|
||||
|
||||
void AboutWindow::createUi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QWidget *aboutWidget = new QWidget();
|
||||
uiAbout = new Ui::About;
|
||||
uiAbout->setupUi(aboutWidget);
|
||||
ui->verticalLayout->insertWidget(0, aboutWidget);
|
||||
createText();
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (pressedKey->key() == Qt::Key_Escape)
|
||||
close();
|
||||
}
|
51
sources/gui/src/aboutwindow.h
Normal file
@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* 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 ABOUTWINDOW_H
|
||||
#define ABOUTWINDOW_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "ui_about.h"
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class AboutWindow;
|
||||
}
|
||||
|
||||
class AboutWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutWindow(QWidget *parent = 0,
|
||||
const bool debugCmd = false);
|
||||
~AboutWindow();
|
||||
|
||||
private:
|
||||
Ui::AboutWindow *ui;
|
||||
Ui::About *uiAbout;
|
||||
bool debug;
|
||||
void createText();
|
||||
void createUi();
|
||||
// ESC pressed event
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
};
|
||||
|
||||
|
||||
#endif /* ABOUTWINDOW_H */
|
30
sources/gui/src/aboutwindow.ui
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AboutWindow</class>
|
||||
<widget class="QMainWindow" name="AboutWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>516</width>
|
||||
<height>431</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -72,9 +72,10 @@ int BridgeWidget::isOk()
|
||||
|
||||
void BridgeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> bridgeSettings = settings;
|
||||
|
||||
if (bridgeSettings.contains(QString("SkipForwardingDelay")))
|
||||
if (bridgeSettings[QString("SkipForwardingDelay")].remove(QString("'")) == QString("yes"))
|
||||
if (bridgeSettings[QString("SkipForwardingDelay")] == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
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 */
|
@ -16,81 +16,185 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "errorwindow.h"
|
||||
#include "ui_errorwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGridLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pdebug.h"
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const int messageNumber)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::ErrorWindow)
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
||||
: debug(debugCmd)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
|
||||
setMessage(messageNumber);
|
||||
}
|
||||
|
||||
|
||||
ErrorWindow::~ErrorWindow()
|
||||
{
|
||||
delete ui;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
void ErrorWindow::setMessage(const int mess)
|
||||
|
||||
QStringList ErrorWindow::getMessage(const int mess, const QString custom)
|
||||
{
|
||||
QString message;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||
|
||||
QString message, title;
|
||||
switch(mess) {
|
||||
case 1:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not find components");
|
||||
break;
|
||||
case 2:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Does not support yet");
|
||||
break;
|
||||
case 3:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Profile name is not set");
|
||||
break;
|
||||
case 4:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Bind interfaces are not set");
|
||||
break;
|
||||
case 5:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Description is not set");
|
||||
break;
|
||||
case 6:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Ip settings are not set");
|
||||
break;
|
||||
case 7:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Configuration file does not exist");
|
||||
break;
|
||||
case 8:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Key is not set");
|
||||
break;
|
||||
case 9:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Wireless settings are not set");
|
||||
break;
|
||||
case 10:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Configuration file is not set");
|
||||
break;
|
||||
case 11:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "ESSID is not set");
|
||||
break;
|
||||
case 12:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "MAC address is incorrect");
|
||||
break;
|
||||
case 13:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Session ID is not set");
|
||||
break;
|
||||
case 14:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "APN is not set");
|
||||
break;
|
||||
case 15:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "APN is not set");
|
||||
break;
|
||||
case 16:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Empty user/group name");
|
||||
break;
|
||||
case 17:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not find profile");
|
||||
break;
|
||||
case 18:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
|
||||
break;
|
||||
case 19:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not run helper");
|
||||
break;
|
||||
default:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
break;
|
||||
}
|
||||
if (!custom.isEmpty())
|
||||
message = custom;
|
||||
|
||||
ui->label->setText(message);
|
||||
QStringList fullMessage;
|
||||
fullMessage.append(title);
|
||||
fullMessage.append(message);
|
||||
return fullMessage;
|
||||
}
|
||||
|
||||
|
||||
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
|
||||
QMessageBox::Icon icon;
|
||||
switch(mess) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
case 10:
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
default:
|
||||
icon = QMessageBox::NoIcon;
|
||||
break;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||
|
||||
QStringList message = getMessage(mess, custom);
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(message[0]);
|
||||
messageBox.setInformativeText(message[1]);
|
||||
if (debug)
|
||||
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").
|
||||
arg(sender));
|
||||
messageBox.setIcon(getIcon(mess));
|
||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||
|
||||
QSpacerItem *horizontalSpacer = new QSpacerItem(400, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
||||
QGridLayout *layout = (QGridLayout *)messageBox.layout();
|
||||
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
||||
|
||||
messageBox.exec();
|
||||
return;
|
||||
}
|
||||
|
@ -18,25 +18,29 @@
|
||||
#ifndef ERRORWINDOW_H
|
||||
#define ERRORWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ErrorWindow;
|
||||
}
|
||||
|
||||
class ErrorWindow : public QMainWindow
|
||||
class ErrorWindow : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ErrorWindow(QWidget *parent = 0,
|
||||
const int messageNumber = 0);
|
||||
const bool debugCmd = false);
|
||||
~ErrorWindow();
|
||||
|
||||
public slots:
|
||||
void showWindow(const int mess = 0,
|
||||
const QString sender = QString(),
|
||||
const QString custom = QString());
|
||||
|
||||
private:
|
||||
Ui::ErrorWindow *ui;
|
||||
void setMessage(const int mess);
|
||||
bool debug;
|
||||
QStringList getMessage(const int mess, const QString custom = QString());
|
||||
QMessageBox::Icon getIcon(const int mess);
|
||||
};
|
||||
|
||||
|
||||
#endif /* ERRORWINDOW_H */
|
||||
|
@ -1,123 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ErrorWindow</class>
|
||||
<widget class="QMainWindow" name="ErrorWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>287</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="spacer2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_main">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Error text</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_button">
|
||||
<item>
|
||||
<spacer name="spacer_button1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_button2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked(bool)</signal>
|
||||
<receiver>ErrorWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>143</x>
|
||||
<y>83</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>252</x>
|
||||
<y>80</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -44,7 +44,7 @@ void EthernetWidget::clear()
|
||||
ui->checkBox_skip->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_8021x->setCheckState(Qt::Unchecked);
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant.conf"));
|
||||
ui->lineEdit_wpaConfig->clear();
|
||||
ui->comboBox_driver->setCurrentIndex(0);
|
||||
ui->spinBox_timeoutCarrier->setValue(5);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
@ -86,10 +86,9 @@ void EthernetWidget::selectWpaConfig()
|
||||
void EthernetWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||
ui->widget_ethernetAdvanced->setShown(true);
|
||||
ui->widget_ethernetAdvanced->setHidden(false);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_ethernetAdvanced->setHidden(true);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
|
||||
}
|
||||
@ -101,7 +100,7 @@ void EthernetWidget::showWpa(const int state)
|
||||
if (state == 0)
|
||||
ui->widget_wpa->setHidden(true);
|
||||
else
|
||||
ui->widget_wpa->setShown(true);
|
||||
ui->widget_wpa->setHidden(false);
|
||||
}
|
||||
|
||||
|
||||
@ -141,19 +140,20 @@ int EthernetWidget::isOk()
|
||||
|
||||
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> ethernetSettings = settings;
|
||||
|
||||
if (ethernetSettings.contains(QString("SkipNoCarrier")))
|
||||
if (ethernetSettings[QString("SkipNoCarrier")].remove(QString("'")) == QString("yes"))
|
||||
if (ethernetSettings[QString("SkipNoCarrier")] == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
if (ethernetSettings.contains(QString("Auth8021X")))
|
||||
if (ethernetSettings[QString("Auth8021X")].remove(QString("'")) == QString("yes"))
|
||||
if (ethernetSettings[QString("Auth8021X")] == QString("yes"))
|
||||
ui->checkBox_8021x->setCheckState(Qt::Checked);
|
||||
if (ethernetSettings.contains(QString("WPAConfigFile")))
|
||||
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")].remove(QString("'")));
|
||||
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")]);
|
||||
if (ethernetSettings.contains(QString("WPADriver")))
|
||||
for (int i=0; i<ui->comboBox_driver->count(); i++)
|
||||
if (ethernetSettings[QString("WPADriver")].remove(QString("'")) == ui->comboBox_driver->itemText(i))
|
||||
if (ethernetSettings[QString("WPADriver")] == ui->comboBox_driver->itemText(i))
|
||||
ui->comboBox_driver->setCurrentIndex(i);
|
||||
if (ethernetSettings.contains(QString("TimeoutCarrier")))
|
||||
ui->spinBox_timeoutCarrier->setValue(ethernetSettings[QString("TimeoutCarrier")].toInt());
|
||||
|
@ -112,10 +112,9 @@ void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
void GeneralWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_generalAdvanced->isChecked()) {
|
||||
ui->widget_generalAdvanced->setShown(true);
|
||||
ui->widget_generalAdvanced->setHidden(false);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_generalAdvanced->setHidden(true);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
|
||||
}
|
||||
@ -136,13 +135,13 @@ QMap<QString, QString> GeneralWidget::getSettings()
|
||||
QStringList interfaces;
|
||||
for (int i=0; i<ui->listWidget_bindto->count(); i++)
|
||||
interfaces.append(ui->listWidget_bindto->item(i)->text());
|
||||
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QString(" "));
|
||||
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QChar(' '));
|
||||
}
|
||||
if (ui->listWidget_after->count() != 0) {
|
||||
QStringList profiles;
|
||||
for (int i=0; i<ui->listWidget_after->count(); i++)
|
||||
profiles.append(ui->listWidget_after->item(i)->text());
|
||||
generalSettings[QString("After")] = profiles.join(QString(" "));
|
||||
generalSettings[QString("After")] = profiles.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_execUpPost->text().isEmpty())
|
||||
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'");
|
||||
@ -162,7 +161,9 @@ int GeneralWidget::isOk()
|
||||
// bind interfaces is not set
|
||||
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("vlan")))
|
||||
(ui->comboBox_connection->currentText() == QString("vlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
||||
if (ui->listWidget_bindto->count() == 0)
|
||||
return 1;
|
||||
// empty description
|
||||
@ -175,30 +176,31 @@ int GeneralWidget::isOk()
|
||||
|
||||
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> generalSettings = settings;
|
||||
|
||||
if (generalSettings.contains(QString("Description")))
|
||||
ui->lineEdit_description->setText(generalSettings[QString("Description")].remove(QString("'")));
|
||||
ui->lineEdit_description->setText(generalSettings[QString("Description")]);
|
||||
if (generalSettings.contains(QString("Connection")))
|
||||
for (int i=0; i<ui->comboBox_connection->count(); i++)
|
||||
if (generalSettings[QString("Connection")].remove(QString("'")) == ui->comboBox_connection->itemText(i))
|
||||
if (generalSettings[QString("Connection")] == ui->comboBox_connection->itemText(i))
|
||||
ui->comboBox_connection->setCurrentIndex(i);
|
||||
if (generalSettings.contains(QString("Interface")))
|
||||
for (int i=0; i<ui->comboBox_interface->count(); i++)
|
||||
if (generalSettings[QString("Interface")].remove(QString("'")) == ui->comboBox_interface->itemText(i))
|
||||
ui->comboBox_interface->setCurrentIndex(i);
|
||||
if (generalSettings.contains(QString("Interface"))) {
|
||||
ui->comboBox_interface->addItem(generalSettings[QString("Interface")]);
|
||||
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count()-1);
|
||||
}
|
||||
if (generalSettings.contains(QString("BindsToInterfaces")))
|
||||
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QString(" ")));
|
||||
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QChar('\n')));
|
||||
if (generalSettings.contains(QString("After")))
|
||||
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QString(" ")));
|
||||
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QChar('\n')));
|
||||
if (generalSettings.contains(QString("ExecUpPost")))
|
||||
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")].remove(QString("'")));
|
||||
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")]);
|
||||
if (generalSettings.contains(QString("ExecDownPre")))
|
||||
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")].remove(QString("'")));
|
||||
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")]);
|
||||
if (generalSettings.contains(QString("ForceConnect")))
|
||||
if (generalSettings[QString("ForceConnect")].remove(QString("'")) == QString("yes"))
|
||||
if (generalSettings[QString("ForceConnect")] == QString("yes"))
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
|
||||
if (generalSettings.contains(QString("NETCTL_DEBUG")))
|
||||
if (generalSettings[QString("NETCTL_DEBUG")].remove(QString("'")) == QString("yes"))
|
||||
if (generalSettings[QString("NETCTL_DEBUG")] == QString("yes"))
|
||||
ui->checkBox_debug->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>537</height>
|
||||
<width>425</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -118,6 +118,16 @@
|
||||
<string notr="true">vlan</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">macvlan</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">openvswitch</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
6
sources/gui/src/gui.cppcheck
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<libraries>
|
||||
<library>qt</library>
|
||||
</libraries>
|
||||
</project>
|
@ -18,7 +18,6 @@
|
||||
#include "ipwidget.h"
|
||||
#include "ui_ipwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
@ -171,7 +170,7 @@ void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
|
||||
QString IpWidget::getIp(const QString rawIp)
|
||||
{
|
||||
QStringList ip = rawIp.split(QString("."));
|
||||
QStringList ip = rawIp.split(QChar('.'));
|
||||
|
||||
// fix empty fields
|
||||
if (ip[0].isEmpty())
|
||||
@ -187,7 +186,7 @@ QString IpWidget::getIp(const QString rawIp)
|
||||
if (ip[i].toInt() > 255)
|
||||
ip[i] = QString("255");
|
||||
|
||||
return ip.join(QString("."));
|
||||
return ip.join(QChar('.'));
|
||||
}
|
||||
|
||||
|
||||
@ -234,8 +233,8 @@ QString IpWidget::getPrefix6(const QString rawPrefix)
|
||||
|
||||
void IpWidget::addIp()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(" ").split(QString("/"))[1]);
|
||||
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[0]);
|
||||
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[1]);
|
||||
|
||||
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
|
||||
ui->lineEdit_ipAddress->clear();
|
||||
@ -244,9 +243,9 @@ void IpWidget::addIp()
|
||||
|
||||
void IpWidget::addIpRoutes()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(" ").split(QString("/"))[1]);
|
||||
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(" "));
|
||||
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[0]);
|
||||
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[1]);
|
||||
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(QChar(' ')));
|
||||
|
||||
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
|
||||
ui->lineEdit_ipRoutes->clear();
|
||||
@ -256,8 +255,8 @@ void IpWidget::addIpRoutes()
|
||||
|
||||
void IpWidget::addIp6()
|
||||
{
|
||||
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(" ").split(QString("/"))[1]);
|
||||
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[0]);
|
||||
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[1]);
|
||||
|
||||
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
|
||||
ui->lineEdit_ipAddress6->clear();
|
||||
@ -266,9 +265,9 @@ void IpWidget::addIp6()
|
||||
|
||||
void IpWidget::addIpRoutes6()
|
||||
{
|
||||
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(" ").split(QString("/"))[1]);
|
||||
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(" "));
|
||||
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[0]);
|
||||
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[1]);
|
||||
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(QChar(' ')));
|
||||
|
||||
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
|
||||
ui->lineEdit_ipRoutes6->clear();
|
||||
@ -286,7 +285,7 @@ void IpWidget::addCustom()
|
||||
|
||||
void IpWidget::addDns()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_dns->text().remove(" "));
|
||||
QString ip = getIp(ui->lineEdit_dns->text().remove(QChar(' ')));
|
||||
|
||||
ui->listWidget_dns->addItem(ip);
|
||||
ui->lineEdit_dns->clear();
|
||||
@ -306,7 +305,7 @@ void IpWidget::changeIpMode(const QString currentText)
|
||||
if (currentText == QString("dhcp"))
|
||||
ui->widget_ip->setHidden(true);
|
||||
else if (currentText == QString("static"))
|
||||
ui->widget_ip->setShown(true);
|
||||
ui->widget_ip->setHidden(false);
|
||||
}
|
||||
|
||||
|
||||
@ -316,8 +315,7 @@ void IpWidget::ipEnable(const int state)
|
||||
ui->comboBox_ip->setDisabled(true);
|
||||
ui->widget_ip->setDisabled(true);
|
||||
ui->widget_ipRoutes->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->comboBox_ip->setEnabled(true);
|
||||
ui->widget_ip->setEnabled(true);
|
||||
ui->widget_ipRoutes->setEnabled(true);
|
||||
@ -332,7 +330,7 @@ void IpWidget::changeIp6Mode(const QString currentText)
|
||||
ui->widget_ip6->setHidden(true);
|
||||
else if ((currentText == QString("static")) ||
|
||||
(currentText == QString("stateless")))
|
||||
ui->widget_ip6->setShown(true);
|
||||
ui->widget_ip6->setHidden(false);
|
||||
}
|
||||
|
||||
|
||||
@ -342,8 +340,7 @@ void IpWidget::ip6Enable(const int state)
|
||||
ui->comboBox_ip6->setDisabled(true);
|
||||
ui->widget_ip6->setDisabled(true);
|
||||
ui->widget_ipRoutes6->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->comboBox_ip6->setEnabled(true);
|
||||
ui->widget_ip6->setEnabled(true);
|
||||
ui->widget_ipRoutes6->setEnabled(true);
|
||||
@ -354,12 +351,11 @@ void IpWidget::ip6Enable(const int state)
|
||||
void IpWidget::changeDhcpClient(const QString currentText)
|
||||
{
|
||||
if (currentText == QString("dhcpcd")) {
|
||||
ui->widget_dhcpcdOpt->setShown(true);
|
||||
ui->widget_dhcpcdOpt->setHidden(false);
|
||||
ui->widget_dhclientOpt->setHidden(true);
|
||||
}
|
||||
else if (currentText == QString("dhclient")) {
|
||||
} else if (currentText == QString("dhclient")) {
|
||||
ui->widget_dhcpcdOpt->setHidden(true);
|
||||
ui->widget_dhclientOpt->setShown(true);
|
||||
ui->widget_dhclientOpt->setHidden(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,10 +363,9 @@ void IpWidget::changeDhcpClient(const QString currentText)
|
||||
void IpWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||
ui->widget_ipAdvanced->setShown(true);
|
||||
ui->widget_ipAdvanced->setHidden(false);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_ipAdvanced->setHidden(true);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
|
||||
}
|
||||
@ -390,17 +385,16 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
QStringList addresses;
|
||||
for (int i=0; i<ui->listWidget_ipAddress->count(); i++)
|
||||
addresses.append(QString("'") + ui->listWidget_ipAddress->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Address")] = addresses.join(QString(" "));
|
||||
ipSettings[QString("Address")] = addresses.join(QChar(' '));
|
||||
ipSettings[QString("Gateway")] = QString("'") + ui->lineEdit_gateway->text() + QString("'");
|
||||
}
|
||||
if (ui->listWidget_ipRoutes->count() > 0) {
|
||||
QStringList routes;
|
||||
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
|
||||
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Routes")] = routes.join(QString(" "));
|
||||
ipSettings[QString("Routes")] = routes.join(QChar(' '));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
ipSettings[QString("IP")] = QString("no");
|
||||
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
||||
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
||||
@ -409,23 +403,22 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
QStringList addresses;
|
||||
for (int i=0; i<ui->listWidget_ipAddress6->count(); i++)
|
||||
addresses.append(QString("'") + ui->listWidget_ipAddress6->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Address6")] = addresses.join(QString(" "));
|
||||
ipSettings[QString("Address6")] = addresses.join(QChar(' '));
|
||||
ipSettings[QString("Gateway6")] = QString("'") + ui->lineEdit_gateway6->text() + QString("'");
|
||||
}
|
||||
if (ui->listWidget_ipRoutes6->count() > 0) {
|
||||
QStringList routes;
|
||||
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
|
||||
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Routes6")] = routes.join(QString(" "));
|
||||
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
ipSettings[QString("IP6")] = QString("no");
|
||||
if (ui->listWidget_custom->count() > 0) {
|
||||
QStringList custom;
|
||||
for (int i=0; i<ui->listWidget_custom->count(); i++)
|
||||
custom.append(QString("'") + ui->listWidget_custom->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("IPCustom")] = custom.join(QString(" "));
|
||||
ipSettings[QString("IPCustom")] = custom.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_hostname->text().isEmpty())
|
||||
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'");
|
||||
@ -434,8 +427,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
|
||||
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
|
||||
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'");
|
||||
}
|
||||
else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
} else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
||||
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
|
||||
@ -450,7 +442,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
QStringList dns;
|
||||
for (int i=0; i<ui->listWidget_dns->count(); i++)
|
||||
dns.append(QString("'") + ui->listWidget_dns->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("DNS")] = dns.join(QString(" "));
|
||||
ipSettings[QString("DNS")] = dns.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_dnsDomain->text().isEmpty())
|
||||
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'");
|
||||
@ -460,7 +452,7 @@ QMap<QString, QString> IpWidget::getSettings()
|
||||
QStringList dnsOpt;
|
||||
for (int i=0; i<ui->listWidget_dnsOptions->count(); i++)
|
||||
dnsOpt.append(QString("'") + ui->listWidget_dnsOptions->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("DNSOptions")] = dnsOpt.join(QString(" "));
|
||||
ipSettings[QString("DNSOptions")] = dnsOpt.join(QChar(' '));
|
||||
}
|
||||
|
||||
return ipSettings;
|
||||
@ -489,76 +481,71 @@ int IpWidget::isOk()
|
||||
|
||||
void IpWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> ipSettings = settings;
|
||||
|
||||
if (ipSettings.contains(QString("IP"))) {
|
||||
if (ipSettings[QString("IP")].remove(QString("'")) == QString("no"))
|
||||
if (ipSettings[QString("IP")] == QString("no"))
|
||||
ui->checkBox_ip->setCheckState(Qt::Unchecked);
|
||||
else {
|
||||
ui->checkBox_ip->setCheckState(Qt::Checked);
|
||||
for (int i=0; i<ui->comboBox_ip->count(); i++)
|
||||
if (ipSettings[QString("IP")].remove(QString("'")) == ui->comboBox_ip->itemText(i))
|
||||
if (ipSettings[QString("IP")] == ui->comboBox_ip->itemText(i))
|
||||
ui->comboBox_ip->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
if (ipSettings.contains(QString("Address")))
|
||||
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].remove(QString("'")).split(QString(" ")));
|
||||
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].split(QChar('\n')));
|
||||
if (ipSettings.contains(QString("Gateway")))
|
||||
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")].remove(QString("'")));
|
||||
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")]);
|
||||
if (ipSettings.contains(QString("Routes")))
|
||||
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].remove(QString("'")).split(QString(" ")));
|
||||
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].split(QChar('\n')));
|
||||
if (ipSettings.contains(QString("IP6"))) {
|
||||
if (ipSettings[QString("IP6")].remove(QString("'")) == QString("no"))
|
||||
if (ipSettings[QString("IP6")] == QString("no"))
|
||||
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
|
||||
else {
|
||||
ui->checkBox_ip6->setCheckState(Qt::Checked);
|
||||
for (int i=0; i<ui->comboBox_ip6->count(); i++)
|
||||
if (ipSettings[QString("IP6")].remove(QString("'")) == ui->comboBox_ip6->itemText(i))
|
||||
if (ipSettings[QString("IP6")] == ui->comboBox_ip6->itemText(i))
|
||||
ui->comboBox_ip6->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
if (ipSettings.contains(QString("Address6")))
|
||||
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].remove(QString("'")).split(QString(" ")));
|
||||
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].split(QChar('\n')));
|
||||
if (ipSettings.contains(QString("Gateway6")))
|
||||
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")].remove(QString("'")));
|
||||
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")]);
|
||||
if (ipSettings.contains(QString("Routes6")))
|
||||
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].remove(QString("'")).split(QString(" ")));
|
||||
if (ipSettings.contains(QString("IPCustom"))) {
|
||||
QStringList custom;
|
||||
if (ipSettings[QString("IPCustom")].contains(QString("\n")))
|
||||
custom = ipSettings[QString("IPCustom")].split(QString("'\n'"));
|
||||
else
|
||||
custom = ipSettings[QString("IPCustom")].split(QString("' '"));
|
||||
for (int i=0; i<custom.count(); i++)
|
||||
ui->listWidget_custom->addItem(custom[i].remove(QString("'")));
|
||||
}
|
||||
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].split(QChar('\n')));
|
||||
if (ipSettings.contains(QString("IPCustom")))
|
||||
ui->listWidget_custom->addItems(ipSettings[QString("IPCustom")].split(QChar('\n')));
|
||||
if (ipSettings.contains(QString("Hostname")))
|
||||
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")].remove(QString("'")));
|
||||
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")]);
|
||||
if (ipSettings.contains(QString("TimeoutDAD")))
|
||||
ui->spinBox_timeoutDad->setValue(ipSettings[QString("TimeoutDAD")].toInt());
|
||||
if (ipSettings.contains(QString("DHCPClient")))
|
||||
for (int i=0; i<ui->comboBox_dhcp->count(); i++)
|
||||
if (ipSettings[QString("DHCPClient")].remove(QString("'")) == ui->comboBox_dhcp->itemText(i))
|
||||
if (ipSettings[QString("DHCPClient")] == ui->comboBox_dhcp->itemText(i))
|
||||
ui->comboBox_dhcp->setCurrentIndex(i);
|
||||
if (ipSettings.contains(QString("DhcpcdOptions")))
|
||||
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")].remove(QString("'")));
|
||||
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")]
|
||||
.remove(QChar('\'')).remove(QChar('"')));
|
||||
if (ipSettings.contains(QString("DhclientOptions")))
|
||||
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")].remove(QString("'")));
|
||||
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")]);
|
||||
if (ipSettings.contains(QString("DhclientOptions6")))
|
||||
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")].remove(QString("'")));
|
||||
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")]);
|
||||
if (ipSettings.contains(QString("TimeoutDHCP")))
|
||||
ui->spinBox_timeoutDhcp->setValue(ipSettings[QString("TimeoutDHCP")].toInt());
|
||||
if (ipSettings.contains(QString("DHCPReleaseOnStop")))
|
||||
if (ipSettings[QString("DHCPReleaseOnStop")].remove(QString("'")) == QString("yes"))
|
||||
if (ipSettings[QString("DHCPReleaseOnStop")] == QString("yes"))
|
||||
ui->checkBox_dhcp->setCheckState(Qt::Checked);
|
||||
if (ipSettings.contains(QString("DNS")))
|
||||
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].remove(QString("'")).split(QString(" ")));
|
||||
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].split(QChar('\n')));
|
||||
if (ipSettings.contains(QString("DNSDomain")))
|
||||
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")].remove(QString("'")));
|
||||
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")]);
|
||||
if (ipSettings.contains(QString("DNSSearch")))
|
||||
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")].remove(QString("'")));
|
||||
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")]);
|
||||
if (ipSettings.contains(QString("DNSOptions")))
|
||||
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].remove(QString("'")).split(QString(" ")));
|
||||
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].split(QChar('\n')));
|
||||
|
||||
ipEnable(ui->checkBox_ip->checkState());
|
||||
changeIpMode(ui->comboBox_ip->currentText());
|
||||
|
115
sources/gui/src/language.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "language.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QLocale>
|
||||
|
||||
|
||||
Language::Language()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
|
||||
{
|
||||
QStringList availableLanguages = getAvailableLanguages();
|
||||
for (int i=0; i<availableLanguages.count(); i++)
|
||||
if (language == availableLanguages[i])
|
||||
return availableLanguages[i];
|
||||
for (int i=0; i<availableLanguages.count(); i++)
|
||||
if (language.contains(availableLanguages[i] + QChar('_')))
|
||||
return availableLanguages[i];
|
||||
|
||||
return defaultLanguage;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguage(const QString configPath, const QString options)
|
||||
{
|
||||
QMap<QString, QString> optionsDict = parseOptions(options);
|
||||
if (optionsDict.contains(QString("LANGUAGE")))
|
||||
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
|
||||
return optionsDict[QString("LANGUAGE")];
|
||||
|
||||
QString language;
|
||||
language = defineLanguageFromFile(configPath);
|
||||
if (language.isEmpty())
|
||||
language = defineLanguageFromLocale();
|
||||
language = checkLanguage(language, QString("en"));
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguageFromFile(const QString configPath)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
if (configPath.isEmpty())
|
||||
return QString("");
|
||||
QFile configFile(configPath);
|
||||
QString fileStr;
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
return QString("");
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('=')))
|
||||
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
||||
if (configFile.atEnd()) break;
|
||||
}
|
||||
configFile.close();
|
||||
|
||||
if (settings.contains(QString("LANGUAGE")))
|
||||
return settings[QString("LANGUAGE")];
|
||||
else
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguageFromLocale()
|
||||
{
|
||||
return QLocale::system().name();
|
||||
}
|
||||
|
||||
|
||||
QStringList Language::getAvailableLanguages()
|
||||
{
|
||||
QStringList languages;
|
||||
languages.append(QString("en"));
|
||||
languages.append(QString("ru"));
|
||||
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> Language::parseOptions(const QString options)
|
||||
{
|
||||
QMap<QString, QString> optionsDict;
|
||||
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
|
||||
continue;
|
||||
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
|
||||
options.split(QChar(','))[i].split(QChar('='))[1];
|
||||
}
|
||||
|
||||
return optionsDict;
|
||||
}
|
43
sources/gui/src/language.h
Normal file
@ -0,0 +1,43 @@
|
||||
/***************************************************************************
|
||||
* 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 LANGUAGE_H
|
||||
#define LANGUAGE_H
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
class Language : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Language();
|
||||
static QString checkLanguage(const QString language,
|
||||
const QString defaultLanguage = QString("en"));
|
||||
static QString defineLanguage(const QString configPath,
|
||||
const QString options = QString("OPTIONS"));
|
||||
static QString defineLanguageFromFile(const QString configPath);
|
||||
static QString defineLanguageFromLocale();
|
||||
static QStringList getAvailableLanguages();
|
||||
|
||||
private:
|
||||
static QMap<QString, QString> parseOptions(const QString options);
|
||||
};
|
||||
|
||||
|
||||
#endif /* LANGUAGE_H */
|
94
sources/gui/src/macvlanwidget.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* 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 "macvlanwidget.h"
|
||||
#include "ui_macvlanwidget.h"
|
||||
|
||||
|
||||
MacvlanWidget::MacvlanWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::MacvlanWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createFilter();
|
||||
}
|
||||
|
||||
|
||||
MacvlanWidget::~MacvlanWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MacvlanWidget::clear()
|
||||
{
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->lineEdit_mac->clear();
|
||||
}
|
||||
|
||||
|
||||
void MacvlanWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void MacvlanWidget::createFilter()
|
||||
{
|
||||
// mac
|
||||
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MacvlanWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> macvlanSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return macvlanSettings;
|
||||
|
||||
macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
|
||||
macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text();
|
||||
|
||||
return macvlanSettings;
|
||||
}
|
||||
|
||||
|
||||
int MacvlanWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void MacvlanWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> macvlanSettings = settings;
|
||||
|
||||
if (macvlanSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (macvlanSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (macvlanSettings.contains(QString("MACAddress")))
|
||||
ui->lineEdit_mac->setText(macvlanSettings[QString("MACAddress")]);
|
||||
}
|
49
sources/gui/src/macvlanwidget.h
Normal file
@ -0,0 +1,49 @@
|
||||
/***************************************************************************
|
||||
* 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 MACVLANWIDGET_H
|
||||
#define MACVLANWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MacvlanWidget;
|
||||
}
|
||||
|
||||
class MacvlanWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MacvlanWidget(QWidget *parent = 0);
|
||||
~MacvlanWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::MacvlanWidget *ui;
|
||||
void createFilter();
|
||||
};
|
||||
|
||||
|
||||
#endif /* MACVLANWIDGET_H */
|
94
sources/gui/src/macvlanwidget.ui
Normal file
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MacvlanWidget</class>
|
||||
<widget class="QWidget" name="MacvlanWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>396</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_macvlan">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>macvlan settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_macvlan">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">bridge</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">vepa</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">private</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">passthru</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mac">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mac">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="toolTip">
|
||||
<string>Optional static MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -17,90 +17,177 @@
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "language.h"
|
||||
#include "mainwindow.h"
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
bool existingSessionOperation(const QString operation)
|
||||
{
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
|
||||
DBUS_INTERFACE, operation);
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return !arguments.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
unsigned int getUidFromSession(const int type = 0)
|
||||
{
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
|
||||
DBUS_INTERFACE, QString("UIDs"));
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return arguments[0].toStringList()[type].toUInt();
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// translation
|
||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
||||
QDir::separator() + QString("netctl-gui.conf");
|
||||
QFile configFile(configPath);
|
||||
QString fileStr;
|
||||
QString language = QString("english");
|
||||
if (configFile.open(QIODevice::ReadOnly))
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.contains(QString("LANGUAGE=")))
|
||||
language = fileStr.split(QString("="))[1]
|
||||
.remove(QString(" "))
|
||||
.trimmed();
|
||||
}
|
||||
if (configFile.atEnd())
|
||||
break;
|
||||
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;
|
||||
}
|
||||
configFile.close();
|
||||
}
|
||||
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;
|
||||
|
||||
// detach from console
|
||||
if (args[QString("detached")].toBool())
|
||||
daemon(0, 0);
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
// reread translations according to flags
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
a.installTranslator(&qtTranslator);
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations/") + language);
|
||||
a.installTranslator(&translator);
|
||||
|
||||
QString helpMessage = QString("");
|
||||
helpMessage += QApplication::translate("MainWindow", " Netctl GUI\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Version : %1 License : GPLv3\n")
|
||||
.arg(QString(VERSION));
|
||||
helpMessage += QApplication::translate("MainWindow", " Evgeniy Alekseev aka arcanis\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " E-mail : esalexeev@gmail.com\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Usage:\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "netctl-gui [ --default ] [ -t NUM | --tab NUM ] [ -h | --help]\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " --default - start with default settings\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -t NUM --tab NUM - open a tab with number NUM\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -h --help - show this help and exit\n");
|
||||
bool defaultSettings = false;
|
||||
int tabNumber = 0;
|
||||
|
||||
for (int i=1; i<argc; i++) {
|
||||
// help message
|
||||
if (((argv[i][0] == '-') && (argv[i][1] == 'h') && (argv[i][2] == '\0')) ||
|
||||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'h') && (argv[i][3] == 'e') &&
|
||||
(argv[i][4] == 'l') && (argv[i][5] == 'p') && (argv[i][6] == '\0'))) {
|
||||
cout << helpMessage.toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
// default settings
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'd') && (argv[i][3] == 'e') &&
|
||||
(argv[i][4] == 'f') && (argv[i][5] == 'a') && (argv[i][6] == 'u') && (argv[i][7] == 'l') &&
|
||||
(argv[i][8] == 't') && (argv[i][9] == '\0')) {
|
||||
defaultSettings = true;
|
||||
}
|
||||
// tab number
|
||||
else if (((argv[i][0] == '-') && (argv[i][1] == 't') && (argv[i][2] == '\0')) ||
|
||||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 't') &&
|
||||
(argv[i][3] == 'a') && (argv[i][4] == 'b') && (argv[i][5] == '\0'))) {
|
||||
if (atoi(argv[i+1]) > 3)
|
||||
tabNumber = 3;
|
||||
else if (atoi(argv[i+1]) < 1)
|
||||
tabNumber = 1;
|
||||
else
|
||||
tabNumber = atoi(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
||||
MainWindow w(0, defaultSettings, tabNumber);
|
||||
w.show();
|
||||
// check if exists
|
||||
if (existingSessionOperation(QString("Active"))) {
|
||||
if ((getuid() == getUidFromSession(0)) && (geteuid() == getUidFromSession(1))) {
|
||||
// restore session
|
||||
cout << QCoreApplication::translate("MainWindow", "Restore existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
existingSessionOperation(QString("Restore"));
|
||||
return 0;
|
||||
} else if ((getuid() == getUidFromSession(0)) && (geteuid() != getUidFromSession(1))) {
|
||||
cout << QCoreApplication::translate("MainWindow", "Close existing session.")
|
||||
.toUtf8().data() << endl;
|
||||
existingSessionOperation(QString("Close"));
|
||||
}
|
||||
}
|
||||
MainWindow w(0, args, &qtTranslator, &translator);
|
||||
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,23 +22,26 @@
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class AboutWindow;
|
||||
class BridgeWidget;
|
||||
class ErrorWindow;
|
||||
class EthernetWidget;
|
||||
class GeneralWidget;
|
||||
class IpWidget;
|
||||
class MacvlanWidget;
|
||||
class MobileWidget;
|
||||
class Netctl;
|
||||
class NetctlProfile;
|
||||
class NetctlAutoWindow;
|
||||
class PasswdWidget;
|
||||
class PppoeWidget;
|
||||
class SettingsWindow;
|
||||
class TrayIcon;
|
||||
class TunnelWidget;
|
||||
class TuntapWidget;
|
||||
class VlanWidget;
|
||||
class WirelessWidget;
|
||||
class WpaSup;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -50,60 +53,124 @@ class MainWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const bool defaultSettings = false,
|
||||
const int tabNum = 1);
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||
QTranslator *qtAppTranslator = 0,
|
||||
QTranslator *appTranslator = 0);
|
||||
~MainWindow();
|
||||
Netctl *netctlCommand;
|
||||
NetctlProfile *netctlProfile;
|
||||
WpaSup *wpaCommand;
|
||||
QStringList printInformation();
|
||||
QStringList printSettings();
|
||||
QStringList printTrayInformation();
|
||||
bool isHelperActive();
|
||||
bool isHelperServiceActive();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
public slots:
|
||||
// actions from trayicon
|
||||
void closeMainWindow();
|
||||
void showAboutWindow();
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// trayicon control slots
|
||||
bool enableProfileSlot(const QString profile);
|
||||
bool startProfileSlot(const QString profile);
|
||||
bool stopAllProfilesSlot();
|
||||
bool switchToProfileSlot(const QString profile);
|
||||
bool restartProfileSlot(const QString profile);
|
||||
// open docs
|
||||
void showApi();
|
||||
void showLibrary();
|
||||
void showSecurityNotes();
|
||||
// helper
|
||||
bool forceStartHelper();
|
||||
bool forceStopHelper();
|
||||
bool startHelper();
|
||||
// main
|
||||
void setTab(int tab);
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateMenu();
|
||||
void updateTabs(const int tab);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
void setHiddenName(const QString name);
|
||||
|
||||
private slots:
|
||||
void reportABug();
|
||||
// menu update slots
|
||||
void setMenuActionsShown(const bool state = true);
|
||||
void updateMenuMain();
|
||||
void updateMenuProfile();
|
||||
void updateMenuWifi();
|
||||
// tab update slots
|
||||
void updateMainTab();
|
||||
void updateProfileTab();
|
||||
void updateWifiTab();
|
||||
// main tab slots
|
||||
void mainTabContextualMenu(const QPoint &pos);
|
||||
void mainTabEditProfile();
|
||||
void mainTabEnableProfile();
|
||||
QStringList mainTabGetActiveProfiles();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabStopAllProfiles();
|
||||
void mainTabSwitchToProfile();
|
||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
// profile tab slots
|
||||
void profileTabBrowseProfile();
|
||||
void profileTabChangeState(const QString current);
|
||||
void profileTabClear();
|
||||
void profileTabCreateProfile();
|
||||
void profileTabLoadProfile();
|
||||
void profileTabRemoveProfile();
|
||||
// wifi tab slots
|
||||
void wifiTabContextualMenu(const QPoint &pos);
|
||||
void wifiTabSetEnabled(const bool state);
|
||||
void wifiTabStart();
|
||||
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
|
||||
private:
|
||||
// ui
|
||||
Ui::MainWindow *ui;
|
||||
BridgeWidget *bridgeWid;
|
||||
EthernetWidget *ethernetWid;
|
||||
GeneralWidget *generalWid;
|
||||
IpWidget *ipWid;
|
||||
MobileWidget *mobileWid;
|
||||
PppoeWidget *pppoeWid;
|
||||
TunnelWidget *tunnelWid;
|
||||
TuntapWidget *tuntapWid;
|
||||
VlanWidget *vlanWid;
|
||||
WirelessWidget *wirelessWid;
|
||||
TrayIcon *trayIcon = nullptr;
|
||||
Ui::MainWindow *ui = nullptr;
|
||||
AboutWindow *aboutWin = nullptr;
|
||||
ErrorWindow *errorWin = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
PasswdWidget *passwdWid = nullptr;
|
||||
SettingsWindow *settingsWin = nullptr;
|
||||
BridgeWidget *bridgeWid = nullptr;
|
||||
EthernetWidget *ethernetWid = nullptr;
|
||||
GeneralWidget *generalWid = nullptr;
|
||||
IpWidget *ipWid = nullptr;
|
||||
MacvlanWidget *macvlanWid = nullptr;
|
||||
MobileWidget *mobileWid = nullptr;
|
||||
PppoeWidget *pppoeWid = nullptr;
|
||||
TunnelWidget *tunnelWid = nullptr;
|
||||
TuntapWidget *tuntapWid = nullptr;
|
||||
VlanWidget *vlanWid = nullptr;
|
||||
WirelessWidget *wirelessWid = nullptr;
|
||||
// backend
|
||||
ErrorWindow *errorWin;
|
||||
PasswdWidget *passwdWid;
|
||||
SettingsWindow *settingsWin;
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
bool checkExternalApps(const QString apps);
|
||||
bool checkState(const QString state, const QString item);
|
||||
bool checkHelperStatus();
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
bool hiddenNetwork;
|
||||
bool useHelper = true;
|
||||
QTranslator *qtTranslator = nullptr;
|
||||
QTranslator *translator = nullptr;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QMap<QString, QString> parseOptions(const QString options);
|
||||
};
|
||||
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>491</width>
|
||||
<height>519</height>
|
||||
<width>469</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -21,12 +21,45 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_main">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Connect to profile</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_netctlAuto" native="true">
|
||||
<layout class="QHBoxLayout" name="layout_netctlAuto">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_netctlAuto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>netctl-auto is running</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_netctlAuto">
|
||||
<property name="text">
|
||||
<string>Show</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_main">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
@ -39,6 +72,9 @@
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
@ -61,14 +97,8 @@
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -78,6 +108,11 @@
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
@ -99,19 +134,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainEnable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRestart">
|
||||
<property name="enabled">
|
||||
@ -120,6 +142,11 @@
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -133,6 +160,11 @@
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -149,6 +181,11 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Create a new profile</string>
|
||||
</attribute>
|
||||
@ -169,12 +206,12 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_profile"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profile">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
<widget class="QComboBox" name="comboBox_profile">
|
||||
<property name="acceptDrops">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -190,8 +227,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<height>28</height>
|
||||
<width>437</width>
|
||||
<height>338</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -211,12 +248,10 @@
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileLoad">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -238,6 +273,11 @@
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -245,6 +285,10 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_wifi">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Connect to Wi-Fi</string>
|
||||
</attribute>
|
||||
@ -261,6 +305,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_wifi">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
@ -273,6 +320,9 @@
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
@ -283,22 +333,28 @@
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Signal</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -308,6 +364,11 @@
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
@ -337,6 +398,11 @@
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
@ -355,21 +421,61 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>491</width>
|
||||
<height>20</height>
|
||||
<width>469</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMenu">
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionNetctlAuto"/>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuActions">
|
||||
<property name="title">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
<addaction name="actionMainRefresh"/>
|
||||
<addaction name="actionWifiRefresh"/>
|
||||
<addaction name="actionProfileClear"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainStart"/>
|
||||
<addaction name="actionMainSwitch"/>
|
||||
<addaction name="actionMainRestart"/>
|
||||
<addaction name="actionMainEnable"/>
|
||||
<addaction name="actionMainStopAll"/>
|
||||
<addaction name="actionProfileLoad"/>
|
||||
<addaction name="actionProfileSave"/>
|
||||
<addaction name="actionWifiStart"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainEdit"/>
|
||||
<addaction name="actionMainRemove"/>
|
||||
<addaction name="actionProfileRemove"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionSecurity"/>
|
||||
<addaction name="actionApi"/>
|
||||
<addaction name="actionLibrary"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReport"/>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
<addaction name="menuActions"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset theme="configure">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
@ -378,6 +484,11 @@
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
@ -385,24 +496,203 @@
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainStart">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRestart">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainEdit">
|
||||
<property name="icon">
|
||||
<iconset theme="edit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileClear">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWifiRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileLoad">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileSave">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWifiStart">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Wi-Fi</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctlAuto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</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>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>tableWidget_main</tabstop>
|
||||
<tabstop>pushButton_mainRefresh</tabstop>
|
||||
<tabstop>pushButton_mainEnable</tabstop>
|
||||
<tabstop>pushButton_mainRestart</tabstop>
|
||||
<tabstop>pushButton_mainStart</tabstop>
|
||||
<tabstop>lineEdit_profile</tabstop>
|
||||
<tabstop>pushButton_profile</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>pushButton_profileClear</tabstop>
|
||||
<tabstop>pushButton_profileLoad</tabstop>
|
||||
<tabstop>pushButton_profileSave</tabstop>
|
||||
<tabstop>tableWidget_wifi</tabstop>
|
||||
<tabstop>pushButton_wifiRefresh</tabstop>
|
||||
<tabstop>pushButton_wifiStart</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
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 */
|
@ -87,10 +87,9 @@ void MobileWidget::selectOptionsFile()
|
||||
void MobileWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||
ui->widget_mobileAdvanced->setShown(true);
|
||||
ui->widget_mobileAdvanced->setHidden(false);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_mobileAdvanced->setHidden(true);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
|
||||
}
|
||||
@ -143,28 +142,29 @@ int MobileWidget::isOk()
|
||||
|
||||
void MobileWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> mobileSettings = settings;
|
||||
|
||||
if (mobileSettings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(mobileSettings[QString("User")].remove(QString("'")));
|
||||
ui->lineEdit_username->setText(mobileSettings[QString("User")]);
|
||||
if (mobileSettings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(mobileSettings[QString("Password")].remove(QString("'")));
|
||||
ui->lineEdit_password->setText(mobileSettings[QString("Password")]);
|
||||
if (mobileSettings.contains(QString("AccessPointName")))
|
||||
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")].remove(QString("'")));
|
||||
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")]);
|
||||
if (mobileSettings.contains(QString("PIN")))
|
||||
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")].remove(QString("'")));
|
||||
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")]);
|
||||
if (mobileSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (mobileSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
|
||||
if (mobileSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (mobileSettings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(mobileSettings[QString("MaxFail")].toInt());
|
||||
if (mobileSettings.contains(QString("DefaultRoute")))
|
||||
if (mobileSettings[QString("DefaultRoute")].remove(QString("'")) == QString("false"))
|
||||
if (mobileSettings[QString("DefaultRoute")] == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (mobileSettings.contains(QString("UsePeerDNS")))
|
||||
if (mobileSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
|
||||
if (mobileSettings[QString("UsePeerDNS")] == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (mobileSettings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")].remove(QString("'")));
|
||||
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")]);
|
||||
}
|
||||
|
467
sources/gui/src/netctlautowindow.cpp
Normal file
@ -0,0 +1,467 @@
|
||||
/***************************************************************************
|
||||
* 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 "netctlautowindow.h"
|
||||
#include "ui_netctlautowindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#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)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::NetctlAutoWindow),
|
||||
debug(debugCmd)
|
||||
{
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
useHelper = true;
|
||||
else
|
||||
useHelper = false;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget->setColumnHidden(2, true);
|
||||
ui->tableWidget->setColumnHidden(3, true);
|
||||
netctlCommand = new Netctl(debug, settings);
|
||||
|
||||
createActions();
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
|
||||
}
|
||||
|
||||
|
||||
NetctlAutoWindow::~NetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
delete netctlCommand;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
|
||||
|
||||
if (statusBool)
|
||||
return QApplication::translate("NetctlAutoWindow", "yes");
|
||||
if (nullFalse)
|
||||
return QString("");
|
||||
else
|
||||
return QApplication::translate("NetctlAutoWindow", "no");
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
|
||||
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
|
||||
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
|
||||
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
|
||||
// service
|
||||
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
|
||||
connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService()));
|
||||
connect(ui->actionStartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartService()));
|
||||
|
||||
// table actions
|
||||
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile()));
|
||||
connect(ui->tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
|
||||
|
||||
// buttons
|
||||
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile()));
|
||||
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable()));
|
||||
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile()));
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::showWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("system-run"));
|
||||
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||
menu.addSeparator();
|
||||
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
|
||||
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
|
||||
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
||||
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
||||
// set text
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
|
||||
enableProfile->setVisible(false);
|
||||
startProfile->setVisible(false);
|
||||
} else {
|
||||
enableProfile->setVisible(true);
|
||||
startProfile->setVisible(true);
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
|
||||
} else {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
|
||||
if (action == startProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Switch to profile";
|
||||
netctlAutoStartProfile();
|
||||
} else if (action == enableProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
|
||||
netctlAutoEnableProfile();
|
||||
} else if (action == enableAllProfiles) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Enable all profiles";
|
||||
netctlAutoEnableAllProfiles();
|
||||
} else if (action == disableAllProfiles) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Disable all profiles";
|
||||
netctlAutoDisableAllProfiles();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
// actions
|
||||
bool enabled = false;
|
||||
bool running = false;
|
||||
if (useHelper) {
|
||||
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
} else {
|
||||
enabled = netctlCommand->isNetctlAutoEnabled();
|
||||
running = netctlCommand->isNetctlAutoRunning();
|
||||
}
|
||||
if (enabled)
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
||||
else
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
|
||||
ui->actionEnableService->setVisible(true);
|
||||
if (running) {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
|
||||
ui->actionDisableAll->setVisible(true);
|
||||
ui->actionEnableAll->setVisible(true);
|
||||
ui->actionRestartService->setVisible(true);
|
||||
} else {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
|
||||
ui->actionDisableAll->setVisible(false);
|
||||
ui->actionEnableAll->setVisible(false);
|
||||
ui->actionRestartService->setVisible(false);
|
||||
netctlAutoRefreshButtons(0, 0);
|
||||
return;
|
||||
}
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (useHelper)
|
||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
||||
QList<QVariant>(), true, debug), debug);
|
||||
else
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
|
||||
ui->tableWidget->setSortingEnabled(false);
|
||||
ui->tableWidget->selectRow(-1);
|
||||
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget->clear();
|
||||
ui->tableWidget->setRowCount(profiles.count());
|
||||
|
||||
// create header
|
||||
QStringList headerList;
|
||||
headerList.append(QApplication::translate("NetctlAutoWindow", "Name"));
|
||||
headerList.append(QApplication::translate("NetctlAutoWindow", "Description"));
|
||||
headerList.append(QApplication::translate("NetctlAutoWindow", "Active"));
|
||||
headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled"));
|
||||
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(profiles[i].active);
|
||||
font.setItalic(profiles[i].enabled);
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled));
|
||||
// name
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
|
||||
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
|
||||
ui->tableWidget->item(i, 0)->setFont(font);
|
||||
// description
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
|
||||
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
|
||||
// active
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// enabled
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
|
||||
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget->setSortingEnabled(true);
|
||||
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
ui->tableWidget->resizeColumnsToContents();
|
||||
ui->tableWidget->resizeRowsToContents();
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#else
|
||||
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
ui->tableWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
|
||||
|
||||
netctlAutoRefreshButtons(0, 0);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoDisableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoEnable"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoEnableProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoEnableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoStartProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoEnableService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoRestartService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoRestartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoStartService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoStartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (current == 0) {
|
||||
// buttons
|
||||
ui->pushButton_enable->setDisabled(true);
|
||||
ui->pushButton_switch->setDisabled(true);
|
||||
// menu
|
||||
ui->actionEnable->setVisible(false);
|
||||
ui->actionSwitch->setVisible(false);
|
||||
return;
|
||||
}
|
||||
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
|
||||
// buttons
|
||||
ui->pushButton_enable->setDisabled(true);
|
||||
ui->pushButton_switch->setDisabled(true);
|
||||
// menu
|
||||
ui->actionEnable->setVisible(false);
|
||||
ui->actionSwitch->setVisible(false);
|
||||
} else {
|
||||
// buttons
|
||||
ui->pushButton_enable->setEnabled(true);
|
||||
ui->pushButton_switch->setEnabled(true);
|
||||
// menu
|
||||
ui->actionEnable->setVisible(true);
|
||||
ui->actionSwitch->setVisible(true);
|
||||
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
||||
// buttons
|
||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
|
||||
// menu
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
|
||||
} else {
|
||||
// buttons
|
||||
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
// menu
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
}
|
||||
}
|
||||
}
|
70
sources/gui/src/netctlautowindow.h
Normal file
@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* 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 NETCTLAUTOWINDOW_H
|
||||
#define NETCTLAUTOWINDOW_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
|
||||
class Netctl;
|
||||
|
||||
namespace Ui {
|
||||
class NetctlAutoWindow;
|
||||
}
|
||||
|
||||
class NetctlAutoWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NetctlAutoWindow(QWidget *parent = 0,
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~NetctlAutoWindow();
|
||||
|
||||
public slots:
|
||||
void showWindow();
|
||||
|
||||
private slots:
|
||||
// table
|
||||
void netctlAutoContextualMenu(const QPoint &pos);
|
||||
void netctlAutoUpdateTable();
|
||||
// netctl-auto
|
||||
void netctlAutoDisableAllProfiles();
|
||||
void netctlAutoEnableProfile();
|
||||
void netctlAutoEnableAllProfiles();
|
||||
void netctlAutoStartProfile();
|
||||
void netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
// service
|
||||
void netctlAutoEnableService();
|
||||
void netctlAutoRestartService();
|
||||
void netctlAutoStartService();
|
||||
|
||||
private:
|
||||
Netctl *netctlCommand = nullptr;
|
||||
Ui::NetctlAutoWindow *ui = nullptr;
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLAUTOWINDOW_H */
|
238
sources/gui/src/netctlautowindow.ui
Normal file
@ -0,0 +1,238 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NetctlAutoWindow</class>
|
||||
<widget class="QMainWindow" name="NetctlAutoWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>339</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_buttons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_refresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_buttons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_enable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_switch">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMenu">
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSwitch"/>
|
||||
<addaction name="actionEnable"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEnableAll"/>
|
||||
<addaction name="actionDisableAll"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionStartService"/>
|
||||
<addaction name="actionRestartService"/>
|
||||
<addaction name="actionEnableService"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClose"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSwitch">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch to profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="icon">
|
||||
<iconset theme="exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Esc</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnableAll">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable all profiles</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisableAll">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Disable all profiles</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStartService">
|
||||
<property name="text">
|
||||
<string>Start service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRestartService">
|
||||
<property name="text">
|
||||
<string>Restart service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnableService">
|
||||
<property name="text">
|
||||
<string>Enable service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
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 */
|
@ -1,228 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctlinteract.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
Netctl::Netctl(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
{
|
||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
}
|
||||
|
||||
|
||||
Netctl::~Netctl()
|
||||
{
|
||||
delete profileDirectory;
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
|
||||
{
|
||||
QProcess command;
|
||||
QString commandText;
|
||||
if (sudo)
|
||||
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
|
||||
QString(" ") + profile;
|
||||
else
|
||||
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
|
||||
qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
return command.readAllStandardOutput();
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
|
||||
{
|
||||
QProcess command;
|
||||
QString commandText;
|
||||
if (sudo)
|
||||
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
|
||||
QString(" ") + profile;
|
||||
else
|
||||
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
|
||||
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// general information
|
||||
QList<QStringList> Netctl::getProfileList()
|
||||
{
|
||||
QList<QStringList> fullProfilesInfo;
|
||||
QStringList profiles = profileDirectory->entryList(QDir::Files);
|
||||
QStringList descriptions = getProfileDescriptions(profiles);
|
||||
QStringList statuses = getProfileStatuses(profiles);
|
||||
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QStringList profileInfo;
|
||||
profileInfo.append(profiles[i]);
|
||||
profileInfo.append(descriptions[i]);
|
||||
profileInfo.append(statuses[i]);
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
return fullProfilesInfo;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
||||
{
|
||||
QStringList descriptions;
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
|
||||
qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
|
||||
QFile profile(profileUrl);
|
||||
QString fileStr;
|
||||
if (profile.open(QIODevice::ReadOnly))
|
||||
while (true) {
|
||||
fileStr = QString(profile.readLine());
|
||||
if (fileStr[0] != '#')
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("Description"))
|
||||
descriptions.append(fileStr.split(QString("="), QString::SkipEmptyParts)[1].trimmed());
|
||||
if (profile.atEnd())
|
||||
break;
|
||||
}
|
||||
else
|
||||
descriptions.append(QString("<unknown>"));
|
||||
}
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
descriptions[i].remove(QChar('\''));
|
||||
descriptions[i].remove(QChar('"'));
|
||||
}
|
||||
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStatuses(const QStringList profileList)
|
||||
{
|
||||
QStringList statuses;
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
QString status;
|
||||
if (isProfileActive(profileList[i]))
|
||||
status = QString("active");
|
||||
else
|
||||
status = QString("inactive");
|
||||
if (isProfileEnabled(profileList[i]))
|
||||
status = status + QString(" (enabled)");
|
||||
else
|
||||
status = status + QString(" (static)");
|
||||
statuses.append(status);
|
||||
}
|
||||
|
||||
return statuses;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getSsidFromProfile(const QString profile)
|
||||
{
|
||||
QString ssidName = QString("");
|
||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
|
||||
QFile profileFile(profileUrl);
|
||||
QString fileStr;
|
||||
if (!profileFile.open(QIODevice::ReadOnly))
|
||||
return ssidName;
|
||||
|
||||
while (true) {
|
||||
fileStr = QString(profileFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("ESSID"))
|
||||
ssidName = fileStr.split(QString("="), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
if (profileFile.atEnd())
|
||||
break;
|
||||
}
|
||||
|
||||
profileFile.close();
|
||||
|
||||
ssidName.remove(QChar('\''));
|
||||
ssidName.remove(QChar('"'));
|
||||
return ssidName;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isProfileActive(const QString profile)
|
||||
{
|
||||
bool status = false;
|
||||
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
|
||||
if (!cmdOutput.isEmpty())
|
||||
if (cmdOutput.contains(QString("Active: active")))
|
||||
status = true;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isProfileEnabled(const QString profile)
|
||||
{
|
||||
bool status = false;
|
||||
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileStatus = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileStatus.count(); i++)
|
||||
if (profileStatus[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:"))
|
||||
if (profileStatus[i].contains(QString("enabled")))
|
||||
status = true;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
bool Netctl::enableProfile(const QString profile)
|
||||
{
|
||||
if (isProfileEnabled(profile))
|
||||
return netctlCall(true, QString("disable"), profile);
|
||||
else
|
||||
return netctlCall(true, QString("enable"), profile);
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::restartProfile(const QString profile)
|
||||
{
|
||||
return netctlCall(true, QString("restart"), profile);
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::startProfile(const QString profile)
|
||||
{
|
||||
if (isProfileActive(profile))
|
||||
return netctlCall(true, QString("stop"), profile);
|
||||
else
|
||||
return netctlCall(true, QString("start"), profile);
|
||||
}
|
@ -1,156 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctlprofile.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlProfile::NetctlProfile(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
{
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
}
|
||||
|
||||
|
||||
NetctlProfile::~NetctlProfile()
|
||||
{
|
||||
delete profileDirectory;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlProfile::copyProfile(const QString oldPath)
|
||||
{
|
||||
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
||||
QProcess command;
|
||||
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
|
||||
qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||
{
|
||||
|
||||
QString profileTempName = QDir::homePath() + QDir::separator() +
|
||||
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
|
||||
QFile profileFile(profileTempName);
|
||||
qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
|
||||
|
||||
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return profileTempName;
|
||||
|
||||
QTextStream out(&profileFile);
|
||||
for (int i=0; i<settings.keys().count(); i++) {
|
||||
out << settings.keys()[i] << QString("=");
|
||||
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
|
||||
(settings.keys()[i] == QString("After")) ||
|
||||
(settings.keys()[i] == QString("Address")) ||
|
||||
(settings.keys()[i] == QString("Routes")) ||
|
||||
(settings.keys()[i] == QString("Address6")) ||
|
||||
(settings.keys()[i] == QString("Routes6")) ||
|
||||
(settings.keys()[i] == QString("IPCustom")) ||
|
||||
(settings.keys()[i] == QString("DNS")) ||
|
||||
(settings.keys()[i] == QString("DNSOptions")) ||
|
||||
(settings.keys()[i] == QString("WPAConfigSection")) ||
|
||||
(settings.keys()[i] == QString("WPAConfigSection")))
|
||||
out << QString("(") + settings[settings.keys()[i]] << QString(")\n");
|
||||
else
|
||||
out << settings[settings.keys()[i]] << QString("\n");
|
||||
}
|
||||
profileFile.close();
|
||||
|
||||
return profileTempName;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
QString fileStr, profileUrl;
|
||||
if (profile[0] == QDir::separator())
|
||||
profileUrl = profile;
|
||||
else
|
||||
profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
QFile profileFile(profileUrl);
|
||||
qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
|
||||
|
||||
if (!profileFile.open(QIODevice::ReadOnly))
|
||||
return settings;
|
||||
while (true) {
|
||||
fileStr = QString(profileFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
|
||||
if ((fileStr.split(QString("="))[1][0] == QChar('(')) &&
|
||||
(fileStr.split(QString("="))[1][fileStr.split(QString("="))[1].size()-2] == QChar(')')))
|
||||
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed();
|
||||
else if (fileStr.split(QString("="))[1][0] == QChar('(')) {
|
||||
QString parameterName = fileStr.split(QString("="))[0];
|
||||
QStringList parameter;
|
||||
if (!fileStr.split(QString("="))[1]
|
||||
.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed()
|
||||
.isEmpty())
|
||||
parameter.append(fileStr.split(QString("="))[1]
|
||||
.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed());
|
||||
while(true) {
|
||||
fileStr = QString(profileFile.readLine());
|
||||
if (fileStr[fileStr.size()-2] == QChar(')'))
|
||||
break;
|
||||
if (!fileStr.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed()
|
||||
.isEmpty())
|
||||
parameter.append(fileStr.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed());
|
||||
if (profileFile.atEnd())
|
||||
break;
|
||||
}
|
||||
settings[parameterName] = parameter.join(QString("\n"));
|
||||
}
|
||||
else
|
||||
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.trimmed();
|
||||
}
|
||||
|
||||
}
|
||||
if (profileFile.atEnd())
|
||||
break;
|
||||
}
|
||||
|
||||
profileFile.close();
|
||||
return settings;
|
||||
}
|
@ -18,6 +18,8 @@
|
||||
#include "passwdwidget.h"
|
||||
#include "ui_passwdwidget.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
@ -59,6 +61,18 @@ void PasswdWidget::setFocusToLineEdit()
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::setPassword(const bool mode)
|
||||
{
|
||||
if (mode) {
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
||||
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
|
||||
} else {
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
||||
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::cancel()
|
||||
{
|
||||
hide();
|
||||
@ -70,5 +84,8 @@ void PasswdWidget::cancel()
|
||||
void PasswdWidget::passwdApply()
|
||||
{
|
||||
hide();
|
||||
return parent->connectToUnknownEssid(ui->lineEdit->text());
|
||||
if (ui->lineEdit->echoMode() == QLineEdit::Normal)
|
||||
return parent->setHiddenName(ui->lineEdit->text());
|
||||
else
|
||||
return parent->connectToUnknownEssid(ui->lineEdit->text());
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void setFocusToLineEdit();
|
||||
void setPassword(const bool mode = true);
|
||||
|
||||
private slots:
|
||||
void cancel();
|
||||
|
1
sources/gui/src/pdebug.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../3rdparty/pdebug/pdebug.h
|
@ -96,7 +96,7 @@ void PppoeWidget::changeMode(const QString currentText)
|
||||
if (currentText == QString("persist"))
|
||||
ui->widget_timeout->setHidden(true);
|
||||
else if (currentText == QString("demand"))
|
||||
ui->widget_timeout->setShown(true);
|
||||
ui->widget_timeout->setHidden(false);
|
||||
}
|
||||
|
||||
|
||||
@ -115,10 +115,9 @@ void PppoeWidget::selectOptionsFile()
|
||||
void PppoeWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
||||
ui->widget_pppoeAdvanced->setShown(true);
|
||||
ui->widget_pppoeAdvanced->setHidden(false);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_pppoeAdvanced->setHidden(true);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
|
||||
}
|
||||
@ -157,9 +156,10 @@ QMap<QString, QString> PppoeWidget::getSettings()
|
||||
pppoeSettings[QString("PPPoEService")] = QString("'") + ui->lineEdit_service->text() + QString("'");
|
||||
if (!ui->lineEdit_ac->text().isEmpty())
|
||||
pppoeSettings[QString("PPPoEAC")] = QString("'") + ui->lineEdit_ac->text() + QString("'");
|
||||
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text().remove(QString(" ")) + QString("'");
|
||||
if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
|
||||
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text()
|
||||
.remove(QChar('\'')).remove(QChar('"')) + QString("'");
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
|
||||
pppoeSettings[QString("PPPoEMAC")] = QString("'") + ui->lineEdit_mac->text() + QString("'");
|
||||
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
|
||||
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
|
||||
@ -175,18 +175,18 @@ int PppoeWidget::isOk()
|
||||
if (!QFile(ui->lineEdit_options->text()).exists())
|
||||
return 1;
|
||||
// mac address
|
||||
if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
if (ui->lineEdit_mac->text().contains(QString(" ")))
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
|
||||
if (ui->lineEdit_mac->text().contains(QChar(' ')))
|
||||
return 2;
|
||||
// session id is not set
|
||||
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
if (ui->lineEdit_session->text().split(QString(":"))[0].remove(QString(" ")).isEmpty())
|
||||
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
|
||||
if (ui->lineEdit_session->text().split(QChar(':'))[0].remove(QChar(' ')).isEmpty())
|
||||
return 3;
|
||||
// session mac address
|
||||
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty()) {
|
||||
QStringList item = ui->lineEdit_session->text().split(QString(":"));
|
||||
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty()) {
|
||||
QStringList item = ui->lineEdit_session->text().split(QChar(':'));
|
||||
for (int i=1; i<7; i++)
|
||||
if (item[i].contains(QString(" ")))
|
||||
if (item[i].contains(QChar(' ')))
|
||||
return 4;
|
||||
}
|
||||
// all fine
|
||||
@ -196,25 +196,26 @@ int PppoeWidget::isOk()
|
||||
|
||||
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> pppoeSettings = settings;
|
||||
|
||||
if (pppoeSettings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(pppoeSettings[QString("User")].remove(QString("'")));
|
||||
ui->lineEdit_username->setText(pppoeSettings[QString("User")]);
|
||||
if (pppoeSettings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(pppoeSettings[QString("Password")].remove(QString("'")));
|
||||
ui->lineEdit_password->setText(pppoeSettings[QString("Password")]);
|
||||
if (pppoeSettings.contains(QString("ConnectionMode")))
|
||||
for (int i=0; i<ui->comboBox_connection->count(); i++)
|
||||
if (pppoeSettings[QString("ConnectionMode")].remove(QString("'")) == ui->comboBox_connection->itemText(i))
|
||||
if (pppoeSettings[QString("ConnectionMode")] == ui->comboBox_connection->itemText(i))
|
||||
ui->comboBox_connection->setCurrentIndex(i);
|
||||
if (pppoeSettings.contains(QString("IdleTimeout")))
|
||||
ui->spinBox_timeout->setValue(pppoeSettings[QString("IdleTimeout")].toInt());
|
||||
if (pppoeSettings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(pppoeSettings[QString("MaxFail")].toInt());
|
||||
if (pppoeSettings.contains(QString("DefaultRoute")))
|
||||
if (pppoeSettings[QString("DefaultRoute")].remove(QString("'")) == QString("false"))
|
||||
if (pppoeSettings[QString("DefaultRoute")] == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (pppoeSettings.contains(QString("UsePeerDNS")))
|
||||
if (pppoeSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
|
||||
if (pppoeSettings[QString("UsePeerDNS")] == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (pppoeSettings.contains(QString("PPPUnit")))
|
||||
ui->lineEdit_unit->setText(pppoeSettings[QString("PPPUnit")]);
|
||||
@ -223,15 +224,15 @@ void PppoeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
if (pppoeSettings.contains(QString("LCPEchoFailure")))
|
||||
ui->spinBox_lcpFailure->setValue(pppoeSettings[QString("LCPEchoFailure")].toInt());
|
||||
if (pppoeSettings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(pppoeSettings[QString("OptionsFile")].remove(QString("'")));
|
||||
ui->lineEdit_options->setText(pppoeSettings[QString("OptionsFile")]);
|
||||
if (pppoeSettings.contains(QString("PPPoEService")))
|
||||
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")].remove(QString("'")));
|
||||
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")]);
|
||||
if (pppoeSettings.contains(QString("PPPoEAC")))
|
||||
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")].remove(QString("'")));
|
||||
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")]);
|
||||
if (pppoeSettings.contains(QString("PPPoESession")))
|
||||
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")].remove(QString("'")));
|
||||
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")]);
|
||||
if (pppoeSettings.contains(QString("PPPoEMAC")))
|
||||
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")].remove(QString("'")));
|
||||
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")]);
|
||||
if (pppoeSettings.contains(QString("PPPoEIP6")))
|
||||
if (pppoeSettings[QString("PPPoEIP6")] == QString("yes"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
|
@ -23,12 +23,14 @@
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "language.h"
|
||||
#include "mainwindow.h"
|
||||
#include "pdebug.h"
|
||||
|
||||
|
||||
SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
|
||||
: QMainWindow(wid),
|
||||
parent(wid),
|
||||
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
file(configFile),
|
||||
ui(new Ui::SettingsWindow)
|
||||
{
|
||||
@ -40,31 +42,43 @@ SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::createActions()
|
||||
{
|
||||
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(restoreSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
|
||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
||||
// buttons
|
||||
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
|
||||
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_interfacesDir, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_status, SIGNAL(clicked(bool)), this, SLOT(startHelper()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (pressedKey->key() == Qt::Key_Escape)
|
||||
close();
|
||||
}
|
||||
@ -72,142 +86,201 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
|
||||
void SettingsWindow::addLanguages()
|
||||
{
|
||||
ui->comboBox_language->addItem(QString("english"));
|
||||
ui->comboBox_language->addItem(QString("russian"));
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->comboBox_language->clear();
|
||||
ui->comboBox_language->addItems(Language::getAvailableLanguages());
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
|
||||
if (current == ui->treeWidget->topLevelItem(i)) {
|
||||
ui->stackedWidget->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::closeWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
saveSettings();
|
||||
close();
|
||||
((MainWindow *)parent())->updateConfiguration();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::saveSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings = readSettings();
|
||||
QFile configFile(file);
|
||||
|
||||
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
QTextStream out(&configFile);
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << QString("\n");
|
||||
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
|
||||
configFile.close();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setTray()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->checkBox_enableTray->checkState() == 0) {
|
||||
ui->checkBox_closeToTray->setDisabled(true);
|
||||
ui->checkBox_startToTray->setDisabled(true);
|
||||
} else if (ui->checkBox_enableTray->checkState() == 2) {
|
||||
ui->checkBox_closeToTray->setEnabled(true);
|
||||
ui->checkBox_startToTray->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::restoreSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setSettings(getSettings());
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setDefault()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setSettings(getDefault());
|
||||
saveSettings();
|
||||
if (sender() != ui->buttonBox->button(QDialogButtonBox::Reset))
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectIfaceDir()
|
||||
void SettingsWindow::selectAbstractSomething()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
|
||||
QString("/sys/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_interfacesDir->setText(directory);
|
||||
}
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool isDir = false;
|
||||
QString path = QString("/usr/bin");
|
||||
QString text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||
QLineEdit *lineEdit = ui->lineEdit_helperPath;
|
||||
if (sender() == ui->pushButton_helperPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||
lineEdit = ui->lineEdit_helperPath;
|
||||
} else if (sender() == ui->pushButton_interfacesDir) {
|
||||
isDir = true;
|
||||
text = QApplication::translate("SettingsWindow", "Select path to directory with interfaces");
|
||||
path = QString("/sys");
|
||||
lineEdit = ui->lineEdit_interfacesDir;
|
||||
} else if (sender() == ui->pushButton_netctlPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select netctl command");
|
||||
lineEdit = ui->lineEdit_netctlPath;
|
||||
} else if (sender() == ui->pushButton_netctlAutoPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select netctl-auto command");
|
||||
lineEdit = ui->lineEdit_netctlAutoPath;
|
||||
} else if (sender() == ui->pushButton_profilePath) {
|
||||
isDir = true;
|
||||
text = QApplication::translate("SettingsWindow", "Select path to profile directory");
|
||||
path = QString("/etc");
|
||||
lineEdit = ui->lineEdit_profilePath;
|
||||
} else if (sender() == ui->pushButton_rfkill) {
|
||||
isDir = true;
|
||||
text = QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices");
|
||||
path = QString("/sys");
|
||||
lineEdit = ui->lineEdit_rfkill;
|
||||
} else if (sender() == ui->pushButton_sudo) {
|
||||
text = QApplication::translate("SettingsWindow", "Select sudo command");
|
||||
lineEdit = ui->lineEdit_sudo;
|
||||
} else if (sender() == ui->pushButton_systemctlPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select systemctl command");
|
||||
lineEdit = ui->lineEdit_systemctlPath;
|
||||
} else if (sender() == ui->pushButton_wpaCliPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select wpa_cli command");
|
||||
lineEdit = ui->lineEdit_wpaCliPath;
|
||||
} else if (sender() == ui->pushButton_wpaSupPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select wpa_supplicant command");
|
||||
lineEdit = ui->lineEdit_wpaSupPath;
|
||||
}
|
||||
|
||||
void SettingsWindow::selectNetctlPath()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select netctl command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
QString filename;
|
||||
if (isDir)
|
||||
filename = QFileDialog::getExistingDirectory(this, text, path);
|
||||
else
|
||||
filename = QFileDialog::getOpenFileName(this, text, path,
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_netctlPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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::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()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaSupPath->setText(filename);
|
||||
lineEdit->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::showWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setSettings(getSettings());
|
||||
ui->label_info->hide();
|
||||
setTray();
|
||||
updateHelper();
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::readSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
if (ui->checkBox_helperClose->checkState() == 2)
|
||||
settings[QString("CLOSE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
if (ui->checkBox_closeToTray->checkState() == 2)
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
if (ui->checkBox_forceSudo->checkState() == 2)
|
||||
settings[QString("FORCE_SUDO")] = QString("true");
|
||||
else
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
|
||||
settings[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
|
||||
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
settings[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
|
||||
settings[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
|
||||
settings[QString("PID_FILE")] = ui->lineEdit_pid->text();
|
||||
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||
if (ui->checkBox_startToTray->checkState() == 2)
|
||||
settings[QString("STARTTOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
|
||||
if (ui->checkBox_enableTray->checkState() == 2)
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("SYSTRAY")] = QString("false");
|
||||
if (ui->checkBox_useHelper->checkState() == 2)
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("USE_HELPER")] = QString("false");
|
||||
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -215,50 +288,89 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
|
||||
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (settings[QString("CLOSE_HELPER")] == QString("true"))
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("CLOSETOTRAY")] == QString("true"))
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]);
|
||||
ui->lineEdit_helperService->setText(settings[QString("HELPER_SERVICE")]);
|
||||
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||
ui->comboBox_language->setCurrentIndex(0);
|
||||
for (int i=0; i<ui->comboBox_language->count(); i++)
|
||||
if (ui->comboBox_language->itemText(i) == settings[QString("LANGUAGE")])
|
||||
ui->comboBox_language->setCurrentIndex(i);
|
||||
ui->lineEdit_netctlPath->setText(settings[QString("NETCTL_PATH")]);
|
||||
ui->lineEdit_netctlAutoPath->setText(settings[QString("NETCTLAUTO_PATH")]);
|
||||
ui->lineEdit_netctlAutoService->setText(settings[QString("NETCTLAUTO_SERVICE")]);
|
||||
ui->lineEdit_pid->setText(settings[QString("PID_FILE")]);
|
||||
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
||||
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
||||
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
||||
if (settings[QString("STARTTOTRAY")] == QString("true"))
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
|
||||
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
|
||||
if (settings[QString("SYSTRAY")] == QString("true"))
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
||||
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getDefault()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||
settings[QString("CTRL_GROUP")] = QString("users");
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
|
||||
settings[QString("HELPER_SERVICE")] = QString("netctlgui-helper.service");
|
||||
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
||||
settings[QString("LANGUAGE")] = QString("english");
|
||||
settings[QString("LANGUAGE")] = QString("en");
|
||||
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
||||
settings[QString("NETCTLAUTO_PATH")] = QString("/usr/bin/netctl-auto");
|
||||
settings[QString("NETCTLAUTO_SERVICE")] = QString("netctl-auto");
|
||||
settings[QString("PID_FILE")] = QString("/run/wpa_supplicant_netctl-gui.pid");
|
||||
settings[QString("PREFERED_IFACE")] = QString("");
|
||||
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
||||
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
@ -266,29 +378,57 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings = getDefault();
|
||||
QFile configFile(file);
|
||||
QString fileStr;
|
||||
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
return getDefault();
|
||||
return settings;
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.contains(QString("=")))
|
||||
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.remove(QString(" "))
|
||||
.trimmed();
|
||||
}
|
||||
if (configFile.atEnd())
|
||||
break;
|
||||
fileStr = QString(configFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('=')))
|
||||
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
|
||||
if (configFile.atEnd()) break;
|
||||
}
|
||||
|
||||
configFile.close();
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
((MainWindow *)parent())->startHelper();
|
||||
updateHelper();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::updateHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (((MainWindow *)parent())->isHelperServiceActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active (systemd)"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
ui->pushButton_status->setDisabled(true);
|
||||
} else if (((MainWindow *)parent())->isHelperActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
ui->pushButton_status->setEnabled(true);
|
||||
} else {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Inactive"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Start"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("system-run"));
|
||||
ui->pushButton_status->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
@ -33,30 +34,31 @@ class SettingsWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsWindow(MainWindow *wid = 0,
|
||||
explicit SettingsWindow(QWidget *parent = 0,
|
||||
const bool debugCmd = false,
|
||||
const QString configFile = QString(""));
|
||||
~SettingsWindow();
|
||||
QMap<QString, QString> getDefault();
|
||||
QMap<QString, QString> getSettings();
|
||||
|
||||
public slots:
|
||||
void closeWindow();
|
||||
void restoreSettings();
|
||||
void setDefault();
|
||||
void showWindow();
|
||||
|
||||
private slots:
|
||||
void addLanguages();
|
||||
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void saveSettings();
|
||||
void setTray();
|
||||
void updateHelper();
|
||||
// buttons
|
||||
void selectIfaceDir();
|
||||
void selectNetctlPath();
|
||||
void selectProfileDir();
|
||||
void selectRfkillDir();
|
||||
void selectSudoPath();
|
||||
void selectWpaCliPath();
|
||||
void selectWpaSupPath();
|
||||
void selectAbstractSomething();
|
||||
void startHelper();
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
bool debug;
|
||||
QString file;
|
||||
Ui::SettingsWindow *ui;
|
||||
void createActions();
|
||||
|
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);
|
||||
}
|
@ -15,51 +15,51 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WPASUPINTERACT_H
|
||||
#define WPASUPINTERACT_H
|
||||
#ifndef TRAYICON_H
|
||||
#define TRAYICON_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QAction>
|
||||
#include <QObject>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class WpaSup : public QObject
|
||||
class TrayIcon : public QSystemTrayIcon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WpaSup(MainWindow *wid = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~WpaSup();
|
||||
// general information
|
||||
QString existentProfile(const QString profile);
|
||||
QStringList getInterfaceList();
|
||||
bool isProfileActive(const QString profile);
|
||||
bool isProfileExists(const QString profile);
|
||||
explicit TrayIcon(QObject *parent = 0,
|
||||
const bool debugCmd = false);
|
||||
~TrayIcon();
|
||||
|
||||
public slots:
|
||||
// functions
|
||||
QList<QStringList> scanWifi();
|
||||
bool startWpaSupplicant();
|
||||
bool stopWpaSupplicant();
|
||||
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:
|
||||
MainWindow *parent;
|
||||
QString ctrlDir;
|
||||
QString ctrlGroup;
|
||||
QDir *ifaceDirectory;
|
||||
QString mainInterface;
|
||||
QString pidFile;
|
||||
QString sudoCommand;
|
||||
QString wpaCliPath;
|
||||
QString wpaDrivers;
|
||||
QString wpaSupPath;
|
||||
bool debug;
|
||||
MainWindow *mainWindow;
|
||||
// contextual actions
|
||||
QMenu *menuActions;
|
||||
QMenu *startProfileMenu;
|
||||
QMenu *switchToProfileMenu;
|
||||
QMap<QString, QAction*> contextMenu;
|
||||
// functions
|
||||
bool wpaCliCall(const QString commandLine);
|
||||
QString getWpaCliOutput(const QString commandLine);
|
||||
void createActions();
|
||||
void init();
|
||||
};
|
||||
|
||||
|
||||
#endif /* WPASUPINTERACT_H */
|
||||
#endif /* TRAYICON_H */
|
@ -63,7 +63,7 @@ void TunnelWidget::createFilter()
|
||||
|
||||
QString TunnelWidget::getIp(const QString rawIp)
|
||||
{
|
||||
QStringList ip = rawIp.split(QString("."));
|
||||
QStringList ip = rawIp.split(QChar('.'));
|
||||
|
||||
// fix empty fields
|
||||
if (ip[0].isEmpty())
|
||||
@ -79,7 +79,7 @@ QString TunnelWidget::getIp(const QString rawIp)
|
||||
if (ip[i].toInt() > 255)
|
||||
ip[i] = QString("255");
|
||||
|
||||
return ip.join(QString("."));
|
||||
return ip.join(QChar('.'));
|
||||
}
|
||||
|
||||
|
||||
@ -91,10 +91,10 @@ QMap<QString, QString> TunnelWidget::getSettings()
|
||||
return tunnelSettings;
|
||||
|
||||
tunnelSettings[QString("Mode")] = QString("'") + ui->comboBox_mode->currentText() + QString("'");
|
||||
if (!ui->lineEdit_local->text().split(QString(".")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
tunnelSettings[QString("Local")] = QString("'") + getIp(ui->lineEdit_local->text().remove(QString(" "))) + QString("'");
|
||||
if (!ui->lineEdit_remote->text().split(QString(".")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
tunnelSettings[QString("Remote")] = QString("'") + getIp(ui->lineEdit_remote->text().remove(QString(" "))) + QString("'");
|
||||
if (!ui->lineEdit_local->text().remove(QChar('.')).remove(QChar(' ')).isEmpty())
|
||||
tunnelSettings[QString("Local")] = QString("'") + getIp(ui->lineEdit_local->text().remove(QChar(' '))) + QString("'");
|
||||
if (!ui->lineEdit_remote->text().remove(QChar('.')).remove(QChar(' ')).isEmpty())
|
||||
tunnelSettings[QString("Remote")] = QString("'") + getIp(ui->lineEdit_remote->text().remove(QChar(' '))) + QString("'");
|
||||
|
||||
return tunnelSettings;
|
||||
}
|
||||
@ -109,14 +109,15 @@ int TunnelWidget::isOk()
|
||||
|
||||
void TunnelWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> tunnelSettings = settings;
|
||||
|
||||
if (tunnelSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (tunnelSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
|
||||
if (tunnelSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (tunnelSettings.contains(QString("Local")))
|
||||
ui->lineEdit_local->setText(tunnelSettings[QString("Local")].remove(QString("'")));
|
||||
ui->lineEdit_local->setText(tunnelSettings[QString("Local")]);
|
||||
if (tunnelSettings.contains(QString("Remote")))
|
||||
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")].remove(QString("'")));
|
||||
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")]);
|
||||
}
|
||||
|
@ -81,14 +81,15 @@ int TuntapWidget::isOk()
|
||||
|
||||
void TuntapWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> tuntapSettings = settings;
|
||||
|
||||
if (tuntapSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (tuntapSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
|
||||
if (tuntapSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (tuntapSettings.contains(QString("User")))
|
||||
ui->lineEdit_user->setText(tuntapSettings[QString("User")].remove(QString("'")));
|
||||
ui->lineEdit_user->setText(tuntapSettings[QString("User")]);
|
||||
if (tuntapSettings.contains(QString("Group")))
|
||||
ui->lineEdit_group->setText(tuntapSettings[QString("Group")].remove(QString("'")));
|
||||
ui->lineEdit_group->setText(tuntapSettings[QString("Group")]);
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ int VlanWidget::isOk()
|
||||
|
||||
void VlanWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> vlanSettings = settings;
|
||||
|
||||
if (vlanSettings.contains(QString("VLANID")))
|
||||
|
@ -56,12 +56,14 @@ void WirelessWidget::clear()
|
||||
ui->spinBox_freq->setValue(2412);
|
||||
ui->listWidget_freq->setCurrentRow(-1);
|
||||
ui->listWidget_freq->clear();
|
||||
ui->spinBox_frequency->setValue(2000);
|
||||
ui->spinBox_priority->setValue(0);
|
||||
ui->lineEdit_country->clear();
|
||||
ui->lineEdit_wpaGroup->setText(QString("wheel"));
|
||||
ui->comboBox_drivers->setCurrentIndex(0);
|
||||
ui->listWidget_drivers->setCurrentRow(-1);
|
||||
ui->listWidget_drivers->clear();
|
||||
ui->comboBox_rfkill->clear();
|
||||
ui->comboBox_rfkill->addItem(QString("auto"));
|
||||
if (rfkillDirectory->exists()) {
|
||||
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
@ -70,7 +72,7 @@ void WirelessWidget::clear()
|
||||
QDir::separator() + QString("name"));
|
||||
QString deviceName;
|
||||
if (device.open(QIODevice::ReadOnly))
|
||||
deviceName = QString(device.readLine()).remove(QString("\n"));
|
||||
deviceName = QString(device.readLine()).trimmed();
|
||||
ui->comboBox_rfkill->addItem(deviceName);
|
||||
}
|
||||
}
|
||||
@ -153,28 +155,25 @@ void WirelessWidget::addOption()
|
||||
void WirelessWidget::changeSecurity(const QString currentText)
|
||||
{
|
||||
if (currentText == QString("none")) {
|
||||
ui->widget_essid->setShown(true);
|
||||
ui->widget_essid->setHidden(false);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if ((currentText == QString("wep")) ||
|
||||
} else if ((currentText == QString("wep")) ||
|
||||
(currentText == QString("wpa"))) {
|
||||
ui->widget_essid->setShown(true);
|
||||
ui->widget_essid->setHidden(false);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setShown(true);
|
||||
}
|
||||
else if (currentText == QString("wpa-configsection")) {
|
||||
ui->widget_key->setHidden(false);
|
||||
} else if (currentText == QString("wpa-configsection")) {
|
||||
ui->widget_essid->setHidden(true);
|
||||
ui->widget_wpaConfigSection->setShown(true);
|
||||
ui->widget_wpaConfigSection->setHidden(false);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if (currentText == QString("wpa-config")) {
|
||||
} else if (currentText == QString("wpa-config")) {
|
||||
ui->widget_essid->setHidden(true);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setShown(true);
|
||||
ui->widget_wpaConfig->setHidden(false);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
}
|
||||
@ -195,10 +194,9 @@ void WirelessWidget::selectWpaConfig()
|
||||
void WirelessWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_wirelessAdvanced->isChecked()) {
|
||||
ui->widget_wirelessAdvanced->setShown(true);
|
||||
ui->widget_wirelessAdvanced->setHidden(false);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
ui->widget_wirelessAdvanced->setHidden(true);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
|
||||
}
|
||||
@ -219,14 +217,13 @@ QMap<QString, QString> WirelessWidget::getSettings()
|
||||
wirelessSettings[QString("Key")] = ui->lineEdit_key->text();
|
||||
else
|
||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||
}
|
||||
else if (ui->comboBox_security->currentText() == QString("wpa"))
|
||||
} else if (ui->comboBox_security->currentText() == QString("wpa"))
|
||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
|
||||
QStringList section;
|
||||
for (int i=0; i<ui->listWidget_wpaConfigSection->count(); i++)
|
||||
section.append(QString("'") + ui->listWidget_wpaConfigSection->item(i)->text() + QString("'"));
|
||||
wirelessSettings[QString("WPAConfigSection")] = QString("\n") + section.join(QString("\n")) + QString("\n");
|
||||
wirelessSettings[QString("WPAConfigSection")] = QString("\n") + section.join(QChar('\n')) + QString("\n");
|
||||
}
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||
wirelessSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
|
||||
@ -238,8 +235,10 @@ QMap<QString, QString> WirelessWidget::getSettings()
|
||||
QStringList freqs;
|
||||
for (int i=0; i<ui->listWidget_freq->count(); i++)
|
||||
freqs.append(ui->listWidget_freq->item(i)->text());
|
||||
wirelessSettings[QString("ScanFrequencies")] = freqs.join(QString(" "));
|
||||
wirelessSettings[QString("ScanFrequencies")] = freqs.join(QChar(' '));
|
||||
}
|
||||
if (ui->spinBox_frequency->value() != 2000)
|
||||
wirelessSettings[QString("Frequency")] = QString::number(ui->spinBox_frequency->value());
|
||||
if (ui->spinBox_priority->value() != 0)
|
||||
wirelessSettings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
|
||||
if (!ui->lineEdit_country->text().isEmpty())
|
||||
@ -250,7 +249,7 @@ QMap<QString, QString> WirelessWidget::getSettings()
|
||||
QStringList drivers;
|
||||
for (int i=0; i<ui->listWidget_drivers->count(); i++)
|
||||
drivers.append(ui->listWidget_drivers->item(i)->text());
|
||||
wirelessSettings[QString("WPADriver")] = QString("'") + drivers.join(QString(",")) + QString("'");
|
||||
wirelessSettings[QString("WPADriver")] = QString("'") + drivers.join(QChar(',')) + QString("'");
|
||||
}
|
||||
if (ui->comboBox_rfkill->currentText() != QString("auto"))
|
||||
wirelessSettings[QString("RFKill")] = ui->comboBox_rfkill->currentText();
|
||||
@ -280,9 +279,8 @@ int WirelessWidget::isOk()
|
||||
return 3;
|
||||
// file wpa_supplicant doesn't exists
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
||||
return 4;
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
||||
return 4;
|
||||
// essid is not set
|
||||
if ((ui->comboBox_security->currentText() == QString("none")) ||
|
||||
(ui->comboBox_security->currentText() == QString("wep")) ||
|
||||
@ -296,51 +294,53 @@ int WirelessWidget::isOk()
|
||||
|
||||
void WirelessWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> wirelessSettings = settings;
|
||||
|
||||
if (wirelessSettings.contains(QString("Security")))
|
||||
for (int i=0; i<ui->comboBox_security->count(); i++)
|
||||
if (wirelessSettings[QString("Security")].remove(QString("'")) == ui->comboBox_security->itemText(i))
|
||||
if (wirelessSettings[QString("Security")] == ui->comboBox_security->itemText(i))
|
||||
ui->comboBox_security->setCurrentIndex(i);
|
||||
if (wirelessSettings.contains(QString("ESSID")))
|
||||
ui->lineEdit_essid->setText(wirelessSettings[QString("ESSID")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("Key")))
|
||||
ui->lineEdit_key->setText(wirelessSettings[QString("Key")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("WPAConfigSection"))) {
|
||||
QStringList custom;
|
||||
if (wirelessSettings[QString("WPAConfigSection")].contains(QString("\n")))
|
||||
custom = wirelessSettings[QString("WPAConfigSection")].split(QString("'\n'"));
|
||||
else
|
||||
custom = wirelessSettings[QString("WPAConfigSection")].split(QString("' '"));
|
||||
for (int i=0; i<custom.count(); i++)
|
||||
ui->listWidget_wpaConfigSection->addItem(custom[i].remove(QString("'")));
|
||||
ui->lineEdit_essid->setText(wirelessSettings[QString("ESSID")]);
|
||||
if (wirelessSettings.contains(QString("Key"))) {
|
||||
// workaround for wireless-wep example
|
||||
if (wirelessSettings.contains(QString("Security")))
|
||||
if ((wirelessSettings[QString("Security")] == QString("wep")) &&
|
||||
(wirelessSettings[QString("Key")][0] == QChar('"')))
|
||||
wirelessSettings[QString("Key")] = QChar('\\') + wirelessSettings[QString("Key")];
|
||||
ui->lineEdit_key->setText(wirelessSettings[QString("Key")]);
|
||||
}
|
||||
if (wirelessSettings.contains(QString("WPAConfigSection")))
|
||||
ui->listWidget_wpaConfigSection->addItems(wirelessSettings[QString("WPAConfigSection")].split(QChar('\n')));
|
||||
if (wirelessSettings.contains(QString("WPAConfigFile")))
|
||||
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")].remove(QString("'")));
|
||||
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")]);
|
||||
if (wirelessSettings.contains(QString("Hidden")))
|
||||
if (wirelessSettings[QString("Hidden")].remove(QString("'")) == QString("yes"))
|
||||
if (wirelessSettings[QString("Hidden")] == QString("yes"))
|
||||
ui->checkBox_hidden->setCheckState(Qt::Checked);
|
||||
if (wirelessSettings.contains(QString("AdHoc")))
|
||||
if (wirelessSettings[QString("AdHoc")].remove(QString("'")) == QString("yes"))
|
||||
if (wirelessSettings[QString("AdHoc")] == QString("yes"))
|
||||
ui->checkBox_adhoc->setCheckState(Qt::Checked);
|
||||
if (wirelessSettings.contains(QString("ScanFrequencies")))
|
||||
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QString("\n")));
|
||||
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QChar('\n')));
|
||||
if (wirelessSettings.contains(QString("Frequency")))
|
||||
ui->spinBox_frequency->setValue(wirelessSettings[QString("Frequency")].toInt());
|
||||
if (wirelessSettings.contains(QString("Priority")))
|
||||
ui->spinBox_priority->setValue(wirelessSettings[QString("Priority")].toInt());
|
||||
if (wirelessSettings.contains(QString("Country")))
|
||||
ui->lineEdit_country->setText(wirelessSettings[QString("Country")].remove(QString("'")));
|
||||
ui->lineEdit_country->setText(wirelessSettings[QString("Country")]);
|
||||
if (wirelessSettings.contains(QString("WPAGroup")))
|
||||
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")].remove(QString("'")));
|
||||
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")]);
|
||||
if (wirelessSettings.contains(QString("WPADriver")))
|
||||
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QString(",")));
|
||||
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QChar(',')));
|
||||
if (wirelessSettings.contains(QString("RFKill")))
|
||||
for (int i=0; i<ui->comboBox_rfkill->count(); i++)
|
||||
if (wirelessSettings[QString("RFKill")].remove(QString("'")) == ui->comboBox_rfkill->itemText(i))
|
||||
if (wirelessSettings[QString("RFKill")] == ui->comboBox_rfkill->itemText(i))
|
||||
ui->comboBox_rfkill->setCurrentIndex(i);
|
||||
if (wirelessSettings.contains(QString("TimeoutWPA")))
|
||||
ui->spinBox_timeoutWpa->setValue(wirelessSettings[QString("TimeoutWPA")].toInt());
|
||||
if (wirelessSettings.contains(QString("ExcludeAuto")))
|
||||
if (wirelessSettings[QString("ExcludeAuto")].remove(QString("'")) == QString("yes"))
|
||||
if (wirelessSettings[QString("ExcludeAuto")] == QString("yes"))
|
||||
ui->checkBox_exclude->setCheckState(Qt::Checked);
|
||||
|
||||
changeSecurity(ui->comboBox_security->currentText());
|
||||
|