Compare commits

..

144 Commits

Author SHA1 Message Date
5a171f6c67 fix url links 2016-03-06 18:29:36 +03:00
arcan1s
c2e4ea2258 fix #46, release 1.4.9 2015-12-21 11:26:54 +03:00
arcan1s
d2714dca02 some library refactoring 2015-08-20 00:13:09 +03:00
arcan1s
5efb25dca3 edit mobilewidget.ui, main and wifi tab now only will be update if they
are active
2015-08-19 00:42:29 +03:00
arcan1s
e67493f5c0 plasmoid fixes 2015-08-15 02:35:09 +03:00
arcan1s
32f7b9344c fix font rendering 2015-07-11 01:22:24 +03:00
arcan1s
2041e01caa Fix pkgbuild 2015-07-06 01:28:29 +03:00
arcan1s
271fdb0d99 release 1.4.8 2015-07-06 01:25:15 +03:00
arcan1s
45904db741 fix no actions on links activation 2015-07-05 00:32:46 +03:00
arcan1s
a216060447 update to netctl 1.10 and 1.11 changes 2015-07-02 00:08:14 +03:00
arcan1s
05a613b501 release 1.4.7 2015-06-28 14:30:56 +03:00
arcan1s
a9c7f98677 more correct work with configration files (use /etc/netctl-gui.conf if
no configuration present in the home directory)
2015-06-28 00:07:44 +03:00
arcan1s
5018232c08 * drop absolute path from configuration
* add configuration from cmake building
* update submodules
2015-06-27 05:10:56 +03:00
arcan1s
aed09bf798 release 1.4.6 2015-06-25 12:23:04 +03:00
arcan1s
d299e7d9a1 some changes in netctl engine 2015-06-24 02:10:27 +03:00
arcan1s
cf7b013726 drop call which does not lead to crash 2015-06-22 09:25:55 +03:00
arcan1s
b65ba2ebe2 fix #44
possible fix #43
2015-06-21 01:13:37 +03:00
arcan1s
69f6a3135b derop notification on status changing since it causes plasmacrash 2015-06-20 15:20:01 +03:00
arcan1s
7dc1a5eda3 implement datetime logging feature 2015-06-19 02:23:44 +03:00
arcan1s
168a270c98 translation update 2015-06-15 22:12:51 +03:00
arcan1s
c3aa3f0c8f implement autoupdate feature
fix bug with invalid profile path using by external editor
2015-06-03 14:31:09 +03:00
arcan1s
e26da85b5f release 1.4.5
+ add translation support to plugin part
* more correct interface painting
* more correct configuration interface painting (fix #42)
* move plugin from private
2015-05-13 00:02:48 +03:00
arcan1s
f665a46346 release 1.4.4
Fix minfo
2015-04-30 01:08:12 +03:00
arcan1s
d541d0a755 bump version 2015-04-23 17:54:56 +03:00
arcan1s
0f5bf03e38 release 1.4.3 2015-04-23 17:52:57 +03:00
arcan1s
3695914226 update submodules, add clang build, fix bug in wpasup 2015-04-23 17:51:52 +03:00
arcan1s
03dbfce482 1.4.2-2 2015-03-21 00:41:02 +03:00
arcan1s
6a8d2701b0 fix drivers 2015-03-21 00:30:04 +03:00
arcan1s
ff3e000688 release 1.4.2
* fix work with helper from GUI
2015-03-21 00:00:47 +03:00
arcan1s
824a11457b release 1.4.1 2015-03-20 00:20:44 +03:00
arcan1s
b7fa17df4e improve dataengine permofrmance (fix #39) - TODO: need to be tested 2015-03-19 11:45:13 +03:00
arcan1s
35af460b7b fix crash on null connection 2015-03-18 06:13:35 +03:00
arcan1s
9aa1f6d715 implement #38
freeze code base to release 1.4.1
2015-03-18 03:33:30 +03:00
arcan1s
308f9824b4 implement #37 2015-03-17 14:07:05 +03:00
arcan1s
bf7521481a implement #36
update translations
2015-03-17 13:22:45 +03:00
arcan1s
e4bcfb1653 fix kde4 build
fix tray destruction on KF5
2015-03-16 08:52:23 +03:00
arcan1s
a2b1d46900 Prepare to release 1.4.1
update docs, update ui
deprecate description function
2015-03-16 05:14:53 +03:00
arcan1s
3f49988cef update submodule
update netctl-auto
update interfaces
2015-03-15 18:17:49 +03:00
arcan1s
f80d6aae6b end work on interfaces 2015-03-14 06:42:06 +03:00
arcan1s
ef2694d7a7 add calls
create interface dbus interface
2015-03-13 08:22:02 +03:00
arcan1s
26afd90df9 + add toolbar config
+ create interface class
* update UI
2015-03-13 05:12:06 +03:00
arcan1s
02432be630 edit ui
* remove margins
* create more pretty toolbars
* edit toolbar update action (s/setVisible/setEnabled/g)
2015-03-12 02:02:20 +03:00
arcan1s
275d71d75f rewrite ui (refactoring, simplification, improvement of user expierence) 2015-03-11 07:19:20 +03:00
arcan1s
b90f441fde roll back interfaces to wpa_cli
improvement of wpa_supplicant control
2015-03-10 07:53:15 +03:00
arcan1s
19976819a1 + add CurrentWiFi method
+ add support of pid files with interface name to provide compability
with netctl module
* change default wpa_sup ctrl paths
* optimization of wifi calls
2015-03-10 00:52:45 +03:00
arcan1s
362a11f0bc + new Verbose* DBus calls
+ new force request to netctl (DBus)
+ PointType enum
+ notification on hidding,
+ new columns in WiFi menu
* improve user expierence
* fix language definition
* fix tests
* update 3rdparty components
* small refactoring
2015-03-09 08:29:26 +03:00
arcan1s
d94aa4ebf7 update KDE4 plasmoid 2015-03-08 19:24:21 +03:00
arcan1s
2cf876cf32 * edit WiFi and ProfileList calls
* optimization of WifiMenu
* small refactoring
2015-03-07 17:12:33 +03:00
arcan1s
9993fee336 rewrite netctlautowindow ui 2015-03-05 12:05:34 +03:00
arcan1s
de0c1f208d edit dbus calls
TODO edit dbus call in netctlautowindow (create callbacks too)
2015-03-03 16:11:38 +03:00
arcan1s
25ca2ef1d9 rewrite private slots
TODO: add more methods to dbusinteraction, check dbus calls
2015-03-02 06:00:42 +03:00
arcan1s
1333967535 rewrite ui part (except for privateslots) 2015-02-28 04:05:34 +03:00
arcan1s
e70ebe318d small refactoring 2015-02-27 18:46:28 +03:00
arcan1s
dcdf03f639 refactoring of profile widgets 2015-02-27 18:10:23 +03:00
arcan1s
8b33ec859b refactoring of library part 2015-02-26 06:20:23 +03:00
arcan1s
53ff63b792 + add ja to available langs
+ add signals to lineEdits
* rewrite errorwindow class to static methods
* replace mask in ip lineedits to validators (fix #34)
* fix advanced lines
* move AdHoc and Hidden options to advanced (#28)
* fix default wpa_supplicant conf path (#28)
* update toolbars to #2
* replace General settings section to Common (see http://doc.qt.io/qt-5/qsettings.html#Format-enum)
2015-02-24 05:32:37 +03:00
arcan1s
b46ce1620b fix #25 2015-02-19 13:06:06 +03:00
arcan1s
4c20a54d7e small update 2015-02-18 16:23:07 +03:00
arcan1s
a73968f98b * refactoring and optimization KF5 part (#26, #31)
* add info instrument
* implement needToBeConfigured() slot, see #29
* fix (#30)
some improvements
2015-02-17 10:44:51 +03:00
arcan1s
9033c51bb4 update files
add _DEFAULT_SOURCE to avoid warnings
fix cppcheck messages
2015-01-14 00:59:42 +03:00
arcan1s
d23429891e release 1.4.0 2015-01-12 19:30:49 +03:00
arcan1s
cf12b3627e update ChangeLog
update CmakeLists
update PKGBUILDs
fix GUI building
2015-01-12 01:14:40 +03:00
arcan1s
582459d174 fix #24
update gitignore
2015-01-11 00:38:47 +03:00
arcan1s
08e7390f6c Merge branch 'master' of github.com:arcan1s/netctl-gui 2015-01-10 00:36:26 +03:00
arcan1s
c8eae4b222 fix painting
update translations
fix PKGBUILD
2015-01-10 00:35:52 +03:00
arcan1s
54583eae6e update interface painting 2015-01-09 02:40:24 +03:00
arcan1s
634b4c3b41 try to paint more pretty interface 2015-01-08 02:00:59 +03:00
arcan1s
54c5e7958a kf5 update
* implement resizing
* implement debug
* implement notifications
* update interface
* correct work with helper
2015-01-07 07:03:41 +03:00
arcan1s
6ed45fa7a5 change in updates 2015-01-06 00:46:28 +03:00
arcan1s
73ba838685 + add de page
* rewrite de configuration to use qsettings
- remove cppcheck
+ add notifyrc
2015-01-05 00:29:52 +03:00
arcan1s
924beacc23 implement actions 2015-01-04 02:01:07 +03:00
arcan1s
a830fc9372 Merge branch 'kf5' 2015-01-03 13:58:17 +03:00
arcan1s
4c7459e833 Merge branch 'kf5' of github.com:arcan1s/netctl-gui into kf5 2015-01-03 13:56:33 +03:00
arcan1s
00a35d75d2 add ability to build kde4 and kf5 packages 2015-01-03 13:56:00 +03:00
Evgeniy Alekseev
3e92ec2aae Update CMakeLists.txt
bump to 1.4.0
2015-01-03 13:23:16 +03:00
arcan1s
3ac0484f21 some test with actions 2014-12-31 08:09:53 +03:00
arcan1s
cbac07b29e move method from original one 2014-12-30 14:39:25 +03:00
arcan1s
7972f2d6d3 some configuration interface changes 2014-12-29 23:37:21 +03:00
arcan1s
afed94745a fix plugin 2014-12-29 20:56:35 +03:00
arcan1s
c8f260c8e2 rename applet to *plasma* 2014-12-29 08:35:23 +03:00
arcan1s
edb386d24e implement binary module 2014-12-28 17:42:08 +03:00
arcan1s
f188dea8a7 add wdiget.qml 2014-12-27 12:24:05 +03:00
arcan1s
6fb7da4b5b add appearance.qml 2014-12-27 03:50:31 +03:00
arcan1s
a35e9b0164 first work on plasmoid 2014-12-26 08:22:26 +03:00
arcan1s
4bc428f8b5 add workaround to #23
(fix?)
2014-12-05 03:52:27 +03:00
arcan1s
030dec5e14 end porting of DE to KF5 2014-10-21 16:26:35 +04:00
arcan1s
0898a99878 updte dataengine skel 2014-10-21 13:06:57 +04:00
arcan1s
8dd48fa7cc release 1.3.3
fix #19
2014-10-19 17:50:24 +04:00
arcan1s
287405f81a try fix #19 2014-10-18 01:17:15 +04:00
arcan1s
fa27b80060 add some w\o 2014-10-17 13:52:46 +04:00
Evgeniy Alekseev
c2c14c4911 Merge pull request #18 from nosada/translate_to_ja
Fix translation on plasmoid
2014-10-13 11:58:23 +04:00
NOGISAKA Sadata
e2deb8751d fix translation at plasmoid 2014-10-13 16:43:37 +09:00
NOGISAKA Sadata
1fe7d6e21f change translation at plasmoid (again) 2014-10-13 16:43:37 +09:00
NOGISAKA Sadata
e68be6d4f1 change translation at plasmoid 2014-10-13 16:43:37 +09:00
arcan1s
45d3a42754 update tasks 2014-10-09 22:58:13 +04:00
arcan1s
cb0410a182 update pkgbuild #17 2014-09-27 18:25:41 +04:00
arcan1s
9d349461cf release 1.3.2 2014-09-22 00:56:12 +04:00
arcan1s
d41a34673b add translations to resources
fix plasmoid icon
2014-09-21 14:28:58 +04:00
NOGISAKA Sadata
b199b43f58 fix mistakes and fluctuation of description at plasmoid 2014-09-19 13:55:43 +09:00
NOGISAKA Sadata
6d212efe1e fix mistakes and fluctuation of description at netctlgui-helper 2014-09-19 13:55:43 +09:00
NOGISAKA Sadata
d32486d882 fix mistakes and fluctuation of description at netctl-gui 2014-09-19 13:55:43 +09:00
arcan1s
5afa65ce68 edit authors 2014-09-19 00:44:55 +04:00
NOGISAKA Sadata
5b46247df2 finished 2014-09-19 01:09:56 +09:00
NOGISAKA Sadata
bda5433716 translating netctl-gui to Japanese (yet not finished) 2014-09-19 01:09:56 +09:00
NOGISAKA Sadata
835e82ca63 translated netctlgui-helper to Japanese 2014-09-19 01:09:56 +09:00
NOGISAKA Sadata
98cdb18d62 translating netctl-gui to Japanese (yet not finished), and modify plasmoid translating file 2014-09-19 01:09:56 +09:00
NOGISAKA Sadata
cd59a9b294 translating netctl-gui to Japanese (not finished) 2014-09-19 01:09:56 +09:00
NOGISAKA Sadata
4780433c4d translated plasmoid to Japanese 2014-09-19 01:09:56 +09:00
arcan1s
28a4934a82 change appmenu to button set to better user experience
(if user will have global appmenu enabled)
2014-09-09 09:38:59 +04:00
arcan1s
4e8bbeed35 update archlinux install scripts 2014-09-06 15:24:42 +04:00
arcan1s
f86ef0514b release 1.3.1 2014-09-06 15:02:05 +04:00
arcan1s
4c004af1ae add dbus configuration to backup 2014-08-27 22:30:49 +04:00
arcan1s
66e3a737d4 rollback some changes since
1) systemd-user doesn't work correctly with session bus
2) systemd-user cannot set capabilities
2014-08-27 22:24:19 +04:00
arcan1s
9cf6552c71 update install files 2014-08-27 18:20:12 +04:00
arcan1s
f18e74917b more correct checking dbus response 2014-08-27 18:14:22 +04:00
arcan1s
b909222db9 better submodules integration (hope =))
add --session support to the helper
2014-08-27 17:23:12 +04:00
arcan1s
0c7868536a update to changes 2014-08-27 17:12:52 +04:00
arcan1s
fc3956caf1 ya submodules fix 2014-08-27 17:07:00 +04:00
arcan1s
4cf3c85070 fix submodules (see #14) 2014-08-27 16:26:38 +04:00
arcan1s
6e57baccaf remove description from security notes 2014-08-27 11:47:44 +04:00
arcan1s
5ed704e676 rewrite to use submodules 2014-08-26 16:06:13 +04:00
arcan1s
eb3753ab25 update 3rdparty/language 2014-08-26 10:46:14 +04:00
arcan1s
f9d71577f3 update html docs to standards 2014-08-25 23:52:10 +04:00
arcan1s
814f2c7904 update license agreement to trdparty items 2014-08-25 20:29:30 +04:00
arcan1s
ceca889be4 release 1.3.0 2014-08-25 16:06:31 +04:00
arcan1s
696283b1e1 update readme/prepare to release 2014-08-25 15:06:03 +04:00
arcan1s
15cc3a8595 rename wifi tab 2014-08-25 14:59:34 +04:00
arcan1s
e8c3441f29 add profile reading description 2014-08-25 11:53:14 +04:00
arcan1s
2de7b26f66 change name to id in html docs 2014-08-25 11:42:50 +04:00
arcan1s
8f35aeb88f rewrite actions to qtoolbutton 2014-08-25 11:34:08 +04:00
arcan1s
b49188c104 remove kde runtime from optdep list 2014-08-25 10:56:45 +04:00
arcan1s
f8bf8830be fix mans 2014-08-25 10:55:34 +04:00
arcan1s
6e6c547460 unify configuration names 2014-08-25 10:54:18 +04:00
arcan1s
d287f52ba5 rename layout 2014-08-25 10:48:01 +04:00
arcan1s
8cc02a07fb update translations 2014-08-24 16:45:19 +04:00
arcan1s
28d51484b1 fix update toolboxes 2014-08-24 16:40:01 +04:00
arcan1s
e7d2e0bd38 change menu to toolboxes 2014-08-24 16:30:37 +04:00
arcan1s
999914926a add force* slots 2014-08-24 13:08:13 +04:00
arcan1s
e21b2201ab small tray fixes 2014-08-24 13:00:50 +04:00
arcan1s
d65ded6072 update messages 2014-08-20 23:37:37 +04:00
arcan1s
16662f697b cleanup!
(remove symlinks)
2014-08-20 22:16:06 +04:00
arcan1s
35d740b778 update build script 2014-08-20 21:25:56 +04:00
arcan1s
0a16364a7a update docs
change building
2014-08-20 21:16:31 +04:00
arcan1s
e9090ab4a9 remove suid bit to use capabilities 2014-08-20 20:21:34 +04:00
230 changed files with 22695 additions and 10637 deletions

2
.gitignore vendored
View File

@ -25,3 +25,5 @@ usr/
# translations # translations
*.qm *.qm
# temporary bckps
*~

12
.gitmodules vendored Normal file
View 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

View File

@ -1,2 +1,5 @@
Current developers: Current developers:
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com> Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
Translators:
@nosada (Japanese translation)

214
CHANGELOG
View File

@ -1,17 +1,177 @@
Ver.1.4.9
---------
* library
* fix bug with invalid enabled profile definition (#46)
* some imrovements inside
* plasmoid
* change rendering from Qt to native
* update plasmoid to recent plasma changes
Ver.1.4.8
---------
* gui
* update profile tab to netclt 1.10 and 1.11 changes
* plasmoid
* fix bug with no action on link activation
Ver.1.4.7
---------
* all
+ implement support of setting of default configuration values while building
* fix language component (refer to #45)
* gui
* more correct work with configuration file
* helper
* more correct work with configuration file
Ver.1.4.6
---------
* all
+ implement time logging feature
* gui
+ implement autoupdate feature
- fix invalid profile path for the external editor
* library
+ implement netctl-auto support to scanWiFi() method (#44)
- fix bug with invalid data in netctl-auto profile list output
Ver.1.4.5
---------
* plasmoid
+ add translation support to plugin part
* more correct interface painting
* more correct configuration interface painting
* move plugin from private
Ver.1.4.4
---------
* dataengine
- fix profile status definition
Ver.1.4.3
---------
* all
- fix clang build (#41)
- fix WPA_DRIVERS (#40)
* library
- fix bug in WpaSup class with invalid returning value
***
Ver.1.4.2
---------
* gui
* remove Update call to the helper
Ver.1.4.1
---------
* all
+ 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 Ver.1.3.0
--------- ---------
* all: * all
+ add processes error messages + add processes error messages
+ add support of several active profiles + add support of several active profiles
* some bug fixes and refactoring * some bug fixes and refactoring
* rewrite debug messages * rewrite debug messages
* dataengine: * dataengine
+ add new sources: intIp6, extIp6, netctlAutoStatus + add new sources: intIp6, extIp6, netctlAutoStatus
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7) * rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
* change default command to define external IP * change default command to define external IP
* change interface list definition * change interface list definition
* change internal IP definition * change internal IP definition
* gui: * gui
+ add 3rd party license information + add 3rd party license information
+ add system tray icon as an alternative to the plasmoid + add system tray icon as an alternative to the plasmoid
+ add DBus session interface org.netctlgui.netctlgui + add DBus session interface org.netctlgui.netctlgui
@ -21,29 +181,33 @@ Ver.1.3.0
+ add ability to use helper + add ability to use helper
+ add ability to start minimized/maximized/detached + add ability to start minimized/maximized/detached
+ add ability to don't save profile from WiFi tab + add ability to don't save profile from WiFi tab
+ add ability to skip external components checking
- remove buttons
* more correct actions into SettingsWindow * more correct actions into SettingsWindow
* update to library changes * update to library changes
* rewrite tables to use toolTip * rewrite tables to use toolTip
* edit about window * edit about window
* helper: * change menuBar
* helper
+ create daemon DBus system interface org.netctlgui.helper to the library: + create daemon DBus system interface org.netctlgui.helper to the library:
self control slots, netctl control slots and netctl information slots self control slots, netctl control slots and netctl information slots
+ add tests + add tests
* library: * library
+ add custom structures netctlWifiInfo and netctlProfileInfo + add custom structures netctlWifiInfo and netctlProfileInfo
+ add methods getActiveProfile(), autoGetActiveProfile() + add methods getActiveProfile(), autoGetActiveProfile()
+ add slot switchToProfile() + add slot switchToProfile()
+ add slot stopAllProfiles() + add slot stopAllProfiles()
+ add slot reenableProfile() + add slot reenableProfile()
+ add slots getRecommendedConfiguration() + add slots getRecommendedConfiguration()
+ add slots forceStartProfile() and forceStopProfile()
+ add double quotes to profile names + add double quotes to profile names
+ add tests + add tests
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
* rename getInterfaceList() to getWirelessInterfaceList()
* change temporaty directory from $HOME/.cache to system one
- remove functions getProfileDescriptions() and getProfileStatuses() - remove functions getProfileDescriptions() and getProfileStatuses()
- remove SleepThread class - remove SleepThread class
* plasmoid: * 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 + add 3rd party license information
+ allow plasmoid to use system tray + allow plasmoid to use system tray
+ add ability to use helper + add ability to use helper
@ -56,14 +220,14 @@ Ver.1.3.0
Ver.1.2.0 Ver.1.2.0
--------- ---------
* all: * all
+ add icons + add icons
+ add support of netctl-auto + add support of netctl-auto
* changes in the project architecture * changes in the project architecture
* refactoring * refactoring
* dataengine: * dataengine
+ add debug information (NETCTLGUI_DEBUG=yes) + add debug information (NETCTLGUI_DEBUG=yes)
* gui: * gui
+ add support of macvlan + add support of macvlan
+ add ability to remove profile + add ability to remove profile
+ add support of hidden wifi network + add support of hidden wifi network
@ -81,13 +245,13 @@ Ver.1.2.0
* refactoring of configuration interface * refactoring of configuration interface
* change setting of the interface to profile tab * change setting of the interface to profile tab
* rewrite ErrorWindow class * rewrite ErrorWindow class
* library: * library
+ detach backend from frontend + detach backend from frontend
+ add error checking + add error checking
+ add doxygen documentation + add doxygen documentation
* more debug information * more debug information
* rewrite getSettingsFromProfile() function * rewrite getSettingsFromProfile() function
* plasmoid: * plasmoid
+ add dataengine configuration + add dataengine configuration
+ add about window + add about window
+ add debug information (NETCTLGUI_DEBUG=yes) + add debug information (NETCTLGUI_DEBUG=yes)
@ -99,26 +263,26 @@ Ver.1.2.0
Ver.1.1.0 (netctl-1.7 update) Ver.1.1.0 (netctl-1.7 update)
----------------------------- -----------------------------
* dataengine: * dataengine
* change definition if profile is enabled * change definition if profile is enabled
* gui: * gui
+ add frequency + add frequency
* change definition if profile is enabled * change definition if profile is enabled
* plasmoid: * plasmoid
+ add menu title + add menu title
*** ***
Ver.1.0.6 Ver.1.0.6
--------- ---------
* gui: * gui
* fix error checking * fix error checking
*** ***
Ver.1.0.5 Ver.1.0.5
--------- ---------
* plasmoid: * plasmoid
+ add "Start WiFi menu" function + add "Start WiFi menu" function
* refactoring * refactoring
* edit icon * edit icon
@ -127,9 +291,9 @@ Ver.1.0.5
Ver.1.0.4 Ver.1.0.4
--------- ---------
* gui: * gui
+ add Qt5 gui (by default) + add Qt5 gui (by default)
* plasmoid: * plasmoid
+ add notifications + add notifications
* fix run command with sudo from plasmoid * fix run command with sudo from plasmoid
@ -137,23 +301,23 @@ Ver.1.0.4
Ver.1.0.3 Ver.1.0.3
--------- ---------
* all: * all
* refactoring * refactoring
* plasmoid: * plasmoid
+ edit russian translation + edit russian translation
*** ***
Ver.1.0.2 Ver.1.0.2
--------- ---------
* plasmoid: * plasmoid
- fix layout margins - fix layout margins
*** ***
Ver.1.0.1 Ver.1.0.1
--------- ---------
* all: * all
- remove scripts - remove scripts
*** ***

147
PKGBUILD
View File

@ -1,147 +0,0 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgbase=netctl-gui
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
'libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
'kdeplasma-applets-netctl-gui')
pkgver=1.3.0
pkgrel=1
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui"
license=('GPL3')
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
install="${pkgbase}.install"
md5sums=('d99eba4101fee42ebbfa5735aa706bc9')
prepare() {
rm -rf "${srcdir}/build-"{plasmoid,qt4,qt5}
mkdir "${srcdir}/build-"{plasmoid,qt4,qt5}
}
build() {
cd "${srcdir}/build-plasmoid"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_GUI:BOOL=0 \
-DBUILD_LIBRARY:BOOL=0 \
-DBUILD_HELPER:BOOL=0 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt4"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
-DUSE_QT5:BOOL=0 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt5"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
"../${pkgbase}"
make
}
package_kdeplasma-applets-netctl-gui() {
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'kdebase-workspace')
optdepends=('kdebase-runtime: sudo support'
'netctlgui-helper: DBus helper daemon'
'netctlgui-helper-qt4: DBus helper daemon'
'netctl-gui: graphical front-end'
'netctl-gui-qt4: graphical front-end'
'sudo: sudo support')
install="${pkgbase}.install"
cd "${srcdir}/build-plasmoid"
make DESTDIR="${pkgdir}" install
}
package_libnetctlgui() {
pkgdesc="Qt5 library which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'qt5-base')
optdepends=('netctlgui-helper: DBus helper daemon'
'sudo: sudo support'
'wpa_supplicant: wifi support')
provides=('libnetctlgui-qt4')
conflicts=('libnetctlgui-qt4')
cd "${srcdir}/build-qt5/netctlgui"
make DESTDIR="${pkgdir}" install
}
package_netctlgui-helper() {
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
depends=('libnetctlgui')
provides=('netctlgui-helper-qt4')
conflicts=('netctlgui-helper-qt4')
backup=('etc/netctlgui-helper.conf')
cd "${srcdir}/build-qt5/helper"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui() {
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
depends=('libnetctlgui' 'xdg-utils')
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
'netctlgui-helper: DBus helper daemon')
provides=('netctl-gui-qt4')
conflicts=('netctl-gui-qt4')
install="${pkgbase}.install"
cd "${srcdir}/build-qt5/gui"
make DESTDIR="${pkgdir}" install
}
package_libnetctlgui-qt4() {
pkgdesc="Qt4 library which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'qt4')
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
'sudo: sudo support'
'wpa_supplicant: wifi support')
provides=('libnetctlgui')
conflicts=('libnetctlgui')
cd "${srcdir}/build-qt4/netctlgui"
make DESTDIR="${pkgdir}" install
}
package_netctlgui-helper-qt4() {
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
depends=('libnetctlgui-qt4')
provides=('netctlgui-helper')
conflicts=('netctlgui-helper')
backup=('etc/netctlgui-helper.conf')
cd "${srcdir}/build-qt4/helper"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui-qt4() {
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
depends=('libnetctlgui-qt4')
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
'netctlgui-helper-qt4: DBus helper daemon')
provides=('netctl-gui')
conflicts=('netctl-gui')
install="${pkgbase}.install"
cd "${srcdir}/build-qt4/gui"
make DESTDIR="${pkgdir}" install
}

View File

@ -4,14 +4,19 @@ Netctl GUI
Information 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 KDE. 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) **NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/netctl-gui/issues/3)
Configuration Configuration
------------- -------------
It is recommended to use graphical interface for widget and DataEngine configuration. All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface. It is recommended to use graphical interface for configuration. Configuration files are:
* `$HOME/.config/netctl-gui.conf` - GUI/helper user configuration
* `/etc/netctl-gui.conf` - helper system-wide configuration
* `$HOME/.config/plasma-dataengine-netctl.conf` - DataEngine user configuration
* `/etc/xdg/plasma-dataengine-netctl.conf` - DataEngine system-wide configuration
Instruction Instruction
=========== ===========
@ -25,7 +30,8 @@ Dependencies
Optional dependencies Optional dependencies
--------------------- ---------------------
* kdebase-workspace (widget) * kdebase-workspace (KDE4 widget)
* plasma-framework (KF5 widget)
* sudo (sudo support) * sudo (sudo support)
* wpa_supplicant (WiFi support) * wpa_supplicant (WiFi support)
@ -50,13 +56,20 @@ Installation
Available cmake flags: Available cmake flags:
* components:
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine * `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_GUI:BOOL=0` - do not build GUI * `-DBUILD_GUI:BOOL=0` - do not build GUI
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon * `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
* `-DBUILD_LIBRARY:BOOL=0` - do not build library * `-DBUILD_LIBRARY:BOOL=0` - do not build library
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid * `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* additional components:
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper * `-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 * `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
Additional information Additional information
@ -65,9 +78,6 @@ Additional information
TODO (wish list) TODO (wish list)
---------------- ----------------
* remove suid bit from helper (polkit/logind/etc)
* check/update documentation
Links Links
----- -----

98
arch/PKGBUILD Normal file
View 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.9
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=('64c04c36eea017e7c0ddf687d60de128')
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
}

101
arch/PKGBUILD-qt4 Normal file
View File

@ -0,0 +1,101 @@
# 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.9
pkgrel=1
pkgdesc="Qt4 GUI for netctl. Also provides a widget for KDE4"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui"
license=('GPL3')
makedepends=('automoc4' 'cmake' 'kdelibs')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${_pkgbase}-${pkgver}-src.tar.xz")
md5sums=('64c04c36eea017e7c0ddf687d60de128')
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')
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
}

View 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
View File

@ -0,0 +1,11 @@
post_install() {
true
}
post_upgrade() {
post_install "$1"
}
post_remove() {
post_install "$1"
}

View File

@ -4,9 +4,9 @@ post_install() {
} }
post_upgrade() { post_upgrade() {
post_install post_install "$1"
} }
post_remove() { post_remove() {
post_install post_install "$1"
} }

View 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"
}

View 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"
}

View File

@ -1,21 +1,30 @@
#!/bin/bash #!/bin/bash
ARCHIVE="netctl-gui"
SRCDIR="sources" SRCDIR="sources"
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" FILES="AUTHORS CHANGELOG COPYING README.md"
IGNORELIST="build en.qm ru.qm netctl-gui.qm *.cppcheck" IGNORELIST="build *.qm *.cppcheck .git* *.kdev4"
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\ # update submodules
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\ git submodule update --init --recursive
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
# create archive # create archive
[[ -e ${ARCHIVE}-${VERSION}-src.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}" [[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
cp -r "${SRCDIR}" "${ARCHIVE}" cp -r "${SRCDIR}" "${ARCHIVE}"
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf {} \;; done for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -delete; done
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}" tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
rm -rf "${ARCHIVE}" rm -rf "${ARCHIVE}"
# update md5sum # update md5sum
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}') MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD{,-qt4}
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD 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

View 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

View 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=Debug
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

1
sources/3rdparty/language vendored Submodule

@ -0,0 +1 @@
Subproject commit 319125b1fafff9da14c89a94de6ba2852c90c9c2

14
sources/3rdparty/language-config.h vendored Normal file
View File

@ -0,0 +1,14 @@
#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"
// name of config section in the file if any
#define LANGUAGE_SECTION "Common"
#endif /* LANGUAGE_CONFIG_H */

View File

@ -15,31 +15,27 @@
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ * * along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#include "listmap.h"
#ifndef PRETTY_DEBUG_H
#define PRETTY_DEBUG_H
inline const char *pDebug(const std::string prettyFunction) QMap<QString, QString> listToMap(const QStringList list)
{ {
return prettyFunction.c_str(); 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;
} }
inline std::string pFuncInfo(const std::string prettyFunction) QStringList mapToList(const QMap<QString, QString> map)
{ {
size_t colons = prettyFunction.find("::"); QStringList list;
// workaround for functions which are not belong to any class for (int i=0; i<map.keys().count(); i++)
if (colons == std::string::npos) list.append(QString("%1==%2").arg(map.keys()[i]).arg(map[map.keys()[i]]));
colons = prettyFunction.rfind("(");
size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
size_t end = prettyFunction.rfind("(") - begin;
return "[" + prettyFunction.substr(begin, end) + "]"; return list;
} }
#define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__))
#endif /* PRETTY_DEBUG_H */

View File

@ -15,29 +15,15 @@
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ * * along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#ifndef LANGUAGE_H #ifndef LISTMAP_H
#define LANGUAGE_H #define LISTMAP_H
#include <QMap>
#include <QStringList> #include <QStringList>
class Language : public QObject QMap<QString, QString> listToMap(const QStringList list);
{ QStringList mapToList(const QMap<QString,QString> map);
Q_OBJECT
public:
explicit Language();
static QString checkLanguage(const QString language,
const QString defaultLanguage = QString("en"));
static QString defineLanguage(const QString configPath,
const QString options = QString("OPTIONS"));
static QString defineLanguageFromFile(const QString configPath);
static QString defineLanguageFromLocale();
static QStringList getAvailableLanguages();
private:
static QMap<QString, QString> parseOptions(const QString options);
};
#endif /* LANGUAGE_H */ #endif /* LISTMAP_H */

1
sources/3rdparty/pdebug vendored Submodule

@ -0,0 +1 @@
Subproject commit 75e4a0df83478802bba53345486b42c56713fe09

1
sources/3rdparty/task vendored Submodule

@ -0,0 +1 @@
Subproject commit dd52af08c9d6a2c8652d2d5e21bc2a433efb497a

View File

@ -1,41 +0,0 @@
Asynchronous programming in Qt/C++ using tasks,continuations and resumable functions.
This project is inspired by this[1] video on channel9.
The project seeks to do async based programming in Qt/C++ using modern C++ with lambdas.
The project has two sets of APIs.
1. Task::run().then() API provides async based programming with continuation[4].
2. Task::await() API provides the first API presented in a different way[5].
Under certain use cases,they can be used interchangeably, and in others,only one or the other can be used.Some of the problems
the first API causes and solved by the second API are discussed in this[7] youtube video.
Example use case for the Task::run().then() API can be found here[0]. Additional example is [2] where an API is
declared and [3] where the declared API is used.
Example use case of the Task::await() API is here[6] where a function call "blocks" waiting for a result without "hanging" the entire GUI application.
A short tutorial on task/async/await as implemented in C# can be viewed from this[8] link.
[0] https://github.com/mhogomchungu/tasks/blob/master/example.cpp
[1] http://channel9.msdn.com/Blogs/Charles/Asynchronous-Programming-for-C-Developers-PPL-Tasks-and-Windows-8
[2] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/zulumounttask.h#L61
[3] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/mainwindow.cpp#L812
[4] Disscussion about this can be found on the following link among other places: http://isocpp.org/files/papers/N3558.pdf
[5] Disscussion about this can be found on the following link among other places: http://isocpp.org/files/papers/N3564.pdf
[6] https://github.com/mhogomchungu/zuluCrypt/blob/7123e3c3a7c8c5b3b3b6958464fd92a7f780d827/zuluMount-gui/keydialog.cpp#L511
[7] https://www.youtube.com/watch?v=Y475RshtAHA
[8] http://www.youtube.com/watch?v=DqjIQiZ_ql4

View File

@ -1,385 +0,0 @@
/*
* copyright: 2014
* name : mhogo mchungu
* email: mhogomchungu@gmail.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef __TASK_H_INCLUDED__
#define __TASK_H_INCLUDED__
#include <utility>
#include <future>
#include <functional>
#include <QThread>
#include <QEventLoop>
/*
*
* Examples on how to use the library are at the end of this file.
*
*/
namespace Task
{
class Thread : public QThread
{
Q_OBJECT
public:
Thread()
{
connect( this,SIGNAL( finished() ),this,SLOT( deleteLater() ) ) ;
}
protected:
virtual ~Thread()
{
}
private:
virtual void run( void )
{
}
};
template< typename T >
class future
{
public:
future() : m_function( []( T t ){ Q_UNUSED( t ) ; } )
{
}
void setActions( std::function< void( void ) > start,
std::function< void( void ) > cancel,
std::function< T ( void ) > get )
{
m_start = std::move( start ) ;
m_cancel = std::move( cancel ) ;
m_get = std::move( get ) ;
}
void then( std::function< void( T ) > function )
{
m_function = std::move( function ) ;
m_start() ;
}
T get()
{
return m_get() ;
}
T await()
{
QEventLoop p ;
T q ;
m_function = [ & ]( T r ){ q = std::move( r ) ; p.exit() ; } ;
m_start() ;
p.exec() ;
return q ;
}
void start()
{
m_start() ;
}
void cancel()
{
m_cancel() ;
}
void run( T r )
{
m_function( std::move( r ) ) ;
}
private:
std::function< void( T ) > m_function ;
std::function< void( void ) > m_start ;
std::function< void( void ) > m_cancel ;
std::function< T ( void ) > m_get ;
};
template< typename T >
class ThreadHelper : public Thread
{
public:
ThreadHelper( std::function< T ( void ) >&& function ) : m_function( std::move( function ) )
{
}
future<T>& Future( void )
{
m_future.setActions( [ this ](){ this->start() ; },
[ this ](){ this->deleteLater() ; },
[ this ](){ T r = m_function() ; this->deleteLater() ; return r ; } ) ;
return m_future ;
}
private:
~ThreadHelper()
{
m_future.run( std::move( m_cargo ) ) ;
}
void run( void )
{
m_cargo = m_function() ;
}
std::function< T ( void ) > m_function ;
future<T> m_future ;
T m_cargo ;
};
class future_1
{
public:
future_1() : m_function( [](){} )
{
}
void setActions( std::function< void( void ) > start,
std::function< void( void ) > cancel,
std::function< void( void ) > get )
{
m_start = std::move( start ) ;
m_cancel = std::move( cancel ) ;
m_get = std::move( get ) ;
}
void then( std::function< void( void ) > function )
{
m_function = std::move( function ) ;
m_start() ;
}
void get()
{
m_get() ;
}
void await()
{
QEventLoop p ;
m_function = [ & ](){ p.exit() ; } ;
m_start() ;
p.exec() ;
}
void start()
{
m_start() ;
}
void run()
{
m_function() ;
}
void cancel()
{
m_cancel() ;
}
private:
std::function< void( void ) > m_function ;
std::function< void( void ) > m_start ;
std::function< void( void ) > m_cancel ;
std::function< void( void ) > m_get ;
};
class ThreadHelper_1 : public Thread
{
public:
ThreadHelper_1( std::function< void ( void ) >&& function ) : m_function( std::move( function ) )
{
}
future_1& Future( void )
{
m_future.setActions( [ this ](){ this->start() ; },
[ this ](){ this->deleteLater() ; },
[ this ](){ m_function() ; this->deleteLater() ; } ) ;
return m_future ;
}
private:
~ThreadHelper_1()
{
m_future.run() ;
}
void run( void )
{
m_function() ;
}
std::function< void ( void ) > m_function ;
future_1 m_future ;
};
/*
* Below APIs runs two tasks,the first one will run in a different thread and
* the second one will be run on the original thread after the completion of the
* first one.
*/
template< typename T >
future<T>& run( std::function< T ( void ) > function )
{
auto t = new ThreadHelper<T>( std::move( function ) ) ;
return t->Future() ;
}
static inline future_1& run( std::function< void( void ) > function )
{
auto t = new ThreadHelper_1( std::move( function ) ) ;
return t->Future() ;
}
static inline void exec( std::function< void( void ) > function )
{
Task::run( std::move( function ) ).start() ;
}
/*
* Below APIs implements resumable functions where a function will be "blocked"
* waiting for the function to return without "hanging" the current thread.
*
* recommending reading up on C#'s await keyword to get a sense of what is being
* discussed below.
*/
static inline void await( Task::future_1& e )
{
e.await() ;
}
static inline void await( std::function< void( void ) > function )
{
Task::run( std::move( function ) ).await() ;
}
template< typename T >
T await( std::function< T ( void ) > function )
{
return Task::run<T>( std::move( function ) ).await() ;
}
template< typename T >
T await( Task::future<T>& e )
{
return e.await() ;
}
template< typename T >
T await( std::future<T>&& t )
{
return Task::await<T>( [ & ](){ return t.get() ; } ) ;
}
}
#if 0
/*
* Examples on how to use the library
*/
/*
* templated version that passes a return value of one function to another function
*/
auto _a = [](){
/*
* task _a does what task _a does here.
*
* This function body will run on a different thread
*/
return 0 ;
}
auto _b = []( int r ){
/*
*
* task _b does what task _b does here.
*
* r is a const reference to a value returned by _a
*
* This function body will run on the original thread
*/
}
Task::run<int>( _a ).then( _b ) ;
alternatively,
Task::future<int>& e = Task::run( _a ) ;
e.then( _b ) ;
/*
* Non templated version that does not pass around return value
*/
auto _c = [](){
/*
* task _a does what task _a does here.
*
* This function body will run on a different thread
*/
}
auto _d = [](){
/*
* task _b does what task _b does here.
*
* r is a const reference to a value returned by _a
*
* This function body will run on the original thread
*/
}
Task::run( _c ).then( _d ) ;
/*
* if no continuation
*/
Task::exec( _c ) ;
/*
* Task::await() is used to "block" without "hanging" the calling thread until the function returns.
*
* Its use case is to do sync programming without hanging the calling thread.
*
* example use case for it is to "block" on function in a GUI thread withough blocking the GUI thread
* hanging the application.
*/
/*
* await example when the called function return no result
*/
Task::await( _c ) ;
/*
* await example when the called function return a result
*/
int r = Task::await<int>( _a ) ;
alternatively,
Task::future<int>& e = Task::run<int>( _a ) ;
int r = e.await() ;
alternatively,
int r = Task::run<int>( _a ).await() ;
#endif
#endif //__TASK_H_INCLUDED__

1
sources/3rdparty/tasks vendored Submodule

@ -0,0 +1 @@
Subproject commit 36f7ac299633e96f246fec160939207257ae0097

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 2.8.12)
cmake_policy (SET CMP0003 OLD) cmake_policy (SET CMP0003 OLD)
cmake_policy (SET CMP0002 OLD) cmake_policy (SET CMP0002 OLD)
@ -10,8 +10,8 @@ set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com") set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3") set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 1) set (PROJECT_VERSION_MAJOR 1)
set (PROJECT_VERSION_MINOR 3) set (PROJECT_VERSION_MINOR 4)
set (PROJECT_VERSION_PATCH 0) set (PROJECT_VERSION_PATCH 9)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC) string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
string (TIMESTAMP CURRENT_YEAR "%Y") string (TIMESTAMP CURRENT_YEAR "%Y")
@ -21,13 +21,17 @@ message (STATUS "Version: ${PROJECT_VERSION}")
message (STATUS "Build date: ${CURRENT_DATE}") message (STATUS "Build date: ${CURRENT_DATE}")
# install options # install options
option (USE_CAPABILITIES "Use setcap to set capabilities for the helper" ON)
option (USE_QT5 "Use Qt5 instead of Qt4" ON) option (USE_QT5 "Use Qt5 instead of Qt4" ON)
# configuration
include (config-defs.cmake)
# components # components
option (BUILD_GUI "Build GUI" ON) option (BUILD_GUI "Build GUI" ON)
option (BUILD_HELPER "Build helper" ON) option (BUILD_HELPER "Build helper" ON)
option (BUILD_LIBRARY "Build library" ON) option (BUILD_LIBRARY "Build library" ON)
option (BUILD_DATAENGINE "Build DataEngine" ON) option (BUILD_DATAENGINE "Build DataEngine" ON)
option (BUILD_PLASMOID "Build plasmoid" ON) option (BUILD_PLASMOID "Build plasmoid" ON)
option (BUILD_KDE4 "Build on KDE4" OFF)
if (BUILD_GUI OR BUILD_HELPER) if (BUILD_GUI OR BUILD_HELPER)
set (BUILD_LIBRARY ON) set (BUILD_LIBRARY ON)
endif () endif ()
@ -49,10 +53,20 @@ set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus sys
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services") set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
# flags # flags
if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set (CMAKE_CXX_FLAGS "-Wall -std=c++11") set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0") set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
# 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 () else ()
message (STATUS "Unknown compiler") message (STATUS "Unknown compiler")
endif () endif ()
@ -60,6 +74,7 @@ endif ()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
# resources # resources
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set (PROJECT_LIBRARY netctlgui) set (PROJECT_LIBRARY netctlgui)
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources) set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
add_subdirectory (${PROJECT_RESOURCE_DIR}) add_subdirectory (${PROJECT_RESOURCE_DIR})
@ -82,5 +97,9 @@ if (BUILD_DATAENGINE)
add_subdirectory (dataengine) add_subdirectory (dataengine)
endif () endif ()
if (BUILD_PLASMOID) if (BUILD_PLASMOID)
add_subdirectory (plasmoid) if (BUILD_KDE4)
add_subdirectory (plasmoid-kde4)
else ()
add_subdirectory (plasmoid-kf5)
endif (BUILD_KDE4)
endif () endif ()

41
sources/config-defs.cmake Normal file
View File

@ -0,0 +1,41 @@
# default configuration options
# [Common] section
set (CFG_LANGUAGE "en" CACHE STRING "LANGUAGE key")
set (CFG_MAINUPDATE "0" CACHE STRING "MAINUPDATE key")
set (CFG_WIFIUPDATE "0" CACHE STRING "WIFIUPDATE key")
set (CFG_SYSTRAY "true" CACHE STRING "SYSTRAY key")
set (CFG_CLOSETOTRAY "true" CACHE STRING "CLOSETOTRAY key")
set (CFG_STARTTOTRAY "false" CACHE STRING "STARTTOTRAY key")
set (CFG_SKIPCOMPONENTS "false" CACHE STRING "SKIPCOMPONENTS key")
# [Helper] section
set (CFG_USE_HELPER "true" CACHE STRING "USE_HELPER key")
set (CFG_FORCE_SUDO "false" CACHE STRING "FORCE_SUDO key")
set (CFG_CLOSE_HELPER "false" CACHE STRING "CLOSE_HELPER key")
set (CFG_HELPER_PATH "netctlgui-helper" CACHE STRING "HELPER_PATH key")
set (CFG_HELPER_SERVICE "netctlgui-helper.service" CACHE STRING "HELPER_SERVICE key")
# [netctl] section
set (CFG_SYSTEMCTL_PATH "systemctl" CACHE STRING "SYSTEMCTL_PATH key")
set (CFG_NETCTL_PATH "netctl" CACHE STRING "NETCTL_PATH key")
set (CFG_NETCTLAUTO_PATH "netctl-auto" CACHE STRING "NETCTLAUTO_PATH key")
set (CFG_NETCTLAUTO_SERVICE "netctl-auto" CACHE STRING "NETCTLAUTO_SERVICE key")
set (CFG_PROFILE_DIR "/etc/netctl/" CACHE STRING "PROFILE_DIR key")
# [sudo] section
set (CFG_SUDO_PATH "kdesu" CACHE STRING "SUDO_PATH key")
# [wpa_supplicant] section
set (CFG_WPASUP_PATH "wpa_supplicant" CACHE STRING "WPASUP_PATH key")
set (CFG_WPACLI_PATH "wpa_cli" CACHE STRING "WPACLI_PATH key")
set (CFG_PID_FILE "/run/wpa_supplicant_$i.pid" CACHE STRING "PID_FILE key")
set (CFG_WPA_DRIVERS "nl80211,wext" CACHE STRING "WPA_DRIVERS key")
set (CFG_CTRL_DIR "/run/wpa_supplicant" CACHE STRING "CTRL_DIR key")
set (CFG_CTRL_GROUP "users" CACHE STRING "CTRL_GROUP key")
# [Other] section
set (CFG_EDITOR_PATH "gvim" CACHE STRING "EDITOR_PATH key")
set (CFG_IFACE_DIR "/sys/class/net/" CACHE STRING "IFACE_DIR key")
set (CFG_RFKILL_DIR "/sys/class/rfkill/" CACHE STRING "RFKILL_DIR key")
set (CFG_PREFERED_IFACE "" CACHE STRING "PREFERED_IFACE key")

View File

@ -3,28 +3,71 @@ set (SUBPROJECT plasma_engine_netctl)
message (STATUS "Subproject ${SUBPROJECT}") message (STATUS "Subproject ${SUBPROJECT}")
# find required libaries # find required libaries
find_package (KDE4 REQUIRED) if (BUILD_KDE4)
include (KDE4Defaults) find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../) 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}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE}
${KDE_INCLUDE})
set (PLUGIN_NAME ${SUBPROJECT}) set (PLUGIN_NAME ${SUBPROJECT})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop) file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN}) file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file (GLOB SUBPROJECT_SOURCE *.cpp) if (BUILD_KDE4)
set (TASK_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/task.h) file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
else ()
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
endif ()
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
file (GLOB SUBPROJECT_CONF *.conf) file (GLOB SUBPROJECT_CONF *.conf)
# prepare # prepare
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP}) configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
# make # make
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER}) if (BUILD_KDE4)
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE}) qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY}) 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 # install
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}) 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 ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR}) install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="1">
<libraries>
<library>qt</library>
</libraries>
</project>

View File

@ -1,17 +0,0 @@
# Configuration file for netctl data engine
## Commands
# command
NETCTLCMD=/usr/bin/netctl
# netctl-auto command
NETCTLAUTOCMD=/usr/bin/netctl-auto
## External IP
# external IPv4 check command
EXTIP4CMD=curl ip4.telize.com
# 'true' - check external IPv4
EXTIP4=false
# external IPv6 check command
EXTIP6CMD=curl ip6.telize.com
# 'true' - check external IPv6
EXTIP6=false

View File

@ -15,19 +15,29 @@
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ * * along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#include <KGlobal> #include "netctl.h"
#include <KStandardDirs>
#include <Plasma/DataContainer> #include <Plasma/DataContainer>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QProcessEnvironment> #include <QProcessEnvironment>
#include <QSettings>
#include <QTextCodec> #include <QTextCodec>
#include "netctl.h" #include <pdebug/pdebug.h>
#include "pdebug.h" #include <task/taskadds.h>
#include "taskadds.h" #include <version.h>
// KF5-KDE4 compability
#ifdef BUILD_KDE4
#include <KGlobal>
#include <KStandardDirs>
#else
#include <QStandardPaths>
#include <pdebug/pdebug-time.h>
#endif /* BUILD_KDE4 */
Netctl::Netctl(QObject *parent, const QVariantList &args) Netctl::Netctl(QObject *parent, const QVariantList &args)
@ -35,16 +45,17 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
{ {
Q_UNUSED(args) Q_UNUSED(args)
#if QT_VERSION >= 0x050000
qInstallMessageHandler(debugString);
#endif /* QT_VERSION >= 0x050000 */
// debug // debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("NETCTLGUI_DEBUG"), QString("no")); QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
if (debugEnv == QString("yes")) debug = (debugEnv == QString("yes"));
debug = true;
else
debug = false;
setMinimumPollingInterval(333); setMinimumPollingInterval(333);
readConfiguration(); readConfiguration();
initSources();
} }
@ -63,6 +74,7 @@ QStringList Netctl::sources() const
sources.append(QString("current")); sources.append(QString("current"));
sources.append(QString("extip4")); sources.append(QString("extip4"));
sources.append(QString("extip6")); sources.append(QString("extip6"));
sources.append(QString("info"));
sources.append(QString("interfaces")); sources.append(QString("interfaces"));
sources.append(QString("intip4")); sources.append(QString("intip4"));
sources.append(QString("intip6")); sources.append(QString("intip6"));
@ -74,71 +86,43 @@ QStringList Netctl::sources() const
} }
QString Netctl::getCmdOutput(const QString cmd) const
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
return QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
}
void Netctl::readConfiguration() void Netctl::readConfiguration()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// default configuration QString fileName;
QMap<QString, QString> rawConfig; #ifdef BUILD_KDE4
rawConfig[QString("EXTIP4")] = QString("false"); fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-netctl.conf");
rawConfig[QString("EXTIP4CMD")] = QString("curl ip4.telize.com"); #else
rawConfig[QString("EXTIP6")] = QString("false"); fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-netctl.conf"));
rawConfig[QString("EXTIP6CMD")] = QString("curl ip6.telize.com"); #endif /* BUILD_KDE4 */
rawConfig[QString("NETCTLCMD")] = QString("/usr/bin/netctl");
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName; if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
QFile configFile(fileName); QSettings settings(fileName, QSettings::IniFormat);
if (!configFile.open(QIODevice::ReadOnly)) {
configuration = updateConfiguration(rawConfig);
return;
}
QString fileStr;
QStringList value;
while (true) {
fileStr = QString(configFile.readLine()).trimmed();
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
if (fileStr.contains(QChar('='))) {
value.clear();
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
value.append(fileStr.split(QChar('='))[i]);
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
}
if (configFile.atEnd()) break;
}
configFile.close();
configuration = updateConfiguration(rawConfig);
return; settings.beginGroup(QString("Netctl commands"));
} configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("netctl"));
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("netctl-auto"));
settings.endGroup();
settings.beginGroup(QString("External IP"));
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig) configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false"));
{ configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com"));
if (debug) qDebug() << PDEBUG; configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false"));
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com"));
QMap<QString, QString> config; settings.endGroup();
QString key, value;
// remove spaces and copy source map
for (int i=0; i<rawConfig.keys().count(); i++) {
key = rawConfig.keys()[i];
value = rawConfig[key];
key.remove(QChar(' '));
if ((key != QString("EXTIP4CMD")) &&
(key != QString("EXTIP6CMD")) &&
(key != QString("NETCTLCMD")) &&
(key != QString("NETCTLAUTOCMD")))
value.remove(QChar(' '));
config[key] = value;
}
for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + config[config.keys()[i]];
return config;
} }
@ -151,63 +135,43 @@ bool Netctl::sourceRequestEvent(const QString &name)
} }
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto) QString Netctl::getExtIp(const QString cmd) const
{
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString cmd;
if (netctlAutoStatus)
cmd = cmdNetctlAuto;
else
cmd = cmdNetctl;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QStringList currentProfile;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i][0] == QChar('*'))
currentProfile.append(profileList[i]);
for (int i=0; i<currentProfile.count(); i++)
currentProfile[i].remove(0, 2);
return currentProfile;
}
QString Netctl::getExtIp(const QString cmd)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd; if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd); return getCmdOutput(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
return extIp;
} }
QStringList Netctl::getInterfaceList() QString Netctl::getInfo(const QStringList profiles, const QStringList statuses) const
{
if (debug) qDebug() << PDEBUG;
if (profiles.count() != statuses.count()) return QString("N\\A");
QStringList list;
for (int i=0; i<profiles.count(); i++)
list.append(QString("%1 (%2)").arg(profiles.at(i)).arg(statuses.at(i)));
if (list.isEmpty()) list.append(QString("N\\A"));
return list.join(QString(" | "));
}
QStringList Netctl::getInterfaceList() const
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces(); QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
QStringList interfacesList; QStringList interfacesList;
for (int i=0; i<rawList.count(); i++) foreach(QNetworkInterface interface, rawList)
interfacesList.append(rawList[i].name()); interfacesList.append(interface.name());
return interfacesList; return interfacesList;
} }
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
@ -217,101 +181,76 @@ QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
else if (protocol == QAbstractSocket::IPv6Protocol) else if (protocol == QAbstractSocket::IPv6Protocol)
intIp = QString("::1/128"); intIp = QString("::1/128");
QList<QHostAddress> rawList = QNetworkInterface::allAddresses(); QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
for (int i=0; i<rawList.count(); i++) { foreach(QHostAddress address, rawList) {
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue; if (address == QHostAddress(QHostAddress::LocalHost)) continue;
if (rawList[i].protocol() == protocol) { if (address == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
intIp = rawList[i].toString(); if (address.protocol() != protocol) continue;
intIp = address.toString();
break; break;
} }
}
return intIp; return intIp;
} }
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString status;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
if (cmdOutput.isEmpty()) {
netctlAutoStatus = false;
status = QString("false");
} else {
netctlAutoStatus = true;
status = QString("true");
}
return status;
}
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto) QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString cmd; QString output = getCmdOutput(QString("%1 list").arg(cmdNetctlAuto));
if (netctlAutoStatus) if (output.isEmpty()) {
cmd = cmdNetctlAuto; output = getCmdOutput(QString("%1 list").arg(cmdNetctl));
else netctlAutoStatus = false;
cmd = cmdNetctl; } else
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd; netctlAutoStatus = true;
TaskResult process = runTask(cmd + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; // parse
if (process.exitCode != 0) QStringList currentProfiles;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; // workaround for first element spaces on which are trimmed
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output); QStringList profileList = QString(" %1").arg(output).split(QChar('\n'));
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts); for (int i=0; i<profileList.count(); i++) {
for (int i=0; i<profileList.count(); i++) bool isActive = (profileList.at(i)[0] == QChar('*'));
profileList[i].remove(0, 2); profileList[i].remove(0, 2);
if (isActive) currentProfiles.append(profileList.at(i));
}
profileList.sort();
currentProfiles.sort();
// return profiles
currentProfile = currentProfiles;
status = !currentProfiles.isEmpty();
return profileList; return profileList;
} }
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto) QStringList Netctl::getProfileStringStatus(const QString cmdNetctl) const
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QStringList status; QStringList status;
if (netctlAutoStatus) if (netctlAutoStatus) {
status.append(QString("netctl-auto")); status.append(QString("netctl-auto"));
else { return status;
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
for (int i=0; i<profiles.count(); i++) {
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode == 0)
status.append(QString("enabled"));
else
status.append(QString("static"));
} }
foreach(QString profile, currentProfile) {
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(profile));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
status.append(process.exitCode == 0 ? QString("enabled") : QString("static"));
} }
return status; return status;
} }
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto) void Netctl::initSources()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString status = QString("false"); QStringList sourcesList = sources();
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto); foreach(QString source, sourcesList)
if (!currentProfile.isEmpty()) setData(source, QString("value"), QString("N\\A"));
status = QString("true");
return status;
} }
@ -322,18 +261,17 @@ bool Netctl::updateSourceEvent(const QString &source)
QString value = QString("N\\A"); QString value = QString("N\\A");
if (source == QString("active")) { if (source == QString("active")) {
value = getStatus(configuration[QString("NETCTLCMD")], value = status ? QString("true") : QString("false");
configuration[QString("NETCTLAUTOCMD")]);
} else if (source == QString("current")) { } else if (source == QString("current")) {
value = getCurrentProfile(configuration[QString("NETCTLCMD")], value = currentProfile.join(QChar('|'));
configuration[QString("NETCTLAUTOCMD")])
.join(QChar('|'));
} else if (source == QString("extip4")) { } else if (source == QString("extip4")) {
if (configuration[QString("EXTIP4")] == QString("true")) if (configuration[QString("EXTIP4")].toString() == QString("true"))
value = getExtIp(configuration[QString("EXTIP4CMD")]); value = getExtIp(configuration[QString("EXTIP4CMD")].toString());
} else if (source == QString("extip6")) { } else if (source == QString("extip6")) {
if (configuration[QString("EXTIP6")] == QString("true")) if (configuration[QString("EXTIP6")].toString() == QString("true"))
value = getExtIp(configuration[QString("EXTIP6CMD")]); value = getExtIp(configuration[QString("EXTIP6CMD")].toString());
} else if (source == QString("info")) {
value = getInfo(currentProfile, currentStatus);
} else if (source == QString("interfaces")) { } else if (source == QString("interfaces")) {
value = getInterfaceList().join(QChar(',')); value = getInterfaceList().join(QChar(','));
} else if (source == QString("intip4")) { } else if (source == QString("intip4")) {
@ -341,15 +279,13 @@ bool Netctl::updateSourceEvent(const QString &source)
} else if (source == QString("intip6")) { } else if (source == QString("intip6")) {
value = getIntIp(QAbstractSocket::IPv6Protocol); value = getIntIp(QAbstractSocket::IPv6Protocol);
} else if (source == QString("netctlauto")) { } else if (source == QString("netctlauto")) {
value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]); value = netctlAutoStatus ? QString("true") : QString("false");
} else if (source == QString("profiles")) { } else if (source == QString("profiles")) {
value = getProfileList(configuration[QString("NETCTLCMD")], value = getProfileList(configuration[QString("NETCTLCMD")].toString(),
configuration[QString("NETCTLAUTOCMD")]) configuration[QString("NETCTLAUTOCMD")].toString()).join(QChar(','));
.join(QChar(','));
} else if (source == QString("status")) { } else if (source == QString("status")) {
value = getProfileStringStatus(configuration[QString("NETCTLCMD")], currentStatus = getProfileStringStatus(configuration[QString("NETCTLCMD")].toString());
configuration[QString("NETCTLAUTOCMD")]) value = currentStatus.join(QChar('|'));
.join(QChar('|'));
} }
setData(source, QString("value"), value); setData(source, QString("value"), value);
@ -357,6 +293,10 @@ bool Netctl::updateSourceEvent(const QString &source)
} }
#ifdef BUILD_KDE4
K_EXPORT_PLASMA_DATAENGINE(netctl, Netctl) 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" #include "netctl.moc"

View File

@ -27,16 +27,17 @@ class Netctl : public Plasma::DataEngine
Q_OBJECT Q_OBJECT
public: public:
Netctl(QObject *parent, const QVariantList &args); explicit Netctl(QObject *parent, const QVariantList &args);
~Netctl(); virtual ~Netctl();
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto); QString getExtIp(const QString cmd) const;
QString getExtIp(const QString cmd); QString getInfo(const QStringList profiles, const QStringList statuses) const;
QStringList getInterfaceList(); QStringList getInterfaceList() const;
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol); QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const;
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto); QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto); QStringList getProfileStringStatus(const QString cmdNetctl) const;
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
public slots:
void initSources();
protected: protected:
bool sourceRequestEvent(const QString &name); bool sourceRequestEvent(const QString &name);
@ -44,13 +45,16 @@ protected:
QStringList sources() const; QStringList sources() const;
private: private:
bool netctlAutoStatus; bool isNetctlCheckRunning = false;
QString currentProfile; bool netctlAutoStatus = false;
bool status = false;
QStringList currentProfile;
QStringList currentStatus;
// configuration // configuration
bool debug; bool debug;
QMap<QString, QString> configuration; QVariantMap configuration;
QString getCmdOutput(const QString cmd) const;
void readConfiguration(); void readConfiguration();
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
}; };

View File

@ -1 +0,0 @@
../3rdparty/pdebug/pdebug.h

View File

@ -0,0 +1,9 @@
[Netctl commands]
NETCTLCMD=netctl
NETCTLAUTOCMD=netctl-auto
[External IP]
EXTIP4CMD=curl ip4.telize.com
EXTIP4=false
EXTIP6CMD=curl ip6.telize.com
EXTIP6=false

View File

@ -10,11 +10,11 @@ X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_netctl X-KDE-Library=plasma_engine_netctl
X-Plasma-EngineName=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-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=netctl X-KDE-PluginInfo-Name=netctl
X-KDE-PluginInfo-Version=@PROJECT_VERSION@ X-KDE-PluginInfo-Version=@PROJECT_VERSION@
X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid X-KDE-PluginInfo-Website=https://arcanis.me/projects/netctl-gui/
X-KDE-PluginInfo-Category=Network X-KDE-PluginInfo-Category=Network
X-KDE-PluginInfo-Depends= X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3 X-KDE-PluginInfo-License=GPLv3

View File

@ -1 +0,0 @@
../3rdparty/task/task.h

View File

@ -1 +0,0 @@
../3rdparty/task/taskadds.cpp

View File

@ -1 +0,0 @@
../3rdparty/task/taskadds.h

View File

@ -63,6 +63,7 @@ _netctl_gui_settings=(
'PREFERED_IFACE' 'PREFERED_IFACE'
'PROFILE_DIR' 'PROFILE_DIR'
'RFKILL_DIR' 'RFKILL_DIR'
'SKIPCOMPONENTS'
'STARTTOTRAY' 'STARTTOTRAY'
'SUDO_PATH' 'SUDO_PATH'
'SYSTEMCTL_PATH' 'SYSTEMCTL_PATH'

View File

@ -1,12 +1,12 @@
# build pages # build pages
file (GLOB SUBPROJECT_DOCS_IN *.html) file (GLOB SUBPROJECT_DOCS_IN *.html)
file (GLOB SUBPROJECT_IMGS *.png) file (GLOB SUBPROJECT_IMGS *.png)
foreach (DOC_IN ${SUBPROJECT_DOCS_IN}) foreach (DOC_IN ${SUBPROJECT_DOCS_IN})
file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN}) file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN})
configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC}) configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC}) set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
endforeach () endforeach ()
install (FILES ${SUBPROJECT_DOCS} DESTINATION share/doc/${PROJECT_NAME}) install (FILES ${SUBPROJECT_DOCS} DESTINATION share/doc/${PROJECT_NAME})
install (FILES ${SUBPROJECT_IMGS} DESTINATION share/doc/${PROJECT_NAME}) install (FILES ${SUBPROJECT_IMGS} DESTINATION share/doc/${PROJECT_NAME})

View File

@ -1,3 +1,4 @@
<!doctype html>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
@ -20,27 +21,28 @@ th {
th.sub { th.sub {
font-style: italic; font-style: italic;
font-weight: normal; font-weight: normal;
}
small {
font-size: 70%;
} }
</style> </style>
<h1>netctl-gui DBus API description</h1>
<h3>Project version : @PROJECT_VERSION@</h3>
<ol>
<li><a href="#api">DBus API</a></li>
<li><a href="#helper">Helper API</a></li>
<ul>
<li><a href="#ctrl">Helper ctrl API</a></li>
<li><a href="#netctl">Helper netctl API</a></li>
</ul>
<li><a href="#gui">GUI API</a></li>
<ul>
<li><a href="#netctlgui">GUI netctlgui API</a></li>
</ul>
<li><a href="#links">External links</a></li>
</ol>
</head> </head>
<body> <body>
<h2><a href="#api" class="anchor" name="api"></a>DBus API</h2> <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> <table>
<tbody><tr> <tbody><tr>
<th>method</th> <th>method</th>
@ -49,11 +51,11 @@ th.sub {
</tr> </tr>
<!-- helper service --> <!-- helper service -->
<tr> <tr>
<th colspan="3"><a href="#helper" class="anchor" name="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th> <th colspan="3"><a href="#helper" class="anchor" id="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th>
</tr> </tr>
<!-- /ctrl path --> <!-- /ctrl path -->
<tr> <tr>
<th colspan="3" class="sub"><a href="#ctrl" class="anchor" name="ctrl"></a><code>/ctrl</code> path</th> <th colspan="3" class="sub"><a href="#ctrl" class="anchor" id="ctrl"></a><code>/ctrl</code> path</th>
</tr> </tr>
<!-- helper actions --> <!-- helper actions -->
<tr> <tr>
@ -73,7 +75,7 @@ th.sub {
</tr> </tr>
<tr> <tr>
<td>QStringList FindSettings()</td> <td>QStringList FindSettings()</td>
<td>scans system and suggests the recommended configuration which will be used by the library</td> <td>scans system and suggests the recommended configuration which may be used by the library</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr> <tr>
@ -112,6 +114,16 @@ th.sub {
<td>enables or disables the profile. Returns <code>true</code> if action has been performed successfully</td> <td>enables or disables the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td> <td>yes</td>
</tr> </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> <tr>
<td>bool Reenable(QString profile)</td> <td>bool Reenable(QString profile)</td>
<td>reenables the profile. Returns <code>true</code> if action has been performed successfully</td> <td>reenables the profile. Returns <code>true</code> if action has been performed successfully</td>
@ -185,23 +197,105 @@ th.sub {
<td>yes</td> <td>yes</td>
</tr> </tr>
<!-- wpa_supplicant actions --> <!-- 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> <tr>
<td>QStringList WiFi()</td> <td>QStringList WiFi()</td>
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td> <td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
<td>yes</td> <td>yes</td>
</tr> </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 --> <!-- /netctl path -->
<tr> <tr>
<th colspan="3" class="sub"><a href="#netctl" class="anchor" name="netctl"></a><code>/netctl</code> path</th> <th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th>
</tr> </tr>
<!-- general information --> <!-- general information -->
<tr> <tr>
<td>QString ActiveProfile()</td> <td>QStringList ActiveProfile()</td>
<td>returns active profile from netctl or netctl-auto</td> <td>returns active profile from netctl or netctl-auto</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr> <tr>
<td>QString ActiveProfileStatus()</td> <td>QStringList ActiveProfileStatus()</td>
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td> <td>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> <td>no</td>
</tr> </tr>
@ -210,11 +304,31 @@ th.sub {
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td> <td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>QStringList 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> <tr>
<td>QStringList ProfileList()</td> <td>QStringList ProfileList()</td>
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code></td> <td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code></td>
<td>no</td> <td>no</td>
</tr> </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> <tr>
<td>QStringList WirelessInterface()</td> <td>QStringList WirelessInterface()</td>
<td>returns wireless interfaces</td> <td>returns wireless interfaces</td>
@ -268,13 +382,17 @@ th.sub {
<td>returns value of the key by the given profile or empty line</td> <td>returns value of the key by the given profile or empty line</td>
<td>no</td> <td>no</td>
</tr> </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 --> <!-- gui service -->
<tr> <tr>
<th colspan="3"><a href="#gui" class="anchor" name="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th> <th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
</tr> </tr>
<!-- /netctlgui path -->
<tr> <tr>
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" name="netctlgui"></a><code>/netctlgui</code> path</th> <th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
</tr> </tr>
<!-- gui actions --> <!-- gui actions -->
<tr> <tr>
@ -292,11 +410,6 @@ th.sub {
<td><code>true</code> and closes the application</td> <td><code>true</code> and closes the application</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>QString Information()</td>
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
<td>no</td>
</tr>
<tr> <tr>
<td>void LibraryDocs()</td> <td>void LibraryDocs()</td>
<td>opens the library documentation</td> <td>opens the library documentation</td>
@ -347,24 +460,19 @@ th.sub {
<td>returns the application process UIDs <code>[UID, EUID]</code></td> <td>returns the application process UIDs <code>[UID, EUID]</code></td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>QStringList VerboseInformation()</td>
<td>returns information in format <code>[isNetctlAutoActive, ProfileList, ActiveProfile, isProfileEnabled/autoIsProfileEnabled]</code></td>
<td>no</td>
</tr>
</table> </table>
<h2><a href="#links" class="anchor" name="links"></a>External links</h2> <h2><a href="#links" class="anchor" id="links"></a>External links</h2>
<ul> <ul>
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li> <li><a href="https://arcanis.me/projects/netctl-gui/">Homepage</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li> <li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li> <li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
</ul> </ul>
<p align="center" style="font-size: 70%"> <small>
&copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br> &copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
This software is licensed under @PROJECT_LICENSE@ This software is licensed under @PROJECT_LICENSE@
</p> </small>
</body> </body>
</html> </html>

View File

@ -1,62 +1,79 @@
<!doctype html>
<html> <html>
<head> <head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>netctl-gui secutiry notes</title> <title>netctl-gui secutiry notes</title>
<style type="text/css"> <style type="text/css">
img {
display: block;
margin: 0 auto;
}
small {
font-size: 70%;
}
</style> </style>
<h1>netctl-gui security notes</h1> </head>
<h3>Project version : @PROJECT_VERSION@</h3> <body>
<ol>
<li><a href="#description">Description</a></li> <h1>netctl-gui security notes</h1>
<h3>Project version : @PROJECT_VERSION@</h3>
<ol>
<li><a href="#arch">Architecture</a></li> <li><a href="#arch">Architecture</a></li>
<li><a href="#library">Library</a></li> <li><a href="#library">Library</a></li>
<li><a href="#helper">Helper</a></li> <li><a href="#helper">Helper</a></li>
<li><a href="#gui">Graphical interface</a></li> <li><a href="#gui">Graphical interface</a></li>
<li><a href="#kde">KDE components</a></li> <li><a href="#kde">KDE components</a></li>
<li><a href="#links">External links</a></li> <li><a href="#links">External links</a></li>
</ol> </ol>
</head>
<body>
<h2><a href="#description" class="anchor" name="description"></a>Description</h2> <h2><a href="#description" class="anchor" id="description"></a>Description</h2>
<p></p> <p></p>
<h2><a href="#arch" class="anchor" name="arch"></a>Architecture</h2> <h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
<img src="architecture.png" alt="architecture" align="middle"> <img src="architecture.png" alt="architecture">
<h2><a href="#library" class="anchor" name="library"></a>Library</h2> <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> <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> <ul>
<li>Netctl control module</li> <li>Netctl control module</li>
<ul> <li><ul>
<li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable &lt;profile&gt;</code>. They are commands which provide a general control to netctl.</li> <li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable &lt;profile&gt;</code>. They are commands which provide a general control to netctl.</li>
<li><code>systemctl start|restart|enable &lt;netctl-auto@service&gt;</code>. They are commands which provide ability to control netctl-auto systemd service.</li> <li><code>systemctl start|restart|enable &lt;netctl-auto@service&gt;</code>. They are commands which provide ability to control netctl-auto systemd service.</li>
</ul> </ul></li>
<li>Netctl profiles module</li> <li>Netctl profiles module</li>
<ul> <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>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> <li>Removal of a profile. <code>rm</code> command is used for it.</li>
</ul> </ul></li>
<li>WiFi module</li> <li>WiFi module</li>
<ul> <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> <li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
</ul> </ul></li>
</ul> </ul>
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p> <p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
<h2><a href="#helper" class="anchor" name="helper"></a>Helper</h2> <p>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 '&lt;profile&gt;'; set"
# get profile variables
env -i bash -c "source '&lt;profile&gt;'; for i in &#36;{!&lt;key&gt;[@]}; do echo &#36;{&lt;key&gt;[$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>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>network</code> group by default (or must be root). But you may change it by editing <code>$DBUS_SYSTEMCONF_PATH/org.netctlgui.helper.conf</code> policy file (<code>/etc/dbus-1/system.d/org.netctlgui.helper.conf</code> by default). Please refer to DBus documentation to do it.</p>
<p>There are two binaries <code>netctgui-helper</code> and <code>netctlgui-helper-suid</code>. They are the same, but the second one has SUID bit, so it can be running by normal user without any password. Please note that <b>it is dangerous</b> and recommended way is to use systemd daemon. In this case you may not install <code>netctlgui-helper-suid</code> binary.</p> <p>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> <p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
<h2><a href="#gui" class="anchor" name="gui"></a>Graphical interface</h2> <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> <p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
<h2><a href="#kde" class="anchor" name="kde"></a>KDE components</h2> <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> <p>There are two netctl-based commands which are run from the DataEngine</p>
<ul> <ul>
<li><code>&lt;cmd&gt; list</code></li> <li><code>&lt;cmd&gt; list</code></li>
@ -79,17 +96,17 @@
<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> <p>The other way is to use DBus communication with <a href="#helper">the helper</a>. In this case user should have rights to start the helper.</p>
<h2><a href="#links" class="anchor" name="links"></a>External links</h2> <h2><a href="#links" class="anchor" id="links"></a>External links</h2>
<ul> <ul>
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li> <li><a href="https://arcanis.me/projects/netctl-gui/">Homepage</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li> <li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li> <li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
</ul> </ul>
<p align="center" style="font-size: 70%"> <small>
&copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br> &copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
This software is licensed under @PROJECT_LICENSE@ This software is licensed under @PROJECT_LICENSE@
</p> </small>
</body> </body>
</html> </html>

View File

@ -64,7 +64,7 @@ Configuration file
.RE .RE
.SH SEE ALSO .SH SEE ALSO
.BR netctlgui-helper (1) .BR netctlgui-helper (1)
.BR netctlgui-helper.conf (5) .BR netctl-gui.conf (5)
.SH STANDARDS .SH STANDARDS
See See
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html .B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html

View File

@ -1,7 +1,17 @@
# set files # set files
file (GLOB SOURCES *.cpp) if (USE_QT5)
file (GLOB HEADERS *.h) file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
file (GLOB FORMS *.ui) ${PROJECT_TRDPARTY_DIR}/language/*.cpp
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
else ()
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
${PROJECT_TRDPARTY_DIR}/language/*.cpp
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
endif ()
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
${PROJECT_TRDPARTY_DIR}/language/*.h)
file (GLOB_RECURSE FORMS *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts) file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc) set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
@ -11,12 +21,13 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/includ
${CMAKE_CURRENT_BINARY_DIR}/../ ${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}) ${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_TRDPARTY_DIR})
link_directories (${PROJECT_LIBRARY}/src/lib) link_directories (${PROJECT_LIBRARY}/src/lib)
if (USE_QT5) if (USE_QT5)
find_package(Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED) find_package (Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS}) add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS}) include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES}) set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS}) qt5_wrap_cpp (MOC_SOURCES ${HEADERS})

View File

@ -22,7 +22,8 @@
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QPushButton> #include <QPushButton>
#include "pdebug.h" #include <pdebug/pdebug.h>
#include "version.h" #include "version.h"

View File

@ -0,0 +1,69 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "bondwidget.h"
#include "ui_bondwidget.h"
BondWidget::BondWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::BondWidget)
{
ui->setupUi(this);
clear();
}
BondWidget::~BondWidget()
{
delete ui;
}
void BondWidget::clear()
{
ui->lineEdit_mode->setText(QString("balance-rr"));
}
QMap<QString, QString> BondWidget::getSettings()
{
QMap<QString, QString> settings;
if (isOk() != 0) return settings;
if (ui->lineEdit_mode->text() != QString("balance-rr"))
settings[QString("Mode")] = ui->lineEdit_mode->text();
return settings;
}
int BondWidget::isOk()
{
// all fine
return 0;
}
void BondWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
if (settings.contains(QString("Mode")))
ui->lineEdit_mode->setText(settings[QString("Mode")]);
}

View File

@ -15,30 +15,33 @@
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ * * along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/ ***************************************************************************/
#ifndef BONDWIDGET_H
#define BONDWIDGET_H
#include "taskadds.h" #include <QWidget>
TaskResult runTask(const QString cmd, const bool useSuid) namespace Ui {
{ class BondWidget;
return Task::await<TaskResult>( [ & ]() {
TaskResult r;
if (useSuid) {
RootProcess command;
command.start(cmd);
command.waitForFinished(-1);
r.exitCode = command.exitCode();
r.output = command.readAllStandardOutput();
r.error = command.readAllStandardError();
} else {
QProcess command;
command.start(cmd);
command.waitForFinished(-1);
r.exitCode = command.exitCode();
r.output = command.readAllStandardOutput();
r.error = command.readAllStandardError();
}
return r;
});
} }
class BondWidget : public QWidget
{
Q_OBJECT
public:
explicit BondWidget(QWidget *parent = 0);
~BondWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
private:
Ui::BondWidget *ui;
};
#endif /* BONDWIDGET_H */

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BondWidget</class>
<widget class="QWidget" name="BondWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>550</width>
<height>46</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QDockWidget" name="dockWidget_bond">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Bond settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_bond">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Mode</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mode">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>The bonding policy. See the kernel documentation on bonding for details</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -40,26 +40,16 @@ void BridgeWidget::clear()
} }
void BridgeWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
QMap<QString, QString> BridgeWidget::getSettings() QMap<QString, QString> BridgeWidget::getSettings()
{ {
QMap<QString, QString> bridgeSettings; QMap<QString, QString> settings;
if (isOk() != 0) if (isOk() != 0) return settings;
return bridgeSettings;
if (ui->checkBox_skip->checkState() == Qt::Checked) if (ui->checkBox_skip->checkState() == Qt::Checked)
bridgeSettings[QString("SkipForwardingDelay")] = QString("yes"); settings[QString("SkipForwardingDelay")] = QString("yes");
return bridgeSettings; return settings;
} }
@ -73,9 +63,8 @@ int BridgeWidget::isOk()
void BridgeWidget::setSettings(const QMap<QString, QString> settings) void BridgeWidget::setSettings(const QMap<QString, QString> settings)
{ {
clear(); clear();
QMap<QString, QString> bridgeSettings = settings;
if (bridgeSettings.contains(QString("SkipForwardingDelay"))) if (settings.contains(QString("SkipForwardingDelay")))
if (bridgeSettings[QString("SkipForwardingDelay")] == QString("yes")) if (settings[QString("SkipForwardingDelay")] == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked); ui->checkBox_skip->setCheckState(Qt::Checked);
} }

View File

@ -38,7 +38,6 @@ public:
public slots: public slots:
void clear(); void clear();
void setShown(const bool state);
private: private:
Ui::BridgeWidget *ui; Ui::BridgeWidget *ui;

View File

@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>424</width> <width>550</width>
<height>76</height> <height>44</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_bridge"> <widget class="QDockWidget" name="dockWidget_bridge">
<property name="features"> <property name="features">
@ -24,8 +24,29 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_bridge"> <widget class="QWidget" name="dockWidgetContents_bridge">
<layout class="QVBoxLayout" name="verticalLayout_2"> <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> <item>
<widget class="QCheckBox" name="checkBox_skip"> <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"> <property name="toolTip">
<string>Skip (R)STP and immediately activate all bridge members</string> <string>Skip (R)STP and immediately activate all bridge members</string>
</property> </property>
@ -35,6 +56,8 @@
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</widget> </widget>
</item> </item>

243
sources/gui/src/calls.cpp Normal file
View 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
View 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 */

View 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;
}

View 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 */

View File

@ -21,24 +21,28 @@
#include <QDBusMessage> #include <QDBusMessage>
#include <QDebug> #include <QDebug>
#include "pdebug.h" #include <pdebug/pdebug.h>
#include "version.h"
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw, QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw)
const bool debug)
{ {
if (debug) qDebug() << PDEBUG;
QList<netctlProfileInfo> profileInfo; QList<netctlProfileInfo> profileInfo;
if (raw.size() == 0) if (raw.isEmpty()) return profileInfo;
return profileInfo; QStringList list = raw[0].toStringList();
for (int i=0; i<raw[0].toStringList().count(); i++) { for (int i=0; i<list.count(); i++) {
QStringList info = list[i].split(QChar('|'));
if (info.count() != 8) continue;
netctlProfileInfo profile; netctlProfileInfo profile;
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
profile.name = info[0]; profile.name = info[0];
profile.description = info[1]; profile.description = info[1];
profile.active = info[2].toInt(); profile.type = info[2];
profile.enabled = info[3].toInt(); 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); profileInfo.append(profile);
} }
@ -46,22 +50,24 @@ QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
} }
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw, QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw)
const bool debug)
{ {
if (debug) qDebug() << PDEBUG;
QList<netctlWifiInfo> wifiInfo; QList<netctlWifiInfo> wifiInfo;
if (raw.size() == 0) if (raw.isEmpty()) return wifiInfo;
return wifiInfo; QStringList list = raw[0].toStringList();
for (int i=0; i<raw[0].toStringList().count(); i++) { for (int i=0; i<list.count(); i++) {
QStringList info = list[i].split(QChar('|'));
if (info.count() != 8) continue;
netctlWifiInfo wifi; netctlWifiInfo wifi;
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
wifi.name = info[0]; wifi.name = info[0];
wifi.security = info[1]; wifi.security = info[1];
wifi.signal = info[2]; wifi.type = static_cast<PointType>(info[2].toInt());
wifi.active = info[3].toInt(); for (int j=0; j<info[3].split(QChar(',')).count(); j++)
wifi.exists = info[4].toInt(); 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); wifiInfo.append(wifi);
} }
@ -69,37 +75,81 @@ QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
} }
QList<QVariant> sendDBusRequest(const QString service, const QString path, QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
const QString interface, const QString cmd, const QList<QVariant> args, const bool debug)
const QList<QVariant> args, const bool system,
const bool debug)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Service" << service;
if (debug) qDebug() << PDEBUG << ":" << "Path" << path;
if (debug) qDebug() << PDEBUG << ":" << "Interface" << interface;
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd; if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
if (debug) qDebug() << PDEBUG << ":" << "args" << args; if (debug) qDebug() << PDEBUG << ":" << "args" << args;
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
QList<QVariant> arguments;
QDBusMessage response;
if (system) {
QDBusConnection bus = QDBusConnection::systemBus(); QDBusConnection bus = QDBusConnection::systemBus();
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd); QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
if (!args.isEmpty()) DBUS_HELPER_INTERFACE, cmd);
request.setArguments(args); if (!args.isEmpty()) request.setArguments(args);
response = bus.call(request, QDBus::BlockWithGui); QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
} else { QList<QVariant> arguments = response.arguments();
QDBusConnection bus = QDBusConnection::sessionBus(); if (arguments.isEmpty())
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
if (!args.isEmpty())
request.setArguments(args);
response = bus.call(request, QDBus::BlockWithGui);
}
arguments = response.arguments();
if (arguments.size() == 0)
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage(); if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
return arguments; 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);
}

View File

@ -23,14 +23,19 @@
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw, 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); const bool debug = false);
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw, 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); const bool debug = false);
QList<QVariant> sendDBusRequest(const QString service, const QString path,
const QString interface, const QString cmd,
const QList<QVariant> args = QList<QVariant>(),
const bool system = true, const bool debug = false);
#endif /* DBUSOPERATION_H */ #endif /* DBUSOPERATION_H */

View File

@ -22,7 +22,7 @@
#include <QSpacerItem> #include <QSpacerItem>
#include <QDebug> #include <QDebug>
#include "pdebug.h" #include <pdebug/pdebug.h>
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd) ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
@ -37,11 +37,10 @@ ErrorWindow::~ErrorWindow()
} }
QStringList ErrorWindow::getMessage(const int mess, const QString custom) QStringList ErrorWindow::getMessage(const int mess)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess; if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QString message, title; QString message, title;
switch(mess) { switch(mess) {
@ -99,7 +98,7 @@ QStringList ErrorWindow::getMessage(const int mess, const QString custom)
break; break;
case 14: case 14:
title = QApplication::translate("ErrorWindow", "Error!"); title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set"); message = QApplication::translate("ErrorWindow", "User is not in network group, helper will not be started");
break; break;
case 15: case 15:
title = QApplication::translate("ErrorWindow", "Error!"); title = QApplication::translate("ErrorWindow", "Error!");
@ -121,13 +120,19 @@ QStringList ErrorWindow::getMessage(const int mess, const QString custom)
title = QApplication::translate("ErrorWindow", "Error!"); title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not run helper"); message = QApplication::translate("ErrorWindow", "Could not run helper");
break; break;
case 20:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "IP address does not match the standard");
break;
case 21:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Key is required for 'gre' mode");
break;
default: default:
title = QApplication::translate("ErrorWindow", "Error!"); title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Unknown error"); message = QApplication::translate("ErrorWindow", "Unknown error");
break; break;
} }
if (!custom.isEmpty())
message = custom;
QStringList fullMessage; QStringList fullMessage;
fullMessage.append(title); fullMessage.append(title);
@ -162,6 +167,8 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
case 17: case 17:
case 18: case 18:
case 19: case 19:
case 20:
case 21:
icon = QMessageBox::Critical; icon = QMessageBox::Critical;
break; break;
default: default:
@ -173,21 +180,22 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
} }
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom) void ErrorWindow::showWindow(const int mess, const QString sender, const bool debugCmd)
{ {
if (debug) qDebug() << PDEBUG; if (debugCmd) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess; if (debugCmd) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender; if (debugCmd) qDebug() << PDEBUG << ":" << "Sender" << sender;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QStringList message = getMessage(mess, custom); ErrorWindow *errorWin = new ErrorWindow(0, debugCmd);
QStringList message = errorWin->getMessage(mess);
QMessageBox messageBox; QMessageBox messageBox;
messageBox.setText(message[0]); messageBox.setText(message[0]);
messageBox.setInformativeText(message[1]); messageBox.setInformativeText(message[1]);
if (debug) if (mess == 1)
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1"). messageBox.setDetailedText(sender);
arg(sender)); else if (debugCmd)
messageBox.setIcon(getIcon(mess)); messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").arg(sender));
messageBox.setIcon(errorWin->getIcon(mess));
messageBox.setStandardButtons(QMessageBox::Ok); messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setDefaultButton(QMessageBox::Ok); messageBox.setDefaultButton(QMessageBox::Ok);
@ -196,5 +204,5 @@ void ErrorWindow::showWindow(const int mess, const QString sender, const QString
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount()); layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
messageBox.exec(); messageBox.exec();
return; delete errorWin;
} }

View File

@ -32,13 +32,13 @@ public:
~ErrorWindow(); ~ErrorWindow();
public slots: public slots:
void showWindow(const int mess = 0, static void showWindow(const int mess = 0,
const QString sender = QString(), const QString sender = QString(),
const QString custom = QString()); const bool debugCmd = false);
private: private:
bool debug; bool debug;
QStringList getMessage(const int mess, const QString custom = QString()); QStringList getMessage(const int mess);
QMessageBox::Icon getIcon(const int mess); QMessageBox::Icon getIcon(const int mess);
}; };

View File

@ -46,6 +46,7 @@ void EthernetWidget::clear()
showWpa(ui->checkBox_8021x->checkState()); showWpa(ui->checkBox_8021x->checkState());
ui->lineEdit_wpaConfig->clear(); ui->lineEdit_wpaConfig->clear();
ui->comboBox_driver->setCurrentIndex(0); ui->comboBox_driver->setCurrentIndex(0);
ui->spinBox_priority->setValue(1);
ui->spinBox_timeoutCarrier->setValue(5); ui->spinBox_timeoutCarrier->setValue(5);
ui->spinBox_timeoutWpa->setValue(15); ui->spinBox_timeoutWpa->setValue(15);
@ -54,15 +55,6 @@ void EthernetWidget::clear()
} }
void EthernetWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void EthernetWidget::createActions() void EthernetWidget::createActions()
{ {
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced())); connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
@ -73,8 +65,7 @@ void EthernetWidget::createActions()
void EthernetWidget::selectWpaConfig() void EthernetWidget::selectWpaConfig()
{ {
QString filename = QFileDialog::getOpenFileName( QString filename = QFileDialog::getOpenFileName(this,
this,
QApplication::translate("EthernetWidget", "Select wpa configuration file"), QApplication::translate("EthernetWidget", "Select wpa configuration file"),
QDir::currentPath(), QDir::currentPath(),
QApplication::translate("EthernetWidget", "Configuration files (*.conf)")); QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
@ -87,43 +78,41 @@ void EthernetWidget::showAdvanced()
{ {
if (ui->pushButton_ethernetAdvanced->isChecked()) { if (ui->pushButton_ethernetAdvanced->isChecked()) {
ui->widget_ethernetAdvanced->setHidden(false); ui->widget_ethernetAdvanced->setHidden(false);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced")); ui->pushButton_ethernetAdvanced->setArrowType(Qt::UpArrow);
} else { } else {
ui->widget_ethernetAdvanced->setHidden(true); ui->widget_ethernetAdvanced->setHidden(true);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced")); ui->pushButton_ethernetAdvanced->setArrowType(Qt::DownArrow);
} }
} }
void EthernetWidget::showWpa(const int state) void EthernetWidget::showWpa(const int state)
{ {
if (state == 0) ui->widget_wpa->setHidden(state == 0);
ui->widget_wpa->setHidden(true);
else
ui->widget_wpa->setHidden(false);
} }
QMap<QString, QString> EthernetWidget::getSettings() QMap<QString, QString> EthernetWidget::getSettings()
{ {
QMap<QString, QString> ethernetSettings; QMap<QString, QString> settings;
if (isOk() != 0) if (isOk() != 0) return settings;
return ethernetSettings;
if (ui->checkBox_skip->checkState() == Qt::Checked) if (ui->checkBox_skip->checkState() == Qt::Checked)
ethernetSettings[QString("SkipNoCarrier")] = QString("yes"); settings[QString("SkipNoCarrier")] = QString("yes");
if (ui->checkBox_8021x->checkState() == Qt::Checked) { if (ui->checkBox_8021x->checkState() == Qt::Checked) {
ethernetSettings[QString("Auth8021X")] = QString("yes"); settings[QString("Auth8021X")] = QString("yes");
ethernetSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'"); settings[QString("WPAConfigFile")] = QString("'%1'").arg(ui->lineEdit_wpaConfig->text());
ethernetSettings[QString("WPADriver")] = ui->comboBox_driver->currentText(); settings[QString("WPADriver")] = ui->comboBox_driver->currentText();
} }
if (ui->spinBox_priority->value() != 1)
settings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
if (ui->spinBox_timeoutCarrier->value() != 5) if (ui->spinBox_timeoutCarrier->value() != 5)
ethernetSettings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value()); settings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
if (ui->spinBox_timeoutWpa->value() != 15) if (ui->spinBox_timeoutWpa->value() != 15)
ethernetSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value()); settings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
return ethernetSettings; return settings;
} }
@ -131,8 +120,7 @@ int EthernetWidget::isOk()
{ {
// file wpa_supplicant doesn't exists // file wpa_supplicant doesn't exists
if (!ui->lineEdit_wpaConfig->text().isEmpty()) if (!ui->lineEdit_wpaConfig->text().isEmpty())
if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) return 1;
return 1;
// all fine // all fine
return 0; return 0;
} }
@ -141,24 +129,25 @@ int EthernetWidget::isOk()
void EthernetWidget::setSettings(const QMap<QString, QString> settings) void EthernetWidget::setSettings(const QMap<QString, QString> settings)
{ {
clear(); clear();
QMap<QString, QString> ethernetSettings = settings;
if (ethernetSettings.contains(QString("SkipNoCarrier"))) if (settings.contains(QString("SkipNoCarrier")))
if (ethernetSettings[QString("SkipNoCarrier")] == QString("yes")) if (settings[QString("SkipNoCarrier")] == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked); ui->checkBox_skip->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("Auth8021X"))) if (settings.contains(QString("Auth8021X")))
if (ethernetSettings[QString("Auth8021X")] == QString("yes")) if (settings[QString("Auth8021X")] == QString("yes"))
ui->checkBox_8021x->setCheckState(Qt::Checked); ui->checkBox_8021x->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("WPAConfigFile"))) if (settings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")]); ui->lineEdit_wpaConfig->setText(settings[QString("WPAConfigFile")]);
if (ethernetSettings.contains(QString("WPADriver"))) if (settings.contains(QString("WPADriver"))) {
for (int i=0; i<ui->comboBox_driver->count(); i++) int index = ui->comboBox_driver->findText(settings[QString("WPADriver")]);
if (ethernetSettings[QString("WPADriver")] == ui->comboBox_driver->itemText(i)) ui->comboBox_driver->setCurrentIndex(index);
ui->comboBox_driver->setCurrentIndex(i); }
if (ethernetSettings.contains(QString("TimeoutCarrier"))) if (settings.contains(QString("Priority")))
ui->spinBox_timeoutCarrier->setValue(ethernetSettings[QString("TimeoutCarrier")].toInt()); ui->spinBox_priority->setValue(settings[QString("Priority")].toInt());
if (ethernetSettings.contains(QString("TimeoutWPA"))) if (settings.contains(QString("TimeoutCarrier")))
ui->spinBox_timeoutWpa->setValue(ethernetSettings[QString("TimeoutWPA")].toInt()); 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()); showWpa(ui->checkBox_8021x->checkState());
} }

View File

@ -39,7 +39,6 @@ public:
public slots: public slots:
void clear(); void clear();
void setShown(const bool state);
private slots: private slots:
void selectWpaConfig(); void selectWpaConfig();

View File

@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>431</width> <width>550</width>
<height>296</height> <height>255</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_ethernet"> <widget class="QDockWidget" name="dockWidget_ethernet">
<property name="features"> <property name="features">
@ -24,29 +24,29 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_ethernet"> <widget class="QWidget" name="dockWidgetContents_ethernet">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_ethernetAdvanced"> <layout class="QHBoxLayout" name="layout_ethernetAdvanced">
<item> <item>
<spacer name="spacer_ethernetAdvanced"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_ethernetAdvanced"> <widget class="QToolButton" name="pushButton_ethernetAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -54,8 +54,29 @@
<item> <item>
<widget class="QWidget" name="widget_ethernetAdvanced" native="true"> <widget class="QWidget" name="widget_ethernetAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3"> <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> <item>
<widget class="QCheckBox" name="checkBox_skip"> <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"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the absence of a carrier is acceptable&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the absence of a carrier is acceptable&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
@ -64,8 +85,28 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QCheckBox" name="checkBox_8021x"> <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"> <property name="toolTip">
<string>Set to yes to use 802.1x authentication</string> <string>Set to yes to use 802.1x authentication</string>
</property> </property>
@ -77,26 +118,40 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<widget class="QWidget" name="widget_wpa" native="true"> <widget class="QWidget" name="widget_wpa" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_wpaConfig"> <layout class="QHBoxLayout" name="layout_wpaConfig">
<item> <item>
<widget class="QLabel" name="label_wpaConfig"> <widget class="QLabel" name="label_wpaConfig">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>7</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>WPA config file</string> <string>WPA config file</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_wpaConfig"> <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"> <property name="toolTip">
<string>Path to a wpa_supplicant configuration file</string> <string>Path to a wpa_supplicant configuration file</string>
</property> </property>
@ -104,6 +159,12 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_wpaConfig"> <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"> <property name="text">
<string>Browse</string> <string>Browse</string>
</property> </property>
@ -115,19 +176,28 @@
<layout class="QHBoxLayout" name="layout_driver"> <layout class="QHBoxLayout" name="layout_driver">
<item> <item>
<widget class="QLabel" name="label_driver"> <widget class="QLabel" name="label_driver">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>7</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>WPA driver</string> <string>WPA driver</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_driver"> <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"> <property name="toolTip">
<string>The wpa_supplicant driver to use for 802.1x authentication</string> <string>The wpa_supplicant driver to use for 802.1x authentication</string>
</property> </property>
@ -157,19 +227,28 @@
<layout class="QHBoxLayout" name="layout_timeoutCarrier"> <layout class="QHBoxLayout" name="layout_timeoutCarrier">
<item> <item>
<widget class="QLabel" name="label_timeoutCarrier"> <widget class="QLabel" name="label_timeoutCarrier">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Timeout carrier</string> <string>Timeout carrier</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_timeoutCarrier"> <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"> <property name="toolTip">
<string>Maximum time, in seconds, to wait for a carrier</string> <string>Maximum time, in seconds, to wait for a carrier</string>
</property> </property>
@ -187,19 +266,28 @@
<layout class="QHBoxLayout" name="layout_timeoutWpa"> <layout class="QHBoxLayout" name="layout_timeoutWpa">
<item> <item>
<widget class="QLabel" name="label_timeoutWpa"> <widget class="QLabel" name="label_timeoutWpa">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Timeout WPA</string> <string>Timeout WPA</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_timeoutWpa"> <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"> <property name="toolTip">
<string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string> <string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string>
</property> </property>
@ -213,6 +301,45 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_priority">
<item>
<widget class="QLabel" name="label_priority">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Priority</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_priority">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Priority level of the profile. In case of automatic profile selection, profiles are tried in decreasing order of priority</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>1</number>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -223,9 +350,6 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>pushButton_ethernetAdvanced</tabstop>
<tabstop>checkBox_skip</tabstop>
<tabstop>checkBox_8021x</tabstop>
<tabstop>lineEdit_wpaConfig</tabstop> <tabstop>lineEdit_wpaConfig</tabstop>
<tabstop>pushButton_wpaConfig</tabstop> <tabstop>pushButton_wpaConfig</tabstop>
<tabstop>comboBox_driver</tabstop> <tabstop>comboBox_driver</tabstop>

View File

@ -59,6 +59,7 @@ void GeneralWidget::clear()
ui->listWidget_after->clear(); ui->listWidget_after->clear();
ui->lineEdit_execUpPost->clear(); ui->lineEdit_execUpPost->clear();
ui->lineEdit_execDownPre->clear(); ui->lineEdit_execDownPre->clear();
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked); ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
ui->checkBox_debug->setCheckState(Qt::Unchecked); ui->checkBox_debug->setCheckState(Qt::Unchecked);
@ -67,20 +68,13 @@ void GeneralWidget::clear()
} }
void GeneralWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void GeneralWidget::createActions() void GeneralWidget::createActions()
{ {
connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced())); connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_after, SIGNAL(clicked(bool)), this, SLOT(addAfter())); 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->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
connect(ui->comboBox_bindto->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addBindTo()));
} }
@ -100,10 +94,10 @@ void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
{ {
if (pressedKey->key() == Qt::Key_Delete) { if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_bindto->hasFocus() && if (ui->listWidget_bindto->hasFocus() &&
(ui->listWidget_bindto->currentItem() != 0)) (ui->listWidget_bindto->currentItem() != nullptr))
delete ui->listWidget_bindto->currentItem(); delete ui->listWidget_bindto->currentItem();
else if (ui->listWidget_after->hasFocus() && else if (ui->listWidget_after->hasFocus() &&
(ui->listWidget_after->currentItem() != 0)) (ui->listWidget_after->currentItem() != nullptr))
delete ui->listWidget_after->currentItem(); delete ui->listWidget_after->currentItem();
} }
} }
@ -123,36 +117,37 @@ void GeneralWidget::showAdvanced()
QMap<QString, QString> GeneralWidget::getSettings() QMap<QString, QString> GeneralWidget::getSettings()
{ {
QMap<QString, QString> generalSettings; QMap<QString, QString> settings;
if (isOk() != 0) if (isOk() != 0) return settings;
return generalSettings;
generalSettings[QString("Description")] = QString("'") + ui->lineEdit_description->text() + QString("'"); settings[QString("Description")] = QString("'%1'").arg(ui->lineEdit_description->text());
generalSettings[QString("Connection")] = ui->comboBox_connection->currentText(); settings[QString("Connection")] = ui->comboBox_connection->currentText();
generalSettings[QString("Interface")] = ui->comboBox_interface->currentText(); settings[QString("Interface")] = ui->comboBox_interface->currentText();
if (ui->listWidget_bindto->count() != 0) { if (ui->listWidget_bindto->count() != 0) {
QStringList interfaces; QStringList interfaces;
for (int i=0; i<ui->listWidget_bindto->count(); i++) for (int i=0; i<ui->listWidget_bindto->count(); i++)
interfaces.append(ui->listWidget_bindto->item(i)->text()); interfaces.append(ui->listWidget_bindto->item(i)->text());
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QChar(' ')); settings[QString("BindsToInterfaces")] = interfaces.join(QChar(' '));
} }
if (ui->listWidget_after->count() != 0) { if (ui->listWidget_after->count() != 0) {
QStringList profiles; QStringList profiles;
for (int i=0; i<ui->listWidget_after->count(); i++) for (int i=0; i<ui->listWidget_after->count(); i++)
profiles.append(ui->listWidget_after->item(i)->text()); profiles.append(ui->listWidget_after->item(i)->text());
generalSettings[QString("After")] = profiles.join(QChar(' ')); settings[QString("After")] = profiles.join(QChar(' '));
} }
if (!ui->lineEdit_execUpPost->text().isEmpty()) if (!ui->lineEdit_execUpPost->text().isEmpty())
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'"); settings[QString("ExecUpPost")] = QString("'%1'").arg(ui->lineEdit_execUpPost->text());
if (!ui->lineEdit_execDownPre->text().isEmpty()) if (!ui->lineEdit_execDownPre->text().isEmpty())
generalSettings[QString("ExecDownPre")] = QString("'") + ui->lineEdit_execDownPre->text() + QString("'"); settings[QString("ExecDownPre")] = QString("'%1'").arg(ui->lineEdit_execDownPre->text());
if (ui->checkBox_exclude->checkState() == Qt::Checked)
settings[QString("ExcludeAuto")] = QString("yes");
if (ui->checkBox_forceConnect->checkState() == Qt::Checked) if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
generalSettings[QString("ForceConnect")] = QString("yes"); settings[QString("ForceConnect")] = QString("yes");
if (ui->checkBox_debug->checkState() == Qt::Checked) if (ui->checkBox_debug->checkState() == Qt::Checked)
generalSettings[QString("NETCTL_DEBUG")] = QString("yes"); settings[QString("NETCTL_DEBUG")] = QString("yes");
return generalSettings; return settings;
} }
@ -164,11 +159,9 @@ int GeneralWidget::isOk()
(ui->comboBox_connection->currentText() == QString("vlan")) || (ui->comboBox_connection->currentText() == QString("vlan")) ||
(ui->comboBox_connection->currentText() == QString("macvlan")) || (ui->comboBox_connection->currentText() == QString("macvlan")) ||
(ui->comboBox_connection->currentText() == QString("openvswitch"))) (ui->comboBox_connection->currentText() == QString("openvswitch")))
if (ui->listWidget_bindto->count() == 0) if (ui->listWidget_bindto->count() == 0) return 1;
return 1;
// empty description // empty description
if (ui->lineEdit_description->text().isEmpty()) if (ui->lineEdit_description->text().isEmpty()) return 2;
return 2;
// all fine // all fine
return 0; return 0;
} }
@ -177,30 +170,32 @@ int GeneralWidget::isOk()
void GeneralWidget::setSettings(const QMap<QString, QString> settings) void GeneralWidget::setSettings(const QMap<QString, QString> settings)
{ {
clear(); clear();
QMap<QString, QString> generalSettings = settings;
if (generalSettings.contains(QString("Description"))) if (settings.contains(QString("Description")))
ui->lineEdit_description->setText(generalSettings[QString("Description")]); ui->lineEdit_description->setText(settings[QString("Description")]);
if (generalSettings.contains(QString("Connection"))) if (settings.contains(QString("Connection"))) {
for (int i=0; i<ui->comboBox_connection->count(); i++) int index = ui->comboBox_connection->findText(settings[QString("Connection")]);
if (generalSettings[QString("Connection")] == ui->comboBox_connection->itemText(i)) ui->comboBox_connection->setCurrentIndex(index);
ui->comboBox_connection->setCurrentIndex(i);
if (generalSettings.contains(QString("Interface"))) {
ui->comboBox_interface->addItem(generalSettings[QString("Interface")]);
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count()-1);
} }
if (generalSettings.contains(QString("BindsToInterfaces"))) if (settings.contains(QString("Interface"))) {
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QChar('\n'))); ui->comboBox_interface->addItem(settings[QString("Interface")]);
if (generalSettings.contains(QString("After"))) ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count() - 1);
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QChar('\n'))); }
if (generalSettings.contains(QString("ExecUpPost"))) if (settings.contains(QString("BindsToInterfaces")))
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")]); ui->listWidget_bindto->addItems(settings[QString("BindsToInterfaces")].split(QChar('\n')));
if (generalSettings.contains(QString("ExecDownPre"))) if (settings.contains(QString("After")))
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")]); ui->listWidget_after->addItems(settings[QString("After")].split(QChar('\n')));
if (generalSettings.contains(QString("ForceConnect"))) if (settings.contains(QString("ExecUpPost")))
if (generalSettings[QString("ForceConnect")] == QString("yes")) ui->lineEdit_execUpPost->setText(settings[QString("ExecUpPost")]);
if (settings.contains(QString("ExecDownPre")))
ui->lineEdit_execDownPre->setText(settings[QString("ExecDownPre")]);
if (settings.contains(QString("ExcludeAuto")))
if (settings[QString("ExcludeAuto")] == QString("yes"))
ui->checkBox_exclude->setCheckState(Qt::Checked);
if (settings.contains(QString("ForceConnect")))
if (settings[QString("ForceConnect")] == QString("yes"))
ui->checkBox_forceConnect->setCheckState(Qt::Checked); ui->checkBox_forceConnect->setCheckState(Qt::Checked);
if (generalSettings.contains(QString("NETCTL_DEBUG"))) if (settings.contains(QString("NETCTL_DEBUG")))
if (generalSettings[QString("NETCTL_DEBUG")] == QString("yes")) if (settings[QString("NETCTL_DEBUG")] == QString("yes"))
ui->checkBox_debug->setCheckState(Qt::Checked); ui->checkBox_debug->setCheckState(Qt::Checked);
} }

View File

@ -43,7 +43,6 @@ public:
public slots: public slots:
void clear(); void clear();
void setShown(const bool state);
private slots: private slots:
void addAfter(); void addAfter();

View File

@ -6,16 +6,22 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>425</width> <width>550</width>
<height>531</height> <height>479</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_general"> <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"> <property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set> <set>QDockWidget::NoDockWidgetFeatures</set>
</property> </property>
@ -24,25 +30,37 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_general"> <widget class="QWidget" name="dockWidgetContents_general">
<layout class="QVBoxLayout" name="verticalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_description"> <layout class="QHBoxLayout" name="layout_description">
<item> <item>
<widget class="QLabel" name="label_description"> <widget class="QLabel" name="label_description">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Description</string> <string>Description</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_description"> <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"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;A description of the profile&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>A description of the profile</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -52,19 +70,28 @@
<layout class="QHBoxLayout" name="layout_connection"> <layout class="QHBoxLayout" name="layout_connection">
<item> <item>
<widget class="QLabel" name="label_connection"> <widget class="QLabel" name="label_connection">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Connection</string> <string>Connection</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_connection"> <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"> <property name="toolTip">
<string>The connection type used by the profile</string> <string>The connection type used by the profile</string>
</property> </property>
@ -136,19 +163,28 @@
<layout class="QHBoxLayout" name="layout_interface"> <layout class="QHBoxLayout" name="layout_interface">
<item> <item>
<widget class="QLabel" name="label_interface"> <widget class="QLabel" name="label_interface">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Interface</string> <string>Interface</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_interface"> <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"> <property name="toolTip">
<string>The name of the associated network interface</string> <string>The name of the associated network interface</string>
</property> </property>
@ -165,18 +201,27 @@
<layout class="QHBoxLayout" name="layout_bindtoButton"> <layout class="QHBoxLayout" name="layout_bindtoButton">
<item> <item>
<widget class="QLabel" name="label_bindto"> <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"> <property name="text">
<string>Binds to interfaces</string> <string>Binds to interfaces</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_bindto"> <widget class="QComboBox" name="comboBox_bindto">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<width>150</width> <horstretch>10</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
@ -185,6 +230,12 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_bindto"> <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"> <property name="text">
<string>Add</string> <string>Add</string>
</property> </property>
@ -210,26 +261,23 @@
<item> <item>
<layout class="QHBoxLayout" name="layout_generalAdvanced"> <layout class="QHBoxLayout" name="layout_generalAdvanced">
<item> <item>
<spacer name="spacer_generalAdvanced"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_generalAdvanced"> <widget class="QToolButton" name="pushButton_generalAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -237,24 +285,36 @@
<item> <item>
<widget class="QWidget" name="widget_generalAdvanced" native="true"> <widget class="QWidget" name="widget_generalAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" name="layout_after"> <layout class="QVBoxLayout" name="layout_after">
<item> <item>
<layout class="QHBoxLayout" name="layout_afterButton"> <layout class="QHBoxLayout" name="layout_afterButton">
<item> <item>
<widget class="QLabel" name="label_after"> <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"> <property name="text">
<string>After</string> <string>After</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_after"> <widget class="QComboBox" name="comboBox_after">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<width>150</width> <horstretch>10</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="editable"> <property name="editable">
<bool>true</bool> <bool>true</bool>
@ -263,6 +323,12 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_after"> <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"> <property name="text">
<string>Add</string> <string>Add</string>
</property> </property>
@ -289,19 +355,28 @@
<layout class="QHBoxLayout" name="layout_execUpPost"> <layout class="QHBoxLayout" name="layout_execUpPost">
<item> <item>
<widget class="QLabel" name="label_execUpPost"> <widget class="QLabel" name="label_execUpPost">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>7</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Command after starting</string> <string>Command after starting</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_execUpPost"> <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"> <property name="toolTip">
<string>A command that is executed after a connection is established</string> <string>A command that is executed after a connection is established</string>
</property> </property>
@ -313,19 +388,28 @@
<layout class="QHBoxLayout" name="layout_execDownPre"> <layout class="QHBoxLayout" name="layout_execDownPre">
<item> <item>
<widget class="QLabel" name="label_execDownPre"> <widget class="QLabel" name="label_execDownPre">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>7</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Command before stoping</string> <string>Command before stoping</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_execDownPre"> <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"> <property name="toolTip">
<string>A command that is executed before a connection is brought down</string> <string>A command that is executed before a connection is brought down</string>
</property> </property>
@ -333,8 +417,56 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_exclude">
<item>
<widget class="QLabel" name="label_exclude">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_exclude">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Whether or not to exclude this profile from automatic profile selection</string>
</property>
<property name="text">
<string>Exclude auto</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_forceConnect">
<item>
<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> <item>
<widget class="QCheckBox" name="checkBox_forceConnect"> <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"> <property name="toolTip">
<string>Set to yes to force connecting even if the interface is up</string> <string>Set to yes to force connecting even if the interface is up</string>
</property> </property>
@ -343,14 +475,36 @@
</property> </property>
</widget> </widget>
</item> </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> <item>
<widget class="QCheckBox" name="checkBox_debug"> <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"> <property name="text">
<string>Debug mode</string> <string>Debug mode</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="1">
<libraries>
<library>qt</library>
</libraries>
</project>

View 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);
}

View 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 */

View File

@ -20,6 +20,9 @@
#include <QKeyEvent> #include <QKeyEvent>
#include "errorwindow.h"
#include "ipregexp.h"
IpWidget::IpWidget(QWidget *parent) IpWidget::IpWidget(QWidget *parent)
: QWidget(parent), : QWidget(parent),
@ -89,15 +92,6 @@ void IpWidget::clear()
} }
void IpWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void IpWidget::createActions() void IpWidget::createActions()
{ {
connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced())); connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
@ -111,32 +105,36 @@ void IpWidget::createActions()
connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString))); connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
// buttons // buttons
connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp())); 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_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6())); 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_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom())); 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->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->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
connect(ui->lineEdit_dnsOptions, SIGNAL(returnPressed()), this, SLOT(addDnsOpt()));
} }
void IpWidget::createFilter() void IpWidget::createFilter()
{ {
// using input mask because validators is not comfortable
// ipv4 // ipv4
ui->lineEdit_ipAddress->setInputMask(QString("999.999.999.999/99")); ui->lineEdit_ipAddress->setValidator(IpRegExp::ipv4CidrValidator());
ui->lineEdit_gateway->setInputMask(QString("999.999.999.999")); ui->lineEdit_gateway->setValidator(IpRegExp::ipv4Validator());
ui->lineEdit_ipRoutes->setInputMask(QString("999.999.999.999/99")); ui->lineEdit_ipRoutes->setValidator(IpRegExp::ipv4CidrValidator());
ui->lineEdit_ipRoutes2->setInputMask(QString("999.999.999.999")); ui->lineEdit_ipRoutes2->setValidator(IpRegExp::ipv4Validator());
// ipv6 // ipv6
ui->lineEdit_ipAddress6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999")); ui->lineEdit_ipAddress6->setValidator(IpRegExp::ipv6CidrValidator());
ui->lineEdit_gateway6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh")); ui->lineEdit_gateway6->setValidator(IpRegExp::ipv6Validator());
ui->lineEdit_ipRoutes6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999")); ui->lineEdit_ipRoutes6->setValidator(IpRegExp::ipv6CidrValidator());
ui->lineEdit_ipRoutes62->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh")); ui->lineEdit_ipRoutes62->setValidator(IpRegExp::ipv6Validator());
// dns // dns
ui->lineEdit_dns->setInputMask(QString("999.999.999.999")); ui->lineEdit_dns->setValidator(IpRegExp::ipv4Validator());
} }
@ -144,110 +142,47 @@ void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
{ {
if (pressedKey->key() == Qt::Key_Delete) { if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_ipAddress->hasFocus() && if (ui->listWidget_ipAddress->hasFocus() &&
(ui->listWidget_ipAddress->currentItem() != 0)) (ui->listWidget_ipAddress->currentItem() != nullptr))
delete ui->listWidget_ipAddress->currentItem(); delete ui->listWidget_ipAddress->currentItem();
else if (ui->listWidget_ipRoutes->hasFocus() && else if (ui->listWidget_ipRoutes->hasFocus() &&
(ui->listWidget_ipRoutes->currentItem() != 0)) (ui->listWidget_ipRoutes->currentItem() != nullptr))
delete ui->listWidget_ipRoutes->currentItem(); delete ui->listWidget_ipRoutes->currentItem();
else if (ui->listWidget_ipAddress6->hasFocus() && else if (ui->listWidget_ipAddress6->hasFocus() &&
(ui->listWidget_ipAddress6->currentItem() != 0)) (ui->listWidget_ipAddress6->currentItem() != nullptr))
delete ui->listWidget_ipAddress6->currentItem(); delete ui->listWidget_ipAddress6->currentItem();
else if (ui->listWidget_ipRoutes6->hasFocus() && else if (ui->listWidget_ipRoutes6->hasFocus() &&
(ui->listWidget_ipRoutes6->currentItem() != 0)) (ui->listWidget_ipRoutes6->currentItem() != nullptr))
delete ui->listWidget_ipRoutes6->currentItem(); delete ui->listWidget_ipRoutes6->currentItem();
else if (ui->listWidget_custom->hasFocus() && else if (ui->listWidget_custom->hasFocus() &&
(ui->listWidget_custom->currentItem() != 0)) (ui->listWidget_custom->currentItem() != nullptr))
delete ui->listWidget_custom->currentItem(); delete ui->listWidget_custom->currentItem();
else if (ui->listWidget_dns->hasFocus() && else if (ui->listWidget_dns->hasFocus() &&
(ui->listWidget_dns->currentItem() != 0)) (ui->listWidget_dns->currentItem() != nullptr))
delete ui->listWidget_dns->currentItem(); delete ui->listWidget_dns->currentItem();
else if (ui->listWidget_dnsOptions->hasFocus() && else if (ui->listWidget_dnsOptions->hasFocus() &&
(ui->listWidget_dnsOptions->currentItem() != 0)) (ui->listWidget_dnsOptions->currentItem() != nullptr))
delete ui->listWidget_dnsOptions->currentItem(); delete ui->listWidget_dnsOptions->currentItem();
} }
} }
QString IpWidget::getIp(const QString rawIp)
{
QStringList ip = rawIp.split(QChar('.'));
// fix empty fields
if (ip[0].isEmpty())
ip[0] = QString("127");
if (ip[1].isEmpty())
ip[1] = QString("0");
if (ip[2].isEmpty())
ip[2] = QString("0");
if (ip[3].isEmpty())
ip[3] = QString("1");
// fix numbers
for (int i=0; i<4; i++)
if (ip[i].toInt() > 255)
ip[i] = QString("255");
return ip.join(QChar('.'));
}
QString IpWidget::getPrefix(const QString rawPrefix)
{
QString prefix;
if (rawPrefix.isEmpty())
prefix = QString("24");
else if (rawPrefix.toInt() > 32)
prefix = QString("32");
else
prefix = rawPrefix;
return prefix;
}
QString IpWidget::getIp6(const QString rawIp)
{
QString ip = rawIp;
for (int i=0; i<5; i++)
ip.replace(QString(":::"), QString("::"));
return ip;
}
QString IpWidget::getPrefix6(const QString rawPrefix)
{
QString prefix;
if (rawPrefix.isEmpty())
prefix = QString("64");
else if (rawPrefix.toInt() > 128)
prefix = QString("128");
else
prefix = rawPrefix;
return prefix;
}
void IpWidget::addIp() void IpWidget::addIp()
{ {
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[0]); if (!IpRegExp::checkString(ui->lineEdit_ipAddress->text(), IpRegExp::ip4CidrRegex()))
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[1]); return ErrorWindow::showWindow(20, QString("[IpWidget::addIp]"));
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix); ui->listWidget_ipAddress->addItem(ui->lineEdit_ipAddress->text());
ui->lineEdit_ipAddress->clear(); ui->lineEdit_ipAddress->clear();
} }
void IpWidget::addIpRoutes() void IpWidget::addIpRoutes()
{ {
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[0]); if ((!IpRegExp::checkString(ui->lineEdit_ipRoutes->text(), IpRegExp::ip4CidrRegex())) ||
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[1]); (!IpRegExp::checkString(ui->lineEdit_ipRoutes2->text(), IpRegExp::ip4Regex())))
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(QChar(' '))); return ErrorWindow::showWindow(20, QString("[IpWidget::addIpRoutes]"));
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia); ui->listWidget_ipRoutes->addItem(QString("%1 via %2").arg(ui->lineEdit_ipRoutes->text()).arg(ui->lineEdit_ipRoutes2->text()));
ui->lineEdit_ipRoutes->clear(); ui->lineEdit_ipRoutes->clear();
ui->lineEdit_ipRoutes2->clear(); ui->lineEdit_ipRoutes2->clear();
} }
@ -255,21 +190,21 @@ void IpWidget::addIpRoutes()
void IpWidget::addIp6() void IpWidget::addIp6()
{ {
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[0]); if (!IpRegExp::checkString(ui->lineEdit_ipAddress6->text(), IpRegExp::ip6CidrRegex()))
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[1]); return ErrorWindow::showWindow(20, QString("[IpWidget::addIp6]"));
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix); ui->listWidget_ipAddress6->addItem(ui->lineEdit_ipAddress6->text());
ui->lineEdit_ipAddress6->clear(); ui->lineEdit_ipAddress6->clear();
} }
void IpWidget::addIpRoutes6() void IpWidget::addIpRoutes6()
{ {
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[0]); if ((!IpRegExp::checkString(ui->lineEdit_ipRoutes6->text(), IpRegExp::ip6CidrRegex())) ||
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[1]); (!IpRegExp::checkString(ui->lineEdit_ipRoutes62->text(), IpRegExp::ip6Regex())))
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(QChar(' '))); return ErrorWindow::showWindow(20, QString("[IpWidget::addIp6Routes]"));
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia); ui->listWidget_ipRoutes6->addItem(QString("%1 via %2").arg(ui->lineEdit_ipRoutes6->text()).arg(ui->lineEdit_ipRoutes62->text()));
ui->lineEdit_ipRoutes6->clear(); ui->lineEdit_ipRoutes6->clear();
ui->lineEdit_ipRoutes62->clear(); ui->lineEdit_ipRoutes62->clear();
} }
@ -285,9 +220,10 @@ void IpWidget::addCustom()
void IpWidget::addDns() void IpWidget::addDns()
{ {
QString ip = getIp(ui->lineEdit_dns->text().remove(QChar(' '))); if (!IpRegExp::checkString(ui->lineEdit_dns->text(), IpRegExp::ip4Regex()))
return ErrorWindow::showWindow(20, QString("[IpWidget::addDns]"));
ui->listWidget_dns->addItem(ip); ui->listWidget_dns->addItem(ui->lineEdit_dns->text());
ui->lineEdit_dns->clear(); ui->lineEdit_dns->clear();
} }
@ -302,61 +238,36 @@ void IpWidget::addDnsOpt()
void IpWidget::changeIpMode(const QString currentText) void IpWidget::changeIpMode(const QString currentText)
{ {
if (currentText == QString("dhcp")) ui->widget_ip->setHidden(currentText == QString("dhcp"));
ui->widget_ip->setHidden(true);
else if (currentText == QString("static"))
ui->widget_ip->setHidden(false);
} }
void IpWidget::ipEnable(const int state) void IpWidget::ipEnable(const int state)
{ {
if (state == 0) { ui->comboBox_ip->setDisabled(state == 0);
ui->comboBox_ip->setDisabled(true); ui->widget_ip->setDisabled(state == 0);
ui->widget_ip->setDisabled(true); ui->widget_ipRoutes->setDisabled(state == 0);
ui->widget_ipRoutes->setDisabled(true);
} else {
ui->comboBox_ip->setEnabled(true);
ui->widget_ip->setEnabled(true);
ui->widget_ipRoutes->setEnabled(true);
}
} }
void IpWidget::changeIp6Mode(const QString currentText) void IpWidget::changeIp6Mode(const QString currentText)
{ {
if ((currentText == QString("dhcp")) || ui->widget_ip6->setHidden(currentText.startsWith(QString("dhcp")));
(currentText == QString("dhcp-noaddr")))
ui->widget_ip6->setHidden(true);
else if ((currentText == QString("static")) ||
(currentText == QString("stateless")))
ui->widget_ip6->setHidden(false);
} }
void IpWidget::ip6Enable(const int state) void IpWidget::ip6Enable(const int state)
{ {
if (state == 0) { ui->comboBox_ip6->setDisabled(state == 0);
ui->comboBox_ip6->setDisabled(true); ui->widget_ip6->setDisabled(state == 0);
ui->widget_ip6->setDisabled(true); ui->widget_ipRoutes6->setDisabled(state == 0);
ui->widget_ipRoutes6->setDisabled(true);
} else {
ui->comboBox_ip6->setEnabled(true);
ui->widget_ip6->setEnabled(true);
ui->widget_ipRoutes6->setEnabled(true);
}
} }
void IpWidget::changeDhcpClient(const QString currentText) void IpWidget::changeDhcpClient(const QString currentText)
{ {
if (currentText == QString("dhcpcd")) { ui->widget_dhcpcdOpt->setHidden(currentText != QString("dhcpcd"));
ui->widget_dhcpcdOpt->setHidden(false); ui->widget_dhclientOpt->setHidden(currentText == QString("dhcpcd"));
ui->widget_dhclientOpt->setHidden(true);
} else if (currentText == QString("dhclient")) {
ui->widget_dhcpcdOpt->setHidden(true);
ui->widget_dhclientOpt->setHidden(false);
}
} }
@ -364,116 +275,113 @@ void IpWidget::showAdvanced()
{ {
if (ui->pushButton_ipAdvanced->isChecked()) { if (ui->pushButton_ipAdvanced->isChecked()) {
ui->widget_ipAdvanced->setHidden(false); ui->widget_ipAdvanced->setHidden(false);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced")); ui->pushButton_ipAdvanced->setArrowType(Qt::UpArrow);
} else { } else {
ui->widget_ipAdvanced->setHidden(true); ui->widget_ipAdvanced->setHidden(true);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced")); ui->pushButton_ipAdvanced->setArrowType(Qt::DownArrow);
} }
} }
QMap<QString, QString> IpWidget::getSettings() QMap<QString, QString> IpWidget::getSettings()
{ {
QMap<QString, QString> ipSettings; QMap<QString, QString> settings;
if (isOk() != 0) if (isOk() != 0) return settings;
return ipSettings;
if (ui->checkBox_ip->checkState() == Qt::Checked) { if (ui->checkBox_ip->checkState() == Qt::Checked) {
ipSettings[QString("IP")] = ui->comboBox_ip->currentText(); settings[QString("IP")] = ui->comboBox_ip->currentText();
if (ui->comboBox_ip->currentText() == QString("static")) { if (ui->comboBox_ip->currentText() == QString("static")) {
QStringList addresses; QStringList addresses;
for (int i=0; i<ui->listWidget_ipAddress->count(); i++) for (int i=0; i<ui->listWidget_ipAddress->count(); i++)
addresses.append(QString("'") + ui->listWidget_ipAddress->item(i)->text() + QString("'")); addresses.append(QString("'%1'").arg(ui->listWidget_ipAddress->item(i)->text()));
ipSettings[QString("Address")] = addresses.join(QChar(' ')); settings[QString("Address")] = addresses.join(QChar(' '));
ipSettings[QString("Gateway")] = QString("'") + ui->lineEdit_gateway->text() + QString("'"); settings[QString("Gateway")] = QString("'%1'").arg(ui->lineEdit_gateway->text());
} }
if (ui->listWidget_ipRoutes->count() > 0) { if (ui->listWidget_ipRoutes->count() > 0) {
QStringList routes; QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++) for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'")); routes.append(QString("'%1'").arg(ui->listWidget_ipRoutes->item(i)->text()));
ipSettings[QString("Routes")] = routes.join(QChar(' ')); settings[QString("Routes")] = routes.join(QChar(' '));
} }
} else } else
ipSettings[QString("IP")] = QString("no"); settings[QString("IP")] = QString("no");
if (ui->checkBox_ip6->checkState() == Qt::Checked) { if (ui->checkBox_ip6->checkState() == Qt::Checked) {
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText(); settings[QString("IP6")] = ui->comboBox_ip6->currentText();
if ((ui->comboBox_ip6->currentText() == QString("static")) || if ((ui->comboBox_ip6->currentText() == QString("static")) ||
(ui->comboBox_ip6->currentText() == QString("stateless"))) { (ui->comboBox_ip6->currentText() == QString("stateless"))) {
QStringList addresses; QStringList addresses;
for (int i=0; i<ui->listWidget_ipAddress6->count(); i++) for (int i=0; i<ui->listWidget_ipAddress6->count(); i++)
addresses.append(QString("'") + ui->listWidget_ipAddress6->item(i)->text() + QString("'")); addresses.append(QString("'%1'").arg(ui->listWidget_ipAddress6->item(i)->text()));
ipSettings[QString("Address6")] = addresses.join(QChar(' ')); settings[QString("Address6")] = addresses.join(QChar(' '));
ipSettings[QString("Gateway6")] = QString("'") + ui->lineEdit_gateway6->text() + QString("'"); settings[QString("Gateway6")] = QString("'%1'").arg(ui->lineEdit_gateway6->text());
} }
if (ui->listWidget_ipRoutes6->count() > 0) { if (ui->listWidget_ipRoutes6->count() > 0) {
QStringList routes; QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++) for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'")); routes.append(QString("'%1'").arg(ui->listWidget_ipRoutes6->item(i)->text()));
ipSettings[QString("Routes6")] = routes.join(QChar(' ')); settings[QString("Routes6")] = routes.join(QChar(' '));
} }
} else } else
ipSettings[QString("IP6")] = QString("no"); settings[QString("IP6")] = QString("no");
if (ui->listWidget_custom->count() > 0) { if (ui->listWidget_custom->count() > 0) {
QStringList custom; QStringList custom;
for (int i=0; i<ui->listWidget_custom->count(); i++) for (int i=0; i<ui->listWidget_custom->count(); i++)
custom.append(QString("'") + ui->listWidget_custom->item(i)->text() + QString("'")); custom.append(QString("'%1'").arg(ui->listWidget_custom->item(i)->text()));
ipSettings[QString("IPCustom")] = custom.join(QChar(' ')); settings[QString("IPCustom")] = custom.join(QChar(' '));
} }
if (!ui->lineEdit_hostname->text().isEmpty()) if (!ui->lineEdit_hostname->text().isEmpty())
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'"); settings[QString("Hostname")] = QString("'%1'").arg(ui->lineEdit_hostname->text());
if (ui->spinBox_timeoutDad->value() != 3) if (ui->spinBox_timeoutDad->value() != 3)
ipSettings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value()); settings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value());
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) { if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty()) if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'"); settings[QString("DhcpcdOptions")] = QString("'%1'").arg(ui->lineEdit_dhcpcdOpt->text());
} else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) { } else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText(); settings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
if (!ui->lineEdit_dhclientOpt->text().isEmpty()) if (!ui->lineEdit_dhclientOpt->text().isEmpty())
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'"); settings[QString("DhclientOptions")] = QString("'%1'").arg(ui->lineEdit_dhclientOpt->text());
if (!ui->lineEdit_dhclientOpt6->text().isEmpty()) if (!ui->lineEdit_dhclientOpt6->text().isEmpty())
ipSettings[QString("DhclientOptions6")] = QString("'") + ui->lineEdit_dhclientOpt6->text() + QString("'"); settings[QString("DhclientOptions6")] = QString("'%1'").arg(ui->lineEdit_dhclientOpt6->text());
} }
if (ui->spinBox_timeoutDhcp->value() != 30) if (ui->spinBox_timeoutDhcp->value() != 30)
ipSettings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value()); settings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
if (ui->checkBox_dhcp->checkState() == Qt::Checked) if (ui->checkBox_dhcp->checkState() == Qt::Checked)
ipSettings[QString("DHCPReleaseOnStop")] = QString("yes"); settings[QString("DHCPReleaseOnStop")] = QString("yes");
if (ui->listWidget_dns->count() > 0) { if (ui->listWidget_dns->count() > 0) {
QStringList dns; QStringList dns;
for (int i=0; i<ui->listWidget_dns->count(); i++) for (int i=0; i<ui->listWidget_dns->count(); i++)
dns.append(QString("'") + ui->listWidget_dns->item(i)->text() + QString("'")); dns.append(QString("'%1'").arg(ui->listWidget_dns->item(i)->text()));
ipSettings[QString("DNS")] = dns.join(QChar(' ')); settings[QString("DNS")] = dns.join(QChar(' '));
} }
if (!ui->lineEdit_dnsDomain->text().isEmpty()) if (!ui->lineEdit_dnsDomain->text().isEmpty())
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'"); settings[QString("DNSDomain")] = QString("'%1'").arg(ui->lineEdit_dnsDomain->text());
if (!ui->lineEdit_dnsSearch->text().isEmpty()) if (!ui->lineEdit_dnsSearch->text().isEmpty())
ipSettings[QString("DNSSearch")] = QString("'") + ui->lineEdit_dnsSearch->text() + QString("'"); settings[QString("DNSSearch")] = QString("'%1'").arg(ui->lineEdit_dnsSearch->text());
if (ui->listWidget_dnsOptions->count() > 0) { if (ui->listWidget_dnsOptions->count() > 0) {
QStringList dnsOpt; QStringList dnsOpt;
for (int i=0; i<ui->listWidget_dnsOptions->count(); i++) for (int i=0; i<ui->listWidget_dnsOptions->count(); i++)
dnsOpt.append(QString("'") + ui->listWidget_dnsOptions->item(i)->text() + QString("'")); dnsOpt.append(QString("'%1'").arg(ui->listWidget_dnsOptions->item(i)->text()));
ipSettings[QString("DNSOptions")] = dnsOpt.join(QChar(' ')); settings[QString("DNSOptions")] = dnsOpt.join(QChar(' '));
} }
return ipSettings; return settings;
} }
int IpWidget::isOk() int IpWidget::isOk()
{ {
// ip settings is not set // ip settings is not set
if (ui->checkBox_ip->checkState() == Qt::Checked) if ((ui->checkBox_ip->checkState() == Qt::Checked) &&
if (ui->comboBox_ip->currentText() == QString("static")) (ui->comboBox_ip->currentText() == QString("static")))
if ((ui->listWidget_ipAddress->count() == 0) || if ((ui->listWidget_ipAddress->count() == 0) ||
(ui->lineEdit_gateway->text().isEmpty())) (ui->lineEdit_gateway->text().isEmpty())) return 1;
return 1;
// ipv6 settings is not set // ipv6 settings is not set
if (ui->checkBox_ip6->checkState() == Qt::Checked) if ((ui->checkBox_ip6->checkState() == Qt::Checked) &&
if ((ui->comboBox_ip6->currentText() == QString("static")) || ((ui->comboBox_ip6->currentText() == QString("static")) ||
(ui->comboBox_ip6->currentText() == QString("stateless"))) (ui->comboBox_ip6->currentText() == QString("stateless"))))
if ((ui->listWidget_ipAddress6->count() == 0) || if ((ui->listWidget_ipAddress6->count() == 0) ||
(ui->lineEdit_gateway6->text().isEmpty())) (ui->lineEdit_gateway6->text().isEmpty())) return 2;
return 2;
// all fine // all fine
return 0; return 0;
} }
@ -482,70 +390,66 @@ int IpWidget::isOk()
void IpWidget::setSettings(const QMap<QString, QString> settings) void IpWidget::setSettings(const QMap<QString, QString> settings)
{ {
clear(); clear();
QMap<QString, QString> ipSettings = settings;
if (ipSettings.contains(QString("IP"))) { if (settings.contains(QString("IP"))) {
if (ipSettings[QString("IP")] == QString("no")) if (settings[QString("IP")] == QString("no"))
ui->checkBox_ip->setCheckState(Qt::Unchecked); ui->checkBox_ip->setCheckState(Qt::Unchecked);
else { else {
ui->checkBox_ip->setCheckState(Qt::Checked); ui->checkBox_ip->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip->count(); i++) int index = ui->comboBox_ip->findText(settings[QString("IP")]);
if (ipSettings[QString("IP")] == ui->comboBox_ip->itemText(i)) ui->comboBox_ip->setCurrentIndex(index);
ui->comboBox_ip->setCurrentIndex(i);
} }
} }
if (ipSettings.contains(QString("Address"))) if (settings.contains(QString("Address")))
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].split(QChar('\n'))); ui->listWidget_ipAddress->addItems(settings[QString("Address")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway"))) if (settings.contains(QString("Gateway")))
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")]); ui->lineEdit_gateway->setText(settings[QString("Gateway")]);
if (ipSettings.contains(QString("Routes"))) if (settings.contains(QString("Routes")))
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].split(QChar('\n'))); ui->listWidget_ipRoutes->addItems(settings[QString("Routes")].split(QChar('\n')));
if (ipSettings.contains(QString("IP6"))) { if (settings.contains(QString("IP6"))) {
if (ipSettings[QString("IP6")] == QString("no")) if (settings[QString("IP6")] == QString("no"))
ui->checkBox_ip6->setCheckState(Qt::Unchecked); ui->checkBox_ip6->setCheckState(Qt::Unchecked);
else { else {
ui->checkBox_ip6->setCheckState(Qt::Checked); ui->checkBox_ip6->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip6->count(); i++) int index = ui->comboBox_ip6->findText(settings[QString("IP6")]);
if (ipSettings[QString("IP6")] == ui->comboBox_ip6->itemText(i)) ui->comboBox_ip6->setCurrentIndex(index);
ui->comboBox_ip6->setCurrentIndex(i);
} }
} }
if (ipSettings.contains(QString("Address6"))) if (settings.contains(QString("Address6")))
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].split(QChar('\n'))); ui->listWidget_ipAddress6->addItems(settings[QString("Address6")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway6"))) if (settings.contains(QString("Gateway6")))
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")]); ui->lineEdit_gateway6->setText(settings[QString("Gateway6")]);
if (ipSettings.contains(QString("Routes6"))) if (settings.contains(QString("Routes6")))
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].split(QChar('\n'))); ui->listWidget_ipRoutes6->addItems(settings[QString("Routes6")].split(QChar('\n')));
if (ipSettings.contains(QString("IPCustom"))) if (settings.contains(QString("IPCustom")))
ui->listWidget_custom->addItems(ipSettings[QString("IPCustom")].split(QChar('\n'))); ui->listWidget_custom->addItems(settings[QString("IPCustom")].split(QChar('\n')));
if (ipSettings.contains(QString("Hostname"))) if (settings.contains(QString("Hostname")))
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")]); ui->lineEdit_hostname->setText(settings[QString("Hostname")]);
if (ipSettings.contains(QString("TimeoutDAD"))) if (settings.contains(QString("TimeoutDAD")))
ui->spinBox_timeoutDad->setValue(ipSettings[QString("TimeoutDAD")].toInt()); ui->spinBox_timeoutDad->setValue(settings[QString("TimeoutDAD")].toInt());
if (ipSettings.contains(QString("DHCPClient"))) if (settings.contains(QString("DHCPClient"))) {
for (int i=0; i<ui->comboBox_dhcp->count(); i++) int index = ui->comboBox_dhcp->findText(settings[QString("DHCPClient")]);
if (ipSettings[QString("DHCPClient")] == ui->comboBox_dhcp->itemText(i)) ui->comboBox_dhcp->setCurrentIndex(index);
ui->comboBox_dhcp->setCurrentIndex(i); }
if (ipSettings.contains(QString("DhcpcdOptions"))) if (settings.contains(QString("DhcpcdOptions")))
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")] ui->lineEdit_dhcpcdOpt->setText(settings[QString("DhcpcdOptions")]);
.remove(QChar('\'')).remove(QChar('"'))); if (settings.contains(QString("DhclientOptions")))
if (ipSettings.contains(QString("DhclientOptions"))) ui->lineEdit_dhclientOpt->setText(settings[QString("DhclientOptions")]);
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")]); if (settings.contains(QString("DhclientOptions6")))
if (ipSettings.contains(QString("DhclientOptions6"))) ui->lineEdit_dhclientOpt6->setText(settings[QString("DhclientOptions6")]);
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")]); if (settings.contains(QString("TimeoutDHCP")))
if (ipSettings.contains(QString("TimeoutDHCP"))) ui->spinBox_timeoutDhcp->setValue(settings[QString("TimeoutDHCP")].toInt());
ui->spinBox_timeoutDhcp->setValue(ipSettings[QString("TimeoutDHCP")].toInt()); if (settings.contains(QString("DHCPReleaseOnStop")))
if (ipSettings.contains(QString("DHCPReleaseOnStop"))) if (settings[QString("DHCPReleaseOnStop")] == QString("yes"))
if (ipSettings[QString("DHCPReleaseOnStop")] == QString("yes"))
ui->checkBox_dhcp->setCheckState(Qt::Checked); ui->checkBox_dhcp->setCheckState(Qt::Checked);
if (ipSettings.contains(QString("DNS"))) if (settings.contains(QString("DNS")))
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].split(QChar('\n'))); ui->listWidget_dns->addItems(settings[QString("DNS")].split(QChar('\n')));
if (ipSettings.contains(QString("DNSDomain"))) if (settings.contains(QString("DNSDomain")))
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")]); ui->lineEdit_dnsDomain->setText(settings[QString("DNSDomain")]);
if (ipSettings.contains(QString("DNSSearch"))) if (settings.contains(QString("DNSSearch")))
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")]); ui->lineEdit_dnsSearch->setText(settings[QString("DNSSearch")]);
if (ipSettings.contains(QString("DNSOptions"))) if (settings.contains(QString("DNSOptions")))
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].split(QChar('\n'))); ui->listWidget_dnsOptions->addItems(settings[QString("DNSOptions")].split(QChar('\n')));
ipEnable(ui->checkBox_ip->checkState()); ipEnable(ui->checkBox_ip->checkState());
changeIpMode(ui->comboBox_ip->currentText()); changeIpMode(ui->comboBox_ip->currentText());

View File

@ -38,7 +38,6 @@ public:
public slots: public slots:
void clear(); void clear();
void setShown(const bool state);
private slots: private slots:
// buttons // buttons
@ -64,10 +63,6 @@ private:
void createActions(); void createActions();
void createFilter(); void createFilter();
void keyPressEvent(QKeyEvent *pressedKey); void keyPressEvent(QKeyEvent *pressedKey);
QString getIp(const QString rawIp);
QString getPrefix(const QString rawPrefix);
QString getIp6(const QString rawIp);
QString getPrefix6(const QString rawPrefix);
}; };

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +0,0 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "language.h"
#include <QFile>
#include <QLocale>
Language::Language()
{
}
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
{
QStringList availableLanguages = getAvailableLanguages();
for (int i=0; i<availableLanguages.count(); i++)
if (language == availableLanguages[i])
return availableLanguages[i];
for (int i=0; i<availableLanguages.count(); i++)
if (language.contains(availableLanguages[i] + QChar('_')))
return availableLanguages[i];
return defaultLanguage;
}
QString Language::defineLanguage(const QString configPath, const QString options)
{
QMap<QString, QString> optionsDict = parseOptions(options);
if (optionsDict.contains(QString("LANGUAGE")))
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
return optionsDict[QString("LANGUAGE")];
QString language;
language = defineLanguageFromFile(configPath);
if (language.isEmpty())
language = defineLanguageFromLocale();
language = checkLanguage(language, QString("en"));
return language;
}
QString Language::defineLanguageFromFile(const QString configPath)
{
QMap<QString, QString> settings;
if (configPath.isEmpty())
return QString("");
QFile configFile(configPath);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return QString("");
while (true) {
fileStr = QString(configFile.readLine()).trimmed();
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
if (fileStr.contains(QChar('=')))
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
if (configFile.atEnd()) break;
}
configFile.close();
if (settings.contains(QString("LANGUAGE")))
return settings[QString("LANGUAGE")];
else
return QString("");
}
QString Language::defineLanguageFromLocale()
{
return QLocale::system().name();
}
QStringList Language::getAvailableLanguages()
{
QStringList languages;
languages.append(QString("en"));
languages.append(QString("ru"));
return languages;
}
QMap<QString, QString> Language::parseOptions(const QString options)
{
QMap<QString, QString> optionsDict;
for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
continue;
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
options.split(QChar(','))[i].split(QChar('='))[1];
}
return optionsDict;
}

View File

@ -42,34 +42,24 @@ void MacvlanWidget::clear()
} }
void MacvlanWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MacvlanWidget::createFilter() void MacvlanWidget::createFilter()
{ {
// mac // mac
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH")); ui->lineEdit_mac->setInputMask(QString(">hh:hh:hh:hh:hh:hh"));
} }
QMap<QString, QString> MacvlanWidget::getSettings() QMap<QString, QString> MacvlanWidget::getSettings()
{ {
QMap<QString, QString> macvlanSettings; QMap<QString, QString> settings;
if (isOk() != 0) if (isOk() != 0) return settings;
return macvlanSettings;
macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText(); settings[QString("Mode")] = ui->comboBox_mode->currentText();
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty()) if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text(); settings[QString("MACAddress")] = ui->lineEdit_mac->text();
return macvlanSettings; return settings;
} }
@ -83,12 +73,11 @@ int MacvlanWidget::isOk()
void MacvlanWidget::setSettings(const QMap<QString, QString> settings) void MacvlanWidget::setSettings(const QMap<QString, QString> settings)
{ {
clear(); clear();
QMap<QString, QString> macvlanSettings = settings;
if (macvlanSettings.contains(QString("Mode"))) if (settings.contains(QString("Mode"))) {
for (int i=0; i<ui->comboBox_mode->count(); i++) int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
if (macvlanSettings[QString("Mode")] == ui->comboBox_mode->itemText(i)) ui->comboBox_mode->setCurrentIndex(index);
ui->comboBox_mode->setCurrentIndex(i); }
if (macvlanSettings.contains(QString("MACAddress"))) if (settings.contains(QString("MACAddress")))
ui->lineEdit_mac->setText(macvlanSettings[QString("MACAddress")]); ui->lineEdit_mac->setText(settings[QString("MACAddress")]);
} }

View File

@ -38,7 +38,6 @@ public:
public slots: public slots:
void clear(); void clear();
void setShown(const bool state);
private: private:
Ui::MacvlanWidget *ui; Ui::MacvlanWidget *ui;

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>396</width> <width>396</width>
<height>101</height> <height>79</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_macvlan"> <widget class="QDockWidget" name="dockWidget_macvlan">
<property name="features"> <property name="features">
@ -24,17 +24,35 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_macvlan"> <widget class="QWidget" name="dockWidgetContents_macvlan">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="layout_mode"> <layout class="QHBoxLayout" name="layout_mode">
<item> <item>
<widget class="QLabel" name="label_mode"> <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"> <property name="text">
<string>Mode</string> <string>Mode</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_mode"> <widget class="QComboBox" name="comboBox_mode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item> <item>
<property name="text"> <property name="text">
<string notr="true">bridge</string> <string notr="true">bridge</string>
@ -63,19 +81,28 @@
<layout class="QHBoxLayout" name="layout_mac"> <layout class="QHBoxLayout" name="layout_mac">
<item> <item>
<widget class="QLabel" name="label_mac"> <widget class="QLabel" name="label_mac">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>MAC address</string> <string>MAC address</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_mac"> <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"> <property name="toolTip">
<string>Optional static MAC address</string> <string>Optional static MAC address</string>
</property> </property>

View File

@ -21,15 +21,21 @@
#include <QDBusMessage> #include <QDBusMessage>
#include <QDir> #include <QDir>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QProcessEnvironment>
#include <QTranslator> #include <QTranslator>
#include <iostream> #include <iostream>
#include <unistd.h> #include <unistd.h>
#include "language.h" #include <language/language.h>
#include "mainwindow.h" #include "mainwindow.h"
#include "messages.h" #include "messages.h"
#include "version.h" #include "version.h"
#if QT_VERSION >= 0x050000
#include <pdebug/pdebug-time.h>
#endif /* QT_VERSION >= 0x050000 */
using namespace std; using namespace std;
@ -42,7 +48,7 @@ bool existingSessionOperation(const QString operation)
QDBusMessage response = bus.call(request); QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments(); QList<QVariant> arguments = response.arguments();
return !arguments.isEmpty(); return (!arguments.isEmpty() && arguments[0].toBool());
} }
@ -60,7 +66,7 @@ unsigned int getUidFromSession(const int type = 0)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QMap<QString, QVariant> args = getArgs(); QVariantMap args = getArgs();
// reading // reading
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
if (QString(argv[i]) == QString("--detached")) { if (QString(argv[i]) == QString("--detached")) {
@ -129,6 +135,9 @@ int main(int argc, char *argv[])
args[QString("error")] = true; 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()) || if ((args[QString("debug")].toBool()) ||
(args[QString("help")].toBool()) || (args[QString("help")].toBool()) ||
(args[QString("info")].toBool()) || (args[QString("info")].toBool()) ||
@ -136,32 +145,42 @@ int main(int argc, char *argv[])
(args[QString("error")].toBool())) (args[QString("error")].toBool()))
args[QString("detached")] = false; args[QString("detached")] = false;
if (args[QString("essid")].toString() != QString("ESSID")) if (args[QString("essid")].toString() != QString("ESSID"))
args[QString("tab")] = (int) 3; args[QString("tab")] = static_cast<int>(3);
if (args[QString("open")].toString() != QString("PROFILE")) if (args[QString("open")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 2; args[QString("tab")] = static_cast<int>(2);
if (args[QString("select")].toString() != QString("PROFILE")) if (args[QString("select")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 1; 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 // detach from console
if (args[QString("detached")].toBool()) if (args[QString("detached")].toBool())
daemon(0, 0); daemon(0, 0);
#if QT_VERSION >= 0x050000
qInstallMessageHandler(debugString);
#endif
QApplication a(argc, argv); QApplication a(argc, argv);
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
// reread translations according to flags // reread translations according to flags
QString language = Language::defineLanguage(args[QString("config")].toString(), QString language = Language::defineLanguage(args[QString("config")].toString(),
args[QString("options")].toString()); args[QString("options")].toString());
QTranslator qtTranslator; QTranslator qtTranslator;
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath)); qtTranslator.load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator); a.installTranslator(&qtTranslator);
QTranslator translator; QTranslator translator;
translator.load(QString(":/translations/") + language); translator.load(QString(":/translations/%1").arg(language));
a.installTranslator(&translator); a.installTranslator(&translator);
// running // running
if (args[QString("error")].toBool()) { if (args[QString("error")].toBool()) {
cout << errorMessage().toUtf8().data() << endl; cout << errorMessage().toUtf8().data() << endl;
cout << helpMessage().toUtf8().data(); cout << helpMessage().toUtf8().data();
return 127; return 1;
} else if (args[QString("help")].toBool()) { } else if (args[QString("help")].toBool()) {
cout << helpMessage().toUtf8().data(); cout << helpMessage().toUtf8().data();
return 0; return 0;

File diff suppressed because it is too large Load Diff

View File

@ -1,521 +0,0 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QDesktopServices>
#include <QLibraryInfo>
#include <QTranslator>
#include <QUrl>
#include "aboutwindow.h"
#include "dbusoperation.h"
#include "errorwindow.h"
#include "language.h"
#include "netctlautowindow.h"
#include "passwdwidget.h"
#include "pdebug.h"
#include "settingswindow.h"
#include "taskadds.h"
#include "trayicon.h"
#include "version.h"
void MainWindow::closeMainWindow()
{
if (debug) qDebug() << PDEBUG;
qApp->quit();
}
void MainWindow::showAboutWindow()
{
if (debug) qDebug() << PDEBUG;
aboutWin->show();
}
void MainWindow::showMainWindow()
{
if (debug) qDebug() << PDEBUG;
if (isHidden()) {
updateTabs(ui->tabWidget->currentIndex());
show();
} else
hide();
}
void MainWindow::showNetctlAutoWindow()
{
if (debug) qDebug() << PDEBUG;
netctlAutoWin->showWindow();
}
void MainWindow::showSettingsWindow()
{
if (debug) qDebug() << PDEBUG;
settingsWin->showWindow();
}
bool MainWindow::enableProfileSlot(const QString profile)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool current;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Enable"),
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
args, true, debug)[0].toBool();
} else {
netctlCommand->enableProfile(profile);
current = netctlCommand->isProfileEnabled(profile);
}
return current;
}
bool MainWindow::restartProfileSlot(const QString profile)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool current;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Restart"),
args, true, debug)[0].toBool();
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool();
} else {
netctlCommand->restartProfile(profile);
current = netctlCommand->isProfileActive(profile);
}
return current;
}
bool MainWindow::startProfileSlot(const QString profile)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool current;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
QStringList currentProfile = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
QList<QVariant>(), true, debug)[0]
.toString().split(QChar('|'));
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"),
args, true, debug);
else
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool();
} else {
QStringList currentProfile = netctlCommand->getActiveProfile();
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
netctlCommand->startProfile(profile);
else
netctlCommand->switchToProfile(profile);
current = netctlCommand->isProfileActive(profile);
}
return current;
}
bool MainWindow::stopAllProfilesSlot()
{
if (debug) qDebug() << PDEBUG;
if (useHelper)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("StopAll"),
QList<QVariant>(), true, debug);
else
netctlCommand->stopAllProfiles();
return true;
}
bool MainWindow::switchToProfileSlot(const QString profile)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
bool netctlAutoStatus = false;
if (useHelper)
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool();
else
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
bool current;
if (netctlAutoStatus) {
if (useHelper) {
QList<QVariant> args;
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoStart"),
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"),
args, true, debug)[0].toBool();
} else {
netctlCommand->autoStartProfile(profile);
current = netctlCommand->autoIsProfileActive(profile);
}
} else {
if (useHelper) {
QList<QVariant> args;
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
args, true, debug);
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool();
} else {
netctlCommand->switchToProfile(profile);
current = netctlCommand->isProfileActive(profile);
}
}
return current;
}
void MainWindow::showApi()
{
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html"))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
void MainWindow::showLibrary()
{
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("html/index.html"))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
void MainWindow::showSecurityNotes()
{
if (debug) qDebug() << PDEBUG;
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"))))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
bool MainWindow::forceStartHelper()
{
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("helper"))) {
errorWin->showWindow(1, QString(PDEBUG));
return false;
}
QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath;
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode == 0)
return true;
else
return false;
}
bool MainWindow::forceStopHelper()
{
if (debug) qDebug() << PDEBUG;
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Close"),
QList<QVariant>(), true, debug);
return !responce.isEmpty();
}
bool MainWindow::startHelper()
{
if (debug) qDebug() << PDEBUG;
if (isHelperActive())
return forceStopHelper();
else
return forceStartHelper();
}
void MainWindow::setTab(int tab)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
switch (tab) {
case 0:
case 1:
case 2:
break;
default:
tab = 0;
break;
}
ui->tabWidget->setCurrentIndex(tab);
updateTabs(tab);
}
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
{
if (debug) qDebug() << PDEBUG;
deleteObjects();
settingsWin = new SettingsWindow(this, debug, configPath);
if (args[QString("default")].toBool())
settingsWin->setDefault();
configuration = settingsWin->getSettings();
delete settingsWin;
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
for (int i=0; i<optionsDict.keys().count(); i++)
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
if ((configuration[QString("USE_HELPER")] == QString("true")) &&
(checkExternalApps(QString("helper"))))
useHelper = true;
else {
useHelper = false;
configuration[QString("USE_HELPER")] = QString("false");
}
// update translation
qApp->removeTranslator(translator);
QString language = Language::defineLanguage(configPath,
args[QString("options")].toString());
qtTranslator->load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtTranslator);
translator->load(QString(":/translations/") + language);
qApp->installTranslator(translator);
createObjects();
createActions();
// tray
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
(configuration[QString("SYSTRAY")] == QString("true")))
trayIcon->setVisible(true);
else
trayIcon->setVisible(false);
if (trayIcon->isVisible()) {
if (configuration[QString("STARTTOTRAY")] == QString("true"))
hide();
else
show();
if (args[QString("minimized")].toInt() == 1)
show();
else if (args[QString("minimized")].toInt() == 2)
hide();
}
else
show();
// update ui
setTab(args[QString("tab")].toInt() - 1);
}
void MainWindow::updateMenu()
{
if (debug) qDebug() << PDEBUG;
int tab = ui->tabWidget->currentIndex();
setMenuActionsShown(false);
if (tab == 0)
updateMenuMain();
else if (tab == 1)
updateMenuProfile();
else if (tab == 2)
updateMenuWifi();
}
void MainWindow::updateTabs(const int tab)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
if (tab == 0)
updateMainTab();
else if (tab == 1)
updateProfileTab();
else if (tab == 2)
updateWifiTab();
updateMenu();
}
void MainWindow::connectToUnknownEssid(const QString passwd)
{
if (debug) qDebug() << PDEBUG;
if (passwdWid != 0)
delete passwdWid;
QStringList interfaces;
if (useHelper)
interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
QList<QVariant>(), true, debug)[0].toStringList();
else
interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty()) return;
QMap<QString, QString> settings;
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
settings[QString("Interface")] = interfaces[0];
settings[QString("Connection")] = QString("wireless");
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text();
if (security.contains(QString("WPA")))
settings[QString("Security")] = QString("wpa");
else if (security.contains(QString("WEP")))
settings[QString("Security")] = QString("wep");
else
settings[QString("Security")] = QString("none");
settings[QString("ESSID")] = QString("'") +
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
QString("'");
if (!passwd.isEmpty())
settings[QString("Key")] = QString("'") + passwd + QString("'");
settings[QString("IP")] = QString("dhcp");
if (hiddenNetwork)
settings[QString("Hidden")] = QString("yes");
QString profile = QString("netctl-gui-") + settings[QString("ESSID")];
profile.remove(QChar('"')).remove(QChar('\''));
bool status = false;
if (useHelper) {
QStringList settingsList;
for (int i=0; i<settings.keys().count(); i++)
settingsList.append(settings.keys()[i] + QString("==") + settings[settings.keys()[i]]);
QList<QVariant> args;
args.append(profile);
args.append(settingsList);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Create"),
args, true, debug);
args.clear();
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"),
args, true, debug);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool();
} else {
QString profileTempName = netctlProfile->createProfile(profile, settings);
netctlProfile->copyProfile(profileTempName);
netctlCommand->startProfile(profile);
status = netctlCommand->isProfileActive(profile);
}
QString message;
if (status) {
message = QApplication::translate("MainWindow", "Connection is successfully.");
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
} else {
message = QApplication::translate("MainWindow", "Connection failed.");
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
message += QString("\n");
message += QApplication::translate("MainWindow", "Do you want to save profile %1?").arg(profile);
int select = QMessageBox::question(this, QApplication::translate("MainWindow", "WiFi menu"),
message, QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save);
switch (select) {
case QMessageBox::Save:
break;
case QMessageBox::Discard:
default:
if (useHelper) {
QList<QVariant> args;
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Remove"),
args, true, debug)[0].toBool();
} else
netctlProfile->removeProfile(profile);
break;
}
updateWifiTab();
}
void MainWindow::setHiddenName(const QString name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Set name" << name;
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
wifiTabStart();
}

View File

@ -0,0 +1,436 @@
/***************************************************************************
* 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);
// auto update
timer.setSingleShot(true);
timer.setInterval(configuration[QString("MAINUPDATE")].toInt() * 1000);
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;
if (mainWindow->currentTab() == 0) {
updateMainTab();
updateMenuMain();
}
if (timer.interval() != 0) return timer.start();
}
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(&timer, SIGNAL(timeout()), this, SLOT(update()));
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
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)));
}

View File

@ -0,0 +1,79 @@
/***************************************************************************
* 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 <QTimer>
#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;
QTimer timer;
bool useHelper = true;
// configuration
QMap<QString, QString> configuration;
};
#endif /* MAINWIDGET_H */

View 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>

View File

@ -21,35 +21,38 @@
#include <QDBusConnection> #include <QDBusConnection>
#include <QDBusMessage> #include <QDBusMessage>
#include <QDebug> #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 "aboutwindow.h"
#include "bridgewidget.h" #include "calls.h"
#include "commonfunctions.h"
#include "dbusoperation.h" #include "dbusoperation.h"
#include "errorwindow.h" #include "errorwindow.h"
#include "ethernetwidget.h" #include "mainwidget.h"
#include "generalwidget.h"
#include "ipwidget.h"
#include "macvlanwidget.h"
#include "mobilewidget.h"
#include "netctlautowindow.h" #include "netctlautowindow.h"
#include "netctlguiadaptor.h" #include "netctlguiadaptor.h"
#include "newprofilewidget.h"
#include "passwdwidget.h" #include "passwdwidget.h"
#include "pdebug.h"
#include "pppoewidget.h"
#include "settingswindow.h" #include "settingswindow.h"
#include "taskadds.h"
#include "trayicon.h" #include "trayicon.h"
#include "tunnelwidget.h"
#include "tuntapwidget.h"
#include "version.h" #include "version.h"
#include "vlanwidget.h" #include "wifimenuwidget.h"
#include "wirelesswidget.h"
MainWindow::MainWindow(QWidget *parent, MainWindow::MainWindow(QWidget *parent, const QVariantMap args,
const QMap<QString, QVariant> args, QTranslator *qtAppTranslator, QTranslator *appTranslator)
QTranslator *qtAppTranslator,
QTranslator *appTranslator)
: QMainWindow(parent), : QMainWindow(parent),
configPath(args[QString("config")].toString()), configPath(args[QString("config")].toString()),
debug(args[QString("debug")].toBool()), debug(args[QString("debug")].toBool()),
@ -70,24 +73,19 @@ MainWindow::MainWindow(QWidget *parent,
if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool(); if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt(); if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt();
ui = new Ui::MainWindow;
ui->setupUi(this);
updateConfiguration(args); updateConfiguration(args);
// main actions // main actions
if (args[QString("essid")].toString() != QString("ESSID")) { if (args[QString("essid")].toString() != QString("ESSID")) {
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++) if (!wifiMenuWidget->wifiTabSelectEssidSlot(args[QString("essid")].toString()))
if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString()) ErrorWindow::showWindow(18, QString(PDEBUG), debug);
ui->tableWidget_wifi->setCurrentCell(i, 0);
if (ui->tableWidget_wifi->currentItem() == 0)
errorWin->showWindow(18, QString(PDEBUG));
} else if (args[QString("open")].toString() != QString("PROFILE")) { } else if (args[QString("open")].toString() != QString("PROFILE")) {
ui->comboBox_profile->addItem(args[QString("open")].toString()); newProfileWidget->profileTabOpenProfileSlot(args[QString("open")].toString());
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
} else if (args[QString("select")].toString() != QString("PROFILE")) { } else if (args[QString("select")].toString() != QString("PROFILE")) {
for (int i=0; i<ui->tableWidget_main->rowCount(); i++) if (!mainWidget->mainTabSelectProfileSlot(args[QString("select")].toString()))
if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString()) ErrorWindow::showWindow(17, QString(PDEBUG), debug);
ui->tableWidget_main->setCurrentCell(i, 0);
if (ui->tableWidget_main->currentItem() == 0)
errorWin->showWindow(17, QString(PDEBUG));
} }
// show windows // show windows
@ -106,42 +104,34 @@ MainWindow::~MainWindow()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true"))) if (configuration[QString("CLOSE_HELPER")] == QString("true"))
forceStopHelper(); forceStopHelper();
deleteObjects(); deleteObjects();
delete ui;
} }
QStringList MainWindow::printInformation() int MainWindow::currentTab()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString profile; return ui->stackedWidget->currentIndex();
QString status; }
if (useHelper) {
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("Information"),
QList<QVariant>(), true, debug)[0].toStringList();
profile = request[0];
status = request[1];
} else {
if (netctlCommand->isNetctlAutoRunning()) {
profile = netctlCommand->autoGetActiveProfile();
status = QString("netctl-auto");
} else {
QStringList currentProfiles = netctlCommand->getActiveProfile();
profile = currentProfiles.join(QChar('|'));
QStringList statusList;
for (int i=0; i<currentProfiles.count(); i++)
statusList.append(netctlCommand->getProfileStatus(currentProfiles[i]));
status = statusList.join(QChar('|'));
}
}
QStringList output;
output.append(profile);
output.append(status);
return output;
Qt::ToolBarArea MainWindow::getToolBarArea()
{
if (debug) qDebug() << PDEBUG;
return toolBarArea(ui->toolBar);
}
void MainWindow::emitNeedToBeConfigured()
{
if (debug) qDebug() << PDEBUG;
emit(needToBeConfigured());
} }
@ -149,79 +139,15 @@ QStringList MainWindow::printSettings()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QStringList settingsList; return mapToList(configuration);
for (int i=0; i<configuration.keys().count(); i++)
settingsList.append(configuration.keys()[i] + QString("==") +
configuration[configuration.keys()[i]]);
return settingsList;
} }
QStringList MainWindow::printTrayInformation() netctlCurrent MainWindow::printTrayInformation()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QStringList information; return trayInformation(netctlInterface, useHelper, debug);
QString current;
QString enabled;
bool netctlAutoStatus = false;
QList<netctlProfileInfo> profiles;
if (useHelper) {
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
QList<QVariant>(), true, debug)[0].toString();
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool();
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true, debug), debug);
if (netctlAutoStatus) {
QList<QVariant> args;
args.append(current);
enabled = QString::number(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("autoIsProfileEnabled"),
args, true, debug)[0].toBool());
} else {
QStringList currentProfiles = current.split(QChar('|'));
QStringList enabledList;
for (int i=0; i<currentProfiles.count(); i++) {
QList<QVariant> args;
args.append(currentProfiles[i]);
enabledList.append(QString::number(
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
args, true, debug)[0].toBool()));
enabled = enabledList.join(QChar('|'));
}
}
} else {
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
if (netctlAutoStatus) {
current = netctlCommand->autoGetActiveProfile();
enabled = QString::number(netctlCommand->autoIsProfileEnabled(current));
profiles = netctlCommand->getProfileListFromNetctlAuto();
} else {
QStringList currentProfiles = netctlCommand->getActiveProfile();
current = currentProfiles.join(QChar('|'));
QStringList enabledList;
for (int i=0; i<currentProfiles.count(); i++)
enabledList.append(QString::number(netctlCommand->isProfileEnabled(currentProfiles[i])));
enabled = enabledList.join(QChar('|'));
profiles = netctlCommand->getProfileList();
}
}
information.append(QString::number(netctlAutoStatus));
QStringList profileList;
for (int i=0; i<profiles.count(); i++)
profileList.append(profiles[i].name);
information.append(profileList.join(QChar('|')));
information.append(current);
information.append(enabled);
return information;
} }
@ -229,9 +155,7 @@ bool MainWindow::isHelperActive()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, QList<QVariant> responce = sendRequestToCtrl(QString("Active"), debug);
DBUS_HELPER_INTERFACE, QString("Active"),
QList<QVariant>(), true, debug);
return (!responce.isEmpty()); return (!responce.isEmpty());
} }
@ -241,18 +165,15 @@ bool MainWindow::isHelperServiceActive()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QString cmd = configuration[QString("SYSTEMCTL_PATH")] + QString(" is-active ") + QString cmd = QString("%1 is-active %2").arg(configuration[QString("SYSTEMCTL_PATH")])
configuration[QString("HELPER_SERVICE")]; .arg(configuration[QString("HELPER_SERVICE")]);
if (debug) qDebug() << PDEBUG << "Run cmd" << cmd; if (debug) qDebug() << PDEBUG << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false); TaskResult process = runTask(cmd, false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0) if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode != 0) return (process.exitCode == 0);
return false;
else
return true;
} }
@ -260,61 +181,294 @@ void MainWindow::closeEvent(QCloseEvent *event)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if ((QSystemTrayIcon::isSystemTrayAvailable()) && if ((QSystemTrayIcon::isSystemTrayAvailable()) && (configuration[QString("SYSTRAY")] == QString("true"))) {
(configuration[QString("SYSTRAY")] == QString("true"))) {
hide(); hide();
trayIcon->showMessage(QApplication::translate("MainWindow", "Information"),
QApplication::translate("MainWindow", "Application has been hidden to tray"));
event->ignore(); event->ignore();
} else } else
closeMainWindow(); closeMainWindow();
} }
bool MainWindow::checkExternalApps(const QString apps = QString("all")) // tray icon
void MainWindow::closeMainWindow()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
QStringList cmd; storeToolBars();
cmd.append("which"); qApp->quit();
cmd.append(configuration[QString("SUDO_PATH")]); }
if ((apps == QString("helper")) || (apps == QString("all"))) {
cmd.append(configuration[QString("HELPER_PATH")]);
} void MainWindow::openProfileSlot(const QString profile)
if ((apps == QString("netctl")) || (apps == QString("all"))) { {
cmd.append(configuration[QString("NETCTL_PATH")]); if (debug) qDebug() << PDEBUG;
cmd.append(configuration[QString("NETCTLAUTO_PATH")]);
} newProfileWidget->profileTabOpenProfileSlot(profile);
if ((apps == QString("systemctl")) || (apps == QString("all"))) { }
cmd.append(configuration[QString("SYSTEMCTL_PATH")]);
}
if ((apps == QString("wpasup")) || (apps == QString("all"))) { void MainWindow::showAboutWindow()
cmd.append(configuration[QString("WPACLI_PATH")]); {
cmd.append(configuration[QString("WPASUP_PATH")]); 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;
} }
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd.join(QChar(' ')); QString cmd = QString("%1 -c %2").arg(configuration[QString("HELPER_PATH")]).arg(configPath);
TaskResult process = runTask(cmd.join(QChar(' ')), false); if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode; if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0) if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error; if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode != 0) return (process.exitCode == 0);
return false;
else
return true;
} }
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 QVariantMap args)
{
if (debug) qDebug() << PDEBUG;
deleteObjects();
QString actualConfigPath = QFile(configPath).exists() ? configPath : QString("/etc/netctl-gui.conf");
settingsWin = new SettingsWindow(this, debug, actualConfigPath);
if (args[QString("default")].toBool())
settingsWin->setDefault();
configuration = settingsWin->getSettings();
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(actualConfigPath, args[QString("options")].toString());
if (debug) qDebug() << PDEBUG << ":" << "Language is" << language;
qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
qApp->installTranslator(qtTranslator);
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() bool MainWindow::checkHelperStatus()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (useHelper) useHelper = isHelperActive(); if (useHelper) useHelper = isHelperActive();
if (useHelper) if (!useHelper) {
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, configuration[QString("CLOSE_HELPER")] = QString("false");
DBUS_HELPER_INTERFACE, QString("Update"),
QList<QVariant>(), true, debug);
else
configuration[QString("FORCE_SUDO")] = QString("true"); configuration[QString("FORCE_SUDO")] = QString("true");
configuration[QString("USE_HELPER")] = QString("false");
}
if (isHelperServiceActive()) if (isHelperServiceActive())
configuration[QString("CLOSE_HELPER")] = QString("false"); configuration[QString("CLOSE_HELPER")] = QString("false");
@ -322,74 +476,23 @@ bool MainWindow::checkHelperStatus()
} }
QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool)
return QApplication::translate("MainWindow", "yes");
if (nullFalse)
return QString("");
else
return QApplication::translate("MainWindow", "no");
}
// window signals
void MainWindow::createActions() void MainWindow::createActions()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int))); connect(ui->toolBar, SIGNAL(actionTriggered(QAction *)), this, SLOT(setTabByAction(QAction *)));
connect(ui->actionAbout, SIGNAL(triggered(bool)), this, SLOT(showAboutWindow())); connect(ui->actionNetctl_auto, SIGNAL(triggered()), this, SLOT(showNetctlAutoWindow()));
connect(ui->actionApi, SIGNAL(triggered(bool)), this, SLOT(showApi())); connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
connect(ui->actionLibrary, SIGNAL(triggered(bool)), this, SLOT(showLibrary())); connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow()));
connect(ui->actionNetctlAuto, SIGNAL(triggered(bool)), this, SLOT(showNetctlAutoWindow()));
connect(ui->actionReport, SIGNAL(triggered(bool)), this, SLOT(reportABug()));
connect(ui->actionSecurity, SIGNAL(triggered(bool)), this, SLOT(showSecurityNotes()));
connect(ui->actionSettings, SIGNAL(triggered(bool)), this, SLOT(showSettingsWindow()));
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(closeMainWindow()));
// actions menu // menu
connect(ui->menuActions, SIGNAL(aboutToShow()), this, SLOT(updateMenu())); connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettingsWindow()));
connect(ui->actionMainEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile())); connect(ui->actionSecurity, SIGNAL(triggered()), this, SLOT(showSecurityNotes()));
connect(ui->actionMainEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile())); connect(ui->actionDBus_API, SIGNAL(triggered()), this, SLOT(showApi()));
connect(ui->actionMainRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab())); connect(ui->actionLibrary, SIGNAL(triggered()), this, SLOT(showLibrary()));
connect(ui->actionMainRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile())); connect(ui->actionReport_a_bug, SIGNAL(triggered()), this, SLOT(reportABug()));
connect(ui->actionMainRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutWindow()));
connect(ui->actionMainStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile())); connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(closeMainWindow()));
connect(ui->actionMainStopAll, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
connect(ui->actionMainSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
connect(ui->actionProfileClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
connect(ui->actionProfileLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
connect(ui->actionProfileRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
connect(ui->actionProfileSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
connect(ui->actionWifiRefresh, SIGNAL(triggered(bool)), this, SLOT(updateWifiTab()));
connect(ui->actionWifiStart, SIGNAL(triggered(bool)), this, SLOT(wifiTabStart()));
// main tab events
connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab()));
connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile()));
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(mainTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
// profile tab events
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
connect(ui->pushButton_profileClear, SIGNAL(clicked(bool)), this, SLOT(profileTabClear()));
connect(ui->pushButton_profileSave, SIGNAL(clicked(bool)), this, SLOT(profileTabCreateProfile()));
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
// wifi tab events
connect(ui->pushButton_wifiRefresh, SIGNAL(clicked(bool)), this, SLOT(updateWifiTab()));
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
connect(ui->tableWidget_wifi, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(wifiTabContextualMenu(QPoint)));
} }
@ -415,55 +518,31 @@ void MainWindow::createObjects()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
// error messages
errorWin = new ErrorWindow(this, debug);
// backend // backend
createDBusSession(); createDBusSession();
if (useHelper) if ((useHelper) && (!forceStartHelper())) {
if (!forceStartHelper()) { ErrorWindow::showWindow(19, QString(PDEBUG), debug);
errorWin->showWindow(19, QString(PDEBUG));
useHelper = false; useHelper = false;
} }
checkHelperStatus(); checkHelperStatus();
netctlCommand = new Netctl(debug, configuration); netctlCommand = new Netctl(debug, configuration);
netctlProfile = new NetctlProfile(debug, configuration); netctlInterface = new NetctlInterface(debug, configuration);
wpaCommand = new WpaSup(debug, configuration); wpaCommand = new WpaSup(debug, configuration);
// frontend // frontend
trayIcon = new TrayIcon(this, debug); 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 // windows
ui = new Ui::MainWindow; ui->retranslateUi(this);
ui->setupUi(this); ui->stackedWidget->addWidget(mainWidget);
ui->tableWidget_main->setColumnHidden(2, true); ui->stackedWidget->addWidget(newProfileWidget);
ui->tableWidget_main->setColumnHidden(3, true); ui->stackedWidget->addWidget(wifiMenuWidget);
ui->tableWidget_wifi->setColumnHidden(3, true); updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("MAIN_TOOLBAR")].toInt()));
ui->tableWidget_wifi->setColumnHidden(4, true);
aboutWin = new AboutWindow(this, debug); aboutWin = new AboutWindow(this, debug);
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
settingsWin = new SettingsWindow(this, debug, configPath); settingsWin = new SettingsWindow(this, debug, configPath);
// profile widgets
generalWid = new GeneralWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
ipWid = new IpWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
bridgeWid = new BridgeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
ethernetWid = new EthernetWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
macvlanWid = new MacvlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
tuntapWid = new TuntapWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
vlanWid = new VlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
} }
@ -471,40 +550,22 @@ void MainWindow::deleteObjects()
{ {
if (debug) qDebug() << PDEBUG; 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().unregisterObject(DBUS_OBJECT_PATH);
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE); QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
if (netctlCommand != nullptr) delete netctlCommand; if (netctlCommand != nullptr) delete netctlCommand;
if (netctlProfile != nullptr) delete netctlProfile; if (netctlInterface != nullptr) delete netctlInterface;
if (wpaCommand != nullptr) delete wpaCommand; if (wpaCommand != nullptr) delete wpaCommand;
if (bridgeWid != nullptr) delete bridgeWid;
if (ethernetWid != nullptr) delete ethernetWid;
if (generalWid != nullptr) delete generalWid;
if (ipWid != nullptr) delete ipWid;
if (macvlanWid != nullptr) delete macvlanWid;
if (mobileWid != nullptr) delete mobileWid;
if (pppoeWid != nullptr) delete pppoeWid;
if (tunnelWid != nullptr) delete tunnelWid;
if (tuntapWid != nullptr) delete tuntapWid;
if (vlanWid != nullptr) delete vlanWid;
if (wirelessWid != nullptr) delete wirelessWid;
if (aboutWin != nullptr) delete aboutWin; if (aboutWin != nullptr) delete aboutWin;
if (errorWin != nullptr) delete errorWin;
if (netctlAutoWin != nullptr) delete netctlAutoWin;
if (settingsWin != nullptr) delete settingsWin; if (settingsWin != nullptr) delete settingsWin;
if (trayIcon != nullptr) delete trayIcon; if (trayIcon != nullptr) delete trayIcon;
if (ui != nullptr) delete ui; if (mainWidget != nullptr) delete mainWidget;
} if (netctlAutoWin != nullptr) delete netctlAutoWin;
if (newProfileWidget != nullptr) delete newProfileWidget;
if (wifiMenuWidget != nullptr) delete wifiMenuWidget;
void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Return)
if (ui->comboBox_profile->hasFocus())
profileTabLoadProfile();
} }
@ -514,12 +575,12 @@ QMap<QString, QString> MainWindow::parseOptions(const QString options)
QMap<QString, QString> settings; QMap<QString, QString> settings;
for (int i=0; i<options.split(QChar(',')).count(); i++) { for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2) continue; QStringList option = options.split(QChar(','))[i].split(QChar('='));
settings[options.split(QChar(','))[i].split(QChar('='))[0]] = if (option.count() != 2) continue;
options.split(QChar(','))[i].split(QChar('='))[1]; settings[option[0]] = option[1];
} }
for (int i=0; i<settings.keys().count(); i++) for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]]; if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]);
return settings; return settings;
} }

View File

@ -20,28 +20,18 @@
#include <QApplication> #include <QApplication>
#include <QMainWindow> #include <QMainWindow>
#include <QTableWidgetItem> #include <QTreeWidgetItem>
#include <netctlgui/netctlgui.h> #include <netctlgui/netctlgui.h>
class AboutWindow; class AboutWindow;
class BridgeWidget; class MainWidget;
class ErrorWindow;
class EthernetWidget;
class GeneralWidget;
class IpWidget;
class MacvlanWidget;
class MobileWidget;
class NetctlAutoWindow; class NetctlAutoWindow;
class PasswdWidget; class NewProfileWidget;
class PppoeWidget;
class SettingsWindow; class SettingsWindow;
class TrayIcon; class TrayIcon;
class TunnelWidget; class WiFiMenuWidget;
class TuntapWidget;
class VlanWidget;
class WirelessWidget;
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
@ -52,16 +42,22 @@ class MainWindow : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget *parent = 0, explicit MainWindow(QWidget *parent = nullptr,
const QMap<QString, QVariant> args = QMap<QString, QVariant>(), const QVariantMap args = QVariantMap(),
QTranslator *qtAppTranslator = 0, QTranslator *qtAppTranslator = nullptr,
QTranslator *appTranslator = 0); QTranslator *appTranslator = nullptr);
~MainWindow(); ~MainWindow();
QStringList printInformation(); int currentTab();
Qt::ToolBarArea getToolBarArea();
void emitNeedToBeConfigured();
QStringList printSettings(); QStringList printSettings();
QStringList printTrayInformation(); netctlCurrent printTrayInformation();
bool isHelperActive(); bool isHelperActive();
bool isHelperServiceActive(); bool isHelperServiceActive();
// library interfaces
Netctl *netctlCommand = nullptr;
NetctlInterface *netctlInterface = nullptr;
WpaSup *wpaCommand = nullptr;
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event);
@ -69,16 +65,11 @@ protected:
public slots: public slots:
// actions from trayicon // actions from trayicon
void closeMainWindow(); void closeMainWindow();
void openProfileSlot(const QString profile);
void showAboutWindow(); void showAboutWindow();
void showMainWindow(); void showMainWindow();
void showNetctlAutoWindow(); void showNetctlAutoWindow();
void showSettingsWindow(); void showSettingsWindow();
// trayicon control slots
bool enableProfileSlot(const QString profile);
bool startProfileSlot(const QString profile);
bool stopAllProfilesSlot();
bool switchToProfileSlot(const QString profile);
bool restartProfileSlot(const QString profile);
// open docs // open docs
void showApi(); void showApi();
void showLibrary(); void showLibrary();
@ -88,83 +79,38 @@ public slots:
bool forceStopHelper(); bool forceStopHelper();
bool startHelper(); bool startHelper();
// main // main
void setDisabled(const bool disabled = true);
void setTab(int tab); void setTab(int tab);
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>()); void showMessage(const bool status);
void updateMenu(); void storeToolBars();
void updateTabs(const int tab); void updateConfiguration(const QVariantMap args = QVariantMap());
// wifi tab slots void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
void connectToUnknownEssid(const QString passwd);
void setHiddenName(const QString name); signals:
void needToBeConfigured();
private slots: private slots:
void setTabByAction(QAction *action);
void reportABug(); void reportABug();
// menu update slots
void setMenuActionsShown(const bool state = true);
void updateMenuMain();
void updateMenuProfile();
void updateMenuWifi();
// tab update slots
void updateMainTab();
void updateProfileTab();
void updateWifiTab();
// main tab slots
void mainTabContextualMenu(const QPoint &pos);
void mainTabEditProfile();
void mainTabEnableProfile();
QStringList mainTabGetActiveProfiles();
void mainTabRemoveProfile();
void mainTabRestartProfile();
void mainTabStartProfile();
void mainTabStopAllProfiles();
void mainTabSwitchToProfile();
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// profile tab slots
void profileTabChangeState(const QString current);
void profileTabClear();
void profileTabCreateProfile();
void profileTabLoadProfile();
void profileTabRemoveProfile();
// wifi tab slots
void wifiTabContextualMenu(const QPoint &pos);
void wifiTabSetEnabled(const bool state);
void wifiTabStart();
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
private: private:
// ui // ui
TrayIcon *trayIcon = nullptr; TrayIcon *trayIcon = nullptr;
Ui::MainWindow *ui = nullptr; Ui::MainWindow *ui = nullptr;
AboutWindow *aboutWin = nullptr; AboutWindow *aboutWin = nullptr;
ErrorWindow *errorWin = nullptr; MainWidget *mainWidget = nullptr;
NetctlAutoWindow *netctlAutoWin = nullptr; NetctlAutoWindow *netctlAutoWin = nullptr;
PasswdWidget *passwdWid = nullptr; NewProfileWidget *newProfileWidget = nullptr;
SettingsWindow *settingsWin = nullptr; SettingsWindow *settingsWin = nullptr;
BridgeWidget *bridgeWid = nullptr; WiFiMenuWidget *wifiMenuWidget = nullptr;
EthernetWidget *ethernetWid = nullptr;
GeneralWidget *generalWid = nullptr;
IpWidget *ipWid = nullptr;
MacvlanWidget *macvlanWid = nullptr;
MobileWidget *mobileWid = nullptr;
PppoeWidget *pppoeWid = nullptr;
TunnelWidget *tunnelWid = nullptr;
TuntapWidget *tuntapWid = nullptr;
VlanWidget *vlanWid = nullptr;
WirelessWidget *wirelessWid = nullptr;
// backend // backend
Netctl *netctlCommand = nullptr;
NetctlProfile *netctlProfile = nullptr;
WpaSup *wpaCommand = nullptr;
bool checkExternalApps(const QString apps);
bool checkHelperStatus(); bool checkHelperStatus();
QString checkStatus(const bool statusBool, const bool nullFalse = false);
void createActions(); void createActions();
void createDBusSession(); void createDBusSession();
void createObjects(); void createObjects();
void deleteObjects(); void deleteObjects();
void keyPressEvent(QKeyEvent *pressedKey);
QString configPath; QString configPath;
bool debug = false; bool debug = false;
bool hiddenNetwork;
bool useHelper = true; bool useHelper = true;
QTranslator *qtTranslator = nullptr; QTranslator *qtTranslator = nullptr;
QTranslator *translator = nullptr; QTranslator *translator = nullptr;

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>469</width> <width>600</width>
<height>497</height> <height>497</height>
</rect> </rect>
</property> </property>
@ -14,414 +14,26 @@
<string>Netctl GUI</string> <string>Netctl GUI</string>
</property> </property>
<widget class="QWidget" name="centralWidget"> <widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="centralLayout">
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_main">
<attribute name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</attribute>
<attribute name="title">
<string>Connect to profile</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget_netctlAuto" native="true">
<layout class="QHBoxLayout" name="layout_netctlAuto">
<item>
<widget class="QLabel" name="label_netctlAuto">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text">
<string>netctl-auto is running</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAuto">
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_main">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<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>
<item>
<layout class="QHBoxLayout" name="layout_mainButtons">
<item>
<widget class="QPushButton" name="pushButton_mainRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainRestart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Restart</string>
</property>
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_new">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
</attribute>
<attribute name="title">
<string>Create a new profile</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="layout_profile">
<item>
<widget class="QLabel" name="label_profile">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_profile">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>338</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="scrollArea_layout"/>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_newProfileButtons">
<item>
<widget class="QPushButton" name="pushButton_profileClear">
<property name="text">
<string>Clear</string>
</property>
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_newProfileButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_profileSave">
<property name="text">
<string>Save</string>
</property>
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_wifi">
<attribute name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
</attribute>
<attribute name="title">
<string>Connect to Wi-Fi</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_wifi">
<property name="text">
<string>Please install 'wpa_supplicant' before using it</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_wifi">
<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>5</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>Signal</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wifiButtons">
<item>
<widget class="QPushButton" name="pushButton_wifiRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_wifiButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_wifiStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>469</width> <width>600</width>
<height>22</height> <height>22</height>
</rect> </rect>
</property> </property>
@ -429,47 +41,102 @@
<property name="title"> <property name="title">
<string>Menu</string> <string>Menu</string>
</property> </property>
<addaction name="actionNetctlAuto"/>
<addaction name="actionSettings"/> <addaction name="actionSettings"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuActions">
<property name="title">
<string>Actions</string>
</property>
<addaction name="actionMainRefresh"/>
<addaction name="actionWifiRefresh"/>
<addaction name="actionProfileClear"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionMainStart"/>
<addaction name="actionMainSwitch"/>
<addaction name="actionMainRestart"/>
<addaction name="actionMainEnable"/>
<addaction name="actionMainStopAll"/>
<addaction name="actionProfileLoad"/>
<addaction name="actionProfileSave"/>
<addaction name="actionWifiStart"/>
<addaction name="separator"/>
<addaction name="actionMainEdit"/>
<addaction name="actionMainRemove"/>
<addaction name="actionProfileRemove"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionSecurity"/> <addaction name="actionSecurity"/>
<addaction name="actionApi"/> <addaction name="actionDBus_API"/>
<addaction name="actionLibrary"/> <addaction name="actionLibrary"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionReport"/> <addaction name="actionReport_a_bug"/>
<addaction name="actionAbout"/> <addaction name="actionAbout"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget> </widget>
<addaction name="menuMenu"/> <addaction name="menuMenu"/>
<addaction name="menuActions"/>
<addaction name="menuHelp"/>
</widget> </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="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"> <action name="actionSettings">
<property name="icon"> <property name="icon">
<iconset theme="configure"> <iconset theme="configure">
@ -483,214 +150,55 @@
<string>Ctrl+S</string> <string>Ctrl+S</string>
</property> </property>
</action> </action>
<action name="actionQuit"> <action name="actionNetctl">
<property name="icon"> <property name="icon">
<iconset theme="exit"> <iconset resource="../../resources/resources.qrc">
<normaloff/> <normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Quit</string> <string>netctl control</string>
</property>
<property name="toolTip">
<string>netctl control</string>
</property> </property>
<property name="shortcut"> <property name="shortcut">
<string>Ctrl+Q</string> <string>Ctrl+N</string>
</property> </property>
</action> </action>
<action name="actionMainRefresh"> <action name="actionProfiles">
<property name="icon"> <property name="icon">
<iconset theme="stock-refresh"> <iconset theme="document-new">
<normaloff/> <normaloff/>
</iconset> </iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Refresh</string> <string>Profiles</string>
</property>
<property name="toolTip">
<string>Profiles</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property> </property>
</action> </action>
<action name="actionMainStart"> <action name="actionWiFi_menu">
<property name="icon"> <property name="icon">
<iconset theme="system-run"> <iconset resource="../../resources/resources.qrc">
<normaloff/> <normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Start profile</string> <string>WiFi menu</string>
</property>
<property name="shortcut">
<string>Ctrl+W</string>
</property> </property>
</action> </action>
<action name="actionMainRestart"> <action name="actionNetctl_auto">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Restart profile</string>
</property>
</action>
<action name="actionMainEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionMainEdit">
<property name="icon">
<iconset theme="edit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Edit profile</string>
</property>
</action>
<action name="actionMainRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionProfileClear">
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
</action>
<action name="actionWifiRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionProfileLoad">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Load profile</string>
</property>
</action>
<action name="actionProfileSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Save profile</string>
</property>
</action>
<action name="actionWifiStart">
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start Wi-Fi</string>
</property>
</action>
<action name="actionProfileRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionNetctlAuto">
<property name="text"> <property name="text">
<string>netctl-auto</string> <string>netctl-auto</string>
</property> </property>
</action> </action>
<action name="actionAbout">
<property name="icon">
<iconset theme="help-about">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>About</string>
</property>
</action>
<action name="actionReport">
<property name="icon">
<iconset theme="tools-report-bug">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Report a bug</string>
</property>
</action>
<action name="actionApi">
<property name="text">
<string>DBus API reference</string>
</property>
</action>
<action name="actionSecurity">
<property name="icon">
<iconset theme="security-medium">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Security notes</string>
</property>
</action>
<action name="actionLibrary">
<property name="text">
<string>Library documentation</string>
</property>
</action>
<action name="actionMainSwitch">
<property name="icon">
<iconset theme="system-run"/>
</property>
<property name="text">
<string>Switch to profile</string>
</property>
</action>
<action name="actionMainStopAll">
<property name="icon">
<iconset theme="process-stop"/>
</property>
<property name="text">
<string>Stop all profiles</string>
</property>
</action>
</widget> </widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>tableWidget_main</tabstop>
<tabstop>pushButton_mainRefresh</tabstop>
<tabstop>pushButton_mainRestart</tabstop>
<tabstop>pushButton_mainStart</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>pushButton_profileClear</tabstop>
<tabstop>pushButton_profileSave</tabstop>
<tabstop>tableWidget_wifi</tabstop>
<tabstop>pushButton_wifiRefresh</tabstop>
<tabstop>pushButton_wifiStart</tabstop>
</tabstops>
<resources> <resources>
<include location="../../resources/resources.qrc"/> <include location="../../resources/resources.qrc"/>
</resources> </resources>

View File

@ -25,18 +25,16 @@
QString errorMessage() QString errorMessage()
{ {
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n"); return QApplication::translate("MainWindow", "Unknown flag\n");
return errorMessage;
} }
QMap<QString, QVariant> getArgs() QVariantMap getArgs()
{ {
QMap<QString, QVariant> args; QVariantMap args;
// windows // windows
args[QString("detached")] = false; args[QString("detached")] = false;
args[QString("minimized")] = (int) 0; args[QString("minimized")] = static_cast<int>(0);
args[QString("about")] = false; args[QString("about")] = false;
args[QString("auto")] = false; args[QString("auto")] = false;
args[QString("settings")] = false; args[QString("settings")] = false;
@ -45,11 +43,11 @@ QMap<QString, QVariant> getArgs()
args[QString("open")] = QString("PROFILE"); args[QString("open")] = QString("PROFILE");
args[QString("select")] = QString("PROFILE"); args[QString("select")] = QString("PROFILE");
// additional functions // additional functions
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf")); args[QString("config")] = QString("%1/.config/netctl-gui.conf").arg(QDir::homePath());
args[QString("debug")] = false; args[QString("debug")] = false;
args[QString("defaults")] = false; args[QString("defaults")] = false;
args[QString("options")] = QString("OPTIONS"); args[QString("options")] = QString("OPTIONS");
args[QString("tab")] = (int) 1; args[QString("tab")] = static_cast<int>(1);
// messages // messages
args[QString("error")] = false; args[QString("error")] = false;
args[QString("help")] = false; args[QString("help")] = false;
@ -68,46 +66,29 @@ QString helpMessage()
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:")); helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
// windows // windows
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString(" --detached - %1\n") helpMessage += QString(" --detached - %1\n").arg(QApplication::translate("MainWindow", "start detached from console"));
.arg(QApplication::translate("MainWindow", "start detached from console")); helpMessage += QString(" --maximized - %1\n").arg(QApplication::translate("MainWindow", "start maximized"));
helpMessage += QString(" --maximized - %1\n") helpMessage += QString(" --minimized - %1\n").arg(QApplication::translate("MainWindow", "start minimized to tray"));
.arg(QApplication::translate("MainWindow", "start maximized")); helpMessage += QString(" --about - %1\n").arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString(" --minimized - %1\n") helpMessage += QString(" --netctl-auto - %1\n").arg(QApplication::translate("MainWindow", "show netctl-auto window"));
.arg(QApplication::translate("MainWindow", "start minimized to tray")); helpMessage += QString(" --settings - %1\n").arg(QApplication::translate("MainWindow", "show settings window"));
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 // main functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e, --essid <arg> - %1\n") helpMessage += QString(" -e, --essid <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this ESSID"));
.arg(QApplication::translate("MainWindow", "select this ESSID")); helpMessage += QString(" -o, --open <arg> - %1\n").arg(QApplication::translate("MainWindow", "open this profile"));
helpMessage += QString(" -o, --open <arg> - %1\n") helpMessage += QString(" -s, --select <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this profile"));
.arg(QApplication::translate("MainWindow", "open this profile"));
helpMessage += QString(" -s, --select <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "select this profile"));
// additional functions // additional functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" -c, --config <arg> - %1\n") helpMessage += QString(" -c, --config <arg> - %1\n").arg(QApplication::translate("MainWindow", "read configuration from this file"));
.arg(QApplication::translate("MainWindow", "read configuration from this file")); helpMessage += QString(" -d, --debug - %1\n").arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString(" -d, --debug - %1\n") helpMessage += QString(" --default - %1\n").arg(QApplication::translate("MainWindow", "start with default settings"));
.arg(QApplication::translate("MainWindow", "print debug information")); helpMessage += QString(" --set-opts <arg> - %1\n").arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" --default - %1\n") helpMessage += QString(" -t, --tab <arg> - %1\n").arg(QApplication::translate("MainWindow", "open a tab with this number"));
.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 // messages
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:")); helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v, --version - %1\n") helpMessage += QString(" -v, --version - %1\n").arg(QApplication::translate("MainWindow", "show version and exit"));
.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(" -i, --info - %1\n") helpMessage += QString(" -h, --help - %1\n").arg(QApplication::translate("MainWindow", "show this help and exit"));
.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; return helpMessage;
} }
@ -117,19 +98,33 @@ QString infoMessage()
{ {
QString infoMessage = QString(""); QString infoMessage = QString("");
// build information // build information
infoMessage += QCoreApplication::translate("MainWindow", "Build date: %1"). infoMessage += QApplication::translate("MainWindow", "Build date: %1").arg(QString(BUILD_DATE));
arg(QString(BUILD_DATE)); // cmake
infoMessage += QString("\n%1:\n").arg(QCoreApplication::translate("MainWindow", "cmake flags")); infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE)); // cmake properties
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX)); infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "cmake properties"));
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS)); infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1\n").arg(QString(CMAKE_BUILD_TYPE));
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY)); infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1\n").arg(QString(CMAKE_INSTALL_PREFIX));
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI)); // components
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5)); 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_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)); 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 // transport information
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("MainWindow", "DBus configuration")); infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE)); infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE)); 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_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
@ -138,11 +133,8 @@ QString infoMessage()
infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH)); infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH));
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH)); infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
// docs path // docs path
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("MainWindow", "Documentation")); infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Documentation"));
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH)); infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
QStringList docs = QDir(QString(DOCS_PATH)).entryList(QDir::NoDotAndDotDot);
for (int i=0; i<docs.count(); i++)
infoMessage += QString("\t%1\n").arg(docs[i]);
return infoMessage; return infoMessage;
} }
@ -152,15 +144,9 @@ QString versionMessage()
{ {
QString versionMessage = QString(""); QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME)); versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n") versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Version")).arg(QString(VERSION));
.arg(QApplication::translate("MainWindow", "Version")) versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "Author")).arg(QString(AUTHOR));
.arg(QString(VERSION)); versionMessage += QString("%1 : %2\n").arg(QApplication::translate("MainWindow", "License")).arg(QString(LICENSE));
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; return versionMessage;
} }

View File

@ -25,7 +25,7 @@
QString errorMessage(); QString errorMessage();
QMap<QString, QVariant> getArgs(); QVariantMap getArgs();
QString helpMessage(); QString helpMessage();
QString infoMessage(); QString infoMessage();
QString versionMessage(); QString versionMessage();

View File

@ -46,9 +46,11 @@ void MobileWidget::clear()
ui->lineEdit_apn->clear(); ui->lineEdit_apn->clear();
ui->lineEdit_pin->clear(); ui->lineEdit_pin->clear();
ui->comboBox_mode->setCurrentIndex(0); ui->comboBox_mode->setCurrentIndex(0);
ui->spinBox_fail->setValue(5);
ui->checkBox_route->setCheckState(Qt::Checked); ui->checkBox_route->setCheckState(Qt::Checked);
ui->checkBox_dns->setCheckState(Qt::Checked); ui->checkBox_dns->setCheckState(Qt::Checked);
ui->lineEdit_init->setText(QString("ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"));
ui->spinBox_fail->setValue(5);
ui->lineEdit_chat->clear();
ui->lineEdit_options->clear(); ui->lineEdit_options->clear();
ui->pushButton_mobileAdvanced->setChecked(false);; ui->pushButton_mobileAdvanced->setChecked(false);;
@ -56,26 +58,28 @@ void MobileWidget::clear()
} }
void MobileWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MobileWidget::createActions() void MobileWidget::createActions()
{ {
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced())); connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_chat, SIGNAL(clicked(bool)), this, SLOT(selectChatFile()));
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile())); connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
} }
void MobileWidget::selectChatFile()
{
QString filename = QFileDialog::getOpenFileName(this,
QApplication::translate("MobileWidget", "Select chat file"),
QDir::currentPath(),
QApplication::translate("MobileWidget", "All (*.*)"));
if (!filename.isEmpty())
ui->lineEdit_chat->setText(filename);
}
void MobileWidget::selectOptionsFile() void MobileWidget::selectOptionsFile()
{ {
QString filename = QFileDialog::getOpenFileName( QString filename = QFileDialog::getOpenFileName(this,
this,
QApplication::translate("MobileWidget", "Select options file"), QApplication::translate("MobileWidget", "Select options file"),
QDir::currentPath(), QDir::currentPath(),
QApplication::translate("MobileWidget", "Configuration files (*.conf)")); QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
@ -88,53 +92,54 @@ void MobileWidget::showAdvanced()
{ {
if (ui->pushButton_mobileAdvanced->isChecked()) { if (ui->pushButton_mobileAdvanced->isChecked()) {
ui->widget_mobileAdvanced->setHidden(false); ui->widget_mobileAdvanced->setHidden(false);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced")); ui->pushButton_mobileAdvanced->setArrowType(Qt::UpArrow);
} else { } else {
ui->widget_mobileAdvanced->setHidden(true); ui->widget_mobileAdvanced->setHidden(true);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced")); ui->pushButton_mobileAdvanced->setArrowType(Qt::DownArrow);
} }
} }
QMap<QString, QString> MobileWidget::getSettings() QMap<QString, QString> MobileWidget::getSettings()
{ {
QMap<QString, QString> mobileSettings; QMap<QString, QString> settings;
if (isOk() != 0) if (isOk() != 0) return settings;
return mobileSettings;
if (!ui->lineEdit_username->text().isEmpty()) if (!ui->lineEdit_username->text().isEmpty())
mobileSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'"); settings[QString("User")] = QString("'%1'").arg(ui->lineEdit_username->text());
if (!ui->lineEdit_password->text().isEmpty()) if (!ui->lineEdit_password->text().isEmpty())
mobileSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'"); settings[QString("Password")] = QString("'%1'").arg(ui->lineEdit_password->text());
mobileSettings[QString("AccessPointName")] = ui->lineEdit_apn->text(); settings[QString("AccessPointName")] = ui->lineEdit_apn->text();
if (!ui->lineEdit_pin->text().isEmpty()) if (!ui->lineEdit_pin->text().isEmpty())
mobileSettings[QString("PIN")] = QString("'") + ui->lineEdit_pin->text() + QString("'"); settings[QString("PIN")] = QString("'%1'").arg(ui->lineEdit_pin->text());
else else
mobileSettings[QString("PIN")] = QString("None"); settings[QString("PIN")] = QString("None");
mobileSettings[QString("Mode")] = ui->comboBox_mode->currentText(); settings[QString("Mode")] = ui->comboBox_mode->currentText();
if (ui->spinBox_fail->value() != 5)
mobileSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
if (ui->checkBox_route->checkState() == Qt::Unchecked) if (ui->checkBox_route->checkState() == Qt::Unchecked)
mobileSettings[QString("DefaultRoute")] = QString("false"); settings[QString("DefaultRoute")] = QString("false");
if (ui->checkBox_dns->checkState() == Qt::Unchecked) if (ui->checkBox_dns->checkState() == Qt::Unchecked)
mobileSettings[QString("UsePeerDNS")] = QString("false"); settings[QString("UsePeerDNS")] = QString("false");
if (ui->lineEdit_init->text() != QString("ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"))
settings[QString("Init")] = QString("'%1'").arg(ui->lineEdit_init->text());
if (ui->spinBox_fail->value() != 5)
settings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
if (!ui->lineEdit_chat->text().isEmpty())
settings[QString("ChatScript")] = QString("'%1'").arg(ui->lineEdit_chat->text());
if (!ui->lineEdit_options->text().isEmpty()) if (!ui->lineEdit_options->text().isEmpty())
mobileSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'"); settings[QString("OptionsFile")] = QString("'%1'").arg(ui->lineEdit_options->text());
return mobileSettings; return settings;
} }
int MobileWidget::isOk() int MobileWidget::isOk()
{ {
// APN is not set // APN is not set
if (ui->lineEdit_apn->text().isEmpty()) if (ui->lineEdit_apn->text().isEmpty()) return 1;
return 1;
// config file doesn't exist // config file doesn't exist
if (!ui->lineEdit_options->text().isEmpty()) if (!ui->lineEdit_options->text().isEmpty())
if (!QFile(ui->lineEdit_options->text()).exists()) if (!QFile(ui->lineEdit_options->text()).exists()) return 2;
return 2;
// all fine // all fine
return 0; return 0;
} }
@ -143,28 +148,31 @@ int MobileWidget::isOk()
void MobileWidget::setSettings(const QMap<QString, QString> settings) void MobileWidget::setSettings(const QMap<QString, QString> settings)
{ {
clear(); clear();
QMap<QString, QString> mobileSettings = settings;
if (mobileSettings.contains(QString("User"))) if (settings.contains(QString("User")))
ui->lineEdit_username->setText(mobileSettings[QString("User")]); ui->lineEdit_username->setText(settings[QString("User")]);
if (mobileSettings.contains(QString("Password"))) if (settings.contains(QString("Password")))
ui->lineEdit_password->setText(mobileSettings[QString("Password")]); ui->lineEdit_password->setText(settings[QString("Password")]);
if (mobileSettings.contains(QString("AccessPointName"))) if (settings.contains(QString("AccessPointName")))
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")]); ui->lineEdit_apn->setText(settings[QString("AccessPointName")]);
if (mobileSettings.contains(QString("PIN"))) if (settings.contains(QString("PIN")))
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")]); ui->lineEdit_pin->setText(settings[QString("PIN")]);
if (mobileSettings.contains(QString("Mode"))) if (settings.contains(QString("Mode"))) {
for (int i=0; i<ui->comboBox_mode->count(); i++) int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
if (mobileSettings[QString("Mode")] == ui->comboBox_mode->itemText(i)) ui->comboBox_mode->setCurrentIndex(index);
ui->comboBox_mode->setCurrentIndex(i); }
if (mobileSettings.contains(QString("MaxFail"))) if (settings.contains(QString("DefaultRoute")))
ui->spinBox_fail->setValue(mobileSettings[QString("MaxFail")].toInt()); if (settings[QString("DefaultRoute")] == QString("false"))
if (mobileSettings.contains(QString("DefaultRoute")))
if (mobileSettings[QString("DefaultRoute")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked); ui->checkBox_route->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("UsePeerDNS"))) if (settings.contains(QString("UsePeerDNS")))
if (mobileSettings[QString("UsePeerDNS")] == QString("false")) if (settings[QString("UsePeerDNS")] == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked); ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("OptionsFile"))) if (settings.contains(QString("Init")))
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")]); ui->lineEdit_init->setText(settings[QString("Init")]);
if (settings.contains(QString("MaxFail")))
ui->spinBox_fail->setValue(settings[QString("MaxFail")].toInt());
if (settings.contains(QString("ChatScript")))
ui->lineEdit_chat->setText(settings[QString("ChatScript")]);
if (settings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(settings[QString("OptionsFile")]);
} }

View File

@ -38,9 +38,9 @@ public:
public slots: public slots:
void clear(); void clear();
void setShown(const bool state);
private slots: private slots:
void selectChatFile();
void selectOptionsFile(); void selectOptionsFile();
void showAdvanced(); void showAdvanced();

View File

@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>445</width> <width>445</width>
<height>370</height> <height>376</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QDockWidget" name="dockWidget_mobile"> <widget class="QDockWidget" name="dockWidget_mobile">
<property name="features"> <property name="features">
@ -24,23 +24,35 @@
</property> </property>
<widget class="QWidget" name="dockWidgetContents_mobile"> <widget class="QWidget" name="dockWidgetContents_mobile">
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<layout class="QHBoxLayout" name="layout_username"> <layout class="QHBoxLayout" name="layout_username">
<item> <item>
<widget class="QLabel" name="label_username"> <widget class="QLabel" name="label_username">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Username</string> <string>Username</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_username"> <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"> <property name="toolTip">
<string>The username and password to connect with</string> <string>The username and password to connect with</string>
</property> </property>
@ -52,19 +64,28 @@
<layout class="QHBoxLayout" name="layout_password"> <layout class="QHBoxLayout" name="layout_password">
<item> <item>
<widget class="QLabel" name="label_password"> <widget class="QLabel" name="label_password">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Password</string> <string>Password</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_password"> <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"> <property name="toolTip">
<string>The username and password to connect with</string> <string>The username and password to connect with</string>
</property> </property>
@ -76,19 +97,28 @@
<layout class="QHBoxLayout" name="layout_apn"> <layout class="QHBoxLayout" name="layout_apn">
<item> <item>
<widget class="QLabel" name="label_apn"> <widget class="QLabel" name="label_apn">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Access point name</string> <string>Access point name</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_apn"> <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"> <property name="toolTip">
<string>The access point (apn) to connect on</string> <string>The access point (apn) to connect on</string>
</property> </property>
@ -100,19 +130,28 @@
<layout class="QHBoxLayout" name="layout_pin"> <layout class="QHBoxLayout" name="layout_pin">
<item> <item>
<widget class="QLabel" name="label_pin"> <widget class="QLabel" name="label_pin">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>PIN</string> <string>PIN</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_pin"> <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"> <property name="toolTip">
<string>If your modem requires a PIN to unlock, use this option</string> <string>If your modem requires a PIN to unlock, use this option</string>
</property> </property>
@ -124,19 +163,28 @@
<layout class="QHBoxLayout" name="layout_mode"> <layout class="QHBoxLayout" name="layout_mode">
<item> <item>
<widget class="QLabel" name="label_mode"> <widget class="QLabel" name="label_mode">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Mode</string> <string>Mode</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboBox_mode"> <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"> <property name="toolTip">
<string>This option is used to specify the connection mode</string> <string>This option is used to specify the connection mode</string>
</property> </property>
@ -172,26 +220,23 @@
<item> <item>
<layout class="QHBoxLayout" name="layout_mobileAdvanced"> <layout class="QHBoxLayout" name="layout_mobileAdvanced">
<item> <item>
<spacer name="spacer_mobileAdvanced"> <widget class="Line" name="line">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_mobileAdvanced"> <widget class="QToolButton" name="pushButton_mobileAdvanced">
<property name="text">
<string>Show advanced</string>
</property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
<property name="arrowType">
<enum>Qt::DownArrow</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -199,23 +244,134 @@
<item> <item>
<widget class="QWidget" name="widget_mobileAdvanced" native="true"> <widget class="QWidget" name="widget_mobileAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2"> <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_init">
<item>
<widget class="QLabel" name="label_init">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Init</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_init">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>An initialization string sent to the modem before dialing</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="layout_fail"> <layout class="QHBoxLayout" name="layout_fail">
<item> <item>
<widget class="QLabel" name="label_fail"> <widget class="QLabel" name="label_fail">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>1</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Max fail</string> <string>Max fail</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSpinBox" name="spinBox_fail"> <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"> <property name="toolTip">
<string>The number of consecutive failed connection attempts to tolerate</string> <string>The number of consecutive failed connection attempts to tolerate</string>
</property> </property>
@ -230,48 +386,77 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_route"> <layout class="QHBoxLayout" name="layout_chat">
<property name="toolTip"> <item>
<string>Use the default route provided by the peer</string> <widget class="QLabel" name="label_chat">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>7</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Default route</string> <string>Chat script</string>
</property> </property>
<property name="checked"> <property name="alignment">
<bool>true</bool> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_dns"> <widget class="QLineEdit" name="lineEdit_chat">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>10</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Use the DNS provided by the peer</string> <string>Path to a chat file</string>
</property>
<property name="text">
<string>Use peer DNS</string>
</property>
<property name="checked">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="pushButton_chat">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>4</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="layout_options"> <layout class="QHBoxLayout" name="layout_options">
<item> <item>
<widget class="QLabel" name="label_options"> <widget class="QLabel" name="label_options">
<property name="minimumSize"> <property name="sizePolicy">
<size> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<width>150</width> <horstretch>7</horstretch>
<height>0</height> <verstretch>0</verstretch>
</size> </sizepolicy>
</property> </property>
<property name="text"> <property name="text">
<string>Options file</string> <string>Options file</string>
</property> </property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="lineEdit_options"> <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"> <property name="toolTip">
<string>A file to read additional pppd options from</string> <string>A file to read additional pppd options from</string>
</property> </property>
@ -279,6 +464,12 @@
</item> </item>
<item> <item>
<widget class="QPushButton" name="pushButton_options"> <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"> <property name="text">
<string>Browse</string> <string>Browse</string>
</property> </property>
@ -301,10 +492,7 @@
<tabstop>lineEdit_apn</tabstop> <tabstop>lineEdit_apn</tabstop>
<tabstop>lineEdit_pin</tabstop> <tabstop>lineEdit_pin</tabstop>
<tabstop>comboBox_mode</tabstop> <tabstop>comboBox_mode</tabstop>
<tabstop>pushButton_mobileAdvanced</tabstop>
<tabstop>spinBox_fail</tabstop> <tabstop>spinBox_fail</tabstop>
<tabstop>checkBox_route</tabstop>
<tabstop>checkBox_dns</tabstop>
<tabstop>lineEdit_options</tabstop> <tabstop>lineEdit_options</tabstop>
<tabstop>pushButton_options</tabstop> <tabstop>pushButton_options</tabstop>
</tabstops> </tabstops>

View File

@ -20,26 +20,29 @@
#include <QDebug> #include <QDebug>
#include <netctlgui/netctlgui.h> #include <pdebug/pdebug.h>
#include "calls.h"
#include "commonfunctions.h"
#include "dbusoperation.h" #include "dbusoperation.h"
#include "pdebug.h" #include "errorwindow.h"
#include "version.h" #include "mainwindow.h"
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings) NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
: QMainWindow(parent), : QMainWindow(parent),
ui(new Ui::NetctlAutoWindow), debug(debugCmd),
debug(debugCmd) configuration(settings)
{ {
if (settings[QString("USE_HELPER")] == QString("true")) mainWindow = dynamic_cast<MainWindow *>(parent);
useHelper = true; useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
else
useHelper = false; // ui
ui = new Ui::NetctlAutoWindow;
ui->setupUi(this); ui->setupUi(this);
ui->tableWidget->setColumnHidden(2, true); ui->tableWidget->setColumnHidden(2, true);
ui->tableWidget->setColumnHidden(3, true); ui->tableWidget->setColumnHidden(3, true);
netctlCommand = new Netctl(debug, settings); updateToolBarState(static_cast<Qt::ToolBarArea>(settings[QString("NETCTLAUTO_TOOLBAR")].toInt()));
createActions(); createActions();
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready")); ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
@ -51,22 +54,14 @@ NetctlAutoWindow::~NetctlAutoWindow()
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
delete ui; delete ui;
delete netctlCommand;
} }
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse) Qt::ToolBarArea NetctlAutoWindow::getToolBarArea()
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool) return toolBarArea(ui->toolBar);
return QApplication::translate("NetctlAutoWindow", "yes");
if (nullFalse)
return QString("");
else
return QApplication::translate("NetctlAutoWindow", "no");
} }
@ -78,9 +73,9 @@ void NetctlAutoWindow::createActions()
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close())); connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles())); connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile())); connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\ connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile())); connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
// service // service
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService())); connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService())); connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService()));
@ -90,11 +85,17 @@ void NetctlAutoWindow::createActions()
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile())); 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(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint))); connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
}
// buttons
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile())); void NetctlAutoWindow::showMessage(const bool status)
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable())); {
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile())); if (debug) qDebug() << PDEBUG;
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
} }
@ -108,12 +109,24 @@ void NetctlAutoWindow::showWindow()
} }
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) void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{ {
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0) if (ui->tableWidget->currentItem() == nullptr) return;
return;
// create menu // create menu
QMenu menu(this); QMenu menu(this);
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile")); QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
@ -121,25 +134,19 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile")); QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
menu.addSeparator(); menu.addSeparator();
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles")); QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add")); enableAllProfiles->setIcon(QIcon::fromTheme("list-add"));
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles")); QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete")); disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
// set text // set text
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) { startProfile->setVisible(ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty());
enableProfile->setVisible(false);
startProfile->setVisible(false);
} else {
enableProfile->setVisible(true);
startProfile->setVisible(true);
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) { if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
} else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable")); enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("list-add"));
} else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete")); enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
} }
}
// actions // actions
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos)); QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
@ -162,88 +169,74 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
void NetctlAutoWindow::netctlAutoUpdateTable() void NetctlAutoWindow::netctlAutoUpdateTable()
{ {
if (debug) qDebug() << PDEBUG; 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); ui->tableWidget->setDisabled(true);
netctlInformation info = generalInformation(mainWindow->netctlInterface,
useHelper, debug);
// actions // actions
bool enabled = false; ui->actionDisableAll->setEnabled(info.netctlAuto);
bool running = false; ui->actionEnableAll->setEnabled(info.netctlAuto);
if (useHelper) { ui->actionRestartService->setEnabled(info.netctlAuto);
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH, if (info.netctlAutoEnabled)
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
QList<QVariant>(), true, debug)[0].toBool();
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool();
} else {
enabled = netctlCommand->isNetctlAutoEnabled();
running = netctlCommand->isNetctlAutoRunning();
}
if (enabled)
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service")); ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service")); ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true); if (info.netctlAuto) {
if (running) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running")); ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service")); ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionDisableAll->setVisible(true);
ui->actionEnableAll->setVisible(true);
ui->actionRestartService->setVisible(true);
} else { } else {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running")); ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service")); ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionDisableAll->setVisible(false); netctlAutoRefreshButtons(nullptr, nullptr);
ui->actionEnableAll->setVisible(false);
ui->actionRestartService->setVisible(false);
netctlAutoRefreshButtons(0, 0);
return; return;
} }
QList<netctlProfileInfo> profiles;
if (useHelper)
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true, debug), debug);
else
profiles = netctlCommand->getProfileListFromNetctlAuto();
ui->tableWidget->setSortingEnabled(false); ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1); ui->tableWidget->selectRow(-1);
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder); ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget->clear(); ui->tableWidget->clear();
ui->tableWidget->setRowCount(profiles.count()); ui->tableWidget->setRowCount(info.netctlAutoProfiles.count());
// create header // create header
QStringList headerList; QStringList headerList;
headerList.append(QApplication::translate("NetctlAutoWindow", "Name")); headerList.append(QApplication::translate("NetctlAutoWindow", "Name"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Description")); headerList.append(QApplication::translate("NetctlAutoWindow", "Description"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Active")); headerList.append(QApplication::translate("NetctlAutoWindow", "Active"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled")); headerList.append(QApplication::translate("NetctlAutoWindow", "Enabled"));
ui->tableWidget->setHorizontalHeaderLabels(headerList); ui->tableWidget->setHorizontalHeaderLabels(headerList);
// create items // create items
for (int i=0; i<profiles.count(); i++) { for (int i=0; i<info.netctlAutoProfiles.count(); i++) {
// font // font
QFont font; QFont font;
font.setBold(profiles[i].active); font.setBold(info.netctlAutoProfiles[i].active);
font.setItalic(profiles[i].enabled); font.setItalic(info.netctlAutoProfiles[i].enabled);
// tooltip // tooltip
QString toolTip = QString(""); QString toolTip = QString("");
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name); toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile"))
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active)); .arg(info.netctlAutoProfiles[i].name);
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled)); 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 // name
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].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)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableWidget->item(i, 0)->setToolTip(toolTip); ui->tableWidget->item(i, 0)->setToolTip(toolTip);
ui->tableWidget->item(i, 0)->setFont(font); ui->tableWidget->item(i, 0)->setFont(font);
// description // description
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].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)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
ui->tableWidget->item(i, 1)->setToolTip(toolTip); ui->tableWidget->item(i, 1)->setToolTip(toolTip);
// active // active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true))); ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(info.netctlAutoProfiles[i].active, true)));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
// enabled // enabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true))); 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->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
} }
@ -258,10 +251,11 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#endif #endif
ui->tableWidget->setEnabled(true); ui->tableWidget->setCurrentCell(-1, -1);
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated")); ui->tableWidget->setDisabled(false);
showMessage(true);
netctlAutoRefreshButtons(0, 0); netctlAutoRefreshButtons(nullptr, nullptr);
update(); update();
} }
@ -269,19 +263,21 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
void NetctlAutoWindow::netctlAutoDisableAllProfiles() void NetctlAutoWindow::netctlAutoDisableAllProfiles()
{ {
if (debug) qDebug() << PDEBUG; 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); ui->tableWidget->setDisabled(true);
bool status = false; bool responce = false;
if (useHelper) if (!useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = mainWindow->netctlCommand->autoDisableAllProfiles();
DBUS_HELPER_INTERFACE, QString("autoDisableAll"), else try {
QList<QVariant>(), true, debug)[0].toBool(); responce = sendRequestToCtrl(QString("autoDisableAll"), debug)[0].toBool();
else } catch (...) {
status = netctlCommand->autoDisableAllProfiles(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
if (status) }
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done")); showMessage(responce);
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -290,24 +286,25 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
void NetctlAutoWindow::netctlAutoEnableProfile() void NetctlAutoWindow::netctlAutoEnableProfile()
{ {
if (debug) qDebug() << PDEBUG; 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;
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true); ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text(); QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
bool status = false; bool responce = false;
if (useHelper) { if (!useHelper)
responce = mainWindow->netctlCommand->autoEnableProfile(profile);
else try {
QList<QVariant> args; QList<QVariant> args;
args.append(profile); args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = sendRequestToCtrlWithArgs(QString("autoEnable"), args, debug)[0].toBool();
DBUS_HELPER_INTERFACE, QString("autoEnable"), } catch (...) {
args, true, debug)[0].toBool(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
} else }
status = netctlCommand->autoEnableProfile(profile); showMessage(responce);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -316,19 +313,21 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
void NetctlAutoWindow::netctlAutoEnableAllProfiles() void NetctlAutoWindow::netctlAutoEnableAllProfiles()
{ {
if (debug) qDebug() << PDEBUG; 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); ui->tableWidget->setDisabled(true);
bool status = false; bool responce = false;
if (useHelper) if (!useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = mainWindow->netctlCommand->autoEnableAllProfiles();
DBUS_HELPER_INTERFACE, QString("autoEnableAll"), else try {
QList<QVariant>(), true, debug)[0].toBool(); responce = sendRequestToCtrl(QString("autoEnableAll"), debug)[0].toBool();
else } catch (...) {
status = netctlCommand->autoEnableAllProfiles(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
if (status) }
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done")); showMessage(responce);
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -337,24 +336,25 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
void NetctlAutoWindow::netctlAutoStartProfile() void NetctlAutoWindow::netctlAutoStartProfile()
{ {
if (debug) qDebug() << PDEBUG; 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;
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true); ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text(); QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
bool status = false; bool responce = false;
if (useHelper) { if (!useHelper)
responce = mainWindow->netctlCommand->autoStartProfile(profile);
else try {
QList<QVariant> args; QList<QVariant> args;
args.append(profile); args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = sendRequestToCtrlWithArgs(QString("autoStart"), args, debug)[0].toBool();
DBUS_HELPER_INTERFACE, QString("autoStart"), } catch (...) {
args, true, debug)[0].toBool(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
} else }
status = netctlCommand->autoStartProfile(profile); showMessage(responce);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -363,18 +363,20 @@ void NetctlAutoWindow::netctlAutoStartProfile()
void NetctlAutoWindow::netctlAutoEnableService() void NetctlAutoWindow::netctlAutoEnableService()
{ {
if (debug) qDebug() << PDEBUG; 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 status = false; bool responce = false;
if (useHelper) if (!useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = mainWindow->netctlCommand->autoEnableService();
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"), else try {
QList<QVariant>(), true, debug)[0].toBool(); responce = sendRequestToCtrl(QString("autoServiceEnable"), debug)[0].toBool();
else } catch (...) {
status = netctlCommand->autoEnableService(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
if (status) }
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done")); showMessage(responce);
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -383,18 +385,20 @@ void NetctlAutoWindow::netctlAutoEnableService()
void NetctlAutoWindow::netctlAutoRestartService() void NetctlAutoWindow::netctlAutoRestartService()
{ {
if (debug) qDebug() << PDEBUG; 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 status = false; bool responce = false;
if (useHelper) if (!useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = mainWindow->netctlCommand->autoRestartService();
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"), else try {
QList<QVariant>(), true, debug)[0].toBool(); responce = sendRequestToCtrl(QString("autoServiceRestart"), debug)[0].toBool();
else } catch (...) {
status = netctlCommand->autoRestartService(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
if (status) }
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done")); showMessage(responce);
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -403,18 +407,20 @@ void NetctlAutoWindow::netctlAutoRestartService()
void NetctlAutoWindow::netctlAutoStartService() void NetctlAutoWindow::netctlAutoStartService()
{ {
if (debug) qDebug() << PDEBUG; 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 status = false; bool responce = false;
if (useHelper) if (!useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH, responce = mainWindow->netctlCommand->autoStartService();
DBUS_HELPER_INTERFACE, QString("autoServiceStart"), else try {
QList<QVariant>(), true, debug)[0].toBool(); responce = sendRequestToCtrl(QString("autoServiceStart"), debug)[0].toBool();
else } catch (...) {
status = netctlCommand->autoStartService(); if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
if (status) }
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done")); showMessage(responce);
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable(); netctlAutoUpdateTable();
} }
@ -425,43 +431,14 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
Q_UNUSED(previous); Q_UNUSED(previous);
if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG;
if (current == 0) { bool selected = (current != nullptr);
// buttons ui->actionEnable->setEnabled(selected);
ui->pushButton_enable->setDisabled(true); ui->actionSwitch->setEnabled(selected && ui->tableWidget->item(current->row(), 2)->text().isEmpty());
ui->pushButton_switch->setDisabled(true); if (selected && !ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
// menu ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
return;
}
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
} else {
// buttons
ui->pushButton_enable->setEnabled(true);
ui->pushButton_switch->setEnabled(true);
// menu
ui->actionEnable->setVisible(true);
ui->actionSwitch->setVisible(true);
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
} else {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete")); ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
} } else {
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
} }
} }

View File

@ -18,12 +18,11 @@
#ifndef NETCTLAUTOWINDOW_H #ifndef NETCTLAUTOWINDOW_H
#define NETCTLAUTOWINDOW_H #define NETCTLAUTOWINDOW_H
#include <QKeyEvent>
#include <QMainWindow> #include <QMainWindow>
#include <QTableWidgetItem> #include <QTableWidgetItem>
class Netctl; class MainWindow;
namespace Ui { namespace Ui {
class NetctlAutoWindow; class NetctlAutoWindow;
@ -35,12 +34,15 @@ class NetctlAutoWindow : public QMainWindow
public: public:
explicit NetctlAutoWindow(QWidget *parent = 0, explicit NetctlAutoWindow(QWidget *parent = 0,
const bool debugCmd = false, const QMap<QString, QString> settings = QMap<QString, QString>(),
const QMap<QString, QString> settings = QMap<QString, QString>()); const bool debugCmd = false);
~NetctlAutoWindow(); ~NetctlAutoWindow();
Qt::ToolBarArea getToolBarArea();
public slots: public slots:
void showMessage(const bool status);
void showWindow(); void showWindow();
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
private slots: private slots:
// table // table
@ -58,12 +60,14 @@ private slots:
void netctlAutoStartService(); void netctlAutoStartService();
private: private:
Netctl *netctlCommand = nullptr; // ui
Ui::NetctlAutoWindow *ui = nullptr; Ui::NetctlAutoWindow *ui = nullptr;
MainWindow *mainWindow = nullptr;
// backend
void createActions();
bool debug = false; bool debug = false;
bool useHelper = true; bool useHelper = true;
QString checkStatus(const bool statusBool, const bool nullFalse = false); QMap<QString, QString> configuration;
void createActions();
}; };

View File

@ -14,12 +14,9 @@
<string>netctl-auto</string> <string>netctl-auto</string>
</property> </property>
<widget class="QWidget" name="centralwidget"> <widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="centralLayout">
<item> <item>
<widget class="QLabel" name="label_info"> <widget class="QLabel" name="label_info">
<property name="text">
<string/>
</property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignCenter</set> <set>Qt::AlignCenter</set>
</property> </property>
@ -65,65 +62,27 @@
<column/> <column/>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="layout_buttons">
<item>
<widget class="QPushButton" name="pushButton_refresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_enable">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable</string>
</property>
<property name="icon">
<iconset theme="edit-add"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_switch">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Switch</string>
</property>
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</widget> </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"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -137,11 +96,6 @@
<property name="title"> <property name="title">
<string>Menu</string> <string>Menu</string>
</property> </property>
<addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionSwitch"/>
<addaction name="actionEnable"/>
<addaction name="separator"/>
<addaction name="actionEnableAll"/> <addaction name="actionEnableAll"/>
<addaction name="actionDisableAll"/> <addaction name="actionDisableAll"/>
<addaction name="separator"/> <addaction name="separator"/>
@ -153,27 +107,6 @@
</widget> </widget>
<addaction name="menuMenu"/> <addaction name="menuMenu"/>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionSwitch">
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Switch to profile</string>
</property>
</action>
<action name="actionClose"> <action name="actionClose">
<property name="icon"> <property name="icon">
<iconset theme="exit"> <iconset theme="exit">
@ -189,7 +122,7 @@
</action> </action>
<action name="actionEnableAll"> <action name="actionEnableAll">
<property name="icon"> <property name="icon">
<iconset theme="edit-add"> <iconset theme="list-add">
<normaloff/> <normaloff/>
</iconset> </iconset>
</property> </property>
@ -211,6 +144,9 @@
<property name="text"> <property name="text">
<string>Start service</string> <string>Start service</string>
</property> </property>
<property name="toolTip">
<string>Start or stop service</string>
</property>
</action> </action>
<action name="actionRestartService"> <action name="actionRestartService">
<property name="text"> <property name="text">
@ -221,16 +157,51 @@
<property name="text"> <property name="text">
<string>Enable service</string> <string>Enable service</string>
</property> </property>
<property name="toolTip">
<string>Enable or disable service</string>
</property>
</action> </action>
<action name="actionRefresh"> <action name="actionRefresh">
<property name="icon"> <property name="icon">
<iconset theme="stock-refresh"> <iconset theme="view-refresh">
<normaloff/> <normaloff/>
</iconset> </iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Refresh</string> <string>Refresh</string>
</property> </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> </action>
</widget> </widget>
<resources/> <resources/>

View File

@ -54,12 +54,6 @@ bool NetctlGuiAdaptor::Close()
} }
QStringList NetctlGuiAdaptor::Information()
{
return mainWindow->printInformation();
}
void NetctlGuiAdaptor::LibraryDocs() void NetctlGuiAdaptor::LibraryDocs()
{ {
return mainWindow->showLibrary(); return mainWindow->showLibrary();
@ -70,8 +64,7 @@ QString NetctlGuiAdaptor::Pony()
{ {
QString pony; QString pony;
QFile ponyFile(QString(":pinkiepie")); QFile ponyFile(QString(":pinkiepie"));
if (!ponyFile.open(QIODevice::ReadOnly)) if (!ponyFile.open(QIODevice::ReadOnly)) return pony;
return pony;
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll()); pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
ponyFile.close(); ponyFile.close();
@ -134,9 +127,3 @@ QStringList NetctlGuiAdaptor::UIDs()
return uids; return uids;
} }
QStringList NetctlGuiAdaptor::VerboseInformation()
{
return mainWindow->printTrayInformation();
}

View File

@ -37,7 +37,6 @@ public slots:
bool Active(); bool Active();
void ApiDocs(); void ApiDocs();
bool Close(); bool Close();
QStringList Information();
void LibraryDocs(); void LibraryDocs();
QString Pony(); QString Pony();
bool Restore(); bool Restore();
@ -48,7 +47,6 @@ public slots:
bool ShowNetctlAuto(); bool ShowNetctlAuto();
bool ShowSettings(); bool ShowSettings();
QStringList UIDs(); QStringList UIDs();
QStringList VerboseInformation();
private: private:
MainWindow *mainWindow; MainWindow *mainWindow;

View File

@ -0,0 +1,494 @@
/***************************************************************************
* 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 "newprofilewidget.h"
#include "ui_newprofilewidget.h"
#include <QDebug>
#include <QLineEdit>
#include <QMenu>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include "bondwidget.h"
#include "bridgewidget.h"
#include "calls.h"
#include "commonfunctions.h"
#include "dbusoperation.h"
#include "errorwindow.h"
#include "ethernetwidget.h"
#include "generalwidget.h"
#include "ipwidget.h"
#include "mainwindow.h"
#include "macvlanwidget.h"
#include "mobilewidget.h"
#include "pppoewidget.h"
#include "tunnelwidget.h"
#include "tuntapwidget.h"
#include "vlanwidget.h"
#include "wirelesswidget.h"
NewProfileWidget::NewProfileWidget(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::NewProfileWidget;
ui->setupUi(this);
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("PROFILE_TOOLBAR")].toInt()));
// profile widgets
generalWid = new GeneralWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
ipWid = new IpWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
bondWid = new BondWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(bondWid);
bridgeWid = new BridgeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
ethernetWid = new EthernetWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
macvlanWid = new MacvlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
tuntapWid = new TuntapWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
vlanWid = new VlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
createActions();
}
NewProfileWidget::~NewProfileWidget()
{
if (debug) qDebug() << PDEBUG;
if (bondWid != nullptr) delete bondWid;
if (bridgeWid != nullptr) delete bridgeWid;
if (ethernetWid != nullptr) delete ethernetWid;
if (generalWid != nullptr) delete generalWid;
if (ipWid != nullptr) delete ipWid;
if (macvlanWid != nullptr) delete macvlanWid;
if (mobileWid != nullptr) delete mobileWid;
if (pppoeWid != nullptr) delete pppoeWid;
if (tunnelWid != nullptr) delete tunnelWid;
if (tuntapWid != nullptr) delete tuntapWid;
if (vlanWid != nullptr) delete vlanWid;
if (wirelessWid != nullptr) delete wirelessWid;
if (ui != nullptr) delete ui;
}
Qt::ToolBarArea NewProfileWidget::getToolBarArea()
{
if (debug) qDebug() << PDEBUG;
return toolBarArea(ui->toolBar);
}
void NewProfileWidget::profileTabOpenProfileSlot(const QString profile)
{
if (debug) qDebug() << PDEBUG;
ui->comboBox_profile->addItem(profile);
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count() - 1);
}
void NewProfileWidget::update()
{
if (debug) qDebug() << PDEBUG;
updateProfileTab();
updateMenuProfile();
}
void NewProfileWidget::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 NewProfileWidget::updateMenuProfile()
{
if (debug) qDebug() << PDEBUG;
bool selected = !ui->comboBox_profile->currentText().isEmpty();
ui->actionLoad->setEnabled(selected);
ui->actionRemove->setEnabled(selected);
ui->actionSave->setEnabled(selected);
ui->actionEditor->setEnabled(selected);
}
void NewProfileWidget::updateProfileTab()
{
if (debug) qDebug() << PDEBUG;
mainWindow->setDisabled(true);
ui->comboBox_profile->clear();
QList<netctlProfileInfo> profiles = generalInformation(mainWindow->netctlInterface,
useHelper, debug).netctlProfiles;
for (int i=0; i<profiles.count(); i++)
ui->comboBox_profile->addItem(profiles[i].name);
ui->comboBox_profile->setCurrentIndex(-1);
generalWid->clear();
ipWid->clear();
bondWid->clear();
bridgeWid->clear();
ethernetWid->clear();
macvlanWid->clear();
mobileWid->clear();
pppoeWid->clear();
tunnelWid->clear();
tuntapWid->clear();
vlanWid->clear();
wirelessWid->clear();
profileTabChangeState(generalWid->connectionType->currentText());
mainWindow->setDisabled(false);
mainWindow->showMessage(true);
}
void NewProfileWidget::profileTabChangeState(const QString current)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Current type" << current;
generalWid->setVisible(true);
ipWid->setVisible((current != QString("pppoe")) && (current != QString("mobile_ppp")));
bondWid->setVisible(current == QString("bond"));
bridgeWid->setVisible(current == QString("bridge"));
ethernetWid->setVisible((current == QString("ethernet")) ||
(current == QString("vlan")) ||
(current == QString("macvlan")));
macvlanWid->setVisible(current == QString("macvlan"));
mobileWid->setVisible(current == QString("mobile_ppp"));
pppoeWid->setVisible(current == QString("pppoe"));
tunnelWid->setVisible(current == QString("tunnel"));
tuntapWid->setVisible(current == QString("tuntap"));
vlanWid->setVisible(current == QString("vlan"));
wirelessWid->setVisible(current == QString("wireless"));
}
void NewProfileWidget::profileTabCreateProfile()
{
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("sudo"), configuration, debug)) {
ErrorWindow::showWindow(1, externalApps(QString("sudo"), configuration).join(QChar('\n')), debug);
return mainWindow->emitNeedToBeConfigured();
}
// error checking
if (ui->comboBox_profile->currentText().isEmpty())
return ErrorWindow::showWindow(3, QString(PDEBUG), debug);
if (generalWid->isOk() == 1)
return ErrorWindow::showWindow(4, QString(PDEBUG), debug);
else if (generalWid->isOk() == 2)
return ErrorWindow::showWindow(5, QString(PDEBUG), debug);
if ((generalWid->connectionType->currentText() == QString("ethernet")) ||
(generalWid->connectionType->currentText() == QString("wireless")) ||
(generalWid->connectionType->currentText() == QString("bond")) ||
(generalWid->connectionType->currentText() == QString("dummy")) ||
(generalWid->connectionType->currentText() == QString("bridge")) ||
(generalWid->connectionType->currentText() == QString("tunnel")) ||
(generalWid->connectionType->currentText() == QString("tuntap")) ||
(generalWid->connectionType->currentText() == QString("vlan")) ||
(generalWid->connectionType->currentText() == QString("macvlan")) ||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
if (ipWid->isOk() == 1)
return ErrorWindow::showWindow(6, QString(PDEBUG), debug);
else if (ipWid->isOk() == 2)
return ErrorWindow::showWindow(6, QString(PDEBUG), debug);
}
if (generalWid->connectionType->currentText() == QString("ethernet")) {
if (ethernetWid->isOk() == 1)
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
if (wirelessWid->isOk() == 1)
return ErrorWindow::showWindow(8, QString(PDEBUG), debug);
else if (wirelessWid->isOk() == 2)
return ErrorWindow::showWindow(9, QString(PDEBUG), debug);
else if (wirelessWid->isOk() == 3)
return ErrorWindow::showWindow(10, QString(PDEBUG), debug);
else if (wirelessWid->isOk() == 4)
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
else if (wirelessWid->isOk() == 5)
return ErrorWindow::showWindow(11, QString(PDEBUG), debug);
} else if (generalWid->connectionType->currentText() == QString("bond")) {
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
if (pppoeWid->isOk() == 1)
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
else if (pppoeWid->isOk() == 2)
return ErrorWindow::showWindow(12, QString(PDEBUG), debug);
else if (pppoeWid->isOk() == 3)
return ErrorWindow::showWindow(13, QString(PDEBUG), debug);
else if (pppoeWid->isOk() == 4)
return ErrorWindow::showWindow(12, QString(PDEBUG), debug);
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
if (mobileWid->isOk() == 1)
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
if (mobileWid->isOk() == 2)
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
}
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
if (tunnelWid->isOk() == 1)
return ErrorWindow::showWindow(20, QString(PDEBUG), debug);
else if (tunnelWid->isOk() == 2)
return ErrorWindow::showWindow(21, QString(PDEBUG), debug);
}
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
if (tuntapWid->isOk() == 1)
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
else if (tuntapWid->isOk() == 2)
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
}
else if (generalWid->connectionType->currentText() == QString("vlan")) {
if (ethernetWid->isOk() == 1)
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
}
else if (generalWid->connectionType->currentText() == QString("macvlan")) {
if (ethernetWid->isOk() == 1)
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
}
mainWindow->setDisabled(true);
// read settings
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
QMap<QString, QString> settings;
settings = generalWid->getSettings();
if (generalWid->connectionType->currentText() == QString("ethernet")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = ethernetWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = wirelessWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if ((generalWid->connectionType->currentText() == QString("dummy")) ||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("bond")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = bondWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = bridgeWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
QMap<QString, QString> addSettings = pppoeWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
QMap<QString, QString> addSettings = mobileWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("tunnel")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = tunnelWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("tuntap")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = tuntapWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("vlan")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = ethernetWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = vlanWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
} else if (generalWid->connectionType->currentText() == QString("macvlan")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = ethernetWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = macvlanWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
// call netctlprofile
InterfaceAnswer answer = createProfileSlot(profile, settings, mainWindow->netctlInterface,
useHelper, debug);
mainWindow->showMessage(answer == InterfaceAnswer::True);
updateProfileTab();
}
void NewProfileWidget::profileTabLoadProfile()
{
if (debug) qDebug() << PDEBUG;
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
if (profile.isEmpty()) return;
QMap<QString, QString> settings = profileInformation(profile, mainWindow->netctlInterface,
useHelper, debug);
if (settings.isEmpty()) return ErrorWindow::showWindow(17, QString(PDEBUG), debug);
generalWid->setSettings(settings);
if (generalWid->connectionType->currentText() == QString("ethernet")) {
ipWid->setSettings(settings);
ethernetWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
ipWid->setSettings(settings);
wirelessWid->setSettings(settings);
} else if ((generalWid->connectionType->currentText() == QString("dummy")) ||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
ipWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
ipWid->setSettings(settings);
bridgeWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("bond")) {
ipWid->setSettings(settings);
bondWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
pppoeWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
mobileWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("tunnel")) {
ipWid->setSettings(settings);
tunnelWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("tuntap")) {
ipWid->setSettings(settings);
tuntapWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("vlan")) {
ipWid->setSettings(settings);
ethernetWid->setSettings(settings);
vlanWid->setSettings(settings);
} else if (generalWid->connectionType->currentText() == QString("macvlan")) {
ipWid->setSettings(settings);
ethernetWid->setSettings(settings);
macvlanWid->setSettings(settings);
}
}
void NewProfileWidget::profileTabOpenInEditor()
{
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("editor"), configuration, debug)) {
ErrorWindow::showWindow(1, externalApps(QString("editor"), configuration).join(QChar('\n')), debug);
return mainWindow->emitNeedToBeConfigured();
}
QString directory = QDir(configuration[QString("PROFILE_DIR")]).absolutePath();
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
profile = QString("%1/%2").arg(directory).arg(profile);
QString cmd = QString("%1 %2 %3").arg(configuration[QString("SUDO_PATH")])
.arg(configuration[QString("EDITOR_PATH")])
.arg(profile);
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;
mainWindow->showMessage(process.exitCode == 0);
}
void NewProfileWidget::profileTabRemoveProfile()
{
if (debug) qDebug() << PDEBUG;
if (!checkExternalApps(QString("sudo"), configuration, debug)) {
ErrorWindow::showWindow(1, externalApps(QString("sudo"), configuration).join(QChar('\n')), debug);
return mainWindow->emitNeedToBeConfigured();
}
mainWindow->setDisabled(true);
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
InterfaceAnswer answer = removeProfileSlot(profile, mainWindow->netctlInterface,
useHelper, debug);
mainWindow->showMessage(answer == InterfaceAnswer::True);
updateProfileTab();
}
void NewProfileWidget::createActions()
{
if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(updateProfileTab()));
connect(ui->actionEditor, SIGNAL(triggered(bool)), this, SLOT(profileTabOpenInEditor()));
connect(ui->actionLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
connect(ui->actionSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
// main tab events
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile()));
connect(ui->comboBox_profile->lineEdit(), SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
}

View File

@ -0,0 +1,96 @@
/***************************************************************************
* 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 NEWPROFILEWIDGET_H
#define NEWPROFILEWIDGET_H
#include <QMainWindow>
#include <netctlgui/netctlgui.h>
class BondWidget;
class BridgeWidget;
class EthernetWidget;
class GeneralWidget;
class IpWidget;
class MainWindow;
class MacvlanWidget;
class MobileWidget;
class PppoeWidget;
class TunnelWidget;
class TuntapWidget;
class VlanWidget;
class WirelessWidget;
namespace Ui {
class NewProfileWidget;
}
class NewProfileWidget : public QMainWindow
{
Q_OBJECT
public:
explicit NewProfileWidget(QWidget *parent = 0,
const QMap<QString,QString> settings = QMap<QString,QString>(),
const bool debugCmd = false);
~NewProfileWidget();
Qt::ToolBarArea getToolBarArea();
public slots:
void profileTabOpenProfileSlot(const QString profile);
void update();
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
private slots:
// update slots
void updateMenuProfile();
void updateProfileTab();
// profile tab slots
void profileTabChangeState(const QString current);
void profileTabCreateProfile();
void profileTabLoadProfile();
void profileTabOpenInEditor();
void profileTabRemoveProfile();
private:
// ui
MainWindow *mainWindow;
Ui::NewProfileWidget *ui = nullptr;
BondWidget *bondWid = nullptr;
BridgeWidget *bridgeWid = nullptr;
EthernetWidget *ethernetWid = nullptr;
GeneralWidget *generalWid = nullptr;
IpWidget *ipWid = nullptr;
MacvlanWidget *macvlanWid = nullptr;
MobileWidget *mobileWid = nullptr;
PppoeWidget *pppoeWid = nullptr;
TunnelWidget *tunnelWid = nullptr;
TuntapWidget *tuntapWid = nullptr;
VlanWidget *vlanWid = nullptr;
WirelessWidget *wirelessWid = nullptr;
// backend
void createActions();
bool debug = false;
bool useHelper = true;
// configuration
QMap<QString, QString> configuration;
};
#endif /* NEWPROFILEWIDGET_H */

View File

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NewProfileWidget</class>
<widget class="QMainWindow" name="NewProfileWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>409</height>
</rect>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="layout_profile">
<item>
<widget class="QLabel" name="label_profile">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Profile</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_profile">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>459</width>
<height>342</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="scrollArea_layout">
<property name="margin">
<number>0</number>
</property>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>New profile 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="actionClear"/>
<addaction name="separator"/>
<addaction name="actionLoad"/>
<addaction name="actionSave"/>
<addaction name="separator"/>
<addaction name="actionRemove"/>
<addaction name="actionEditor"/>
</widget>
<action name="actionClear">
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
<property name="toolTip">
<string>Clear data</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="actionLoad">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Load</string>
</property>
<property name="toolTip">
<string>Load selected profile</string>
</property>
</action>
<action name="actionSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Save</string>
</property>
<property name="toolTip">
<string>Save 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>
<action name="actionEditor">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Open in editor</string>
</property>
<property name="toolTip">
<string>Open in an external editor</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -20,10 +20,10 @@
#include <QLineEdit> #include <QLineEdit>
#include "mainwindow.h" #include "wifimenuwidget.h"
PasswdWidget::PasswdWidget(MainWindow *wid) PasswdWidget::PasswdWidget(WiFiMenuWidget *wid)
: QWidget(wid), : QWidget(wid),
parent(wid), parent(wid),
ui(new Ui::PasswdWidget) ui(new Ui::PasswdWidget)
@ -49,6 +49,7 @@ void PasswdWidget::keyPressEvent(QKeyEvent *pressedKey)
void PasswdWidget::createActions() void PasswdWidget::createActions()
{ {
connect(ui->checkBox_showSymbols, SIGNAL(stateChanged(int)), this, SLOT(setEchoMode(int)));
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(passwdApply())); connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(passwdApply()));
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(cancel())); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(cancel()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(passwdApply())); connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(passwdApply()));
@ -64,19 +65,21 @@ void PasswdWidget::setFocusToLineEdit()
void PasswdWidget::setPassword(const bool mode) void PasswdWidget::setPassword(const bool mode)
{ {
if (mode) { if (mode) {
ui->lineEdit->setEchoMode(QLineEdit::Password); ui->checkBox_showSymbols->setCheckState(Qt::Checked);
setEchoMode(ui->checkBox_showSymbols->checkState());
ui->label->setText(QApplication::translate("PasswdWidget", "Password")); ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
} else { } else {
ui->lineEdit->setEchoMode(QLineEdit::Normal); ui->lineEdit->setEchoMode(QLineEdit::Normal);
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID")); ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
} }
passwdMode = mode;
} }
void PasswdWidget::cancel() void PasswdWidget::cancel()
{ {
hide(); hide();
parent->updateTabs(2); parent->update();
this->~PasswdWidget(); this->~PasswdWidget();
} }
@ -84,8 +87,17 @@ void PasswdWidget::cancel()
void PasswdWidget::passwdApply() void PasswdWidget::passwdApply()
{ {
hide(); hide();
if (ui->lineEdit->echoMode() == QLineEdit::Normal) if (passwdMode)
return parent->setHiddenName(ui->lineEdit->text());
else
return parent->connectToUnknownEssid(ui->lineEdit->text()); return parent->connectToUnknownEssid(ui->lineEdit->text());
else
return parent->setHiddenName(ui->lineEdit->text());
}
void PasswdWidget::setEchoMode(const int mode)
{
if (mode == 0)
ui->lineEdit->setEchoMode(QLineEdit::Password);
else
ui->lineEdit->setEchoMode(QLineEdit::Normal);
} }

View File

@ -23,7 +23,7 @@
#include <QWidget> #include <QWidget>
class MainWindow; class WiFiMenuWidget;
namespace Ui { namespace Ui {
class PasswdWidget; class PasswdWidget;
@ -34,7 +34,7 @@ class PasswdWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit PasswdWidget(MainWindow *wid = 0); explicit PasswdWidget(WiFiMenuWidget *wid = 0);
~PasswdWidget(); ~PasswdWidget();
public slots: public slots:
@ -44,13 +44,15 @@ public slots:
private slots: private slots:
void cancel(); void cancel();
void passwdApply(); void passwdApply();
void setEchoMode(const int mode);
private: private:
MainWindow *parent; WiFiMenuWidget *parent;
Ui::PasswdWidget *ui; Ui::PasswdWidget *ui;
// ESC pressed event // ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey); void keyPressEvent(QKeyEvent *pressedKey);
void createActions(); void createActions();
bool passwdMode = true;
}; };

Some files were not shown because too many files have changed in this diff Show More