nm-l2tp / NetworkManager-l2tp

L2TP and L2TP/IPsec support for NetworkManager
GNU General Public License v2.0
486 stars 83 forks source link

Port to Gtk4 #179

Closed lkundrak closed 2 years ago

lkundrak commented 2 years ago

GNOME 42 seems to be switching to Gtk4, so we seem to be in a bit of a hurry to port the VPN plugins over.

The bunch of the changes are much the same as is done for other plugins [1]. The things that are going to come up with that review are likely to affect this too. I suggest this is not merged before the OpenVPN plugin gets sorted out, so there's a good example of how to do things properly.

[1] https://gitlab.gnome.org/GNOME/NetworkManager-openvpn/-/merge_requests/41

Note that due to the time constrains I have not verified if this works well; I merely got it to compile and run. Feedback and fixes are very welcome.

dkosovic commented 2 years ago

I tested on CentOS Stream 9 and configured with --with-gtk4 and without, both worked as I was able to edit L2TP connections and also successfully connect.

For PKCS#12 (.p12) files, NMACertChooser doesn't disable the password box if no password is required, like the non-NMACertChooser prior implementation did, it is so far the only issue I've come across. I'm still doing more testing and source code reading.

Unrelated to this merge request, CentOS Stream 9 has disabled IPsec IKEv1 by default (although Fedora hasn't yet), so I will probably write some info in the README file on how to re-enable IPsec IKEv1 so that L2TP/IPsec connections can work.

dkosovic commented 2 years ago

Sorry for not getting back to you sooner, last month had major flooding and my father passed away, plus I had issues getting pre-beta Fedora 36 snapshots installed as a VM.

gnome-control-center (but not nm-connection-manager) had issues with Show password checkboxes not being toggle buttons :

gnome-control-c[2819]: gtk_toggle_button_get_active: assertion 'GTK_IS_TOGGLE_BUTTON (toggle_button)' failed

the following seems to solve that checkbox issue:

--- a/properties/auth-helpers.c
+++ b/properties/auth-helpers.c
@@ -10,9 +10,10 @@
 #include "nm-default.h"

 #include "auth-helpers.h"
+#include "nm-l2tp-editor.h"

 void
-show_password_cb(GtkToggleButton *togglebutton, GtkEntry *password_entry)
+show_password_cb(GtkCheckButton *checkbutton, GtkEntry *password_entry)
 {
-    gtk_entry_set_visibility(password_entry, gtk_toggle_button_get_active(togglebutton));
+    gtk_entry_set_visibility(password_entry, gtk_check_button_get_active(checkbutton));
 }
diff --git a/properties/auth-helpers.h b/properties/auth-helpers.h
index 0773be9..6fcb0a5 100644
--- a/properties/auth-helpers.h
+++ b/properties/auth-helpers.h
@@ -12,6 +12,6 @@

 #define BLOCK_HANDLER_ID "block-handler-id"

-void show_password_cb(GtkToggleButton *togglebutton, GtkEntry *password_entry);
+void show_password_cb(GtkCheckButton *checkbutton, GtkEntry *password_entry);

 #endif /* _AUTH_HELPERS_H_ */

With NetworkManager-l2tp 1.7 I used NMACertChooser, but reverted to not using NMACertChooser with NetworkManager-l2tp 1.8 as NMACertChooser had a few issues that I was able to overcome by using OpenSSL to parse the certificates. But as the other VPN clients are using NMACertChooser, I might as well be consistent.

Thanks for the pull request