Compare commits
395 Commits
Author | SHA1 | Date | |
---|---|---|---|
f665a46346 | |||
d541d0a755 | |||
0f5bf03e38 | |||
3695914226 | |||
03dbfce482 | |||
6a8d2701b0 | |||
ff3e000688 | |||
824a11457b | |||
b7fa17df4e | |||
35af460b7b | |||
9aa1f6d715 | |||
308f9824b4 | |||
bf7521481a | |||
e4bcfb1653 | |||
a2b1d46900 | |||
3f49988cef | |||
f80d6aae6b | |||
ef2694d7a7 | |||
26afd90df9 | |||
02432be630 | |||
275d71d75f | |||
b90f441fde | |||
19976819a1 | |||
362a11f0bc | |||
d94aa4ebf7 | |||
2cf876cf32 | |||
9993fee336 | |||
de0c1f208d | |||
25ca2ef1d9 | |||
1333967535 | |||
e70ebe318d | |||
dcdf03f639 | |||
8b33ec859b | |||
53ff63b792 | |||
b46ce1620b | |||
4c20a54d7e | |||
a73968f98b | |||
9033c51bb4 | |||
d23429891e | |||
cf12b3627e | |||
582459d174 | |||
08e7390f6c | |||
c8eae4b222 | |||
54583eae6e | |||
634b4c3b41 | |||
54c5e7958a | |||
6ed45fa7a5 | |||
73ba838685 | |||
924beacc23 | |||
a830fc9372 | |||
4c7459e833 | |||
00a35d75d2 | |||
3e92ec2aae | |||
3ac0484f21 | |||
cbac07b29e | |||
7972f2d6d3 | |||
afed94745a | |||
c8f260c8e2 | |||
edb386d24e | |||
f188dea8a7 | |||
6fb7da4b5b | |||
a35e9b0164 | |||
4bc428f8b5 | |||
030dec5e14 | |||
0898a99878 | |||
8dd48fa7cc | |||
287405f81a | |||
fa27b80060 | |||
c2c14c4911 | |||
e2deb8751d | |||
1fe7d6e21f | |||
e68be6d4f1 | |||
45d3a42754 | |||
cb0410a182 | |||
9d349461cf | |||
d41a34673b | |||
b199b43f58 | |||
6d212efe1e | |||
d32486d882 | |||
5afa65ce68 | |||
5b46247df2 | |||
bda5433716 | |||
835e82ca63 | |||
98cdb18d62 | |||
cd59a9b294 | |||
4780433c4d | |||
28a4934a82 | |||
4e8bbeed35 | |||
f86ef0514b | |||
4c004af1ae | |||
66e3a737d4 | |||
9cf6552c71 | |||
f18e74917b | |||
b909222db9 | |||
0c7868536a | |||
fc3956caf1 | |||
4cf3c85070 | |||
6e57baccaf | |||
5ed704e676 | |||
eb3753ab25 | |||
f9d71577f3 | |||
814f2c7904 | |||
ceca889be4 | |||
696283b1e1 | |||
15cc3a8595 | |||
e8c3441f29 | |||
2de7b26f66 | |||
8f35aeb88f | |||
b49188c104 | |||
f8bf8830be | |||
6e6c547460 | |||
d287f52ba5 | |||
8cc02a07fb | |||
28d51484b1 | |||
e7d2e0bd38 | |||
999914926a | |||
e21b2201ab | |||
d65ded6072 | |||
16662f697b | |||
35d740b778 | |||
0a16364a7a | |||
e9090ab4a9 | |||
8bf33d4369 | |||
4e76d52671 | |||
47dc016da2 | |||
8b58f6d383 | |||
709431ead2 | |||
f90b2d97a7 | |||
5416ef841f | |||
e4cff2baf4 | |||
d047eaf2f2 | |||
56f4a75b25 | |||
dd05782f80 | |||
2c2919160b | |||
d7c8490724 | |||
1930eeb33c | |||
4cc9d0ec11 | |||
a7911d48d1 | |||
012c725e12 | |||
1907d3ac2f | |||
87376f1a5c | |||
f238ba3a6a | |||
abbc5641cd | |||
82c3690dcb | |||
d3e1c4bca0 | |||
b63d883eb2 | |||
529e2dd995 | |||
1d34a65f38 | |||
fea0bedef0 | |||
ec8fc79dd7 | |||
07e07ee777 | |||
5c8dca22d0 | |||
dba3eeabaa | |||
eabfac7323 | |||
3b1701f8b5 | |||
b65f761520 | |||
fddd4703cc | |||
f4e3848fa7 | |||
3e0ae6d4cc | |||
80f6ccf1d1 | |||
863b49eaec | |||
4785e358ec | |||
f0adbb60e5 | |||
61d814d9a2 | |||
d166668feb | |||
db3bfe9ad7 | |||
d2ea9d96d9 | |||
d4c82fce0c | |||
fe672aa8cc | |||
501b43002e | |||
43ed28de52 | |||
f7352f5c59 | |||
d112446d87 | |||
b863eedd96 | |||
e19c9fef53 | |||
10499691b3 | |||
bf6d7cd53b | |||
11db0fcf8d | |||
d44979e95e | |||
41f58c1448 | |||
2ff76e9c8e | |||
0b2cc3ba79 | |||
fb430b036e | |||
42194295cc | |||
558a206a8d | |||
172624b494 | |||
e64e8810f8 | |||
23f4a7f141 | |||
d01bb8834a | |||
0989a6584b | |||
c75f5ec135 | |||
d0a0b0eb4a | |||
6b7d5d3800 | |||
6a3e3b14b3 | |||
1ae30b0821 | |||
c15e387472 | |||
d04a0b0920 | |||
e8e0c71c05 | |||
516c4b5a22 | |||
4e027ec19f | |||
4788ad0081 | |||
891b3b43ef | |||
dee47b0ffc | |||
86753070e8 | |||
ff78d390ae | |||
447bcf8a0e | |||
e8a7865e99 | |||
fdb5b46ea1 | |||
0432579f5b | |||
2aa6b43e61 | |||
0bade9c42f | |||
067115280c | |||
873f84c447 | |||
4c9c7b00a1 | |||
64937105c6 | |||
297a18d530 | |||
8c0226c9db | |||
1abc4a5ac9 | |||
7ed3e4e01b | |||
dc81a44034 | |||
7febf94233 | |||
3a0f0c252e | |||
209c3b9616 | |||
a79cbd4429 | |||
eb6bd34489 | |||
ccc62ffb67 | |||
fc2d338450 | |||
eefe196b69 | |||
c1e23d38a9 | |||
e9c10e262e | |||
0d26d6230e | |||
0aa162b71b | |||
78a4aeb0eb | |||
ec5dff4b75 | |||
0070f910cc | |||
6cba836d98 | |||
4600aae8bc | |||
79e7aa1926 | |||
32683a89b9 | |||
43de4e5738 | |||
099b4e3792 | |||
389726379c | |||
9c0dcfe621 | |||
75a95661f8 | |||
31f52e5d22 | |||
78827d833d | |||
c0207a108e | |||
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 | |||
9a5b61be4e | |||
7d7a24c23d | |||
1366852a62 | |||
b1e455b976 | |||
1a7d3cb50a | |||
762e43c0d6 | |||
f02e553164 | |||
44a5ee9083 | |||
e576ff3b51 | |||
20e744d3cd | |||
6132de0951 | |||
80e4b3e3d3 | |||
028b636d22 | |||
682b6c5b4f | |||
996d2d5bee | |||
d0a39b6770 | |||
8c9904ac4b | |||
e969be6b89 | |||
9e854d8893 | |||
ecea3f2cf8 | |||
e24b908015 | |||
2abe09473a | |||
f258f18e8c | |||
c66891ee60 | |||
3f02c047c2 | |||
2cade97786 | |||
fbad5a6c7d | |||
710941c259 | |||
32fb8ceb54 | |||
9b3902e971 | |||
9184aa78f4 | |||
0c219544b2 | |||
946b470d11 | |||
76877f737e | |||
4dd6a8276d | |||
4da239e41f | |||
d98b3694a4 | |||
ac1a135844 | |||
806cc02075 | |||
887cc013a7 | |||
3cb4e1dfee | |||
03b4744097 | |||
23df40960c | |||
026f08d0cf | |||
13c63163b1 | |||
a56119d0de | |||
f3b6457a9b | |||
d85e5560fa | |||
9cad2e2c29 | |||
49fcfafc9e | |||
a20cac49aa | |||
4e53eaa1ea | |||
6b9f9beabc | |||
6e427519af | |||
61bf2627cc | |||
ec27411b1d | |||
b81bd78327 | |||
8d3a3d29d2 | |||
da7f1488c8 | |||
b439906be4 | |||
65086a9aa3 | |||
95a3e0d544 | |||
d9571b76cf | |||
4a2a27176f | |||
fc43861ba6 | |||
121ba0e54f | |||
7a6930ce2c | |||
e4c2402530 | |||
c6902c6c6b | |||
af414bb720 |
11
.gitignore
vendored
@ -14,9 +14,16 @@
|
||||
|
||||
# Source archive
|
||||
*.tar.xz
|
||||
*.tar.gz
|
||||
*.sig
|
||||
|
||||
# Build directory
|
||||
build/
|
||||
sources/build/
|
||||
sources/build/*/
|
||||
tmp/
|
||||
usr/
|
||||
|
||||
# translations
|
||||
*.qm
|
||||
|
||||
# temporary bckps
|
||||
*~
|
||||
|
12
.gitmodules
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
[submodule "sources/3rdparty/tasks"]
|
||||
path = sources/3rdparty/tasks
|
||||
url = https://github.com/mhogomchungu/tasks.git
|
||||
[submodule "sources/3rdparty/pdebug"]
|
||||
path = sources/3rdparty/pdebug
|
||||
url = https://github.com/arcan1s/qtadds-pdebug.git
|
||||
[submodule "sources/3rdparty/language"]
|
||||
path = sources/3rdparty/language
|
||||
url = https://github.com/arcan1s/qtadds-language.git
|
||||
[submodule "sources/3rdparty/task"]
|
||||
path = sources/3rdparty/task
|
||||
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
|
5
AUTHORS
Normal file
@ -0,0 +1,5 @@
|
||||
Current developers:
|
||||
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
|
||||
|
||||
Translators:
|
||||
@nosada (Japanese translation)
|
282
CHANGELOG
Normal file
@ -0,0 +1,282 @@
|
||||
Ver.1.4.4
|
||||
---------
|
||||
* dataengine
|
||||
- fix profile status definition
|
||||
|
||||
Ver.1.4.3
|
||||
---------
|
||||
* all
|
||||
- fix clang build (#41)
|
||||
- fix WPA_DRIVERS (#40)
|
||||
* library
|
||||
- fix bug in WpaSup class with invalid returning value
|
||||
|
||||
***
|
||||
|
||||
Ver.1.4.2
|
||||
---------
|
||||
* gui
|
||||
* remove Update call to the helper
|
||||
|
||||
Ver.1.4.1
|
||||
---------
|
||||
* all
|
||||
+ some Easter eggs
|
||||
+ add _DEFAULT_SOURCE to avoid gcc warnings
|
||||
* refactoring
|
||||
* fix cppcheck warnings
|
||||
* update 3rdparty components
|
||||
* fix language defilition
|
||||
* replace General section to Common in settings (see http://doc.qt.io/qt-5/qsettings.html#Format-enum)
|
||||
* gui
|
||||
+ allow to change helper control group from UI (#36)
|
||||
+ allow to open profile in an external editor (#38)
|
||||
+ add IP validators (#34)
|
||||
+ add toolbar configuration
|
||||
+ add notification on hidding to tray
|
||||
+ add returnPressed() signal to lineEdits
|
||||
+ implement needToBeConfigured() signal
|
||||
- remove margins
|
||||
- fix bug with segfault on updating UI with KF5
|
||||
* rewrite ErrorWindow class
|
||||
* split MainWindow class
|
||||
* update WiFi menu to new library functions
|
||||
* improve UI (#25, #28)
|
||||
* more correct component checking (#29, #37)
|
||||
* more correct callbacks with exceptions
|
||||
* dataengine
|
||||
+ add desktop reconfiguration (#30)
|
||||
* improve performance
|
||||
* helper
|
||||
+ add /interface interface
|
||||
+ add /ctrl/{CurrentWiFi,VerboseWiFi} calls
|
||||
+ add /netctl/VerboseProfiles call
|
||||
+ add /netctl/{netctlActiveProfile,netctlProfileList,netctlVerboseProfileList) calls
|
||||
* library
|
||||
+ add NetctlInterface class
|
||||
+ add WpaSup::CurrentWiFi method
|
||||
+ append structures some additional information
|
||||
+ mark Netctl::getProfileDescription() as deprecated
|
||||
+ now WpaSup can connect to already created session (by default)
|
||||
* improve performance
|
||||
* plasmoid
|
||||
+ add desktop reconfiguration (#30)
|
||||
- remove legacy functions from KDE4 plasmoid
|
||||
* improve performance of KF5 plasmoid (#26)
|
||||
* test
|
||||
* fix netctl tests
|
||||
|
||||
***
|
||||
|
||||
Ver.1.4.0
|
||||
---------
|
||||
* all
|
||||
* change settings format from shell-like to ini (#24)
|
||||
* dataengine
|
||||
+ create package for KF5
|
||||
* change NETCTLGUI_DEBUG=yes to DEBUG=yes
|
||||
* update url
|
||||
* gui
|
||||
+ add workarounds to #22 and #23
|
||||
* plasmoid
|
||||
+ create package and plugin for KF5
|
||||
* change NETCTLGUI_DEBUG=yes to DEBUG=yes
|
||||
* update url
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.3
|
||||
---------
|
||||
* all
|
||||
* update Japanese translation
|
||||
* dataengine
|
||||
- fix #19
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.2
|
||||
---------
|
||||
* all
|
||||
+ add Japanese translation (thanks to @nosada)
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.1
|
||||
---------
|
||||
* gui
|
||||
* more correct calls of boolean DBus methods
|
||||
* edit helper icon
|
||||
* helper
|
||||
* more correct calls of boolean DBus methods
|
||||
* more correct systemd service
|
||||
* add ability to create session bus
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.0
|
||||
---------
|
||||
* all
|
||||
+ add processes error messages
|
||||
+ add support of several active profiles
|
||||
* some bug fixes and refactoring
|
||||
* rewrite debug messages
|
||||
* dataengine
|
||||
+ add new sources: intIp6, extIp6, netctlAutoStatus
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* change default command to define external IP
|
||||
* change interface list definition
|
||||
* change internal IP definition
|
||||
* gui
|
||||
+ add 3rd party license information
|
||||
+ add system tray icon as an alternative to the plasmoid
|
||||
+ add DBus session interface org.netctlgui.netctlgui
|
||||
+ add dynamic settings load
|
||||
+ add support of openvswitch
|
||||
+ add security notes and API descriptions
|
||||
+ add ability to use helper
|
||||
+ add ability to start minimized/maximized/detached
|
||||
+ add ability to don't save profile from WiFi tab
|
||||
+ add ability to skip external components checking
|
||||
- remove buttons
|
||||
* more correct actions into SettingsWindow
|
||||
* update to library changes
|
||||
* rewrite tables to use toolTip
|
||||
* edit about window
|
||||
* change menuBar
|
||||
* helper
|
||||
+ create daemon DBus system interface org.netctlgui.helper to the library:
|
||||
self control slots, netctl control slots and netctl information slots
|
||||
+ add tests
|
||||
* library
|
||||
+ add custom structures netctlWifiInfo and netctlProfileInfo
|
||||
+ add methods getActiveProfile(), autoGetActiveProfile()
|
||||
+ add slot switchToProfile()
|
||||
+ add slot stopAllProfiles()
|
||||
+ add slot reenableProfile()
|
||||
+ add slots getRecommendedConfiguration()
|
||||
+ add slots forceStartProfile() and forceStopProfile()
|
||||
+ add double quotes to profile names
|
||||
+ add tests
|
||||
- remove functions getProfileDescriptions() and getProfileStatuses()
|
||||
- remove SleepThread class
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* rename getInterfaceList() to getWirelessInterfaceList()
|
||||
* change temporary directory from $HOME/.cache to system one
|
||||
* plasmoid
|
||||
+ add 3rd party license information
|
||||
+ allow plasmoid to use system tray
|
||||
+ add ability to use helper
|
||||
* change all running processes to detached (see #7)
|
||||
* rewrite text label to use tags
|
||||
* update to dataengine changes
|
||||
* edit about window
|
||||
|
||||
***
|
||||
|
||||
Ver.1.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.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
|
@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
netctl-plasmoid
|
||||
netctl-gui
|
||||
Copyright (C) 2014 Evgeniy Alekseev
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
netctl-plasmoid Copyright (C) 2014 Evgeniy Alekseev
|
||||
netctl-gui Copyright (C) 2014 Evgeniy Alekseev
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
37
PKGBUILD
@ -1,37 +0,0 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgname=kdeplasma-applets-netctl
|
||||
_pkgname=netctl-plasmoid
|
||||
pkgver=1.0.0
|
||||
pkgrel=1
|
||||
pkgdesc="Plasmoid written on C++ which interacts with netctl"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcan1s.github.io/projects/netctlplasmoid"
|
||||
license=('GPLv3')
|
||||
depends=('kdebase-workspace')
|
||||
makedepends=('cmake' 'automoc4')
|
||||
source=(https://github.com/arcan1s/netctlplasmoid/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('5ac750e391936a6f3494a819b7b4d0b2')
|
||||
_cmakekeys="-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)
|
||||
-DBUILD_GUI:BOOL=1
|
||||
-DBUILD_PLASMOID:BOOL=1
|
||||
-DCMAKE_BUILD_TYPE=Release"
|
||||
|
||||
prepare() {
|
||||
if [[ -d ${srcdir}/build ]]; then
|
||||
rm -rf "${srcdir}/build"
|
||||
fi
|
||||
mkdir "${srcdir}/build"
|
||||
}
|
||||
|
||||
build () {
|
||||
cd "${srcdir}/build"
|
||||
cmake ${_cmakekeys} ../${_pkgname}
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/build"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
88
README.md
@ -1,4 +1,86 @@
|
||||
netctl-plasmoid
|
||||
===============
|
||||
Netctl GUI
|
||||
==========
|
||||
|
||||
Plasmoid written on C++ which interacts with netctl
|
||||
Information
|
||||
-----------
|
||||
|
||||
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 KDE4/KF5.
|
||||
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/netctl-gui/issues/3)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
It is recommended to use graphical interface for configuration. Configuration files are:
|
||||
|
||||
* `$HOME/.config/netctl-gui.conf` - GUI/helper user configuration
|
||||
* `/etc/netctl-gui.conf` - helper system-wide configuration
|
||||
* `$HOME/.config/plasma-dataengine-netctl.conf` - DataEngine user configuration
|
||||
* `/etc/xdg/plasma-dataengine-netctl.conf` - DataEngine system-wide configuration
|
||||
|
||||
Instruction
|
||||
===========
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
* netctl
|
||||
* qt5-base (if Qt5 is used) or qt4 (if Qt4 is used)
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* kdebase-workspace (KDE4 widget)
|
||||
* plasma-framework (KF5 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:
|
||||
|
||||
cd /path/to/extracted/archive
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Available cmake flags:
|
||||
|
||||
* components:
|
||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
||||
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
|
||||
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
|
||||
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
||||
* additional components:
|
||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
|
||||
* project properties:
|
||||
* `-DDBUS_SYSTEMCONF_PATH=/etc/dbus-1/system.d/` - path to dbus system configuration files
|
||||
* `-DSYSTEMD_SERVICE_PATH=lib/systemd/system` - path to systemd services
|
||||
* `-DUSE_CAPABILITIES:BOOL=0` - do not use setcap to get privileges to the helper
|
||||
* `-DBUILD_KDE4:BOOL=1` - build KDE4 plasmoid instead of KF5 one
|
||||
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
||||
|
||||
Additional information
|
||||
======================
|
||||
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
* [Homepage](http://arcanis.name/projects/netctl-gui)
|
||||
* Page on [kde-apps](http://kde-apps.org/content/show.php?content=164490)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/pkgbase/netctl-gui/) package
|
||||
|
98
arch/PKGBUILD
Normal file
@ -0,0 +1,98 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'plasma5-applet-netctl-gui')
|
||||
pkgver=1.4.4
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('cmake' 'extra-cmake-modules' 'plasma-framework' 'qt5-tools')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('ea5eb54bf0ad29f392c8fe6e5ea2585e')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt5}
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
package_plasma5-applet-netctl-gui() {
|
||||
pkgdesc="A KF5 plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'plasma-framework')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'netctl-gui: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="plasma-netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui() {
|
||||
pkgdesc="Qt5 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt5-base')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui-qt4')
|
||||
conflicts=('libnetctlgui-qt4')
|
||||
|
||||
cd "${srcdir}/build-qt5/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=("libnetctlgui=${pkgver}")
|
||||
provides=('netctlgui-helper-qt4')
|
||||
conflicts=('netctlgui-helper-qt4')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui() {
|
||||
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=("libnetctlgui=${pkgver}" 'xdg-utils')
|
||||
optdepends=('plasma-netctl-gui: KF5 widget'
|
||||
'netctlgui-helper: DBus helper daemon')
|
||||
provides=('netctl-gui-qt4')
|
||||
conflicts=('netctl-gui-qt4')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/build-qt5/resources"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
102
arch/PKGBUILD-qt4
Normal file
@ -0,0 +1,102 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui-qt4
|
||||
_pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.4.4
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4 GUI for netctl. Also provides a widget for KDE4"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${_pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('ea5eb54bf0ad29f392c8fe6e5ea2585e')
|
||||
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt4}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt4}
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
-DBUILD_KDE4:BOOL=1 \
|
||||
"../${_pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${_pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A KDE4 plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
|
||||
'netctl-gui-qt4: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="kdeplasma-applets-netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui-qt4() {
|
||||
pkgdesc="Qt4 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt4')
|
||||
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui')
|
||||
conflicts=('libnetctlgui')
|
||||
install=""
|
||||
|
||||
cd "${srcdir}/build-qt4/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper-qt4() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=("libnetctlgui-qt4=${pkgver}")
|
||||
provides=('netctlgui-helper')
|
||||
conflicts=('netctlgui-helper')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui-qt4() {
|
||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=("libnetctlgui-qt4=${pkgver}")
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'netctlgui-helper-qt4: DBus helper daemon')
|
||||
provides=('netctl-gui')
|
||||
conflicts=('netctl-gui')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/build-qt4/resources"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
14
arch/kdeplasma-applets-netctl-gui.install
Normal file
@ -0,0 +1,14 @@
|
||||
post_install() {
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
11
arch/libnetctlgui.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
true
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
@ -1,13 +1,12 @@
|
||||
post_install() {
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
xdg-icon-resource forceupdate --theme hicolor 2> /dev/null
|
||||
update-desktop-database -q
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install
|
||||
post_install "$1"
|
||||
}
|
11
arch/netctlgui-helper.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
setcap cap_setuid=ep usr/bin/netctlgui-helper 2>/dev/null || chmod +s usr/bin/netctlgui-helper
|
||||
cat << EOF
|
||||
Note: users should be in network group if you want to get them access to the system bus
|
||||
See http://arcanis.name/devs/netctl-gui-security-notes.html#helper
|
||||
EOF
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
14
arch/plasma-netctl-gui.install
Normal file
@ -0,0 +1,14 @@
|
||||
post_install() {
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca5 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
@ -1,23 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARCHIVE="netctl-plasmoid"
|
||||
SRCDIR="sources"
|
||||
FILES="LICENSE README.md"
|
||||
IGNORELIST="CMakeLists.txt.user"
|
||||
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)
|
||||
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
MINOR=$(grep -m1 PROJECT_VERSION_MINOR ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
PATCH=$(grep -m1 PROJECT_VERSION_PATCH ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
ARCHIVE="netctl-gui"
|
||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||
IGNORELIST="build *.qm *.cppcheck .git* *.kdev4"
|
||||
# update submodules
|
||||
git submodule update --init --recursive
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -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 "$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 ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
||||
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -delete; done
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
||||
rm -rf "${ARCHIVE}"
|
||||
|
||||
# update md5sum
|
||||
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD{,-qt4}
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD{,-qt4}
|
||||
# clear
|
||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -delete
|
||||
find arch -type l -xtype l -delete
|
||||
|
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 |
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 |
23
sources/.kdev4/sources.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x14\x00n\x00e\x00t\x00c\x00t\x00l\x00-\x00g\x00u\x00i)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
||||
Build Type=Release
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
218
sources/3rdparty/about/about.ui
vendored
Normal file
@ -0,0 +1,218 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>About</class>
|
||||
<widget class="QWidget" name="About">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>450</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_About">
|
||||
<attribute name="title">
|
||||
<string>About</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_about">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_about">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_version">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_links">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_about">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_ackn">
|
||||
<attribute name="title">
|
||||
<string>Acknowledgement</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_ackn">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_ackn">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>418</width>
|
||||
<height>284</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_translators">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_trdparty">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_ackn">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>229</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_license">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::RichText</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextBrowserInteraction</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
1
sources/3rdparty/language
vendored
Submodule
12
sources/3rdparty/language-config.h
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef LANGUAGE_CONFIG_H
|
||||
#define LANGUAGE_CONFIG_H
|
||||
|
||||
|
||||
// put your languages here comma separated
|
||||
// the first language is default language
|
||||
#define LANGUAGES "en,ja,ru"
|
||||
// language key in the configuration file
|
||||
#define LANGUAGE_KEY "LANGUAGE"
|
||||
|
||||
|
||||
#endif /* LANGUAGE_CONFIG_H */
|
41
sources/3rdparty/listmap/listmap.cpp
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/***************************************************************************
|
||||
* 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 "listmap.h"
|
||||
|
||||
|
||||
QMap<QString, QString> listToMap(const QStringList list)
|
||||
{
|
||||
QMap<QString, QString> map;
|
||||
for (int i=0; i<list.count(); i++) {
|
||||
QStringList str = list[i].split(QString("=="));
|
||||
if (str.count() != 2) continue;
|
||||
map[str[0]] = str[1];
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
QStringList mapToList(const QMap<QString, QString> map)
|
||||
{
|
||||
QStringList list;
|
||||
for (int i=0; i<map.keys().count(); i++)
|
||||
list.append(QString("%1==%2").arg(map.keys()[i]).arg(map[map.keys()[i]]));
|
||||
|
||||
return list;
|
||||
}
|
29
sources/3rdparty/listmap/listmap.h
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/***************************************************************************
|
||||
* 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 LISTMAP_H
|
||||
#define LISTMAP_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
QMap<QString, QString> listToMap(const QStringList list);
|
||||
QStringList mapToList(const QMap<QString,QString> map);
|
||||
|
||||
|
||||
#endif /* LISTMAP_H */
|
1
sources/3rdparty/pdebug
vendored
Submodule
1
sources/3rdparty/task
vendored
Submodule
1
sources/3rdparty/tasks
vendored
Submodule
@ -1,46 +1,93 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
|
||||
cmake_policy (SET CMP0003 OLD)
|
||||
cmake_policy (SET CMP0002 OLD)
|
||||
cmake_policy (SET CMP0011 NEW)
|
||||
cmake_policy (SET CMP0015 NEW)
|
||||
|
||||
project (netctl-plasmoid)
|
||||
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 0)
|
||||
set (PROJECT_VERSION_MINOR 4)
|
||||
set (PROJECT_VERSION_PATCH 4)
|
||||
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 (WITH_DEBUG_MODE "Build with debug mode" OFF)
|
||||
option (USE_CAPABILITIES "Use setcap to set capabilities for the helper" ON)
|
||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||
# components
|
||||
option (BUILD_GUI "Build GUI" ON)
|
||||
option (BUILD_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)
|
||||
|
||||
# verbose
|
||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
||||
option (BUILD_KDE4 "Build on KDE4" OFF)
|
||||
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 (WITH_DEBUG_MODE)
|
||||
add_definitions (-DDEBUG_MODE=1)
|
||||
endif ()
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# avoid newer gcc warnings
|
||||
add_definitions (-D_DEFAULT_SOURCE)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# linker flags
|
||||
set (CMAKE_EXE_LINKER_FLAGS "-lc++abi")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "-lc++abi")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-lc++abi")
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
|
||||
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_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||
set (PROJECT_LIBRARY netctlgui)
|
||||
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||
|
||||
# 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)
|
||||
endif ()
|
||||
@ -48,5 +95,9 @@ if (BUILD_DATAENGINE)
|
||||
add_subdirectory (dataengine)
|
||||
endif ()
|
||||
if (BUILD_PLASMOID)
|
||||
add_subdirectory (plasmoid)
|
||||
if (BUILD_KDE4)
|
||||
add_subdirectory (plasmoid-kde4)
|
||||
else ()
|
||||
add_subdirectory (plasmoid-kf5)
|
||||
endif (BUILD_KDE4)
|
||||
endif ()
|
||||
|
@ -3,30 +3,66 @@ set (SUBPROJECT plasma_engine_netctl)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
if (BUILD_KDE4)
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS}
|
||||
${KDE4_DEFINITIONS})
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
set (KDE_INCLUDE ${KDE4_INCLUDES})
|
||||
else ()
|
||||
find_package (Qt5 REQUIRED COMPONENTS Widgets Network)
|
||||
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
find_package(KF5 REQUIRED COMPONENTS Plasma Service)
|
||||
|
||||
include (KDEInstallDirs)
|
||||
include (KDECMakeSettings)
|
||||
include (KDECompilerSettings)
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS})
|
||||
set (KDE_INCLUDE ${ConfigCore_INCLUDE_DIR}
|
||||
${CoreAddons_INCLUDE_DIR}
|
||||
${Plasma_INCLUDE_DIR}
|
||||
${Service_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
${Qt_INCLUDE}
|
||||
${KDE_INCLUDE})
|
||||
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
|
||||
# prepare
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
|
||||
if (BUILD_KDE4)
|
||||
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})
|
||||
else ()
|
||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
endif ()
|
||||
|
||||
# install
|
||||
if (BUILD_KDE4)
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
else ()
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/dataengine)
|
||||
endif ()
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
||||
|
@ -1,18 +0,0 @@
|
||||
# Configuration file for netctl data engine
|
||||
|
||||
## Commands
|
||||
# command
|
||||
CMD=/usr/bin/netctl
|
||||
# ip command
|
||||
IPCMD=/usr/bin/ip
|
||||
|
||||
## Network
|
||||
# path to list of network devices
|
||||
NETDIR=/sys/class/net/
|
||||
|
||||
## External IP
|
||||
# external ip check command
|
||||
EXTIPCMD=wget -qO- http://ifconfig.me/ip
|
||||
# 'true' - check external IP
|
||||
EXTIP=false
|
||||
|
@ -1,26 +1,42 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* 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-plasmoid is distributed in the hope that it will be useful, *
|
||||
* 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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctl.h"
|
||||
|
||||
#include <Plasma/DataContainer>
|
||||
#include <QDir>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
#include <version.h>
|
||||
|
||||
// KF5-KDE4 compability
|
||||
#ifdef BUILD_KDE4
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#else
|
||||
#include <QStandardPaths>
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
@ -28,201 +44,276 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
initSources();
|
||||
}
|
||||
|
||||
|
||||
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("info"));
|
||||
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()
|
||||
QString Netctl::getCmdOutput(const QString cmd)
|
||||
{
|
||||
// default configuration
|
||||
checkExtIP = QString("false");
|
||||
cmd = QString("/usr/bin/netctl");
|
||||
extIpCmd = QString("wget -qO- http://ifconfig.me/ip");
|
||||
ipCmd = QString("/usr/bin/ip");
|
||||
netDir = QString("/sys/class/net/");
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
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;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
fileStr = QString(confFile.readLine());
|
||||
if (confFile.atEnd())
|
||||
break;
|
||||
else if (fileStr[0] != '#') {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIP"))
|
||||
checkExtIP = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("CMD"))
|
||||
cmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIPCMD"))
|
||||
extIpCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("IPCMD"))
|
||||
ipCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("NETDIR"))
|
||||
netDir = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
confFile.close();
|
||||
return true;
|
||||
void Netctl::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString fileName;
|
||||
#ifdef BUILD_KDE4
|
||||
fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-netctl.conf");
|
||||
#else
|
||||
fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-netctl.conf"));
|
||||
#endif /* BUILD_KDE4 */
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl")).toString();
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto")).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("External IP"));
|
||||
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false")).toString();
|
||||
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com")).toString();
|
||||
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false")).toString();
|
||||
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com")).toString();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Source name" << name;
|
||||
|
||||
return updateSourceEvent(name);
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getExtIp(const QString cmd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
// test network connection
|
||||
if (!isNetworkActive()) return QString("N\\A");
|
||||
|
||||
return getCmdOutput(cmd).trimmed();
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getInfo(const QStringList profiles, const QStringList statuses)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (profiles.count() != statuses.count()) return QString("N\\A");
|
||||
|
||||
QStringList list;
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
list.append(QString("%1 (%2)").arg(profiles[i]).arg(statuses[i]));
|
||||
if (list.isEmpty()) list.append(QString("N\\A"));
|
||||
|
||||
return list.join(QString(" | "));
|
||||
}
|
||||
|
||||
|
||||
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] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||
if (rawList[i].protocol() != protocol) continue;
|
||||
intIp = rawList[i].toString();
|
||||
break;
|
||||
}
|
||||
|
||||
return intIp;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoStatus = true;
|
||||
QString output = getCmdOutput(QString("%1 list").arg(cmdNetctlAuto)).trimmed();
|
||||
if (output.isEmpty()) {
|
||||
output = getCmdOutput(QString("%1 list").arg(cmdNetctl)).trimmed();
|
||||
netctlAutoStatus = false;
|
||||
}
|
||||
|
||||
// parse
|
||||
QStringList currentProfiles;
|
||||
QStringList profileList = output.split(QChar('\n'));
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
if (profileList[i][0] != QChar('*')) continue;
|
||||
currentProfiles.append(profileList[i]);
|
||||
}
|
||||
// remove first symbols
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
profileList[i].remove(0, 2);
|
||||
for (int i=0; i<currentProfiles.count(); i++)
|
||||
currentProfiles[i].remove(0, 2);
|
||||
|
||||
// return profiles
|
||||
currentProfile = currentProfiles;
|
||||
status = !currentProfiles.isEmpty();
|
||||
return profileList;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList status;
|
||||
if (netctlAutoStatus) {
|
||||
status.append(QString("netctl-auto"));
|
||||
return status;
|
||||
}
|
||||
|
||||
for (int i=0; i<currentProfile.count(); i++) {
|
||||
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(currentProfile[i]));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
status.append(QString("static"));
|
||||
} else
|
||||
status.append(QString("enabled"));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
void Netctl::initSources()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList sourcesList = sources();
|
||||
for (int i=0; i<sourcesList.count(); i++)
|
||||
setData(sourcesList[i], QString("value"), QString("N\\A"));
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isNetworkActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("ping -c 1 google.com");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
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(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString("")) {
|
||||
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;
|
||||
}
|
||||
QString value = QString("N\\A");
|
||||
if (source == QString("active")) {
|
||||
value = status ? QString("true") : QString("false");
|
||||
} else if (source == QString("current")) {
|
||||
value = currentProfile.join(QChar('|'));
|
||||
} else if (source == QString("extip4")) {
|
||||
if (configuration[QString("EXTIP4")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
||||
} else if (source == QString("extip6")) {
|
||||
if (configuration[QString("EXTIP6")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
||||
} else if (source == QString("info")) {
|
||||
value = getInfo(currentProfile, currentStatus);
|
||||
} 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 = netctlAutoStatus ? QString("true") : QString("false");
|
||||
} else if (source == QString("profiles")) {
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
|
||||
} else if (source == QString("status")) {
|
||||
currentStatus = getProfileStringStatus(configuration[QString("NETCTLCMD")]);
|
||||
value = currentStatus.join(QChar('|'));
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("extIp")) {
|
||||
if (checkExtIP == QString("true")) {
|
||||
command.start(extIpCmd);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString(""))
|
||||
value = cmdOutput.split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("interfaces")) {
|
||||
if (QDir(netDir).exists())
|
||||
value = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot).join(QString(","));
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
else if (source == QString("intIp")) {
|
||||
if (QDir(netDir).exists()) {
|
||||
value = QString("127.0.0.1/8");
|
||||
QStringList netDevices = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<netDevices.count(); i++)
|
||||
if (netDevices[i] != QString("lo")) {
|
||||
cmdOutput = QString("");
|
||||
command.start(ipCmd + QString(" addr show ") + netDevices[i]);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString("")) {
|
||||
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(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
QStringList list;
|
||||
if (cmdOutput != QString("")) {
|
||||
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(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
value = QString("false");
|
||||
if (cmdOutput != QString("")) {
|
||||
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(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
QString currentProfile;
|
||||
if (cmdOutput != QString("")) {
|
||||
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(cmd + QString(" status ") + currentProfile);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString("")) {
|
||||
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].indexOf(QString("enabled")) > -1) {
|
||||
value = QString("enabled");
|
||||
break;
|
||||
}
|
||||
else if (profile[i].indexOf(QString("static")) > -1) {
|
||||
value = QString("static");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_KDE4
|
||||
K_EXPORT_PLASMA_DATAENGINE(netctl, Netctl)
|
||||
#else
|
||||
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(netctl, Netctl, "plasma-dataengine-netctl.json")
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
#include "netctl.moc"
|
||||
|
@ -1,24 +1,26 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* 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-plasmoid is distributed in the hope that it will be useful, *
|
||||
* 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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NETCTL_DE_H
|
||||
#define NETCTL_DE_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
#include <QAbstractSocket>
|
||||
|
||||
|
||||
class Netctl : public Plasma::DataEngine
|
||||
{
|
||||
@ -26,24 +28,34 @@ class Netctl : public Plasma::DataEngine
|
||||
|
||||
public:
|
||||
Netctl(QObject *parent, const QVariantList &args);
|
||||
~Netctl();
|
||||
QString getExtIp(const QString cmd);
|
||||
QString getInfo(const QStringList profiles, const QStringList statuses);
|
||||
QStringList getInterfaceList();
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl);
|
||||
bool isNetworkActive();
|
||||
|
||||
public slots:
|
||||
void initSources();
|
||||
|
||||
protected:
|
||||
bool readConfiguration();
|
||||
bool sourceRequestEvent(const QString &name);
|
||||
bool updateSourceEvent(const QString &source);
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
bool netctlAutoStatus = false;
|
||||
bool status = false;
|
||||
QStringList currentProfile;
|
||||
QStringList currentStatus;
|
||||
// configuration
|
||||
// enable check external IP
|
||||
QString checkExtIP;
|
||||
// path to netctl command
|
||||
QString cmd;
|
||||
// command to check external IP
|
||||
QString extIpCmd;
|
||||
// path to ip command
|
||||
QString ipCmd;
|
||||
// path to directory with network device configuration
|
||||
QString netDir;
|
||||
bool debug;
|
||||
QMap<QString, QString> configuration;
|
||||
QString getCmdOutput(const QString cmd);
|
||||
void readConfiguration();
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTL_DE_H */
|
||||
|
9
sources/dataengine/plasma-dataengine-netctl.conf
Normal file
@ -0,0 +1,9 @@
|
||||
[Netctl commands]
|
||||
NETCTLCMD=/usr/bin/netctl
|
||||
NETCTLAUTOCMD=/usr/bin/netctl-auto
|
||||
|
||||
[External IP]
|
||||
EXTIP4CMD=curl ip4.telize.com
|
||||
EXTIP4=false
|
||||
EXTIP6CMD=curl ip6.telize.com
|
||||
EXTIP6=false
|
@ -1,20 +1,20 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Netctl DataEngine
|
||||
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
|
||||
X-Plasma-EngineName=netctl
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=netctl
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid
|
||||
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui/
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
@ -5,6 +5,9 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
# set directories
|
||||
set (SUBPROJECT_BINARY_DIR bin)
|
||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set (SUBPROJECT_DOCS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
|
||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
|
||||
# executable path
|
||||
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
|
||||
|
||||
@ -13,7 +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 ${SUBPROJECT}-logo.png DESTINATION share/pixmaps/)
|
||||
install (FILES ${SUBPROJECT}.png DESTINATION share/icons/hicolor/32x32/apps/)
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
|
||||
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
|
||||
install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT})
|
||||
|
115
sources/gui/bash-completions
Normal file
@ -0,0 +1,115 @@
|
||||
###########################################################################
|
||||
# This file is part of netctl-gui #
|
||||
# #
|
||||
# netctl-gui is free software: you can redistribute it and/or #
|
||||
# modify it under the terms of the GNU General Public License as #
|
||||
# published by the Free Software Foundation, either version 3 of the #
|
||||
# License, or (at your option) any later version. #
|
||||
# #
|
||||
# netctl-gui is distributed in the hope that it will be useful, #
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
||||
# GNU General Public License for more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License #
|
||||
# along with netctl-gui. If not, see http://www.gnu.org/licenses/ #
|
||||
###########################################################################
|
||||
|
||||
|
||||
# variables
|
||||
_netctl_gui_arglist=(
|
||||
'--detached'
|
||||
'--maximized'
|
||||
'--minimized'
|
||||
'--about'
|
||||
'--netctl-auto'
|
||||
'--settings'
|
||||
'-e'
|
||||
'--essid'
|
||||
'-o'
|
||||
'--open'
|
||||
'-s'
|
||||
'--select'
|
||||
'-c'
|
||||
'--config'
|
||||
'-d'
|
||||
'--debug'
|
||||
'--default'
|
||||
'--set-opts'
|
||||
'-t'
|
||||
'--tab'
|
||||
'-v'
|
||||
'--version'
|
||||
'-i'
|
||||
'--info'
|
||||
'-h'
|
||||
'--help'
|
||||
)
|
||||
|
||||
_netctl_gui_settings=(
|
||||
'CLOSE_HELPER'
|
||||
'CLOSETOTRAY'
|
||||
'CTRL_DIR'
|
||||
'CTRL_GROUP'
|
||||
'FORCE_SUDO'
|
||||
'HELPER_PATH'
|
||||
'HELPER_SERVICE'
|
||||
'IFACE_DIR'
|
||||
'LANGUAGE'
|
||||
'NETCTL_PATH'
|
||||
'NETCTLAUTO_PATH'
|
||||
'NETCTLAUTO_SERVICE'
|
||||
'PID_FILE'
|
||||
'PREFERED_IFACE'
|
||||
'PROFILE_DIR'
|
||||
'RFKILL_DIR'
|
||||
'SKIPCOMPONENTS'
|
||||
'STARTTOTRAY'
|
||||
'SUDO_PATH'
|
||||
'SYSTEMCTL_PATH'
|
||||
'SYSTRAY'
|
||||
'USE_HELPER'
|
||||
'WPACLI_PATH'
|
||||
'WPASUP_PATH'
|
||||
'WPA_DRIVERS'
|
||||
)
|
||||
|
||||
_netctl_gui_tabs=(
|
||||
'1'
|
||||
'2'
|
||||
'3'
|
||||
)
|
||||
|
||||
_netctl_profiles() {
|
||||
echo $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
|
||||
}
|
||||
|
||||
|
||||
# work block
|
||||
_netctl_gui() {
|
||||
COMPREPLY=()
|
||||
wantfiles='-@(c|-config)'
|
||||
wantprofiles='-@(o|-open|s|-select)'
|
||||
wantsettings='-@(-set-opts)'
|
||||
wantstring='-@(e|-essid)'
|
||||
wanttabs='-@(t|-tab)'
|
||||
_get_comp_words_by_ref cur prev words cword
|
||||
|
||||
if [[ $prev = $wantfiles ]]; then
|
||||
_filedir
|
||||
elif [[ $prev = $wantprofiles ]]; then
|
||||
COMPREPLY=($(compgen -W '$(_netctl_profiles)' -- "$cur"))
|
||||
elif [[ $prev = $wantsettings ]]; then
|
||||
COMPREPLY=($(compgen -S ',' -W '${_netctl_gui_settings[@]}' -- "$cur"))
|
||||
elif [[ $prev = $wantstring ]]; then
|
||||
COMPREPLY=()
|
||||
elif [[ $prev = $wanttabs ]]; then
|
||||
COMPREPLY=($(compgen -W '${_netctl_gui_tabs[@]}' -- "$cur"))
|
||||
else
|
||||
COMPREPLY=($(compgen -W '${_netctl_gui_arglist[@]}' -- "$cur"))
|
||||
fi
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
complete -F _netctl_gui netctl-gui
|
12
sources/gui/docs/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# build pages
|
||||
file (GLOB SUBPROJECT_DOCS_IN *.html)
|
||||
file (GLOB SUBPROJECT_IMGS *.png)
|
||||
|
||||
foreach (DOC_IN ${SUBPROJECT_DOCS_IN})
|
||||
file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN})
|
||||
configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
endforeach ()
|
||||
|
||||
install (FILES ${SUBPROJECT_DOCS} DESTINATION share/doc/${PROJECT_NAME})
|
||||
install (FILES ${SUBPROJECT_IMGS} DESTINATION share/doc/${PROJECT_NAME})
|
BIN
sources/gui/docs/architecture.png
Normal file
After Width: | Height: | Size: 40 KiB |
478
sources/gui/docs/netctl-gui-dbus-api.html
Normal file
@ -0,0 +1,478 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>netctl-gui DBus API desription</title>
|
||||
<style type="text/css">
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
th, td {
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #000000;
|
||||
};
|
||||
td {
|
||||
text-align: justify;
|
||||
}
|
||||
th {
|
||||
text-align: center;
|
||||
}
|
||||
th.sub {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
small {
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>netctl-gui DBus API description</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#api">DBus API</a></li>
|
||||
<li><a href="#helper">Helper API</a></li>
|
||||
<li><a href="#ctrl">Helper ctrl API</a></li>
|
||||
<li><a href="#interface">Helper interface API</a></li>
|
||||
<li><a href="#netctl">Helper netctl API</a></li>
|
||||
<li><a href="#gui">GUI API</a></li>
|
||||
<li><a href="#netctlgui">GUI netctlgui API</a></li>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
|
||||
<h2><a href="#api" class="anchor" id="api"></a>DBus API</h2>
|
||||
<table>
|
||||
<tbody><tr>
|
||||
<th>method</th>
|
||||
<th>responce</th>
|
||||
<th>run as root</th>
|
||||
</tr>
|
||||
<!-- helper service -->
|
||||
<tr>
|
||||
<th colspan="3"><a href="#helper" class="anchor" id="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th>
|
||||
</tr>
|
||||
<!-- /ctrl path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#ctrl" class="anchor" id="ctrl"></a><code>/ctrl</code> path</th>
|
||||
</tr>
|
||||
<!-- helper actions -->
|
||||
<tr>
|
||||
<td>bool Active()</td>
|
||||
<td><code>true</code> if the helper is active</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ApiDocs()</td>
|
||||
<td>returns path to this API documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Close()</td>
|
||||
<td><code>true</code> and closes the helper</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList FindSettings()</td>
|
||||
<td>scans system and suggests the recommended configuration which may be used by the library</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString LibraryDocs()</td>
|
||||
<td>returns path to the library documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString Pony()</td>
|
||||
<td>prints Pinkie Pie to stdout. Really, just try</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString SecurityDocs()</td>
|
||||
<td>returns path to the security documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Settings()</td>
|
||||
<td>current helper settings <code>KEY==VALUE</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList UIDs()</td>
|
||||
<td>returns the helper process UIDs <code>[UID, EUID]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Update()</td>
|
||||
<td>calls update the helper configuration. Returns <code>true</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- netctl actions -->
|
||||
<tr>
|
||||
<td>bool Enable(QString profile)</td>
|
||||
<td>enables or disables the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool forceStart(QString profile)</td>
|
||||
<td>force starts the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool forceStop(QString profile)</td>
|
||||
<td>force stops the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Reenable(QString profile)</td>
|
||||
<td>reenables the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Restart(QString profile)</td>
|
||||
<td>restarts the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Start(QString profile)</td>
|
||||
<td>starts or stops the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool StopAll()</td>
|
||||
<td>stops all active profiles. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool SwitchTo(QString profile)</td>
|
||||
<td>switchs to the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Create(QString profile, QStringList settingsList)</td>
|
||||
<td>creates the profile with specified settings. Settings should be given in the format <code>KEY==VALUE</code>. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Remove(QString profile)</td>
|
||||
<td>removes the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- netctl-auto actions -->
|
||||
<tr>
|
||||
<td>bool autoDisableAll()</td>
|
||||
<td>disables all profiles (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoEnable(QString profile)</td>
|
||||
<td>enables or disables the profile (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoEnableAll()</td>
|
||||
<td>enables all profiles (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoStart(QString profile)</td>
|
||||
<td>switchs to the profile (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>no?</td>
|
||||
</tr>
|
||||
<!-- netctl-auto service actions -->
|
||||
<tr>
|
||||
<td>bool autoServiceEnable()</td>
|
||||
<td>enables or disables netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoServiceRestart()</td>
|
||||
<td>restarts netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool autoServiceStart()</td>
|
||||
<td>starts or stops netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- wpa_supplicant actions -->
|
||||
<tr>
|
||||
<td>QStringList CurrentWiFi()</td>
|
||||
<td>returns current WiFi point in format <code>NAME|SECURITY|TYPE|FREQ|MAC|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList VerboseWiFi()</td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|TYPE|FREQS|MACS|SIGNAL|ACTIVE|EXISTS</code>. First line is always active connection (see <code>CurrentWiFi()</code>)</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList WiFi()</td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- /interface path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#interface" class="anchor" id="interface"></a><code>/interface</code> path</th>
|
||||
</tr>
|
||||
<!-- netctl control -->
|
||||
<tr>
|
||||
<td>int Enable(QString profile)</td>
|
||||
<td>enables or disables the profile. Returns is the profile enabled or <code>2</code> if there was an another error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Restart(QString profile)</td>
|
||||
<td>restarts the profile. Returns is the profile active or <code>2</code> if there was an error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Start(QString profile)</td>
|
||||
<td>starts or stops the profile. Returns is the profile active or <code>2</code> if there was an error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool StopAll()</td>
|
||||
<td>synonym of <code>/ctlr/StopAll()</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool SwitchTo(QString profile)</td>
|
||||
<td>switchs to the profile (works with netctl and netctl-auto). Returns is the profile active or <code>2</code> if there was an error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int 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>1</code> if action has been performed successfully, <code>0</code> if there was an error in the profile copying and <code>2</code> if there was an another error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Profile(QString profile)</td>
|
||||
<td>synonym of <code>/netctl/Profile()</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Remove(QString profile)</td>
|
||||
<td>synonym of <code>/ctrl/Remove()</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- information -->
|
||||
<tr>
|
||||
<td>QStringList Information()</td>
|
||||
<td>returns general information in format <code>[IsNetctlAutoActive, NetctlProfiles, NetctlAutoProfiles]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Status()</td>
|
||||
<td>returns actual information in format <code>[IsNetctlAutoActive, ProfilesNames, ActiveProfile, ActiveProfileEnables]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- wpa_supplicant actions -->
|
||||
<tr>
|
||||
<td>int Essid(QString essid, QStringList settingsList)</td>
|
||||
<td>connects to WiFi point with the given ESSID, calls KnownEssid or UnknownESSID depending on whether there is a profile. Settings may be empty. To get return codes refer to <code>KnownEssid()</code> and <code>UnknownEssid()</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int KnownEssid(QString essid)</td>
|
||||
<td>connects to WiFi point with the given ESSID with existent profile. Returns <code>Start()</code> if ok, in other cases returns <code>2</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int UnknownEssid(QString essid, QStringList settingsList)</td>
|
||||
<td>creates a profile and connects to WiFi point with the given ESSID. Returns <code>Start()</code> if ok, in other cases returns <code>2</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- /netctl path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th>
|
||||
</tr>
|
||||
<!-- general information -->
|
||||
<tr>
|
||||
<td>QString ActiveProfile()</td>
|
||||
<td>returns active profile from netctl or netctl-auto</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ActiveProfileStatus()</td>
|
||||
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Information()</td>
|
||||
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString netctlActiveProfile()</td>
|
||||
<td>returns active profile from netctl even if netctl-auto is running</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList netctlProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code> from netctl even if netctl-auto is running</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList netctlVerboseProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|TYPE|INTERFACE|ESSID|ACTIVE|ENABLED|NETCTL-AUTO</code> from netctl even if netctl-auto is running</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 VerboseProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|TYPE|INTERFACE|ESSID|ACTIVE|ENABLED|NETCTL-AUTO</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>
|
||||
<tr>
|
||||
<td>QStringList ProfileValues(QString profile, QStringList keys)</td>
|
||||
<td>returns values of the keys by the given profile or empty lines</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- gui service -->
|
||||
<tr>
|
||||
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
|
||||
</tr>
|
||||
<!-- gui actions -->
|
||||
<tr>
|
||||
<td>bool Active()</td>
|
||||
<td><code>true</code> if the application is active</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>void ApiDocs()</td>
|
||||
<td>opens this API documentation</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Close()</td>
|
||||
<td><code>true</code> and closes the application</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>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>
|
||||
</table>
|
||||
|
||||
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
|
||||
<ul>
|
||||
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
||||
<small>
|
||||
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||
This software is licensed under @PROJECT_LICENSE@
|
||||
</small>
|
||||
|
||||
</body>
|
||||
</html>
|
112
sources/gui/docs/netctl-gui-security-notes.html
Normal file
@ -0,0 +1,112 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>netctl-gui secutiry notes</title>
|
||||
<style type="text/css">
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
small {
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>netctl-gui security notes</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#arch">Architecture</a></li>
|
||||
<li><a href="#library">Library</a></li>
|
||||
<li><a href="#helper">Helper</a></li>
|
||||
<li><a href="#gui">Graphical interface</a></li>
|
||||
<li><a href="#kde">KDE components</a></li>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
|
||||
<h2><a href="#description" class="anchor" id="description"></a>Description</h2>
|
||||
<p></p>
|
||||
|
||||
<h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
|
||||
<img src="architecture.png" alt="architecture">
|
||||
|
||||
<h2><a href="#library" class="anchor" id="library"></a>Library</h2>
|
||||
<p>According to <a href="#arch">the scheme</a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
|
||||
<ul>
|
||||
<li>Netctl control module</li>
|
||||
<li><ul>
|
||||
<li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable <profile></code>. They are commands which provide a general control to netctl.</li>
|
||||
<li><code>systemctl start|restart|enable <netctl-auto@service></code>. They are commands which provide ability to control netctl-auto systemd service.</li>
|
||||
</ul></li>
|
||||
<li>Netctl profiles module</li>
|
||||
<li><ul>
|
||||
<li>Copying of a temporary profile from home directory to netctl profiles directory. <code>cp</code> command is used for it.</li>
|
||||
<li>Removal of a profile. <code>rm</code> command is used for it.</li>
|
||||
</ul></li>
|
||||
<li>WiFi module</li>
|
||||
<li><ul>
|
||||
<li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
|
||||
|
||||
<p>Profiles reading should be described. Since profiles has shell-like syntax some variables (which provide an array) cannot be reading by usual ways. To do it library uses bash:</p>
|
||||
<pre>
|
||||
# define system variables
|
||||
env -i bash -c "set"
|
||||
# get profile and system variable list
|
||||
env -i bash -c "source '<profile>'; set"
|
||||
# get profile variables
|
||||
env -i bash -c "source '<profile>'; for i in ${!<key>[@]}; do echo ${<key>[$i]}; done"
|
||||
</pre>
|
||||
|
||||
<h2><a href="#helper" class="anchor" id="helper"></a>Helper</h2>
|
||||
<p>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>network</code> group by default (or must be root). But you may change it by editing <code>$DBUS_SYSTEMCONF_PATH/org.netctlgui.helper.conf</code> policy file (<code>/etc/dbus-1/system.d/org.netctlgui.helper.conf</code> by default). Please refer to DBus documentation to do it.</p>
|
||||
|
||||
<p>By default <code>netctgui-helper</code> binary has capabilities to set UID to the children processes (<code>CAP_SETUID</code>). If you do not want to get these capabilities you may use <code>-DUSE_CAPABILITIES</code> cmake flag. Please refer to <code>man 7 capabilities</code> for more details.</p>
|
||||
|
||||
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
|
||||
|
||||
<h2><a href="#gui" class="anchor" id="gui"></a>Graphical interface</h2>
|
||||
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
|
||||
|
||||
<h2><a href="#kde" class="anchor" id="kde"></a>KDE components</h2>
|
||||
<p>There are two netctl-based commands which are run from the DataEngine</p>
|
||||
<ul>
|
||||
<li><code><cmd> list</code></li>
|
||||
<li><code>netctl is-enabled <profile></code></li>
|
||||
</ul>
|
||||
<p>Both of them do not require any additional privileges normally. Also DataEngine has two other command which will be run from; they should define external IP. According to the idea that user can set <b>any</b> command to run, this module is not secure. But running commands will not do more than user can do from console himself.</p>
|
||||
|
||||
<p>The widget gets information from DataEngine, thus it does not require any additional permissions to show information. But netctl calls are used to control netctl. In this case used commands are</p>
|
||||
<ul>
|
||||
<li><code>netctl enable <profile></code></li>
|
||||
<li><code>netctl disable <profile></code></li>
|
||||
<li><code>netctl restart <profile></code></li>
|
||||
<li><code>netctl start <profile></code></li>
|
||||
<li><code>netctl stop <profile></code></li>
|
||||
<li><code>netctl stop-all</code></li>
|
||||
<li><code>netctl switch-to <profile></code></li>
|
||||
<li><code>netctl-auto switch-to <profile></code></li>
|
||||
</ul>
|
||||
<p>All netctl-based commands <b>require</b> root privileges and <code>sudo</code> (and any other alternatives) is used normally as prefix to the commands. The netctl-auto command <b>does not require</b> additional permissions.</p>
|
||||
|
||||
<p>The other way is to use DBus communication with <a href="#helper">the helper</a>. In this case user should have rights to start the helper.</p>
|
||||
|
||||
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
|
||||
<ul>
|
||||
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
||||
<small>
|
||||
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||
This software is licensed under @PROJECT_LICENSE@
|
||||
</small>
|
||||
|
||||
</body>
|
||||
</html>
|
BIN
sources/gui/docs/rawscheme.ppt
Normal file
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 netctl-gui.conf (5)
|
||||
.SH STANDARDS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html
|
||||
for more details.
|
||||
.SH SECURITY CONSIDERATIONS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html
|
||||
for more details.
|
||||
.SH AUTHOR
|
||||
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
|
||||
.SH LICENSE
|
||||
This software is licensed under @PROJECT_LICENSE@
|
10
sources/gui/netctl-gui.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=Netctl GUI
|
||||
Comment=Qt graphical user interface for netctl
|
||||
Exec=netctl-gui
|
||||
Icon=netctl-gui.png
|
||||
Terminal=false
|
||||
Encoding=UTF-8
|
||||
Type=Application
|
||||
Categories=Network
|
144
sources/gui/netctl.profile
Normal file
@ -0,0 +1,144 @@
|
||||
! - обязательное поле
|
||||
[ddsg] - условие для этой опции
|
||||
в массиве первая опция - дефолт
|
||||
yes - бинарная опция, по дефолту стоит no (и наоборот)
|
||||
|
||||
GENERAL
|
||||
=======
|
||||
Description=
|
||||
! Connection=ethernet|wireless|bond|bridge|dummy|pppoe|mobile_ppp|tunnel|tuntap|vlan
|
||||
! Interface=
|
||||
BindsToInterfaces=(массив интерфейсов, которые будет ожидать этот профиль)
|
||||
After=(список профилей, которые будут запущены перед этим)
|
||||
ExecUpPost=команда, которая будет запущена после
|
||||
ExecDownPre=команда, которая будет запущена перед
|
||||
ForceConnect=yes - включить, даже если интерфейс уже поднят
|
||||
|
||||
IP
|
||||
==
|
||||
! IP=static|dhcp|no
|
||||
! IP6=static|stateless|dhcp-noaddr|dhcp|no
|
||||
[IP=static] Address=('192.168.1.23/24' '192.168.1.87/24')
|
||||
[IP=static] Gateway='192.168.1.1'
|
||||
Routes=('192.168.0.0/24 via 192.168.1.2')
|
||||
[IP6=static]|[IP6=stateless] Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
|
||||
[IP6=static]|[IP6=stateless] Gateway6='1234:0:123::abcd'
|
||||
Routes6=('192.168.0.0/24 via 192.168.1.2')
|
||||
[IP=dhcp] DHCPClient=dhcpcd|dhclient
|
||||
[IP=dhcp] DHCPReleaseOnStop=yes - release the DHCP lease when the profile is stopped.
|
||||
[IP=dhcp][DHCPClient=dhcpcd] DhcpcdOptions=опции
|
||||
[IP=dhcp][DHCPClient=dhclient] DhclientOptions=опции
|
||||
[IP=dhcp][DHCPClient=dhclient] DhclientOptions6=опции
|
||||
IPCustom=('addr add dev eth0 192.168.1.23/24 brd +' 'route add default via 192.168.1.1') - команда для ip напрямую
|
||||
Hostname=
|
||||
DNS=('192.168.1.1')
|
||||
DNSDomain= domain для /etc/resolv.conf
|
||||
DNSSearch= search для /etc/resolv.conf
|
||||
DNSOptions=() массив options для /etc/resolv.conf
|
||||
TimeoutDHCP=30 - время в секундах
|
||||
TimeoutDAD=3 - время в секундах для ipv6 удаление дубликата
|
||||
|
||||
ETHERNET
|
||||
========
|
||||
SkipNoCarrier=yes
|
||||
Auth8021X=yes
|
||||
WPAConfigFile=/etc/wpa_supplicant.conf
|
||||
WPADriver=wired|nl80211|wext
|
||||
TimeoutCarrier=5
|
||||
TimeoutWPA=15
|
||||
+ IP
|
||||
|
||||
WIRELESS
|
||||
========
|
||||
Security=none|wep|wpa|wpa-configsection|wpa-config
|
||||
! ESSID=
|
||||
AP=MAC address
|
||||
[Security=wep]|[Security=wpa] ! Key='superpass'
|
||||
Hidden=yes
|
||||
AdHoc=yes
|
||||
ScanFrequencies=A space-separated list of frequencies in MHz to scan when searching for the network.
|
||||
Priority=0
|
||||
[Security=wpa-configsection] ! WPAConfigSection=(
|
||||
'ssid="University"'
|
||||
'key_mgmt=WPA-EAP'
|
||||
'eap=TTLS'
|
||||
'group=TKIP'
|
||||
'pairwise=TKIP CCMP'
|
||||
'anonymous_identity="anonymous"'
|
||||
'identity="myusername"'
|
||||
'password="mypassword"'
|
||||
'priority=1'
|
||||
'phase2="auth=PAP"'
|
||||
)
|
||||
WPAConfigFile=/etc/wpa_supplicant.conf
|
||||
Country=страна
|
||||
WPAGroup=wheel (группа)
|
||||
WPADriver=nl80211,wext
|
||||
TimeoutWPA=15
|
||||
RFKill=for X in 0..2 $(cat /sys/class/rfkill/rfkillX/name)|auto
|
||||
ExcludeAuto=yes
|
||||
+ IP
|
||||
|
||||
BOND
|
||||
====
|
||||
! BindsToInterfaces=
|
||||
+ IP
|
||||
|
||||
BRIDGE
|
||||
======
|
||||
! BindsToInterfaces=
|
||||
+ IP
|
||||
|
||||
DUMMY
|
||||
=====
|
||||
+ IP
|
||||
|
||||
PPPOE
|
||||
=====
|
||||
-User='example@yourprovider.com'
|
||||
-Password='very secret'
|
||||
ConnectionMode=persist|demand
|
||||
[ConnectionMode=demand] IdleTimeout=0
|
||||
MaxFail=5
|
||||
DefaultRoute=false
|
||||
UsePeerDNS=false
|
||||
PPPUnit=ppp0|ppp1|...
|
||||
-LCPEchoInterval=30
|
||||
-LCPEchoFailure=4
|
||||
OptionsFile=доп файл
|
||||
PPPoEService=имя
|
||||
PPPoEAC=имя
|
||||
PPPoESession='sessid:macaddr'
|
||||
PPPoEMAC=мак
|
||||
PPPoEIP6=yes
|
||||
|
||||
MOBILE_PPP
|
||||
==========
|
||||
MaxFail=5
|
||||
DefaultRoute=false
|
||||
UsePeerDNS=false
|
||||
-User='example@yourprovider.com'
|
||||
-Password='very secret'
|
||||
AccessPointName=имя
|
||||
Pin=код
|
||||
Mode=None|3Gpref|3Gonly|GPRSpref|GPRSonly
|
||||
OptionsFile=доп файл
|
||||
|
||||
TUNNEL
|
||||
======
|
||||
Mode=ipip|gre|sit|isatap|ip6ip6|ipip6|ip6gre|any
|
||||
Local='172.16.0.1'
|
||||
Remote='216.66.80.26'
|
||||
+ ip
|
||||
|
||||
TUNTAP
|
||||
======
|
||||
Mode=tun|tap
|
||||
User='nobody'
|
||||
Group='nobody'
|
||||
+ ip
|
||||
|
||||
VLAN
|
||||
====
|
||||
! BindsToInterfaces=
|
||||
VLANID=55
|
@ -1,28 +1,61 @@
|
||||
# set files
|
||||
file (GLOB SOURCES *.cpp)
|
||||
file (GLOB HEADERS *.h)
|
||||
file (GLOB FORMS *.ui)
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.h)
|
||||
file (GLOB_RECURSE FORMS *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
|
||||
|
||||
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
|
||||
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
|
||||
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
|
||||
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
|
||||
|
||||
# include_path
|
||||
include_directories (${SUBPROJECT_SOURCE_DIR}
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||
|
||||
find_package (Qt4 REQUIRED)
|
||||
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 ${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})
|
||||
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
|
||||
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
||||
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} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
|
||||
# install properties
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
|
107
sources/gui/src/aboutwindow.cpp
Normal file
@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
* 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/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>
|
70
sources/gui/src/bridgewidget.cpp
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/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "bridgewidget.h"
|
||||
#include "ui_bridgewidget.h"
|
||||
|
||||
|
||||
BridgeWidget::BridgeWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::BridgeWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
BridgeWidget::~BridgeWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void BridgeWidget::clear()
|
||||
{
|
||||
ui->checkBox_skip->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> BridgeWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->checkBox_skip->checkState() == Qt::Checked)
|
||||
settings[QString("SkipForwardingDelay")] = QString("yes");
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int BridgeWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void BridgeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("SkipForwardingDelay")))
|
||||
if (settings[QString("SkipForwardingDelay")] == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
}
|
47
sources/gui/src/bridgewidget.h
Normal file
@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BRIDGEWIDGET_H
|
||||
#define BRIDGEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class BridgeWidget;
|
||||
}
|
||||
|
||||
class BridgeWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BridgeWidget(QWidget *parent = 0);
|
||||
~BridgeWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
Ui::BridgeWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif /* BRIDGEWIDGET_H */
|
68
sources/gui/src/bridgewidget.ui
Normal file
@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BridgeWidget</class>
|
||||
<widget class="QWidget" name="BridgeWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>44</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_bridge">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Bridge settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_bridge">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_skip">
|
||||
<item>
|
||||
<widget class="QLabel" name="labe_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Skip (R)STP and immediately activate all bridge members</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip forwarding delay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
243
sources/gui/src/calls.cpp
Normal file
@ -0,0 +1,243 @@
|
||||
/***************************************************************************
|
||||
* 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 "calls.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <listmap/listmap.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "dbusoperation.h"
|
||||
|
||||
|
||||
InterfaceAnswer createProfileSlot(const QString profile, QMap<QString,QString> settings,
|
||||
NetctlInterface* interface, const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->createProfile(profile, settings);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
args.append(mapToList(settings));
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Create"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer enableProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->enableProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Enable"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer removeProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->removeProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Remove"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer restartProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->restartProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Restart"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer startProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->startProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Start"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer stopAllProfilesSlot(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!useHelper) return interface->stopAllProfiles();
|
||||
try {
|
||||
int responce = sendRequestToInterface(QString("StopAll"), debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer switchToProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->switchToProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("SwitchTo"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString,QString> settings,
|
||||
NetctlInterface* interface, const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||
|
||||
|
||||
if (!useHelper) return interface->connectToEssid(essid, settings);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(essid);
|
||||
args.append(mapToList(settings));
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Essid"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
netctlInformation generalInformation(NetctlInterface* interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!useHelper) return interface->information();
|
||||
try {
|
||||
QList<QVariant> responce = sendRequestToInterface(QString("Information"), debug);
|
||||
// main
|
||||
netctlInformation info;
|
||||
info.netctlAuto = responce[0].toStringList().takeFirst().toInt();
|
||||
info.netctlAutoEnabled = responce[0].toStringList().takeFirst().toInt();
|
||||
QList<netctlProfileInfo> profiles = parseOutputNetctl(responce);
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
if (profiles[i].netctlAuto)
|
||||
info.netctlAutoProfiles.append(profiles[i]);
|
||||
else
|
||||
info.netctlProfiles.append(profiles[i]);
|
||||
}
|
||||
return info;
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return netctlInformation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> profileInformation(const QString profile, NetctlInterface* interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (!useHelper) return interface->profileSettings(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
QStringList responce = sendRequestToInterfaceWithArgs(QString("Profile"), args, debug)[0].toStringList();
|
||||
return listToMap(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
netctlCurrent trayInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!useHelper) return interface->status();
|
||||
try {
|
||||
QStringList responce = sendRequestToInterface(QString("Status"), debug)[0].toStringList();
|
||||
netctlCurrent status;
|
||||
status.netctlAuto = responce[0].toInt();
|
||||
status.profiles = responce[1].split(QChar('|'));
|
||||
status.current = responce[2].split(QChar('|'));
|
||||
QStringList enables = responce[3].split(QChar('|'));
|
||||
for (int i=0; i<enables.count(); i++)
|
||||
status.enables.append(enables[i].toInt());
|
||||
return status;
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return netctlCurrent();
|
||||
}
|
||||
}
|
55
sources/gui/src/calls.h
Normal file
@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* 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 CALLS_H
|
||||
#define CALLS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
// control
|
||||
InterfaceAnswer createProfileSlot(const QString profile, const QMap<QString,QString> settings,
|
||||
NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
InterfaceAnswer enableProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer removeProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer restartProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer startProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer stopAllProfilesSlot(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
InterfaceAnswer switchToProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
// wireless connection
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString,QString> settings,
|
||||
NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
// information
|
||||
netctlInformation generalInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
QMap<QString, QString> profileInformation(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
netctlCurrent trayInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
|
||||
|
||||
#endif /* CALLS_H */
|
88
sources/gui/src/commonfunctions.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/***************************************************************************
|
||||
* 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 "commonfunctions.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
|
||||
bool checkExternalApps(const QString apps, const QMap<QString, QString> configuration,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Applications" << apps;
|
||||
|
||||
if (configuration[QString("SKIPCOMPONENTS")] == QString("true")) return true;
|
||||
QStringList cmd;
|
||||
cmd.append("which");
|
||||
// avoid null-lines arguments
|
||||
cmd.append("true");
|
||||
cmd.append(externalApps(apps, configuration));
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd.join(QChar(' '));
|
||||
TaskResult process = runTask(cmd.join(QChar(' ')), false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (statusBool) return QApplication::translate("MainWindow", "yes");
|
||||
if (!nullFalse) return QApplication::translate("MainWindow", "no");
|
||||
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
||||
QStringList externalApps(const QString apps, const QMap<QString, QString> configuration)
|
||||
{
|
||||
QStringList app;
|
||||
// editor works always over cmd
|
||||
if ((apps == QString("editor")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("EDITOR_PATH")]);
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("HELPER_PATH")]);
|
||||
}
|
||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("NETCTL_PATH")]);
|
||||
app.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||
}
|
||||
if ((apps == QString("wpasup")) || (apps == QString("wpasup-only")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("WPACLI_PATH")]);
|
||||
app.append(configuration[QString("WPASUP_PATH")]);
|
||||
}
|
||||
// append sudo
|
||||
// FORCE_SUDO is always true if helper is not running
|
||||
if ((apps.contains(QRegExp(QString("(^all$|^editor$|^netctl$|^sudo$|^systemctl$|^wpasup$)")))) &&
|
||||
(configuration[QString("FORCE_SUDO")] == QString("true")))
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
|
||||
return app;
|
||||
}
|
33
sources/gui/src/commonfunctions.h
Normal file
@ -0,0 +1,33 @@
|
||||
/***************************************************************************
|
||||
* 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 COMMONFUNCTIONS_H
|
||||
#define COMMONFUNCTIONS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
bool checkExternalApps(const QString apps = QString("all"),
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>(),
|
||||
const bool debug = false);
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
QStringList externalApps(const QString apps,
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||
|
||||
|
||||
#endif /* COMMONFUNCTIONS_H */
|
155
sources/gui/src/dbusoperation.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "dbusoperation.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw)
|
||||
{
|
||||
QList<netctlProfileInfo> profileInfo;
|
||||
if (raw.isEmpty()) return profileInfo;
|
||||
QStringList list = raw[0].toStringList();
|
||||
for (int i=0; i<list.count(); i++) {
|
||||
QStringList info = list[i].split(QChar('|'));
|
||||
if (info.count() != 8) continue;
|
||||
netctlProfileInfo profile;
|
||||
profile.name = info[0];
|
||||
profile.description = info[1];
|
||||
profile.type = info[2];
|
||||
profile.interface = info[3];
|
||||
profile.essid = info[4];
|
||||
profile.active = info[5].toInt();
|
||||
profile.enabled = info[6].toInt();
|
||||
profile.netctlAuto = info[7].toInt();
|
||||
profileInfo.append(profile);
|
||||
}
|
||||
|
||||
return profileInfo;
|
||||
}
|
||||
|
||||
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw)
|
||||
{
|
||||
QList<netctlWifiInfo> wifiInfo;
|
||||
if (raw.isEmpty()) return wifiInfo;
|
||||
QStringList list = raw[0].toStringList();
|
||||
for (int i=0; i<list.count(); i++) {
|
||||
QStringList info = list[i].split(QChar('|'));
|
||||
if (info.count() != 8) continue;
|
||||
netctlWifiInfo wifi;
|
||||
wifi.name = info[0];
|
||||
wifi.security = info[1];
|
||||
wifi.type = static_cast<PointType>(info[2].toInt());
|
||||
for (int j=0; j<info[3].split(QChar(',')).count(); j++)
|
||||
wifi.frequencies.append(info[3].split(QChar(','))[j].toInt());
|
||||
wifi.macs = info[4].split(QChar(','));
|
||||
wifi.signal = info[5].toInt();
|
||||
wifi.active = info[6].toInt();
|
||||
wifi.exists = info[7].toInt();
|
||||
wifiInfo.append(wifi);
|
||||
}
|
||||
|
||||
return wifiInfo;
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
|
||||
const QList<QVariant> args, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
|
||||
DBUS_HELPER_INTERFACE, cmd);
|
||||
if (!args.isEmpty()) request.setArguments(args);
|
||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
if (arguments.isEmpty())
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToCtrl(const QString cmd, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
return sendRequestToCtrlWithArgs(cmd, QList<QVariant>(), debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToCtrlWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
return sendRequestToHelper(DBUS_CTRL_PATH, cmd, args, debug);
|
||||
}
|
||||
|
||||
|
||||
QList< QVariant > sendRequestToInterface(const QString cmd, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
return sendRequestToInterfaceWithArgs(cmd, QList<QVariant>(), debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToInterfaceWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
return sendRequestToHelper(DBUS_INTERFACE_PATH, cmd, args, debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToLib(const QString cmd, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
return sendRequestToLibWithArgs(cmd, QList<QVariant>(), debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToLibWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
return sendRequestToHelper(DBUS_LIB_PATH, cmd, args, debug);
|
||||
}
|
41
sources/gui/src/dbusoperation.h
Normal file
@ -0,0 +1,41 @@
|
||||
/***************************************************************************
|
||||
* 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);
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw);
|
||||
QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
|
||||
const QList<QVariant> args, const bool debug = false);
|
||||
QList<QVariant> sendRequestToCtrl(const QString cmd, const bool debug = false);
|
||||
QList<QVariant> sendRequestToCtrlWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug = false);
|
||||
QList<QVariant> sendRequestToInterface(const QString cmd, const bool debug = false);
|
||||
QList<QVariant> sendRequestToInterfaceWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug = false);
|
||||
QList<QVariant> sendRequestToLib(const QString cmd, const bool debug = false);
|
||||
QList<QVariant> sendRequestToLibWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug = false);
|
||||
|
||||
|
||||
#endif /* DBUSOPERATION_H */
|
203
sources/gui/src/errorwindow.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
/***************************************************************************
|
||||
* 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 "errorwindow.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGridLayout>
|
||||
#include <QSpacerItem>
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
||||
: debug(debugCmd)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ErrorWindow::~ErrorWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
QStringList ErrorWindow::getMessage(const int mess)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
|
||||
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", "User is not in network group, helper will not be started");
|
||||
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;
|
||||
case 20:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "IP address does not match the standard");
|
||||
break;
|
||||
default:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
break;
|
||||
}
|
||||
|
||||
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:
|
||||
case 20:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
default:
|
||||
icon = QMessageBox::NoIcon;
|
||||
break;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
|
||||
void ErrorWindow::showWindow(const int mess, const QString sender, const bool debugCmd)
|
||||
{
|
||||
if (debugCmd) qDebug() << PDEBUG;
|
||||
if (debugCmd) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debugCmd) qDebug() << PDEBUG << ":" << "Sender" << sender;
|
||||
|
||||
ErrorWindow *errorWin = new ErrorWindow(0, debugCmd);
|
||||
QStringList message = errorWin->getMessage(mess);
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(message[0]);
|
||||
messageBox.setInformativeText(message[1]);
|
||||
if (mess == 1)
|
||||
messageBox.setDetailedText(sender);
|
||||
else if (debugCmd)
|
||||
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").arg(sender));
|
||||
messageBox.setIcon(errorWin->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();
|
||||
delete errorWin;
|
||||
}
|
46
sources/gui/src/errorwindow.h
Normal file
@ -0,0 +1,46 @@
|
||||
/***************************************************************************
|
||||
* 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 ERRORWINDOW_H
|
||||
#define ERRORWINDOW_H
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class ErrorWindow : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ErrorWindow(QWidget *parent = 0,
|
||||
const bool debugCmd = false);
|
||||
~ErrorWindow();
|
||||
|
||||
public slots:
|
||||
static void showWindow(const int mess = 0,
|
||||
const QString sender = QString(),
|
||||
const bool debugCmd = false);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QStringList getMessage(const int mess);
|
||||
QMessageBox::Icon getIcon(const int mess);
|
||||
};
|
||||
|
||||
|
||||
#endif /* ERRORWINDOW_H */
|
148
sources/gui/src/ethernetwidget.cpp
Normal file
@ -0,0 +1,148 @@
|
||||
/***************************************************************************
|
||||
* 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 "ethernetwidget.h"
|
||||
#include "ui_ethernetwidget.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
EthernetWidget::EthernetWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::EthernetWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
EthernetWidget::~EthernetWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::clear()
|
||||
{
|
||||
ui->checkBox_skip->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_8021x->setCheckState(Qt::Unchecked);
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
ui->lineEdit_wpaConfig->clear();
|
||||
ui->comboBox_driver->setCurrentIndex(0);
|
||||
ui->spinBox_timeoutCarrier->setValue(5);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
|
||||
ui->pushButton_ethernetAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
|
||||
connect(ui->checkBox_8021x, SIGNAL(stateChanged(int)), this, SLOT(showWpa(int)));
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::selectWpaConfig()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaConfig->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||
ui->widget_ethernetAdvanced->setHidden(false);
|
||||
ui->pushButton_ethernetAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_ethernetAdvanced->setHidden(true);
|
||||
ui->pushButton_ethernetAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::showWpa(const int state)
|
||||
{
|
||||
ui->widget_wpa->setHidden(state == 0);
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> EthernetWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->checkBox_skip->checkState() == Qt::Checked)
|
||||
settings[QString("SkipNoCarrier")] = QString("yes");
|
||||
if (ui->checkBox_8021x->checkState() == Qt::Checked) {
|
||||
settings[QString("Auth8021X")] = QString("yes");
|
||||
settings[QString("WPAConfigFile")] = QString("'%1'").arg(ui->lineEdit_wpaConfig->text());
|
||||
settings[QString("WPADriver")] = ui->comboBox_driver->currentText();
|
||||
}
|
||||
if (ui->spinBox_timeoutCarrier->value() != 5)
|
||||
settings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
|
||||
if (ui->spinBox_timeoutWpa->value() != 15)
|
||||
settings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int EthernetWidget::isOk()
|
||||
{
|
||||
// file wpa_supplicant doesn't exists
|
||||
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) return 1;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("SkipNoCarrier")))
|
||||
if (settings[QString("SkipNoCarrier")] == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
if (settings.contains(QString("Auth8021X")))
|
||||
if (settings[QString("Auth8021X")] == QString("yes"))
|
||||
ui->checkBox_8021x->setCheckState(Qt::Checked);
|
||||
if (settings.contains(QString("WPAConfigFile")))
|
||||
ui->lineEdit_wpaConfig->setText(settings[QString("WPAConfigFile")]);
|
||||
if (settings.contains(QString("WPADriver"))) {
|
||||
int index = ui->comboBox_driver->findText(settings[QString("WPADriver")]);
|
||||
ui->comboBox_driver->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("TimeoutCarrier")))
|
||||
ui->spinBox_timeoutCarrier->setValue(settings[QString("TimeoutCarrier")].toInt());
|
||||
if (settings.contains(QString("TimeoutWPA")))
|
||||
ui->spinBox_timeoutWpa->setValue(settings[QString("TimeoutWPA")].toInt());
|
||||
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
}
|
54
sources/gui/src/ethernetwidget.h
Normal file
@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* 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 ETHERNETWIDGET_H
|
||||
#define ETHERNETWIDGET_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class EthernetWidget;
|
||||
}
|
||||
|
||||
class EthernetWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EthernetWidget(QWidget *parent = 0);
|
||||
~EthernetWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void selectWpaConfig();
|
||||
void showAdvanced();
|
||||
void showWpa(const int state);
|
||||
|
||||
private:
|
||||
Ui::EthernetWidget *ui;
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
||||
#endif /* ETHERNETWIDGET_H */
|
322
sources/gui/src/ethernetwidget.ui
Normal file
@ -0,0 +1,322 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EthernetWidget</class>
|
||||
<widget class="QWidget" name="EthernetWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>227</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_ethernet">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Ethernet options</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_ethernet">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ethernetAdvanced">
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pushButton_ethernetAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ethernetAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_skip">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Whether or not the absence of a carrier is acceptable</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip no carrier</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_8021x">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8021x">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_8021x">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set to ‘yes’ to use 802.1x authentication</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>802.1x authentication</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wpa" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaConfig">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaConfig">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA config file</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfig">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Path to a wpa_supplicant configuration file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaConfig">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_driver">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_driver">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA driver</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_driver">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The wpa_supplicant driver to use for 802.1x authentication</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wired</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>nl80211</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wext</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutCarrier">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutCarrier">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout carrier</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutCarrier">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for a carrier</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutWpa">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutWpa">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout WPA</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutWpa">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>15</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_wpaConfig</tabstop>
|
||||
<tabstop>pushButton_wpaConfig</tabstop>
|
||||
<tabstop>comboBox_driver</tabstop>
|
||||
<tabstop>spinBox_timeoutCarrier</tabstop>
|
||||
<tabstop>spinBox_timeoutWpa</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
195
sources/gui/src/generalwidget.cpp
Normal file
@ -0,0 +1,195 @@
|
||||
/***************************************************************************
|
||||
* 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 "generalwidget.h"
|
||||
#include "ui_generalwidget.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
GeneralWidget::GeneralWidget(QWidget *parent, const QMap<QString, QString> settings)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::GeneralWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connectionType = ui->comboBox_connection;
|
||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
GeneralWidget::~GeneralWidget()
|
||||
{
|
||||
delete connectionType;
|
||||
delete ifaceDirectory;
|
||||
delete profileDirectory;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::clear()
|
||||
{
|
||||
ui->lineEdit_description->setText(QString("Generated by Netctl GUI"));
|
||||
ui->comboBox_connection->setCurrentIndex(0);
|
||||
ui->comboBox_interface->clear();
|
||||
ui->comboBox_interface->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
|
||||
ui->comboBox_bindto->clear();
|
||||
ui->comboBox_bindto->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
|
||||
ui->listWidget_bindto->setCurrentRow(-1);
|
||||
ui->listWidget_bindto->clear();
|
||||
ui->comboBox_after->clear();
|
||||
ui->comboBox_after->addItems(profileDirectory->entryList(QDir::Files));
|
||||
ui->listWidget_after->setCurrentRow(-1);
|
||||
ui->listWidget_after->clear();
|
||||
ui->lineEdit_execUpPost->clear();
|
||||
ui->lineEdit_execDownPre->clear();
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_debug->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_generalAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_after, SIGNAL(clicked(bool)), this, SLOT(addAfter()));
|
||||
connect(ui->comboBox_after->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addAfter()));
|
||||
connect(ui->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
|
||||
connect(ui->comboBox_bindto->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addBindTo()));
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::addAfter()
|
||||
{
|
||||
ui->listWidget_after->addItem(ui->comboBox_after->currentText());
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::addBindTo()
|
||||
{
|
||||
ui->listWidget_bindto->addItem(ui->comboBox_bindto->currentText());
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_bindto->hasFocus() &&
|
||||
(ui->listWidget_bindto->currentItem() != nullptr))
|
||||
delete ui->listWidget_bindto->currentItem();
|
||||
else if (ui->listWidget_after->hasFocus() &&
|
||||
(ui->listWidget_after->currentItem() != nullptr))
|
||||
delete ui->listWidget_after->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_generalAdvanced->isChecked()) {
|
||||
ui->widget_generalAdvanced->setHidden(false);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||
} else {
|
||||
ui->widget_generalAdvanced->setHidden(true);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> GeneralWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
settings[QString("Description")] = QString("'%1'").arg(ui->lineEdit_description->text());
|
||||
settings[QString("Connection")] = ui->comboBox_connection->currentText();
|
||||
settings[QString("Interface")] = ui->comboBox_interface->currentText();
|
||||
if (ui->listWidget_bindto->count() != 0) {
|
||||
QStringList interfaces;
|
||||
for (int i=0; i<ui->listWidget_bindto->count(); i++)
|
||||
interfaces.append(ui->listWidget_bindto->item(i)->text());
|
||||
settings[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());
|
||||
settings[QString("After")] = profiles.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_execUpPost->text().isEmpty())
|
||||
settings[QString("ExecUpPost")] = QString("'%1'").arg(ui->lineEdit_execUpPost->text());
|
||||
if (!ui->lineEdit_execDownPre->text().isEmpty())
|
||||
settings[QString("ExecDownPre")] = QString("'%1'").arg(ui->lineEdit_execDownPre->text());
|
||||
if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
|
||||
settings[QString("ForceConnect")] = QString("yes");
|
||||
if (ui->checkBox_debug->checkState() == Qt::Checked)
|
||||
settings[QString("NETCTL_DEBUG")] = QString("yes");
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
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("macvlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
||||
if (ui->listWidget_bindto->count() == 0) return 1;
|
||||
// empty description
|
||||
if (ui->lineEdit_description->text().isEmpty()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("Description")))
|
||||
ui->lineEdit_description->setText(settings[QString("Description")]);
|
||||
if (settings.contains(QString("Connection"))) {
|
||||
int index = ui->comboBox_connection->findText(settings[QString("Connection")]);
|
||||
ui->comboBox_connection->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("Interface"))) {
|
||||
ui->comboBox_interface->addItem(settings[QString("Interface")]);
|
||||
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count() - 1);
|
||||
}
|
||||
if (settings.contains(QString("BindsToInterfaces")))
|
||||
ui->listWidget_bindto->addItems(settings[QString("BindsToInterfaces")].split(QChar('\n')));
|
||||
if (settings.contains(QString("After")))
|
||||
ui->listWidget_after->addItems(settings[QString("After")].split(QChar('\n')));
|
||||
if (settings.contains(QString("ExecUpPost")))
|
||||
ui->lineEdit_execUpPost->setText(settings[QString("ExecUpPost")]);
|
||||
if (settings.contains(QString("ExecDownPre")))
|
||||
ui->lineEdit_execDownPre->setText(settings[QString("ExecDownPre")]);
|
||||
if (settings.contains(QString("ForceConnect")))
|
||||
if (settings[QString("ForceConnect")] == QString("yes"))
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
|
||||
if (settings.contains(QString("NETCTL_DEBUG")))
|
||||
if (settings[QString("NETCTL_DEBUG")] == QString("yes"))
|
||||
ui->checkBox_debug->setCheckState(Qt::Checked);
|
||||
}
|
61
sources/gui/src/generalwidget.h
Normal file
@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* 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 GENERALWIDGET_H
|
||||
#define GENERALWIDGET_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GeneralWidget;
|
||||
}
|
||||
|
||||
class GeneralWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GeneralWidget(QWidget *parent = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~GeneralWidget();
|
||||
QComboBox *connectionType;
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void addAfter();
|
||||
void addBindTo();
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
QDir *ifaceDirectory;
|
||||
QDir *profileDirectory;
|
||||
Ui::GeneralWidget *ui;
|
||||
void createActions();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
};
|
||||
|
||||
|
||||
#endif /* GENERALWIDGET_H */
|
488
sources/gui/src/generalwidget.ui
Normal file
@ -0,0 +1,488 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeneralWidget</class>
|
||||
<widget class="QWidget" name="GeneralWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>452</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_general">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_general">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_description">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_description">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A description of the profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_connection">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_connection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_connection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The connection type used by the profile</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">ethernet</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">wireless</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">bond</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">bridge</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">dummy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">pppoe</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">mobile_ppp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">tunnel</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">tuntap</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<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>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_interface">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interface">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_interface">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The name of the associated network interface</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_bindto">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_bindtoButton">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_bindto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Binds to interfaces</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_bindto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bindto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_bindto">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of physical network interfaces that this profile needs before it can be started</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_generalAdvanced">
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pushButton_generalAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_generalAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_after">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_afterButton">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_after">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>After</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_after">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_after">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_after">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of profile names that should be started before this profile is started</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_execUpPost">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_execUpPost">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command after starting</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_execUpPost">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A command that is executed after a connection is established</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_execDownPre">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_execDownPre">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command before stoping</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_execDownPre">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A command that is executed before a connection is brought down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_forceConnect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_forceConnect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_forceConnect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set to ‘yes’ to force connecting even if the interface is up</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Force connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_debug">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Debug mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
83
sources/gui/src/ipregexp.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* 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 "ipregexp.h"
|
||||
|
||||
|
||||
IpRegExp::IpRegExp(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
IpRegExp::~IpRegExp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip4Regex()
|
||||
{
|
||||
return QRegExp(QString("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"));
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip4CidrRegex()
|
||||
{
|
||||
return QRegExp(QString("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(/([0-9]|[1-2][0-9]|3[0-2]))$"));
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip6Regex()
|
||||
{
|
||||
return QRegExp(QString("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*"));
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip6CidrRegex()
|
||||
{
|
||||
return QRegExp(QString("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(/(d|dd|1[0-1]d|12[0-8]))$"));
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv4Validator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip4Regex());
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv4CidrValidator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip4CidrRegex());
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv6Validator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip6Regex());
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv6CidrValidator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip6CidrRegex());
|
||||
}
|
||||
|
||||
|
||||
bool IpRegExp::checkString(const QString input, const QRegExp regexp)
|
||||
{
|
||||
return regexp.exactMatch(input);
|
||||
}
|
49
sources/gui/src/ipregexp.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 IPREGEXP_H
|
||||
#define IPREGEXP_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QRegExp>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
|
||||
class IpRegExp : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IpRegExp(QObject *parent = 0);
|
||||
~IpRegExp();
|
||||
|
||||
// ipv4
|
||||
static QRegExp ip4Regex();
|
||||
static QRegExp ip4CidrRegex();
|
||||
// ipv6
|
||||
static QRegExp ip6Regex();
|
||||
static QRegExp ip6CidrRegex();
|
||||
// validators
|
||||
static QRegExpValidator *ipv4Validator();
|
||||
static QRegExpValidator *ipv4CidrValidator();
|
||||
static QRegExpValidator *ipv6Validator();
|
||||
static QRegExpValidator *ipv6CidrValidator();
|
||||
// check
|
||||
static bool checkString(const QString input, const QRegExp regexp);
|
||||
};
|
||||
|
||||
|
||||
#endif /* IPREGEXP_H */
|
459
sources/gui/src/ipwidget.cpp
Normal file
@ -0,0 +1,459 @@
|
||||
/***************************************************************************
|
||||
* 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 "ipwidget.h"
|
||||
#include "ui_ipwidget.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "errorwindow.h"
|
||||
#include "ipregexp.h"
|
||||
|
||||
|
||||
IpWidget::IpWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::IpWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
createFilter();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
IpWidget::~IpWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::clear()
|
||||
{
|
||||
ui->checkBox_ip->setCheckState(Qt::Checked);
|
||||
ui->comboBox_ip->setCurrentIndex(0);
|
||||
ipEnable(ui->checkBox_ip->checkState());
|
||||
changeIpMode(ui->comboBox_ip->currentText());
|
||||
ui->lineEdit_ipAddress->clear();
|
||||
ui->listWidget_ipAddress->setCurrentRow(-1);
|
||||
ui->listWidget_ipAddress->clear();
|
||||
ui->lineEdit_gateway->clear();
|
||||
ui->lineEdit_ipRoutes->clear();
|
||||
ui->lineEdit_ipRoutes2->clear();
|
||||
ui->listWidget_ipRoutes->setCurrentRow(-1);
|
||||
ui->listWidget_ipRoutes->clear();
|
||||
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
|
||||
ui->comboBox_ip6->setCurrentIndex(0);
|
||||
ip6Enable(ui->checkBox_ip6->checkState());
|
||||
changeIp6Mode(ui->comboBox_ip6->currentText());
|
||||
ui->lineEdit_ipAddress6->clear();
|
||||
ui->listWidget_ipAddress6->setCurrentRow(-1);
|
||||
ui->listWidget_ipAddress6->clear();
|
||||
ui->lineEdit_gateway6->clear();
|
||||
ui->lineEdit_ipRoutes6->clear();
|
||||
ui->lineEdit_ipRoutes62->clear();
|
||||
ui->listWidget_ipRoutes6->setCurrentRow(-1);
|
||||
ui->listWidget_ipRoutes6->clear();
|
||||
ui->lineEdit_custom->clear();
|
||||
ui->listWidget_custom->clear();
|
||||
ui->lineEdit_hostname->clear();
|
||||
ui->spinBox_timeoutDad->setValue(3);
|
||||
ui->comboBox_dhcp->setCurrentIndex(0);
|
||||
changeDhcpClient(ui->comboBox_dhcp->currentText());
|
||||
ui->lineEdit_dhcpcdOpt->clear();
|
||||
ui->lineEdit_dhclientOpt->clear();
|
||||
ui->lineEdit_dhclientOpt6->clear();
|
||||
ui->spinBox_timeoutDhcp->setValue(30);
|
||||
ui->checkBox_dhcp->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_dns->clear();
|
||||
ui->listWidget_dns->setCurrentRow(-1);
|
||||
ui->listWidget_dns->clear();
|
||||
ui->lineEdit_dnsDomain->clear();
|
||||
ui->lineEdit_dnsSearch->clear();
|
||||
ui->lineEdit_dnsOptions->clear();
|
||||
ui->listWidget_dnsOptions->setCurrentRow(-1);
|
||||
ui->listWidget_dnsOptions->clear();
|
||||
|
||||
ui->pushButton_ipAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
// ip mode
|
||||
connect(ui->checkBox_ip, SIGNAL(stateChanged(int)), this, SLOT(ipEnable(int)));
|
||||
connect(ui->comboBox_ip, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIpMode(QString)));
|
||||
// ipv6 mode
|
||||
connect(ui->checkBox_ip6, SIGNAL(stateChanged(int)), this, SLOT(ip6Enable(int)));
|
||||
connect(ui->comboBox_ip6, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIp6Mode(QString)));
|
||||
// dhcp client
|
||||
connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
|
||||
// buttons
|
||||
connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp()));
|
||||
connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), this, SLOT(addIp()));
|
||||
connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
|
||||
connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6()));
|
||||
connect(ui->lineEdit_ipAddress6, SIGNAL(returnPressed()), this, SLOT(addIp6()));
|
||||
connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
|
||||
connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom()));
|
||||
connect(ui->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom()));
|
||||
connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns()));
|
||||
connect(ui->lineEdit_dns, SIGNAL(returnPressed()), this, SLOT(addDns()));
|
||||
connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
|
||||
connect(ui->lineEdit_dnsOptions, SIGNAL(returnPressed()), this, SLOT(addDnsOpt()));
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::createFilter()
|
||||
{
|
||||
// ipv4
|
||||
ui->lineEdit_ipAddress->setValidator(IpRegExp::ipv4CidrValidator());
|
||||
ui->lineEdit_gateway->setValidator(IpRegExp::ipv4Validator());
|
||||
ui->lineEdit_ipRoutes->setValidator(IpRegExp::ipv4CidrValidator());
|
||||
ui->lineEdit_ipRoutes2->setValidator(IpRegExp::ipv4Validator());
|
||||
|
||||
// ipv6
|
||||
ui->lineEdit_ipAddress6->setValidator(IpRegExp::ipv6CidrValidator());
|
||||
ui->lineEdit_gateway6->setValidator(IpRegExp::ipv6Validator());
|
||||
ui->lineEdit_ipRoutes6->setValidator(IpRegExp::ipv6CidrValidator());
|
||||
ui->lineEdit_ipRoutes62->setValidator(IpRegExp::ipv6Validator());
|
||||
|
||||
// dns
|
||||
ui->lineEdit_dns->setValidator(IpRegExp::ipv4Validator());
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_ipAddress->hasFocus() &&
|
||||
(ui->listWidget_ipAddress->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipAddress->currentItem();
|
||||
else if (ui->listWidget_ipRoutes->hasFocus() &&
|
||||
(ui->listWidget_ipRoutes->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipRoutes->currentItem();
|
||||
else if (ui->listWidget_ipAddress6->hasFocus() &&
|
||||
(ui->listWidget_ipAddress6->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipAddress6->currentItem();
|
||||
else if (ui->listWidget_ipRoutes6->hasFocus() &&
|
||||
(ui->listWidget_ipRoutes6->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipRoutes6->currentItem();
|
||||
else if (ui->listWidget_custom->hasFocus() &&
|
||||
(ui->listWidget_custom->currentItem() != nullptr))
|
||||
delete ui->listWidget_custom->currentItem();
|
||||
else if (ui->listWidget_dns->hasFocus() &&
|
||||
(ui->listWidget_dns->currentItem() != nullptr))
|
||||
delete ui->listWidget_dns->currentItem();
|
||||
else if (ui->listWidget_dnsOptions->hasFocus() &&
|
||||
(ui->listWidget_dnsOptions->currentItem() != nullptr))
|
||||
delete ui->listWidget_dnsOptions->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIp()
|
||||
{
|
||||
if (!IpRegExp::checkString(ui->lineEdit_ipAddress->text(), IpRegExp::ip4CidrRegex()))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIp]"));
|
||||
|
||||
ui->listWidget_ipAddress->addItem(ui->lineEdit_ipAddress->text());
|
||||
ui->lineEdit_ipAddress->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIpRoutes()
|
||||
{
|
||||
if ((!IpRegExp::checkString(ui->lineEdit_ipRoutes->text(), IpRegExp::ip4CidrRegex())) ||
|
||||
(!IpRegExp::checkString(ui->lineEdit_ipRoutes2->text(), IpRegExp::ip4Regex())))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIpRoutes]"));
|
||||
|
||||
ui->listWidget_ipRoutes->addItem(QString("%1 via %2").arg(ui->lineEdit_ipRoutes->text()).arg(ui->lineEdit_ipRoutes2->text()));
|
||||
ui->lineEdit_ipRoutes->clear();
|
||||
ui->lineEdit_ipRoutes2->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIp6()
|
||||
{
|
||||
if (!IpRegExp::checkString(ui->lineEdit_ipAddress6->text(), IpRegExp::ip6CidrRegex()))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIp6]"));
|
||||
|
||||
ui->listWidget_ipAddress6->addItem(ui->lineEdit_ipAddress6->text());
|
||||
ui->lineEdit_ipAddress6->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIpRoutes6()
|
||||
{
|
||||
if ((!IpRegExp::checkString(ui->lineEdit_ipRoutes6->text(), IpRegExp::ip6CidrRegex())) ||
|
||||
(!IpRegExp::checkString(ui->lineEdit_ipRoutes62->text(), IpRegExp::ip6Regex())))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIp6Routes]"));
|
||||
|
||||
ui->listWidget_ipRoutes6->addItem(QString("%1 via %2").arg(ui->lineEdit_ipRoutes6->text()).arg(ui->lineEdit_ipRoutes62->text()));
|
||||
ui->lineEdit_ipRoutes6->clear();
|
||||
ui->lineEdit_ipRoutes62->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addCustom()
|
||||
{
|
||||
if (!ui->lineEdit_custom->text().isEmpty())
|
||||
ui->listWidget_custom->addItem(ui->lineEdit_custom->text());
|
||||
ui->lineEdit_custom->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addDns()
|
||||
{
|
||||
if (!IpRegExp::checkString(ui->lineEdit_dns->text(), IpRegExp::ip4Regex()))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addDns]"));
|
||||
|
||||
ui->listWidget_dns->addItem(ui->lineEdit_dns->text());
|
||||
ui->lineEdit_dns->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addDnsOpt()
|
||||
{
|
||||
if (!ui->lineEdit_dnsOptions->text().isEmpty())
|
||||
ui->listWidget_dnsOptions->addItem(ui->lineEdit_dnsOptions->text());
|
||||
ui->lineEdit_dnsOptions->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::changeIpMode(const QString currentText)
|
||||
{
|
||||
ui->widget_ip->setHidden(currentText == QString("dhcp"));
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::ipEnable(const int state)
|
||||
{
|
||||
ui->comboBox_ip->setDisabled(state == 0);
|
||||
ui->widget_ip->setDisabled(state == 0);
|
||||
ui->widget_ipRoutes->setDisabled(state == 0);
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::changeIp6Mode(const QString currentText)
|
||||
{
|
||||
ui->widget_ip6->setHidden(currentText.startsWith(QString("dhcp")));
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::ip6Enable(const int state)
|
||||
{
|
||||
ui->comboBox_ip6->setDisabled(state == 0);
|
||||
ui->widget_ip6->setDisabled(state == 0);
|
||||
ui->widget_ipRoutes6->setDisabled(state == 0);
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::changeDhcpClient(const QString currentText)
|
||||
{
|
||||
ui->widget_dhcpcdOpt->setHidden(currentText != QString("dhcpcd"));
|
||||
ui->widget_dhclientOpt->setHidden(currentText == QString("dhcpcd"));
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||
ui->widget_ipAdvanced->setHidden(false);
|
||||
ui->pushButton_ipAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_ipAdvanced->setHidden(true);
|
||||
ui->pushButton_ipAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> IpWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->checkBox_ip->checkState() == Qt::Checked) {
|
||||
settings[QString("IP")] = ui->comboBox_ip->currentText();
|
||||
if (ui->comboBox_ip->currentText() == QString("static")) {
|
||||
QStringList addresses;
|
||||
for (int i=0; i<ui->listWidget_ipAddress->count(); i++)
|
||||
addresses.append(QString("'%1'").arg(ui->listWidget_ipAddress->item(i)->text()));
|
||||
settings[QString("Address")] = addresses.join(QChar(' '));
|
||||
settings[QString("Gateway")] = QString("'%1'").arg(ui->lineEdit_gateway->text());
|
||||
}
|
||||
if (ui->listWidget_ipRoutes->count() > 0) {
|
||||
QStringList routes;
|
||||
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
|
||||
routes.append(QString("'%1'").arg(ui->listWidget_ipRoutes->item(i)->text()));
|
||||
settings[QString("Routes")] = routes.join(QChar(' '));
|
||||
}
|
||||
} else
|
||||
settings[QString("IP")] = QString("no");
|
||||
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
||||
settings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
||||
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
|
||||
(ui->comboBox_ip6->currentText() == QString("stateless"))) {
|
||||
QStringList addresses;
|
||||
for (int i=0; i<ui->listWidget_ipAddress6->count(); i++)
|
||||
addresses.append(QString("'%1'").arg(ui->listWidget_ipAddress6->item(i)->text()));
|
||||
settings[QString("Address6")] = addresses.join(QChar(' '));
|
||||
settings[QString("Gateway6")] = QString("'%1'").arg(ui->lineEdit_gateway6->text());
|
||||
}
|
||||
if (ui->listWidget_ipRoutes6->count() > 0) {
|
||||
QStringList routes;
|
||||
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
|
||||
routes.append(QString("'%1'").arg(ui->listWidget_ipRoutes6->item(i)->text()));
|
||||
settings[QString("Routes6")] = routes.join(QChar(' '));
|
||||
}
|
||||
} else
|
||||
settings[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("'%1'").arg(ui->listWidget_custom->item(i)->text()));
|
||||
settings[QString("IPCustom")] = custom.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_hostname->text().isEmpty())
|
||||
settings[QString("Hostname")] = QString("'%1'").arg(ui->lineEdit_hostname->text());
|
||||
if (ui->spinBox_timeoutDad->value() != 3)
|
||||
settings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value());
|
||||
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
|
||||
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
|
||||
settings[QString("DhcpcdOptions")] = QString("'%1'").arg(ui->lineEdit_dhcpcdOpt->text());
|
||||
} else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
settings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
||||
settings[QString("DhclientOptions")] = QString("'%1'").arg(ui->lineEdit_dhclientOpt->text());
|
||||
if (!ui->lineEdit_dhclientOpt6->text().isEmpty())
|
||||
settings[QString("DhclientOptions6")] = QString("'%1'").arg(ui->lineEdit_dhclientOpt6->text());
|
||||
}
|
||||
if (ui->spinBox_timeoutDhcp->value() != 30)
|
||||
settings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
|
||||
if (ui->checkBox_dhcp->checkState() == Qt::Checked)
|
||||
settings[QString("DHCPReleaseOnStop")] = QString("yes");
|
||||
if (ui->listWidget_dns->count() > 0) {
|
||||
QStringList dns;
|
||||
for (int i=0; i<ui->listWidget_dns->count(); i++)
|
||||
dns.append(QString("'%1'").arg(ui->listWidget_dns->item(i)->text()));
|
||||
settings[QString("DNS")] = dns.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_dnsDomain->text().isEmpty())
|
||||
settings[QString("DNSDomain")] = QString("'%1'").arg(ui->lineEdit_dnsDomain->text());
|
||||
if (!ui->lineEdit_dnsSearch->text().isEmpty())
|
||||
settings[QString("DNSSearch")] = QString("'%1'").arg(ui->lineEdit_dnsSearch->text());
|
||||
if (ui->listWidget_dnsOptions->count() > 0) {
|
||||
QStringList dnsOpt;
|
||||
for (int i=0; i<ui->listWidget_dnsOptions->count(); i++)
|
||||
dnsOpt.append(QString("'%1'").arg(ui->listWidget_dnsOptions->item(i)->text()));
|
||||
settings[QString("DNSOptions")] = dnsOpt.join(QChar(' '));
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int IpWidget::isOk()
|
||||
{
|
||||
// ip settings is not set
|
||||
if ((ui->checkBox_ip->checkState() == Qt::Checked) &&
|
||||
(ui->comboBox_ip->currentText() == QString("static")))
|
||||
if ((ui->listWidget_ipAddress->count() == 0) ||
|
||||
(ui->lineEdit_gateway->text().isEmpty())) return 1;
|
||||
// ipv6 settings is not set
|
||||
if ((ui->checkBox_ip6->checkState() == Qt::Checked) &&
|
||||
((ui->comboBox_ip6->currentText() == QString("static")) ||
|
||||
(ui->comboBox_ip6->currentText() == QString("stateless"))))
|
||||
if ((ui->listWidget_ipAddress6->count() == 0) ||
|
||||
(ui->lineEdit_gateway6->text().isEmpty())) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("IP"))) {
|
||||
if (settings[QString("IP")] == QString("no"))
|
||||
ui->checkBox_ip->setCheckState(Qt::Unchecked);
|
||||
else {
|
||||
ui->checkBox_ip->setCheckState(Qt::Checked);
|
||||
int index = ui->comboBox_ip->findText(settings[QString("IP")]);
|
||||
ui->comboBox_ip->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
if (settings.contains(QString("Address")))
|
||||
ui->listWidget_ipAddress->addItems(settings[QString("Address")].split(QChar('\n')));
|
||||
if (settings.contains(QString("Gateway")))
|
||||
ui->lineEdit_gateway->setText(settings[QString("Gateway")]);
|
||||
if (settings.contains(QString("Routes")))
|
||||
ui->listWidget_ipRoutes->addItems(settings[QString("Routes")].split(QChar('\n')));
|
||||
if (settings.contains(QString("IP6"))) {
|
||||
if (settings[QString("IP6")] == QString("no"))
|
||||
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
|
||||
else {
|
||||
ui->checkBox_ip6->setCheckState(Qt::Checked);
|
||||
int index = ui->comboBox_ip6->findText(settings[QString("IP6")]);
|
||||
ui->comboBox_ip6->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
if (settings.contains(QString("Address6")))
|
||||
ui->listWidget_ipAddress6->addItems(settings[QString("Address6")].split(QChar('\n')));
|
||||
if (settings.contains(QString("Gateway6")))
|
||||
ui->lineEdit_gateway6->setText(settings[QString("Gateway6")]);
|
||||
if (settings.contains(QString("Routes6")))
|
||||
ui->listWidget_ipRoutes6->addItems(settings[QString("Routes6")].split(QChar('\n')));
|
||||
if (settings.contains(QString("IPCustom")))
|
||||
ui->listWidget_custom->addItems(settings[QString("IPCustom")].split(QChar('\n')));
|
||||
if (settings.contains(QString("Hostname")))
|
||||
ui->lineEdit_hostname->setText(settings[QString("Hostname")]);
|
||||
if (settings.contains(QString("TimeoutDAD")))
|
||||
ui->spinBox_timeoutDad->setValue(settings[QString("TimeoutDAD")].toInt());
|
||||
if (settings.contains(QString("DHCPClient"))) {
|
||||
int index = ui->comboBox_dhcp->findText(settings[QString("DHCPClient")]);
|
||||
ui->comboBox_dhcp->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("DhcpcdOptions")))
|
||||
ui->lineEdit_dhcpcdOpt->setText(settings[QString("DhcpcdOptions")]);
|
||||
if (settings.contains(QString("DhclientOptions")))
|
||||
ui->lineEdit_dhclientOpt->setText(settings[QString("DhclientOptions")]);
|
||||
if (settings.contains(QString("DhclientOptions6")))
|
||||
ui->lineEdit_dhclientOpt6->setText(settings[QString("DhclientOptions6")]);
|
||||
if (settings.contains(QString("TimeoutDHCP")))
|
||||
ui->spinBox_timeoutDhcp->setValue(settings[QString("TimeoutDHCP")].toInt());
|
||||
if (settings.contains(QString("DHCPReleaseOnStop")))
|
||||
if (settings[QString("DHCPReleaseOnStop")] == QString("yes"))
|
||||
ui->checkBox_dhcp->setCheckState(Qt::Checked);
|
||||
if (settings.contains(QString("DNS")))
|
||||
ui->listWidget_dns->addItems(settings[QString("DNS")].split(QChar('\n')));
|
||||
if (settings.contains(QString("DNSDomain")))
|
||||
ui->lineEdit_dnsDomain->setText(settings[QString("DNSDomain")]);
|
||||
if (settings.contains(QString("DNSSearch")))
|
||||
ui->lineEdit_dnsSearch->setText(settings[QString("DNSSearch")]);
|
||||
if (settings.contains(QString("DNSOptions")))
|
||||
ui->listWidget_dnsOptions->addItems(settings[QString("DNSOptions")].split(QChar('\n')));
|
||||
|
||||
ipEnable(ui->checkBox_ip->checkState());
|
||||
changeIpMode(ui->comboBox_ip->currentText());
|
||||
ip6Enable(ui->checkBox_ip6->checkState());
|
||||
changeIp6Mode(ui->comboBox_ip6->currentText());
|
||||
changeDhcpClient(ui->comboBox_dhcp->currentText());
|
||||
}
|
69
sources/gui/src/ipwidget.h
Normal file
@ -0,0 +1,69 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef IPWIDGET_H
|
||||
#define IPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class IpWidget;
|
||||
}
|
||||
|
||||
class IpWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IpWidget(QWidget *parent = 0);
|
||||
~IpWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
// buttons
|
||||
void addIp();
|
||||
void addIpRoutes();
|
||||
void addIp6();
|
||||
void addIpRoutes6();
|
||||
void addCustom();
|
||||
void addDns();
|
||||
void addDnsOpt();
|
||||
// ip mode
|
||||
void changeIpMode(const QString currentText);
|
||||
void ipEnable(const int state);
|
||||
// ipv6 mode
|
||||
void changeIp6Mode(const QString currentText);
|
||||
void ip6Enable(int state);
|
||||
// dhcp client
|
||||
void changeDhcpClient(const QString currentText);
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
Ui::IpWidget *ui;
|
||||
void createActions();
|
||||
void createFilter();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
};
|
||||
|
||||
|
||||
#endif /* IPWIDGET_H */
|
1224
sources/gui/src/ipwidget.ui
Normal file
83
sources/gui/src/macvlanwidget.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* 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::createFilter()
|
||||
{
|
||||
// mac
|
||||
ui->lineEdit_mac->setInputMask(QString(">hh:hh:hh:hh:hh:hh"));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MacvlanWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
settings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
|
||||
settings[QString("MACAddress")] = ui->lineEdit_mac->text();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int MacvlanWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void MacvlanWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("Mode"))) {
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("MACAddress")))
|
||||
ui->lineEdit_mac->setText(settings[QString("MACAddress")]);
|
||||
}
|
48
sources/gui/src/macvlanwidget.h
Normal file
@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* 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();
|
||||
|
||||
private:
|
||||
Ui::MacvlanWidget *ui;
|
||||
void createFilter();
|
||||
};
|
||||
|
||||
|
||||
#endif /* MACVLANWIDGET_H */
|
121
sources/gui/src/macvlanwidget.ui
Normal file
@ -0,0 +1,121 @@
|
||||
<?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>79</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MAC address</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Optional static MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
205
sources/gui/src/main.cpp
Normal file
@ -0,0 +1,205 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <language/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() && arguments[0].toBool());
|
||||
}
|
||||
|
||||
|
||||
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[])
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
if (!args[QString("debug")].toBool()) args[QString("debug")] = (debugEnv == QString("yes"));
|
||||
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")] = static_cast<int>(3);
|
||||
if (args[QString("open")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = static_cast<int>(2);
|
||||
if (args[QString("select")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = static_cast<int>(1);
|
||||
|
||||
// check
|
||||
QString robotEnv = environment.value(QString("SKYNET"), QString(""));
|
||||
if (!robotEnv.isEmpty()) {
|
||||
cout << "Sorry, this software is only for humans" << endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// 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_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
a.installTranslator(&qtTranslator);
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations/%1").arg(language));
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// running
|
||||
if (args[QString("error")].toBool()) {
|
||||
cout << errorMessage().toUtf8().data() << endl;
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 1;
|
||||
} else if (args[QString("help")].toBool()) {
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 0;
|
||||
} else if (args[QString("info")].toBool()) {
|
||||
cout << versionMessage().toUtf8().data() << endl;
|
||||
cout << infoMessage().toUtf8().data();
|
||||
return 0;
|
||||
} else if (args[QString("version")].toBool()) {
|
||||
cout << versionMessage().toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// check if exists
|
||||
if (existingSessionOperation(QString("Active"))) {
|
||||
if ((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();
|
||||
}
|
427
sources/gui/src/mainwidget.cpp
Normal file
@ -0,0 +1,427 @@
|
||||
/***************************************************************************
|
||||
* 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 "mainwidget.h"
|
||||
#include "ui_mainwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
configuration(settings)
|
||||
{
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
// windows
|
||||
ui = new Ui::MainWidget;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_main->setColumnHidden(2, true);
|
||||
ui->tableWidget_main->setColumnHidden(3, true);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("NETCTL_TOOLBAR")].toInt()));
|
||||
|
||||
// append toolbar
|
||||
QMenu *actionMenu = new QMenu(this);
|
||||
actionMenu->addAction(ui->actionSwitch);
|
||||
actionMenu->addAction(ui->actionRestart);
|
||||
actionMenu->addAction(ui->actionEnable);
|
||||
ui->actionStart->setMenu(actionMenu);
|
||||
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
MainWidget::~MainWidget()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea MainWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
bool MainWidget::mainTabSelectProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
for (int i=0; i<ui->tableWidget_main->rowCount(); i++) {
|
||||
if (ui->tableWidget_main->item(i, 0)->text() != profile) continue;
|
||||
ui->tableWidget_main->setCurrentCell(i, 0);
|
||||
}
|
||||
|
||||
return (ui->tableWidget_main->currentItem() != nullptr);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
updateMainTab();
|
||||
updateMenuMain();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateMenuMain()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool selected = (ui->tableWidget_main->currentItem() != nullptr);
|
||||
ui->actionStart->setEnabled(selected);
|
||||
ui->actionEnable->setEnabled(selected);
|
||||
ui->actionEdit->setEnabled(selected);
|
||||
ui->actionRemove->setEnabled(selected);
|
||||
|
||||
if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
|
||||
// visible
|
||||
ui->actionRestart->setEnabled(true);
|
||||
ui->actionSwitch->setEnabled(false);
|
||||
// text
|
||||
ui->actionStart->setText(QApplication::translate("MainWidget", "Stop"));
|
||||
ui->actionStart->setIcon(QIcon::fromTheme("process-stop"));
|
||||
} else {
|
||||
// visible
|
||||
ui->actionRestart->setEnabled(false);
|
||||
ui->actionSwitch->setEnabled(selected);
|
||||
// text
|
||||
ui->actionStart->setText(QApplication::translate("MainWidget", "Start"));
|
||||
ui->actionStart->setIcon(QIcon::fromTheme("system-run"));
|
||||
}
|
||||
if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
ui->actionEnable->setText(QApplication::translate("MainWidget", "Disable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-remove"));
|
||||
} else {
|
||||
ui->actionEnable->setText(QApplication::translate("MainWidget", "Enable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateMainTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
netctlInformation info = generalInformation(mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
ui->label_netctlAuto->setHidden(!info.netctlAuto);
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(false);
|
||||
ui->tableWidget_main->selectRow(-1);
|
||||
ui->tableWidget_main->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget_main->clear();
|
||||
ui->tableWidget_main->setRowCount(info.netctlProfiles.count());
|
||||
|
||||
// create header
|
||||
QStringList headerList;
|
||||
headerList.append(QApplication::translate("MainWidget", "Name"));
|
||||
headerList.append(QApplication::translate("MainWidget", "Description"));
|
||||
headerList.append(QApplication::translate("MainWidget", "Active"));
|
||||
headerList.append(QApplication::translate("MainWidget", "Enabled"));
|
||||
ui->tableWidget_main->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
for (int i=0; i<info.netctlProfiles.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(info.netctlProfiles[i].active);
|
||||
font.setItalic(info.netctlProfiles[i].enabled);
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
toolTip += QString("%1: %2@%3\n").arg(QApplication::translate("MainWidget", "Type"))
|
||||
.arg(info.netctlProfiles[i].type)
|
||||
.arg(info.netctlProfiles[i].interface);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWidget", "Active"))
|
||||
.arg(checkStatus(info.netctlProfiles[i].active));
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWidget", "Enabled"))
|
||||
.arg(checkStatus(info.netctlProfiles[i].enabled));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("MainWidget", "Is wireless"))
|
||||
.arg(checkStatus(!info.netctlProfiles[i].essid.isEmpty()));
|
||||
// name
|
||||
ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(info.netctlProfiles[i].name));
|
||||
ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
ui->tableWidget_main->item(i, 0)->setToolTip(toolTip);
|
||||
ui->tableWidget_main->item(i, 0)->setFont(font);
|
||||
// description
|
||||
ui->tableWidget_main->setItem(i, 1, new QTableWidgetItem(info.netctlProfiles[i].description));
|
||||
ui->tableWidget_main->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
ui->tableWidget_main->item(i, 1)->setToolTip(toolTip);
|
||||
// active
|
||||
ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(checkStatus(info.netctlProfiles[i].active, true)));
|
||||
ui->tableWidget_main->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// enabled
|
||||
ui->tableWidget_main->setItem(i, 3, new QTableWidgetItem(checkStatus(info.netctlProfiles[i].enabled, true)));
|
||||
ui->tableWidget_main->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(true);
|
||||
|
||||
ui->tableWidget_main->resizeRowsToContents();
|
||||
ui->tableWidget_main->resizeColumnsToContents();
|
||||
ui->tableWidget_main->resizeRowsToContents();
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->tableWidget_main->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#else
|
||||
ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
mainWindow->setDisabled(false);
|
||||
mainWindow->showMessage(true);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *refreshTable = menu.addAction(QApplication::translate("MainWidget", "Refresh"));
|
||||
refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
|
||||
menu.addSeparator();
|
||||
QAction *startProfile = menu.addAction(QApplication::translate("MainWidget", "Start profile"));
|
||||
QAction *restartProfile = menu.addAction(QApplication::translate("MainWidget", "Restart profile"));
|
||||
restartProfile->setIcon(QIcon::fromTheme("view-refresh"));
|
||||
QAction *enableProfile = menu.addAction(QApplication::translate("MainWidget", "Enable profile"));
|
||||
menu.addSeparator();
|
||||
QAction *editProfile = menu.addAction(QApplication::translate("MainWidget", "Edit profile"));
|
||||
editProfile->setIcon(QIcon::fromTheme("document-edit"));
|
||||
QAction *removeProfile = menu.addAction(QApplication::translate("MainWidget", "Remove profile"));
|
||||
removeProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
||||
// set text
|
||||
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
|
||||
restartProfile->setVisible(true);
|
||||
startProfile->setText(QApplication::translate("MainWidget", "Stop profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("process-stop"));
|
||||
} else {
|
||||
restartProfile->setVisible(false);
|
||||
startProfile->setText(QApplication::translate("MainWidget", "Start profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("system-run"));
|
||||
}
|
||||
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
enableProfile->setText(QApplication::translate("MainWidget", "Disable profile"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-remove"));
|
||||
} else {
|
||||
enableProfile->setText(QApplication::translate("MainWidget", "Enable profile"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("list-add"));
|
||||
}
|
||||
|
||||
// actions
|
||||
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
|
||||
if (action == refreshTable) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Refresh table";
|
||||
updateMainTab();
|
||||
} else if (action == startProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Start profile";
|
||||
mainTabStartProfile();
|
||||
} else if (action == restartProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Restart profile";
|
||||
mainTabRestartProfile();
|
||||
} else if (action == enableProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
|
||||
mainTabEnableProfile();
|
||||
} else if (action == editProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Edit profile";
|
||||
mainTabEditProfile();
|
||||
} else if (action == removeProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove profile";
|
||||
mainTabRemoveProfile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabEditProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
mainWindow->setTab(1);
|
||||
mainWindow->openProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = enableProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
// TODO check if status has been changed?
|
||||
mainWindow->showMessage(answer != InterfaceAnswer::Error);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabRemoveProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("sudo"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("sudo"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = removeProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabRestartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = restartProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = startProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabStopAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
InterfaceAnswer answer = stopAllProfilesSlot(mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabSwitchToProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = switchToProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
|
||||
connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
|
||||
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||
connect(ui->actionRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
connect(ui->actionStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->actionStop_all, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
|
||||
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
|
||||
// main tab events
|
||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
|
||||
this, SLOT(updateMenuMain()));
|
||||
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
|
||||
}
|
77
sources/gui/src/mainwidget.h
Normal file
@ -0,0 +1,77 @@
|
||||
/***************************************************************************
|
||||
* 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 MAINWIDGET_H
|
||||
#define MAINWIDGET_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class MainWidget;
|
||||
}
|
||||
|
||||
class MainWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWidget(QWidget *parent = 0,
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~MainWidget();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
bool mainTabSelectProfileSlot(const QString profile);
|
||||
void update();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// update slots
|
||||
void updateMenuMain();
|
||||
void updateMainTab();
|
||||
// main tab slots
|
||||
void mainTabContextualMenu(const QPoint &pos);
|
||||
void mainTabEditProfile();
|
||||
void mainTabEnableProfile();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabStopAllProfiles();
|
||||
void mainTabSwitchToProfile();
|
||||
|
||||
private:
|
||||
// ui
|
||||
MainWindow *mainWindow = nullptr;
|
||||
Ui::MainWidget *ui = nullptr;
|
||||
// backend
|
||||
void createActions();
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAINWIDGET_H */
|
208
sources/gui/src/mainwidget.ui
Normal file
@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWidget</class>
|
||||
<widget class="QMainWindow" name="MainWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>515</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</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>
|
||||
<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>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Main actions toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionStart"/>
|
||||
<addaction name="actionStop_all"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEdit"/>
|
||||
<addaction name="actionRemove"/>
|
||||
</widget>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh table</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStart">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Start or stop selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSwitch">
|
||||
<property name="text">
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Switch to selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRestart">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restart selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="list-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable or disable selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop_all">
|
||||
<property name="icon">
|
||||
<iconset theme="process-stop">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop all</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Stop all profiles</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit">
|
||||
<property name="icon">
|
||||
<iconset theme="document-edit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
579
sources/gui/src/mainwindow.cpp
Normal file
@ -0,0 +1,579 @@
|
||||
/***************************************************************************
|
||||
* 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 <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
#include <language/language.h>
|
||||
#include <listmap/listmap.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "netctlguiadaptor.h"
|
||||
#include "newprofilewidget.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "trayicon.h"
|
||||
#include "version.h"
|
||||
#include "wifimenuwidget.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent,
|
||||
const QMap<QString, QVariant> args,
|
||||
QTranslator *qtAppTranslator,
|
||||
QTranslator *appTranslator)
|
||||
: QMainWindow(parent),
|
||||
configPath(args[QString("config")].toString()),
|
||||
debug(args[QString("debug")].toBool()),
|
||||
qtTranslator(qtAppTranslator),
|
||||
translator(appTranslator)
|
||||
{
|
||||
setWindowIcon(QIcon(":icon"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "about" << args[QString("about")].toBool();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "auto" << args[QString("auto")].toBool();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "config" << configPath;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "debug" << debug;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "defaults" << args[QString("defaults")].toBool();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "essid" << args[QString("essid")].toString();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "minimized" << args[QString("minimized")].toInt();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "open" << args[QString("open")].toString();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "options" << args[QString("options")].toString();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "select" << args[QString("select")].toString();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt();
|
||||
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
updateConfiguration(args);
|
||||
|
||||
// main actions
|
||||
if (args[QString("essid")].toString() != QString("ESSID")) {
|
||||
if (!wifiMenuWidget->wifiTabSelectEssidSlot(args[QString("essid")].toString()))
|
||||
ErrorWindow::showWindow(18, QString(PDEBUG), debug);
|
||||
} else if (args[QString("open")].toString() != QString("PROFILE")) {
|
||||
newProfileWidget->profileTabOpenProfileSlot(args[QString("open")].toString());
|
||||
} else if (args[QString("select")].toString() != QString("PROFILE")) {
|
||||
if (!mainWidget->mainTabSelectProfileSlot(args[QString("select")].toString()))
|
||||
ErrorWindow::showWindow(17, QString(PDEBUG), debug);
|
||||
}
|
||||
|
||||
// show windows
|
||||
if (args[QString("about")].toBool())
|
||||
showAboutWindow();
|
||||
if (args[QString("auto")].toBool())
|
||||
showNetctlAutoWindow();
|
||||
if (args[QString("settings")].toBool())
|
||||
showSettingsWindow();
|
||||
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (configuration[QString("CLOSE_HELPER")] == QString("true"))
|
||||
forceStopHelper();
|
||||
deleteObjects();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea MainWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::emitNeedToBeConfigured()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
emit(needToBeConfigured());
|
||||
}
|
||||
|
||||
|
||||
QStringList MainWindow::printSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return mapToList(configuration);
|
||||
}
|
||||
|
||||
|
||||
netctlCurrent MainWindow::printTrayInformation()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return trayInformation(netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::isHelperActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QVariant> responce = sendRequestToCtrl(QString("Active"), debug);
|
||||
|
||||
return (!responce.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::isHelperServiceActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("%1 is-active %2").arg(configuration[QString("SYSTEMCTL_PATH")])
|
||||
.arg(configuration[QString("HELPER_SERVICE")]);
|
||||
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;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) && (configuration[QString("SYSTRAY")] == QString("true"))) {
|
||||
hide();
|
||||
trayIcon->showMessage(QApplication::translate("MainWindow", "Information"),
|
||||
QApplication::translate("MainWindow", "Application has been hidden to tray"));
|
||||
event->ignore();
|
||||
} else
|
||||
closeMainWindow();
|
||||
}
|
||||
|
||||
|
||||
// tray icon
|
||||
void MainWindow::closeMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
storeToolBars();
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::openProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
newProfileWidget->profileTabOpenProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showAboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
aboutWin->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHidden()) {
|
||||
setTab(ui->stackedWidget->currentIndex());
|
||||
show();
|
||||
} else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showNetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
storeToolBars();
|
||||
settingsWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showApi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString("%1netctl-gui-dbus-api.html").arg(QString(DOCS_PATH)))));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showLibrary()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString("%1html/index.html").arg(QString(DOCS_PATH)))));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSecurityNotes()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString("%1netctl-gui-security-notes.html").arg(QString(DOCS_PATH)))));
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("helper"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("helper"), configuration).join(QChar('\n')), debug);
|
||||
emit(needToBeConfigured());
|
||||
return false;
|
||||
}
|
||||
|
||||
QString cmd = QString("%1 -c %2").arg(configuration[QString("HELPER_PATH")]).arg(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;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStopHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QVariant> responce = sendRequestToCtrl(QString("Close"), debug);
|
||||
|
||||
return (!responce.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHelperActive())
|
||||
return forceStopHelper();
|
||||
else
|
||||
return forceStartHelper();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setDisabled(const bool disabled)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->toolBar->setDisabled(disabled);
|
||||
ui->stackedWidget->setDisabled(disabled);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setTab(int tab)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Set tab" << tab;
|
||||
if (ui->stackedWidget->currentWidget() == nullptr) return;
|
||||
|
||||
if ((tab > 2) || (tab < 0)) tab = 0;
|
||||
if (tab != ui->stackedWidget->currentIndex())
|
||||
return ui->stackedWidget->setCurrentIndex(tab);
|
||||
|
||||
switch (tab) {
|
||||
case 1:
|
||||
newProfileWidget->update();
|
||||
break;
|
||||
case 2:
|
||||
wifiMenuWidget->update();
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
mainWidget->update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showMessage(const bool status)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << status;
|
||||
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::storeToolBars()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(configPath, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
settings.setValue(QString("MAIN_TOOLBAR"), QString::number(getToolBarArea()));
|
||||
settings.setValue(QString("NETCTL_TOOLBAR"), QString::number(mainWidget->getToolBarArea()));
|
||||
settings.setValue(QString("NETCTLAUTO_TOOLBAR"), QString::number(netctlAutoWin->getToolBarArea()));
|
||||
settings.setValue(QString("PROFILE_TOOLBAR"), QString::number(newProfileWidget->getToolBarArea()));
|
||||
settings.setValue(QString("WIFI_TOOLBAR"), QString::number(wifiMenuWidget->getToolBarArea()));
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
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]];
|
||||
useHelper = ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||
(checkExternalApps(QString("helper"), configuration, debug)));
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
QString language = Language::defineLanguage(configPath, args[QString("options")].toString());
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Language is" << language;
|
||||
qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qApp->installTranslator(qtTranslator);
|
||||
translator->load(QString(":/translations/%1").arg(language));
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
createObjects();
|
||||
createActions();
|
||||
|
||||
// tray
|
||||
trayIcon->setVisible(QSystemTrayIcon::isSystemTrayAvailable() && (configuration[QString("SYSTRAY")] == QString("true")));
|
||||
if (trayIcon->isVisible()) {
|
||||
setHidden(configuration[QString("STARTTOTRAY")] == QString("true"));
|
||||
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::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private slots
|
||||
void MainWindow::setTabByAction(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (action == nullptr) return;
|
||||
|
||||
if (action == ui->actionNetctl)
|
||||
setTab(0);
|
||||
else if (action == ui->actionProfiles)
|
||||
setTab(1);
|
||||
else if (action == ui->actionWiFi_menu)
|
||||
setTab(2);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::reportABug()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString(BUGTRACKER))));
|
||||
}
|
||||
|
||||
|
||||
// window signals
|
||||
bool MainWindow::checkHelperStatus()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper) useHelper = isHelperActive();
|
||||
if (!useHelper) {
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
configuration[QString("FORCE_SUDO")] = QString("true");
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
if (isHelperServiceActive())
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
|
||||
return useHelper;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
connect(ui->toolBar, SIGNAL(actionTriggered(QAction *)), this, SLOT(setTabByAction(QAction *)));
|
||||
connect(ui->actionNetctl_auto, SIGNAL(triggered()), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
|
||||
connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow()));
|
||||
|
||||
// menu
|
||||
connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettingsWindow()));
|
||||
connect(ui->actionSecurity, SIGNAL(triggered()), this, SLOT(showSecurityNotes()));
|
||||
connect(ui->actionDBus_API, SIGNAL(triggered()), this, SLOT(showApi()));
|
||||
connect(ui->actionLibrary, SIGNAL(triggered()), this, SLOT(showLibrary()));
|
||||
connect(ui->actionReport_a_bug, SIGNAL(triggered()), this, SLOT(reportABug()));
|
||||
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutWindow()));
|
||||
connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(closeMainWindow()));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createDBusSession()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
if (!bus.registerService(DBUS_SERVICE)) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not register service";
|
||||
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
|
||||
}
|
||||
if (!bus.registerObject(DBUS_OBJECT_PATH,
|
||||
new NetctlGuiAdaptor(this),
|
||||
QDBusConnection::ExportAllContents)) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Could not register GUI object";
|
||||
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// backend
|
||||
createDBusSession();
|
||||
if ((useHelper) && (!forceStartHelper())) {
|
||||
ErrorWindow::showWindow(19, QString(PDEBUG), debug);
|
||||
useHelper = false;
|
||||
}
|
||||
checkHelperStatus();
|
||||
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlInterface = new NetctlInterface(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
// frontend
|
||||
mainWidget = new MainWidget(this, configuration, debug);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, configuration, debug);
|
||||
newProfileWidget = new NewProfileWidget(this, configuration, debug);
|
||||
wifiMenuWidget = new WiFiMenuWidget(this, configuration, debug);
|
||||
trayIcon = new TrayIcon(this, configuration, debug);
|
||||
// windows
|
||||
ui->retranslateUi(this);
|
||||
ui->stackedWidget->addWidget(mainWidget);
|
||||
ui->stackedWidget->addWidget(newProfileWidget);
|
||||
ui->stackedWidget->addWidget(wifiMenuWidget);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("MAIN_TOOLBAR")].toInt()));
|
||||
aboutWin = new AboutWindow(this, debug);
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// workaround to avoid crash on window closing
|
||||
disconnect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
|
||||
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlInterface != nullptr) delete netctlInterface;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
|
||||
if (aboutWin != nullptr) delete aboutWin;
|
||||
if (settingsWin != nullptr) delete settingsWin;
|
||||
if (trayIcon != nullptr) delete trayIcon;
|
||||
if (mainWidget != nullptr) delete mainWidget;
|
||||
if (netctlAutoWin != nullptr) delete netctlAutoWin;
|
||||
if (newProfileWidget != nullptr) delete newProfileWidget;
|
||||
if (wifiMenuWidget != nullptr) delete wifiMenuWidget;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MainWindow::parseOptions(const QString options)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||
QStringList option = options.split(QChar(','))[i].split(QChar('='));
|
||||
if (option.count() != 2) continue;
|
||||
settings[option[0]] = option[1];
|
||||
}
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]);
|
||||
|
||||
return settings;
|
||||
}
|
122
sources/gui/src/mainwindow.h
Normal file
@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
* 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 MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class AboutWindow;
|
||||
class MainWidget;
|
||||
class NetctlAutoWindow;
|
||||
class NewProfileWidget;
|
||||
class SettingsWindow;
|
||||
class TrayIcon;
|
||||
class WiFiMenuWidget;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||
QTranslator *qtAppTranslator = 0,
|
||||
QTranslator *appTranslator = 0);
|
||||
~MainWindow();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
void emitNeedToBeConfigured();
|
||||
QStringList printSettings();
|
||||
netctlCurrent printTrayInformation();
|
||||
bool isHelperActive();
|
||||
bool isHelperServiceActive();
|
||||
// library interfaces
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlInterface *netctlInterface = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
public slots:
|
||||
// actions from trayicon
|
||||
void closeMainWindow();
|
||||
void openProfileSlot(const QString profile);
|
||||
void showAboutWindow();
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// open docs
|
||||
void showApi();
|
||||
void showLibrary();
|
||||
void showSecurityNotes();
|
||||
// helper
|
||||
bool forceStartHelper();
|
||||
bool forceStopHelper();
|
||||
bool startHelper();
|
||||
// main
|
||||
void setDisabled(const bool disabled = true);
|
||||
void setTab(int tab);
|
||||
void showMessage(const bool status);
|
||||
void storeToolBars();
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
signals:
|
||||
void needToBeConfigured();
|
||||
|
||||
private slots:
|
||||
void setTabByAction(QAction *action);
|
||||
void reportABug();
|
||||
|
||||
private:
|
||||
// ui
|
||||
TrayIcon *trayIcon = nullptr;
|
||||
Ui::MainWindow *ui = nullptr;
|
||||
AboutWindow *aboutWin = nullptr;
|
||||
MainWidget *mainWidget = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
NewProfileWidget *newProfileWidget = nullptr;
|
||||
SettingsWindow *settingsWin = nullptr;
|
||||
WiFiMenuWidget *wifiMenuWidget = nullptr;
|
||||
// backend
|
||||
bool checkHelperStatus();
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
void createObjects();
|
||||
void deleteObjects();
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
QTranslator *qtTranslator = nullptr;
|
||||
QTranslator *translator = nullptr;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
QMap<QString, QString> parseOptions(const QString options);
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAINWINDOW_H */
|
206
sources/gui/src/mainwindow.ui
Normal file
@ -0,0 +1,206 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Netctl GUI</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="centralLayout">
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMenu">
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSecurity"/>
|
||||
<addaction name="actionDBus_API"/>
|
||||
<addaction name="actionLibrary"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReport_a_bug"/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNetctl_auto"/>
|
||||
<addaction name="actionNetctl"/>
|
||||
<addaction name="actionProfiles"/>
|
||||
<addaction name="actionWiFi_menu"/>
|
||||
</widget>
|
||||
<action name="actionSecurity">
|
||||
<property name="icon">
|
||||
<iconset theme="security-medium">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show security notes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBus_API">
|
||||
<property name="text">
|
||||
<string>DBus API</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show DBus API</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLibrary">
|
||||
<property name="text">
|
||||
<string>Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show library docs</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReport_a_bug">
|
||||
<property name="icon">
|
||||
<iconset theme="tools-report-bug">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Report a bug</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>About this application</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="application-exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSettings">
|
||||
<property name="icon">
|
||||
<iconset theme="configure">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctl">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>netctl control</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>netctl control</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfiles">
|
||||
<property name="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWiFi_menu">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WiFi menu</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctl_auto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
152
sources/gui/src/messages.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
/***************************************************************************
|
||||
* 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()
|
||||
{
|
||||
return QApplication::translate("MainWindow", "Unknown flag\n");
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> getArgs()
|
||||
{
|
||||
QMap<QString, QVariant> args;
|
||||
// windows
|
||||
args[QString("detached")] = false;
|
||||
args[QString("minimized")] = static_cast<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("%1/.config/netctl-gui.conf").arg(QDir::homePath());
|
||||
args[QString("debug")] = false;
|
||||
args[QString("defaults")] = false;
|
||||
args[QString("options")] = QString("OPTIONS");
|
||||
args[QString("tab")] = static_cast<int>(1);
|
||||
// messages
|
||||
args[QString("error")] = false;
|
||||
args[QString("help")] = false;
|
||||
args[QString("info")] = false;
|
||||
args[QString("version")] = false;
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
QString helpMessage()
|
||||
{
|
||||
QString helpMessage = QString("");
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
|
||||
helpMessage += QString("netctl-gui [ options ]\n");
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
|
||||
// windows
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
||||
helpMessage += QString(" --detached - %1\n").arg(QApplication::translate("MainWindow", "start detached from console"));
|
||||
helpMessage += QString(" --maximized - %1\n").arg(QApplication::translate("MainWindow", "start maximized"));
|
||||
helpMessage += QString(" --minimized - %1\n").arg(QApplication::translate("MainWindow", "start minimized to tray"));
|
||||
helpMessage += QString(" --about - %1\n").arg(QApplication::translate("MainWindow", "show about window"));
|
||||
helpMessage += QString(" --netctl-auto - %1\n").arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
||||
helpMessage += QString(" --settings - %1\n").arg(QApplication::translate("MainWindow", "show settings window"));
|
||||
// main functions
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
|
||||
helpMessage += QString(" -e, --essid <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this ESSID"));
|
||||
helpMessage += QString(" -o, --open <arg> - %1\n").arg(QApplication::translate("MainWindow", "open this profile"));
|
||||
helpMessage += QString(" -s, --select <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this profile"));
|
||||
// additional functions
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
|
||||
helpMessage += QString(" -c, --config <arg> - %1\n").arg(QApplication::translate("MainWindow", "read configuration from this file"));
|
||||
helpMessage += QString(" -d, --debug - %1\n").arg(QApplication::translate("MainWindow", "print debug information"));
|
||||
helpMessage += QString(" --default - %1\n").arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||
helpMessage += QString(" --set-opts <arg> - %1\n").arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
|
||||
helpMessage += QString(" -t, --tab <arg> - %1\n").arg(QApplication::translate("MainWindow", "open a tab with this number"));
|
||||
// messages
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
|
||||
helpMessage += QString(" -v, --version - %1\n").arg(QApplication::translate("MainWindow", "show version and exit"));
|
||||
helpMessage += QString(" -i, --info - %1\n").arg(QApplication::translate("MainWindow", "show build information and exit"));
|
||||
helpMessage += QString(" -h, --help - %1\n").arg(QApplication::translate("MainWindow", "show this help and exit"));
|
||||
|
||||
return helpMessage;
|
||||
}
|
||||
|
||||
|
||||
QString infoMessage()
|
||||
{
|
||||
QString infoMessage = QString("");
|
||||
// build information
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").arg(QString(BUILD_DATE));
|
||||
// cmake
|
||||
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
|
||||
// cmake properties
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "cmake properties"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
// components
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Components"));
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QString("\t-DBUILD_GUI=%1\n").arg(QString(PROJECT_BUILD_GUI));
|
||||
infoMessage += QString("\t-DBUILD_HELPER=%1\n").arg(QString(PROJECT_BUILD_HELPER));
|
||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
|
||||
// additional components
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Additional components"));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
infoMessage += QString("\t-DBUILD_TEST=%1\n").arg(QString(PROJECT_BUILD_TEST));
|
||||
// project properties
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Project properties"));
|
||||
infoMessage += QString("\t-DDBUS_SYSTEMCONF_PATH=%1\n").arg(QString(PROJECT_DBUS_SYSTEMCONF_PATH));
|
||||
infoMessage += QString("\t-DSYSTEMD_SERVICE_PATH=%1\n").arg(QString(PROJECT_SYSTEMD_SERVICE_PATH));
|
||||
infoMessage += QString("\t-DUSE_CAPABILITIES=%1\n").arg(QString(PROJECT_USE_CAPABILITIES));
|
||||
infoMessage += QString("\t-DUSE_KDE4=%1\n").arg(QString(PROJECT_USE_KDE4));
|
||||
infoMessage += QString("\t-DUSE_QT5=%1\n").arg(QString(PROJECT_USE_QT5));
|
||||
// transport information
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
|
||||
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
|
||||
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
infoMessage += QString("\tDBUS_HELPER_SERVICE=%1\n").arg(QString(DBUS_HELPER_SERVICE));
|
||||
infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH));
|
||||
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
|
||||
// docs path
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Documentation"));
|
||||
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
|
||||
|
||||
return infoMessage;
|
||||
}
|
||||
|
||||
|
||||
QString versionMessage()
|
||||
{
|
||||
QString versionMessage = QString("");
|
||||
versionMessage += QString("%1\n").arg(QString(NAME));
|
||||
versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Version")).arg(QString(VERSION));
|
||||
versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Author")).arg(QString(AUTHOR));
|
||||
versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "License")).arg(QString(LICENSE));
|
||||
|
||||
return versionMessage;
|
||||
}
|
34
sources/gui/src/messages.h
Normal file
@ -0,0 +1,34 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MESSAGES_H
|
||||
#define MESSAGES_H
|
||||
|
||||
#include <QChar>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
QString errorMessage();
|
||||
QMap<QString, QVariant> getArgs();
|
||||
QString helpMessage();
|
||||
QString infoMessage();
|
||||
QString versionMessage();
|
||||
|
||||
|
||||
#endif /* MESSAGES_H */
|
156
sources/gui/src/mobilewidget.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
/***************************************************************************
|
||||
* 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 "mobilewidget.h"
|
||||
#include "ui_mobilewidget.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
MobileWidget::MobileWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::MobileWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
MobileWidget::~MobileWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::clear()
|
||||
{
|
||||
ui->lineEdit_username->clear();
|
||||
ui->lineEdit_password->clear();
|
||||
ui->lineEdit_apn->clear();
|
||||
ui->lineEdit_pin->clear();
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->spinBox_fail->setValue(5);
|
||||
ui->checkBox_route->setCheckState(Qt::Checked);
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
ui->lineEdit_options->clear();
|
||||
|
||||
ui->pushButton_mobileAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::selectOptionsFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("MobileWidget", "Select options file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_options->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||
ui->widget_mobileAdvanced->setHidden(false);
|
||||
ui->pushButton_mobileAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_mobileAdvanced->setHidden(true);
|
||||
ui->pushButton_mobileAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MobileWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (!ui->lineEdit_username->text().isEmpty())
|
||||
settings[QString("User")] = QString("'%1'").arg(ui->lineEdit_username->text());
|
||||
if (!ui->lineEdit_password->text().isEmpty())
|
||||
settings[QString("Password")] = QString("'%1'").arg(ui->lineEdit_password->text());
|
||||
settings[QString("AccessPointName")] = ui->lineEdit_apn->text();
|
||||
if (!ui->lineEdit_pin->text().isEmpty())
|
||||
settings[QString("PIN")] = QString("'%1'").arg(ui->lineEdit_pin->text());
|
||||
else
|
||||
settings[QString("PIN")] = QString("None");
|
||||
settings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
settings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (ui->checkBox_route->checkState() == Qt::Unchecked)
|
||||
settings[QString("DefaultRoute")] = QString("false");
|
||||
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
|
||||
settings[QString("UsePeerDNS")] = QString("false");
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
settings[QString("OptionsFile")] = QString("'%1'").arg(ui->lineEdit_options->text());
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int MobileWidget::isOk()
|
||||
{
|
||||
// APN is not set
|
||||
if (ui->lineEdit_apn->text().isEmpty()) return 1;
|
||||
// config file doesn't exist
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_options->text()).exists()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(settings[QString("User")]);
|
||||
if (settings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(settings[QString("Password")]);
|
||||
if (settings.contains(QString("AccessPointName")))
|
||||
ui->lineEdit_apn->setText(settings[QString("AccessPointName")]);
|
||||
if (settings.contains(QString("PIN")))
|
||||
ui->lineEdit_pin->setText(settings[QString("PIN")]);
|
||||
if (settings.contains(QString("Mode"))) {
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(settings[QString("MaxFail")].toInt());
|
||||
if (settings.contains(QString("DefaultRoute")))
|
||||
if (settings[QString("DefaultRoute")] == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (settings.contains(QString("UsePeerDNS")))
|
||||
if (settings[QString("UsePeerDNS")] == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (settings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(settings[QString("OptionsFile")]);
|
||||
}
|
52
sources/gui/src/mobilewidget.h
Normal file
@ -0,0 +1,52 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MOBILEWIDGET_H
|
||||
#define MOBILEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MobileWidget;
|
||||
}
|
||||
|
||||
class MobileWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MobileWidget(QWidget *parent = 0);
|
||||
~MobileWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private slots:
|
||||
void selectOptionsFile();
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
Ui::MobileWidget *ui;
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
||||
#endif /* MOBILEWIDGET_H */
|
428
sources/gui/src/mobilewidget.ui
Normal file
@ -0,0 +1,428 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MobileWidget</class>
|
||||
<widget class="QWidget" name="MobileWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>445</width>
|
||||
<height>314</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_mobile">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Mobile PPP settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_mobile">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_username">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_username">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_username">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_password">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_apn">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_apn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Access point name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_apn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The access point (apn) to connect on</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pin">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PIN</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>If your modem requires a PIN to unlock, use this option</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option is used to specify the connection mode</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3Gpref</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3Gonly</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>GPRSpref</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>GPRSonly</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mobileAdvanced">
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="pushButton_mobileAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_mobileAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_route">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_route">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_route">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Use the default route provided by the peer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default route</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dns">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dns">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_dns">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Use the DNS provided by the peer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use peer DNS</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fail">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fail">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max fail</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fail">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The number of consecutive failed connection attempts to tolerate</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_options">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Options file</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A file to read additional pppd options from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_username</tabstop>
|
||||
<tabstop>lineEdit_password</tabstop>
|
||||
<tabstop>lineEdit_apn</tabstop>
|
||||
<tabstop>lineEdit_pin</tabstop>
|
||||
<tabstop>comboBox_mode</tabstop>
|
||||
<tabstop>spinBox_fail</tabstop>
|
||||
<tabstop>lineEdit_options</tabstop>
|
||||
<tabstop>pushButton_options</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
444
sources/gui/src/netctlautowindow.cpp
Normal file
@ -0,0 +1,444 @@
|
||||
/***************************************************************************
|
||||
* 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 <pdebug/pdebug.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
configuration(settings)
|
||||
{
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
// ui
|
||||
ui = new Ui::NetctlAutoWindow;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget->setColumnHidden(2, true);
|
||||
ui->tableWidget->setColumnHidden(3, true);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(settings[QString("NETCTLAUTO_TOOLBAR")].toInt()));
|
||||
|
||||
createActions();
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
|
||||
}
|
||||
|
||||
|
||||
NetctlAutoWindow::~NetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea NetctlAutoWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
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->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
|
||||
// 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)));
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::showMessage(const bool status)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::showWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == nullptr) 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("list-add"));
|
||||
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
|
||||
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
||||
// set text
|
||||
startProfile->setVisible(ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty());
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("list-add"));
|
||||
} else {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
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;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
netctlInformation info = generalInformation(mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
|
||||
// actions
|
||||
ui->actionDisableAll->setEnabled(info.netctlAuto);
|
||||
ui->actionEnableAll->setEnabled(info.netctlAuto);
|
||||
ui->actionRestartService->setEnabled(info.netctlAuto);
|
||||
if (info.netctlAutoEnabled)
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
||||
else
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
|
||||
if (info.netctlAuto) {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
|
||||
} else {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
|
||||
netctlAutoRefreshButtons(nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->tableWidget->setSortingEnabled(false);
|
||||
ui->tableWidget->selectRow(-1);
|
||||
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget->clear();
|
||||
ui->tableWidget->setRowCount(info.netctlAutoProfiles.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", "Enabled"));
|
||||
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
for (int i=0; i<info.netctlAutoProfiles.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(info.netctlAutoProfiles[i].active);
|
||||
font.setItalic(info.netctlAutoProfiles[i].enabled);
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile"))
|
||||
.arg(info.netctlAutoProfiles[i].name);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active"))
|
||||
.arg(checkStatus(info.netctlAutoProfiles[i].active));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled"))
|
||||
.arg(checkStatus(!info.netctlAutoProfiles[i].enabled));
|
||||
// name
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(info.netctlAutoProfiles[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(info.netctlAutoProfiles[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(info.netctlAutoProfiles[i].active, true)));
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// enabled
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(info.netctlAutoProfiles[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->setCurrentCell(-1, -1);
|
||||
ui->tableWidget->setDisabled(false);
|
||||
showMessage(true);
|
||||
|
||||
netctlAutoRefreshButtons(nullptr, nullptr);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoDisableAllProfiles();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoDisableAll"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoEnableProfile(profile);
|
||||
else try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
responce = sendRequestToCtrlWithArgs(QString("autoEnable"), args, debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoEnableAllProfiles();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoEnableAll"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoStartProfile(profile);
|
||||
else try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
responce = sendRequestToCtrlWithArgs(QString("autoStart"), args, debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoEnableService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoEnableService();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoServiceEnable"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoRestartService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("systemctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("systemctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoRestartService();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoServiceRestart"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoStartService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("systemctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("systemctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoStartService();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoServiceStart"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool selected = (current != nullptr);
|
||||
ui->actionEnable->setEnabled(selected);
|
||||
ui->actionSwitch->setEnabled(selected && ui->tableWidget->item(current->row(), 2)->text().isEmpty());
|
||||
if (selected && !ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
} else {
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
|
||||
}
|
||||
}
|
74
sources/gui/src/netctlautowindow.h
Normal file
@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* 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 <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class NetctlAutoWindow;
|
||||
}
|
||||
|
||||
class NetctlAutoWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NetctlAutoWindow(QWidget *parent = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>(),
|
||||
const bool debugCmd = false);
|
||||
~NetctlAutoWindow();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
void showMessage(const bool status);
|
||||
void showWindow();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
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:
|
||||
// ui
|
||||
Ui::NetctlAutoWindow *ui = nullptr;
|
||||
MainWindow *mainWindow = nullptr;
|
||||
// backend
|
||||
void createActions();
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLAUTOWINDOW_H */
|
209
sources/gui/src/netctlautowindow.ui
Normal file
@ -0,0 +1,209 @@
|
||||
<?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="centralLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSwitch"/>
|
||||
<addaction name="actionEnable"/>
|
||||
</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="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>
|
||||
<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="list-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>
|
||||
<property name="toolTip">
|
||||
<string>Start or stop 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>
|
||||
<property name="toolTip">
|
||||
<string>Enable or disable service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh table</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="list-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable or disable profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSwitch">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Switch to profile</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|