Commit d321d0df authored by Beniamino Galvani's avatar Beniamino Galvani

editor: merge branch 'bg/wireguard'

Add wireguard support to nm-connection-editor.

!78
parents f4cb24dd 34c087c9
Pipeline #172268 passed with stages
in 11 minutes and 30 seconds
......@@ -361,6 +361,8 @@ connection_editor_hc_real = \
src/connection-editor/page-vlan.c \
src/connection-editor/page-dcb.c \
src/connection-editor/page-dcb.h \
src/connection-editor/page-wireguard.h \
src/connection-editor/page-wireguard.c \
src/connection-editor/vpn-helpers.h \
src/connection-editor/vpn-helpers.c \
src/connection-editor/ip4-routes-dialog.h \
......@@ -445,6 +447,7 @@ EXTRA_DIST += \
src/connection-editor/ce-page-vlan.ui \
src/connection-editor/ce-page-wifi-security.ui \
src/connection-editor/ce-page-wifi.ui \
src/connection-editor/ce-page-wireguard.ui \
src/connection-editor/ce-ppp-auth-methods.ui \
src/connection-editor/gtk/menus.ui \
src/connection-editor/nm-connection-editor.ui \
......
This diff is collapsed.
......@@ -35,98 +35,86 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
typedef struct {
int value;
const char *text;
} SpinMapping;
static gboolean
spin_output_with_default_string (GtkSpinButton *spin,
int defvalue,
const char *defstring)
spin_output_with_mapping (GtkSpinButton *spin,
const SpinMapping *mapping)
{
int val;
gchar *buf = NULL;
val = gtk_spin_button_get_value_as_int (spin);
if (val == defvalue)
buf = g_strdup (defstring);
if (val == mapping->value)
buf = g_strdup (mapping->text);
else
buf = g_strdup_printf ("%d", val);
if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin))))
if (!nm_streq (buf, gtk_entry_get_text (GTK_ENTRY (spin))))
gtk_entry_set_text (GTK_ENTRY (spin), buf);
g_free (buf);
return TRUE;
}
static gboolean
ce_spin_output_with_automatic (GtkSpinButton *spin, gpointer user_data)
{
return spin_output_with_default_string (spin,
GPOINTER_TO_INT (user_data),
_("automatic"));
}
static gboolean
ce_spin_output_with_default (GtkSpinButton *spin, gpointer user_data)
{
return spin_output_with_default_string (spin,
GPOINTER_TO_INT (user_data),
_("default"));
}
static gint
spin_input_with_default_string (GtkSpinButton *spin,
int defvalue,
spin_input_with_mapping (GtkSpinButton *spin,
gdouble *new_val,
const char *defstring)
const SpinMapping *mapping)
{
const gchar *buf;
buf = gtk_entry_get_text (GTK_ENTRY (spin));
if (strcmp (buf, defstring) == 0) {
*new_val = defvalue;
if (nm_streq (buf, mapping->text)) {
*new_val = mapping->value;
return TRUE;
}
return FALSE;
}
static gint
ce_spin_input_with_automatic (GtkSpinButton *spin, gdouble *new_val, gpointer user_data)
static void
spin_set_mapping (GtkSpinButton *spin, int value, const char *text)
{
return spin_input_with_default_string (spin,
GPOINTER_TO_INT (user_data),
new_val,
_("automatic"));
}
SpinMapping *mapping;
static gint
ce_spin_input_with_default (GtkSpinButton *spin, gdouble *new_val, gpointer user_data)
{
return spin_input_with_default_string (spin,
GPOINTER_TO_INT (user_data),
new_val,
_("default"));
g_return_if_fail (!g_object_get_data (G_OBJECT (spin), "mapping"));
mapping = g_new (SpinMapping, 1);
*mapping = (SpinMapping) {
.value = value,
.text = text,
};
g_object_set_data_full (G_OBJECT (spin), "mapping", mapping, g_free);
g_signal_connect (spin, "output",
G_CALLBACK (spin_output_with_mapping),
mapping);
g_signal_connect (spin, "input",
G_CALLBACK (spin_input_with_mapping),
mapping);
}
void
ce_spin_automatic_val (GtkSpinButton *spin, int defvalue)
{
g_signal_connect (spin, "output",
G_CALLBACK (ce_spin_output_with_automatic),
GINT_TO_POINTER (defvalue));
g_signal_connect (spin, "input",
G_CALLBACK (ce_spin_input_with_automatic),
GINT_TO_POINTER (defvalue));
spin_set_mapping (spin, defvalue, _("automatic"));
}
void
ce_spin_default_val (GtkSpinButton *spin, int defvalue)
{
g_signal_connect (spin, "output",
G_CALLBACK (ce_spin_output_with_default),
GINT_TO_POINTER (defvalue));
g_signal_connect (spin, "input",
G_CALLBACK (ce_spin_input_with_default),
GINT_TO_POINTER (defvalue));
spin_set_mapping (spin, defvalue, _("default"));
}
void
ce_spin_off_val (GtkSpinButton *spin, int defvalue)
{
spin_set_mapping (spin, defvalue, _("off"));
}
int
......
......@@ -84,7 +84,6 @@ typedef struct {
gboolean (*inter_page_change) (CEPage *self);
} CEPageClass;
typedef CEPage* (*CEPageNewFunc)(NMConnectionEditor *editor,
NMConnection *connection,
GtkWindow *parent,
......@@ -145,7 +144,7 @@ NMConnectionEditor *ce_page_new_editor (CEPage *self,
void ce_spin_automatic_val (GtkSpinButton *spin, int defvalue);
void ce_spin_default_val (GtkSpinButton *spin, int defvalue);
void ce_spin_off_val (GtkSpinButton *spin, int defvalue);
int ce_get_property_default (NMSetting *setting, const char *property_name);
void ce_page_complete_init (CEPage *self,
......@@ -187,6 +186,5 @@ CEPage *ce_page_new (GType page_type,
const char *widget_name,
const char *title);
#endif /* __CE_PAGE_H__ */
......@@ -27,6 +27,7 @@
<file preprocess="xml-stripblanks">ce-page-vlan.ui</file>
<file preprocess="xml-stripblanks">ce-page-wifi-security.ui</file>
<file preprocess="xml-stripblanks">ce-page-wifi.ui</file>
<file preprocess="xml-stripblanks">ce-page-wireguard.ui</file>
<file preprocess="xml-stripblanks">ce-ppp-auth-methods.ui</file>
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
</gresource>
......
......@@ -23,6 +23,7 @@
#include "page-bridge.h"
#include "page-vlan.h"
#include "page-vpn.h"
#include "page-wireguard.h"
#include "vpn-helpers.h"
#include "nm-utils/nm-vpn-editor-plugin-call.h"
......@@ -106,6 +107,7 @@ get_connection_type_list (void)
add_type_data_virtual (array, _("VLAN"), vlan_connection_new, NM_TYPE_SETTING_VLAN);
add_type_data_virtual (array, _("IP tunnel"), ip_tunnel_connection_new, NM_TYPE_SETTING_IP_TUNNEL);
add_type_data_virtual (array, _("MACsec"), macsec_connection_new, NM_TYPE_SETTING_MACSEC);
add_type_data_virtual (array, _("WireGuard"), wireguard_connection_new, NM_TYPE_SETTING_WIREGUARD);
add_type_data_virtual (array, _("VPN"), vpn_connection_new, NM_TYPE_SETTING_VPN);
......
......@@ -33,6 +33,7 @@ sources = files(
'page-vpn.c',
'page-wifi.c',
'page-wifi-security.c',
'page-wireguard.c',
'ppp-auth-methods-dialog.c',
'vpn-helpers.c'
)
......@@ -62,6 +63,7 @@ resource_data = files(
'ce-page-vlan.ui',
'ce-page-wifi-security.ui',
'ce-page-wifi.ui',
'ce-page-wireguard.ui',
'ce-ppp-auth-methods.ui',
'gtk/menus.ui',
'nm-connection-editor.ui',
......
......@@ -48,6 +48,7 @@
#include "page-vlan.h"
#include "page-dcb.h"
#include "page-macsec.h"
#include "page-wireguard.h"
#include "ce-polkit-button.h"
#include "vpn-helpers.h"
#include "eap-method.h"
......@@ -1037,6 +1038,9 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
goto out;
if (!add_page (editor, ce_page_8021x_security_new, editor->connection, error))
goto out;
} else if (!strcmp (connection_type, NM_SETTING_WIREGUARD_SETTING_NAME)) {
if (!add_page (editor, ce_page_wireguard_new, editor->connection, error))
goto out;
} else {
g_warning ("Unhandled setting type '%s'", connection_type);
}
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0+
/* NetworkManager Connection editor -- Connection editor for NetworkManager
*
* Copyright 2020 Red Hat, Inc.
*/
#ifndef __PAGE_WIREGUARD_H__
#define __PAGE_WIREGUARD_H__
#include <glib.h>
#include <glib-object.h>
#include "ce-page.h"
#define CE_TYPE_PAGE_WIREGUARD (ce_page_wireguard_get_type ())
#define CE_PAGE_WIREGUARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CE_TYPE_PAGE_WIREGUARD, CEPageWireGuard))
#define CE_PAGE_WIREGUARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CE_TYPE_PAGE_WIREGUARD, CEPageWireGuardClass))
#define CE_IS_PAGE_WIREGUARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CE_TYPE_PAGE_WIREGUARD))
#define CE_IS_PAGE_WIREGUARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CE_TYPE_PAGE_WIREGUARD))
#define CE_PAGE_WIREGUARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CE_TYPE_PAGE_WIREGUARD, CEPageWireGuardClass))
typedef struct {
CEPage parent;
} CEPageWireGuard;
typedef struct {
CEPageClass parent;
} CEPageWireGuardClass;
GType ce_page_wireguard_get_type (void);
CEPage *ce_page_wireguard_new (NMConnectionEditor *editor,
NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
GError **error);
void wireguard_connection_new (FUNC_TAG_PAGE_NEW_CONNECTION_IMPL,
GtkWindow *parent,
const char *detail,
gpointer detail_data,
NMConnection *connection,
NMClient *client,
PageNewConnectionResultFunc callback,
gpointer user_data);
#endif /* __PAGE_WIREGUARD_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment