293 Commits

Author SHA1 Message Date
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
bb7af8da40 update russian translation 2014-07-15 21:26:38 +04:00
81ff9340cc fix build 2014-07-15 21:23:03 +04:00
3d040e9bab small text update / prerelease 1.2.0 2014-07-15 20:56:46 +04:00
3542901781 added flag --config
updated translations
2014-07-15 20:40:20 +04:00
8b91f43f0b added doxygen documentation building 2014-07-15 20:01:19 +04:00
7e622ad33b added all documentation 2014-07-15 17:31:29 +04:00
48a879bd71 added documentation to wpasupinteract 2014-07-15 15:08:55 +04:00
bc8655aaeb add documentation to netctlprofile 2014-07-15 13:32:22 +04:00
05f9759d47 small edit of about.ui 2014-07-15 13:05:16 +04:00
51659c7a42 added --set-opts 2014-07-15 06:11:22 +04:00
39b8ff834f added man page 2014-07-14 22:43:17 +04:00
ea522b3864 added flags 2014-07-14 21:57:29 +04:00
79fc70efa1 rewrite errorwindow 2014-07-14 20:37:46 +04:00
5e1a4be134 add openProfile 2014-07-14 19:36:14 +04:00
63ae04cd8d edit changelog 2014-07-14 19:11:22 +04:00
4fb02058b1 added workarounds 2014-07-14 19:07:17 +04:00
e02a6a8ce1 update plasmoid translations 2014-07-14 18:35:15 +04:00
2f40ae7913 added about window 2014-07-14 18:31:35 +04:00
2e35cd356e edited cmake files 2014-07-14 14:22:04 +04:00
341a19a955 fix profile reading 2014-07-14 14:03:38 +04:00
f7e39c7834 edited profile reading 2014-07-13 15:51:44 +04:00
7660deb787 end of refactoring 2014-07-13 11:45:20 +04:00
3fb847a7b6 edited main.cpp 2014-07-13 11:26:42 +04:00
dbb9ba70c4 end of refactoring of the widgets
refactoring of settingswindow
2014-07-13 10:48:46 +04:00
ceb7f3bd0f edited configuration interface 2014-07-13 09:56:07 +04:00
8ce4b03399 end of refactoring of the library 2014-07-13 09:44:20 +04:00
44f0b6a06a refactoring of netctlprofile 2014-07-13 00:13:24 +04:00
b37272d875 refactoring of netctlinteract 2014-07-12 23:41:52 +04:00
ea91aa4ca4 refactoring of dataengine and plasmoid
update plasmoid translations
2014-07-12 23:00:59 +04:00
cc250a643a small update of documentation 2014-07-12 22:31:08 +04:00
9b01fcd4e1 refactoring of the configuration interface 2014-07-12 22:15:39 +04:00
021a870220 add support of netctl-auto to plasmoid and dataengine 2014-07-12 18:19:19 +04:00
ae001b4d7f added netctl-auto support to profiles 2014-07-12 13:36:06 +04:00
ec6834d90e edited todo list 2014-07-12 13:25:40 +04:00
de22663156 add gui for netctl-auto 2014-07-12 13:23:43 +04:00
c3f090d9a0 intermediate commit 2014-07-11 23:31:27 +04:00
d17543a075 add null translation file 2014-07-11 20:59:01 +04:00
ace3a141e4 change lineEdit to comboBox
add clear() function to profile tab
2014-07-11 11:06:01 +04:00
06bd1ce198 remove soversioned 2014-07-11 10:26:16 +04:00
9852fb8f68 detached backend from frontend 2014-07-11 09:56:48 +04:00
eccb6b6578 fix settings 2014-07-11 07:03:53 +04:00
c1457d3ef0 add language class 2014-07-11 07:00:16 +04:00
6dab355d87 added all icons 2014-07-10 14:33:04 +04:00
e81f7714f9 added icons
changes in the project architecture
2014-07-10 13:48:21 +04:00
2a3011bdef edited configuration interface of the plasmoid 2014-07-10 10:44:33 +04:00
bf799ce061 add contextual actions to wifi tab 2014-07-10 10:30:26 +04:00
a845e32960 add contextual actions to the main table 2014-07-10 10:15:11 +04:00
028546540c add debug flug 2014-07-10 09:44:23 +04:00
2bf1d0f78e update pkgbuilds 2014-06-20 02:22:44 +04:00
cce4ef4811 add support of hidden network (test) 2014-06-04 00:18:04 +04:00
4051d2f2c8 add support of macvlan
add support of profile removal
2014-06-02 00:43:13 +04:00
8a031f2183 added todo list 2014-05-28 10:17:10 +04:00
7c013310ab fix default tabnumber 2014-05-22 01:29:13 +04:00
d5f0bbc3bf release 1.1.0 2014-05-21 19:50:12 +04:00
cb033140ac added menu title 2014-05-17 08:46:55 +04:00
d582445597 release 1.1.0 2014-05-14 23:55:13 +04:00
3506bd46a9 release 1.0.6 2014-04-19 12:09:58 +04:00
727619bb85 fix rel 2014-04-14 01:23:30 +04:00
d59345c0e4 Release 1.0.5 2014-04-14 01:19:36 +04:00
4c1685164c updated translations 2014-04-12 18:58:36 +04:00
d515e4a51f added cppcheck to gui 2014-04-12 16:34:04 +04:00
2778f654ef refactoring of dataengine 2014-04-12 16:31:19 +04:00
92ec04cae1 refactoring of plasmoid
added function to start wifi menu
2014-04-12 15:27:14 +04:00
501151828d pkgbuild fixes 2014-04-10 12:14:10 +04:00
4a788aa05f edited gitignore 2014-04-10 11:39:54 +04:00
2cf91930f8 added pkgbuilds for different builds 2014-04-10 11:34:22 +04:00
4bb5d4925d F*CKING icu 2014-04-07 03:02:50 +04:00
10d44f786e removed plasmoid only =) 2014-04-07 02:32:07 +04:00
c69ff2165e removed cmakelists from root 2014-04-07 02:29:15 +04:00
4d455d93e8 added only plasmoid archive 2014-04-07 02:28:07 +04:00
046ae119a3 updated screenshots 2014-04-07 00:58:29 +04:00
b958d0b78b edited readme 2014-04-07 00:49:53 +04:00
7529cd7af0 edited changelog 2014-04-07 00:41:27 +04:00
7e85f1f933 Release 1.0.4 2014-04-07 00:39:28 +04:00
c4c407542f added notifications 2014-04-07 00:31:42 +04:00
cc2b3faf85 edited pkgbuild for the current version 2014-04-06 23:34:07 +04:00
b983f4424e commit before merging 2014-04-06 23:22:13 +04:00
72782a40c2 added qt5 build 2014-04-06 22:59:12 +04:00
9a5b61be4e updated pkgbuild 2014-04-06 19:08:21 +04:00
7d7a24c23d small changes
changed license notes since project had beed renamed to netctl-gui
2014-04-06 19:02:52 +04:00
1366852a62 refactoring of plasmoid 2014-04-06 18:45:56 +04:00
b1e455b976 changed de configuration 2014-04-06 13:08:32 +04:00
1a7d3cb50a added ui translation to plasmoid 2014-04-06 12:34:31 +04:00
762e43c0d6 fixed size 2014-03-30 19:01:02 +04:00
f02e553164 fix 2014-03-28 21:51:53 +04:00
44a5ee9083 edited readme 2014-03-28 21:51:11 +04:00
e576ff3b51 release 1.0.1 2014-03-25 12:06:18 +04:00
20e744d3cd removed install scripts 2014-03-25 12:00:34 +04:00
6132de0951 release 1.0.0 2014-03-25 11:00:50 +04:00
80e4b3e3d3 small changes before work on plasmoid 2014-03-21 19:11:47 +04:00
028b636d22 changes before renaming 2014-03-06 22:10:27 +04:00
682b6c5b4f small fixes before editing plasmoid 2014-03-02 18:45:07 +04:00
996d2d5bee more refactoring and tests profile tab 2014-03-02 17:56:19 +04:00
d0a39b6770 edited vlan before testing 2014-03-02 16:47:04 +04:00
8c9904ac4b added screenshot
edited buttons
2014-03-02 04:41:08 +04:00
e969be6b89 fix 2014-03-02 04:21:37 +04:00
9e854d8893 edited pkgbuild 2014-03-02 04:20:29 +04:00
ecea3f2cf8 small fix 2014-03-02 04:18:40 +04:00
e24b908015 more refactoring
+ added debug output
2014-03-02 04:11:55 +04:00
2abe09473a small fixes 2014-03-01 17:39:23 +04:00
f258f18e8c added translations 2014-03-01 16:32:33 +04:00
c66891ee60 added translations 2014-02-28 20:45:02 +04:00
3f02c047c2 more refactoring 2014-02-28 20:07:04 +04:00
2cade97786 added settings functions
added const type
2014-02-28 18:46:04 +04:00
fbad5a6c7d added settings window 2014-02-27 03:53:09 +04:00
710941c259 edited pkgbuild 2014-02-26 04:21:07 +04:00
32fb8ceb54 edited pkgbuild 2014-02-26 04:14:11 +04:00
9b3902e971 settings type has been changed from QHash to QMap 2014-02-26 04:07:50 +04:00
9184aa78f4 fix work wit arrays 2014-02-26 03:48:29 +04:00
0c219544b2 small fixes 2014-02-26 02:21:42 +04:00
946b470d11 looks working... 2014-02-25 16:09:37 +04:00
76877f737e added several function to profile tab 2014-02-25 02:06:33 +04:00
4dd6a8276d added setSettings() to ipwidget 2014-02-24 20:17:29 +04:00
4da239e41f added update functions 2014-02-24 19:59:12 +04:00
d98b3694a4 small edit of
added setSettings() to wireless
2014-02-24 19:55:04 +04:00
ac1a135844 added setSettings() to tunnel, tuntap and vlan 2014-02-24 19:32:34 +04:00
806cc02075 added setSettings() to pppoe 2014-02-24 19:27:58 +04:00
887cc013a7 function setSettings() has been added to mobile widget 2014-02-22 13:52:52 +04:00
3cb4e1dfee starting work on setSettings() functions 2014-02-22 13:35:05 +04:00
03b4744097 wireless widget has been completed
small fix
2014-02-22 03:34:04 +04:00
23df40960c intermediate commit 2014-02-22 02:35:07 +04:00
026f08d0cf tuntap, tunnel and vlan widgets have been completed 2014-02-22 00:38:17 +04:00
13c63163b1 pppoe widget has been completed 2014-02-22 00:06:53 +04:00
a56119d0de added command line arguments 2014-02-21 22:18:08 +04:00
f3b6457a9b now mobile ppp widget has been completed 2014-02-21 21:26:44 +04:00
d85e5560fa now ip widget has been completed 2014-02-20 02:39:27 +04:00
9cad2e2c29 small fix 2014-02-18 00:43:45 +04:00
49fcfafc9e now general widget has been completed 2014-02-18 00:38:57 +04:00
a20cac49aa now ethernet widget has been completed 2014-02-17 23:43:09 +04:00
4e53eaa1ea edited ethernet widget 2014-02-17 22:11:37 +04:00
6b9f9beabc added all widgets 2014-02-17 21:33:49 +04:00
6e427519af added pppoe widget 2014-02-17 20:21:00 +04:00
61bf2627cc added wirelesswidget 2014-02-11 16:40:26 +04:00
ec27411b1d added ethernet widget 2014-02-10 10:58:29 +04:00
b81bd78327 starting work on new profile tab... 2014-02-10 02:13:59 +04:00
8d3a3d29d2 added profile file 2014-02-09 21:09:36 +04:00
da7f1488c8 added errorwin and passwdwin
added function to read password
small changes
2014-02-08 17:40:29 +04:00
b439906be4 small changes in the architecture 2014-02-08 12:35:52 +04:00
65086a9aa3 almost working wifi module 2014-02-07 12:04:49 +04:00
95a3e0d544 try to get it work 2014-02-07 01:34:43 +04:00
d9571b76cf edited wpa functions, added scripts 2014-02-06 16:32:01 +04:00
4a2a27176f small commit 2014-02-06 11:06:36 +04:00
fc43861ba6 started work on wifi-menu 2014-02-05 00:28:02 +04:00
121ba0e54f small fixes 2014-02-04 22:05:35 +04:00
7a6930ce2c added main functions 2014-02-04 21:59:06 +04:00
e4c2402530 yet another edit of pkgbuild 2014-02-02 11:34:25 +04:00
c6902c6c6b edited pkgbuild 2014-02-02 11:15:45 +04:00
af414bb720 Small edit of cmakefiles 2014-02-02 04:57:59 +04:00
187 changed files with 34350 additions and 1362 deletions

11
.gitignore vendored
View File

@ -14,9 +14,16 @@
# Source archive
*.tar.xz
*.tar.gz
*.sig
# Build directory
build/
sources/build/
sources/build/*/
tmp/
usr/
# translations
*.qm
# temporary bckps
*~

2
AUTHORS Normal file
View File

@ -0,0 +1,2 @@
Current developers:
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>

167
CHANGELOG Normal file
View File

@ -0,0 +1,167 @@
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 temporaty 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

@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
netctl-plasmoid
netctl-gui
Copyright (C) 2014 Evgeniy Alekseev
This program is free software: you can redistribute it and/or modify
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
netctl-plasmoid Copyright (C) 2014 Evgeniy Alekseev
netctl-gui Copyright (C) 2014 Evgeniy Alekseev
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

View File

@ -1,37 +0,0 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgname=kdeplasma-applets-netctl
_pkgname=netctl-plasmoid
pkgver=1.0.0
pkgrel=1
pkgdesc="Plasmoid written on C++ which interacts with netctl"
arch=('i686' 'x86_64')
url="http://arcan1s.github.io/projects/netctlplasmoid"
license=('GPLv3')
depends=('kdebase-workspace')
makedepends=('cmake' 'automoc4')
source=(https://github.com/arcan1s/netctlplasmoid/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install=${pkgname}.install
md5sums=('5ac750e391936a6f3494a819b7b4d0b2')
_cmakekeys="-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)
-DBUILD_GUI:BOOL=1
-DBUILD_PLASMOID:BOOL=1
-DCMAKE_BUILD_TYPE=Release"
prepare() {
if [[ -d ${srcdir}/build ]]; then
rm -rf "${srcdir}/build"
fi
mkdir "${srcdir}/build"
}
build () {
cd "${srcdir}/build"
cmake ${_cmakekeys} ../${_pkgname}
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

View File

@ -1,4 +1,84 @@
netctl-plasmoid
===============
Netctl GUI
==========
Plasmoid written on C++ which interacts with netctl
Information
-----------
Qt4/Qt5 graphical interface for netctl. It may work with profiles and may create new profiles. Also it may create a connection to WiFi. Moreover, it provides a widget and DataEngine for KDE.
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/netctl-gui/issues/3)
Configuration
-------------
It is recommended to use graphical interface for configuration. Configuration files are:
* `$HOME/.config/netctl-gui.conf` - GUI/helper user configuration
* `/etc/netctl-gui.conf` - helper system-wide configuration
* `$KDEHOME/share/config/netctl.conf` - DataEngine user configuration
* `$KDESYSTEM/share/config/netctl.conf` - DataEngine system-wide configuration
Instruction
===========
Dependencies
------------
* netctl
* qt5-base (if Qt5 is used) or qt4 (if Qt4 is used)
Optional dependencies
---------------------
* kdebase-workspace (widget)
* sudo (sudo support)
* wpa_supplicant (WiFi support)
Make dependencies
-----------------
* automoc4
* cmake
* qt5-tools (if Qt5 is used)
Installation
------------
* download sources
* extract it and install the application:
cd /path/to/extracted/archive
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
make
sudo make install
Available cmake flags:
* components:
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
* `-DBUILD_GUI:BOOL=0` - do not build GUI
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* additional components:
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
* project properties:
* `-DDBUS_SYSTEMCONF_PATH=/etc/dbus-1/system.d/` - path to dbus system configuration files
* `-DSYSTEMD_SERVICE_PATH=lib/systemd/system` - path to systemd services
* `-DUSE_CAPABILITIES:BOOL=0` - do not use setcap to get privileges to the helper
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
Additional information
======================
TODO (wish list)
----------------
Links
-----
* [Homepage](http://arcanis.name/projects/netctl-gui)
* Page on [kde-apps](http://kde-apps.org/content/show.php?content=164490)
* Archlinux [AUR](https://aur.archlinux.org/pkgbase/netctl-gui/) package

148
arch/PKGBUILD Normal file
View File

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

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() {
xdg-icon-resource forceupdate --theme hicolor 2> /dev/null
}
post_upgrade() {
post_install "$1"
}
post_remove() {
post_install "$1"
}

View File

@ -1,13 +1,12 @@
post_install() {
kbuildsycoca4 > /dev/null 2>&1
xdg-icon-resource forceupdate --theme hicolor 2> /dev/null
update-desktop-database -q
}
post_upgrade() {
post_install
post_install "$1"
}
post_remove() {
post_install
post_install "$1"
}

View File

@ -0,0 +1,7 @@
post_install() {
setcap cap_setuid=ep usr/bin/netctlgui-helper 2>/dev/null || chmod +s usr/bin/ping
}
post_upgrade() {
post_install "$1"
}

View File

@ -1,23 +1,25 @@
#!/bin/bash
ARCHIVE="netctl-plasmoid"
ARCHIVE="netctl-gui"
SRCDIR="sources"
FILES="LICENSE README.md"
IGNORELIST="CMakeLists.txt.user"
FILES="AUTHORS CHANGELOG COPYING README.md"
IGNORELIST="build en.qm ru.qm netctl-gui.qm *.cppcheck"
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
# create archive
[[ -e ${ARCHIVE}-${VERSION}.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
cp -r "${SRCDIR}" "${ARCHIVE}"
for FILE in ${FILES[*]}; do cp "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do rm -f "${ARCHIVE}/${FILE}"; done
tar cvJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}" > /dev/null
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -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
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD
# 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: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 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.

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: 100 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>

115
sources/3rdparty/language/language.cpp vendored Normal file
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/ *
***************************************************************************/
#include "language.h"
#include <QFile>
#include <QLocale>
Language::Language()
{
}
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
{
QStringList availableLanguages = getAvailableLanguages();
for (int i=0; i<availableLanguages.count(); i++)
if (language == availableLanguages[i])
return availableLanguages[i];
for (int i=0; i<availableLanguages.count(); i++)
if (language.contains(availableLanguages[i] + QChar('_')))
return availableLanguages[i];
return defaultLanguage;
}
QString Language::defineLanguage(const QString configPath, const QString options)
{
QMap<QString, QString> optionsDict = parseOptions(options);
if (optionsDict.contains(QString("LANGUAGE")))
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
return optionsDict[QString("LANGUAGE")];
QString language;
language = defineLanguageFromFile(configPath);
if (language.isEmpty())
language = defineLanguageFromLocale();
language = checkLanguage(language, QString("en"));
return language;
}
QString Language::defineLanguageFromFile(const QString configPath)
{
QMap<QString, QString> settings;
if (configPath.isEmpty())
return QString("");
QFile configFile(configPath);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return QString("");
while (true) {
fileStr = QString(configFile.readLine()).trimmed();
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
if (fileStr.contains(QChar('=')))
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
if (configFile.atEnd()) break;
}
configFile.close();
if (settings.contains(QString("LANGUAGE")))
return settings[QString("LANGUAGE")];
else
return QString("");
}
QString Language::defineLanguageFromLocale()
{
return QLocale::system().name();
}
QStringList Language::getAvailableLanguages()
{
QStringList languages;
languages.append(QString("en"));
languages.append(QString("ru"));
return languages;
}
QMap<QString, QString> Language::parseOptions(const QString options)
{
QMap<QString, QString> optionsDict;
for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
continue;
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
options.split(QChar(','))[i].split(QChar('='))[1];
}
return optionsDict;
}

43
sources/3rdparty/language/language.h vendored Normal file
View File

@ -0,0 +1,43 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef LANGUAGE_H
#define LANGUAGE_H
#include <QStringList>
class Language : public QObject
{
Q_OBJECT
public:
explicit Language();
static QString checkLanguage(const QString language,
const QString defaultLanguage = QString("en"));
static QString defineLanguage(const QString configPath,
const QString options = QString("OPTIONS"));
static QString defineLanguageFromFile(const QString configPath);
static QString defineLanguageFromLocale();
static QStringList getAvailableLanguages();
private:
static QMap<QString, QString> parseOptions(const QString options);
};
#endif /* LANGUAGE_H */

45
sources/3rdparty/pdebug/pdebug.h vendored Normal file
View File

@ -0,0 +1,45 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef PRETTY_DEBUG_H
#define PRETTY_DEBUG_H
inline const char *pDebug(const std::string prettyFunction)
{
return prettyFunction.c_str();
}
inline std::string pFuncInfo(const std::string prettyFunction)
{
size_t colons = prettyFunction.find("::");
// workaround for functions which are not belong to any class
if (colons == std::string::npos)
colons = prettyFunction.rfind("(");
size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
size_t end = prettyFunction.rfind("(") - begin;
return "[" + prettyFunction.substr(begin, end) + "]";
}
#define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__))
#endif /* PRETTY_DEBUG_H */

41
sources/3rdparty/task/README.md vendored Normal file
View File

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

385
sources/3rdparty/task/task.h vendored Normal file
View File

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

44
sources/3rdparty/task/taskadds.cpp vendored Normal file
View File

@ -0,0 +1,44 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "taskadds.h"
TaskResult runTask(const QString cmd, const bool useSuid)
{
return Task::await<TaskResult>( [ & ]() {
TaskResult r;
if (useSuid) {
RootProcess command;
command.start(cmd);
command.waitForFinished(-1);
r.exitCode = command.exitCode();
r.output = command.readAllStandardOutput();
r.error = command.readAllStandardError();
} else {
QProcess command;
command.start(cmd);
command.waitForFinished(-1);
r.exitCode = command.exitCode();
r.output = command.readAllStandardOutput();
r.error = command.readAllStandardError();
}
return r;
});
}

47
sources/3rdparty/task/taskadds.h vendored Normal file
View File

@ -0,0 +1,47 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TASKADDS_H
#define TASKADDS_H
#include <QProcess>
#include <unistd.h>
#include "task.h"
class RootProcess : public QProcess
{
protected:
void setupChildProcess()
{
::setuid(0);
};
};
struct TaskResult
{
int exitCode;
QByteArray error;
QByteArray output;
};
TaskResult runTask(const QString cmd, const bool useSuid = true);
#endif /* TASKADDS_H */

View File

@ -5,48 +5,84 @@ cmake_policy (SET CMP0002 OLD)
cmake_policy (SET CMP0011 NEW)
cmake_policy (SET CMP0015 NEW)
project (netctl-plasmoid)
project (netctl-gui)
set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 1)
set (PROJECT_VERSION_MINOR 0)
set (PROJECT_VERSION_MINOR 3)
set (PROJECT_VERSION_PATCH 0)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
string (TIMESTAMP CURRENT_YEAR "%Y")
message (STATUS "Project: ${PROJECT_NAME}")
message (STATUS "Version: ${PROJECT_VERSION}")
message (STATUS "Build date: ${CURRENT_DATE}")
# install options
option (WITH_DEBUG_MODE "Build with debug mode" OFF)
option (USE_CAPABILITIES "Use setcap to set capabilities for the helper" ON)
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
# components
option (BUILD_GUI "Build GUI" ON)
option (BUILD_DATAENGINE "Build data engine" ON)
option (BUILD_HELPER "Build helper" ON)
option (BUILD_LIBRARY "Build library" ON)
option (BUILD_DATAENGINE "Build DataEngine" ON)
option (BUILD_PLASMOID "Build plasmoid" ON)
# verbose
set (CMAKE_VERBOSE_MAKEFILE ON)
if (BUILD_GUI OR BUILD_HELPER)
set (BUILD_LIBRARY ON)
endif ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
# documentation
option (BUILD_DOCS "Build Doxygen documentation" OFF)
if (BUILD_DOCS)
set (BUILD_LIBRARY ON)
endif ()
# test
option (BUILD_TEST "Build unit tests" OFF)
if (BUILD_TEST)
set (BUILD_LIBRARY ON)
endif ()
# FIXME: dbus path
set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus system configuration files")
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
# flags
if (WITH_DEBUG_MODE)
add_definitions (-DDEBUG_MODE=1)
endif ()
if (CMAKE_COMPILER_IS_GNUCXX)
set (ADD_CXX_FLAGS "-Wall")
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
else ()
message (STATUS "Unknown compiler")
message (STATUS "Unknown compiler")
endif ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
add_subdirectory (icons)
# resources
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
set (PROJECT_LIBRARY netctlgui)
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
add_subdirectory (${PROJECT_RESOURCE_DIR})
# components
if (BUILD_LIBRARY)
add_subdirectory (${PROJECT_LIBRARY})
endif ()
if (BUILD_HELPER)
add_subdirectory (helper)
endif ()
if (BUILD_TEST)
enable_testing ()
add_subdirectory (test)
endif ()
if (BUILD_GUI)
add_subdirectory (gui)
add_subdirectory (gui)
endif ()
if (BUILD_DATAENGINE)
add_subdirectory (dataengine)
add_subdirectory (dataengine)
endif ()
if (BUILD_PLASMOID)
add_subdirectory (plasmoid)
add_subdirectory (plasmoid)
endif ()

View File

@ -6,25 +6,28 @@ message (STATUS "Subproject ${SUBPROJECT}")
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS}
${KDE4_DEFINITIONS})
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}/../)
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${PROJECT_TRDPARTY_DIR})
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})
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
# install
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})

View File

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

View File

@ -2,17 +2,16 @@
## Commands
# command
CMD=/usr/bin/netctl
# ip command
IPCMD=/usr/bin/ip
## Network
# path to list of network devices
NETDIR=/sys/class/net/
NETCTLCMD=/usr/bin/netctl
# netctl-auto command
NETCTLAUTOCMD=/usr/bin/netctl-auto
## External IP
# external ip check command
EXTIPCMD=wget -qO- http://ifconfig.me/ip
# 'true' - check external IP
EXTIP=false
# external IPv4 check command
EXTIP4CMD=curl ip4.telize.com
# 'true' - check external IPv4
EXTIP4=false
# external IPv6 check command
EXTIP6CMD=curl ip6.telize.com
# 'true' - check external IPv6
EXTIP6=false

View File

@ -1,26 +1,34 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctl.h"
#include <KGlobal>
#include <KStandardDirs>
#include <Plasma/DataContainer>
#include <QDir>
#include <QDebug>
#include <QFile>
#include <QProcess>
#include <QNetworkInterface>
#include <QProcessEnvironment>
#include <QTextCodec>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
Netctl::Netctl(QObject *parent, const QVariantList &args)
@ -28,196 +36,324 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
{
Q_UNUSED(args)
// debug
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
QString debugEnv = environment.value(QString("NETCTLGUI_DEBUG"), QString("no"));
if (debugEnv == QString("yes"))
debug = true;
else
debug = false;
setMinimumPollingInterval(333);
readConfiguration();
}
Netctl::~Netctl()
{
if (debug) qDebug() << PDEBUG;
}
QStringList Netctl::sources() const
{
QStringList sources;
if (debug) qDebug() << PDEBUG;
sources.append(QString("currentProfile"));
sources.append(QString("extIp"));
QStringList sources;
sources.append(QString("active"));
sources.append(QString("current"));
sources.append(QString("extip4"));
sources.append(QString("extip6"));
sources.append(QString("interfaces"));
sources.append(QString("intIp"));
sources.append(QString("intip4"));
sources.append(QString("intip6"));
sources.append(QString("netctlauto"));
sources.append(QString("profiles"));
sources.append(QString("statusBool"));
sources.append(QString("statusString"));
sources.append(QString("status"));
return sources;
}
bool Netctl::readConfiguration()
void Netctl::readConfiguration()
{
if (debug) qDebug() << PDEBUG;
// default configuration
checkExtIP = QString("false");
cmd = QString("/usr/bin/netctl");
extIpCmd = QString("wget -qO- http://ifconfig.me/ip");
ipCmd = QString("/usr/bin/ip");
netDir = QString("/sys/class/net/");
QMap<QString, QString> rawConfig;
rawConfig[QString("EXTIP4")] = QString("false");
rawConfig[QString("EXTIP4CMD")] = QString("curl ip4.telize.com");
rawConfig[QString("EXTIP6")] = QString("false");
rawConfig[QString("EXTIP6CMD")] = QString("curl ip6.telize.com");
rawConfig[QString("NETCTLCMD")] = QString("/usr/bin/netctl");
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
QFile configFile(fileName);
if (!configFile.open(QIODevice::ReadOnly)) {
configuration = updateConfiguration(rawConfig);
return;
}
QString fileStr;
// FIXME: define configuration file
QFile confFile(QString(getenv("HOME")) + QString("/.kde4/share/config/netctl.conf"));
bool exists = confFile.open(QIODevice::ReadOnly);
if (!exists) {
confFile.setFileName("/usr/share/config/netctl.conf");
exists = confFile.open(QIODevice::ReadOnly);
if (!exists)
return false;
}
QStringList value;
while (true) {
fileStr = QString(confFile.readLine());
if (confFile.atEnd())
break;
else if (fileStr[0] != '#') {
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIP"))
checkExtIP = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("CMD"))
cmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIPCMD"))
extIpCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("IPCMD"))
ipCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("NETDIR"))
netDir = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
fileStr = QString(configFile.readLine()).trimmed();
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
if (fileStr.contains(QChar('='))) {
value.clear();
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
value.append(fileStr.split(QChar('='))[i]);
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
}
if (configFile.atEnd()) break;
}
configFile.close();
configuration = updateConfiguration(rawConfig);
return;
}
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
{
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> config;
QString key, value;
// remove spaces and copy source map
for (int i=0; i<rawConfig.keys().count(); i++) {
key = rawConfig.keys()[i];
value = rawConfig[key];
key.remove(QChar(' '));
if ((key != QString("EXTIP4CMD")) &&
(key != QString("EXTIP6CMD")) &&
(key != QString("NETCTLCMD")) &&
(key != QString("NETCTLAUTOCMD")))
value.remove(QChar(' '));
config[key] = value;
}
confFile.close();
return true;
for (int i=0; i<config.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + config[config.keys()[i]];
return config;
}
bool Netctl::sourceRequestEvent(const QString &name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source name" << name;
return updateSourceEvent(name);
}
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString cmd;
if (netctlAutoStatus)
cmd = cmdNetctlAuto;
else
cmd = cmdNetctl;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QStringList currentProfile;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i][0] == QChar('*'))
currentProfile.append(profileList[i]);
for (int i=0; i<currentProfile.count(); i++)
currentProfile[i].remove(0, 2);
return currentProfile;
}
QString Netctl::getExtIp(const QString cmd)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
return extIp;
}
QStringList Netctl::getInterfaceList()
{
if (debug) qDebug() << PDEBUG;
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
QStringList interfacesList;
for (int i=0; i<rawList.count(); i++)
interfacesList.append(rawList[i].name());
return interfacesList;
}
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
{
if (debug) qDebug() << PDEBUG;
QString intIp = QString("");
if (protocol == QAbstractSocket::IPv4Protocol)
intIp = QString("127.0.0.1/8");
else if (protocol == QAbstractSocket::IPv6Protocol)
intIp = QString("::1/128");
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
for (int i=0; i<rawList.count(); i++) {
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
if (rawList[i].protocol() == protocol) {
intIp = rawList[i].toString();
break;
}
}
return intIp;
}
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString status;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
if (cmdOutput.isEmpty()) {
netctlAutoStatus = false;
status = QString("false");
} else {
netctlAutoStatus = true;
status = QString("true");
}
return status;
}
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString cmd;
if (netctlAutoStatus)
cmd = cmdNetctlAuto;
else
cmd = cmdNetctl;
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
TaskResult process = runTask(cmd + QString(" list"));
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
profileList[i].remove(0, 2);
return profileList;
}
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QStringList status;
if (netctlAutoStatus)
status.append(QString("netctl-auto"));
else {
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
for (int i=0; i<profiles.count(); i++) {
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode == 0)
status.append(QString("enabled"));
else
status.append(QString("static"));
}
}
return status;
}
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
if (debug) qDebug() << PDEBUG;
getNetctlAutoStatus(cmdNetctlAuto);
QString status = QString("false");
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
if (!currentProfile.isEmpty())
status = QString("true");
return status;
}
bool Netctl::updateSourceEvent(const QString &source)
{
QProcess command;
QString cmdOutput = QString("");
QString value = QString("");
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Source name" << source;
if (source == QString("currentProfile")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != QString("")) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
value = profileList[i].split(QString(" "), QString::SkipEmptyParts)[1];
break;
}
}
setData(source, QString("value"), value);
}
else if (source == QString("extIp")) {
if (checkExtIP == QString("true")) {
command.start(extIpCmd);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != QString(""))
value = cmdOutput.split(QString("\n"), QString::SkipEmptyParts)[0];
}
setData(source, QString("value"), value);
}
else if (source == QString("interfaces")) {
if (QDir(netDir).exists())
value = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot).join(QString(","));
setData(source, QString("value"), value);
}
else if (source == QString("intIp")) {
if (QDir(netDir).exists()) {
value = QString("127.0.0.1/8");
QStringList netDevices = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<netDevices.count(); i++)
if (netDevices[i] != QString("lo")) {
cmdOutput = QString("");
command.start(ipCmd + QString(" addr show ") + netDevices[i]);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != QString("")) {
QStringList deviceInfo = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int j=0; j<deviceInfo.count(); j++)
if (deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[0] == QString("inet"))
value = deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[1];
}
}
}
setData(source, QString("value"), value);
}
else if (source == QString("profiles")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
QStringList list;
if (cmdOutput != QString("")) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 1)
list.append(profileList[i].split(QString(" "), QString::SkipEmptyParts)[0]);
else if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2)
list.append(profileList[i].split(QString(" "), QString::SkipEmptyParts)[1]);
}
value = list.join(QString(","));
setData(source, QString("value"), value);
}
else if (source == QString("statusBool")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
value = QString("false");
if (cmdOutput != QString("")) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
value = QString("true");
break;
}
}
setData(source, QString("value"), value);
}
else if (source == QString("statusString")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
QString currentProfile;
if (cmdOutput != QString("")) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
currentProfile = profileList[i].split(QString(" "), QString::SkipEmptyParts)[1];
break;
}
}
command.start(cmd + QString(" status ") + currentProfile);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != QString("")) {
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profile.count(); i++)
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
if (profile[i].indexOf(QString("enabled")) > -1) {
value = QString("enabled");
break;
}
else if (profile[i].indexOf(QString("static")) > -1) {
value = QString("static");
break;
}
}
}
setData(source, QString("value"), value);
QString value = QString("N\\A");
if (source == QString("active")) {
value = getStatus(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")]);
} else if (source == QString("current")) {
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")])
.join(QChar('|'));
} else if (source == QString("extip4")) {
if (configuration[QString("EXTIP4")] == QString("true"))
value = getExtIp(configuration[QString("EXTIP4CMD")]);
} else if (source == QString("extip6")) {
if (configuration[QString("EXTIP6")] == QString("true"))
value = getExtIp(configuration[QString("EXTIP6CMD")]);
} else if (source == QString("interfaces")) {
value = getInterfaceList().join(QChar(','));
} else if (source == QString("intip4")) {
value = getIntIp(QAbstractSocket::IPv4Protocol);
} else if (source == QString("intip6")) {
value = getIntIp(QAbstractSocket::IPv6Protocol);
} else if (source == QString("netctlauto")) {
value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]);
} else if (source == QString("profiles")) {
value = getProfileList(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")])
.join(QChar(','));
} else if (source == QString("status")) {
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
configuration[QString("NETCTLAUTOCMD")])
.join(QChar('|'));
}
setData(source, QString("value"), value);
return true;
}

View File

@ -1,24 +1,26 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTL_DE_H
#define NETCTL_DE_H
#include <Plasma/DataEngine>
#include <QAbstractSocket>
class Netctl : public Plasma::DataEngine
{
@ -26,24 +28,30 @@ class Netctl : public Plasma::DataEngine
public:
Netctl(QObject *parent, const QVariantList &args);
~Netctl();
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
QString getExtIp(const QString cmd);
QStringList getInterfaceList();
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
protected:
bool readConfiguration();
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList sources() const;
private:
bool netctlAutoStatus;
QString currentProfile;
// configuration
// enable check external IP
QString checkExtIP;
// path to netctl command
QString cmd;
// command to check external IP
QString extIpCmd;
// path to ip command
QString ipCmd;
// path to directory with network device configuration
QString netDir;
bool debug;
QMap<QString, QString> configuration;
void readConfiguration();
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
};
#endif /* NETCTL_DE_H */

View File

@ -1,10 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Name=Netctl DataEngine
Name=Netctl
Comment=Data engine for netctl
ServiceTypes=Plasma/DataEngine
Type=Service
Icon=netctl-gui
Icon=netctl-gui-widget
X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_netctl

View File

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

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,380 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>netctl-gui DBus API desription</title>
<style type="text/css">
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 5px 10px;
border: 1px solid #000000;
};
td {
text-align: justify;
}
th {
text-align: center;
}
th.sub {
font-style: italic;
font-weight: normal;
}
</style>
<h1>netctl-gui DBus API description</h1>
<h3>Project version : @PROJECT_VERSION@</h3>
<ol>
<li><a href="#api">DBus API</a></li>
<li><a href="#helper">Helper API</a></li>
<ul>
<li><a href="#ctrl">Helper ctrl API</a></li>
<li><a href="#netctl">Helper netctl API</a></li>
</ul>
<li><a href="#gui">GUI API</a></li>
<ul>
<li><a href="#netctlgui">GUI netctlgui API</a></li>
</ul>
<li><a href="#links">External links</a></li>
</ol>
</head>
<body>
<h2><a href="#api" class="anchor" 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>
<p align="center" style="font-size: 70%">
&copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
This software is licensed under @PROJECT_LICENSE@
</p>
</body>
</html>

View File

@ -0,0 +1,105 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>netctl-gui secutiry notes</title>
<style type="text/css">
</style>
<h1>netctl-gui security notes</h1>
<h3>Project version : @PROJECT_VERSION@</h3>
<ol>
<li><a href="#description">Description</a></li>
<li><a href="#arch">Architecture</a></li>
<li><a href="#library">Library</a></li>
<li><a href="#helper">Helper</a></li>
<li><a href="#gui">Graphical interface</a></li>
<li><a href="#kde">KDE components</a></li>
<li><a href="#links">External links</a></li>
</ol>
</head>
<body>
<h2><a href="#description" class="anchor" id="description"></a>Description</h2>
<p></p>
<h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
<img src="architecture.png" alt="architecture" align="middle">
<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>
<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>Netctl profiles module</li>
<ul>
<li>Copying of a temporary profile from home directory to netctl profiles directory. <code>cp</code> command is used for it.</li>
<li>Removal of a profile. <code>rm</code> command is used for it.</li>
</ul>
<li>WiFi module</li>
<ul>
<li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
</ul>
</ul>
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
<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>
<p align="center" style="font-size: 70%">
&copy; 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
This software is licensed under @PROJECT_LICENSE@
</p>
</body>
</html>

Binary file not shown.

79
sources/gui/netctl-gui.1 Normal file
View File

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

View File

@ -0,0 +1,10 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Netctl GUI
Comment=Qt graphical user interface for netctl
Exec=netctl-gui
Icon=netctl-gui.png
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Network

144
sources/gui/netctl.profile Normal file
View File

@ -0,0 +1,144 @@
! - обязательное поле
[ddsg] - условие для этой опции
в массиве первая опция - дефолт
yes - бинарная опция, по дефолту стоит no (и наоборот)
GENERAL
=======
Description=
! Connection=ethernet|wireless|bond|bridge|dummy|pppoe|mobile_ppp|tunnel|tuntap|vlan
! Interface=
BindsToInterfaces=(массив интерфейсов, которые будет ожидать этот профиль)
After=(список профилей, которые будут запущены перед этим)
ExecUpPost=команда, которая будет запущена после
ExecDownPre=команда, которая будет запущена перед
ForceConnect=yes - включить, даже если интерфейс уже поднят
IP
==
! IP=static|dhcp|no
! IP6=static|stateless|dhcp-noaddr|dhcp|no
[IP=static] Address=('192.168.1.23/24' '192.168.1.87/24')
[IP=static] Gateway='192.168.1.1'
Routes=('192.168.0.0/24 via 192.168.1.2')
[IP6=static]|[IP6=stateless] Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
[IP6=static]|[IP6=stateless] Gateway6='1234:0:123::abcd'
Routes6=('192.168.0.0/24 via 192.168.1.2')
[IP=dhcp] DHCPClient=dhcpcd|dhclient
[IP=dhcp] DHCPReleaseOnStop=yes - release the DHCP lease when the profile is stopped.
[IP=dhcp][DHCPClient=dhcpcd] DhcpcdOptions=опции
[IP=dhcp][DHCPClient=dhclient] DhclientOptions=опции
[IP=dhcp][DHCPClient=dhclient] DhclientOptions6=опции
IPCustom=('addr add dev eth0 192.168.1.23/24 brd +' 'route add default via 192.168.1.1') - команда для ip напрямую
Hostname=
DNS=('192.168.1.1')
DNSDomain= domain для /etc/resolv.conf
DNSSearch= search для /etc/resolv.conf
DNSOptions=() массив options для /etc/resolv.conf
TimeoutDHCP=30 - время в секундах
TimeoutDAD=3 - время в секундах для ipv6 удаление дубликата
ETHERNET
========
SkipNoCarrier=yes
Auth8021X=yes
WPAConfigFile=/etc/wpa_supplicant.conf
WPADriver=wired|nl80211|wext
TimeoutCarrier=5
TimeoutWPA=15
+ IP
WIRELESS
========
Security=none|wep|wpa|wpa-configsection|wpa-config
! ESSID=
AP=MAC address
[Security=wep]|[Security=wpa] ! Key='superpass'
Hidden=yes
AdHoc=yes
ScanFrequencies=A space-separated list of frequencies in MHz to scan when searching for the network.
Priority=0
[Security=wpa-configsection] ! WPAConfigSection=(
'ssid="University"'
'key_mgmt=WPA-EAP'
'eap=TTLS'
'group=TKIP'
'pairwise=TKIP CCMP'
'anonymous_identity="anonymous"'
'identity="myusername"'
'password="mypassword"'
'priority=1'
'phase2="auth=PAP"'
)
WPAConfigFile=/etc/wpa_supplicant.conf
Country=страна
WPAGroup=wheel (группа)
WPADriver=nl80211,wext
TimeoutWPA=15
RFKill=for X in 0..2 $(cat /sys/class/rfkill/rfkillX/name)|auto
ExcludeAuto=yes
+ IP
BOND
====
! BindsToInterfaces=
+ IP
BRIDGE
======
! BindsToInterfaces=
+ IP
DUMMY
=====
+ IP
PPPOE
=====
-User='example@yourprovider.com'
-Password='very secret'
ConnectionMode=persist|demand
[ConnectionMode=demand] IdleTimeout=0
MaxFail=5
DefaultRoute=false
UsePeerDNS=false
PPPUnit=ppp0|ppp1|...
-LCPEchoInterval=30
-LCPEchoFailure=4
OptionsFile=доп файл
PPPoEService=имя
PPPoEAC=имя
PPPoESession='sessid:macaddr'
PPPoEMAC=мак
PPPoEIP6=yes
MOBILE_PPP
==========
MaxFail=5
DefaultRoute=false
UsePeerDNS=false
-User='example@yourprovider.com'
-Password='very secret'
AccessPointName=имя
Pin=код
Mode=None|3Gpref|3Gonly|GPRSpref|GPRSonly
OptionsFile=доп файл
TUNNEL
======
Mode=ipip|gre|sit|isatap|ip6ip6|ipip6|ip6gre|any
Local='172.16.0.1'
Remote='216.66.80.26'
+ ip
TUNTAP
======
Mode=tun|tap
User='nobody'
Group='nobody'
+ ip
VLAN
====
! BindsToInterfaces=
VLANID=55

View File

@ -1,28 +1,60 @@
# 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)
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
# include_path
include_directories (${SUBPROJECT_SOURCE_DIR}
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../)
${PROJECT_TRDPARTY_DIR})
link_directories (${PROJECT_LIBRARY}/src/lib)
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
if (USE_QT5)
find_package(Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_wrap_ui (UI_HEADERS ${FORMS})
qt5_add_resources (QRC_SOURCES ${RESOURCES})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
else ()
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
include (${QT_USE_FILE})
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
endif()
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_NEEDED_LIBS})
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)

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 "aboutwindow.h"
#include "ui_aboutwindow.h"
#include <QDebug>
#include <QDialogButtonBox>
#include <QPushButton>
#include <pdebug/pdebug.h>
#include "version.h"
AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
: QMainWindow(parent),
ui(new Ui::AboutWindow),
debug(debugCmd)
{
ui->setupUi(this);
createUi();
}
AboutWindow::~AboutWindow()
{
if (debug) qDebug() << PDEBUG;
delete uiAbout;
delete ui;
}
void AboutWindow::createText()
{
if (debug) qDebug() << PDEBUG;
// 1st tab
uiAbout->label_name->setText(QString(NAME));
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE))
.arg(QApplication::translate("AboutWindow", "Homepage")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY))
.arg(QApplication::translate("AboutWindow", "Repository")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER))
.arg(QApplication::translate("AboutWindow", "Bugtracker")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION))
.arg(QApplication::translate("AboutWindow", "Translation issue")) +\
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES))
.arg(QApplication::translate("AboutWindow", "AUR packages")));
uiAbout->label_license->setText(QString("<small>&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() << PDEBUG;
QWidget *aboutWidget = new QWidget();
uiAbout = new Ui::About;
uiAbout->setupUi(aboutWidget);
ui->verticalLayout->insertWidget(0, aboutWidget);
createText();
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
}
// ESC press event
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Escape)
close();
}

View File

@ -0,0 +1,51 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef ABOUTWINDOW_H
#define ABOUTWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
#include "ui_about.h"
namespace Ui {
class AboutWindow;
}
class AboutWindow : public QMainWindow
{
Q_OBJECT
public:
explicit AboutWindow(QWidget *parent = 0,
const bool debugCmd = false);
~AboutWindow();
private:
Ui::AboutWindow *ui;
Ui::About *uiAbout;
bool debug;
void createText();
void createUi();
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
};
#endif /* ABOUTWINDOW_H */

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutWindow</class>
<widget class="QMainWindow" name="AboutWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>516</width>
<height>431</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

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

View File

@ -0,0 +1,48 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef BRIDGEWIDGET_H
#define BRIDGEWIDGET_H
#include <QWidget>
namespace Ui {
class BridgeWidget;
}
class BridgeWidget : public QWidget
{
Q_OBJECT
public:
explicit BridgeWidget(QWidget *parent = 0);
~BridgeWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::BridgeWidget *ui;
};
#endif /* BRIDGEWIDGET_H */

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BridgeWidget</class>
<widget class="QWidget" name="BridgeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>76</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_bridge">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Bridge settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_bridge">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox_skip">
<property name="toolTip">
<string>Skip (R)STP and immediately activate all bridge members</string>
</property>
<property name="text">
<string>Skip forwarding delay</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

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

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

@ -0,0 +1,200 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "errorwindow.h"
#include <QApplication>
#include <QGridLayout>
#include <QSpacerItem>
#include <QDebug>
#include <pdebug/pdebug.h>
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
: debug(debugCmd)
{
}
ErrorWindow::~ErrorWindow()
{
if (debug) qDebug() << PDEBUG;
}
QStringList ErrorWindow::getMessage(const int mess, const QString custom)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QString message, title;
switch(mess) {
case 1:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find components");
break;
case 2:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Does not support yet");
break;
case 3:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Profile name is not set");
break;
case 4:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Bind interfaces are not set");
break;
case 5:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Description is not set");
break;
case 6:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Ip settings are not set");
break;
case 7:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Configuration file does not exist");
break;
case 8:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Key is not set");
break;
case 9:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Wireless settings are not set");
break;
case 10:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Configuration file is not set");
break;
case 11:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "ESSID is not set");
break;
case 12:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "MAC address is incorrect");
break;
case 13:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Session ID is not set");
break;
case 14:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 15:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 16:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Empty user/group name");
break;
case 17:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find profile");
break;
case 18:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
break;
case 19:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not run helper");
break;
default:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
}
if (!custom.isEmpty())
message = custom;
QStringList fullMessage;
fullMessage.append(title);
fullMessage.append(message);
return fullMessage;
}
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
QMessageBox::Icon icon;
switch(mess) {
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
case 15:
case 16:
case 17:
case 18:
case 19:
icon = QMessageBox::Critical;
break;
default:
icon = QMessageBox::NoIcon;
break;
}
return icon;
}
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
QStringList message = getMessage(mess, custom);
QMessageBox messageBox;
messageBox.setText(message[0]);
messageBox.setInformativeText(message[1]);
if (debug)
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").
arg(sender));
messageBox.setIcon(getIcon(mess));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setDefaultButton(QMessageBox::Ok);
QSpacerItem *horizontalSpacer = new QSpacerItem(400, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout *layout = (QGridLayout *)messageBox.layout();
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
messageBox.exec();
return;
}

View File

@ -0,0 +1,46 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef ERRORWINDOW_H
#define ERRORWINDOW_H
#include <QMessageBox>
#include <QObject>
class ErrorWindow : public QObject
{
Q_OBJECT
public:
explicit ErrorWindow(QWidget *parent = 0,
const bool debugCmd = false);
~ErrorWindow();
public slots:
void showWindow(const int mess = 0,
const QString sender = QString(),
const QString custom = QString());
private:
bool debug;
QStringList getMessage(const int mess, const QString custom = QString());
QMessageBox::Icon getIcon(const int mess);
};
#endif /* ERRORWINDOW_H */

View File

@ -0,0 +1,164 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "ethernetwidget.h"
#include "ui_ethernetwidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
EthernetWidget::EthernetWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::EthernetWidget)
{
ui->setupUi(this);
createActions();
clear();
}
EthernetWidget::~EthernetWidget()
{
delete ui;
}
void EthernetWidget::clear()
{
ui->checkBox_skip->setCheckState(Qt::Unchecked);
ui->checkBox_8021x->setCheckState(Qt::Unchecked);
showWpa(ui->checkBox_8021x->checkState());
ui->lineEdit_wpaConfig->clear();
ui->comboBox_driver->setCurrentIndex(0);
ui->spinBox_timeoutCarrier->setValue(5);
ui->spinBox_timeoutWpa->setValue(15);
ui->pushButton_ethernetAdvanced->setChecked(false);
showAdvanced();
}
void EthernetWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void EthernetWidget::createActions()
{
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
connect(ui->checkBox_8021x, SIGNAL(stateChanged(int)), this, SLOT(showWpa(int)));
}
void EthernetWidget::selectWpaConfig()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
QDir::currentPath(),
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_wpaConfig->setText(filename);
}
void EthernetWidget::showAdvanced()
{
if (ui->pushButton_ethernetAdvanced->isChecked()) {
ui->widget_ethernetAdvanced->setHidden(false);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
} else {
ui->widget_ethernetAdvanced->setHidden(true);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
}
}
void EthernetWidget::showWpa(const int state)
{
if (state == 0)
ui->widget_wpa->setHidden(true);
else
ui->widget_wpa->setHidden(false);
}
QMap<QString, QString> EthernetWidget::getSettings()
{
QMap<QString, QString> ethernetSettings;
if (isOk() != 0)
return ethernetSettings;
if (ui->checkBox_skip->checkState() == Qt::Checked)
ethernetSettings[QString("SkipNoCarrier")] = QString("yes");
if (ui->checkBox_8021x->checkState() == Qt::Checked) {
ethernetSettings[QString("Auth8021X")] = QString("yes");
ethernetSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
ethernetSettings[QString("WPADriver")] = ui->comboBox_driver->currentText();
}
if (ui->spinBox_timeoutCarrier->value() != 5)
ethernetSettings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
if (ui->spinBox_timeoutWpa->value() != 15)
ethernetSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
return ethernetSettings;
}
int EthernetWidget::isOk()
{
// file wpa_supplicant doesn't exists
if (!ui->lineEdit_wpaConfig->text().isEmpty())
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
return 1;
// all fine
return 0;
}
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> ethernetSettings = settings;
if (ethernetSettings.contains(QString("SkipNoCarrier")))
if (ethernetSettings[QString("SkipNoCarrier")] == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("Auth8021X")))
if (ethernetSettings[QString("Auth8021X")] == QString("yes"))
ui->checkBox_8021x->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")]);
if (ethernetSettings.contains(QString("WPADriver")))
for (int i=0; i<ui->comboBox_driver->count(); i++)
if (ethernetSettings[QString("WPADriver")] == ui->comboBox_driver->itemText(i))
ui->comboBox_driver->setCurrentIndex(i);
if (ethernetSettings.contains(QString("TimeoutCarrier")))
ui->spinBox_timeoutCarrier->setValue(ethernetSettings[QString("TimeoutCarrier")].toInt());
if (ethernetSettings.contains(QString("TimeoutWPA")))
ui->spinBox_timeoutWpa->setValue(ethernetSettings[QString("TimeoutWPA")].toInt());
showWpa(ui->checkBox_8021x->checkState());
}

View File

@ -0,0 +1,55 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef ETHERNETWIDGET_H
#define ETHERNETWIDGET_H
#include <QMap>
#include <QWidget>
namespace Ui {
class EthernetWidget;
}
class EthernetWidget : public QWidget
{
Q_OBJECT
public:
explicit EthernetWidget(QWidget *parent = 0);
~EthernetWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void selectWpaConfig();
void showAdvanced();
void showWpa(const int state);
private:
Ui::EthernetWidget *ui;
void createActions();
};
#endif /* ETHERNETWIDGET_H */

View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EthernetWidget</class>
<widget class="QWidget" name="EthernetWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>296</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_ethernet">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Ethernet options</string>
</property>
<widget class="QWidget" name="dockWidgetContents_ethernet">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="layout_ethernetAdvanced">
<item>
<spacer name="spacer_ethernetAdvanced">
<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_ethernetAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ethernetAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="checkBox_skip">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the absence of a carrier is acceptable&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Skip no carrier</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_8021x">
<property name="toolTip">
<string>Set to yes to use 802.1x authentication</string>
</property>
<property name="text">
<string>802.1x authentication</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_wpa" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_wpaConfig">
<item>
<widget class="QLabel" name="label_wpaConfig">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>WPA config file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaConfig">
<property name="toolTip">
<string>Path to a wpa_supplicant configuration file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaConfig">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_driver">
<item>
<widget class="QLabel" name="label_driver">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>WPA driver</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_driver">
<property name="toolTip">
<string>The wpa_supplicant driver to use for 802.1x authentication</string>
</property>
<item>
<property name="text">
<string>wired</string>
</property>
</item>
<item>
<property name="text">
<string>nl80211</string>
</property>
</item>
<item>
<property name="text">
<string>wext</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutCarrier">
<item>
<widget class="QLabel" name="label_timeoutCarrier">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout carrier</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutCarrier">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for a carrier</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutWpa">
<item>
<widget class="QLabel" name="label_timeoutWpa">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout WPA</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutWpa">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>15</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>pushButton_ethernetAdvanced</tabstop>
<tabstop>checkBox_skip</tabstop>
<tabstop>checkBox_8021x</tabstop>
<tabstop>lineEdit_wpaConfig</tabstop>
<tabstop>pushButton_wpaConfig</tabstop>
<tabstop>comboBox_driver</tabstop>
<tabstop>spinBox_timeoutCarrier</tabstop>
<tabstop>spinBox_timeoutWpa</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,206 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "generalwidget.h"
#include "ui_generalwidget.h"
#include <QKeyEvent>
GeneralWidget::GeneralWidget(QWidget *parent, const QMap<QString, QString> settings)
: QWidget(parent),
ui(new Ui::GeneralWidget)
{
ui->setupUi(this);
connectionType = ui->comboBox_connection;
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
createActions();
clear();
}
GeneralWidget::~GeneralWidget()
{
delete connectionType;
delete ifaceDirectory;
delete profileDirectory;
delete ui;
}
void GeneralWidget::clear()
{
ui->lineEdit_description->setText(QString("Generated by Netctl GUI"));
ui->comboBox_connection->setCurrentIndex(0);
ui->comboBox_interface->clear();
ui->comboBox_interface->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
ui->comboBox_bindto->clear();
ui->comboBox_bindto->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
ui->listWidget_bindto->setCurrentRow(-1);
ui->listWidget_bindto->clear();
ui->comboBox_after->clear();
ui->comboBox_after->addItems(profileDirectory->entryList(QDir::Files));
ui->listWidget_after->setCurrentRow(-1);
ui->listWidget_after->clear();
ui->lineEdit_execUpPost->clear();
ui->lineEdit_execDownPre->clear();
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
ui->checkBox_debug->setCheckState(Qt::Unchecked);
ui->pushButton_generalAdvanced->setChecked(false);
showAdvanced();
}
void GeneralWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void GeneralWidget::createActions()
{
connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_after, SIGNAL(clicked(bool)), this, SLOT(addAfter()));
connect(ui->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
}
void GeneralWidget::addAfter()
{
ui->listWidget_after->addItem(ui->comboBox_after->currentText());
}
void GeneralWidget::addBindTo()
{
ui->listWidget_bindto->addItem(ui->comboBox_bindto->currentText());
}
void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_bindto->hasFocus() &&
(ui->listWidget_bindto->currentItem() != 0))
delete ui->listWidget_bindto->currentItem();
else if (ui->listWidget_after->hasFocus() &&
(ui->listWidget_after->currentItem() != 0))
delete ui->listWidget_after->currentItem();
}
}
void GeneralWidget::showAdvanced()
{
if (ui->pushButton_generalAdvanced->isChecked()) {
ui->widget_generalAdvanced->setHidden(false);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
} else {
ui->widget_generalAdvanced->setHidden(true);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
}
}
QMap<QString, QString> GeneralWidget::getSettings()
{
QMap<QString, QString> generalSettings;
if (isOk() != 0)
return generalSettings;
generalSettings[QString("Description")] = QString("'") + ui->lineEdit_description->text() + QString("'");
generalSettings[QString("Connection")] = ui->comboBox_connection->currentText();
generalSettings[QString("Interface")] = ui->comboBox_interface->currentText();
if (ui->listWidget_bindto->count() != 0) {
QStringList interfaces;
for (int i=0; i<ui->listWidget_bindto->count(); i++)
interfaces.append(ui->listWidget_bindto->item(i)->text());
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QChar(' '));
}
if (ui->listWidget_after->count() != 0) {
QStringList profiles;
for (int i=0; i<ui->listWidget_after->count(); i++)
profiles.append(ui->listWidget_after->item(i)->text());
generalSettings[QString("After")] = profiles.join(QChar(' '));
}
if (!ui->lineEdit_execUpPost->text().isEmpty())
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'");
if (!ui->lineEdit_execDownPre->text().isEmpty())
generalSettings[QString("ExecDownPre")] = QString("'") + ui->lineEdit_execDownPre->text() + QString("'");
if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
generalSettings[QString("ForceConnect")] = QString("yes");
if (ui->checkBox_debug->checkState() == Qt::Checked)
generalSettings[QString("NETCTL_DEBUG")] = QString("yes");
return generalSettings;
}
int GeneralWidget::isOk()
{
// bind interfaces is not set
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
(ui->comboBox_connection->currentText() == QString("vlan")) ||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
if (ui->listWidget_bindto->count() == 0)
return 1;
// empty description
if (ui->lineEdit_description->text().isEmpty())
return 2;
// all fine
return 0;
}
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> generalSettings = settings;
if (generalSettings.contains(QString("Description")))
ui->lineEdit_description->setText(generalSettings[QString("Description")]);
if (generalSettings.contains(QString("Connection")))
for (int i=0; i<ui->comboBox_connection->count(); i++)
if (generalSettings[QString("Connection")] == ui->comboBox_connection->itemText(i))
ui->comboBox_connection->setCurrentIndex(i);
if (generalSettings.contains(QString("Interface"))) {
ui->comboBox_interface->addItem(generalSettings[QString("Interface")]);
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count()-1);
}
if (generalSettings.contains(QString("BindsToInterfaces")))
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QChar('\n')));
if (generalSettings.contains(QString("After")))
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QChar('\n')));
if (generalSettings.contains(QString("ExecUpPost")))
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")]);
if (generalSettings.contains(QString("ExecDownPre")))
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")]);
if (generalSettings.contains(QString("ForceConnect")))
if (generalSettings[QString("ForceConnect")] == QString("yes"))
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
if (generalSettings.contains(QString("NETCTL_DEBUG")))
if (generalSettings[QString("NETCTL_DEBUG")] == QString("yes"))
ui->checkBox_debug->setCheckState(Qt::Checked);
}

View File

@ -0,0 +1,62 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef GENERALWIDGET_H
#define GENERALWIDGET_H
#include <QComboBox>
#include <QDir>
#include <QMap>
#include <QWidget>
namespace Ui {
class GeneralWidget;
}
class GeneralWidget : public QWidget
{
Q_OBJECT
public:
explicit GeneralWidget(QWidget *parent = 0,
const QMap<QString, QString> settings = QMap<QString, QString>());
~GeneralWidget();
QComboBox *connectionType;
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void addAfter();
void addBindTo();
void showAdvanced();
private:
QDir *ifaceDirectory;
QDir *profileDirectory;
Ui::GeneralWidget *ui;
void createActions();
void keyPressEvent(QKeyEvent *pressedKey);
};
#endif /* GENERALWIDGET_H */

View File

@ -0,0 +1,364 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralWidget</class>
<widget class="QWidget" name="GeneralWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>531</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QDockWidget" name="dockWidget_general">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>General</string>
</property>
<widget class="QWidget" name="dockWidgetContents_general">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="layout_description">
<item>
<widget class="QLabel" name="label_description">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_description">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;A description of the profile&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_connection">
<item>
<widget class="QLabel" name="label_connection">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Connection</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_connection">
<property name="toolTip">
<string>The connection type used by the profile</string>
</property>
<item>
<property name="text">
<string notr="true">ethernet</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">wireless</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bond</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bridge</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dummy</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">pppoe</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mobile_ppp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">tunnel</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">tuntap</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">vlan</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">macvlan</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">openvswitch</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_interface">
<item>
<widget class="QLabel" name="label_interface">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Interface</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_interface">
<property name="toolTip">
<string>The name of the associated network interface</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_bindto">
<item>
<layout class="QHBoxLayout" name="layout_bindtoButton">
<item>
<widget class="QLabel" name="label_bindto">
<property name="text">
<string>Binds to interfaces</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_bindto">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_bindto">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_bindto">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="toolTip">
<string>An array of physical network interfaces that this profile needs before it can be started</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_generalAdvanced">
<item>
<spacer name="spacer_generalAdvanced">
<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_generalAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_generalAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="layout_after">
<item>
<layout class="QHBoxLayout" name="layout_afterButton">
<item>
<widget class="QLabel" name="label_after">
<property name="text">
<string>After</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_after">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_after">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_after">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="toolTip">
<string>An array of profile names that should be started before this profile is started</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_execUpPost">
<item>
<widget class="QLabel" name="label_execUpPost">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Command after starting</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_execUpPost">
<property name="toolTip">
<string>A command that is executed after a connection is established</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_execDownPre">
<item>
<widget class="QLabel" name="label_execDownPre">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Command before stoping</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_execDownPre">
<property name="toolTip">
<string>A command that is executed before a connection is brought down</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_forceConnect">
<property name="toolTip">
<string>Set to yes to force connecting even if the interface is up</string>
</property>
<property name="text">
<string>Force connect</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_debug">
<property name="text">
<string>Debug mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

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

View File

@ -0,0 +1,555 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "ipwidget.h"
#include "ui_ipwidget.h"
#include <QKeyEvent>
IpWidget::IpWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::IpWidget)
{
ui->setupUi(this);
createActions();
createFilter();
clear();
}
IpWidget::~IpWidget()
{
delete ui;
}
void IpWidget::clear()
{
ui->checkBox_ip->setCheckState(Qt::Checked);
ui->comboBox_ip->setCurrentIndex(0);
ipEnable(ui->checkBox_ip->checkState());
changeIpMode(ui->comboBox_ip->currentText());
ui->lineEdit_ipAddress->clear();
ui->listWidget_ipAddress->setCurrentRow(-1);
ui->listWidget_ipAddress->clear();
ui->lineEdit_gateway->clear();
ui->lineEdit_ipRoutes->clear();
ui->lineEdit_ipRoutes2->clear();
ui->listWidget_ipRoutes->setCurrentRow(-1);
ui->listWidget_ipRoutes->clear();
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
ui->comboBox_ip6->setCurrentIndex(0);
ip6Enable(ui->checkBox_ip6->checkState());
changeIp6Mode(ui->comboBox_ip6->currentText());
ui->lineEdit_ipAddress6->clear();
ui->listWidget_ipAddress6->setCurrentRow(-1);
ui->listWidget_ipAddress6->clear();
ui->lineEdit_gateway6->clear();
ui->lineEdit_ipRoutes6->clear();
ui->lineEdit_ipRoutes62->clear();
ui->listWidget_ipRoutes6->setCurrentRow(-1);
ui->listWidget_ipRoutes6->clear();
ui->lineEdit_custom->clear();
ui->listWidget_custom->clear();
ui->lineEdit_hostname->clear();
ui->spinBox_timeoutDad->setValue(3);
ui->comboBox_dhcp->setCurrentIndex(0);
changeDhcpClient(ui->comboBox_dhcp->currentText());
ui->lineEdit_dhcpcdOpt->clear();
ui->lineEdit_dhclientOpt->clear();
ui->lineEdit_dhclientOpt6->clear();
ui->spinBox_timeoutDhcp->setValue(30);
ui->checkBox_dhcp->setCheckState(Qt::Unchecked);
ui->lineEdit_dns->clear();
ui->listWidget_dns->setCurrentRow(-1);
ui->listWidget_dns->clear();
ui->lineEdit_dnsDomain->clear();
ui->lineEdit_dnsSearch->clear();
ui->lineEdit_dnsOptions->clear();
ui->listWidget_dnsOptions->setCurrentRow(-1);
ui->listWidget_dnsOptions->clear();
ui->pushButton_ipAdvanced->setChecked(false);;
showAdvanced();
}
void IpWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void IpWidget::createActions()
{
connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
// ip mode
connect(ui->checkBox_ip, SIGNAL(stateChanged(int)), this, SLOT(ipEnable(int)));
connect(ui->comboBox_ip, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIpMode(QString)));
// ipv6 mode
connect(ui->checkBox_ip6, SIGNAL(stateChanged(int)), this, SLOT(ip6Enable(int)));
connect(ui->comboBox_ip6, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIp6Mode(QString)));
// dhcp client
connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
// buttons
connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp()));
connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6()));
connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom()));
connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns()));
connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
}
void IpWidget::createFilter()
{
// using input mask because validators is not comfortable
// ipv4
ui->lineEdit_ipAddress->setInputMask(QString("999.999.999.999/99"));
ui->lineEdit_gateway->setInputMask(QString("999.999.999.999"));
ui->lineEdit_ipRoutes->setInputMask(QString("999.999.999.999/99"));
ui->lineEdit_ipRoutes2->setInputMask(QString("999.999.999.999"));
// ipv6
ui->lineEdit_ipAddress6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999"));
ui->lineEdit_gateway6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh"));
ui->lineEdit_ipRoutes6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999"));
ui->lineEdit_ipRoutes62->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh"));
// dns
ui->lineEdit_dns->setInputMask(QString("999.999.999.999"));
}
void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_ipAddress->hasFocus() &&
(ui->listWidget_ipAddress->currentItem() != 0))
delete ui->listWidget_ipAddress->currentItem();
else if (ui->listWidget_ipRoutes->hasFocus() &&
(ui->listWidget_ipRoutes->currentItem() != 0))
delete ui->listWidget_ipRoutes->currentItem();
else if (ui->listWidget_ipAddress6->hasFocus() &&
(ui->listWidget_ipAddress6->currentItem() != 0))
delete ui->listWidget_ipAddress6->currentItem();
else if (ui->listWidget_ipRoutes6->hasFocus() &&
(ui->listWidget_ipRoutes6->currentItem() != 0))
delete ui->listWidget_ipRoutes6->currentItem();
else if (ui->listWidget_custom->hasFocus() &&
(ui->listWidget_custom->currentItem() != 0))
delete ui->listWidget_custom->currentItem();
else if (ui->listWidget_dns->hasFocus() &&
(ui->listWidget_dns->currentItem() != 0))
delete ui->listWidget_dns->currentItem();
else if (ui->listWidget_dnsOptions->hasFocus() &&
(ui->listWidget_dnsOptions->currentItem() != 0))
delete ui->listWidget_dnsOptions->currentItem();
}
}
QString IpWidget::getIp(const QString rawIp)
{
QStringList ip = rawIp.split(QChar('.'));
// fix empty fields
if (ip[0].isEmpty())
ip[0] = QString("127");
if (ip[1].isEmpty())
ip[1] = QString("0");
if (ip[2].isEmpty())
ip[2] = QString("0");
if (ip[3].isEmpty())
ip[3] = QString("1");
// fix numbers
for (int i=0; i<4; i++)
if (ip[i].toInt() > 255)
ip[i] = QString("255");
return ip.join(QChar('.'));
}
QString IpWidget::getPrefix(const QString rawPrefix)
{
QString prefix;
if (rawPrefix.isEmpty())
prefix = QString("24");
else if (rawPrefix.toInt() > 32)
prefix = QString("32");
else
prefix = rawPrefix;
return prefix;
}
QString IpWidget::getIp6(const QString rawIp)
{
QString ip = rawIp;
for (int i=0; i<5; i++)
ip.replace(QString(":::"), QString("::"));
return ip;
}
QString IpWidget::getPrefix6(const QString rawPrefix)
{
QString prefix;
if (rawPrefix.isEmpty())
prefix = QString("64");
else if (rawPrefix.toInt() > 128)
prefix = QString("128");
else
prefix = rawPrefix;
return prefix;
}
void IpWidget::addIp()
{
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[1]);
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress->clear();
}
void IpWidget::addIpRoutes()
{
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[1]);
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(QChar(' ')));
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes->clear();
ui->lineEdit_ipRoutes2->clear();
}
void IpWidget::addIp6()
{
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[1]);
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress6->clear();
}
void IpWidget::addIpRoutes6()
{
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[1]);
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(QChar(' ')));
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes6->clear();
ui->lineEdit_ipRoutes62->clear();
}
void IpWidget::addCustom()
{
if (!ui->lineEdit_custom->text().isEmpty())
ui->listWidget_custom->addItem(ui->lineEdit_custom->text());
ui->lineEdit_custom->clear();
}
void IpWidget::addDns()
{
QString ip = getIp(ui->lineEdit_dns->text().remove(QChar(' ')));
ui->listWidget_dns->addItem(ip);
ui->lineEdit_dns->clear();
}
void IpWidget::addDnsOpt()
{
if (!ui->lineEdit_dnsOptions->text().isEmpty())
ui->listWidget_dnsOptions->addItem(ui->lineEdit_dnsOptions->text());
ui->lineEdit_dnsOptions->clear();
}
void IpWidget::changeIpMode(const QString currentText)
{
if (currentText == QString("dhcp"))
ui->widget_ip->setHidden(true);
else if (currentText == QString("static"))
ui->widget_ip->setHidden(false);
}
void IpWidget::ipEnable(const int state)
{
if (state == 0) {
ui->comboBox_ip->setDisabled(true);
ui->widget_ip->setDisabled(true);
ui->widget_ipRoutes->setDisabled(true);
} else {
ui->comboBox_ip->setEnabled(true);
ui->widget_ip->setEnabled(true);
ui->widget_ipRoutes->setEnabled(true);
}
}
void IpWidget::changeIp6Mode(const QString currentText)
{
if ((currentText == QString("dhcp")) ||
(currentText == QString("dhcp-noaddr")))
ui->widget_ip6->setHidden(true);
else if ((currentText == QString("static")) ||
(currentText == QString("stateless")))
ui->widget_ip6->setHidden(false);
}
void IpWidget::ip6Enable(const int state)
{
if (state == 0) {
ui->comboBox_ip6->setDisabled(true);
ui->widget_ip6->setDisabled(true);
ui->widget_ipRoutes6->setDisabled(true);
} else {
ui->comboBox_ip6->setEnabled(true);
ui->widget_ip6->setEnabled(true);
ui->widget_ipRoutes6->setEnabled(true);
}
}
void IpWidget::changeDhcpClient(const QString currentText)
{
if (currentText == QString("dhcpcd")) {
ui->widget_dhcpcdOpt->setHidden(false);
ui->widget_dhclientOpt->setHidden(true);
} else if (currentText == QString("dhclient")) {
ui->widget_dhcpcdOpt->setHidden(true);
ui->widget_dhclientOpt->setHidden(false);
}
}
void IpWidget::showAdvanced()
{
if (ui->pushButton_ipAdvanced->isChecked()) {
ui->widget_ipAdvanced->setHidden(false);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
} else {
ui->widget_ipAdvanced->setHidden(true);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
}
}
QMap<QString, QString> IpWidget::getSettings()
{
QMap<QString, QString> ipSettings;
if (isOk() != 0)
return ipSettings;
if (ui->checkBox_ip->checkState() == Qt::Checked) {
ipSettings[QString("IP")] = ui->comboBox_ip->currentText();
if (ui->comboBox_ip->currentText() == QString("static")) {
QStringList addresses;
for (int i=0; i<ui->listWidget_ipAddress->count(); i++)
addresses.append(QString("'") + ui->listWidget_ipAddress->item(i)->text() + QString("'"));
ipSettings[QString("Address")] = addresses.join(QChar(' '));
ipSettings[QString("Gateway")] = QString("'") + ui->lineEdit_gateway->text() + QString("'");
}
if (ui->listWidget_ipRoutes->count() > 0) {
QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
ipSettings[QString("Routes")] = routes.join(QChar(' '));
}
} else
ipSettings[QString("IP")] = QString("no");
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
(ui->comboBox_ip6->currentText() == QString("stateless"))) {
QStringList addresses;
for (int i=0; i<ui->listWidget_ipAddress6->count(); i++)
addresses.append(QString("'") + ui->listWidget_ipAddress6->item(i)->text() + QString("'"));
ipSettings[QString("Address6")] = addresses.join(QChar(' '));
ipSettings[QString("Gateway6")] = QString("'") + ui->lineEdit_gateway6->text() + QString("'");
}
if (ui->listWidget_ipRoutes6->count() > 0) {
QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
}
} else
ipSettings[QString("IP6")] = QString("no");
if (ui->listWidget_custom->count() > 0) {
QStringList custom;
for (int i=0; i<ui->listWidget_custom->count(); i++)
custom.append(QString("'") + ui->listWidget_custom->item(i)->text() + QString("'"));
ipSettings[QString("IPCustom")] = custom.join(QChar(' '));
}
if (!ui->lineEdit_hostname->text().isEmpty())
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'");
if (ui->spinBox_timeoutDad->value() != 3)
ipSettings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value());
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")) {
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
if (!ui->lineEdit_dhclientOpt6->text().isEmpty())
ipSettings[QString("DhclientOptions6")] = QString("'") + ui->lineEdit_dhclientOpt6->text() + QString("'");
}
if (ui->spinBox_timeoutDhcp->value() != 30)
ipSettings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
if (ui->checkBox_dhcp->checkState() == Qt::Checked)
ipSettings[QString("DHCPReleaseOnStop")] = QString("yes");
if (ui->listWidget_dns->count() > 0) {
QStringList dns;
for (int i=0; i<ui->listWidget_dns->count(); i++)
dns.append(QString("'") + ui->listWidget_dns->item(i)->text() + QString("'"));
ipSettings[QString("DNS")] = dns.join(QChar(' '));
}
if (!ui->lineEdit_dnsDomain->text().isEmpty())
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'");
if (!ui->lineEdit_dnsSearch->text().isEmpty())
ipSettings[QString("DNSSearch")] = QString("'") + ui->lineEdit_dnsSearch->text() + QString("'");
if (ui->listWidget_dnsOptions->count() > 0) {
QStringList dnsOpt;
for (int i=0; i<ui->listWidget_dnsOptions->count(); i++)
dnsOpt.append(QString("'") + ui->listWidget_dnsOptions->item(i)->text() + QString("'"));
ipSettings[QString("DNSOptions")] = dnsOpt.join(QChar(' '));
}
return ipSettings;
}
int IpWidget::isOk()
{
// ip settings is not set
if (ui->checkBox_ip->checkState() == Qt::Checked)
if (ui->comboBox_ip->currentText() == QString("static"))
if ((ui->listWidget_ipAddress->count() == 0) ||
(ui->lineEdit_gateway->text().isEmpty()))
return 1;
// ipv6 settings is not set
if (ui->checkBox_ip6->checkState() == Qt::Checked)
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
(ui->comboBox_ip6->currentText() == QString("stateless")))
if ((ui->listWidget_ipAddress6->count() == 0) ||
(ui->lineEdit_gateway6->text().isEmpty()))
return 2;
// all fine
return 0;
}
void IpWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> ipSettings = settings;
if (ipSettings.contains(QString("IP"))) {
if (ipSettings[QString("IP")] == QString("no"))
ui->checkBox_ip->setCheckState(Qt::Unchecked);
else {
ui->checkBox_ip->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip->count(); i++)
if (ipSettings[QString("IP")] == ui->comboBox_ip->itemText(i))
ui->comboBox_ip->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address")))
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway")))
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")]);
if (ipSettings.contains(QString("Routes")))
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].split(QChar('\n')));
if (ipSettings.contains(QString("IP6"))) {
if (ipSettings[QString("IP6")] == QString("no"))
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
else {
ui->checkBox_ip6->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip6->count(); i++)
if (ipSettings[QString("IP6")] == ui->comboBox_ip6->itemText(i))
ui->comboBox_ip6->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address6")))
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway6")))
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")]);
if (ipSettings.contains(QString("Routes6")))
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].split(QChar('\n')));
if (ipSettings.contains(QString("IPCustom")))
ui->listWidget_custom->addItems(ipSettings[QString("IPCustom")].split(QChar('\n')));
if (ipSettings.contains(QString("Hostname")))
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")]);
if (ipSettings.contains(QString("TimeoutDAD")))
ui->spinBox_timeoutDad->setValue(ipSettings[QString("TimeoutDAD")].toInt());
if (ipSettings.contains(QString("DHCPClient")))
for (int i=0; i<ui->comboBox_dhcp->count(); i++)
if (ipSettings[QString("DHCPClient")] == ui->comboBox_dhcp->itemText(i))
ui->comboBox_dhcp->setCurrentIndex(i);
if (ipSettings.contains(QString("DhcpcdOptions")))
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")]
.remove(QChar('\'')).remove(QChar('"')));
if (ipSettings.contains(QString("DhclientOptions")))
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")]);
if (ipSettings.contains(QString("DhclientOptions6")))
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")]);
if (ipSettings.contains(QString("TimeoutDHCP")))
ui->spinBox_timeoutDhcp->setValue(ipSettings[QString("TimeoutDHCP")].toInt());
if (ipSettings.contains(QString("DHCPReleaseOnStop")))
if (ipSettings[QString("DHCPReleaseOnStop")] == QString("yes"))
ui->checkBox_dhcp->setCheckState(Qt::Checked);
if (ipSettings.contains(QString("DNS")))
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].split(QChar('\n')));
if (ipSettings.contains(QString("DNSDomain")))
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")]);
if (ipSettings.contains(QString("DNSSearch")))
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")]);
if (ipSettings.contains(QString("DNSOptions")))
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].split(QChar('\n')));
ipEnable(ui->checkBox_ip->checkState());
changeIpMode(ui->comboBox_ip->currentText());
ip6Enable(ui->checkBox_ip6->checkState());
changeIp6Mode(ui->comboBox_ip6->currentText());
changeDhcpClient(ui->comboBox_dhcp->currentText());
}

View File

@ -0,0 +1,74 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef IPWIDGET_H
#define IPWIDGET_H
#include <QWidget>
namespace Ui {
class IpWidget;
}
class IpWidget : public QWidget
{
Q_OBJECT
public:
explicit IpWidget(QWidget *parent = 0);
~IpWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
// buttons
void addIp();
void addIpRoutes();
void addIp6();
void addIpRoutes6();
void addCustom();
void addDns();
void addDnsOpt();
// ip mode
void changeIpMode(const QString currentText);
void ipEnable(const int state);
// ipv6 mode
void changeIp6Mode(const QString currentText);
void ip6Enable(int state);
// dhcp client
void changeDhcpClient(const QString currentText);
void showAdvanced();
private:
Ui::IpWidget *ui;
void createActions();
void createFilter();
void keyPressEvent(QKeyEvent *pressedKey);
QString getIp(const QString rawIp);
QString getPrefix(const QString rawPrefix);
QString getIp6(const QString rawIp);
QString getPrefix6(const QString rawPrefix);
};
#endif /* IPWIDGET_H */

900
sources/gui/src/ipwidget.ui Normal file
View File

@ -0,0 +1,900 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IpWidget</class>
<widget class="QWidget" name="IpWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<height>1353</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QDockWidget" name="dockWidget_ip">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>IP options</string>
</property>
<widget class="QWidget" name="dockWidgetContents_ip">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="layout_ip">
<item>
<widget class="QCheckBox" name="checkBox_ip">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_ip">
<item>
<property name="text">
<string>dhcp</string>
</property>
</item>
<item>
<property name="text">
<string>static</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ip" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="layout_ipAddress">
<item>
<layout class="QHBoxLayout" name="layout_ipAddressLine">
<item>
<widget class="QLabel" name="label_ipAddress">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipAddress"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipAddress">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipAddress">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of IP addresses suffixed with /&lt;netmask&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_gateway">
<item>
<widget class="QLabel" name="label_gateway">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Gateway</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gateway">
<property name="toolTip">
<string>An IP routing gateway address</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ip6">
<item>
<widget class="QCheckBox" name="checkBox_ip6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>IP6</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_ip6">
<item>
<property name="text">
<string>dhcp</string>
</property>
</item>
<item>
<property name="text">
<string>dhcp-noaddr</string>
</property>
</item>
<item>
<property name="text">
<string>static</string>
</property>
</item>
<item>
<property name="text">
<string>stateless</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ip6" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="layout_ipAddress6">
<item>
<layout class="QHBoxLayout" name="layout_ipAddress6Line">
<item>
<widget class="QLabel" name="label_ipAddress6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Address6</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipAddress6"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipAddress6">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipAddress6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of IPv6 addresses</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_gateway6">
<item>
<widget class="QLabel" name="label_gateway6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Gateway6</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gateway6">
<property name="toolTip">
<string>An IPv6 routing gateway address</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ipAdvanced">
<item>
<spacer name="spacer_ipAdvanced">
<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_ipAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ipAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QWidget" name="widget_ipRoutes" native="true">
<layout class="QVBoxLayout" name="layout_ipRoutes">
<item>
<layout class="QHBoxLayout" name="layout_ipRoutesLine">
<item>
<widget class="QLabel" name="label_ipRoutes">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Routes</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ipRoutesLine2">
<item>
<spacer name="spacer_ipRoutes">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_ipRoutes2">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>via</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes2"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipRoutes">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipRoutes">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of custom routes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_ipRoutes6" native="true">
<layout class="QVBoxLayout" name="layout_ipRoutes6">
<item>
<layout class="QHBoxLayout" name="layout_ipRoutes6Line">
<item>
<widget class="QLabel" name="label_ipRoutes6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Routes6</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes6"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ipRoutes62">
<item>
<spacer name="spacer_ipRoutes6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_ipRoutes62">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>via</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes62"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipRoutes6">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipRoutes6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of custom routes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="layout_custom">
<item>
<layout class="QHBoxLayout" name="layout_customLine">
<item>
<widget class="QLabel" name="label_custom">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Custom</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_custom"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_custom">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_custom">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of argument lines to pass to ip</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_hostmane">
<item>
<widget class="QLabel" name="label_hostname">
<property name="text">
<string>Hostname</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_hostname">
<property name="toolTip">
<string>A system hostname</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutDad">
<item>
<widget class="QLabel" name="label_timeoutDad">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout DAD</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutDad">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for IPv6s Duplicate Address Detection to succeed</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_dhcp" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_dhcp">
<item>
<widget class="QLabel" name="label_dhcp">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DHCP client</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_dhcp">
<property name="toolTip">
<string>The name of the preferred DHCP client</string>
</property>
<item>
<property name="text">
<string>dhcpcd</string>
</property>
</item>
<item>
<property name="text">
<string>dhclient</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_dhcpcdOpt" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_dhcpcdOpt">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>dhcpcd options</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dhcpcdOpt">
<property name="toolTip">
<string>Additional options to be passed to the DHCP client</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_dhclientOpt" native="true">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="layout_dhclientOpt">
<item>
<widget class="QLabel" name="label_dhclientOpt">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>dhclient options</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dhclientOpt">
<property name="toolTip">
<string>Additional options to be passed to the DHCP client</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_dhclientOpt6">
<item>
<widget class="QLabel" name="label_dhclientOpt6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>dhclient options (6)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dhclientOpt6">
<property name="toolTip">
<string>Additional options to be passed to the DHCP client</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutDhcp">
<item>
<widget class="QLabel" name="label_timeoutDhcp">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout DHCP</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutDhcp">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for DHCP to be successful</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_dhcp">
<property name="toolTip">
<string>Set to yes to release the DHCP lease when the profile is stopped</string>
</property>
<property name="text">
<string>DHCP release on stop</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_dns" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="layout_dns">
<item>
<layout class="QHBoxLayout" name="layout_dnsLine">
<item>
<widget class="QLabel" name="label_dns">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dns"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_dns">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_dns">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of DNS nameservers</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_dnsDomain">
<item>
<widget class="QLabel" name="label_dnsDomain">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS domain</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dnsDomain">
<property name="toolTip">
<string>A domain line for /etc/resolv.conf</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_dnsSearch">
<item>
<widget class="QLabel" name="label_dnsSearch">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS search</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dnsSearch">
<property name="toolTip">
<string>A search line for /etc/resolv.conf</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_dnsOptions">
<item>
<layout class="QHBoxLayout" name="layout_dnsOptionsLine">
<item>
<widget class="QLabel" name="label_dnsOptions">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS options</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dnsOptions"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_dnsOptions">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_dnsOptions">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of options lines for /etc/resolv.conf</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>checkBox_ip</tabstop>
<tabstop>comboBox_ip</tabstop>
<tabstop>lineEdit_ipAddress</tabstop>
<tabstop>pushButton_ipAddress</tabstop>
<tabstop>listWidget_ipAddress</tabstop>
<tabstop>lineEdit_gateway</tabstop>
<tabstop>checkBox_ip6</tabstop>
<tabstop>comboBox_ip6</tabstop>
<tabstop>lineEdit_ipAddress6</tabstop>
<tabstop>pushButton_ipAddress6</tabstop>
<tabstop>listWidget_ipAddress6</tabstop>
<tabstop>lineEdit_gateway6</tabstop>
<tabstop>pushButton_ipAdvanced</tabstop>
<tabstop>lineEdit_ipRoutes</tabstop>
<tabstop>lineEdit_ipRoutes2</tabstop>
<tabstop>pushButton_ipRoutes</tabstop>
<tabstop>listWidget_ipRoutes</tabstop>
<tabstop>lineEdit_ipRoutes6</tabstop>
<tabstop>lineEdit_ipRoutes62</tabstop>
<tabstop>pushButton_ipRoutes6</tabstop>
<tabstop>listWidget_ipRoutes6</tabstop>
<tabstop>lineEdit_custom</tabstop>
<tabstop>pushButton_custom</tabstop>
<tabstop>listWidget_custom</tabstop>
<tabstop>lineEdit_hostname</tabstop>
<tabstop>spinBox_timeoutDad</tabstop>
<tabstop>comboBox_dhcp</tabstop>
<tabstop>lineEdit_dhcpcdOpt</tabstop>
<tabstop>lineEdit_dhclientOpt</tabstop>
<tabstop>lineEdit_dhclientOpt6</tabstop>
<tabstop>spinBox_timeoutDhcp</tabstop>
<tabstop>checkBox_dhcp</tabstop>
<tabstop>lineEdit_dns</tabstop>
<tabstop>pushButton_dns</tabstop>
<tabstop>listWidget_dns</tabstop>
<tabstop>lineEdit_dnsDomain</tabstop>
<tabstop>lineEdit_dnsSearch</tabstop>
<tabstop>lineEdit_dnsOptions</tabstop>
<tabstop>pushButton_dnsOptions</tabstop>
<tabstop>listWidget_dnsOptions</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,94 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "macvlanwidget.h"
#include "ui_macvlanwidget.h"
MacvlanWidget::MacvlanWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::MacvlanWidget)
{
ui->setupUi(this);
createFilter();
}
MacvlanWidget::~MacvlanWidget()
{
delete ui;
}
void MacvlanWidget::clear()
{
ui->comboBox_mode->setCurrentIndex(0);
ui->lineEdit_mac->clear();
}
void MacvlanWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MacvlanWidget::createFilter()
{
// mac
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
}
QMap<QString, QString> MacvlanWidget::getSettings()
{
QMap<QString, QString> macvlanSettings;
if (isOk() != 0)
return macvlanSettings;
macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText();
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text();
return macvlanSettings;
}
int MacvlanWidget::isOk()
{
// all fine
return 0;
}
void MacvlanWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> macvlanSettings = settings;
if (macvlanSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (macvlanSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (macvlanSettings.contains(QString("MACAddress")))
ui->lineEdit_mac->setText(macvlanSettings[QString("MACAddress")]);
}

View File

@ -0,0 +1,49 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MACVLANWIDGET_H
#define MACVLANWIDGET_H
#include <QWidget>
namespace Ui {
class MacvlanWidget;
}
class MacvlanWidget : public QWidget
{
Q_OBJECT
public:
explicit MacvlanWidget(QWidget *parent = 0);
~MacvlanWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::MacvlanWidget *ui;
void createFilter();
};
#endif /* MACVLANWIDGET_H */

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MacvlanWidget</class>
<widget class="QWidget" name="MacvlanWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>101</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_macvlan">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>macvlan settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_macvlan">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mode">
<item>
<property name="text">
<string notr="true">bridge</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">vepa</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">private</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">passthru</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="layout_mac">
<item>
<widget class="QLabel" name="label_mac">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>MAC address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mac">
<property name="toolTip">
<string>Optional static MAC address</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

194
sources/gui/src/main.cpp Normal file
View File

@ -0,0 +1,194 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include <QApplication>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDir>
#include <QLibraryInfo>
#include <QTranslator>
#include <iostream>
#include <unistd.h>
#include <language/language.h>
#include "mainwindow.h"
#include "messages.h"
#include "version.h"
using namespace std;
bool existingSessionOperation(const QString operation)
{
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
DBUS_INTERFACE, operation);
QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments();
return !arguments.isEmpty();
}
unsigned int getUidFromSession(const int type = 0)
{
QDBusConnection bus = QDBusConnection::sessionBus();
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_SERVICE, DBUS_OBJECT_PATH,
DBUS_INTERFACE, QString("UIDs"));
QDBusMessage response = bus.call(request);
QList<QVariant> arguments = response.arguments();
return arguments[0].toStringList()[type].toUInt();
}
int main(int argc, char *argv[])
{
QMap<QString, QVariant> args = getArgs();
// reading
for (int i=1; i<argc; i++) {
if (QString(argv[i]) == QString("--detached")) {
// detached
args[QString("detached")] = true;
} else if (QString(argv[i]) == QString("--maximized")) {
// maximized
args[QString("minimized")] = (int) 1;
} else if (QString(argv[i]) == QString("--minimized")) {
// minimized
args[QString("minimized")] = (int) 2;
} else if (QString(argv[i]) == QString("--about")) {
// about
args[QString("about")] = true;
} else if (QString(argv[i]) == QString("--netctl-auto")) {
// netctl-auto
args[QString("auto")] = true;
} else if (QString(argv[i]) == QString("--settings")) {
// settings
args[QString("settings")] = true;
} else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
// select ESSID
args[QString("essid")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
// open profile
args[QString("open")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
// select profile
args[QString("select")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-c")) || (QString(argv[i]) == QString("--config"))) {
// config path
args[QString("config")] = QDir().absoluteFilePath(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
// debug
args[QString("debug")] = true;
} else if (QString(argv[i]) == QString("--default")) {
// default settings
args[QString("default")] = true;
} else if (QString(argv[i]) == QString("--set-opts")) {
// options
args[QString("options")] = QString(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
// tab number
if (atoi(argv[i+1]) > 3)
args[QString("tab")] = (int) 3;
else if (atoi(argv[i+1]) < 1)
args[QString("tab")] = (int) 1;
else
args[QString("tab")] = atoi(argv[i+1]);
i++;
} else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
// help message
args[QString("help")] = true;
} else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
// info message
args[QString("info")] = true;
} else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
// version message
args[QString("version")] = true;
} else {
args[QString("error")] = true;
}
}
if ((args[QString("debug")].toBool()) ||
(args[QString("help")].toBool()) ||
(args[QString("info")].toBool()) ||
(args[QString("version")].toBool()) ||
(args[QString("error")].toBool()))
args[QString("detached")] = false;
if (args[QString("essid")].toString() != QString("ESSID"))
args[QString("tab")] = (int) 3;
if (args[QString("open")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 2;
if (args[QString("select")].toString() != QString("PROFILE"))
args[QString("tab")] = (int) 1;
// detach from console
if (args[QString("detached")].toBool())
daemon(0, 0);
QApplication a(argc, argv);
QApplication::setQuitOnLastWindowClosed(false);
// reread translations according to flags
QString language = Language::defineLanguage(args[QString("config")].toString(),
args[QString("options")].toString());
QTranslator qtTranslator;
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
a.installTranslator(&qtTranslator);
QTranslator translator;
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
// running
if (args[QString("error")].toBool()) {
cout << errorMessage().toUtf8().data() << endl;
cout << helpMessage().toUtf8().data();
return 127;
} else if (args[QString("help")].toBool()) {
cout << helpMessage().toUtf8().data();
return 0;
} else if (args[QString("info")].toBool()) {
cout << versionMessage().toUtf8().data() << endl;
cout << infoMessage().toUtf8().data();
return 0;
} else if (args[QString("version")].toBool()) {
cout << versionMessage().toUtf8().data();
return 0;
}
// check if exists
if (existingSessionOperation(QString("Active"))) {
if ((getuid() == getUidFromSession(0)) && (geteuid() == getUidFromSession(1))) {
// restore session
cout << QCoreApplication::translate("MainWindow", "Restore existing session.")
.toUtf8().data() << endl;
existingSessionOperation(QString("Restore"));
return 0;
} else if ((getuid() == getUidFromSession(0)) && (geteuid() != getUidFromSession(1))) {
cout << QCoreApplication::translate("MainWindow", "Close existing session.")
.toUtf8().data() << endl;
existingSessionOperation(QString("Close"));
}
}
MainWindow w(0, args, &qtTranslator, &translator);
return a.exec();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,522 @@
/***************************************************************************
* 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();
// tray
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
(configuration[QString("SYSTRAY")] == QString("true")))
trayIcon->setVisible(true);
else
trayIcon->setVisible(false);
if (trayIcon->isVisible()) {
if (configuration[QString("STARTTOTRAY")] == QString("true"))
hide();
else
show();
if (args[QString("minimized")].toInt() == 1)
show();
else if (args[QString("minimized")].toInt() == 2)
hide();
}
else
show();
// update ui
setTab(args[QString("tab")].toInt() - 1);
}
void MainWindow::updateMenu()
{
if (debug) qDebug() << PDEBUG;
int tab = ui->tabWidget->currentIndex();
setMenuActionsShown(false);
if (tab == 0)
updateMenuMain();
else if (tab == 1)
updateMenuProfile();
else if (tab == 2)
updateMenuWifi();
}
void MainWindow::updateTabs(const int tab)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
if (tab == 0)
updateMainTab();
else if (tab == 1)
updateProfileTab();
else if (tab == 2)
updateWifiTab();
updateMenu();
}
void MainWindow::connectToUnknownEssid(const QString passwd)
{
if (debug) qDebug() << PDEBUG;
if (passwdWid != 0)
delete passwdWid;
QStringList interfaces;
if (useHelper)
interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
QList<QVariant>(), true, debug)[0].toStringList();
else
interfaces = netctlCommand->getWirelessInterfaceList();
if (interfaces.isEmpty()) return;
QMap<QString, QString> settings;
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
settings[QString("Interface")] = interfaces[0];
settings[QString("Connection")] = QString("wireless");
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text();
if (security.contains(QString("WPA")))
settings[QString("Security")] = QString("wpa");
else if (security.contains(QString("WEP")))
settings[QString("Security")] = QString("wep");
else
settings[QString("Security")] = QString("none");
settings[QString("ESSID")] = QString("'") +
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
QString("'");
if (!passwd.isEmpty())
settings[QString("Key")] = QString("'") + passwd + QString("'");
settings[QString("IP")] = QString("dhcp");
if (hiddenNetwork)
settings[QString("Hidden")] = QString("yes");
QString profile = QString("netctl-gui-") + settings[QString("ESSID")];
profile.remove(QChar('"')).remove(QChar('\''));
bool status = false;
if (useHelper) {
QStringList settingsList;
for (int i=0; i<settings.keys().count(); i++)
settingsList.append(settings.keys()[i] + QString("==") + settings[settings.keys()[i]]);
QList<QVariant> args;
args.append(profile);
args.append(settingsList);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Create"),
args, true, debug);
args.clear();
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Start"),
args, true, debug);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
args, true, debug)[0].toBool();
} else {
QString profileTempName = netctlProfile->createProfile(profile, settings);
netctlProfile->copyProfile(profileTempName);
netctlCommand->startProfile(profile);
status = netctlCommand->isProfileActive(profile);
}
QString message;
if (status) {
message = QApplication::translate("MainWindow", "Connection is successfully.");
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
} else {
message = QApplication::translate("MainWindow", "Connection failed.");
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
message += QString("\n");
message += QApplication::translate("MainWindow", "Do you want to save profile %1?").arg(profile);
int select = QMessageBox::question(this, QApplication::translate("MainWindow", "WiFi menu"),
message, QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save);
switch (select) {
case QMessageBox::Save:
break;
case QMessageBox::Discard:
default:
if (useHelper) {
QList<QVariant> args;
args.append(profile);
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Remove"),
args, true, debug)[0].toBool();
} else
netctlProfile->removeProfile(profile);
break;
}
updateWifiTab();
}
void MainWindow::setHiddenName(const QString name)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Set name" << name;
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
wifiTabStart();
}

View File

@ -0,0 +1,627 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDebug>
#include <pdebug/pdebug.h>
#include <task/taskadds.h>
#include "aboutwindow.h"
#include "bridgewidget.h"
#include "dbusoperation.h"
#include "errorwindow.h"
#include "ethernetwidget.h"
#include "generalwidget.h"
#include "ipwidget.h"
#include "macvlanwidget.h"
#include "mobilewidget.h"
#include "netctlautowindow.h"
#include "netctlguiadaptor.h"
#include "passwdwidget.h"
#include "pppoewidget.h"
#include "settingswindow.h"
#include "trayicon.h"
#include "tunnelwidget.h"
#include "tuntapwidget.h"
#include "version.h"
#include "vlanwidget.h"
#include "wirelesswidget.h"
MainWindow::MainWindow(QWidget *parent,
const QMap<QString, QVariant> args,
QTranslator *qtAppTranslator,
QTranslator *appTranslator)
: QMainWindow(parent),
configPath(args[QString("config")].toString()),
debug(args[QString("debug")].toBool()),
qtTranslator(qtAppTranslator),
translator(appTranslator)
{
setWindowIcon(QIcon(":icon"));
if (debug) qDebug() << PDEBUG << ":" << "about" << args[QString("about")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "auto" << args[QString("auto")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "config" << configPath;
if (debug) qDebug() << PDEBUG << ":" << "debug" << debug;
if (debug) qDebug() << PDEBUG << ":" << "defaults" << args[QString("defaults")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "essid" << args[QString("essid")].toString();
if (debug) qDebug() << PDEBUG << ":" << "minimized" << args[QString("minimized")].toInt();
if (debug) qDebug() << PDEBUG << ":" << "open" << args[QString("open")].toString();
if (debug) qDebug() << PDEBUG << ":" << "options" << args[QString("options")].toString();
if (debug) qDebug() << PDEBUG << ":" << "select" << args[QString("select")].toString();
if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool();
if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt();
updateConfiguration(args);
// main actions
if (args[QString("essid")].toString() != QString("ESSID")) {
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++)
if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString())
ui->tableWidget_wifi->setCurrentCell(i, 0);
if (ui->tableWidget_wifi->currentItem() == 0)
errorWin->showWindow(18, QString(PDEBUG));
} else if (args[QString("open")].toString() != QString("PROFILE")) {
ui->comboBox_profile->addItem(args[QString("open")].toString());
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
} else if (args[QString("select")].toString() != QString("PROFILE")) {
for (int i=0; i<ui->tableWidget_main->rowCount(); i++)
if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString())
ui->tableWidget_main->setCurrentCell(i, 0);
if (ui->tableWidget_main->currentItem() == 0)
errorWin->showWindow(17, QString(PDEBUG));
}
// show windows
if (args[QString("about")].toBool())
showAboutWindow();
if (args[QString("auto")].toBool())
showNetctlAutoWindow();
if (args[QString("settings")].toBool())
showSettingsWindow();
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
}
MainWindow::~MainWindow()
{
if (debug) qDebug() << PDEBUG;
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true")))
forceStopHelper();
deleteObjects();
}
QStringList MainWindow::printInformation()
{
if (debug) qDebug() << PDEBUG;
QString profile;
QString status;
if (useHelper) {
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("Information"),
QList<QVariant>(), true, debug)[0].toStringList();
profile = request[0];
status = request[1];
} else {
if (netctlCommand->isNetctlAutoRunning()) {
profile = netctlCommand->autoGetActiveProfile();
status = QString("netctl-auto");
} else {
QStringList currentProfiles = netctlCommand->getActiveProfile();
profile = currentProfiles.join(QChar('|'));
QStringList statusList;
for (int i=0; i<currentProfiles.count(); i++)
statusList.append(netctlCommand->getProfileStatus(currentProfiles[i]));
status = statusList.join(QChar('|'));
}
}
QStringList output;
output.append(profile);
output.append(status);
return output;
}
QStringList MainWindow::printSettings()
{
if (debug) qDebug() << PDEBUG;
QStringList settingsList;
for (int i=0; i<configuration.keys().count(); i++)
settingsList.append(configuration.keys()[i] + QString("==") +
configuration[configuration.keys()[i]]);
return settingsList;
}
QStringList MainWindow::printTrayInformation()
{
if (debug) qDebug() << PDEBUG;
QStringList information;
QString current;
QString enabled;
bool netctlAutoStatus = false;
QList<netctlProfileInfo> profiles;
if (useHelper) {
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
QList<QVariant>(), true, debug)[0].toString();
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool();
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true, debug), debug);
if (netctlAutoStatus) {
QList<QVariant> args;
args.append(current);
enabled = QString::number(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("autoIsProfileEnabled"),
args, true, debug)[0].toBool());
} else {
QStringList currentProfiles = current.split(QChar('|'));
QStringList enabledList;
for (int i=0; i<currentProfiles.count(); i++) {
QList<QVariant> args;
args.append(currentProfiles[i]);
enabledList.append(QString::number(
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
args, true, debug)[0].toBool()));
enabled = enabledList.join(QChar('|'));
}
}
} else {
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
if (netctlAutoStatus) {
current = netctlCommand->autoGetActiveProfile();
enabled = QString::number(netctlCommand->autoIsProfileEnabled(current));
profiles = netctlCommand->getProfileListFromNetctlAuto();
} else {
QStringList currentProfiles = netctlCommand->getActiveProfile();
current = currentProfiles.join(QChar('|'));
QStringList enabledList;
for (int i=0; i<currentProfiles.count(); i++)
enabledList.append(QString::number(netctlCommand->isProfileEnabled(currentProfiles[i])));
enabled = enabledList.join(QChar('|'));
profiles = netctlCommand->getProfileList();
}
}
information.append(QString::number(netctlAutoStatus));
QStringList profileList;
for (int i=0; i<profiles.count(); i++)
profileList.append(profiles[i].name);
information.append(profileList.join(QChar('|')));
information.append(current);
information.append(enabled);
return information;
}
bool MainWindow::isHelperActive()
{
if (debug) qDebug() << PDEBUG;
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Active"),
QList<QVariant>(), true, debug);
return (!responce.isEmpty());
}
bool MainWindow::isHelperServiceActive()
{
if (debug) qDebug() << PDEBUG;
QString cmd = configuration[QString("SYSTEMCTL_PATH")] + QString(" is-active ") +
configuration[QString("HELPER_SERVICE")];
if (debug) qDebug() << PDEBUG << "Run cmd" << cmd;
TaskResult process = runTask(cmd, false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode != 0)
return false;
else
return true;
}
void MainWindow::closeEvent(QCloseEvent *event)
{
if (debug) qDebug() << PDEBUG;
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
(configuration[QString("SYSTRAY")] == QString("true"))) {
hide();
event->ignore();
} else
closeMainWindow();
}
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
{
if (debug) qDebug() << PDEBUG;
if (configuration[QString("SKIPCOMPONENTS")] == QString("true")) return true;
QStringList cmd;
cmd.append("which");
cmd.append(configuration[QString("SUDO_PATH")]);
if ((apps == QString("helper")) || (apps == QString("all"))) {
cmd.append(configuration[QString("HELPER_PATH")]);
}
if ((apps == QString("netctl")) || (apps == QString("all"))) {
cmd.append(configuration[QString("NETCTL_PATH")]);
cmd.append(configuration[QString("NETCTLAUTO_PATH")]);
}
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
cmd.append(configuration[QString("SYSTEMCTL_PATH")]);
}
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
cmd.append(configuration[QString("WPACLI_PATH")]);
cmd.append(configuration[QString("WPASUP_PATH")]);
}
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd.join(QChar(' '));
TaskResult process = runTask(cmd.join(QChar(' ')), false);
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
if (process.exitCode != 0)
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
if (process.exitCode != 0)
return false;
else
return true;
}
bool MainWindow::checkHelperStatus()
{
if (debug) qDebug() << PDEBUG;
if (useHelper) useHelper = isHelperActive();
if (useHelper)
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("Update"),
QList<QVariant>(), true, debug);
else
configuration[QString("FORCE_SUDO")] = QString("true");
if (isHelperServiceActive())
configuration[QString("CLOSE_HELPER")] = QString("false");
return useHelper;
}
QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool)
return QApplication::translate("MainWindow", "yes");
if (nullFalse)
return QString("");
else
return QApplication::translate("MainWindow", "no");
}
// window signals
void MainWindow::createActions()
{
if (debug) qDebug() << PDEBUG;
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
// main tab events
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
this, SLOT(updateMenuMain()));
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
// profile tab events
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile()));
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
// wifi tab events
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
this, SLOT(updateMenuWifi()));
connect(ui->tableWidget_wifi, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(wifiTabContextualMenu(QPoint)));
}
void MainWindow::createDBusSession()
{
if (debug) qDebug() << PDEBUG;
QDBusConnection bus = QDBusConnection::sessionBus();
if (!bus.registerService(DBUS_SERVICE)) {
if (debug) qDebug() << PDEBUG << ":" << "Could not register service";
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
}
if (!bus.registerObject(DBUS_OBJECT_PATH,
new NetctlGuiAdaptor(this),
QDBusConnection::ExportAllContents)) {
if (debug) qDebug() << PDEBUG << ":" << "Could not register GUI object";
if (debug) qDebug() << PDEBUG << ":" << bus.lastError().message();
}
}
void MainWindow::createObjects()
{
if (debug) qDebug() << PDEBUG;
// error messages
errorWin = new ErrorWindow(this, debug);
// backend
createDBusSession();
if (useHelper)
if (!forceStartHelper()) {
errorWin->showWindow(19, QString(PDEBUG));
useHelper = false;
}
checkHelperStatus();
netctlCommand = new Netctl(debug, configuration);
netctlProfile = new NetctlProfile(debug, configuration);
wpaCommand = new WpaSup(debug, configuration);
// frontend
trayIcon = new TrayIcon(this, debug);
// windows
ui = new Ui::MainWindow;
ui->setupUi(this);
ui->tableWidget_main->setColumnHidden(2, true);
ui->tableWidget_main->setColumnHidden(3, true);
ui->tableWidget_wifi->setColumnHidden(3, true);
ui->tableWidget_wifi->setColumnHidden(4, true);
aboutWin = new AboutWindow(this, debug);
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
settingsWin = new SettingsWindow(this, debug, configPath);
// profile widgets
generalWid = new GeneralWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
ipWid = new IpWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
bridgeWid = new BridgeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
ethernetWid = new EthernetWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
macvlanWid = new MacvlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
tuntapWid = new TuntapWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
vlanWid = new VlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
createToolBars();
}
void MainWindow::createToolBars()
{
if (debug) qDebug() << PDEBUG;
toolBarActions[QString("menu")] = ui->menuBar->addAction(QApplication::translate("MainWindow", "Menu"),
this, SLOT(updateToolBars()));
toolBarActions[QString("actions")] = ui->menuBar->addAction(QApplication::translate("MainWindow", "Actions"),
this, SLOT(updateToolBars()));
toolBarActions[QString("help")] = ui->menuBar->addAction(QApplication::translate("MainWindow", "Help"),
this, SLOT(updateToolBars()));
mainToolBar = new QToolBar(this);
mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("netctlAuto")] = mainToolBar->addAction(QApplication::translate("MainWindow", "netctl-auto"),
this, SLOT(showNetctlAutoWindow()));
toolBarActions[QString("settings")] = mainToolBar->addAction(QIcon::fromTheme(QString("configure")),
QApplication::translate("MainWindow", "Settings"),
this, SLOT(showSettingsWindow()));
appShortcuts[QString("settingsShortcut")] = new QShortcut(QKeySequence(QApplication::translate("MainWindow", "Ctrl+S")),
this, SLOT(showSettingsWindow()));
toolBarActions[QString("quit")] = mainToolBar->addAction(QIcon::fromTheme(QString("exit")),
QApplication::translate("MainWindow", "Quit"),
this, SLOT(closeMainWindow()));
appShortcuts[QString("quitShortcut")] = new QShortcut(QKeySequence(QApplication::translate("MainWindow", "Ctrl+Q")),
this, SLOT(closeMainWindow()));
ui->centralLayout->insertWidget(0, mainToolBar);
mainToolBar->setHidden(true);
actionToolBar = new QToolBar(this);
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("mainRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("stock-refresh")),
QApplication::translate("MainWindow", "Refresh"),
this, SLOT(updateMainTab()));
toolBarActions[QString("profileClear")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-clear")),
QApplication::translate("MainWindow", "Clear"),
this, SLOT(profileTabClear()));
toolBarActions[QString("wifiRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("stock-refresh")),
QApplication::translate("MainWindow", "Refresh"),
this, SLOT(updateWifiTab()));
actionMenu = new QToolButton(this);
actionMenu->setPopupMode(QToolButton::DelayedPopup);
actionMenu->setToolButtonStyle(Qt::ToolButtonFollowStyle);
QMenu *menu = new QMenu(actionMenu);
toolBarActions[QString("mainStart")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("MainWindow", "Start"),
this, SLOT(mainTabStartProfile()));
toolBarActions[QString("mainSwitch")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("MainWindow", "Switch"),
this, SLOT(mainTabSwitchToProfile()));
toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("stock-refresh")),
QApplication::translate("MainWindow", "Restart"),
this, SLOT(mainTabRestartProfile()));
toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("edit-add")),
QApplication::translate("MainWindow", "Enable"),
this, SLOT(mainTabEnableProfile()));
toolBarActions[QString("mainStopAll")] = menu->addAction(QIcon::fromTheme(QString("process-stop")),
QApplication::translate("MainWindow", "Stop all"),
this, SLOT(mainTabStopAllProfiles()));
toolBarActions[QString("profileLoad")] = menu->addAction(QIcon::fromTheme(QString("document-open")),
QApplication::translate("MainWindow", "Load"),
this, SLOT(profileTabLoadProfile()));
toolBarActions[QString("profileSave")] = menu->addAction(QIcon::fromTheme(QString("document-save")),
QApplication::translate("MainWindow", "Save"),
this, SLOT(profileTabCreateProfile()));
toolBarActions[QString("wifiStart")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
QApplication::translate("MainWindow", "Start"),
this, SLOT(wifiTabStart()));
actionMenu->setMenu(menu);
actionToolBar->addWidget(actionMenu);
toolBarActions[QString("mainEdit")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit")),
QApplication::translate("MainWindow", "Edit"),
this, SLOT(mainTabEditProfile()));
toolBarActions[QString("mainRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")),
QApplication::translate("MainWindow", "Remove"),
this, SLOT(mainTabRemoveProfile()));
toolBarActions[QString("profileRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")),
QApplication::translate("MainWindow", "Remove"),
this, SLOT(profileTabRemoveProfile()));
ui->centralLayout->insertWidget(0, actionToolBar);
actionToolBar->setHidden(true);
helpToolBar = new QToolBar(this);
helpToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
toolBarActions[QString("security")] = helpToolBar->addAction(QIcon::fromTheme(QString("security-medium")),
QApplication::translate("MainWindow", "Security"),
this, SLOT(showSecurityNotes()));
toolBarActions[QString("api")] = helpToolBar->addAction(QApplication::translate("MainWindow", "DBus API"),
this, SLOT(showApi()));
toolBarActions[QString("library")] = helpToolBar->addAction(QApplication::translate("MainWindow", "Library"),
this, SLOT(showLibrary()));
helpToolBar->addSeparator();
toolBarActions[QString("report")] = helpToolBar->addAction(QIcon::fromTheme(QString("tools-report-bug")),
QApplication::translate("MainWindow", "Report a bug"),
this, SLOT(reportABug()));
toolBarActions[QString("about")] = helpToolBar->addAction(QIcon::fromTheme(QString("help-about")),
QApplication::translate("MainWindow", "About"),
this, SLOT(showAboutWindow()));
ui->centralLayout->insertWidget(0, helpToolBar);
helpToolBar->setHidden(true);
toolBarActions[QString("menu")]->trigger();
}
void MainWindow::deleteObjects()
{
if (debug) qDebug() << PDEBUG;
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
if (netctlCommand != nullptr) delete netctlCommand;
if (netctlProfile != nullptr) delete netctlProfile;
if (wpaCommand != nullptr) delete wpaCommand;
if (bridgeWid != nullptr) delete bridgeWid;
if (ethernetWid != nullptr) delete ethernetWid;
if (generalWid != nullptr) delete generalWid;
if (ipWid != nullptr) delete ipWid;
if (macvlanWid != nullptr) delete macvlanWid;
if (mobileWid != nullptr) delete mobileWid;
if (pppoeWid != nullptr) delete pppoeWid;
if (tunnelWid != nullptr) delete tunnelWid;
if (tuntapWid != nullptr) delete tuntapWid;
if (vlanWid != nullptr) delete vlanWid;
if (wirelessWid != nullptr) delete wirelessWid;
if (aboutWin != nullptr) delete aboutWin;
if (errorWin != nullptr) delete errorWin;
if (netctlAutoWin != nullptr) delete netctlAutoWin;
if (settingsWin != nullptr) delete settingsWin;
if (actionMenu != nullptr) {
actionMenu->menu()->clear();
delete actionMenu;
}
if (actionToolBar != nullptr) {
actionToolBar->clear();
delete actionToolBar;
}
if (helpToolBar != nullptr) {
helpToolBar->clear();
delete helpToolBar;
}
if (mainToolBar != nullptr) {
mainToolBar->clear();
delete mainToolBar;
delete appShortcuts[QString("settingsShortcut")];
delete appShortcuts[QString("quitShortcut")];
}
if (trayIcon != nullptr) delete trayIcon;
if (ui != nullptr) {
ui->menuBar->clear();
delete ui;
}
}
void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Return)
if (ui->comboBox_profile->hasFocus())
profileTabLoadProfile();
}
QMap<QString, QString> MainWindow::parseOptions(const QString options)
{
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2) continue;
settings[options.split(QChar(','))[i].split(QChar('='))[0]] =
options.split(QChar(','))[i].split(QChar('='))[1];
}
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}

View File

@ -0,0 +1,186 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QApplication>
#include <QMainWindow>
#include <QShortcut>
#include <QTableWidgetItem>
#include <QToolBar>
#include <QToolButton>
#include <netctlgui/netctlgui.h>
class AboutWindow;
class BridgeWidget;
class ErrorWindow;
class EthernetWidget;
class GeneralWidget;
class IpWidget;
class MacvlanWidget;
class MobileWidget;
class NetctlAutoWindow;
class PasswdWidget;
class PppoeWidget;
class SettingsWindow;
class TrayIcon;
class TunnelWidget;
class TuntapWidget;
class VlanWidget;
class WirelessWidget;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0,
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
QTranslator *qtAppTranslator = 0,
QTranslator *appTranslator = 0);
~MainWindow();
QStringList printInformation();
QStringList printSettings();
QStringList printTrayInformation();
bool isHelperActive();
bool isHelperServiceActive();
protected:
void closeEvent(QCloseEvent *event);
public slots:
// actions from trayicon
void closeMainWindow();
void showAboutWindow();
void showMainWindow();
void showNetctlAutoWindow();
void showSettingsWindow();
// trayicon control slots
bool enableProfileSlot(const QString profile);
bool startProfileSlot(const QString profile);
bool stopAllProfilesSlot();
bool switchToProfileSlot(const QString profile);
bool restartProfileSlot(const QString profile);
// open docs
void showApi();
void showLibrary();
void showSecurityNotes();
// helper
bool forceStartHelper();
bool forceStopHelper();
bool startHelper();
// main
void setTab(int tab);
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
void updateMenu();
void updateTabs(const int tab);
// wifi tab slots
void connectToUnknownEssid(const QString passwd);
void setHiddenName(const QString name);
private slots:
void reportABug();
// menu update slots
void setMenuActionsShown(const bool state = true);
void updateMenuMain();
void updateMenuProfile();
void updateMenuWifi();
void updateToolBars();
// tab update slots
void updateMainTab();
void updateProfileTab();
void updateWifiTab();
// main tab slots
void mainTabContextualMenu(const QPoint &pos);
void mainTabEditProfile();
void mainTabEnableProfile();
QStringList mainTabGetActiveProfiles();
void mainTabRemoveProfile();
void mainTabRestartProfile();
void mainTabStartProfile();
void mainTabStopAllProfiles();
void mainTabSwitchToProfile();
// profile tab slots
void profileTabChangeState(const QString current);
void profileTabClear();
void profileTabCreateProfile();
void profileTabLoadProfile();
void profileTabRemoveProfile();
// wifi tab slots
void wifiTabContextualMenu(const QPoint &pos);
void wifiTabSetEnabled(const bool state);
void wifiTabStart();
private:
// ui
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 = nullptr;
NetctlProfile *netctlProfile = nullptr;
WpaSup *wpaCommand = nullptr;
bool checkExternalApps(const QString apps);
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);
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);
};
#endif /* MAINWINDOW_H */

View File

@ -0,0 +1,276 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>Netctl GUI</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="centralLayout">
<item>
<widget class="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>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget_netctlAuto" native="true">
<layout class="QHBoxLayout" name="layout_netctlAuto">
<item>
<widget class="QLabel" name="label_netctlAuto">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>netctl-auto is running</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAuto">
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_main">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column/>
<column/>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_new">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="icon">
<iconset theme="document-new">
<normaloff/>
</iconset>
</attribute>
<attribute name="title">
<string>Create a new profile</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="layout_profile">
<item>
<widget class="QLabel" name="label_profile">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_profile">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>437</width>
<height>371</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="scrollArea_layout"/>
</widget>
</widget>
</item>
</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>WiFi menu</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_wifi">
<property name="text">
<string>Please install 'wpa_supplicant' before using it</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_wifi">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>5</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Signal</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column/>
<column/>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>469</width>
<height>22</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>tableWidget_main</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>tableWidget_wifi</tabstop>
</tabstops>
<resources>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,177 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include <QApplication>
#include <QDir>
#include "messages.h"
#include "version.h"
QString errorMessage()
{
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
return errorMessage;
}
QMap<QString, QVariant> getArgs()
{
QMap<QString, QVariant> args;
// windows
args[QString("detached")] = false;
args[QString("minimized")] = (int) 0;
args[QString("about")] = false;
args[QString("auto")] = false;
args[QString("settings")] = false;
// main functions
args[QString("essid")] = QString("ESSID");
args[QString("open")] = QString("PROFILE");
args[QString("select")] = QString("PROFILE");
// additional functions
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf"));
args[QString("debug")] = false;
args[QString("defaults")] = false;
args[QString("options")] = QString("OPTIONS");
args[QString("tab")] = (int) 1;
// messages
args[QString("error")] = false;
args[QString("help")] = false;
args[QString("info")] = false;
args[QString("version")] = false;
return args;
}
QString helpMessage()
{
QString helpMessage = QString("");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
helpMessage += QString("netctl-gui [ options ]\n");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
// windows
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString(" --detached - %1\n")
.arg(QApplication::translate("MainWindow", "start detached from console"));
helpMessage += QString(" --maximized - %1\n")
.arg(QApplication::translate("MainWindow", "start maximized"));
helpMessage += QString(" --minimized - %1\n")
.arg(QApplication::translate("MainWindow", "start minimized to tray"));
helpMessage += QString(" --about - %1\n")
.arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString(" --netctl-auto - %1\n")
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
helpMessage += QString(" --settings - %1\n")
.arg(QApplication::translate("MainWindow", "show settings window"));
// main functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e, --essid <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "select this ESSID"));
helpMessage += QString(" -o, --open <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "open this profile"));
helpMessage += QString(" -s, --select <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "select this profile"));
// additional functions
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" -c, --config <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
helpMessage += QString(" -d, --debug - %1\n")
.arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString(" --default - %1\n")
.arg(QApplication::translate("MainWindow", "start with default settings"));
helpMessage += QString(" --set-opts <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" -t, --tab <arg> - %1\n")
.arg(QApplication::translate("MainWindow", "open a tab with this number"));
// messages
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v, --version - %1\n")
.arg(QApplication::translate("MainWindow", "show version and exit"));
helpMessage += QString(" -i, --info - %1\n")
.arg(QApplication::translate("MainWindow", "show build information and exit"));
helpMessage += QString(" -h, --help - %1\n")
.arg(QApplication::translate("MainWindow", "show this help and exit"));
return helpMessage;
}
QString infoMessage()
{
QString infoMessage = QString("");
// build information
infoMessage += 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_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

@ -0,0 +1,170 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "mobilewidget.h"
#include "ui_mobilewidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
MobileWidget::MobileWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::MobileWidget)
{
ui->setupUi(this);
createActions();
clear();
}
MobileWidget::~MobileWidget()
{
delete ui;
}
void MobileWidget::clear()
{
ui->lineEdit_username->clear();
ui->lineEdit_password->clear();
ui->lineEdit_apn->clear();
ui->lineEdit_pin->clear();
ui->comboBox_mode->setCurrentIndex(0);
ui->spinBox_fail->setValue(5);
ui->checkBox_route->setCheckState(Qt::Checked);
ui->checkBox_dns->setCheckState(Qt::Checked);
ui->lineEdit_options->clear();
ui->pushButton_mobileAdvanced->setChecked(false);;
showAdvanced();
}
void MobileWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MobileWidget::createActions()
{
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
}
void MobileWidget::selectOptionsFile()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("MobileWidget", "Select options file"),
QDir::currentPath(),
QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_options->setText(filename);
}
void MobileWidget::showAdvanced()
{
if (ui->pushButton_mobileAdvanced->isChecked()) {
ui->widget_mobileAdvanced->setHidden(false);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
} else {
ui->widget_mobileAdvanced->setHidden(true);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
}
}
QMap<QString, QString> MobileWidget::getSettings()
{
QMap<QString, QString> mobileSettings;
if (isOk() != 0)
return mobileSettings;
if (!ui->lineEdit_username->text().isEmpty())
mobileSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
if (!ui->lineEdit_password->text().isEmpty())
mobileSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
mobileSettings[QString("AccessPointName")] = ui->lineEdit_apn->text();
if (!ui->lineEdit_pin->text().isEmpty())
mobileSettings[QString("PIN")] = QString("'") + ui->lineEdit_pin->text() + QString("'");
else
mobileSettings[QString("PIN")] = QString("None");
mobileSettings[QString("Mode")] = ui->comboBox_mode->currentText();
if (ui->spinBox_fail->value() != 5)
mobileSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
if (ui->checkBox_route->checkState() == Qt::Unchecked)
mobileSettings[QString("DefaultRoute")] = QString("false");
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
mobileSettings[QString("UsePeerDNS")] = QString("false");
if (!ui->lineEdit_options->text().isEmpty())
mobileSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
return mobileSettings;
}
int MobileWidget::isOk()
{
// APN is not set
if (ui->lineEdit_apn->text().isEmpty())
return 1;
// config file doesn't exist
if (!ui->lineEdit_options->text().isEmpty())
if (!QFile(ui->lineEdit_options->text()).exists())
return 2;
// all fine
return 0;
}
void MobileWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> mobileSettings = settings;
if (mobileSettings.contains(QString("User")))
ui->lineEdit_username->setText(mobileSettings[QString("User")]);
if (mobileSettings.contains(QString("Password")))
ui->lineEdit_password->setText(mobileSettings[QString("Password")]);
if (mobileSettings.contains(QString("AccessPointName")))
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")]);
if (mobileSettings.contains(QString("PIN")))
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")]);
if (mobileSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (mobileSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (mobileSettings.contains(QString("MaxFail")))
ui->spinBox_fail->setValue(mobileSettings[QString("MaxFail")].toInt());
if (mobileSettings.contains(QString("DefaultRoute")))
if (mobileSettings[QString("DefaultRoute")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("UsePeerDNS")))
if (mobileSettings[QString("UsePeerDNS")] == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")]);
}

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/ *
***************************************************************************/
#ifndef MOBILEWIDGET_H
#define MOBILEWIDGET_H
#include <QWidget>
namespace Ui {
class MobileWidget;
}
class MobileWidget : public QWidget
{
Q_OBJECT
public:
explicit MobileWidget(QWidget *parent = 0);
~MobileWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void selectOptionsFile();
void showAdvanced();
private:
Ui::MobileWidget *ui;
void createActions();
};
#endif /* MOBILEWIDGET_H */

View File

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MobileWidget</class>
<widget class="QWidget" name="MobileWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>445</width>
<height>370</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_mobile">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Mobile PPP settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_mobile">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="layout_username">
<item>
<widget class="QLabel" name="label_username">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_username">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_password">
<item>
<widget class="QLabel" name="label_password">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_apn">
<item>
<widget class="QLabel" name="label_apn">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Access point name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_apn">
<property name="toolTip">
<string>The access point (apn) to connect on</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pin">
<item>
<widget class="QLabel" name="label_pin">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PIN</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_pin">
<property name="toolTip">
<string>If your modem requires a PIN to unlock, use this option</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mode">
<property name="toolTip">
<string>This option is used to specify the connection mode</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>3Gpref</string>
</property>
</item>
<item>
<property name="text">
<string>3Gonly</string>
</property>
</item>
<item>
<property name="text">
<string>GPRSpref</string>
</property>
</item>
<item>
<property name="text">
<string>GPRSonly</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mobileAdvanced">
<item>
<spacer name="spacer_mobileAdvanced">
<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_mobileAdvanced">
<property name="text">
<string>Show advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_mobileAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_fail">
<item>
<widget class="QLabel" name="label_fail">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Max fail</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fail">
<property name="toolTip">
<string>The number of consecutive failed connection attempts to tolerate</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_route">
<property name="toolTip">
<string>Use the default route provided by the peer</string>
</property>
<property name="text">
<string>Default route</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_dns">
<property name="toolTip">
<string>Use the DNS provided by the peer</string>
</property>
<property name="text">
<string>Use peer DNS</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_options">
<item>
<widget class="QLabel" name="label_options">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Options file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_options">
<property name="toolTip">
<string>A file to read additional pppd options from</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_options">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEdit_username</tabstop>
<tabstop>lineEdit_password</tabstop>
<tabstop>lineEdit_apn</tabstop>
<tabstop>lineEdit_pin</tabstop>
<tabstop>comboBox_mode</tabstop>
<tabstop>pushButton_mobileAdvanced</tabstop>
<tabstop>spinBox_fail</tabstop>
<tabstop>checkBox_route</tabstop>
<tabstop>checkBox_dns</tabstop>
<tabstop>lineEdit_options</tabstop>
<tabstop>pushButton_options</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,467 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctlautowindow.h"
#include "ui_netctlautowindow.h"
#include <QDebug>
#include <netctlgui/netctlgui.h>
#include <pdebug/pdebug.h>
#include "dbusoperation.h"
#include "version.h"
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
: QMainWindow(parent),
ui(new Ui::NetctlAutoWindow),
debug(debugCmd)
{
if (settings[QString("USE_HELPER")] == QString("true"))
useHelper = true;
else
useHelper = false;
ui->setupUi(this);
ui->tableWidget->setColumnHidden(2, true);
ui->tableWidget->setColumnHidden(3, true);
netctlCommand = new Netctl(debug, settings);
createActions();
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
}
NetctlAutoWindow::~NetctlAutoWindow()
{
if (debug) qDebug() << PDEBUG;
delete ui;
delete netctlCommand;
}
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
{
if (debug) qDebug() << PDEBUG;
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
if (statusBool)
return QApplication::translate("NetctlAutoWindow", "yes");
if (nullFalse)
return QString("");
else
return QApplication::translate("NetctlAutoWindow", "no");
}
void NetctlAutoWindow::createActions()
{
if (debug) qDebug() << PDEBUG;
// menu actions
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
// service
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService()));
connect(ui->actionStartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartService()));
// table actions
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile()));
connect(ui->tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
// buttons
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile()));
}
void NetctlAutoWindow::showWindow()
{
if (debug) qDebug() << PDEBUG;
netctlAutoUpdateTable();
show();
}
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
// create menu
QMenu menu(this);
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
startProfile->setIcon(QIcon::fromTheme("system-run"));
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
menu.addSeparator();
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
// set text
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty()) {
enableProfile->setVisible(false);
startProfile->setVisible(false);
} else {
enableProfile->setVisible(true);
startProfile->setVisible(true);
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
} else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
}
}
// actions
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (action == startProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Switch to profile";
netctlAutoStartProfile();
} else if (action == enableProfile) {
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
netctlAutoEnableProfile();
} else if (action == enableAllProfiles) {
if (debug) qDebug() << PDEBUG << ":" << "Enable all profiles";
netctlAutoEnableAllProfiles();
} else if (action == disableAllProfiles) {
if (debug) qDebug() << PDEBUG << ":" << "Disable all profiles";
netctlAutoDisableAllProfiles();
}
}
void NetctlAutoWindow::netctlAutoUpdateTable()
{
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
// actions
bool enabled = false;
bool running = false;
if (useHelper) {
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
QList<QVariant>(), true, debug)[0].toBool();
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
QList<QVariant>(), true, debug)[0].toBool();
} else {
enabled = netctlCommand->isNetctlAutoEnabled();
running = netctlCommand->isNetctlAutoRunning();
}
if (enabled)
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true);
if (running) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionDisableAll->setVisible(true);
ui->actionEnableAll->setVisible(true);
ui->actionRestartService->setVisible(true);
} else {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionDisableAll->setVisible(false);
ui->actionEnableAll->setVisible(false);
ui->actionRestartService->setVisible(false);
netctlAutoRefreshButtons(0, 0);
return;
}
QList<netctlProfileInfo> profiles;
if (useHelper)
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
DBUS_HELPER_INTERFACE, QString("ProfileList"),
QList<QVariant>(), true, debug), debug);
else
profiles = netctlCommand->getProfileListFromNetctlAuto();
ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1);
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget->clear();
ui->tableWidget->setRowCount(profiles.count());
// create header
QStringList headerList;
headerList.append(QApplication::translate("NetctlAutoWindow", "Name"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Description"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Active"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled"));
ui->tableWidget->setHorizontalHeaderLabels(headerList);
// create items
for (int i=0; i<profiles.count(); i++) {
// font
QFont font;
font.setBold(profiles[i].active);
font.setItalic(profiles[i].enabled);
// tooltip
QString toolTip = QString("");
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name);
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active));
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled));
// name
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
ui->tableWidget->item(i, 0)->setFont(font);
// description
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
// active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
// enabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
ui->tableWidget->setSortingEnabled(true);
ui->tableWidget->resizeRowsToContents();
ui->tableWidget->resizeColumnsToContents();
ui->tableWidget->resizeRowsToContents();
#if QT_VERSION >= 0x050000
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#else
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#endif
ui->tableWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
netctlAutoRefreshButtons(0, 0);
update();
}
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
{
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoDisableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableProfile()
{
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
bool status = false;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoEnable"),
args, true, debug)[0].toBool();
} else
status = netctlCommand->autoEnableProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
{
if (debug) qDebug() << PDEBUG;
ui->tableWidget->setDisabled(true);
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoEnableAllProfiles();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoStartProfile()
{
if (debug) qDebug() << PDEBUG;
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
bool status = false;
if (useHelper) {
QList<QVariant> args;
args.append(profile);
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoStart"),
args, true, debug)[0].toBool();
} else
status = netctlCommand->autoStartProfile(profile);
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoEnableService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoRestartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << PDEBUG;
bool status = false;
if (useHelper)
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
QList<QVariant>(), true, debug)[0].toBool();
else
status = netctlCommand->autoStartService();
if (status)
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << PDEBUG;
if (current == 0) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
return;
}
if (!ui->tableWidget->item(current->row(), 2)->text().isEmpty()) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
} else {
// buttons
ui->pushButton_enable->setEnabled(true);
ui->pushButton_switch->setEnabled(true);
// menu
ui->actionEnable->setVisible(true);
ui->actionSwitch->setVisible(true);
if (!ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
} else {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
}
}
}

View File

@ -0,0 +1,70 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTLAUTOWINDOW_H
#define NETCTLAUTOWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
#include <QTableWidgetItem>
class Netctl;
namespace Ui {
class NetctlAutoWindow;
}
class NetctlAutoWindow : public QMainWindow
{
Q_OBJECT
public:
explicit NetctlAutoWindow(QWidget *parent = 0,
const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
~NetctlAutoWindow();
public slots:
void showWindow();
private slots:
// table
void netctlAutoContextualMenu(const QPoint &pos);
void netctlAutoUpdateTable();
// netctl-auto
void netctlAutoDisableAllProfiles();
void netctlAutoEnableProfile();
void netctlAutoEnableAllProfiles();
void netctlAutoStartProfile();
void netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// service
void netctlAutoEnableService();
void netctlAutoRestartService();
void netctlAutoStartService();
private:
Netctl *netctlCommand = nullptr;
Ui::NetctlAutoWindow *ui = nullptr;
bool debug = false;
bool useHelper = true;
QString checkStatus(const bool statusBool, const bool nullFalse = false);
void createActions();
};
#endif /* NETCTLAUTOWINDOW_H */

View File

@ -0,0 +1,238 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NetctlAutoWindow</class>
<widget class="QMainWindow" name="NetctlAutoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>339</height>
</rect>
</property>
<property name="windowTitle">
<string>netctl-auto</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_info">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>4</number>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_buttons">
<item>
<widget class="QPushButton" name="pushButton_refresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_enable">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable</string>
</property>
<property name="icon">
<iconset theme="edit-add"/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_switch">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Switch</string>
</property>
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>428</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionSwitch"/>
<addaction name="actionEnable"/>
<addaction name="separator"/>
<addaction name="actionEnableAll"/>
<addaction name="actionDisableAll"/>
<addaction name="separator"/>
<addaction name="actionStartService"/>
<addaction name="actionRestartService"/>
<addaction name="actionEnableService"/>
<addaction name="separator"/>
<addaction name="actionClose"/>
</widget>
<addaction name="menuMenu"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionSwitch">
<property name="icon">
<iconset theme="system-run">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Switch to profile</string>
</property>
</action>
<action name="actionClose">
<property name="icon">
<iconset theme="exit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="shortcut">
<string>Esc</string>
</property>
</action>
<action name="actionEnableAll">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable all profiles</string>
</property>
</action>
<action name="actionDisableAll">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Disable all profiles</string>
</property>
</action>
<action name="actionStartService">
<property name="text">
<string>Start service</string>
</property>
</action>
<action name="actionRestartService">
<property name="text">
<string>Restart service</string>
</property>
</action>
<action name="actionEnableService">
<property name="text">
<string>Enable service</string>
</property>
</action>
<action name="actionRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

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

@ -0,0 +1,91 @@
/***************************************************************************
* 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 "passwdwidget.h"
#include "ui_passwdwidget.h"
#include <QLineEdit>
#include "mainwindow.h"
PasswdWidget::PasswdWidget(MainWindow *wid)
: QWidget(wid),
parent(wid),
ui(new Ui::PasswdWidget)
{
ui->setupUi(this);
createActions();
}
PasswdWidget::~PasswdWidget()
{
delete ui;
}
// ESC press event
void PasswdWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Escape)
cancel();
}
void PasswdWidget::createActions()
{
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(passwdApply()));
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(cancel()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(passwdApply()));
}
void PasswdWidget::setFocusToLineEdit()
{
ui->lineEdit->setFocus(Qt::ActiveWindowFocusReason);
}
void PasswdWidget::setPassword(const bool mode)
{
if (mode) {
ui->lineEdit->setEchoMode(QLineEdit::Password);
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
} else {
ui->lineEdit->setEchoMode(QLineEdit::Normal);
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
}
}
void PasswdWidget::cancel()
{
hide();
parent->updateTabs(2);
this->~PasswdWidget();
}
void PasswdWidget::passwdApply()
{
hide();
if (ui->lineEdit->echoMode() == QLineEdit::Normal)
return parent->setHiddenName(ui->lineEdit->text());
else
return parent->connectToUnknownEssid(ui->lineEdit->text());
}

View File

@ -0,0 +1,57 @@
/***************************************************************************
* 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 PASSWDWIDGET_H
#define PASSWDWIDGET_H
#include <QKeyEvent>
#include <QPushButton>
#include <QWidget>
class MainWindow;
namespace Ui {
class PasswdWidget;
}
class PasswdWidget : public QWidget
{
Q_OBJECT
public:
explicit PasswdWidget(MainWindow *wid = 0);
~PasswdWidget();
public slots:
void setFocusToLineEdit();
void setPassword(const bool mode = true);
private slots:
void cancel();
void passwdApply();
private:
MainWindow *parent;
Ui::PasswdWidget *ui;
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
void createActions();
};
#endif /* PASSWDWIDGET_H */

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PasswdWidget</class>
<widget class="QWidget" name="PasswdWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>86</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_passwd">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_button">
<item>
<spacer name="spacer_button1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_button2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,241 @@
/***************************************************************************
* 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 "pppoewidget.h"
#include "ui_pppoewidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
PppoeWidget::PppoeWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::PppoeWidget)
{
ui->setupUi(this);
createActions();
createFilter();
clear();
}
PppoeWidget::~PppoeWidget()
{
delete ui;
}
void PppoeWidget::clear()
{
ui->lineEdit_username->clear();
ui->lineEdit_password->clear();
ui->comboBox_connection->setCurrentIndex(0);
changeMode(ui->comboBox_connection->currentText());
ui->spinBox_timeout->setValue(300);
ui->spinBox_fail->setValue(5);
ui->checkBox_route->setCheckState(Qt::Checked);
ui->checkBox_dns->setCheckState(Qt::Checked);
ui->lineEdit_unit->clear();
ui->spinBox_lcpInterval->setValue(30);
ui->spinBox_lcpFailure->setValue(4);
ui->lineEdit_options->clear();
ui->lineEdit_service->clear();
ui->lineEdit_ac->clear();
ui->lineEdit_session->clear();
ui->lineEdit_mac->clear();
ui->checkBox_ipv6->setCheckState(Qt::Unchecked);
ui->pushButton_pppoeAdvanced->setChecked(false);;
showAdvanced();
}
void PppoeWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void PppoeWidget::createFilter()
{
// session mac
ui->lineEdit_session->setInputMask(QString(">99999:HH:HH:HH:HH:HH:HH"));
// mac
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
}
void PppoeWidget::createActions()
{
connect(ui->pushButton_pppoeAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->comboBox_connection, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeMode(QString)));
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
}
void PppoeWidget::changeMode(const QString currentText)
{
if (currentText == QString("persist"))
ui->widget_timeout->setHidden(true);
else if (currentText == QString("demand"))
ui->widget_timeout->setHidden(false);
}
void PppoeWidget::selectOptionsFile()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("PppoeWidget", "Select options file"),
QDir::currentPath(),
QApplication::translate("PppoeWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_options->setText(filename);
}
void PppoeWidget::showAdvanced()
{
if (ui->pushButton_pppoeAdvanced->isChecked()) {
ui->widget_pppoeAdvanced->setHidden(false);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
} else {
ui->widget_pppoeAdvanced->setHidden(true);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
}
}
QMap<QString, QString> PppoeWidget::getSettings()
{
QMap<QString, QString> pppoeSettings;
if (isOk() != 0)
return pppoeSettings;
if (!ui->lineEdit_username->text().isEmpty())
pppoeSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
if (!ui->lineEdit_password->text().isEmpty())
pppoeSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
pppoeSettings[QString("ConnectionMode")] = QString("'") + ui->comboBox_connection->currentText() + QString("'");
if (ui->comboBox_connection->currentText() == QString("demand"))
pppoeSettings[QString("IdleTimeout")] = QString::number(ui->spinBox_timeout->value());
if (ui->spinBox_fail->value() != 5)
pppoeSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
if (ui->checkBox_route->checkState() == Qt::Unchecked)
pppoeSettings[QString("DefaultRoute")] = QString("false");
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
pppoeSettings[QString("UsePeerDNS")] = QString("false");
if (!ui->lineEdit_unit->text().isEmpty())
pppoeSettings[QString("PPPUnit")] = ui->lineEdit_unit->text();
if (ui->spinBox_lcpInterval->value() != 30)
pppoeSettings[QString("LCPEchoInterval")] = QString::number(ui->spinBox_lcpInterval->value());
if (ui->spinBox_lcpFailure->value() != 4)
pppoeSettings[QString("LCPEchoFailure")] = QString::number(ui->spinBox_lcpFailure->value());
if (!ui->lineEdit_options->text().isEmpty())
pppoeSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
if (!ui->lineEdit_service->text().isEmpty())
pppoeSettings[QString("PPPoEService")] = QString("'") + ui->lineEdit_service->text() + QString("'");
if (!ui->lineEdit_ac->text().isEmpty())
pppoeSettings[QString("PPPoEAC")] = QString("'") + ui->lineEdit_ac->text() + QString("'");
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text()
.remove(QChar('\'')).remove(QChar('"')) + QString("'");
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
pppoeSettings[QString("PPPoEMAC")] = QString("'") + ui->lineEdit_mac->text() + QString("'");
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
return pppoeSettings;
}
int PppoeWidget::isOk()
{
// config file doesn't exist
if (!ui->lineEdit_options->text().isEmpty())
if (!QFile(ui->lineEdit_options->text()).exists())
return 1;
// mac address
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
if (ui->lineEdit_mac->text().contains(QChar(' ')))
return 2;
// session id is not set
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
if (ui->lineEdit_session->text().split(QChar(':'))[0].remove(QChar(' ')).isEmpty())
return 3;
// session mac address
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty()) {
QStringList item = ui->lineEdit_session->text().split(QChar(':'));
for (int i=1; i<7; i++)
if (item[i].contains(QChar(' ')))
return 4;
}
// all fine
return 0;
}
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> pppoeSettings = settings;
if (pppoeSettings.contains(QString("User")))
ui->lineEdit_username->setText(pppoeSettings[QString("User")]);
if (pppoeSettings.contains(QString("Password")))
ui->lineEdit_password->setText(pppoeSettings[QString("Password")]);
if (pppoeSettings.contains(QString("ConnectionMode")))
for (int i=0; i<ui->comboBox_connection->count(); i++)
if (pppoeSettings[QString("ConnectionMode")] == ui->comboBox_connection->itemText(i))
ui->comboBox_connection->setCurrentIndex(i);
if (pppoeSettings.contains(QString("IdleTimeout")))
ui->spinBox_timeout->setValue(pppoeSettings[QString("IdleTimeout")].toInt());
if (pppoeSettings.contains(QString("MaxFail")))
ui->spinBox_fail->setValue(pppoeSettings[QString("MaxFail")].toInt());
if (pppoeSettings.contains(QString("DefaultRoute")))
if (pppoeSettings[QString("DefaultRoute")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("UsePeerDNS")))
if (pppoeSettings[QString("UsePeerDNS")] == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("PPPUnit")))
ui->lineEdit_unit->setText(pppoeSettings[QString("PPPUnit")]);
if (pppoeSettings.contains(QString("LCPEchoInterval")))
ui->spinBox_lcpInterval->setValue(pppoeSettings[QString("LCPEchoInterval")].toInt());
if (pppoeSettings.contains(QString("LCPEchoFailure")))
ui->spinBox_lcpFailure->setValue(pppoeSettings[QString("LCPEchoFailure")].toInt());
if (pppoeSettings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(pppoeSettings[QString("OptionsFile")]);
if (pppoeSettings.contains(QString("PPPoEService")))
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")]);
if (pppoeSettings.contains(QString("PPPoEAC")))
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")]);
if (pppoeSettings.contains(QString("PPPoESession")))
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")]);
if (pppoeSettings.contains(QString("PPPoEMAC")))
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")]);
if (pppoeSettings.contains(QString("PPPoEIP6")))
if (pppoeSettings[QString("PPPoEIP6")] == QString("yes"))
ui->checkBox_dns->setCheckState(Qt::Checked);
changeMode(ui->comboBox_connection->currentText());
}

View File

@ -0,0 +1,55 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef PPPOEWIDGET_H
#define PPPOEWIDGET_H
#include <QWidget>
namespace Ui {
class PppoeWidget;
}
class PppoeWidget : public QWidget
{
Q_OBJECT
public:
explicit PppoeWidget(QWidget *parent = 0);
~PppoeWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void changeMode(const QString currentText);
void selectOptionsFile();
void showAdvanced();
private:
Ui::PppoeWidget *ui;
void createActions();
void createFilter();
};
#endif /* PPPOEWIDGET_H */

View File

@ -0,0 +1,465 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PppoeWidget</class>
<widget class="QWidget" name="PppoeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>602</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_pppoe">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>PPPoE settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_pppoe">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="layout_username">
<item>
<widget class="QLabel" name="label_username">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_username">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_password">
<item>
<widget class="QLabel" name="label_password">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_connection">
<item>
<widget class="QLabel" name="label_connection">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Connection mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_connection">
<property name="toolTip">
<string>This option specifies how a connection should be established</string>
</property>
<item>
<property name="text">
<string>persist</string>
</property>
</item>
<item>
<property name="text">
<string>demand</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_timeout" native="true">
<layout class="QHBoxLayout" name="layout_timeout">
<item>
<widget class="QLabel" name="label_timeout">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Idle timeout</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeout">
<property name="toolTip">
<string>This option specifies the idle time (in seconds) after which pppd should disconnect</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>300</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pppoeAdvanced">
<item>
<spacer name="spacer_pppoeAdvanced">
<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_pppoeAdvanced">
<property name="text">
<string>Show advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_pppoeAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_fail">
<item>
<widget class="QLabel" name="label_fail">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Max fail</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fail">
<property name="toolTip">
<string>The number of consecutive failed connection attempts to tolerate</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_route">
<property name="toolTip">
<string>Use the default route provided by the peer</string>
</property>
<property name="text">
<string>Default route</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_dns">
<property name="toolTip">
<string>Use the DNS provided by the peer</string>
</property>
<property name="text">
<string>Use peer DNS</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_unit">
<item>
<widget class="QLabel" name="label_unit">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPP unit</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_unit">
<property name="toolTip">
<string>Set the ppp unit number in the interface name (ppp0, ppp1, etc.)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_lcpInterval">
<item>
<widget class="QLabel" name="label_lcpInterval">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>LCP echo interval</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_lcpInterval">
<property name="toolTip">
<string>These options override default LCP parameters from /etc/ppp/options</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>499</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_lcpFailure">
<item>
<widget class="QLabel" name="label_lcpFailure">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>LCP echo failure</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_lcpFailure">
<property name="toolTip">
<string>These options override default LCP parameters from /etc/ppp/options</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_options">
<item>
<widget class="QLabel" name="label_options">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Options file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_options">
<property name="toolTip">
<string>A file to read additional pppd options from</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_options">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_service">
<item>
<widget class="QLabel" name="label_service">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE service</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_service">
<property name="toolTip">
<string>This option specifies the PPPoE service name</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ac">
<item>
<widget class="QLabel" name="label_ac">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE AC</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ac">
<property name="toolTip">
<string>This option specifies the PPPoE access concentrator name</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_session">
<item>
<widget class="QLabel" name="label_session">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE session</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_session">
<property name="toolTip">
<string>This option specifies an existing session to attach to, MAC address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mac">
<item>
<widget class="QLabel" name="label_mac">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE MAC</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mac">
<property name="toolTip">
<string>Only connect to specified MAC address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ipv6">
<property name="toolTip">
<string>Enable IPv6 support</string>
</property>
<property name="text">
<string>PPPoE IPv6</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,444 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "settingswindow.h"
#include "ui_settingswindow.h"
#include <QDebug>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <language/language.h>
#include <pdebug/pdebug.h>
#include "mainwindow.h"
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
: QMainWindow(parent),
debug(debugCmd),
file(configFile),
ui(new Ui::SettingsWindow)
{
ui->setupUi(this);
addLanguages();
createActions();
}
SettingsWindow::~SettingsWindow()
{
if (debug) qDebug() << PDEBUG;
delete ui;
}
void SettingsWindow::createActions()
{
if (debug) qDebug() << PDEBUG;
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(restoreSettings()));
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
// buttons
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_interfacesDir, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_status, SIGNAL(clicked(bool)), this, SLOT(startHelper()));
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
}
// ESC press event
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << PDEBUG;
if (pressedKey->key() == Qt::Key_Escape)
close();
}
void SettingsWindow::addLanguages()
{
if (debug) qDebug() << PDEBUG;
ui->comboBox_language->clear();
ui->comboBox_language->addItems(Language::getAvailableLanguages());
}
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous)
if (debug) qDebug() << PDEBUG;
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
if (current == ui->treeWidget->topLevelItem(i)) {
ui->stackedWidget->setCurrentIndex(i);
break;
}
}
void SettingsWindow::closeWindow()
{
if (debug) qDebug() << PDEBUG;
saveSettings();
close();
((MainWindow *)parent())->updateConfiguration();
}
void SettingsWindow::saveSettings()
{
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings = readSettings();
QFile configFile(file);
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&configFile);
for (int i=0; i<settings.keys().count(); i++)
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
configFile.close();
}
void SettingsWindow::setTray()
{
if (debug) qDebug() << PDEBUG;
if (ui->checkBox_enableTray->checkState() == 0) {
ui->checkBox_closeToTray->setDisabled(true);
ui->checkBox_startToTray->setDisabled(true);
} else if (ui->checkBox_enableTray->checkState() == 2) {
ui->checkBox_closeToTray->setEnabled(true);
ui->checkBox_startToTray->setEnabled(true);
}
}
void SettingsWindow::restoreSettings()
{
if (debug) qDebug() << PDEBUG;
setSettings(getSettings());
}
void SettingsWindow::setDefault()
{
if (debug) qDebug() << PDEBUG;
setSettings(getDefault());
if (sender() != ui->buttonBox->button(QDialogButtonBox::Reset))
saveSettings();
}
void SettingsWindow::selectAbstractSomething()
{
if (debug) qDebug() << PDEBUG;
bool isDir = false;
QString path = QString("/usr/bin");
QString text = QApplication::translate("SettingsWindow", "Select helper command");
QLineEdit *lineEdit = ui->lineEdit_helperPath;
if (sender() == ui->pushButton_helperPath) {
text = QApplication::translate("SettingsWindow", "Select helper command");
lineEdit = ui->lineEdit_helperPath;
} else if (sender() == ui->pushButton_interfacesDir) {
isDir = true;
text = QApplication::translate("SettingsWindow", "Select path to directory with interfaces");
path = QString("/sys");
lineEdit = ui->lineEdit_interfacesDir;
} else if (sender() == ui->pushButton_netctlPath) {
text = QApplication::translate("SettingsWindow", "Select netctl command");
lineEdit = ui->lineEdit_netctlPath;
} else if (sender() == ui->pushButton_netctlAutoPath) {
text = QApplication::translate("SettingsWindow", "Select netctl-auto command");
lineEdit = ui->lineEdit_netctlAutoPath;
} else if (sender() == ui->pushButton_profilePath) {
isDir = true;
text = QApplication::translate("SettingsWindow", "Select path to profile directory");
path = QString("/etc");
lineEdit = ui->lineEdit_profilePath;
} else if (sender() == ui->pushButton_rfkill) {
isDir = true;
text = QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices");
path = QString("/sys");
lineEdit = ui->lineEdit_rfkill;
} else if (sender() == ui->pushButton_sudo) {
text = QApplication::translate("SettingsWindow", "Select sudo command");
lineEdit = ui->lineEdit_sudo;
} else if (sender() == ui->pushButton_systemctlPath) {
text = QApplication::translate("SettingsWindow", "Select systemctl command");
lineEdit = ui->lineEdit_systemctlPath;
} else if (sender() == ui->pushButton_wpaCliPath) {
text = QApplication::translate("SettingsWindow", "Select wpa_cli command");
lineEdit = ui->lineEdit_wpaCliPath;
} else if (sender() == ui->pushButton_wpaSupPath) {
text = QApplication::translate("SettingsWindow", "Select wpa_supplicant command");
lineEdit = ui->lineEdit_wpaSupPath;
}
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())
lineEdit->setText(filename);
}
void SettingsWindow::showWindow()
{
if (debug) qDebug() << PDEBUG;
setSettings(getSettings());
setTray();
updateHelper();
show();
}
QMap<QString, QString> SettingsWindow::readSettings()
{
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
if (ui->checkBox_helperClose->checkState() == 2)
settings[QString("CLOSE_HELPER")] = QString("true");
else
settings[QString("CLOSE_HELPER")] = QString("false");
if (ui->checkBox_closeToTray->checkState() == 2)
settings[QString("CLOSETOTRAY")] = QString("true");
else
settings[QString("CLOSETOTRAY")] = QString("false");
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
if (ui->checkBox_forceSudo->checkState() == 2)
settings[QString("FORCE_SUDO")] = QString("true");
else
settings[QString("FORCE_SUDO")] = QString("false");
settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
settings[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
settings[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
settings[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
settings[QString("PID_FILE")] = ui->lineEdit_pid->text();
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
if (ui->checkBox_components->checkState() == 2)
settings[QString("SKIPCOMPONENTS")] = QString("true");
else
settings[QString("SKIPCOMPONENTS")] = QString("false");
if (ui->checkBox_startToTray->checkState() == 2)
settings[QString("STARTTOTRAY")] = QString("true");
else
settings[QString("STARTTOTRAY")] = QString("false");
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
if (ui->checkBox_enableTray->checkState() == 2)
settings[QString("SYSTRAY")] = QString("true");
else
settings[QString("SYSTRAY")] = QString("false");
if (ui->checkBox_useHelper->checkState() == 2)
settings[QString("USE_HELPER")] = QString("true");
else
settings[QString("USE_HELPER")] = QString("false");
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
{
if (debug) qDebug() << PDEBUG;
if (settings[QString("CLOSE_HELPER")] == QString("true"))
ui->checkBox_helperClose->setCheckState(Qt::Checked);
else
ui->checkBox_helperClose->setCheckState(Qt::Unchecked);
if (settings[QString("CLOSETOTRAY")] == QString("true"))
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
else
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
if (settings[QString("FORCE_SUDO")] == QString("true"))
ui->checkBox_forceSudo->setCheckState(Qt::Checked);
else
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]);
ui->lineEdit_helperService->setText(settings[QString("HELPER_SERVICE")]);
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
ui->comboBox_language->setCurrentIndex(0);
for (int i=0; i<ui->comboBox_language->count(); i++)
if (ui->comboBox_language->itemText(i) == settings[QString("LANGUAGE")])
ui->comboBox_language->setCurrentIndex(i);
ui->lineEdit_netctlPath->setText(settings[QString("NETCTL_PATH")]);
ui->lineEdit_netctlAutoPath->setText(settings[QString("NETCTLAUTO_PATH")]);
ui->lineEdit_netctlAutoService->setText(settings[QString("NETCTLAUTO_SERVICE")]);
ui->lineEdit_pid->setText(settings[QString("PID_FILE")]);
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
if (settings[QString("SKIPCOMPONENTS")] == QString("true"))
ui->checkBox_components->setCheckState(Qt::Checked);
else
ui->checkBox_components->setCheckState(Qt::Unchecked);
if (settings[QString("STARTTOTRAY")] == QString("true"))
ui->checkBox_startToTray->setCheckState(Qt::Checked);
else
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
if (settings[QString("SYSTRAY")] == QString("true"))
ui->checkBox_enableTray->setCheckState(Qt::Checked);
else
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
if (settings[QString("USE_HELPER")] == QString("true"))
ui->checkBox_useHelper->setCheckState(Qt::Checked);
else
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
}
QMap<QString, QString> SettingsWindow::getDefault()
{
if (debug) qDebug() << PDEBUG;
QMap<QString, QString> settings;
settings[QString("CLOSE_HELPER")] = QString("false");
settings[QString("CLOSETOTRAY")] = QString("true");
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
settings[QString("CTRL_GROUP")] = QString("users");
settings[QString("FORCE_SUDO")] = QString("false");
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
settings[QString("HELPER_SERVICE")] = QString("netctlgui-helper.service");
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
settings[QString("LANGUAGE")] = QString("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("SKIPCOMPONENTS")] = QString("false");
settings[QString("STARTTOTRAY")] = QString("false");
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
settings[QString("SYSTRAY")] = QString("true");
settings[QString("USE_HELPER")] = QString("true");
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
QMap<QString, QString> SettingsWindow::getSettings()
{
if (debug) qDebug() << PDEBUG;
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.isEmpty()) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
if (fileStr.contains(QChar('=')))
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
if (configFile.atEnd()) break;
}
configFile.close();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
void SettingsWindow::startHelper()
{
if (debug) qDebug() << PDEBUG;
((MainWindow *)parent())->startHelper();
updateHelper();
}
void SettingsWindow::updateHelper()
{
if (debug) qDebug() << PDEBUG;
if (((MainWindow *)parent())->isHelperServiceActive()) {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active (systemd)"));
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
ui->pushButton_status->setDisabled(true);
} else if (((MainWindow *)parent())->isHelperActive()) {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active"));
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
ui->pushButton_status->setEnabled(true);
} else {
ui->label_status->setText(QApplication::translate("SettingsWindow", "Inactive"));
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Start"));
ui->pushButton_status->setIcon(QIcon::fromTheme("system-run"));
ui->pushButton_status->setEnabled(true);
}
}

View File

@ -0,0 +1,72 @@
/***************************************************************************
* 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 SETTINGSWINDOW_H
#define SETTINGSWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
#include <QTreeWidgetItem>
class MainWindow;
namespace Ui {
class SettingsWindow;
}
class SettingsWindow : public QMainWindow
{
Q_OBJECT
public:
explicit SettingsWindow(QWidget *parent = 0,
const bool debugCmd = false,
const QString configFile = QString(""));
~SettingsWindow();
QMap<QString, QString> getDefault();
QMap<QString, QString> getSettings();
public slots:
void closeWindow();
void restoreSettings();
void setDefault();
void showWindow();
private slots:
void addLanguages();
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void saveSettings();
void setTray();
void updateHelper();
// buttons
void selectAbstractSomething();
void startHelper();
private:
bool debug;
QString file;
Ui::SettingsWindow *ui;
void createActions();
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
QMap<QString, QString> readSettings();
void setSettings(const QMap<QString, QString> settings);
};
#endif /* SETTINGSWINDOW_H */

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