209 Commits

Author SHA1 Message Date
d23429891e release 1.4.0 2015-01-12 19:30:49 +03:00
cf12b3627e update ChangeLog
update CmakeLists
update PKGBUILDs
fix GUI building
2015-01-12 01:14:40 +03:00
582459d174 fix #24
update gitignore
2015-01-11 00:38:47 +03:00
08e7390f6c Merge branch 'master' of github.com:arcan1s/netctl-gui 2015-01-10 00:36:26 +03:00
c8eae4b222 fix painting
update translations
fix PKGBUILD
2015-01-10 00:35:52 +03:00
54583eae6e update interface painting 2015-01-09 02:40:24 +03:00
634b4c3b41 try to paint more pretty interface 2015-01-08 02:00:59 +03:00
54c5e7958a kf5 update
* implement resizing
* implement debug
* implement notifications
* update interface
* correct work with helper
2015-01-07 07:03:41 +03:00
6ed45fa7a5 change in updates 2015-01-06 00:46:28 +03:00
73ba838685 + add de page
* rewrite de configuration to use qsettings
- remove cppcheck
+ add notifyrc
2015-01-05 00:29:52 +03:00
924beacc23 implement actions 2015-01-04 02:01:07 +03:00
a830fc9372 Merge branch 'kf5' 2015-01-03 13:58:17 +03:00
4c7459e833 Merge branch 'kf5' of github.com:arcan1s/netctl-gui into kf5 2015-01-03 13:56:33 +03:00
00a35d75d2 add ability to build kde4 and kf5 packages 2015-01-03 13:56:00 +03:00
3e92ec2aae Update CMakeLists.txt
bump to 1.4.0
2015-01-03 13:23:16 +03:00
3ac0484f21 some test with actions 2014-12-31 08:09:53 +03:00
cbac07b29e move method from original one 2014-12-30 14:39:25 +03:00
7972f2d6d3 some configuration interface changes 2014-12-29 23:37:21 +03:00
afed94745a fix plugin 2014-12-29 20:56:35 +03:00
c8f260c8e2 rename applet to *plasma* 2014-12-29 08:35:23 +03:00
edb386d24e implement binary module 2014-12-28 17:42:08 +03:00
f188dea8a7 add wdiget.qml 2014-12-27 12:24:05 +03:00
6fb7da4b5b add appearance.qml 2014-12-27 03:50:31 +03:00
a35e9b0164 first work on plasmoid 2014-12-26 08:22:26 +03:00
4bc428f8b5 add workaround to #23
(fix?)
2014-12-05 03:52:27 +03:00
030dec5e14 end porting of DE to KF5 2014-10-21 16:26:35 +04:00
0898a99878 updte dataengine skel 2014-10-21 13:06:57 +04:00
8dd48fa7cc release 1.3.3
fix #19
2014-10-19 17:50:24 +04:00
287405f81a try fix #19 2014-10-18 01:17:15 +04:00
fa27b80060 add some w\o 2014-10-17 13:52:46 +04:00
c2c14c4911 Merge pull request #18 from nosada/translate_to_ja
Fix translation on plasmoid
2014-10-13 11:58:23 +04:00
e2deb8751d fix translation at plasmoid 2014-10-13 16:43:37 +09:00
1fe7d6e21f change translation at plasmoid (again) 2014-10-13 16:43:37 +09:00
e68be6d4f1 change translation at plasmoid 2014-10-13 16:43:37 +09:00
45d3a42754 update tasks 2014-10-09 22:58:13 +04:00
cb0410a182 update pkgbuild #17 2014-09-27 18:25:41 +04:00
9d349461cf release 1.3.2 2014-09-22 00:56:12 +04:00
d41a34673b add translations to resources
fix plasmoid icon
2014-09-21 14:28:58 +04:00
b199b43f58 fix mistakes and fluctuation of description at plasmoid 2014-09-19 13:55:43 +09:00
6d212efe1e fix mistakes and fluctuation of description at netctlgui-helper 2014-09-19 13:55:43 +09:00
d32486d882 fix mistakes and fluctuation of description at netctl-gui 2014-09-19 13:55:43 +09:00
5afa65ce68 edit authors 2014-09-19 00:44:55 +04:00
5b46247df2 finished 2014-09-19 01:09:56 +09:00
bda5433716 translating netctl-gui to Japanese (yet not finished) 2014-09-19 01:09:56 +09:00
835e82ca63 translated netctlgui-helper to Japanese 2014-09-19 01:09:56 +09:00
98cdb18d62 translating netctl-gui to Japanese (yet not finished), and modify plasmoid translating file 2014-09-19 01:09:56 +09:00
cd59a9b294 translating netctl-gui to Japanese (not finished) 2014-09-19 01:09:56 +09:00
4780433c4d translated plasmoid to Japanese 2014-09-19 01:09:56 +09:00
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
4e8bbeed35 update archlinux install scripts 2014-09-06 15:24:42 +04:00
f86ef0514b release 1.3.1 2014-09-06 15:02:05 +04:00
4c004af1ae add dbus configuration to backup 2014-08-27 22:30:49 +04:00
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
9cf6552c71 update install files 2014-08-27 18:20:12 +04:00
f18e74917b more correct checking dbus response 2014-08-27 18:14:22 +04:00
b909222db9 better submodules integration (hope =))
add --session support to the helper
2014-08-27 17:23:12 +04:00
0c7868536a update to changes 2014-08-27 17:12:52 +04:00
fc3956caf1 ya submodules fix 2014-08-27 17:07:00 +04:00
4cf3c85070 fix submodules (see #14) 2014-08-27 16:26:38 +04:00
6e57baccaf remove description from security notes 2014-08-27 11:47:44 +04:00
5ed704e676 rewrite to use submodules 2014-08-26 16:06:13 +04:00
eb3753ab25 update 3rdparty/language 2014-08-26 10:46:14 +04:00
f9d71577f3 update html docs to standards 2014-08-25 23:52:10 +04:00
814f2c7904 update license agreement to trdparty items 2014-08-25 20:29:30 +04:00
ceca889be4 release 1.3.0 2014-08-25 16:06:31 +04:00
696283b1e1 update readme/prepare to release 2014-08-25 15:06:03 +04:00
15cc3a8595 rename wifi tab 2014-08-25 14:59:34 +04:00
e8c3441f29 add profile reading description 2014-08-25 11:53:14 +04:00
2de7b26f66 change name to id in html docs 2014-08-25 11:42:50 +04:00
8f35aeb88f rewrite actions to qtoolbutton 2014-08-25 11:34:08 +04:00
b49188c104 remove kde runtime from optdep list 2014-08-25 10:56:45 +04:00
f8bf8830be fix mans 2014-08-25 10:55:34 +04:00
6e6c547460 unify configuration names 2014-08-25 10:54:18 +04:00
d287f52ba5 rename layout 2014-08-25 10:48:01 +04:00
8cc02a07fb update translations 2014-08-24 16:45:19 +04:00
28d51484b1 fix update toolboxes 2014-08-24 16:40:01 +04:00
e7d2e0bd38 change menu to toolboxes 2014-08-24 16:30:37 +04:00
999914926a add force* slots 2014-08-24 13:08:13 +04:00
e21b2201ab small tray fixes 2014-08-24 13:00:50 +04:00
d65ded6072 update messages 2014-08-20 23:37:37 +04:00
16662f697b cleanup!
(remove symlinks)
2014-08-20 22:16:06 +04:00
35d740b778 update build script 2014-08-20 21:25:56 +04:00
0a16364a7a update docs
change building
2014-08-20 21:16:31 +04:00
e9090ab4a9 remove suid bit to use capabilities 2014-08-20 20:21:34 +04:00
8bf33d4369 edit about window, update translations 2014-08-20 12:01:56 +04:00
4e76d52671 update configuration file 2014-08-20 08:32:14 +04:00
47dc016da2 update man pages
more correct behavior to --daemon option (renamed to --detached)
2014-08-19 11:26:03 +04:00
8b58f6d383 small edit of showing information 2014-08-18 21:17:53 +04:00
709431ead2 change temporary profile directory 2014-08-18 12:49:36 +04:00
f90b2d97a7 update translations 2014-08-18 10:12:02 +04:00
5416ef841f more pretty CMakeLists.txt 2014-08-18 09:55:55 +04:00
e4cff2baf4 small stuff update 2014-08-17 21:26:50 +04:00
d047eaf2f2 update changelog 2014-08-17 19:02:17 +04:00
56f4a75b25 end work on tests 2014-08-17 18:26:04 +04:00
dd05782f80 add dbus functions to netctlauto and wpasup 2014-08-17 16:38:28 +04:00
2c2919160b add dbus test to testnetctl 2014-08-17 16:34:51 +04:00
d7c8490724 add wpasup test 2014-08-17 15:54:08 +04:00
1930eeb33c add testnetctlprofile 2014-08-17 14:54:16 +04:00
4cc9d0ec11 more pretty tests 2014-08-17 11:05:49 +04:00
a7911d48d1 add tests to netctl control
(todo: netctl-auto tests)
2014-08-17 09:42:52 +04:00
012c725e12 update readme 2014-08-16 22:02:27 +04:00
1907d3ac2f add several active profiles support to de and plasmoid 2014-08-16 22:01:10 +04:00
87376f1a5c add test support of several active profiles to gui, library and helper 2014-08-16 21:47:22 +04:00
f238ba3a6a fix startprofileslot 2014-08-15 20:46:18 +04:00
abbc5641cd do not block gui for dbus requests 2014-08-15 20:38:33 +04:00
82c3690dcb add actions 2014-08-14 17:00:51 +04:00
d3e1c4bca0 add FindSettings key 2014-08-13 11:41:30 +04:00
b63d883eb2 add getrecommended to wpasup class 2014-08-13 09:29:49 +04:00
529e2dd995 add error output to gui 2014-08-13 07:58:54 +04:00
1d34a65f38 add new API to the helper 2014-08-13 07:53:22 +04:00
fea0bedef0 add stopAllProfiles and reenableProfile slots 2014-08-13 07:49:27 +04:00
ec8fc79dd7 rewrite library to use pdebug 2014-08-13 07:45:00 +04:00
07e07ee777 rewrite plasmoid, de and helper to use pdebug 2014-08-13 07:26:15 +04:00
5c8dca22d0 rewrite gui to use pdebug 2014-08-13 07:12:32 +04:00
dba3eeabaa add error output to dataengine 2014-08-13 04:22:25 +04:00
eabfac7323 add --system flag to the helper
add security notes
2014-08-12 23:49:35 +04:00
3b1701f8b5 some fixes including adding double quotes 2014-08-12 22:58:13 +04:00
b65f761520 some improvements in helper and gui APIs and replacement and restoring
sessions
2014-08-12 14:01:00 +04:00
fddd4703cc some applet and dataengine fixes 2014-08-12 10:17:18 +04:00
f4e3848fa7 update changelog and some translations fixes 2014-08-12 00:59:56 +04:00
3e0ae6d4cc moved helper daemonization
add abillity to own users org.netctlgui.helper service
2014-08-12 00:23:11 +04:00
80f6ccf1d1 fix #10, #11 2014-08-11 23:56:26 +04:00
863b49eaec add euid checking to the helper 2014-08-11 23:23:18 +04:00
4785e358ec rewrite mainwindow class 2014-08-11 23:12:52 +04:00
f0adbb60e5 some gui fixes 2014-08-11 22:38:54 +04:00
61d814d9a2 add Pony() call <3
helper and library refatoring
2014-08-11 21:51:50 +04:00
d166668feb prepare dataengine to release 2014-08-11 20:54:35 +04:00
db3bfe9ad7 prepare plasmoid to release 2014-08-11 20:49:48 +04:00
d2ea9d96d9 split MainWindow into mainwindow, mainpublicslots, mainprivateslots 2014-08-11 17:21:11 +04:00
d4c82fce0c update plasmoid translation 2014-08-10 22:33:15 +04:00
fe672aa8cc add plasmoid helper integration 2014-08-10 22:29:42 +04:00
501b43002e add openvswitch support 2014-08-10 21:21:18 +04:00
43ed28de52 allow applet to move into notifications area 2014-08-10 16:17:00 +04:00
f7352f5c59 edit todo list 2014-08-10 15:08:39 +04:00
d112446d87 add translation to the helper 2014-08-10 14:51:47 +04:00
b863eedd96 change message class from helper to mainwindow 2014-08-10 14:28:45 +04:00
e19c9fef53 update mainwindow translations 2014-08-10 14:26:59 +04:00
10499691b3 rewrite tray 2014-08-10 14:22:23 +04:00
bf6d7cd53b add == checking 2014-08-10 11:11:34 +04:00
11db0fcf8d add docs integration 2014-08-10 11:05:29 +04:00
d44979e95e update man pagesand translations 2014-08-09 23:27:58 +04:00
41f58c1448 fix security hole in helper 2014-08-09 22:33:13 +04:00
2ff76e9c8e add additional docs to helper 2014-08-09 22:05:29 +04:00
0b2cc3ba79 update readme / TODO 2014-08-09 21:41:53 +04:00
fb430b036e update main funtions
Beta release of helper
2014-08-09 21:35:55 +04:00
42194295cc rename CONTROL to CTRL 2014-08-09 20:55:14 +04:00
558a206a8d rewrite netctlautowindow 2014-08-09 20:48:12 +04:00
172624b494 test fix #9 2014-08-09 20:19:52 +04:00
e64e8810f8 rewrite mainwindow to use helper 2014-08-09 18:08:01 +04:00
23f4a7f141 rewrite mainwindow.cpp to use helper 2014-08-09 12:56:05 +04:00
d01bb8834a refactoring mainwindow class 2014-08-09 12:02:48 +04:00
0989a6584b update pkgbuild to the current changes 2014-08-09 11:27:59 +04:00
c75f5ec135 update todo 2014-08-09 08:06:33 +04:00
d0a0b0eb4a update readme 2014-08-09 07:59:28 +04:00
6b7d5d3800 intermediate commit 2014-08-09 07:56:17 +04:00
6a3e3b14b3 add helper proto 2014-08-08 19:33:36 +04:00
1ae30b0821 commit before starting work on helper 2014-08-08 17:01:33 +04:00
c15e387472 update translation 2014-08-07 17:24:55 +04:00
d04a0b0920 small fix 2014-08-07 17:22:00 +04:00
e8e0c71c05 fix some bugs 2014-08-07 17:16:35 +04:00
516c4b5a22 add dynamic settings load
fix setTray() function
2014-08-07 17:06:52 +04:00
4e027ec19f rewrite main() 2014-08-07 15:46:37 +04:00
4788ad0081 add daemonized option 2014-08-07 00:59:43 +04:00
891b3b43ef add control interface 2014-08-06 22:56:01 +04:00
dee47b0ffc end work to dbus interface 2014-08-06 22:36:10 +04:00
86753070e8 add org.netctlgui.netctlgui /netctlgui 2014-08-06 21:47:54 +04:00
ff78d390ae start work on dbus module 2014-08-06 21:10:08 +04:00
447bcf8a0e add dbus interface proto 2014-08-06 19:01:03 +04:00
e8a7865e99 update gui translations 2014-08-06 17:15:22 +04:00
fdb5b46ea1 add system tray 2014-08-06 17:12:22 +04:00
0432579f5b fix table resize 2014-08-06 13:58:51 +04:00
2aa6b43e61 rewrite tables 2014-08-06 13:12:18 +04:00
0bade9c42f update netctlProfileInfo structure 2014-08-06 01:43:08 +04:00
067115280c update readme 2014-08-06 00:36:17 +04:00
873f84c447 update changelog 2014-08-06 00:35:59 +04:00
4c9c7b00a1 update gui 2014-08-06 00:12:52 +04:00
64937105c6 rewrite library to use task 2014-08-05 23:32:12 +04:00
297a18d530 edit project structure 2014-08-05 20:53:55 +04:00
8c0226c9db fix dataengine
update plasmoid translations
2014-08-05 20:37:16 +04:00
1abc4a5ac9 add task definitions to dataengine 2014-08-05 16:55:23 +04:00
7ed3e4e01b rewrited plasmoid 2014-08-05 12:57:27 +04:00
dc81a44034 rewrited dataengine
+ add ipv6 definition (internal and external)
+ add netctlAuto source
* rewrite interface list definition to use QtNetwork module
* rewrite internal ip definition to use QtNetwork module
- fix #7
2014-08-05 00:22:01 +04:00
7febf94233 add roadmap to dataengine 2014-08-04 22:35:26 +04:00
3a0f0c252e (?) fix #8
fucking heisenbug
2014-08-04 22:05:29 +04:00
209c3b9616 edit plasmoid netctl calls (see #7) 2014-08-04 16:28:12 +04:00
a79cbd4429 fix building 2014-08-02 12:12:13 +04:00
eb6bd34489 update po 2014-08-01 21:28:23 +04:00
ccc62ffb67 end of refactoring of plasmoid 2014-08-01 21:22:30 +04:00
fc2d338450 fix resize event 2014-08-01 20:49:10 +04:00
eefe196b69 add click event, remove button
TODO: refactoring (including removal of unneeded pointers) and normal resize event
2014-08-01 20:24:40 +04:00
c1e23d38a9 plasmoid is now popupapplet 2014-08-01 12:20:06 +04:00
e9c10e262e update about window
add report a bug link
2014-08-01 09:54:26 +04:00
0d26d6230e roll back 2014-08-01 09:37:09 +04:00
0aa162b71b add reportabug 1.0.2 2014-07-31 19:59:55 +04:00
78a4aeb0eb removed unneede libraries 2014-07-27 23:47:05 +04:00
ec5dff4b75 yae reading files` 2014-07-21 12:11:30 +04:00
0070f910cc add debug information
fix reading files
2014-07-21 11:58:42 +04:00
6cba836d98 small edit 2014-07-21 10:55:15 +04:00
4600aae8bc add netctlgui.h
rewrited some functions
2014-07-21 10:25:10 +04:00
79e7aa1926 fix completions names
deatached library in PKGBUILD
2014-07-20 13:30:10 +04:00
32683a89b9 small fix 2014-07-20 12:47:43 +04:00
43de4e5738 fix possible segfaults with null arrays (#5) 2014-07-20 12:20:26 +04:00
099b4e3792 update desktop file 2014-07-20 11:30:00 +04:00
389726379c update archive 2014-07-20 11:03:26 +04:00
9c0dcfe621 small update 2014-07-18 00:05:10 +04:00
75a95661f8 fix completions 2014-07-17 23:40:25 +04:00
31f52e5d22 small fixes 2014-07-17 19:36:15 +04:00
78827d833d added completions
removed wpa_actiond dependency
2014-07-17 18:18:40 +04:00
c0207a108e update screenshots 2014-07-16 22:18:08 +04:00
182 changed files with 20637 additions and 6736 deletions

6
.gitignore vendored
View File

@ -25,3 +25,9 @@ usr/
# translations
*.qm
# temporary bckps
*~
# kdevelop files
.kdev4
*.kdev4

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:
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
Translators:
@nosada (Japanese translation)

254
CHANGELOG
View File

@ -1,60 +1,212 @@
Ver.1.2.0:
+ [all] added icons
+ [all] added support of netctl-auto
+ [gui] added suppoort of macvlan
+ [gui] added ability to remove profile
+ [gui] added support of hidden wifi network
+ [gui] added contextual menu to tables
+ [gui] added actions menu
+ [gui] added clear() function to profileTab
+ [gui] added about window
+ [gui] more command line options
+ [gui] added workaround for wireless-wep example
+ [lib] detached backend from frontend
+ [lib] added error checking
+ [lib] added doxygen documentation
+ [plasmoid] added dataengine configuration
+ [plasmoid] added about window
* [all] changes in the project architecture
* [all] refactoring
* [gui] more debug information
* [gui] changed lineEdit_profile to comboBox
* [gui] refactoring of configuration interface
* [gui] changed setting of the interface to profile tab
* [gui] rewrited ErrorWindow class
* [lib] more debug information
* [lib] rewrited getSettingsFromProfile() function
* [plasmoid] edited configuration interface
* [plasmoid] changed double click event to click event
Ver.1.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.1.0 (netctl-1.7 update):
+ [gui] added frequency
+ [plasmoid] added menu title
* [dataengine] changed definition if profile is enabled
* [gui] changed definition if profile is enabled
***
Ver.1.0.6:
* [gui] fix error checking
Ver.1.3.3
---------
* all
* update Japanese translation
* dataengine
- fix #19
Ver.1.0.5:
+ [plasmoid] added "Start WiFi menu" function
* [plasmoid] refactoring
* [plasmoid] edited icon
***
Ver.1.0.4:
+ [gui] added Qt5 gui (by default)
+ [plasmoid] added notifications
* [plasmoid] fix run command with sudo from plasmoid
Ver.1.3.2
---------
* all
+ add Japanese translation (thanks to @nosada)
Ver.1.0.3:
+ [plasmoid] edited russian translation
* [all] refactoring
***
Ver.1.0.2:
* [plasmoid] fix layout margins
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.0.1:
- [all] removed scripts
***
Ver.1.0:
Ver.1.3.0
---------
* all:
+ add processes error messages
+ add support of several active profiles
* some bug fixes and refactoring
* rewrite debug messages
* dataengine:
+ add new sources: intIp6, extIp6, netctlAutoStatus
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
* change default command to define external IP
* change interface list definition
* change internal IP definition
* gui:
+ add 3rd party license information
+ add system tray icon as an alternative to the plasmoid
+ add DBus session interface org.netctlgui.netctlgui
+ add dynamic settings load
+ add support of openvswitch
+ add security notes and API descriptions
+ add ability to use helper
+ add ability to start minimized/maximized/detached
+ add ability to don't save profile from WiFi tab
+ add ability to skip external components checking
- remove buttons
* more correct actions into SettingsWindow
* update to library changes
* rewrite tables to use toolTip
* edit about window
* change menuBar
* helper:
+ create daemon DBus system interface org.netctlgui.helper to the library:
self control slots, netctl control slots and netctl information slots
+ add tests
* library:
+ add custom structures netctlWifiInfo and netctlProfileInfo
+ add methods getActiveProfile(), autoGetActiveProfile()
+ add slot switchToProfile()
+ add slot stopAllProfiles()
+ add slot reenableProfile()
+ add slots getRecommendedConfiguration()
+ add slots forceStartProfile() and forceStopProfile()
+ add double quotes to profile names
+ add tests
- remove functions getProfileDescriptions() and getProfileStatuses()
- remove SleepThread class
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
* rename getInterfaceList() to getWirelessInterfaceList()
* change temporary directory from $HOME/.cache to system one
* plasmoid:
+ add 3rd party license information
+ allow plasmoid to use system tray
+ add ability to use helper
* change all running processes to detached (see #7)
* rewrite text label to use tags
* update to dataengine changes
* edit about window
***
Ver.1.2.0
---------
* all:
+ add icons
+ add support of netctl-auto
* changes in the project architecture
* refactoring
* dataengine:
+ add debug information (NETCTLGUI_DEBUG=yes)
* gui:
+ add support of macvlan
+ add ability to remove profile
+ add support of hidden wifi network
+ add contextual menu to tables
+ add actions menu
+ add clear() function to profileTab
+ add about window
+ more command line options
+ add workaround for wireless-wep example
+ add shell completions
+ add "Report a bug" action
- fix possible segfaults with null arrays (#5)
* more debug information
* change lineEdit_profile to comboBox
* refactoring of configuration interface
* change setting of the interface to profile tab
* rewrite ErrorWindow class
* library:
+ detach backend from frontend
+ add error checking
+ add doxygen documentation
* more debug information
* rewrite getSettingsFromProfile() function
* plasmoid:
+ add dataengine configuration
+ add about window
+ add debug information (NETCTLGUI_DEBUG=yes)
* edit configuration interface
* change double click event to click event
* change class from Applet to PopupApplet
***
Ver.1.1.0 (netctl-1.7 update)
-----------------------------
* dataengine:
* change definition if profile is enabled
* gui:
+ add frequency
* change definition if profile is enabled
* plasmoid:
+ add menu title
***
Ver.1.0.6
---------
* gui:
* fix error checking
***
Ver.1.0.5
---------
* plasmoid:
+ add "Start WiFi menu" function
* refactoring
* edit icon
***
Ver.1.0.4
---------
* gui:
+ add Qt5 gui (by default)
* plasmoid:
+ add notifications
* fix run command with sudo from plasmoid
***
Ver.1.0.3
---------
* all:
* refactoring
* plasmoid:
+ edit russian translation
***
Ver.1.0.2
---------
* plasmoid:
- fix layout margins
***
Ver.1.0.1
---------
* all:
- remove scripts
***
Ver.1.0
-------
First release

View File

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

View File

@ -4,14 +4,19 @@ Netctl GUI
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)
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
===========
@ -25,9 +30,9 @@ Dependencies
Optional dependencies
---------------------
* kdebase-workspace (widget)
* kdebase-workspace (KDE4 widget)
* plasma-framework (KF5 widget)
* sudo (sudo support)
* wpa_actiond (netctl-auto support)
* wpa_supplicant (WiFi support)
Make dependencies
@ -51,12 +56,21 @@ Installation
Available cmake flags:
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_GUI:BOOL=0` - do not build GUI
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
* components:
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
* `-DBUILD_GUI:BOOL=0` - do not build GUI
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* additional components:
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
* project properties:
* `-DDBUS_SYSTEMCONF_PATH=/etc/dbus-1/system.d/` - path to dbus system configuration files
* `-DSYSTEMD_SERVICE_PATH=lib/systemd/system` - path to systemd services
* `-DUSE_CAPABILITIES:BOOL=0` - do not use setcap to get privileges to the helper
* `-DBUILD_KDE4:BOOL=1` - build KDE4 plasmoid instead of KF5 one
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
Additional information
======================

99
arch/PKGBUILD Normal file
View File

@ -0,0 +1,99 @@
# 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.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' 'extra-cmake-modules' 'plasma-framework' 'qt5-tools')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
md5sums=('172fff4b59c15c991b016db35971eca1')
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')
provides=('netctlgui-helper-qt4')
conflicts=('netctlgui-helper-qt4')
backup=('etc/netctl-gui.conf'
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
install="netctlgui-helper.install"
cd "${srcdir}/build-qt5/helper"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui() {
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
depends=('libnetctlgui' 'xdg-utils')
optdepends=('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
pkgname=('libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
'kdeplasma-applets-netctl-gui')
pkgver=1.4.0
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=('172fff4b59c15c991b016db35971eca1')
prepare() {
rm -rf "${srcdir}/build-"{plasmoid,qt4}
mkdir "${srcdir}/build-"{plasmoid,qt4}
}
build() {
cd "${srcdir}/build-plasmoid"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_GUI:BOOL=0 \
-DBUILD_LIBRARY:BOOL=0 \
-DBUILD_HELPER:BOOL=0 \
-DBUILD_KDE4:BOOL=1 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt4"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
-DUSE_CAPABILITIES:BOOL=0 \
-DUSE_QT5:BOOL=0 \
"../${pkgbase}"
make
}
package_kdeplasma-applets-netctl-gui() {
pkgdesc="A KDE4 plasmoid, which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'kdebase-workspace')
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
'netctl-gui-qt4: graphical front-end'
'sudo: sudo support')
install="kdeplasma-applets-netctl-gui.install"
cd "${srcdir}/build-plasmoid"
make DESTDIR="${pkgdir}" install
}
package_libnetctlgui-qt4() {
pkgdesc="Qt4 library which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'qt4')
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
'sudo: sudo support'
'wpa_supplicant: wifi support')
provides=('libnetctlgui')
conflicts=('libnetctlgui')
install=""
cd "${srcdir}/build-qt4/netctlgui"
make DESTDIR="${pkgdir}" install
}
package_netctlgui-helper-qt4() {
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
depends=('libnetctlgui-qt4')
provides=('netctlgui-helper')
conflicts=('netctlgui-helper')
backup=('etc/netctl-gui.conf'
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
install="netctlgui-helper.install"
cd "${srcdir}/build-qt4/helper"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui-qt4() {
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
depends=('libnetctlgui-qt4')
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
'netctlgui-helper-qt4: DBus helper daemon')
provides=('netctl-gui')
conflicts=('netctl-gui')
install="netctl-gui.install"
cd "${srcdir}/build-qt4/gui"
make DESTDIR="${pkgdir}" install
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_install
post_install "$1"
}
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

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

BIN
screenshots/de-main.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

BIN
screenshots/gui-about.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

218
sources/3rdparty/about/about.ui vendored Normal file
View File

@ -0,0 +1,218 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QWidget" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>359</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_About">
<attribute name="title">
<string>About</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QScrollArea" name="scrollArea_about">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_about">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>284</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_name">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_version">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_description">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_links">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_about">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_ackn">
<attribute name="title">
<string>Acknowledgement</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QScrollArea" name="scrollArea_ackn">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_ackn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>418</width>
<height>284</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLabel" name="label_translators">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_trdparty">
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_ackn">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>229</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="label_license">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

1
sources/3rdparty/language vendored Submodule

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

@ -0,0 +1,12 @@
#ifndef LANGUAGE_CONFIG_H
#define LANGUAGE_CONFIG_H
// put your languages here comma separated
// the first language is default language
#define LANGUAGES "en,ru"
// language key in the configuration file
#define LANGUAGE_KEY "LANGUAGE"
#endif /* LANGUAGE_CONFIG_H */

1
sources/3rdparty/pdebug vendored Submodule

Submodule sources/3rdparty/pdebug added at 294a590bb9

1
sources/3rdparty/task vendored Submodule

Submodule sources/3rdparty/task added at d2798204a1

1
sources/3rdparty/tasks vendored Submodule

Submodule sources/3rdparty/tasks added at 230bdecd2c

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 CMP0002 OLD)
@ -10,7 +10,7 @@ set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 1)
set (PROJECT_VERSION_MINOR 2)
set (PROJECT_VERSION_MINOR 4)
set (PROJECT_VERSION_PATCH 0)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
@ -21,51 +21,73 @@ message (STATUS "Version: ${PROJECT_VERSION}")
message (STATUS "Build date: ${CURRENT_DATE}")
# install options
option (USE_CAPABILITIES "Use setcap to set capabilities for the helper" ON)
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
# components
option (BUILD_GUI "Build GUI" ON)
option (BUILD_HELPER "Build helper" ON)
option (BUILD_LIBRARY "Build library" ON)
option (BUILD_DATAENGINE "Build data engine" ON)
option (BUILD_DATAENGINE "Build DataEngine" ON)
option (BUILD_PLASMOID "Build plasmoid" ON)
if (BUILD_GUI)
set (BUILD_LIBRARY ON)
option (BUILD_KDE4 "Build on KDE4" OFF)
if (BUILD_GUI OR BUILD_HELPER)
set (BUILD_LIBRARY ON)
endif ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
set (BUILD_DATAENGINE ON)
endif ()
# documentation
option (BUILD_DOCS "Build documentation and install headers" ON)
option (BUILD_DOCS "Build Doxygen documentation" OFF)
if (BUILD_DOCS)
set (BUILD_LIBRARY ON)
set (BUILD_LIBRARY ON)
endif ()
# test
option (BUILD_TEST "Build unit tests" OFF)
if (BUILD_TEST)
set (BUILD_LIBRARY ON)
endif ()
# FIXME: dbus path
set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus system configuration files")
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
# flags
if (CMAKE_COMPILER_IS_GNUCXX)
set (ADD_CXX_FLAGS "-Wall")
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
else ()
message (STATUS "Unknown compiler")
message (STATUS "Unknown compiler")
endif ()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
# resources
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set (PROJECT_LIBRARY netctlgui)
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
add_subdirectory (${PROJECT_RESOURCE_DIR})
# components
if (BUILD_LIBRARY)
add_subdirectory (${PROJECT_LIBRARY})
endif()
add_subdirectory (${PROJECT_LIBRARY})
endif ()
if (BUILD_HELPER)
add_subdirectory (helper)
endif ()
if (BUILD_TEST)
enable_testing ()
add_subdirectory (test)
endif ()
if (BUILD_GUI)
add_subdirectory (gui)
add_subdirectory (gui)
endif ()
if (BUILD_DATAENGINE)
add_subdirectory (dataengine)
add_subdirectory (dataengine)
endif ()
if (BUILD_PLASMOID)
add_subdirectory (plasmoid)
if (BUILD_KDE4)
add_subdirectory (plasmoid-kde4)
else ()
add_subdirectory (plasmoid-kf5)
endif (BUILD_KDE4)
endif ()

View File

@ -3,26 +3,66 @@ set (SUBPROJECT plasma_engine_netctl)
message (STATUS "Subproject ${SUBPROJECT}")
# find required libaries
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
if (BUILD_KDE4)
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
set (KDE_INCLUDE ${KDE4_INCLUDES})
else ()
find_package (Qt5 REQUIRED COMPONENTS Widgets Network)
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
find_package(KF5 REQUIRED COMPONENTS Plasma Service)
include (KDEInstallDirs)
include (KDECMakeSettings)
include (KDECompilerSettings)
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS})
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
${Qt5Network_INCLUDE_DIRS})
set (KDE_INCLUDE ${ConfigCore_INCLUDE_DIR}
${CoreAddons_INCLUDE_DIR}
${Plasma_INCLUDE_DIR}
${Service_INCLUDE_DIR})
endif ()
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR}
${Qt_INCLUDE}
${KDE_INCLUDE})
set (PLUGIN_NAME ${SUBPROJECT})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file (GLOB SUBPROJECT_SOURCE *.cpp)
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
file (GLOB SUBPROJECT_CONF *.conf)
# prepare
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
# make
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS})
if (BUILD_KDE4)
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
else ()
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} ${Qt5Network_LIBRARIES})
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
endif ()
# install
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 ${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,20 +0,0 @@
# Configuration file for netctl data engine
## Commands
# command
CMD=/usr/bin/netctl
# netctl-auto command
NETCTLAUTOCMD=/usr/bin/netctl-auto
# ip command
IPCMD=/usr/bin/ip
## Network
# path to list of network devices
NETDIR=/sys/class/net/
## External IP
# external ip check command
EXTIPCMD=wget -qO- http://ifconfig.me/ip
# 'true' - check external IP
EXTIP=false

View File

@ -17,13 +17,26 @@
#include "netctl.h"
#include <Plasma/DataContainer>
#include <QDebug>
#include <QFile>
#include <QNetworkInterface>
#include <QProcessEnvironment>
#include <QSettings>
#include <QTextCodec>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include <version.h>
// KF5-KDE4 compability
#ifdef BUILD_KDE4
#include <KGlobal>
#include <KStandardDirs>
#include <Plasma/DataContainer>
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QTextCodec>
#else
#include <QStandardPaths>
#endif /* BUILD_KDE4 */
Netctl::Netctl(QObject *parent, const QVariantList &args)
@ -31,22 +44,41 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
{
Q_UNUSED(args)
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
if (debugEnv == QString("yes"))
debug = true;
else
debug = false;
setMinimumPollingInterval(333);
readConfiguration();
initSources();
}
Netctl::~Netctl()
{
if (debug) qDebug() << PDEBUG;
}
QStringList Netctl::sources() const
{
QStringList sources;
if (debug) qDebug() << PDEBUG;
sources.append(QString("currentProfile"));
sources.append(QString("extIp"));
QStringList sources;
sources.append(QString("active"));
sources.append(QString("current"));
sources.append(QString("extip4"));
sources.append(QString("extip6"));
sources.append(QString("interfaces"));
sources.append(QString("intIp"));
sources.append(QString("intip4"));
sources.append(QString("intip6"));
sources.append(QString("netctlauto"));
sources.append(QString("profiles"));
sources.append(QString("statusBool"));
sources.append(QString("statusString"));
sources.append(QString("status"));
return sources;
}
@ -54,207 +86,279 @@ QStringList Netctl::sources() const
void Netctl::readConfiguration()
{
// default configuration
QMap<QString, QString> rawConfig;
rawConfig[QString("CMD")] = QString("/usr/bin/netctl");
rawConfig[QString("EXTIP")] = QString("false");
rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
rawConfig[QString("IPCMD")] = QString("/usr/bin/ip");
rawConfig[QString("NETDIR")] = QString("/sys/class/net/");
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
if (debug) qDebug() << PDEBUG;
QString fileName;
#ifdef BUILD_KDE4
fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-netctl.conf");
#else
fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-netctl.conf"));
#endif /* BUILD_KDE4 */
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
settings.beginGroup(QString("Netctl commands"));
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl")).toString();
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto")).toString();
settings.endGroup();
settings.beginGroup(QString("External IP"));
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false")).toString();
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com")).toString();
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false")).toString();
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com")).toString();
settings.endGroup();
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
QFile confFile(fileName);
if (!confFile.open(QIODevice::ReadOnly)) {
configuration = updateConfiguration(rawConfig);
return;
}
QString fileStr;
QStringList value;
while (true) {
fileStr = QString(confFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (!fileStr.contains(QChar('='))) continue;
value.clear();
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
value.append(fileStr.split(QChar('='))[i]);
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
if (confFile.atEnd())
break;
}
confFile.close();
configuration = updateConfiguration(rawConfig);
return;
}
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
{
QMap<QString, QString> config;
QString key, value;
// remove spaces and copy source map
for (int i=0; i<rawConfig.keys().count(); i++) {
key = rawConfig.keys()[i];
value = rawConfig[key];
key.remove(QChar(' '));
if ((key != QString("CMD")) &&
(key != QString("EXTIPCMD")) &&
(key != QString("IPCMD")) &&
(key != QString("NETCTLAUTOCMD")))
value.remove(QChar(' '));
config[key] = value;
}
return config;
}
bool Netctl::sourceRequestEvent(const QString &name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source name" << name;
return updateSourceEvent(name);
}
QString Netctl::getCurrentProfile(const QString cmd)
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto)
{
QProcess command;
QString profile = QString("");
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString cmd;
if (netctlAutoStatus)
cmd = cmdNetctlAuto;
else
cmd = cmdNetctl;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QStringList currentProfile;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i][0] == QChar('*')) {
profile = profileList[i];
break;
}
profile.remove(0, 1);
return profile;
if (profileList[i][0] == QChar('*'))
currentProfile.append(profileList[i]);
for (int i=0; i<currentProfile.count(); i++)
currentProfile[i].remove(0, 2);
return currentProfile;
}
QString Netctl::getExtIp(const QString cmd)
{
QProcess command;
QString extIp = QString("");
command.start(cmd);
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
extIp = cmdOutput.trimmed();
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
// test network connection
if (!isNetworkActive()) return QString("N\\A");
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
return extIp;
}
QStringList Netctl::getInterfaceList(const QString dir)
QStringList Netctl::getInterfaceList()
{
QStringList interfaceList;
if (QDir(dir).exists())
interfaceList = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
return interfaceList;
if (debug) qDebug() << PDEBUG;
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
QStringList interfacesList;
for (int i=0; i<rawList.count(); i++)
interfacesList.append(rawList[i].name());
return interfacesList;
}
QString Netctl::getIntIp(const QString cmd, const QString dir)
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
{
QProcess command;
QString intIp = QString("127.0.0.1/8");
QStringList interfaceList = getInterfaceList(dir);
for (int i=0; i<interfaceList.count(); i++)
if (interfaceList[i] != QString("lo")) {
command.start(cmd + QString(" addr show ") + interfaceList[i]);
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
QStringList deviceInfo = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int j=0; j<deviceInfo.count(); j++)
if (deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[0] == QString("inet"))
intIp = deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[1];
if (debug) qDebug() << PDEBUG;
QString intIp = QString("");
if (protocol == QAbstractSocket::IPv4Protocol)
intIp = QString("127.0.0.1/8");
else if (protocol == QAbstractSocket::IPv6Protocol)
intIp = QString("::1/128");
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
for (int i=0; i<rawList.count(); i++) {
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
if (rawList[i].protocol() == protocol) {
intIp = rawList[i].toString();
break;
}
}
return intIp;
}
QStringList Netctl::getProfileList(const QString cmd)
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
{
QProcess command;
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
if (debug) qDebug() << PDEBUG;
TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString status;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
if (cmdOutput.isEmpty()) {
netctlAutoStatus = false;
status = QString("false");
} else {
netctlAutoStatus = true;
status = QString("true");
}
return status;
}
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString cmd;
if (netctlAutoStatus)
cmd = cmdNetctlAuto;
else
cmd = cmdNetctl;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
profileList[i].remove(0, 1);
profileList[i].remove(0, 2);
return profileList;
}
bool Netctl::getProfileStatus(const QString cmd)
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
bool status = false;
QString cmdOutput = getCurrentProfile(cmd);
if (!cmdOutput.isEmpty())
status = true;
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QStringList status;
if (netctlAutoStatus)
status.append(QString("netctl-auto"));
else {
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
for (int i=0; i<profiles.count(); i++) {
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode == 0)
status.append(QString("enabled"));
else
status.append(QString("static"));
}
}
return status;
}
QString Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
QProcess command;
QString status = QString("static");
// check netctl-auto
if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
status = QString("netctl-auto");
else {
// check netctl
command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
command.waitForFinished(-1);
if (command.exitCode() == 0)
status = QString("enabled");
}
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString status = QString("false");
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
if (!currentProfile.isEmpty())
status = QString("true");
return status;
}
void Netctl::initSources()
{
if (debug) qDebug() << PDEBUG;
QStringList sourcesList = sources();
for (int i=0; i<sourcesList.count(); i++)
setData(sourcesList[i], QString("value"), QString("N\\A"));
}
bool Netctl::isNetworkActive()
{
if (debug) qDebug() << PDEBUG;
QString cmd = QString("ping -c 1 google.com");
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode == 0)
return true;
else
return false;
}
bool Netctl::updateSourceEvent(const QString &source)
{
QString key = QString("value");
QString value = QString("");
if (source == QString("currentProfile")) {
value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
if (value.isEmpty())
value = getCurrentProfile(configuration[QString("CMD")]);
}
else if (source == QString("extIp")) {
if (configuration[QString("EXTIP")] == QString("true"))
value = getExtIp(configuration[QString("EXTIPCMD")]);
}
else if (source == QString("interfaces")) {
value = getInterfaceList(configuration[QString("NETDIR")]).join(QChar(','));
}
else if (source == QString("intIp")) {
value = getIntIp(configuration[QString("IPCMD")], configuration[QString("NETDIR")]);
}
else if (source == QString("profiles")) {
value = getProfileList(configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
if (value.isEmpty())
value = getProfileList(configuration[QString("CMD")]).join(QChar(','));
}
else if (source == QString("statusBool")) {
if (getProfileStatus(configuration[QString("NETCTLAUTOCMD")]))
value = QString("true");
else if (getProfileStatus(configuration[QString("CMD")]))
value = QString("true");
else
value = QString("false");
}
else if (source == QString("statusString")) {
value = getProfileStringStatus(configuration[QString("CMD")],
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source name" << source;
QString value = QString("N\\A");
if (source == QString("active")) {
value = getStatus(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")]);
} else if (source == QString("current")) {
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")])
.join(QChar('|'));
} else if (source == QString("extip4")) {
if (configuration[QString("EXTIP4")] == QString("true"))
value = getExtIp(configuration[QString("EXTIP4CMD")]);
} else if (source == QString("extip6")) {
if (configuration[QString("EXTIP6")] == QString("true"))
value = getExtIp(configuration[QString("EXTIP6CMD")]);
} else if (source == QString("interfaces")) {
value = getInterfaceList().join(QChar(','));
} else if (source == QString("intip4")) {
value = getIntIp(QAbstractSocket::IPv4Protocol);
} else if (source == QString("intip6")) {
value = getIntIp(QAbstractSocket::IPv6Protocol);
} else if (source == QString("netctlauto")) {
value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]);
} else if (source == QString("profiles")) {
value = getProfileList(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")])
.join(QChar(','));
} else if (source == QString("status")) {
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")])
.join(QChar('|'));
}
setData(source, key, value);
setData(source, QString("value"), value);
return true;
}
#ifdef BUILD_KDE4
K_EXPORT_PLASMA_DATAENGINE(netctl, Netctl)
#else
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(netctl, Netctl, "plasma-dataengine-netctl.json")
#endif /* BUILD_KDE4 */
#include "netctl.moc"

View File

@ -19,6 +19,7 @@
#define NETCTL_DE_H
#include <Plasma/DataEngine>
#include <QAbstractSocket>
class Netctl : public Plasma::DataEngine
@ -27,13 +28,19 @@ class Netctl : public Plasma::DataEngine
public:
Netctl(QObject *parent, const QVariantList &args);
QString getCurrentProfile(const QString cmd);
~Netctl();
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
QString getExtIp(const QString cmd);
QStringList getInterfaceList(const QString dir);
QString getIntIp(const QString cmd, const QString dir);
QStringList getProfileList(const QString cmd);
bool getProfileStatus(const QString cmd);
QString getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
QStringList getInterfaceList();
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
bool isNetworkActive();
public slots:
void initSources();
protected:
bool sourceRequestEvent(const QString &name);
@ -41,11 +48,12 @@ protected:
QStringList sources() const;
private:
bool isNetctlAutoRunning();
bool netctlAutoStatus;
QString currentProfile;
// configuration
bool debug;
QMap<QString, QString> configuration;
void readConfiguration();
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
};

View File

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

View File

@ -10,11 +10,11 @@ X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_netctl
X-Plasma-EngineName=netctl
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Author=Evgeniy Alekseev
X-KDE-PluginInfo-Email=esalexeev@gmail.com
X-KDE-PluginInfo-Name=netctl
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid
X-KDE-PluginInfo-Website=http://arcanis.name/projects/netctl-gui/
X-KDE-PluginInfo-Category=Network
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPLv3

View File

@ -5,6 +5,7 @@ message (STATUS "Subproject ${SUBPROJECT}")
# set directories
set (SUBPROJECT_BINARY_DIR bin)
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set (SUBPROJECT_DOCS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/docs)
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
# executable path
@ -15,6 +16,7 @@ set (TARGETS "")
set (HEADERS "")
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
add_subdirectory (${SUBPROJECT_DOCS_DIR})
# build man
file (GLOB SUBPROJECT_MAN_IN *.1)
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
@ -22,3 +24,5 @@ configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MA
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT})

View File

@ -0,0 +1,115 @@
###########################################################################
# This file is part of netctl-gui #
# #
# netctl-gui is free software: you can redistribute it and/or #
# modify it under the terms of the GNU General Public License as #
# published by the Free Software Foundation, either version 3 of the #
# License, or (at your option) any later version. #
# #
# netctl-gui is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with netctl-gui. If not, see http://www.gnu.org/licenses/ #
###########################################################################
# variables
_netctl_gui_arglist=(
'--detached'
'--maximized'
'--minimized'
'--about'
'--netctl-auto'
'--settings'
'-e'
'--essid'
'-o'
'--open'
'-s'
'--select'
'-c'
'--config'
'-d'
'--debug'
'--default'
'--set-opts'
'-t'
'--tab'
'-v'
'--version'
'-i'
'--info'
'-h'
'--help'
)
_netctl_gui_settings=(
'CLOSE_HELPER'
'CLOSETOTRAY'
'CTRL_DIR'
'CTRL_GROUP'
'FORCE_SUDO'
'HELPER_PATH'
'HELPER_SERVICE'
'IFACE_DIR'
'LANGUAGE'
'NETCTL_PATH'
'NETCTLAUTO_PATH'
'NETCTLAUTO_SERVICE'
'PID_FILE'
'PREFERED_IFACE'
'PROFILE_DIR'
'RFKILL_DIR'
'SKIPCOMPONENTS'
'STARTTOTRAY'
'SUDO_PATH'
'SYSTEMCTL_PATH'
'SYSTRAY'
'USE_HELPER'
'WPACLI_PATH'
'WPASUP_PATH'
'WPA_DRIVERS'
)
_netctl_gui_tabs=(
'1'
'2'
'3'
)
_netctl_profiles() {
echo $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
# work block
_netctl_gui() {
COMPREPLY=()
wantfiles='-@(c|-config)'
wantprofiles='-@(o|-open|s|-select)'
wantsettings='-@(-set-opts)'
wantstring='-@(e|-essid)'
wanttabs='-@(t|-tab)'
_get_comp_words_by_ref cur prev words cword
if [[ $prev = $wantfiles ]]; then
_filedir
elif [[ $prev = $wantprofiles ]]; then
COMPREPLY=($(compgen -W '$(_netctl_profiles)' -- "$cur"))
elif [[ $prev = $wantsettings ]]; then
COMPREPLY=($(compgen -S ',' -W '${_netctl_gui_settings[@]}' -- "$cur"))
elif [[ $prev = $wantstring ]]; then
COMPREPLY=()
elif [[ $prev = $wanttabs ]]; then
COMPREPLY=($(compgen -W '${_netctl_gui_tabs[@]}' -- "$cur"))
else
COMPREPLY=($(compgen -W '${_netctl_gui_arglist[@]}' -- "$cur"))
fi
true
}
complete -F _netctl_gui netctl-gui

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -0,0 +1,381 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>netctl-gui DBus API desription</title>
<style type="text/css">
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 5px 10px;
border: 1px solid #000000;
};
td {
text-align: justify;
}
th {
text-align: center;
}
th.sub {
font-style: italic;
font-weight: normal;
}
small {
font-size: 70%;
}
</style>
</head>
<body>
<h1>netctl-gui DBus API description</h1>
<h3>Project version : @PROJECT_VERSION@</h3>
<ol>
<li><a href="#api">DBus API</a></li>
<li><a href="#helper">Helper API</a></li>
<li><a href="#ctrl">Helper ctrl API</a></li>
<li><a href="#netctl">Helper netctl API</a></li>
<li><a href="#gui">GUI API</a></li>
<li><a href="#netctlgui">GUI netctlgui API</a></li>
<li><a href="#links">External links</a></li>
</ol>
<h2><a href="#api" class="anchor" id="api"></a>DBus API</h2>
<table>
<tbody><tr>
<th>method</th>
<th>responce</th>
<th>run as root</th>
</tr>
<!-- helper service -->
<tr>
<th colspan="3"><a href="#helper" class="anchor" id="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th>
</tr>
<!-- /ctrl path -->
<tr>
<th colspan="3" class="sub"><a href="#ctrl" class="anchor" id="ctrl"></a><code>/ctrl</code> path</th>
</tr>
<!-- helper actions -->
<tr>
<td>bool Active()</td>
<td><code>true</code> if the helper is active</td>
<td>no</td>
</tr>
<tr>
<td>QString ApiDocs()</td>
<td>returns path to this API documentation</td>
<td>no</td>
</tr>
<tr>
<td>bool Close()</td>
<td><code>true</code> and closes the helper</td>
<td>no</td>
</tr>
<tr>
<td>QStringList FindSettings()</td>
<td>scans system and suggests the recommended configuration which will be used by the library</td>
<td>no</td>
</tr>
<tr>
<td>QString LibraryDocs()</td>
<td>returns path to the library documentation</td>
<td>no</td>
</tr>
<tr>
<td>QString Pony()</td>
<td>prints Pinkie Pie to stdout. Really, just try</td>
<td>no</td>
</tr>
<tr>
<td>QString SecurityDocs()</td>
<td>returns path to the security documentation</td>
<td>no</td>
</tr>
<tr>
<td>QStringList Settings()</td>
<td>current helper settings <code>KEY==VALUE</code></td>
<td>no</td>
</tr>
<tr>
<td>QStringList UIDs()</td>
<td>returns the helper process UIDs <code>[UID, EUID]</code></td>
<td>no</td>
</tr>
<tr>
<td>bool Update()</td>
<td>calls update the helper configuration. Returns <code>true</code></td>
<td>no</td>
</tr>
<!-- netctl actions -->
<tr>
<td>bool Enable(QString profile)</td>
<td>enables or disables the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool forceStart(QString profile)</td>
<td>force starts the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool forceStop(QString profile)</td>
<td>force stops the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool Reenable(QString profile)</td>
<td>reenables the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool Restart(QString profile)</td>
<td>restarts the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool Start(QString profile)</td>
<td>starts or stops the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool StopAll()</td>
<td>stops all active profiles. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool SwitchTo(QString profile)</td>
<td>switchs to the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool Create(QString profile, QStringList settingsList)</td>
<td>creates the profile with specified settings. Settings should be given in the format <code>KEY==VALUE</code>. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool Remove(QString profile)</td>
<td>removes the profile. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<!-- netctl-auto actions -->
<tr>
<td>bool autoDisableAll()</td>
<td>disables all profiles (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
<td>no?</td>
</tr>
<tr>
<td>bool autoEnable(QString profile)</td>
<td>enables or disables the profile (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
<td>no?</td>
</tr>
<tr>
<td>bool autoEnableAll()</td>
<td>enables all profiles (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
<td>no?</td>
</tr>
<tr>
<td>bool autoStart(QString profile)</td>
<td>switchs to the profile (netctl-auto). Returns <code>true</code> if action has been performed successfully</td>
<td>no?</td>
</tr>
<!-- netctl-auto service actions -->
<tr>
<td>bool autoServiceEnable()</td>
<td>enables or disables netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool autoServiceRestart()</td>
<td>restarts netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<tr>
<td>bool autoServiceStart()</td>
<td>starts or stops netctl-auto systemd service. Returns <code>true</code> if action has been performed successfully</td>
<td>yes</td>
</tr>
<!-- wpa_supplicant actions -->
<tr>
<td>QStringList WiFi()</td>
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
<td>yes</td>
</tr>
<!-- /netctl path -->
<tr>
<th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th>
</tr>
<!-- general information -->
<tr>
<td>QString ActiveProfile()</td>
<td>returns active profile from netctl or netctl-auto</td>
<td>no</td>
</tr>
<tr>
<td>QString ActiveProfileStatus()</td>
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td>
<td>no</td>
</tr>
<tr>
<td>QStringList Information()</td>
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
<td>no</td>
</tr>
<tr>
<td>QStringList ProfileList()</td>
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code></td>
<td>no</td>
</tr>
<tr>
<td>QStringList WirelessInterface()</td>
<td>returns wireless interfaces</td>
<td>no</td>
</tr>
<!-- netctl specific information -->
<tr>
<td>bool isProfileActive(QString profile)</td>
<td>returns <code>true</code> if the profile is active</td>
<td>no</td>
</tr>
<tr>
<td>bool isProfileEnabled(QString profile)</td>
<td>returns <code>true</code> if the profile is enabled</td>
<td>no</td>
</tr>
<!-- netctl-auto specific information -->
<tr>
<td>bool autoIsProfileActive(QString profile)</td>
<td>returns <code>true</code> if the profile is active (netctl-auto)</td>
<td>no</td>
</tr>
<tr>
<td>bool autoIsProfileEnabled(QString profile)</td>
<td>returns <code>true</code> if the profile is enabled (netctl-auto)</td>
<td>no</td>
</tr>
<tr>
<td>bool isNetctlAutoActive()</td>
<td>returns <code>true</code> if netctl-auto is active</td>
<td>no</td>
</tr>
<tr>
<td>bool isNetctlAutoEnabled()</td>
<td>returns <code>true</code> if netctl-auto is enabled</td>
<td>no</td>
</tr>
<!-- profile information -->
<tr>
<td>QStringList Profile(QString profile)</td>
<td>returns the profile settings in format <code>KEY==VALUE</code></td>
<td>no</td>
</tr>
<tr>
<td>QString ProfileByEssid(QString essid)</td>
<td>returns the profile name by the given ESSID or empty line</td>
<td>no</td>
</tr>
<tr>
<td>QString ProfileValue(QString profile, QString key)</td>
<td>returns value of the key by the given profile or empty line</td>
<td>no</td>
</tr>
<!-- gui service -->
<tr>
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
</tr>
<!-- /netctlgui path -->
<tr>
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
</tr>
<!-- gui actions -->
<tr>
<td>bool Active()</td>
<td><code>true</code> if the application is active</td>
<td>no</td>
</tr>
<tr>
<td>void ApiDocs()</td>
<td>opens this API documentation</td>
<td>no</td>
</tr>
<tr>
<td>bool Close()</td>
<td><code>true</code> and closes the application</td>
<td>no</td>
</tr>
<tr>
<td>QString Information()</td>
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
<td>no</td>
</tr>
<tr>
<td>void LibraryDocs()</td>
<td>opens the library documentation</td>
<td>no</td>
</tr>
<tr>
<td>QString Pony()</td>
<td>prints Pinkie Pie to stdout. Really, just try</td>
<td>no</td>
</tr>
<tr>
<td>bool Restore()</td>
<td><code>true</code> and restores the application</td>
<td>no</td>
</tr>
<tr>
<td>void SecurityDocs()</td>
<td>opens the security documentation</td>
<td>no</td>
</tr>
<tr>
<td>QStringList Settings()</td>
<td>current application settings <code>KEY==VALUE</code></td>
<td>no</td>
</tr>
<tr>
<td>bool ShowAbout()</td>
<td><code>true</code> and shows about window</td>
<td>no</td>
</tr>
<tr>
<td>bool ShowMain()</td>
<td><code>true</code> and shows main window</td>
<td>no</td>
</tr>
<tr>
<td>bool ShowNetctlAuto()</td>
<td><code>true</code> and shows netctl-auto window</td>
<td>no</td>
</tr>
<tr>
<td>bool ShowSettings()</td>
<td><code>true</code> and shows settings window</td>
<td>no</td>
</tr>
<tr>
<td>QStringList UIDs()</td>
<td>returns the application process UIDs <code>[UID, EUID]</code></td>
<td>no</td>
</tr>
<tr>
<td>QStringList VerboseInformation()</td>
<td>returns information in format <code>[isNetctlAutoActive, ProfileList, ActiveProfile, isProfileEnabled/autoIsProfileEnabled]</code></td>
<td>no</td>
</tr>
</table>
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
<ul>
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
</ul>
<small>
&copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
This software is licensed under @PROJECT_LICENSE@
</small>
</body>
</html>

View File

@ -0,0 +1,112 @@
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>netctl-gui secutiry notes</title>
<style type="text/css">
img {
display: block;
margin: 0 auto;
}
small {
font-size: 70%;
}
</style>
</head>
<body>
<h1>netctl-gui security notes</h1>
<h3>Project version : @PROJECT_VERSION@</h3>
<ol>
<li><a href="#arch">Architecture</a></li>
<li><a href="#library">Library</a></li>
<li><a href="#helper">Helper</a></li>
<li><a href="#gui">Graphical interface</a></li>
<li><a href="#kde">KDE components</a></li>
<li><a href="#links">External links</a></li>
</ol>
<h2><a href="#description" class="anchor" id="description"></a>Description</h2>
<p></p>
<h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
<img src="architecture.png" alt="architecture">
<h2><a href="#library" class="anchor" id="library"></a>Library</h2>
<p>According to <a href="#arch">the scheme</a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
<ul>
<li>Netctl control module</li>
<li><ul>
<li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable &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>
</ul></li>
<li>Netctl profiles module</li>
<li><ul>
<li>Copying of a temporary profile from home directory to netctl profiles directory. <code>cp</code> command is used for it.</li>
<li>Removal of a profile. <code>rm</code> command is used for it.</li>
</ul></li>
<li>WiFi module</li>
<li><ul>
<li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
</ul></li>
</ul>
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
<p>Profiles reading should be described. Since profiles has shell-like syntax some variables (which provide an array) cannot be reading by usual ways. To do it library uses bash:</p>
<pre>
# define system variables
env -i bash -c "set"
# get profile and system variable list
env -i bash -c "source '&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>By default <code>netctgui-helper</code> binary has capabilities to set UID to the children processes (<code>CAP_SETUID</code>). If you do not want to get these capabilities you may use <code>-DUSE_CAPABILITIES</code> cmake flag. Please refer to <code>man 7 capabilities</code> for more details.</p>
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
<h2><a href="#gui" class="anchor" id="gui"></a>Graphical interface</h2>
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
<h2><a href="#kde" class="anchor" id="kde"></a>KDE components</h2>
<p>There are two netctl-based commands which are run from the DataEngine</p>
<ul>
<li><code>&lt;cmd&gt; list</code></li>
<li><code>netctl is-enabled &lt;profile&gt;</code></li>
</ul>
<p>Both of them do not require any additional privileges normally. Also DataEngine has two other command which will be run from; they should define external IP. According to the idea that user can set <b>any</b> command to run, this module is not secure. But running commands will not do more than user can do from console himself.</p>
<p>The widget gets information from DataEngine, thus it does not require any additional permissions to show information. But netctl calls are used to control netctl. In this case used commands are</p>
<ul>
<li><code>netctl enable &lt;profile&gt;</code></li>
<li><code>netctl disable &lt;profile&gt;</code></li>
<li><code>netctl restart &lt;profile&gt;</code></li>
<li><code>netctl start &lt;profile&gt;</code></li>
<li><code>netctl stop &lt;profile&gt;</code></li>
<li><code>netctl stop-all</code></li>
<li><code>netctl switch-to &lt;profile&gt;</code></li>
<li><code>netctl-auto switch-to &lt;profile&gt;</code></li>
</ul>
<p>All netctl-based commands <b>require</b> root privileges and <code>sudo</code> (and any other alternatives) is used normally as prefix to the commands. The netctl-auto command <b>does not require</b> additional permissions.</p>
<p>The other way is to use DBus communication with <a href="#helper">the helper</a>. In this case user should have rights to start the helper.</p>
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
<ul>
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
</ul>
<small>
&copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
This software is licensed under @PROJECT_LICENSE@
</small>
</body>
</html>

Binary file not shown.

View File

@ -1,63 +1,78 @@
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "USER COMMANDS"
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "General Commands Manual"
.SH NAME
netctl-gui is a graphical interface for netctl
.SH SYNOPSIS
.B netctl-gui
[ --about ] [ --netctl-auto ] [ --settings ]
[ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]
[ -s PROFILE | --select PROFILE ]
[ --config FILE ] [ -d | --debug ] [ --default ]
[ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]
[ -v | --version ] [ -i | --info ] [ -h | --help]
[ options ]
.SH DESCRIPTION
Graphical user interface for netctl written on C++ using Qt toolkit. Provides shared library for interaction with netctl and Plasmoid and DataEngine for KDE.
.B netctl-gui
is a project which provides graphical user interface for
.B netctl
written on C++ using Qt toolkit. It provides shared library and DBus API (through helper daemon) and Plasmoid and DataEngine for KDE.
.SH OPTIONS
.TP
--about
.IP "--detached"
run detached from console
.IP "--maximized"
run maximized
.IP "--minimized"
run to system tray if it is available
.IP "--about"
show about window
.TP
--netctl-auto
.IP "--netctl-auto"
show netctl-auto window
.TP
--settings
.IP "--settings"
show settings window
.TP
-e, --essid ESSID
select ESSID ESSID. This option will set tab to 3 automatically
.TP
-o, --open PROFILE
open profile PROFILE. This option will set tab to 2 automatically
.TP
-s, --select PROFILE
select profile PROFILE. This option will set tab to 1 automatically
.TP
--config FILE
read configuration from file FILE
.TP
-d, --debug
.IP "-e, --essid ESSID"
select ESSID
.I ESSID
This option will set tab to 3 automatically
.IP "-o, --open PROFILE"
open profile
.I PROFILE
This option will set tab to 2 automatically
.IP "-s, --select PROFILE"
select profile
.I PROFILE
This option will set tab to 1 automatically
.IP "-c, --config FILE"
read configuration from file
.I FILE
.IP "-d, --debug"
print debug information
.TP
--default
.IP "--default"
start with default settings
.TP
--set-opts OPTIONS
set options OPTIONS for this run, comma separated. Example "LANGUAGE=en,NETCTL_PATH=/usr/bin/netctl"
.TP
-t, --tab NUM
open a tab with number NUM
.TP
-v, --version
.IP "--set-opts OPTIONS"
set options
.I OPTIONS
for this run, comma separated. Example:
.nf
LANGUAGE=en,NETCTL_PATH=/path/to/ponies
.fi
.IP "-t, --tab NUM"
open a tab with number
.I NUM
.IP "-v, --version"
show version and exit
.TP
-i, --info
.IP "-i, --info"
show build information and exit
.TP
-h, --help
.IP "-h, --help"
show this help and exit
.SH FILES
.TP
$HOME/.config/netctl-gui.conf
.I $HOME/.config/netctl-gui.conf
.RS
Configuration file
.RE
.SH SEE ALSO
.BR netctlgui-helper (1)
.BR netctl-gui.conf (5)
.SH STANDARDS
See
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html
for more details.
.SH SECURITY CONSIDERATIONS
See
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html
for more details.
.SH AUTHOR
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
.SH LICENSE

View File

@ -1,7 +1,7 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Netctl GUI
Comment=GUI written on Qt4 for netctl
Comment=Qt graphical user interface for netctl
Exec=netctl-gui
Icon=netctl-gui.png
Terminal=false

View File

@ -1,7 +1,9 @@
# set files
file (GLOB SOURCES *.cpp)
file (GLOB HEADERS *.h)
file (GLOB FORMS *.ui)
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
${PROJECT_TRDPARTY_DIR}/language/*.cpp)
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
${PROJECT_TRDPARTY_DIR}/language/*.h)
file (GLOB_RECURSE FORMS *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
@ -11,61 +13,48 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/includ
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR})
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_TRDPARTY_DIR})
link_directories (${PROJECT_LIBRARY}/src/lib)
if (USE_QT5)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5LinguistTools_DEFINITIONS})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_wrap_ui (UI_HEADERS ${FORMS})
qt5_add_resources (QRC_SOURCES ${RESOURCES})
find_package (Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_wrap_ui (UI_HEADERS ${FORMS})
qt5_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
else ()
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
include (${QT_USE_FILE})
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
endif()
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)

View File

@ -1,105 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QWidget" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>290</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_description">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_name">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_version">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="spacer_about">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_links">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_license">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -22,6 +22,8 @@
#include <QDialogButtonBox>
#include <QPushButton>
#include <pdebug/pdebug.h>
#include "version.h"
@ -38,7 +40,7 @@ AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
AboutWindow::~AboutWindow()
{
if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]";
if (debug) qDebug() << PDEBUG;
delete uiAbout;
delete ui;
@ -47,45 +49,58 @@ AboutWindow::~AboutWindow()
void AboutWindow::createText()
{
if (debug) qDebug() << "[AboutWindow]" << "[createText]";
if (debug) qDebug() << PDEBUG;
// 1st tab
uiAbout->label_name->setText(QString(NAME));
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(QApplication::translate("AboutWindow", "Homepage")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(QApplication::translate("AboutWindow", "Repository")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(QApplication::translate("AboutWindow", "Bugtracker")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(QApplication::translate("AboutWindow", "Translation issue")) +\
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES)).arg(QApplication::translate("AboutWindow", "AUR packages")));
uiAbout->label_license->setText(QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE))
.arg(QApplication::translate("AboutWindow", "Homepage")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY))
.arg(QApplication::translate("AboutWindow", "Repository")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER))
.arg(QApplication::translate("AboutWindow", "Bugtracker")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION))
.arg(QApplication::translate("AboutWindow", "Translation issue")) +\
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES))
.arg(QApplication::translate("AboutWindow", "AUR packages")));
uiAbout->label_license->setText(QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>")
.arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) +
QString("</small>"));
// 2nd tab
QStringList trdPartyList = QString(TRDPARTY_LICENSE).split(QChar(';'), QString::SkipEmptyParts);
for (int i=0; i<trdPartyList.count(); i++)
trdPartyList[i] = QString("<a href=\"%3\">%1</a> (%2 license)")
.arg(trdPartyList[i].split(QChar(','))[0])
.arg(trdPartyList[i].split(QChar(','))[1])
.arg(trdPartyList[i].split(QChar(','))[2]);
uiAbout->label_translators->setText(QApplication::translate("AboutWindow", "Translators: %1").arg(QString(TRANSLATORS)));
uiAbout->label_trdparty->setText(QApplication::translate("AboutWindow", "This software uses: %1").arg(trdPartyList.join(QString(", "))));
}
void AboutWindow::createUi()
{
if (debug) qDebug() << "[AboutWindow]" << "[createUi]";
if (debug) qDebug() << PDEBUG;
QWidget *aboutWidget = new QWidget();
uiAbout = new Ui::About;
uiAbout->setupUi(aboutWidget);
ui->verticalLayout->addWidget(aboutWidget);
ui->verticalLayout->insertWidget(0, aboutWidget);
createText();
QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(QDialogButtonBox::Close);
ui->verticalLayout->addWidget(buttonBox);
connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
}
// ESC press event
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]";
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Escape)
close();

View File

@ -6,15 +6,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>307</height>
<width>516</width>
<height>431</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"/>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>

View File

@ -0,0 +1,107 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "dbusoperation.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDebug>
#include <pdebug/pdebug.h>
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
const bool debug)
{
if (debug) qDebug() << PDEBUG;
QList<netctlProfileInfo> profileInfo;
if (raw.size() == 0) return profileInfo;
QStringList list = raw[0].toStringList();
for (int i=0; i<list.count(); i++) {
QStringList info = list[i].split(QChar('|'));
if (info.count() != 4) continue;
netctlProfileInfo profile;
profile.name = info[0];
profile.description = info[1];
profile.active = info[2].toInt();
profile.enabled = info[3].toInt();
profileInfo.append(profile);
}
return profileInfo;
}
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
const bool debug)
{
if (debug) qDebug() << PDEBUG;
QList<netctlWifiInfo> wifiInfo;
if (raw.size() == 0) return wifiInfo;
QStringList list = raw[0].toStringList();
for (int i=0; i<list.count(); i++) {
QStringList info = list[i].split(QChar('|'));
if (info.count() != 5) continue;
netctlWifiInfo wifi;
wifi.name = info[0];
wifi.security = info[1];
wifi.signal = info[2];
wifi.active = info[3].toInt();
wifi.exists = info[4].toInt();
wifiInfo.append(wifi);
}
return wifiInfo;
}
QList<QVariant> sendDBusRequest(const QString service, const QString path,
const QString interface, const QString cmd,
const QList<QVariant> args, const bool system,
const bool debug)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Service" << service;
if (debug) qDebug() << PDEBUG << ":" << "Path" << path;
if (debug) qDebug() << PDEBUG << ":" << "Interface" << interface;
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
QList<QVariant> arguments;
QDBusMessage response;
if (system) {
QDBusConnection bus = QDBusConnection::systemBus();
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
if (!args.isEmpty())
request.setArguments(args);
response = bus.call(request, QDBus::BlockWithGui);
} else {
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
if (!args.isEmpty())
request.setArguments(args);
response = bus.call(request, QDBus::BlockWithGui);
}
arguments = response.arguments();
if (arguments.size() == 0)
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
return arguments;
}

View File

@ -0,0 +1,36 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef DBUSOPERATION_H
#define DBUSOPERATION_H
#include <QList>
#include <QVariant>
#include <netctlgui/netctlgui.h>
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
const bool debug = false);
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
const bool debug = false);
QList<QVariant> sendDBusRequest(const QString service, const QString path,
const QString interface, const QString cmd,
const QList<QVariant> args = QList<QVariant>(),
const bool system = true, const bool debug = false);
#endif /* DBUSOPERATION_H */

View File

@ -22,6 +22,8 @@
#include <QSpacerItem>
#include <QDebug>
#include <pdebug/pdebug.h>
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
: debug(debugCmd)
@ -31,14 +33,15 @@ ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
ErrorWindow::~ErrorWindow()
{
if (debug) qDebug() << "[ErrorWindow]" << "[~ErrorWindow]";
if (debug) qDebug() << PDEBUG;
}
QStringList ErrorWindow::getMessage(const int mess)
QStringList ErrorWindow::getMessage(const int mess, const QString custom)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]";
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QString message, title;
switch(mess) {
@ -114,11 +117,17 @@ QStringList ErrorWindow::getMessage(const int mess)
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
break;
case 19:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not run helper");
break;
default:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
}
if (!custom.isEmpty())
message = custom;
QStringList fullMessage;
fullMessage.append(title);
@ -129,63 +138,30 @@ QStringList ErrorWindow::getMessage(const int mess)
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]";
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]" << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
QMessageBox::Icon icon;
switch(mess) {
case 1:
icon = QMessageBox::Critical;
break;
case 2:
icon = QMessageBox::Critical;
break;
case 3:
icon = QMessageBox::Critical;
break;
case 4:
icon = QMessageBox::Critical;
break;
case 5:
icon = QMessageBox::Critical;
break;
case 6:
icon = QMessageBox::Critical;
break;
case 7:
icon = QMessageBox::Critical;
break;
case 8:
icon = QMessageBox::Critical;
break;
case 9:
icon = QMessageBox::Critical;
break;
case 10:
icon = QMessageBox::Critical;
break;
case 11:
icon = QMessageBox::Critical;
break;
case 12:
icon = QMessageBox::Critical;
break;
case 13:
icon = QMessageBox::Critical;
break;
case 14:
icon = QMessageBox::Critical;
break;
case 15:
icon = QMessageBox::Critical;
break;
case 16:
icon = QMessageBox::Critical;
break;
case 17:
icon = QMessageBox::Critical;
break;
case 18:
case 19:
icon = QMessageBox::Critical;
break;
default:
@ -197,13 +173,14 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
}
void ErrorWindow::showWindow(const int mess, const QString sender)
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom)
{
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]";
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess;
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender;
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QStringList message = getMessage(mess);
QStringList message = getMessage(mess, custom);
QMessageBox messageBox;
messageBox.setText(message[0]);
messageBox.setInformativeText(message[1]);

View File

@ -33,11 +33,12 @@ public:
public slots:
void showWindow(const int mess = 0,
const QString sender = QString());
const QString sender = QString(),
const QString custom = QString());
private:
bool debug;
QStringList getMessage(const int mess);
QStringList getMessage(const int mess, const QString custom = QString());
QMessageBox::Icon getIcon(const int mess);
};

View File

@ -88,8 +88,7 @@ void EthernetWidget::showAdvanced()
if (ui->pushButton_ethernetAdvanced->isChecked()) {
ui->widget_ethernetAdvanced->setHidden(false);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
}
else {
} else {
ui->widget_ethernetAdvanced->setHidden(true);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
}

View File

@ -114,8 +114,7 @@ void GeneralWidget::showAdvanced()
if (ui->pushButton_generalAdvanced->isChecked()) {
ui->widget_generalAdvanced->setHidden(false);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
}
else {
} else {
ui->widget_generalAdvanced->setHidden(true);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
}
@ -162,7 +161,9 @@ int GeneralWidget::isOk()
// bind interfaces is not set
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
(ui->comboBox_connection->currentText() == QString("vlan")))
(ui->comboBox_connection->currentText() == QString("vlan")) ||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
if (ui->listWidget_bindto->count() == 0)
return 1;
// empty description

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>429</width>
<height>535</height>
<width>425</width>
<height>531</height>
</rect>
</property>
<property name="windowTitle">
@ -123,6 +123,11 @@
<string notr="true">macvlan</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">openvswitch</string>
</property>
</item>
</widget>
</item>
</layout>

View File

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

View File

@ -315,8 +315,7 @@ void IpWidget::ipEnable(const int state)
ui->comboBox_ip->setDisabled(true);
ui->widget_ip->setDisabled(true);
ui->widget_ipRoutes->setDisabled(true);
}
else {
} else {
ui->comboBox_ip->setEnabled(true);
ui->widget_ip->setEnabled(true);
ui->widget_ipRoutes->setEnabled(true);
@ -341,8 +340,7 @@ void IpWidget::ip6Enable(const int state)
ui->comboBox_ip6->setDisabled(true);
ui->widget_ip6->setDisabled(true);
ui->widget_ipRoutes6->setDisabled(true);
}
else {
} else {
ui->comboBox_ip6->setEnabled(true);
ui->widget_ip6->setEnabled(true);
ui->widget_ipRoutes6->setEnabled(true);
@ -355,8 +353,7 @@ void IpWidget::changeDhcpClient(const QString currentText)
if (currentText == QString("dhcpcd")) {
ui->widget_dhcpcdOpt->setHidden(false);
ui->widget_dhclientOpt->setHidden(true);
}
else if (currentText == QString("dhclient")) {
} else if (currentText == QString("dhclient")) {
ui->widget_dhcpcdOpt->setHidden(true);
ui->widget_dhclientOpt->setHidden(false);
}
@ -368,8 +365,7 @@ void IpWidget::showAdvanced()
if (ui->pushButton_ipAdvanced->isChecked()) {
ui->widget_ipAdvanced->setHidden(false);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
}
else {
} else {
ui->widget_ipAdvanced->setHidden(true);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
}
@ -398,8 +394,7 @@ QMap<QString, QString> IpWidget::getSettings()
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
ipSettings[QString("Routes")] = routes.join(QChar(' '));
}
}
else
} else
ipSettings[QString("IP")] = QString("no");
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
@ -417,8 +412,7 @@ QMap<QString, QString> IpWidget::getSettings()
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
}
}
else
} else
ipSettings[QString("IP6")] = QString("no");
if (ui->listWidget_custom->count() > 0) {
QStringList custom;
@ -433,8 +427,7 @@ QMap<QString, QString> IpWidget::getSettings()
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'");
}
else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
} else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");

View File

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

View File

@ -17,259 +17,178 @@
#include <QApplication>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDir>
#include <QLibraryInfo>
#include <QTranslator>
#include <iostream>
#include <unistd.h>
#include <language/language.h>
#include "language.h"
#include "mainwindow.h"
#include "messages.h"
#include "version.h"
using namespace std;
QChar isParametrEnable(const bool parametr)
bool existingSessionOperation(const QString operation)
{
if (parametr)
return QChar('*');
else
return QChar(' ');
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
DBUS_INTERFACE, operation);
QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments();
return (!arguments.isEmpty() && bool(arguments[0].toInt()));
}
unsigned int getUidFromSession(const int type = 0)
{
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
DBUS_INTERFACE, QString("UIDs"));
QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments();
return arguments[0].toStringList()[type].toUInt();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMap<QString, QVariant> args = getArgs();
// reading
for (int i=1; i<argc; i++) {
if (QString(argv[i]) == QString("--detached")) {
// detached
args[QString("detached")] = true;
} else if (QString(argv[i]) == QString("--maximized")) {
// maximized
args[QString("minimized")] = (int) 1;
} else if (QString(argv[i]) == QString("--minimized")) {
// minimized
args[QString("minimized")] = (int) 2;
} else if (QString(argv[i]) == QString("--about")) {
// about
args[QString("about")] = true;
} else if (QString(argv[i]) == QString("--netctl-auto")) {
// netctl-auto
args[QString("auto")] = true;
} else if (QString(argv[i]) == QString("--settings")) {
// settings
args[QString("settings")] = true;
} else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
// select ESSID
args[QString("essid")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
// open profile
args[QString("open")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
// select profile
args[QString("select")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) {
// config path
args[QString("config")] = QDir().absoluteFilePath(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
// debug
args[QString("debug")] = true;
} else if (QString(argv[i]) == QString("--default")) {
// default settings
args[QString("default")] = true;
} else if (QString(argv[i]) == QString("--set-opts")) {
// options
args[QString("options")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
// tab number
if (atoi(argv[i+1]) > 3)
args[QString("tab")] = (int) 3;
else if (atoi(argv[i+1]) < 1)
args[QString("tab")] = (int) 1;
else
args[QString("tab")] = atoi(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
// help message
args[QString("help")] = true;
} else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
// info message
args[QString("info")] = true;
} else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
// version message
args[QString("version")] = true;
} else {
args[QString("error")] = true;
}
}
if ((args[QString("debug")].toBool()) ||
(args[QString("help")].toBool()) ||
(args[QString("info")].toBool()) ||
(args[QString("version")].toBool()) ||
(args[QString("error")].toBool()))
args[QString("detached")] = false;
if (args[QString("essid")].toString() != QString("ESSID"))
args[QString("tab")] = (int) 3;
if (args[QString("open")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 2;
if (args[QString("select")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 1;
// translation
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
QDir::separator() + QString("netctl-gui.conf");
QString language = Language::defineLanguage(configPath);
// detach from console
if (args[QString("detached")].toBool())
daemon(0, 0);
QApplication a(argc, argv);
QApplication::setQuitOnLastWindowClosed(false);
// reread translations according to flags
QString language = Language::defineLanguage(args[QString("config")].toString(),
args[QString("options")].toString());
QTranslator qtTranslator;
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator);
QTranslator translator;
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
// reading command line flags
bool error = false;
// windows
bool showAbout = false;
bool showNetctlAuto = false;
bool showSettings = false;
// main functions
QString selectEssid = QString("ESSID");
QString openProfile = QString("PROFILE");
QString selectProfile = QString("PROFILE");
// additional functions
bool debug = false;
bool defaultSettings = false;
QString options = QString("OPTIONS");
int tabNumber = 1;
// messages
bool showVersion = false;
bool showInfo = false;
bool showHelp = false;
// reading
for (int i=1; i<argc; i++) {
// windows
// about
if (QString(argv[i]) == QString("--about")) {
showAbout = true;
}
// netctl-auto
else if (QString(argv[i]) == QString("--netctl-auto")) {
showNetctlAuto = true;
}
// settings
else if (QString(argv[i]) == QString("--settings")) {
showSettings = true;
}
// main functions
// select ESSID
else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
selectEssid = QString(argv[i+1]);
i++;
}
// open profile
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
openProfile = QString(argv[i+1]);
i++;
}
// select profile
else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
selectProfile = QString(argv[i+1]);
i++;
}
// additional functions
// config path
else if (QString(argv[i]) == QString("--config")) {
configPath = QString(argv[i+1]);
i++;
}
// debug
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
debug = true;
}
// default settings
else if (QString(argv[i]) == QString("--default")) {
defaultSettings = true;
}
// options
else if (QString(argv[i]) == QString("--set-opts")) {
options = QString(argv[i+1]);
i++;
}
// tab number
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
if (atoi(argv[i+1]) > 3)
tabNumber = 3;
else if (atoi(argv[i+1]) < 1)
tabNumber = 1;
else
tabNumber = atoi(argv[i+1]);
i++;
}
// messages
// version message
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
showVersion = true;
}
// info message
else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
showInfo = true;
}
// help message
else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
showHelp = true;
}
else {
error = true;
}
}
if (selectEssid != QString("ESSID"))
tabNumber = 3;
if (openProfile != QString("PROFILE"))
tabNumber = 2;
if (selectProfile != QString("PROFILE"))
tabNumber = 1;
// messages
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
QString helpMessage = QString("");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
helpMessage += QString(" [ --config FILE ] [ -d | --debug ] [ --default ]\n");
helpMessage += QString(" [ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]\n");
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
// windows
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString("%1 --about - %2\n")
.arg(isParametrEnable(showAbout))
.arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString("%1 --netctl-auto - %2\n")
.arg(isParametrEnable(showNetctlAuto))
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
helpMessage += QString("%1 --settings - %2\n")
.arg(isParametrEnable(showSettings))
.arg(QApplication::translate("MainWindow", "show settings window"));
// main functions
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e %1 --essid %1 - %2\n")
.arg(selectEssid, -10)
.arg(QApplication::translate("MainWindow", "select ESSID %1").arg(selectEssid));
helpMessage += QString(" -o %1 --open %1 - %2\n")
.arg(openProfile, -10)
.arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
helpMessage += QString(" -s %1 --select %1 - %2\n")
.arg(selectProfile, -10)
.arg(QApplication::translate("MainWindow", "select profile %1").arg(selectProfile));
// additional functions
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" --config %1\n")
.arg(configPath, -10);
helpMessage += QString(" - %1\n")
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
helpMessage += QString("%1 -d --debug - %2\n")
.arg(isParametrEnable(debug))
.arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString("%1 --default - %2\n")
.arg(isParametrEnable(defaultSettings))
.arg(QApplication::translate("MainWindow", "start with default settings"));
helpMessage += QString(" --set-opts %1\n")
.arg(options, -10);
helpMessage += QString(" - %1\n")
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" -t %1 --tab %1 - %2\n")
.arg(QString::number(tabNumber), -3)
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
// messages
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v --version - %1\n")
.arg(QApplication::translate("MainWindow", "show version and exit"));
helpMessage += QString(" -i --info - %1\n")
.arg(QApplication::translate("MainWindow", "show build information and exit"));
helpMessage += QString(" -h --help - %1\n")
.arg(QApplication::translate("MainWindow", "show this help and exit"));
QString infoMessage = QString("");
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
arg(QString(BUILD_DATE));
infoMessage += QString("\n%1\n").arg(QApplication::translate("MainWindow", "cmake flags:"));
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
infoMessage += QString("\t-DBUILD_DATAENGINE=%1 \\\n").arg(QString(PROJECT_BUILD_DATAENGINE));
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Version"))
.arg(QString(VERSION));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Author"))
.arg(QString(AUTHOR));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "License"))
.arg(QString(LICENSE));
// reread translations
a.removeTranslator(&translator);
language = Language::defineLanguage(configPath, options);
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
// running
if (error) {
cout << errorMessage.toUtf8().data() << endl;
cout << helpMessage.toUtf8().data();
if (args[QString("error")].toBool()) {
cout << errorMessage().toUtf8().data() << endl;
cout << helpMessage().toUtf8().data();
return 127;
}
if (showInfo) {
cout << versionMessage.toUtf8().data() << endl;
cout << infoMessage.toUtf8().data();
} else if (args[QString("help")].toBool()) {
cout << helpMessage().toUtf8().data();
return 0;
} else if (args[QString("info")].toBool()) {
cout << versionMessage().toUtf8().data() << endl;
cout << infoMessage().toUtf8().data();
return 0;
} else if (args[QString("version")].toBool()) {
cout << versionMessage().toUtf8().data();
return 0;
}
if (showHelp) {
cout << helpMessage.toUtf8().data();
return 0;
// check if exists
if (existingSessionOperation(QString("Active"))) {
if ((getuid() == getUidFromSession(0)) && (geteuid() == getUidFromSession(1))) {
// restore session
cout << QCoreApplication::translate("MainWindow", "Restore existing session.")
.toUtf8().data() << endl;
existingSessionOperation(QString("Restore"));
return 0;
} else if ((getuid() == getUidFromSession(0)) && (geteuid() != getUidFromSession(1))) {
cout << QCoreApplication::translate("MainWindow", "Close existing session.")
.toUtf8().data() << endl;
existingSessionOperation(QString("Close"));
}
}
if (showVersion) {
cout << versionMessage.toUtf8().data();
return 0;
}
MainWindow w(0,
showAbout, showNetctlAuto, showSettings,
selectEssid, openProfile, selectProfile,
configPath, debug, defaultSettings, options, tabNumber);
w.show();
MainWindow w(0, args, &qtTranslator, &translator);
return a.exec();
}

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,12 @@
#include <QApplication>
#include <QMainWindow>
#include <QShortcut>
#include <QTableWidgetItem>
#include <QToolBar>
#include <QToolButton>
#include <netctlgui/netctlgui.h>
class AboutWindow;
@ -31,17 +36,15 @@ class GeneralWidget;
class IpWidget;
class MacvlanWidget;
class MobileWidget;
class Netctl;
class NetctlAutoWindow;
class NetctlProfile;
class PasswdWidget;
class PppoeWidget;
class SettingsWindow;
class TrayIcon;
class TunnelWidget;
class TuntapWidget;
class VlanWidget;
class WirelessWidget;
class WpaSup;
namespace Ui {
class MainWindow;
@ -53,32 +56,57 @@ class MainWindow : public QMainWindow
public:
explicit MainWindow(QWidget *parent = 0,
const bool showAbout = false,
const bool showNetctlAuto = false,
const bool showSettings = false,
const QString selectEssid = QString("ESSID"),
const QString openProfile = QString("PROFILE"),
const QString selectProfile = QString("PROFILE"),
const QString configPath = QString(""),
const bool debugCmd = false,
const bool defaultSettings = false,
const QString options = QString("OPTIONS"),
const int tabNum = 1);
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
QTranslator *qtAppTranslator = 0,
QTranslator *appTranslator = 0);
~MainWindow();
QStringList printInformation();
QStringList printSettings();
QStringList printTrayInformation();
bool isHelperActive();
bool isHelperServiceActive();
protected:
void closeEvent(QCloseEvent *event);
public slots:
// actions from trayicon
void closeMainWindow();
void showAboutWindow();
void showMainWindow();
void showNetctlAutoWindow();
void showSettingsWindow();
// trayicon control slots
bool enableProfileSlot(const QString profile);
bool startProfileSlot(const QString profile);
bool stopAllProfilesSlot();
bool switchToProfileSlot(const QString profile);
bool restartProfileSlot(const QString profile);
// open docs
void showApi();
void showLibrary();
void showSecurityNotes();
// helper
bool forceStartHelper();
bool forceStopHelper();
bool startHelper();
// main
void setTab(int tab);
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
void updateMenu();
void updateTabs(const int tab);
void updateMenu(const int tab);
// wifi tab slots
void connectToUnknownEssid(const QString passwd);
void setHiddenName(const QString name);
private slots:
void reportABug();
// menu update slots
void setMenuActionsShown(const bool state = true);
void updateMenuMain();
void updateMenuProfile();
void updateMenuWifi();
void updateToolBars();
// tab update slots
void updateMainTab();
void updateProfileTab();
@ -86,11 +114,13 @@ private slots:
// main tab slots
void mainTabContextualMenu(const QPoint &pos);
void mainTabEditProfile();
void mainTabRemoveProfile();
void mainTabEnableProfile();
QStringList mainTabGetActiveProfiles();
void mainTabRemoveProfile();
void mainTabRestartProfile();
void mainTabStartProfile();
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
void mainTabStopAllProfiles();
void mainTabSwitchToProfile();
// profile tab slots
void profileTabChangeState(const QString current);
void profileTabClear();
@ -101,38 +131,52 @@ private slots:
void wifiTabContextualMenu(const QPoint &pos);
void wifiTabSetEnabled(const bool state);
void wifiTabStart();
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
private:
// ui
Ui::MainWindow *ui;
AboutWindow *aboutWin;
ErrorWindow *errorWin;
NetctlAutoWindow *netctlAutoWin;
PasswdWidget *passwdWid;
SettingsWindow *settingsWin;
BridgeWidget *bridgeWid;
EthernetWidget *ethernetWid;
GeneralWidget *generalWid;
IpWidget *ipWid;
MacvlanWidget *macvlanWid;
MobileWidget *mobileWid;
PppoeWidget *pppoeWid;
TunnelWidget *tunnelWid;
TuntapWidget *tuntapWid;
VlanWidget *vlanWid;
WirelessWidget *wirelessWid;
TrayIcon *trayIcon = nullptr;
QMap<QString, QShortcut *> appShortcuts;
QMap<QString, QAction *> toolBarActions;
QToolButton *actionMenu = nullptr;
QToolBar *actionToolBar = nullptr;
QToolBar *helpToolBar = nullptr;
QToolBar *mainToolBar = nullptr;
Ui::MainWindow *ui = nullptr;
AboutWindow *aboutWin = nullptr;
ErrorWindow *errorWin = nullptr;
NetctlAutoWindow *netctlAutoWin = nullptr;
PasswdWidget *passwdWid = nullptr;
SettingsWindow *settingsWin = nullptr;
BridgeWidget *bridgeWid = nullptr;
EthernetWidget *ethernetWid = nullptr;
GeneralWidget *generalWid = nullptr;
IpWidget *ipWid = nullptr;
MacvlanWidget *macvlanWid = nullptr;
MobileWidget *mobileWid = nullptr;
PppoeWidget *pppoeWid = nullptr;
TunnelWidget *tunnelWid = nullptr;
TuntapWidget *tuntapWid = nullptr;
VlanWidget *vlanWid = nullptr;
WirelessWidget *wirelessWid = nullptr;
// backend
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
Netctl *netctlCommand = nullptr;
NetctlProfile *netctlProfile = nullptr;
WpaSup *wpaCommand = nullptr;
bool checkExternalApps(const QString apps);
bool checkState(const QString state, const QString item);
bool checkHelperStatus();
QString checkStatus(const bool statusBool, const bool nullFalse = false);
void createActions();
void createDBusSession();
void createObjects();
void createToolBars();
void deleteObjects();
void keyPressEvent(QKeyEvent *pressedKey);
void setIconsToButtons();
bool debug;
QString configPath;
bool debug = false;
bool hiddenNetwork;
bool useHelper = true;
QTranslator *qtTranslator = nullptr;
QTranslator *translator = nullptr;
// configuration
QMap<QString, QString> configuration;
QMap<QString, QString> parseOptions(const QString options);

View File

@ -6,21 +6,59 @@
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<height>507</height>
<width>469</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>Netctl GUI</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<layout class="QVBoxLayout" name="centralLayout">
<item>
<layout class="QHBoxLayout" name="layout_menus">
<item>
<widget class="QPushButton" name="pushButton_menu">
<property name="styleSheet">
<string notr="true">border: none;</string>
</property>
<property name="text">
<string>Menu</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_action">
<property name="styleSheet">
<string notr="true">border: none;</string>
</property>
<property name="text">
<string>Actions</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_help">
<property name="styleSheet">
<string notr="true">border: none;</string>
</property>
<property name="text">
<string>Help</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_main">
<attribute name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</attribute>
<attribute name="title">
<string>Connect to profile</string>
</attribute>
@ -68,6 +106,9 @@
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
@ -90,72 +131,10 @@
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mainButtons">
<item>
<widget class="QPushButton" name="pushButton_mainRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainRestart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Restart</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_new">
@ -165,6 +144,11 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
</attribute>
<attribute name="title">
<string>Create a new profile</string>
</attribute>
@ -206,8 +190,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>96</width>
<height>26</height>
<width>437</width>
<height>368</height>
</rect>
</property>
<property name="sizePolicy">
@ -220,42 +204,15 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_newProfileButtons">
<item>
<widget class="QPushButton" name="pushButton_profileClear">
<property name="text">
<string>Clear</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_newProfileButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_profileSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_wifi">
<attribute name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
</attribute>
<attribute name="title">
<string>Connect to Wi-Fi</string>
<string>WiFi menu</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@ -285,6 +242,9 @@
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>5</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
@ -295,293 +255,46 @@
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Signal</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wifiButtons">
<item>
<widget class="QPushButton" name="pushButton_wifiRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_wifiButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_wifiStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionNetctlAuto"/>
<addaction name="actionSettings"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuActions">
<property name="title">
<string>Actions</string>
</property>
<addaction name="actionMainRefresh"/>
<addaction name="actionWifiRefresh"/>
<addaction name="actionProfileClear"/>
<addaction name="separator"/>
<addaction name="actionMainStart"/>
<addaction name="actionMainRestart"/>
<addaction name="actionMainEnable"/>
<addaction name="actionProfileLoad"/>
<addaction name="actionProfileSave"/>
<addaction name="actionWifiStart"/>
<addaction name="separator"/>
<addaction name="actionMainEdit"/>
<addaction name="actionMainRemove"/>
<addaction name="actionProfileRemove"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuMenu"/>
<addaction name="menuActions"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionSettings">
<property name="icon">
<iconset theme="configure">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionQuit">
<property name="icon">
<iconset theme="exit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionMainRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionMainStart">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start profile</string>
</property>
</action>
<action name="actionMainRestart">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Restart profile</string>
</property>
</action>
<action name="actionMainEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionMainEdit">
<property name="icon">
<iconset theme="edit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Edit profile</string>
</property>
</action>
<action name="actionMainRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionProfileClear">
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
</action>
<action name="actionWifiRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionProfileLoad">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Load profile</string>
</property>
</action>
<action name="actionProfileSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Save profile</string>
</property>
</action>
<action name="actionWifiStart">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start Wi-Fi</string>
</property>
</action>
<action name="actionProfileRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionNetctlAuto">
<property name="text">
<string>netctl-auto</string>
</property>
</action>
<action name="actionAbout">
<property name="icon">
<iconset theme="help-about"/>
</property>
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>tableWidget_main</tabstop>
<tabstop>pushButton_mainRefresh</tabstop>
<tabstop>pushButton_mainRestart</tabstop>
<tabstop>pushButton_mainStart</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>pushButton_profileClear</tabstop>
<tabstop>pushButton_profileSave</tabstop>
<tabstop>tableWidget_wifi</tabstop>
<tabstop>pushButton_wifiRefresh</tabstop>
<tabstop>pushButton_wifiStart</tabstop>
</tabstops>
<resources/>
<resources>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,176 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include <QApplication>
#include <QDir>
#include "messages.h"
#include "version.h"
QString errorMessage()
{
return QApplication::translate("MainWindow", "Unknown flag\n");
}
QMap<QString, QVariant> getArgs()
{
QMap<QString, QVariant> args;
// windows
args[QString("detached")] = false;
args[QString("minimized")] = (int) 0;
args[QString("about")] = false;
args[QString("auto")] = false;
args[QString("settings")] = false;
// main functions
args[QString("essid")] = QString("ESSID");
args[QString("open")] = QString("PROFILE");
args[QString("select")] = QString("PROFILE");
// additional functions
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf"));
args[QString("debug")] = false;
args[QString("defaults")] = false;
args[QString("options")] = QString("OPTIONS");
args[QString("tab")] = (int) 1;
// messages
args[QString("error")] = false;
args[QString("help")] = false;
args[QString("info")] = false;
args[QString("version")] = false;
return args;
}
QString helpMessage()
{
QString helpMessage = QString("");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
helpMessage += QString("netctl-gui [ options ]\n");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
// windows
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString(" --detached - %1\n")
.arg(QApplication::translate("MainWindow", "start detached from console"));
helpMessage += QString(" --maximized - %1\n")
.arg(QApplication::translate("MainWindow", "start maximized"));
helpMessage += QString(" --minimized - %1\n")
.arg(QApplication::translate("MainWindow", "start minimized to tray"));
helpMessage += QString(" --about - %1\n")
.arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString(" --netctl-auto - %1\n")
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
helpMessage += QString(" --settings - %1\n")
.arg(QApplication::translate("MainWindow", "show settings window"));
// main functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e, --essid <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "select this ESSID"));
helpMessage += QString(" -o, --open <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "open this profile"));
helpMessage += QString(" -s, --select <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "select this profile"));
// additional functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" -c, --config <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
helpMessage += QString(" -d, --debug - %1\n")
.arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString(" --default - %1\n")
.arg(QApplication::translate("MainWindow", "start with default settings"));
helpMessage += QString(" --set-opts <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" -t, --tab <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "open a tab with this number"));
// messages
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v, --version - %1\n")
.arg(QApplication::translate("MainWindow", "show version and exit"));
helpMessage += QString(" -i, --info - %1\n")
.arg(QApplication::translate("MainWindow", "show build information and exit"));
helpMessage += QString(" -h, --help - %1\n")
.arg(QApplication::translate("MainWindow", "show this help and exit"));
return helpMessage;
}
QString infoMessage()
{
QString infoMessage = QString("");
// build information
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
arg(QString(BUILD_DATE));
// cmake
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
// cmake properties
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "cmake properties"));
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1\n").arg(QString(CMAKE_BUILD_TYPE));
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1\n").arg(QString(CMAKE_INSTALL_PREFIX));
// components
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Components"));
infoMessage += QString("\t-DBUILD_DATAENGINE=%1\n").arg(QString(PROJECT_BUILD_DATAENGINE));
infoMessage += QString("\t-DBUILD_GUI=%1\n").arg(QString(PROJECT_BUILD_GUI));
infoMessage += QString("\t-DBUILD_HELPER=%1\n").arg(QString(PROJECT_BUILD_HELPER));
infoMessage += QString("\t-DBUILD_LIBRARY=%1\n").arg(QString(PROJECT_BUILD_LIBRARY));
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
// additional components
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Additional components"));
infoMessage += QString("\t-DBUILD_DOCS=%1\n").arg(QString(PROJECT_BUILD_DOCS));
infoMessage += QString("\t-DBUILD_TEST=%1\n").arg(QString(PROJECT_BUILD_TEST));
// project properties
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Project properties"));
infoMessage += QString("\t-DDBUS_SYSTEMCONF_PATH=%1\n").arg(QString(PROJECT_DBUS_SYSTEMCONF_PATH));
infoMessage += QString("\t-DSYSTEMD_SERVICE_PATH=%1\n").arg(QString(PROJECT_SYSTEMD_SERVICE_PATH));
infoMessage += QString("\t-DUSE_CAPABILITIES=%1\n").arg(QString(PROJECT_USE_CAPABILITIES));
infoMessage += QString("\t-DUSE_KDE4=%1\n").arg(QString(PROJECT_USE_KDE4));
infoMessage += QString("\t-DUSE_QT5=%1\n").arg(QString(PROJECT_USE_QT5));
// transport information
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
infoMessage += QString("\tDBUS_HELPER_SERVICE=%1\n").arg(QString(DBUS_HELPER_SERVICE));
infoMessage += QString("\tDBUS_HELPER_INTERFACE=%1\n").arg(QString(DBUS_HELPER_INTERFACE));
infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH));
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
// docs path
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Documentation"));
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
return infoMessage;
}
QString versionMessage()
{
QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Version"))
.arg(QString(VERSION));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Author"))
.arg(QString(AUTHOR));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "License"))
.arg(QString(LICENSE));
return versionMessage;
}

View File

@ -0,0 +1,34 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MESSAGES_H
#define MESSAGES_H
#include <QChar>
#include <QMap>
#include <QString>
#include <QVariant>
QString errorMessage();
QMap<QString, QVariant> getArgs();
QString helpMessage();
QString infoMessage();
QString versionMessage();
#endif /* MESSAGES_H */

View File

@ -89,8 +89,7 @@ void MobileWidget::showAdvanced()
if (ui->pushButton_mobileAdvanced->isChecked()) {
ui->widget_mobileAdvanced->setHidden(false);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
}
else {
} else {
ui->widget_mobileAdvanced->setHidden(true);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
}

View File

@ -20,7 +20,11 @@
#include <QDebug>
#include <netctlgui/netctlinteract.h>
#include <netctlgui/netctlgui.h>
#include <pdebug/pdebug.h>
#include "dbusoperation.h"
#include "version.h"
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
@ -28,7 +32,13 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
ui(new Ui::NetctlAutoWindow),
debug(debugCmd)
{
if (settings[QString("USE_HELPER")] == QString("true"))
useHelper = true;
else
useHelper = false;
ui->setupUi(this);
ui->tableWidget->setColumnHidden(2, true);
ui->tableWidget->setColumnHidden(3, true);
netctlCommand = new Netctl(debug, settings);
createActions();
@ -38,16 +48,31 @@ NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const Q
NetctlAutoWindow::~NetctlAutoWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[~NetctlAutoWindow]";
if (debug) qDebug() << PDEBUG;
delete ui;
delete netctlCommand;
}
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool)
return QApplication::translate("NetctlAutoWindow", "yes");
if (nullFalse)
return QString("");
else
return QApplication::translate("NetctlAutoWindow", "no");
}
void NetctlAutoWindow::createActions()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]";
if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
@ -75,7 +100,7 @@ void NetctlAutoWindow::createActions()
void NetctlAutoWindow::showWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
if (debug) qDebug() << PDEBUG;
netctlAutoUpdateTable();
@ -83,31 +108,103 @@ void NetctlAutoWindow::showWindow()
}
void NetctlAutoWindow::netctlAutoUpdateTable()
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto();
if (ui->tableWidget->currentItem() == 0)
return;
// create menu
QMenu menu(this);
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
startProfile->setIcon(QIcon::fromTheme("system-run"));
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
menu.addSeparator();
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
// set text
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
enableProfile->setVisible(false);
startProfile->setVisible(false);
} else {
enableProfile->setVisible(true);
startProfile->setVisible(true);
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
} else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
}
}
// actions
if (netctlCommand->isNetctlAutoEnabled())
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (action == startProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Switch to profile";
netctlAutoStartProfile();
} else if (action == enableProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
netctlAutoEnableProfile();
} else if (action == enableAllProfiles) {
if (debug) qDebug() << PDEBUG << ":" << "Enable all profiles";
netctlAutoEnableAllProfiles();
} else if (action == disableAllProfiles) {
if (debug) qDebug() << PDEBUG << ":" << "Disable all profiles";
netctlAutoDisableAllProfiles();
}
}
void NetctlAutoWindow::netctlAutoUpdateTable()
{
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
// actions
bool enabled = false;
bool running = false;
if (useHelper) {
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
QList<QVariant>(), true, debug)[0].toBool();
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool();
} else {
enabled = netctlCommand->isNetctlAutoEnabled();
running = netctlCommand->isNetctlAutoRunning();
}
if (enabled)
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true);
if (netctlCommand->isNetctlAutoRunning()) {
if (running) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionDisableAll->setVisible(true);
ui->actionEnableAll->setVisible(true);
ui->actionRestartService->setVisible(true);
}
else {
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionRestartService->setVisible(false);
} else {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionDisableAll->setVisible(false);
ui->actionEnableAll->setVisible(false);
ui->actionRestartService->setVisible(false);
netctlAutoRefreshButtons(0, 0);
return;
}
QList<netctlProfileInfo> profiles;
if (useHelper)
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true, debug), debug);
else
profiles = netctlCommand->getProfileListFromNetctlAuto();
ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1);
@ -124,45 +221,43 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
ui->tableWidget->setHorizontalHeaderLabels(headerList);
// create items
for (int i=0; i<profiles.count(); i++) {
// font
QFont font;
font.setBold(profiles[i].active);
font.setItalic(profiles[i].enabled);
// tooltip
QString toolTip = QString("");
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name);
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active));
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled));
// name
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i][0]));
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
if (profiles[i][2] == QString("*")) {
QFont font;
font.setBold(true);
ui->tableWidget->item(i, 0)->setFont(font);
}
else if (profiles[i][2] == QString("!")) {
QFont font;
font.setItalic(true);
ui->tableWidget->item(i, 0)->setFont(font);
}
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
ui->tableWidget->item(i, 0)->setFont(font);
// description
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
if (profiles[i][2] == QString("*")) {
// active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
else
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString("")));
if (profiles[i][2] == QString("!")) {
// disabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
else
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QString("")));
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
// active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
// enabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
ui->tableWidget->setSortingEnabled(true);
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
#if QT_VERSION >= 0x050000
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#else
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#endif
ui->tableWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
@ -171,68 +266,19 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
}
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
if (ui->tableWidget->currentItem() == 0)
return;
// create menu
QMenu menu(this);
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
startProfile->setIcon(QIcon::fromTheme("dialog-apply"));
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
menu.addSeparator();
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
// set text
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text() == QString("yes")) {
enableProfile->setVisible(false);
startProfile->setVisible(false);
}
else {
enableProfile->setVisible(true);
startProfile->setVisible(true);
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text() == QString("yes")) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
}
else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
}
}
// actions
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (action == startProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
netctlAutoStartProfile();
}
else if (action == enableProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
netctlAutoEnableProfile();
}
else if (action == enableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
netctlAutoEnableAllProfiles();
}
else if (action == disableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
netctlAutoDisableAllProfiles();
}
}
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoDisableAllProfiles())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoDisableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -243,13 +289,22 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
void NetctlAutoWindow::netctlAutoEnableProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableProfile]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoEnableProfile(profile))
bool status = false;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoEnable"),
args, true, debug)[0].toBool();
} else
status = netctlCommand->autoEnableProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -260,10 +315,17 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoEnableAllProfiles())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoEnableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -274,13 +336,22 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
void NetctlAutoWindow::netctlAutoStartProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartProfile]";
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoStartProfile(profile))
bool status = false;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoStart"),
args, true, debug)[0].toBool();
} else
status = netctlCommand->autoStartProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -291,9 +362,16 @@ void NetctlAutoWindow::netctlAutoStartProfile()
void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableService]";
if (debug) qDebug() << PDEBUG;
if (netctlCommand->autoEnableService())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoEnableService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -304,9 +382,16 @@ void NetctlAutoWindow::netctlAutoEnableService()
void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRestartService]";
if (debug) qDebug() << PDEBUG;
if (netctlCommand->autoRestartService())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoRestartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -317,9 +402,16 @@ void NetctlAutoWindow::netctlAutoRestartService()
void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartService]";
if (debug) qDebug() << PDEBUG;
if (netctlCommand->autoStartService())
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoStartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
@ -331,7 +423,7 @@ void NetctlAutoWindow::netctlAutoStartService()
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRefreshButtons]";
if (debug) qDebug() << PDEBUG;
if (current == 0) {
// buttons
@ -342,30 +434,28 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
ui->actionSwitch->setVisible(false);
return;
}
if (ui->tableWidget->item(current->row(), 2)->text() == QString("yes")) {
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
}
else {
} else {
// buttons
ui->pushButton_enable->setEnabled(true);
ui->pushButton_switch->setEnabled(true);
// menu
ui->actionEnable->setVisible(true);
ui->actionSwitch->setVisible(true);
if (ui->tableWidget->item(current->row(), 3)->text() == QString("yes")) {
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
}
else {
} else {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));

View File

@ -58,9 +58,11 @@ private slots:
void netctlAutoStartService();
private:
Netctl *netctlCommand;
Ui::NetctlAutoWindow *ui;
bool debug;
Netctl *netctlCommand = nullptr;
Ui::NetctlAutoWindow *ui = nullptr;
bool debug = false;
bool useHelper = true;
QString checkStatus(const bool statusBool, const bool nullFalse = false);
void createActions();
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>343</height>
<width>428</width>
<height>339</height>
</rect>
</property>
<property name="windowTitle">
@ -42,6 +42,9 @@
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
@ -58,16 +61,8 @@
<string>Description</string>
</property>
</column>
<column>
<property name="text">
<string>Active</string>
</property>
</column>
<column>
<property name="text">
<string>Disabled</string>
</property>
</column>
<column/>
<column/>
</widget>
</item>
<item>
@ -105,6 +100,9 @@
<property name="text">
<string>Enable</string>
</property>
<property name="icon">
<iconset theme="edit-add"/>
</property>
</widget>
</item>
<item>
@ -116,7 +114,7 @@
<string>Switch</string>
</property>
<property name="icon">
<iconset theme="dialog-apply">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
@ -131,7 +129,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<width>428</width>
<height>22</height>
</rect>
</property>
@ -168,7 +166,7 @@
</action>
<action name="actionSwitch">
<property name="icon">
<iconset theme="dialog-apply">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>

View File

@ -0,0 +1,142 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctlguiadaptor.h"
#include <QTextCodec>
#include <unistd.h>
#include "mainwindow.h"
NetctlGuiAdaptor::NetctlGuiAdaptor(MainWindow *parent)
: QDBusAbstractAdaptor(parent),
mainWindow(parent)
{
}
NetctlGuiAdaptor::~NetctlGuiAdaptor()
{
}
bool NetctlGuiAdaptor::Active()
{
return true;
}
void NetctlGuiAdaptor::ApiDocs()
{
return mainWindow->showApi();
}
bool NetctlGuiAdaptor::Close()
{
mainWindow->closeMainWindow();
return true;
}
QStringList NetctlGuiAdaptor::Information()
{
return mainWindow->printInformation();
}
void NetctlGuiAdaptor::LibraryDocs()
{
return mainWindow->showLibrary();
}
QString NetctlGuiAdaptor::Pony()
{
QString pony;
QFile ponyFile(QString(":pinkiepie"));
if (!ponyFile.open(QIODevice::ReadOnly))
return pony;
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
ponyFile.close();
return pony;
}
bool NetctlGuiAdaptor::Restore()
{
mainWindow->show();
return true;
}
void NetctlGuiAdaptor::SecurityDocs()
{
return mainWindow->showSecurityNotes();
}
QStringList NetctlGuiAdaptor::Settings()
{
return mainWindow->printSettings();
}
bool NetctlGuiAdaptor::ShowAbout()
{
mainWindow->showAboutWindow();
return true;
}
bool NetctlGuiAdaptor::ShowMain()
{
mainWindow->showMainWindow();
return true;
}
bool NetctlGuiAdaptor::ShowNetctlAuto()
{
mainWindow->showNetctlAutoWindow();
return true;
}
bool NetctlGuiAdaptor::ShowSettings()
{
mainWindow->showSettingsWindow();
return true;
}
QStringList NetctlGuiAdaptor::UIDs()
{
QStringList uids;
uids.append(QString::number(getuid()));
uids.append(QString::number(geteuid()));
return uids;
}
QStringList NetctlGuiAdaptor::VerboseInformation()
{
return mainWindow->printTrayInformation();
}

View File

@ -0,0 +1,58 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTLGUIADAPTOR_H
#define NETCTLGUIADAPTOR_H
#include <QDBusAbstractAdaptor>
#include <QStringList>
class MainWindow;
class NetctlGuiAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.netctlgui.netctlgui")
public:
explicit NetctlGuiAdaptor(MainWindow *parent = 0);
~NetctlGuiAdaptor();
public slots:
bool Active();
void ApiDocs();
bool Close();
QStringList Information();
void LibraryDocs();
QString Pony();
bool Restore();
void SecurityDocs();
QStringList Settings();
bool ShowAbout();
bool ShowMain();
bool ShowNetctlAuto();
bool ShowSettings();
QStringList UIDs();
QStringList VerboseInformation();
private:
MainWindow *mainWindow;
};
#endif /* NETCTLGUIADAPTOR_H */

View File

@ -66,8 +66,7 @@ void PasswdWidget::setPassword(const bool mode)
if (mode) {
ui->lineEdit->setEchoMode(QLineEdit::Password);
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
}
else {
} else {
ui->lineEdit->setEchoMode(QLineEdit::Normal);
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
}

View File

@ -117,8 +117,7 @@ void PppoeWidget::showAdvanced()
if (ui->pushButton_pppoeAdvanced->isChecked()) {
ui->widget_pppoeAdvanced->setHidden(false);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
}
else {
} else {
ui->widget_pppoeAdvanced->setHidden(true);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
}

View File

@ -22,8 +22,12 @@
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QSettings>
#include "language.h"
#include <language/language.h>
#include <pdebug/pdebug.h>
#include "mainwindow.h"
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
@ -40,7 +44,7 @@ SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QStri
SettingsWindow::~SettingsWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
if (debug) qDebug() << PDEBUG;
delete ui;
}
@ -48,33 +52,34 @@ SettingsWindow::~SettingsWindow()
void SettingsWindow::createActions()
{
if (debug) qDebug() << "[SettingsWindow]" << "[createActions]";
if (debug) qDebug() << PDEBUG;
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(restoreSettings()));
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
// buttons
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), SLOT(selectNetctlAutoPath()));
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath()));
connect(ui->pushButton_wpaActiondPath, SIGNAL(clicked(bool)), SLOT(selectWpaActiondPath()));
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_interfacesDir, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_status, SIGNAL(clicked(bool)), this, SLOT(startHelper()));
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
}
// ESC press event
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Escape)
close();
@ -83,7 +88,7 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
void SettingsWindow::addLanguages()
{
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
if (debug) qDebug() << PDEBUG;
ui->comboBox_language->clear();
ui->comboBox_language->addItems(Language::getAvailableLanguages());
@ -92,8 +97,8 @@ void SettingsWindow::addLanguages()
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous)
if (debug) qDebug() << "[SettingsWindow]" << "[changePage]";
Q_UNUSED(previous);
if (debug) qDebug() << PDEBUG;
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
if (current == ui->treeWidget->topLevelItem(i)) {
@ -103,173 +108,166 @@ void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previ
}
void SettingsWindow::closeWindow()
{
if (debug) qDebug() << PDEBUG;
saveSettings();
close();
((MainWindow *)parent())->updateConfiguration();
}
void SettingsWindow::saveSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings = readSettings();
QFile configFile(file);
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&configFile);
for (int i=0; i<settings.keys().count(); i++)
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
configFile.close();
QMap<QString, QString> config = readSettings();
QSettings settings(file, QSettings::IniFormat);
settings.beginGroup(QString("General"));
settings.setValue(QString("LANGUAGE"), config[QString("LANGUAGE")]);
settings.setValue(QString("SYSTRAY"), config[QString("SYSTRAY")]);
settings.setValue(QString("CLOSETOTRAY"), config[QString("CLOSETOTRAY")]);
settings.setValue(QString("STARTTOTRAY"), config[QString("STARTTOTRAY")]);
settings.setValue(QString("SKIPCOMPONENTS"), config[QString("SKIPCOMPONENTS")]);
settings.endGroup();
settings.beginGroup(QString("Helper"));
settings.setValue(QString("USE_HELPER"), config[QString("USE_HELPER")]);
settings.setValue(QString("FORCE_SUDO"), config[QString("FORCE_SUDO")]);
settings.setValue(QString("CLOSE_HELPER"), config[QString("CLOSE_HELPER")]);
settings.setValue(QString("HELPER_PATH"), config[QString("HELPER_PATH")]);
settings.setValue(QString("HELPER_SERVICE"), config[QString("HELPER_SERVICE")]);
settings.endGroup();
settings.beginGroup(QString("netctl"));
settings.setValue(QString("SYSTEMCTL_PATH"), config[QString("SYSTEMCTL_PATH")]);
settings.setValue(QString("NETCTL_PATH"), config[QString("NETCTL_PATH")]);
settings.setValue(QString("NETCTLAUTO_PATH"), config[QString("NETCTLAUTO_PATH")]);
settings.setValue(QString("NETCTLAUTO_PATH"), config[QString("NETCTLAUTO_PATH")]);
settings.setValue(QString("PROFILE_DIR"), config[QString("PROFILE_DIR")]);
settings.endGroup();
settings.beginGroup(QString("sudo"));
settings.setValue(QString("SUDO_PATH"), config[QString("SUDO_PATH")]);
settings.endGroup();
settings.beginGroup(QString("wpa_supplicant"));
settings.setValue(QString("WPASUP_PATH"), config[QString("WPASUP_PATH")]);
settings.setValue(QString("WPACLI_PATH"), config[QString("WPACLI_PATH")]);
settings.setValue(QString("PID_FILE"), config[QString("PID_FILE")]);
settings.setValue(QString("WPA_DRIVERS"), config[QString("WPA_DRIVERS")]);
settings.setValue(QString("CTRL_DIR"), config[QString("CTRL_DIR")]);
settings.setValue(QString("CTRL_GROUP"), config[QString("CTRL_GROUP")]);
settings.endGroup();
settings.beginGroup(QString("Other"));
settings.setValue(QString("IFACE_DIR"), config[QString("IFACE_DIR")]);
settings.setValue(QString("RFKILL_DIR"), config[QString("RFKILL_DIR")]);
settings.setValue(QString("PREFERED_IFACE"), config[QString("PREFERED_IFACE")]);
settings.endGroup();
settings.sync();
}
void SettingsWindow::setTray()
{
if (debug) qDebug() << PDEBUG;
if (ui->checkBox_enableTray->checkState() == 0) {
ui->checkBox_closeToTray->setDisabled(true);
ui->checkBox_startToTray->setDisabled(true);
} else if (ui->checkBox_enableTray->checkState() == 2) {
ui->checkBox_closeToTray->setEnabled(true);
ui->checkBox_startToTray->setEnabled(true);
}
}
void SettingsWindow::restoreSettings()
{
if (debug) qDebug() << PDEBUG;
setSettings(getSettings());
}
void SettingsWindow::setDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
if (debug) qDebug() << PDEBUG;
setSettings(getDefault());
saveSettings();
if (sender() != ui->buttonBox->button(QDialogButtonBox::Reset))
saveSettings();
}
void SettingsWindow::selectIfaceDir()
void SettingsWindow::selectAbstractSomething()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectIfaceDir]";
if (debug) qDebug() << PDEBUG;
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
QString("/sys/"));
if (!directory.isEmpty())
ui->lineEdit_interfacesDir->setText(directory);
}
bool isDir = false;
QString path = QString("/usr/bin");
QString text = QApplication::translate("SettingsWindow", "Select helper command");
QLineEdit *lineEdit = ui->lineEdit_helperPath;
if (sender() == ui->pushButton_helperPath) {
text = QApplication::translate("SettingsWindow", "Select helper command");
lineEdit = ui->lineEdit_helperPath;
} else if (sender() == ui->pushButton_interfacesDir) {
isDir = true;
text = QApplication::translate("SettingsWindow", "Select path to directory with interfaces");
path = QString("/sys");
lineEdit = ui->lineEdit_interfacesDir;
} else if (sender() == ui->pushButton_netctlPath) {
text = QApplication::translate("SettingsWindow", "Select netctl command");
lineEdit = ui->lineEdit_netctlPath;
} else if (sender() == ui->pushButton_netctlAutoPath) {
text = QApplication::translate("SettingsWindow", "Select netctl-auto command");
lineEdit = ui->lineEdit_netctlAutoPath;
} else if (sender() == ui->pushButton_profilePath) {
isDir = true;
text = QApplication::translate("SettingsWindow", "Select path to profile directory");
path = QString("/etc");
lineEdit = ui->lineEdit_profilePath;
} else if (sender() == ui->pushButton_rfkill) {
isDir = true;
text = QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices");
path = QString("/sys");
lineEdit = ui->lineEdit_rfkill;
} else if (sender() == ui->pushButton_sudo) {
text = QApplication::translate("SettingsWindow", "Select sudo command");
lineEdit = ui->lineEdit_sudo;
} else if (sender() == ui->pushButton_systemctlPath) {
text = QApplication::translate("SettingsWindow", "Select systemctl command");
lineEdit = ui->lineEdit_systemctlPath;
} else if (sender() == ui->pushButton_wpaCliPath) {
text = QApplication::translate("SettingsWindow", "Select wpa_cli command");
lineEdit = ui->lineEdit_wpaCliPath;
} else if (sender() == ui->pushButton_wpaSupPath) {
text = QApplication::translate("SettingsWindow", "Select wpa_supplicant command");
lineEdit = ui->lineEdit_wpaSupPath;
}
void SettingsWindow::selectNetctlPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select netctl command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
QString filename;
if (isDir)
filename = QFileDialog::getExistingDirectory(this, text, path);
else
filename = QFileDialog::getOpenFileName(this, text, path,
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_netctlPath->setText(filename);
}
void SettingsWindow::selectNetctlAutoPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlAutoPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select netctl-auto command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_netctlAutoPath->setText(filename);
}
void SettingsWindow::selectProfileDir()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectProfileDir]";
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to profile directory"),
QString("/etc/"));
if (!directory.isEmpty())
ui->lineEdit_profilePath->setText(directory);
}
void SettingsWindow::selectRfkillDir()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectRfkillDir]";
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
QString("/sys/"));
if (!directory.isEmpty())
ui->lineEdit_rfkill->setText(directory);
}
void SettingsWindow::selectSudoPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectSudoPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select sudo command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_sudo->setText(filename);
}
void SettingsWindow::selectSystemctlPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectSystemctlPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select systemctl command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_systemctlPath->setText(filename);
}
void SettingsWindow::selectWpaActiondPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaActiondPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_actiond command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaActiondPath->setText(filename);
}
void SettingsWindow::selectWpaCliPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaCliPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaCliPath->setText(filename);
}
void SettingsWindow::selectWpaSupPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaSupPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaSupPath->setText(filename);
lineEdit->setText(filename);
}
void SettingsWindow::showWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
if (debug) qDebug() << PDEBUG;
setSettings(getSettings());
ui->label_info->hide();
setTray();
updateHelper();
show();
}
@ -277,116 +275,221 @@ void SettingsWindow::showWindow()
QMap<QString, QString> SettingsWindow::readSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
settings[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
settings[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
settings[QString("PID_FILE")] = ui->lineEdit_pid->text();
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
settings[QString("WPAACTIOND_PATH")] = ui->lineEdit_wpaActiondPath->text();
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
QMap<QString, QString> config;
return settings;
if (ui->checkBox_helperClose->checkState() == 2)
config[QString("CLOSE_HELPER")] = QString("true");
else
config[QString("CLOSE_HELPER")] = QString("false");
if (ui->checkBox_closeToTray->checkState() == 2)
config[QString("CLOSETOTRAY")] = QString("true");
else
config[QString("CLOSETOTRAY")] = QString("false");
config[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
config[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
if (ui->checkBox_forceSudo->checkState() == 2)
config[QString("FORCE_SUDO")] = QString("true");
else
config[QString("FORCE_SUDO")] = QString("false");
config[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
config[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
config[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
config[QString("LANGUAGE")] = ui->comboBox_language->currentText();
config[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
config[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
config[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
config[QString("PID_FILE")] = ui->lineEdit_pid->text();
config[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
config[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
config[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
if (ui->checkBox_components->checkState() == 2)
config[QString("SKIPCOMPONENTS")] = QString("true");
else
config[QString("SKIPCOMPONENTS")] = QString("false");
if (ui->checkBox_startToTray->checkState() == 2)
config[QString("STARTTOTRAY")] = QString("true");
else
config[QString("STARTTOTRAY")] = QString("false");
config[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
config[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
if (ui->checkBox_enableTray->checkState() == 2)
config[QString("SYSTRAY")] = QString("true");
else
config[QString("SYSTRAY")] = QString("false");
if (ui->checkBox_useHelper->checkState() == 2)
config[QString("USE_HELPER")] = QString("true");
else
config[QString("USE_HELPER")] = QString("false");
config[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
config[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
config[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") +
config[config.keys()[i]];
return config;
}
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
void SettingsWindow::setSettings(const QMap<QString, QString> config)
{
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
if (debug) qDebug() << PDEBUG;
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
if (config[QString("CLOSE_HELPER")] == QString("true"))
ui->checkBox_helperClose->setCheckState(Qt::Checked);
else
ui->checkBox_helperClose->setCheckState(Qt::Unchecked);
if (config[QString("CLOSETOTRAY")] == QString("true"))
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
else
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
ui->lineEdit_wpaDir->setText(config[QString("CTRL_DIR")]);
ui->lineEdit_wpaGroup->setText(config[QString("CTRL_GROUP")]);
if (config[QString("FORCE_SUDO")] == QString("true"))
ui->checkBox_forceSudo->setCheckState(Qt::Checked);
else
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
ui->lineEdit_helperPath->setText(config[QString("HELPER_PATH")]);
ui->lineEdit_helperService->setText(config[QString("HELPER_SERVICE")]);
ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]);
ui->comboBox_language->setCurrentIndex(0);
for (int i=0; i<ui->comboBox_language->count(); i++)
if (ui->comboBox_language->itemText(i) == settings[QString("LANGUAGE")])
if (ui->comboBox_language->itemText(i) == config[QString("LANGUAGE")]) {
ui->comboBox_language->setCurrentIndex(i);
ui->lineEdit_netctlPath->setText(settings[QString("NETCTL_PATH")]);
ui->lineEdit_netctlAutoPath->setText(settings[QString("NETCTLAUTO_PATH")]);
ui->lineEdit_netctlAutoService->setText(settings[QString("NETCTLAUTO_SERVICE")]);
ui->lineEdit_pid->setText(settings[QString("PID_FILE")]);
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
ui->lineEdit_wpaActiondPath->setText(settings[QString("WPAACTIOND_PATH")]);
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
break;
}
ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]);
ui->lineEdit_netctlAutoPath->setText(config[QString("NETCTLAUTO_PATH")]);
ui->lineEdit_netctlAutoService->setText(config[QString("NETCTLAUTO_SERVICE")]);
ui->lineEdit_pid->setText(config[QString("PID_FILE")]);
ui->lineEdit_interface->setText(config[QString("PREFERED_IFACE")]);
ui->lineEdit_profilePath->setText(config[QString("PROFILE_DIR")]);
ui->lineEdit_rfkill->setText(config[QString("RFKILL_DIR")]);
if (config[QString("SKIPCOMPONENTS")] == QString("true"))
ui->checkBox_components->setCheckState(Qt::Checked);
else
ui->checkBox_components->setCheckState(Qt::Unchecked);
if (config[QString("STARTTOTRAY")] == QString("true"))
ui->checkBox_startToTray->setCheckState(Qt::Checked);
else
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
ui->lineEdit_sudo->setText(config[QString("SUDO_PATH")]);
ui->lineEdit_systemctlPath->setText(config[QString("SYSTEMCTL_PATH")]);
if (config[QString("SYSTRAY")] == QString("true"))
ui->checkBox_enableTray->setCheckState(Qt::Checked);
else
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
if (config[QString("USE_HELPER")] == QString("true"))
ui->checkBox_useHelper->setCheckState(Qt::Checked);
else
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
ui->lineEdit_wpaCliPath->setText(config[QString("WPACLI_PATH")]);
ui->lineEdit_wpaSupPath->setText(config[QString("WPASUP_PATH")]);
ui->lineEdit_wpaSupDrivers->setText(config[QString("WPA_DRIVERS")]);
for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") +
config[config.keys()[i]];
}
QMap<QString, QString> SettingsWindow::getDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
settings[QString("CTRL_GROUP")] = QString("users");
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
settings[QString("LANGUAGE")] = QString("en");
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
settings[QString("NETCTLAUTO_PATH")] = QString("/usr/bin/netctl-auto");
settings[QString("NETCTLAUTO_SERVICE")] = QString("netctl-auto");
settings[QString("PID_FILE")] = QString("/run/wpa_supplicant_netctl-gui.pid");
settings[QString("PREFERED_IFACE")] = QString("");
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
settings[QString("WPAACTIOND_PATH")] = QString("/usr/bin/wpa_actiond");
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
return getSettings(QString("/dev/null"));
}
QMap<QString, QString> SettingsWindow::getSettings()
QMap<QString, QString> SettingsWindow::getSettings(QString fileName)
{
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
if (debug) qDebug() << PDEBUG;
if (fileName == QString("")) fileName = file;
QMap<QString, QString> settings = getDefault();
QFile configFile(file);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return settings;
while (true) {
fileStr = QString(configFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (!fileStr.contains(QChar('='))) continue;
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
if (configFile.atEnd())
break;
}
configFile.close();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
QMap<QString, QString> config;
QSettings settings(fileName, QSettings::IniFormat);
return settings;
settings.beginGroup(QString("General"));
config[QString("LANGUAGE")] = settings.value(QString("LANGUAGE"), QString("en")).toString();
config[QString("SYSTRAY")] = settings.value(QString("SYSTRAY"), QString("true")).toString();
config[QString("CLOSETOTRAY")] = settings.value(QString("CLOSETOTRAY"), QString("true")).toString();
config[QString("STARTTOTRAY")] = settings.value(QString("STARTTOTRAY"), QString("false")).toString();
config[QString("SKIPCOMPONENTS")] = settings.value(QString("SKIPCOMPONENTS"), QString("false")).toString();
settings.endGroup();
settings.beginGroup(QString("Helper"));
config[QString("USE_HELPER")] = settings.value(QString("USE_HELPER"), QString("true")).toString();
config[QString("FORCE_SUDO")] = settings.value(QString("FORCE_SUDO"), QString("false")).toString();
config[QString("CLOSE_HELPER")] = settings.value(QString("CLOSE_HELPER"), QString("false")).toString();
config[QString("HELPER_PATH")] = settings.value(QString("HELPER_PATH"), QString("/usr/bin/netctlgui-helper")).toString();
config[QString("HELPER_SERVICE")] = settings.value(QString("HELPER_SERVICE"), QString("netctlgui-helper.service")).toString();
settings.endGroup();
settings.beginGroup(QString("netctl"));
config[QString("SYSTEMCTL_PATH")] = settings.value(QString("SYSTEMCTL_PATH"), QString("/usr/bin/systemctl")).toString();
config[QString("NETCTL_PATH")] = settings.value(QString("NETCTL_PATH"), QString("/usr/bin/netctl")).toString();
config[QString("NETCTLAUTO_PATH")] = settings.value(QString("NETCTLAUTO_PATH"), QString("/usr/bin/netctl-auto")).toString();
config[QString("NETCTLAUTO_SERVICE")] = settings.value(QString("NETCTLAUTO_SERVICE"), QString("netctl-auto")).toString();
config[QString("PROFILE_DIR")] = settings.value(QString("PROFILE_DIR"), QString("/etc/netctl")).toString();
settings.endGroup();
settings.beginGroup(QString("sudo"));
config[QString("SUDO_PATH")] = settings.value(QString("SUDO_PATH"), QString("/usr/bin/kdesu")).toString();
settings.endGroup();
settings.beginGroup(QString("wpa_supplicant"));
config[QString("WPASUP_PATH")] = settings.value(QString("WPASUP_PATH"), QString("/usr/bin/wpa_supplicant")).toString();
config[QString("WPACLI_PATH")] = settings.value(QString("WPACLI_PATH"), QString("/usr/bin/wpa_cli")).toString();
config[QString("PID_FILE")] = settings.value(QString("PID_FILE"), QString("/run/wpa_supplicant_netctl-gui.pid")).toString();
config[QString("WPA_DRIVERS")] = settings.value(QString("WPA_DRIVERS"), QString("nl80211,wext")).toString();
config[QString("CTRL_DIR")] = settings.value(QString("CTRL_DIR"), QString("/run/wpa_supplicant_netctl-gui")).toString();
config[QString("CTRL_GROUP")] = settings.value(QString("CTRL_GROUP"), QString("users")).toString();
settings.endGroup();
settings.beginGroup(QString("Other"));
config[QString("IFACE_DIR")] = settings.value(QString("IFACE_DIR"), QString("/sys/class/net/")).toString();
config[QString("RFKILL_DIR")] = settings.value(QString("RFKILL_DIR"), QString("/sys/class/rfkill/")).toString();
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString("")).toString();
settings.endGroup();
for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") +
config[config.keys()[i]];
return config;
}
void SettingsWindow::startHelper()
{
if (debug) qDebug() << PDEBUG;
((MainWindow *)parent())->startHelper();
updateHelper();
}
void SettingsWindow::updateHelper()
{
if (debug) qDebug() << PDEBUG;
if (((MainWindow *)parent())->isHelperServiceActive()) {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active (systemd)"));
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
ui->pushButton_status->setDisabled(true);
} else if (((MainWindow *)parent())->isHelperActive()) {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active"));
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
ui->pushButton_status->setEnabled(true);
} else {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Inactive"));
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Start"));
ui->pushButton_status->setIcon(QIcon::fromTheme("system-run"));
ui->pushButton_status->setEnabled(true);
}
}

View File

@ -39,9 +39,11 @@ public:
const QString configFile = QString(""));
~SettingsWindow();
QMap<QString, QString> getDefault();
QMap<QString, QString> getSettings();
QMap<QString, QString> getSettings(QString fileName = QString(""));
public slots:
void closeWindow();
void restoreSettings();
void setDefault();
void showWindow();
@ -49,17 +51,11 @@ private slots:
void addLanguages();
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void saveSettings();
void setTray();
void updateHelper();
// buttons
void selectIfaceDir();
void selectNetctlPath();
void selectNetctlAutoPath();
void selectProfileDir();
void selectRfkillDir();
void selectSudoPath();
void selectSystemctlPath();
void selectWpaActiondPath();
void selectWpaCliPath();
void selectWpaSupPath();
void selectAbstractSomething();
void startHelper();
private:
bool debug;
@ -69,7 +65,7 @@ private:
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
QMap<QString, QString> readSettings();
void setSettings(const QMap<QString, QString> settings);
void setSettings(const QMap<QString, QString> config);
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>670</width>
<height>331</height>
<width>678</width>
<height>395</height>
</rect>
</property>
<property name="windowTitle">
@ -67,6 +67,15 @@
</iconset>
</property>
</item>
<item>
<property name="text">
<string>Helper</string>
</property>
<property name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/icon-helper.png</normaloff>:/icon-helper.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>netctl</string>
@ -127,8 +136,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>462</width>
<height>330</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -151,12 +160,30 @@
</layout>
</item>
<item>
<widget class="QLabel" name="label_info">
<widget class="QCheckBox" name="checkBox_enableTray">
<property name="text">
<string>You will need to restart the application</string>
<string>Enable system tray</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_closeToTray">
<property name="text">
<string>Minimize to tray instead of closing</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_startToTray">
<property name="text">
<string>Start minimized to tray</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_components">
<property name="text">
<string>Skip components checking</string>
</property>
</widget>
</item>
@ -179,6 +206,173 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="page_helper">
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<widget class="QScrollArea" name="scrollArea_helper">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>462</width>
<height>330</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<widget class="QLabel" name="label_helperInfo">
<property name="text">
<string>It is recommended to use systemd integration. See `man 1 netctlgui-helper` for more details.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_status">
<item>
<widget class="QLabel" name="label_statusText">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Helper status</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_status">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_status">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_status">
<property name="text">
<string>Start</string>
</property>
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_useHelper">
<property name="text">
<string>Use helper</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_forceSudo">
<property name="text">
<string>Force use sudo in helper</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_helperClose">
<property name="text">
<string>Close helper after exit (doesn't work while systemd service is active)</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_helperPath">
<item>
<widget class="QLabel" name="label_helperPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Helper command</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_helperPath"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_helperPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_helperService">
<item>
<widget class="QLabel" name="label_helperService">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Helper service</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_helperService">
<property name="toolTip">
<string>Name of netctlgui-helper service</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_helper">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_netctl">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
@ -194,8 +388,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>436</width>
<height>173</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -381,8 +575,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>436</width>
<height>45</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
@ -451,8 +645,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>277</width>
<height>194</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
@ -518,37 +712,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wpaActiondPath">
<item>
<widget class="QLabel" name="label_wpaActiondPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>wpa_actiond path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaActiondPath">
<property name="toolTip">
<string>Path to wpa_actiond</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaActiondPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pid">
<item>
@ -679,8 +842,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
<width>436</width>
<height>107</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
@ -707,7 +870,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_interfaceDir">
<widget class="QPushButton" name="pushButton_interfacesDir">
<property name="text">
<string>Browse</string>
</property>
@ -796,7 +959,7 @@
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>

View File

@ -0,0 +1,323 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "trayicon.h"
#include <QDebug>
#include <QMenu>
#include <QMessageBox>
#include <pdebug/pdebug.h>
#include "mainwindow.h"
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
: QSystemTrayIcon(parent),
debug(debugCmd)
{
mainWindow = (MainWindow *)parent;
init();
}
TrayIcon::~TrayIcon()
{
if (debug) qDebug() << PDEBUG;
setContextMenu(0);
startProfileMenu->clear();
switchToProfileMenu->clear();
menuActions->clear();
delete startProfileMenu;
delete switchToProfileMenu;
delete menuActions;
for (int i=0; i<contextMenu.keys().count(); i++)
delete contextMenu[contextMenu.keys()[i]];
}
int TrayIcon::showInformation()
{
if (debug) qDebug() << PDEBUG;
if (supportsMessages()) {
QString title = QApplication::translate("TrayIcon", "netctl status");
QStringList info = mainWindow->printInformation();
QString message = QString("%1: %2\n").arg(QApplication::translate("TrayIcon", "Profile")).arg(info[0]);
message += QString("%1: %2").arg(QApplication::translate("TrayIcon", "Status")).arg(info[1]);
showMessage(title, message, QSystemTrayIcon::Information);
}
else
return showInformationInWindow();
return 0;
}
int TrayIcon::showInformationInWindow()
{
if (debug) qDebug() << PDEBUG;
QString title = QApplication::translate("TrayIcon", "netctl status");
QStringList info = mainWindow->printInformation();
QString message = QString("%1: %2\n").arg(QApplication::translate("TrayIcon", "Profile")).arg(info[0]);
message += QString("%1: %2").arg(QApplication::translate("TrayIcon", "Status")).arg(info[1]);
return QMessageBox::information(0, title, message);
}
void TrayIcon::updateMenu()
{
if (debug) qDebug() << PDEBUG;
QStringList info = mainWindow->printTrayInformation();
bool netctlAutoStatus = info[0].toInt();
QStringList profiles = info[1].split(QChar('|'));
QString current = info[2];
QString enabled = info[3];
if (current.isEmpty()) {
contextMenu[QString("title")]->setIcon(QIcon(QString(":network-offline-64x64")));
contextMenu[QString("title")]->setText(QApplication::translate("TrayIcon", "(inactive)"));
} else {
contextMenu[QString("title")]->setIcon(QIcon(QString(":network-idle-64x64")));
QStringList currentProfiles, status;
if (netctlAutoStatus) {
currentProfiles.append(current);
status.append(QApplication::translate("TrayIcon", "(netctl-auto)"));
} else {
for (int i=0; i<enabled.split(QChar('|')).count(); i++) {
currentProfiles.append(current.split(QChar('|'))[i]);
if (enabled.split(QChar('|'))[i] == QString("0"))
status.append(QApplication::translate("TrayIcon", "static"));
else
status.append(QApplication::translate("TrayIcon", "enabled"));
}
}
QStringList profiles;
for (int i=0; i<currentProfiles.count(); i++)
profiles.append(currentProfiles[i] + QString(" (") + status[i] + QString(")"));
contextMenu[QString("title")]->setText(profiles.join(QString(" | ")));
}
if (netctlAutoStatus) {
contextMenu[QString("start")]->setVisible(false);
contextMenu[QString("stop")]->setVisible(false);
contextMenu[QString("stopall")]->setVisible(false);
contextMenu[QString("switch")]->setVisible(true);
contextMenu[QString("restart")]->setVisible(false);
contextMenu[QString("enable")]->setVisible(false);
switchToProfileMenu->clear();
for (int i=0; i<profiles.count(); i++) {
QAction *profile = new QAction(profiles[i], this);
switchToProfileMenu->addAction(profile);
}
} else {
if (current.contains(QChar('|'))) {
contextMenu[QString("start")]->setVisible(true);
contextMenu[QString("stop")]->setVisible(false);
contextMenu[QString("stopall")]->setVisible(true);
contextMenu[QString("switch")]->setVisible(false);
contextMenu[QString("restart")]->setVisible(false);
contextMenu[QString("enable")]->setVisible(false);
} else {
contextMenu[QString("start")]->setVisible(true);
contextMenu[QString("stop")]->setVisible(!current.isEmpty());
contextMenu[QString("switch")]->setVisible(false);
contextMenu[QString("stopall")]->setVisible(false);
contextMenu[QString("restart")]->setVisible(!current.isEmpty());
contextMenu[QString("enable")]->setVisible(!current.isEmpty());
}
if (!current.isEmpty()) {
contextMenu[QString("start")]->setText(QApplication::translate("TrayIcon", "Start another profile"));
contextMenu[QString("stop")]->setText(QApplication::translate("TrayIcon", "Stop %1").arg(current));
contextMenu[QString("restart")]->setText(QApplication::translate("TrayIcon", "Restart %1").arg(current));
if (enabled.split(QChar('|'))[0].toInt())
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Disable %1").arg(current));
else
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Enable %1").arg(current));
} else
contextMenu[QString("start")]->setText(QApplication::translate("TrayIcon", "Start profile"));
startProfileMenu->clear();
for (int i=0; i<profiles.count(); i++) {
QAction *profile = new QAction(profiles[i], this);
startProfileMenu->addAction(profile);
}
}
if (mainWindow->isHidden())
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Show"));
else
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Hide"));
setContextMenu(menuActions);
}
void TrayIcon::createActions()
{
if (debug) qDebug() << PDEBUG;
menuActions = new QMenu();
contextMenu[QString("title")] = new QAction(QIcon(":icon"), QApplication::translate("TrayIcon", "Status"), this);
menuActions->addAction(contextMenu[QString("title")]);
connect(contextMenu[QString("title")], SIGNAL(triggered(bool)), this, SLOT(showInformationInWindow()));
menuActions->addSeparator();
contextMenu[QString("start")] = new QAction(QIcon::fromTheme("system-run"), QApplication::translate("TrayIcon", "Start profile"), this);
startProfileMenu = new QMenu();
contextMenu[QString("start")]->setMenu(startProfileMenu);
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(startProfileSlot(QAction *)));
menuActions->addAction(contextMenu[QString("start")]);
contextMenu[QString("stop")] = new QAction(QIcon::fromTheme("process-stop"), QApplication::translate("TrayIcon", "Stop profile"), this);
connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
menuActions->addAction(contextMenu[QString("stop")]);
contextMenu[QString("stopall")] = new QAction(QIcon::fromTheme("process-stop"), QApplication::translate("TrayIcon", "Stop all profiles"), this);
connect(contextMenu[QString("stopall")], SIGNAL(triggered(bool)), this, SLOT(stopAllProfilesSlot()));
menuActions->addAction(contextMenu[QString("stopall")]);
contextMenu[QString("switch")] = new QAction(QIcon::fromTheme("system-run"), QApplication::translate("TrayIcon", "Switch to profile"), this);
switchToProfileMenu = new QMenu();
contextMenu[QString("switch")]->setMenu(switchToProfileMenu);
connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchToProfileSlot(QAction *)));
menuActions->addAction(contextMenu[QString("switch")]);
contextMenu[QString("restart")] = new QAction(QIcon::fromTheme("stock-refresh"), QApplication::translate("TrayIcon", "Restart profile"), this);
connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
menuActions->addAction(contextMenu[QString("restart")]);
contextMenu[QString("enable")] = new QAction(QApplication::translate("TrayIcon", "Enable profile"), this);
connect(contextMenu[QString("enable")], SIGNAL(triggered(bool)), this, SLOT(enableProfileSlot()));
menuActions->addAction(contextMenu[QString("enable")]);
menuActions->addSeparator();
contextMenu[QString("gui")] = new QAction(QApplication::translate("TrayIcon", "Show"), this);
connect(contextMenu[QString("gui")], SIGNAL(triggered(bool)), mainWindow, SLOT(showMainWindow()));
menuActions->addAction(contextMenu[QString("gui")]);
contextMenu[QString("auto")] = new QAction(QApplication::translate("TrayIcon", "Show netctl-auto"), this);
connect(contextMenu[QString("auto")], SIGNAL(triggered(bool)), mainWindow, SLOT(showNetctlAutoWindow()));
menuActions->addAction(contextMenu[QString("auto")]);
menuActions->addSeparator();
contextMenu[QString("quit")] = new QAction(QApplication::translate("TrayIcon", "Quit"), this);
connect(contextMenu[QString("quit")], SIGNAL(triggered(bool)), mainWindow, SLOT(closeMainWindow()));
menuActions->addAction(contextMenu[QString("quit")]);
}
void TrayIcon::init()
{
if (debug) qDebug() << PDEBUG;
setIcon(QIcon(":icon"));
setToolTip(QString("netctl-gui"));
createActions();
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(itemActivated(QSystemTrayIcon::ActivationReason)));
}
void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Reason" << reason;
switch (reason) {
case QSystemTrayIcon::Trigger:
showInformation();
break;
case QSystemTrayIcon::DoubleClick:
mainWindow->showMainWindow();
break;
case QSystemTrayIcon::Context:
// clear menu before update
setContextMenu(0);
updateMenu();
break;
default:
break;
}
}
bool TrayIcon::enableProfileSlot()
{
if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0];
return mainWindow->enableProfileSlot(profile);
}
bool TrayIcon::restartProfileSlot()
{
if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0];
return mainWindow->restartProfileSlot(profile);
}
bool TrayIcon::startProfileSlot(QAction *action)
{
if (debug) qDebug() << PDEBUG;
QString profile = action->text().remove(QChar('&'));
return mainWindow->switchToProfileSlot(profile);
}
bool TrayIcon::stopProfileSlot()
{
if (debug) qDebug() << PDEBUG;
QString profile = mainWindow->printInformation()[0];
return mainWindow->startProfileSlot(profile);
}
bool TrayIcon::stopAllProfilesSlot()
{
if (debug) qDebug() << PDEBUG;
return mainWindow->stopAllProfilesSlot();
}
bool TrayIcon::switchToProfileSlot(QAction *action)
{
if (debug) qDebug() << PDEBUG;
QString profile = action->text().remove(QChar('&'));
return mainWindow->switchToProfileSlot(profile);
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TRAYICON_H
#define TRAYICON_H
#include <QAction>
#include <QObject>
#include <QSystemTrayIcon>
class MainWindow;
class TrayIcon : public QSystemTrayIcon
{
Q_OBJECT
public:
explicit TrayIcon(QObject *parent = 0,
const bool debugCmd = false);
~TrayIcon();
public slots:
int showInformation();
int showInformationInWindow();
void updateMenu();
private slots:
void itemActivated(const QSystemTrayIcon::ActivationReason reason);
bool enableProfileSlot();
bool restartProfileSlot();
bool startProfileSlot(QAction *action);
bool stopProfileSlot();
bool stopAllProfilesSlot();
bool switchToProfileSlot(QAction *action);
private:
bool debug;
MainWindow *mainWindow;
// contextual actions
QMenu *menuActions;
QMenu *startProfileMenu;
QMenu *switchToProfileMenu;
QMap<QString, QAction*> contextMenu;
// functions
void createActions();
void init();
};
#endif /* TRAYICON_H */

View File

@ -63,6 +63,7 @@ void WirelessWidget::clear()
ui->comboBox_drivers->setCurrentIndex(0);
ui->listWidget_drivers->setCurrentRow(-1);
ui->listWidget_drivers->clear();
ui->comboBox_rfkill->clear();
ui->comboBox_rfkill->addItem(QString("auto"));
if (rfkillDirectory->exists()) {
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
@ -158,21 +159,18 @@ void WirelessWidget::changeSecurity(const QString currentText)
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setHidden(true);
}
else if ((currentText == QString("wep")) ||
} else if ((currentText == QString("wep")) ||
(currentText == QString("wpa"))) {
ui->widget_essid->setHidden(false);
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setHidden(false);
}
else if (currentText == QString("wpa-configsection")) {
} else if (currentText == QString("wpa-configsection")) {
ui->widget_essid->setHidden(true);
ui->widget_wpaConfigSection->setHidden(false);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setHidden(true);
}
else if (currentText == QString("wpa-config")) {
} else if (currentText == QString("wpa-config")) {
ui->widget_essid->setHidden(true);
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setHidden(false);
@ -198,8 +196,7 @@ void WirelessWidget::showAdvanced()
if (ui->pushButton_wirelessAdvanced->isChecked()) {
ui->widget_wirelessAdvanced->setHidden(false);
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
}
else {
} else {
ui->widget_wirelessAdvanced->setHidden(true);
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
}
@ -220,8 +217,7 @@ QMap<QString, QString> WirelessWidget::getSettings()
wirelessSettings[QString("Key")] = ui->lineEdit_key->text();
else
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
}
else if (ui->comboBox_security->currentText() == QString("wpa"))
} else if (ui->comboBox_security->currentText() == QString("wpa"))
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
QStringList section;

105
sources/gui/zsh-completions Normal file
View File

@ -0,0 +1,105 @@
#compdef netctl-gui
###########################################################################
# This file is part of netctl-gui #
# #
# netctl-gui is free software: you can redistribute it and/or #
# modify it under the terms of the GNU General Public License as #
# published by the Free Software Foundation, either version 3 of the #
# License, or (at your option) any later version. #
# #
# netctl-gui is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with netctl-gui. If not, see http://www.gnu.org/licenses/ #
###########################################################################
# variables
_netctl_gui_arglist=(
{'--detached','--detached'}'[start detached from console]'
{'--maximized','--maximized'}'[start maximized]'
{'--minimized','--minimized'}'[start minimized to tray]'
{'--about','--about'}'[show about window]'
{'--netctl-auto','--netctl-auto'}'[show netctl-auto window]'
{'--settings','--settings'}'[show settings window]'
{'(--essid)-e','(-e)--essid'}'[select ESSID]:type ESSID:->essid'
{'(--open)-o','(-o)--open'}'[open profile]:select profile:->profiles'
{'(--select)-s','(-s)--select'}'[select profile]:select profile:->profiles'
{'(--config)-c','(-c)--config'}'[read configuration from this file]:select file:->files'
{'(--debug)-d','(-d)--debug'}'[print debug information]'
{'--default','--default'}'[start with default settings]'
{'--set-opts','--set-opts'}'[set options for this run, comma separated]:comma separated:->settings'
{'(--tab)-t','(-t)--tab'}'[open a tab with specified number]:select tab:->tab'
{'(--version)-v','(-v)--version'}'[show version and exit]'
{'(--info)-i','(-i)--info'}'[show build information and exit]'
{'(--help)-h','(-h)--help'}'[show help and exit]'
)
_netctl_gui_settings=(
'CLOSE_HELPER'
'CLOSETOTRAY'
'CTRL_DIR'
'CTRL_GROUP'
'FORCE_SUDO'
'HELPER_PATH'
'HELPER_SERVICE'
'IFACE_DIR'
'LANGUAGE'
'NETCTL_PATH'
'NETCTLAUTO_PATH'
'NETCTLAUTO_SERVICE'
'PID_FILE'
'PREFERED_IFACE'
'PROFILE_DIR'
'RFKILL_DIR'
'SKIPCOMPONENTS'
'STARTTOTRAY'
'SUDO_PATH'
'SYSTEMCTL_PATH'
'SYSTRAY'
'USE_HELPER'
'WPACLI_PATH'
'WPASUP_PATH'
'WPA_DRIVERS'
)
_netctl_gui_tabs=(
'1'
'2'
'3'
)
_netctl_profiles() {
print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
# work block
_netctl-gui() {
_arguments $_netctl_gui_arglist
case "$state" in
essid)
;;
files)
_files
;;
profiles)
_values 'profiles' $(_netctl_profiles)
;;
settings)
_values -s ',' 'settings' $_netctl_gui_settings
;;
tab)
_values 'tab' $_netctl_gui_tabs
;;
esac
}
case "$service" in
netctl-gui)
_netctl-gui "$@" && return 0
;;
esac

View File

@ -0,0 +1,32 @@
# set project name
set (SUBPROJECT netctlgui-helper)
message (STATUS "Subproject ${SUBPROJECT}")
# set directories
set (SUBPROJECT_BINARY_DIR bin)
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations-helper)
# executable path
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
# additional targets
set (TARGETS "")
set (HEADERS "")
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
# build man
file (GLOB SUBPROJECT_MAN_IN *.1)
file (GLOB SUBPROJECT_MAN5_IN *.5)
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
file (RELATIVE_PATH SUBPROJECT_MAN5 ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN5_IN})
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
configure_file (${SUBPROJECT_MAN5_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN5})
install (FILES org.netctlgui.helper.conf DESTINATION ${DBUS_SYSTEMCONF_PATH})
install (FILES netctl-gui.conf DESTINATION /etc)
install (FILES netctlgui-helper.service DESTINATION ${SYSTEMD_SERVICE_PATH})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN5} DESTINATION share/man/man5/)
install (FILES bash-completions DESTINATION share/bash-completion/completions/ RENAME ${SUBPROJECT})
install (FILES zsh-completions DESTINATION share/zsh/site-functions/ RENAME _${SUBPROJECT})

View File

@ -0,0 +1,53 @@
###########################################################################
# This file is part of netctl-gui #
# #
# netctl-gui is free software: you can redistribute it and/or #
# modify it under the terms of the GNU General Public License as #
# published by the Free Software Foundation, either version 3 of the #
# License, or (at your option) any later version. #
# #
# netctl-gui is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with netctl-gui. If not, see http://www.gnu.org/licenses/ #
###########################################################################
# variables
_netctlgui_helper_arglist=(
'-c'
'--config'
'-d'
'--debug'
'--nodaemon'
'--replace'
'--restore'
'--session'
'--system'
'-v'
'--version'
'-i'
'--info'
'-h'
'--help'
)
# work block
_netctlgui_helper() {
COMPREPLY=()
wantfiles='-@(c|-config)'
_get_comp_words_by_ref cur prev words cword
if [[ $prev = $wantfiles ]]; then
_filedir
else
COMPREPLY=($(compgen -W '${_netctlgui_helper[@]}' -- "$cur"))
fi
true
}
complete -F _netctlgui_helper netctlgui-helper

View File

@ -0,0 +1,63 @@
# Configuration file for Netctl GUI project
# /etc/netctl-gui.conf - system-wide configuration
# $HOME/.config/netctl-gui.conf - user configuration
# close helper after GUI application quit.
# This option is not recognized by netctlgui-helper
CLOSETOTRAY=true
# hide application to tray on exit if tray is available.
# This option is not recognized by netctlgui-helper
CLOSE_HELPER=false
# path to control directory which is required by wpa_supplicant
CTRL_DIR=/run/wpa_supplicant_netctl-gui
# group which is owner of CTRL_DIR
CTRL_GROUP=users
# force use SUDO_PATH for helper instead of using setuid(3) to child processes
FORCE_SUDO=false
# path to netctlgui-helper.
# This option is not recognized by netctlgui-helper
HELPER_PATH=/usr/bin/netctlgui-helper
# netctlgui-helper service name.
# This option is not recognized by netctlgui-helper
HELPER_SERVICE=netctlgui-helper.service
# path to directory which contains interface information
IFACE_DIR=/sys/class/net/
# application language
LANGUAGE=en
# path to netctl-auto
NETCTLAUTO_PATH=/usr/bin/netctl-auto
# netctl-auto service name without .service suffix
NETCTLAUTO_SERVICE=netctl-auto
# path to netctl
NETCTL_PATH=/usr/bin/netctl
# wpa_supplicant PID file
PID_FILE=/run/wpa_supplicant_netctl-gui.pid
# prefered wireless interface
PREFERED_IFACE=
# path to netctl profile directory
PROFILE_DIR=/etc/netctl/
# path to directory with rfkill devices.
# This option is not recognized by netctlgui-helper
RFKILL_DIR=/sys/class/rfkill/
# skip external components checking
# This option is not recognized by netctlgui-helper
SKIPCOMPONENTS=false
# start netctl-gui minimized to tray if it is available.
# This option is not recognized by netctlgui-helper
STARTTOTRAY=false
# path to sudo frontend
SUDO_PATH=/usr/bin/sudo
# path to systemctl
SYSTEMCTL_PATH=/usr/bin/systemctl
# create system tray icon.
# This option is not recognized by netctlgui-helper
SYSTRAY=true
# use netctlgui-helper if it is available.
# This option is not recognized by netctlgui-helper
USE_HELPER=true
# path to wpa_cli
WPACLI_PATH=/usr/bin/wpa_cli
# path to wpa_supplicant
WPASUP_PATH=/usr/bin/wpa_supplicant
# wpa_supplicant drivers for wireless interface comma separated
WPA_DRIVERS=nl80211,wext

View File

@ -0,0 +1,107 @@
.TH netctl-gui.conf 5 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "File Formats Manual"
.SH NAME
netctl-gui.conf is a configuration file of Netctl GUI project
.SH SYNOPSIS
.B /etc/netctl-gui.conf
for system-wide configuration or
.B $HOME/.config/netctl-gui.conf
for user one
.SH DESCRIPTION
.B netctl-gui.conf
is a file which contains parameters for
.BR netctlgui-helper (1)
and may be used as template for
.BR netctl-gui (1)
configuration also.
.SH OPTIONS
.IP "CLOSE_HELPER=false"
close helper after GUI application quit. This option is not recognized by
.BR netctlgui-helper (1)
.IP "CLOSETOTRAY=true"
hide application to tray on exit if tray is available. This option is not recognized by
.BR netctlgui-helper (1)
.IP "CTRL_DIR=/run/wpa_supplicant_netctl-gui"
path to control directory which is required by
.BR wpa_supplicant (8)
.IP "CTRL_GROUP=users"
group which is owner of
.B CTRL_DIR
.IP "FORCE_SUDO=false"
force use
.B SUDO_PATH
for helper instead of using
.BR setuid (3)
to child processes
.IP "HELPER_PATH=/usr/bin/netctlgui-helper"
path to
.BR netctlgui-helper (1)
This option is not recognized by
.BR netctlgui-helper (1)
.IP "HELPER_SERVICE=netctlgui-helper.service"
.BR netctlgui-helper (1)
service name. This option is not recognized by
.BR netctlgui-helper (1)
.IP "IFACE_DIR=/sys/class/net/"
path to directory which contains interface information
.IP "LANGUAGE=en"
application language
.IP "NETCTL_PATH=/usr/bin/netctl"
path to
.BR netctl (1)
.IP "NETCTLAUTO_PATH=/usr/bin/netctl-auto"
path to
.BR netctl-auto (1)
.IP "NETCTLAUTO_SERVICE=netctl-auto"
.BR netctl-auto (1)
service name without
.I .service
suffix
.IP "PID_FILE=/run/wpa_supplicant_netctl-gui.pid"
.BR wpa_supplicant (8)
PID file
.IP "PREFERED_IFACE="
prefered wireless interface
.IP "PROFILE_DIR=/etc/netctl/"
path to
.BR netctl (1)
profile directory
.IP "RFKILL_DIR=/sys/class/rfkill/"
path to directory with
.BR rfkill (8)
devices. This option is not recognized by
.BR netctlgui-helper (1)
.IP "SKIPCOMPONENTS=false"
skip external components checking. This option is not recognized by
.BR netctlgui-helper (1)
.IP "STARTTOTRAY=false"
start
.BR netctl-gui (1)
minimized to tray if it is available. This option is not recognized by
.BR netctlgui-helper (1)
.IP "SUDO_PATH=/usr/bin/kdesu"
path to
.BR sudo (8)
frontend
.IP "SYSTEMCTL_PATH=/usr/bin/systemctl"
path to
.BR systemctl (1)
.IP "SYSTRAY=true"
create system tray icon. This option is not recognized by
.BR netctlgui-helper (1)
.IP "USE_HELPER=true"
use
.BR netctlgui-helper (1)
if it is available. This option is not recognized by
.BR netctlgui-helper (1)
.IP "WPACLI_PATH=/usr/bin/wpa_cli"
path to
.BR wpa_cli (8)
.IP "WPASUP_PATH=/usr/bin/wpa_supplicant"
path to
.BR wpa_supplicant (8)
.IP "WPA_DRIVERS=nl80211,wext"
.BR wpa_supplicant (8)
drivers for wireless interface comma separated
.SH SEE ALSO
.BR netctl-gui (1)
.BR netctlgui-helper (1)

View File

@ -0,0 +1,81 @@
.TH netctlgui-helper 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "General Commands Manual"
.SH NAME
netctlgui-helper is a helper daemon for netctl-gui
.SH SYNOPSIS
.B netctlgui-helper
[ options ]
.SH DESCRIPTION
.B netctlgui-helper
is a Qt based helper daemon which provides a DBus interface for interaction with
.B netctl
without any additional permissions. To have access to DBus interface user should have group
.B network
.SH OPTIONS
.IP "-c, --config FILE"
read configuration from file
.I FILE
instead of default user configuration
.IP "-d, --debug"
print debug information
.IP "--nodaemon"
do not run as daemon
.IP "--replace"
force replace the existing session
.IP "--restore"
force restore the existing session
.IP "--session"
force create user DBus session
.IP "--system"
do not read user configuration
.IP "-v, --version"
show version and exit
.IP "-i, --info"
show build information and exit
.IP "-h, --help"
show this help and exit
.SH FILES
.I $HOME/.config/netctl-gui.conf
,
.I /etc/netctl-gui.conf
.RS
Configuration files
.RE
.I /usr/lib/systemd/system/netctlgui-helper.service
.RS
Systemd service file
.RE
.I /etc/dbus-1/system.d/org.netctlgui.helper.conf
.RS
DBus policy configuration file
.RE
.SH USAGE WITH SYSTEMD
It is a recommended way to use this daemon. To start helper as systemd daemon type:
.nf
# systemctl start netctlgui-helper
.fi
If you want to setup non-standard configuration file edit source service file and replace the following line:
.nf
ExecStart=/usr/bin/netctlgui-helper
.fi
to
.nf
ExecStart=/usr/bin/netctlgui-helper -c /path/to/your/file
.fi
By the way it is highly recommended to copy source service file before to
.B /etc/systemd/system
and edit copied file to avoid upgrade problems.
.SH SEE ALSO
.BR netctl-gui (1)
.BR netctl-gui.conf (5)
.SH STANDARDS
See
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html
for more details.
.SH SECURITY CONSIDERATIONS
See
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-security-notes.html
for more details.
.SH AUTHOR
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
.SH LICENSE
This software is licensed under @PROJECT_LICENSE@

View File

@ -0,0 +1,11 @@
[Unit]
Description=netctlgui-helper daemon
Documentation=man:netctlgui-helper(1) man:netctl-gui.conf(5)
[Service]
Type=dbus
BusName=org.netctlgui.helper
ExecStart=/usr/bin/netctlgui-helper --nodaemon --system
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,16 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<!-- allow everything to users of the group "network" -->
<policy group="network">
<allow own="org.netctlgui.helper"/>
<allow send_destination="org.netctlgui.helper"/>
<allow receive_sender="org.netctlgui.helper"/>
</policy>
<policy user="root">
<allow own="org.netctlgui.helper"/>
<allow send_destination="org.netctlgui.helper"/>
<allow receive_sender="org.netctlgui.helper"/>
</policy>
</busconfig>

View File

@ -0,0 +1,60 @@
# set files
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
${PROJECT_TRDPARTY_DIR}/language/*.cpp)
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
${PROJECT_TRDPARTY_DIR}/language/*.h)
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources-helper.qrc)
# include_path
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_TRDPARTY_DIR})
link_directories (${PROJECT_LIBRARY}/src/lib)
if (USE_QT5)
find_package (Qt5 COMPONENTS Core DBus LinguistTools REQUIRED)
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS})
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations-helper COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations-helper COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
else ()
find_package (Qt4 COMPONENTS QtCore QtDBus REQUIRED)
include (${QT_USE_FILE})
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations-helper COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations-helper COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
endif()
add_executable (${SUBPROJECT} ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)
if (USE_CAPABILITIES)
install (CODE "exec_program (setcap ARGS \"cap_setuid=ep\" \"$ENV{DESTDIR}/bin/${SUBPROJECT}\")")
endif ()

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