Commit 9183d349 authored by Bastien Nocera's avatar Bastien Nocera

network: Port to libnm 1.2

We also remove support for WiMAX (now unsupported by NetworkManager),
and InfiniBand (Enterprise feature), and the use of
the deprecated NM_SETTING_WIRELESS_SEC property.

With help from network-manager-applet patches by Jiří Klimeš and
Dan Winship.

https://bugzilla.gnome.org/show_bug.cgi?id=765910
parent 8400d3ed
......@@ -92,8 +92,8 @@ CANBERRA_REQUIRED_VERSION=0.13
GDKPIXBUF_REQUIRED_VERSION=2.23.0
POLKIT_REQUIRED_VERSION=0.103
GSD_REQUIRED_VERSION=3.19.1
NETWORK_MANAGER_REQUIRED_VERSION=0.9.8
NETWORK_MANAGER_APPLET_REQUIRED_VERSION=0.9.7.995
NETWORK_MANAGER_REQUIRED_VERSION=1.2.0
NETWORK_MANAGER_APPLET_REQUIRED_VERSION=1.2.0
MODEM_MANAGER_REQUIRED_VERSION=0.7
LIBNOTIFY_REQUIRED_VERSION=0.7.3
GNOME_DESKTOP_REQUIRED_VERSION=3.21.2
......@@ -193,11 +193,9 @@ if test "x$have_wayland" = xyes ; then
fi
fi
PKG_CHECK_MODULES(NETWORK_MANAGER, NetworkManager >= $NETWORK_MANAGER_REQUIRED_VERSION
libnm-glib >= $NETWORK_MANAGER_REQUIRED_VERSION
libnm-glib-vpn >= $NETWORK_MANAGER_REQUIRED_VERSION
libnm-util >= $NETWORK_MANAGER_REQUIRED_VERSION
libnm-gtk >= $NETWORK_MANAGER_APPLET_REQUIRED_VERSION
PKG_CHECK_MODULES(NETWORK_MANAGER,
libnm >= $NETWORK_MANAGER_REQUIRED_VERSION
libnma >= $NETWORK_MANAGER_APPLET_REQUIRED_VERSION
mm-glib >= $MODEM_MANAGER_REQUIRED_VERSION,
[have_networkmanager=yes], have_networkmanager=no)
if test "x$have_networkmanager" = xno ; then
......
......@@ -26,11 +26,7 @@
#include "cc-network-panel.h"
#include "cc-network-resources.h"
#include "nm-remote-settings.h"
#include "nm-client.h"
#include "nm-device.h"
#include "nm-device-modem.h"
#include "nm-ui-utils.h"
#include <NetworkManager.h>
#include "net-device.h"
#include "net-device-mobile.h"
......@@ -68,7 +64,6 @@ struct _CcNetworkPanelPrivate
GtkWidget *treeview;
NMClient *client;
MMManager *modem_manager;
NMRemoteSettings *remote_settings;
gboolean updating_device;
/* Killswitch stuff */
......@@ -231,7 +226,6 @@ cc_network_panel_dispose (GObject *object)
g_clear_object (&priv->builder);
g_clear_object (&priv->client);
g_clear_object (&priv->modem_manager);
g_clear_object (&priv->remote_settings);
g_clear_object (&priv->kill_switch_header);
priv->rfkill_switch = NULL;
......@@ -534,7 +528,7 @@ panel_refresh_device_titles (CcNetworkPanel *panel)
nm_devices = (NMDevice **)nmdarray->pdata;
num_devices = ndarray->len;
titles = nma_utils_disambiguate_device_names (nm_devices, num_devices);
titles = nm_device_disambiguate_names (nm_devices, num_devices);
for (i = 0; i < num_devices; i++) {
net_object_set_title (NET_OBJECT (devices[i]), titles[i]);
g_free (titles[i]);
......@@ -565,21 +559,21 @@ handle_argv_for_device (CcNetworkPanel *panel,
select_tree_iter (panel, iter);
if (priv->arg_operation == OPERATION_CREATE_WIFI)
cc_network_panel_create_wifi_network (toplevel, priv->client, priv->remote_settings);
cc_network_panel_create_wifi_network (toplevel, priv->client);
else
cc_network_panel_connect_to_hidden_network (toplevel, priv->client, priv->remote_settings);
cc_network_panel_connect_to_hidden_network (toplevel, priv->client);
reset_command_line_args (panel); /* done */
return TRUE;
} else if (g_strcmp0 (nm_object_get_path (NM_OBJECT (device)), priv->arg_device) == 0) {
if (priv->arg_operation == OPERATION_CONNECT_MOBILE) {
cc_network_panel_connect_to_3g_network (toplevel, priv->client, priv->remote_settings, device);
cc_network_panel_connect_to_3g_network (toplevel, priv->client, device);
reset_command_line_args (panel); /* done */
select_tree_iter (panel, iter);
return TRUE;
} else if (priv->arg_operation == OPERATION_CONNECT_8021X) {
cc_network_panel_connect_to_8021x_network (toplevel, priv->client, priv->remote_settings, device, priv->arg_access_point);
cc_network_panel_connect_to_8021x_network (toplevel, priv->client, device, priv->arg_access_point);
reset_command_line_args (panel); /* done */
select_tree_iter (panel, iter);
return TRUE;
......@@ -736,7 +730,6 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
"removable", FALSE,
"cancellable", panel->priv->cancellable,
"client", panel->priv->client,
"remote-settings", panel->priv->remote_settings,
"nm-device", device,
"id", nm_device_get_udi (device),
NULL);
......@@ -992,7 +985,7 @@ active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_d
for (j = 0; devices && j < devices->len; j++)
g_debug (" %s", nm_device_get_udi (g_ptr_array_index (devices, j)));
if (NM_IS_VPN_CONNECTION (connection))
g_debug (" VPN base connection: %s", nm_active_connection_get_specific_object (connection));
g_debug (" VPN base connection: %s", nm_active_connection_get_specific_object_path (connection));
if (g_object_get_data (G_OBJECT (connection), "has-state-changed-handler") == NULL) {
g_signal_connect_object (connection, "notify::state",
......@@ -1029,7 +1022,7 @@ manager_running (NMClient *client, GParamSpec *pspec, gpointer user_data)
CcNetworkPanel *panel = CC_NETWORK_PANEL (user_data);
/* clear all devices we added */
if (!nm_client_get_manager_running (client)) {
if (!nm_client_get_nm_running (client)) {
g_debug ("NM disappeared");
liststore_devices = GTK_LIST_STORE (gtk_builder_get_object (panel->priv->builder,
"liststore_devices"));
......@@ -1118,7 +1111,6 @@ panel_add_vpn_device (CcNetworkPanel *panel, NMConnection *connection)
"id", id,
"connection", connection,
"client", panel->priv->client,
"remote-settings", panel->priv->remote_settings,
NULL);
g_signal_connect_object (net_vpn, "removed",
G_CALLBACK (object_removed_cb), panel, 0);
......@@ -1158,7 +1150,7 @@ add_connection (CcNetworkPanel *panel,
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection,
NM_TYPE_SETTING_CONNECTION));
type = nm_setting_connection_get_connection_type (s_con);
iface = nm_connection_get_virtual_iface_name (connection);
iface = nm_connection_get_interface_name (connection);
if (g_strcmp0 (type, "vpn") != 0 && iface == NULL)
return;
......@@ -1174,34 +1166,13 @@ add_connection (CcNetworkPanel *panel,
}
static void
notify_new_connection_cb (NMRemoteSettings *settings,
NMRemoteConnection *connection,
CcNetworkPanel *panel)
notify_connection_added_cb (NMClient *client,
NMRemoteConnection *connection,
CcNetworkPanel *panel)
{
add_connection (panel, NM_CONNECTION (connection));
}
static void
notify_connections_read_cb (NMRemoteSettings *settings,
CcNetworkPanel *panel)
{
GSList *list, *iter;
NMConnection *connection;
list = nm_remote_settings_list_connections (settings);
g_debug ("%p has %i remote connections",
panel, g_slist_length (list));
for (iter = list; iter; iter = g_slist_next (iter)) {
connection = NM_CONNECTION (iter->data);
add_connection (panel, connection);
}
g_slist_free (list);
g_debug ("Calling handle_argv() after cold-plugging connections");
handle_argv (panel);
}
static void
panel_check_network_manager_version (CcNetworkPanel *panel)
{
......@@ -1256,8 +1227,7 @@ add_connection_cb (GtkToolButton *button, CcNetworkPanel *panel)
toplevel = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (panel)));
editor = net_connection_editor_new (toplevel, NULL, NULL, NULL,
panel->priv->client,
panel->priv->remote_settings);
panel->priv->client);
g_signal_connect (editor, "done", G_CALLBACK (editor_done), panel);
net_connection_editor_run (editor);
}
......@@ -1289,7 +1259,6 @@ on_toplevel_map (GtkWidget *widget,
static void
cc_network_panel_init (CcNetworkPanel *panel)
{
DBusGConnection *bus = NULL;
GError *error = NULL;
GtkStyleContext *context;
GtkTreeSelection *selection;
......@@ -1297,6 +1266,8 @@ cc_network_panel_init (CcNetworkPanel *panel)
GtkWidget *toplevel;
GDBusConnection *system_bus;
GtkCssProvider *provider;
const GPtrArray *connections;
guint i;
panel->priv = NETWORK_PANEL_PRIVATE (panel);
g_resources_register (cc_network_get_resource ());
......@@ -1336,10 +1307,10 @@ cc_network_panel_init (CcNetworkPanel *panel)
panel_add_proxy_device (panel);
/* use NetworkManager client */
panel->priv->client = nm_client_new ();
g_signal_connect (panel->priv->client, "notify::" NM_CLIENT_MANAGER_RUNNING,
panel->priv->client = nm_client_new (NULL, NULL);
g_signal_connect (panel->priv->client, "notify::nm-running" ,
G_CALLBACK (manager_running), panel);
g_signal_connect (panel->priv->client, "notify::" NM_CLIENT_ACTIVE_CONNECTIONS,
g_signal_connect (panel->priv->client, "notify::active-connections",
G_CALLBACK (active_connections_changed), panel);
g_signal_connect (panel->priv->client, "device-added",
G_CALLBACK (device_added_cb), panel);
......@@ -1377,17 +1348,8 @@ cc_network_panel_init (CcNetworkPanel *panel)
G_CALLBACK (remove_connection), panel);
/* add remote settings such as VPN settings as virtual devices */
bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
if (bus == NULL) {
g_warning ("Error connecting to system D-Bus: %s",
error->message);
g_error_free (error);
}
panel->priv->remote_settings = nm_remote_settings_new (bus);
g_signal_connect (panel->priv->remote_settings, NM_REMOTE_SETTINGS_CONNECTIONS_READ,
G_CALLBACK (notify_connections_read_cb), panel);
g_signal_connect (panel->priv->remote_settings, NM_REMOTE_SETTINGS_NEW_CONNECTION,
G_CALLBACK (notify_new_connection_cb), panel);
g_signal_connect (panel->priv->client, NM_CLIENT_CONNECTION_ADDED,
G_CALLBACK (notify_connection_added_cb), panel);
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (panel));
g_signal_connect_after (toplevel, "map", G_CALLBACK (on_toplevel_map), panel);
......@@ -1408,4 +1370,11 @@ cc_network_panel_init (CcNetworkPanel *panel)
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
/* Cold-plug existing connections */
connections = nm_client_get_connections (panel->priv->client);
for (i = 0; i < connections->len; i++)
add_connection (panel, connections->pdata[i]);
g_debug ("Calling handle_argv() after cold-plugging connections");
handle_argv (panel);
}
......@@ -28,11 +28,6 @@
#include <glib/gi18n.h>
#include <NetworkManager.h>
#include <nm-setting-connection.h>
#include <nm-setting-wired.h>
#include <nm-setting-8021x.h>
#include <nm-setting-wireless.h>
#include <nm-utils.h>
#include "wireless-security.h"
#include "ce-page-ethernet.h"
......@@ -95,15 +90,13 @@ finish_setup (CEPage8021xSecurity *page, gpointer unused, GError *error, gpointe
CEPage *
ce_page_8021x_security_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings)
NMClient *client)
{
CEPage8021xSecurity *page;
page = CE_PAGE_8021X_SECURITY (ce_page_new (CE_TYPE_PAGE_8021X_SECURITY,
connection,
client,
settings,
"/org/gnome/control-center/network/8021x-security-page.ui",
_("Security")));
......@@ -136,7 +129,7 @@ validate (CEPage *cepage, NMConnection *connection, GError **error)
NMSetting *s_con;
/* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */
tmp_connection = nm_connection_new ();
tmp_connection = nm_simple_connection_new ();
nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ());
/* temp connection needs a 'connection' setting too, since most of
......@@ -152,7 +145,7 @@ validate (CEPage *cepage, NMConnection *connection, GError **error)
g_object_unref (tmp_connection);
} else
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Invalid 802.1x security");
g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING, "Invalid 802.1x security");
} else {
nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X);
valid = TRUE;
......
......@@ -23,7 +23,7 @@
#ifndef __CE_PAGE_8021X_SECURITY_H
#define __CE_PAGE_8021X_SECURITY_H
#include <nm-connection.h>
#include <NetworkManager.h>
#include "wireless-security.h"
#include <glib.h>
......@@ -58,7 +58,6 @@ struct CEPage8021xSecurityClass {
GType ce_page_8021x_security_get_type (void);
CEPage *ce_page_8021x_security_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings);
NMClient *client);
#endif /* __CE_PAGE_8021X_SECURITY_H */
......@@ -24,9 +24,7 @@
#include <glib-object.h>
#include <glib/gi18n.h>
#include <nm-utils.h>
#include <nm-device-wifi.h>
#include <nm-device-ethernet.h>
#include <NetworkManager.h>
#include "../panel-common.h"
#include "ce-page-details.h"
......@@ -141,8 +139,8 @@ connect_details_page (CEPageDetails *page)
const gchar *p1, *p2;
ac = nm_device_get_active_connection (page->device);
p1 = ac ? nm_active_connection_get_connection (ac) : NULL;
p2 = nm_connection_get_path (CE_PAGE (page)->connection);
p1 = ac ? nm_active_connection_get_uuid (ac) : NULL;
p2 = nm_connection_get_uuid (CE_PAGE (page)->connection);
if (g_strcmp0 (p1, p2) == 0) {
device_is_active = TRUE;
if (NM_IS_DEVICE_WIFI (page->device))
......@@ -226,7 +224,6 @@ ce_page_details_class_init (CEPageDetailsClass *class)
CEPage *
ce_page_details_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings,
NMDevice *device,
NMAccessPoint *ap)
{
......@@ -235,7 +232,6 @@ ce_page_details_new (NMConnection *connection,
page = CE_PAGE_DETAILS (ce_page_new (CE_TYPE_PAGE_DETAILS,
connection,
client,
settings,
"/org/gnome/control-center/network/details-page.ui",
_("Details")));
......
......@@ -56,7 +56,6 @@ GType ce_page_details_get_type (void);
CEPage *ce_page_details_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings,
NMDevice *device,
NMAccessPoint *ap);
......
......@@ -23,11 +23,10 @@
#include <glib-object.h>
#include <glib/gi18n.h>
#include <net/if_arp.h>
#include <nm-utils.h>
#include <nm-device-ethernet.h>
#include <NetworkManager.h>
#include <net/if_arp.h>
#include "firewall-helpers.h"
#include "ce-page-ethernet.h"
......@@ -65,11 +64,11 @@ connect_ethernet_page (CEPageEthernet *page)
NMSettingConnection *sc;
int mtu_def;
char **mac_list;
const GByteArray *s_mac;
char *s_mac_str;
const char *s_mac_str;
GtkWidget *widget;
GtkWidget *heading;
const gchar *name;
const gchar *cloned_mac;
name = nm_setting_connection_get_id (page->setting_connection);
gtk_entry_set_text (page->name, name);
......@@ -77,16 +76,14 @@ connect_ethernet_page (CEPageEthernet *page)
/* Device MAC address */
mac_list = ce_page_get_mac_list (CE_PAGE (page)->client, NM_TYPE_DEVICE_ETHERNET,
NM_DEVICE_ETHERNET_PERMANENT_HW_ADDRESS);
s_mac = nm_setting_wired_get_mac_address (setting);
s_mac_str = s_mac ? nm_utils_hwaddr_ntoa (s_mac->data, ARPHRD_ETHER) : NULL;
s_mac_str = nm_setting_wired_get_mac_address (setting);
ce_page_setup_mac_combo (page->device_mac, s_mac_str, mac_list);
g_free (s_mac_str);
g_strfreev (mac_list);
g_signal_connect_swapped (page->device_mac, "changed", G_CALLBACK (ce_page_changed), page);
/* Cloned MAC address */
ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (setting),
ARPHRD_ETHER, page->cloned_mac);
cloned_mac = nm_setting_wired_get_cloned_mac_address (setting);
gtk_entry_set_text (GTK_ENTRY (page->cloned_mac), cloned_mac ? cloned_mac : "");
g_signal_connect_swapped (page->cloned_mac, "changed", G_CALLBACK (ce_page_changed), page);
/* MTU */
......@@ -122,20 +119,23 @@ connect_ethernet_page (CEPageEthernet *page)
heading = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "heading_zone"));
firewall_ui_setup (sc, widget, heading, CE_PAGE (page)->cancellable);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
}
static void
ui_to_setting (CEPageEthernet *page)
{
GByteArray *device_mac = NULL;
GByteArray *cloned_mac = NULL;
gchar *device_mac = NULL;
gchar *cloned_mac;
const gchar *text;
GtkWidget *entry;
entry = gtk_bin_get_child (GTK_BIN (page->device_mac));
if (entry)
device_mac = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, NULL);
cloned_mac = ce_page_entry_to_mac (page->cloned_mac, ARPHRD_ETHER, NULL);
if (entry) {
text = gtk_entry_get_text (GTK_ENTRY (entry));
device_mac = ce_page_trim_address (text);
}
text = gtk_entry_get_text (GTK_ENTRY (entry));
cloned_mac = ce_page_trim_address (text);
g_object_set (page->setting_wired,
NM_SETTING_WIRED_MAC_ADDRESS, device_mac,
......@@ -143,11 +143,6 @@ ui_to_setting (CEPageEthernet *page)
NM_SETTING_WIRED_MTU, (guint32) gtk_spin_button_get_value_as_int (page->mtu),
NULL);
if (device_mac)
g_byte_array_free (device_mac, TRUE);
if (cloned_mac)
g_byte_array_free (cloned_mac, TRUE);
g_object_set (page->setting_connection,
NM_SETTING_CONNECTION_ID, gtk_entry_get_text (page->name),
NULL);
......@@ -155,6 +150,8 @@ ui_to_setting (CEPageEthernet *page)
entry = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "combo_zone"));
firewall_ui_to_setting (page->setting_connection, entry);
g_free (cloned_mac);
g_free (device_mac);
}
static gboolean
......@@ -163,31 +160,23 @@ validate (CEPage *page,
GError **error)
{
CEPageEthernet *self = CE_PAGE_ETHERNET (page);
gboolean invalid = FALSE;
GByteArray *ignore;
GtkWidget *entry;
gboolean ret = TRUE;
entry = gtk_bin_get_child (GTK_BIN (self->device_mac));
if (entry) {
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
if (invalid) {
if (!ce_page_address_is_valid (gtk_entry_get_text (GTK_ENTRY (entry)))) {
widget_set_error (entry);
ret = FALSE;
} else {
if (ignore)
g_byte_array_free (ignore, TRUE);
widget_unset_error (entry);
}
}
ignore = ce_page_entry_to_mac (self->cloned_mac, ARPHRD_ETHER, &invalid);
if (invalid) {
if (!ce_page_address_is_valid (gtk_entry_get_text (GTK_ENTRY (self->cloned_mac)))) {
widget_set_error (GTK_WIDGET (self->cloned_mac));
ret = FALSE;
} else {
if (ignore)
g_byte_array_free (ignore, TRUE);
widget_unset_error (GTK_WIDGET (self->cloned_mac));
}
......@@ -215,15 +204,13 @@ ce_page_ethernet_class_init (CEPageEthernetClass *class)
CEPage *
ce_page_ethernet_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings)
NMClient *client)
{
CEPageEthernet *page;
page = CE_PAGE_ETHERNET (ce_page_new (CE_TYPE_PAGE_ETHERNET,
connection,
client,
settings,
"/org/gnome/control-center/network/ethernet-page.ui",
_("Identity")));
......
......@@ -24,7 +24,7 @@
#include <glib-object.h>
#include <nm-setting-wired.h>
#include <NetworkManager.h>
#include <gtk/gtk.h>
#include "ce-page.h"
......@@ -63,8 +63,7 @@ struct _CEPageEthernetClass
GType ce_page_ethernet_get_type (void);
CEPage *ce_page_ethernet_new (NMConnection *connection,
NMClient *client,
NMRemoteSettings *settings);
NMClient *client);
G_END_DECLS
......
......@@ -23,13 +23,14 @@
#include <errno.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <glib-object.h>
#include <glib/gi18n.h>
#include <NetworkManager.h>
#include "shell/list-box-helper.h"
#include "ce-page-ip4.h"
#include "ui-helpers.h"
#include <nm-utils.h>
G_DEFINE_TYPE (CEPageIP4, ce_page_ip4, CE_TYPE_PAGE)
......@@ -298,29 +299,24 @@ add_address_section (CEPageIP4 *page)
add_section_toolbar (page, widget, G_CALLBACK (add_empty_address_row));
for (i = 0; i < nm_setting_ip4_config_get_num_addresses (page->setting); i++) {
NMIP4Address *addr;
for (i = 0; i < nm_setting_ip_config_get_num_addresses (page->setting); i++) {
NMIPAddress *addr;
struct in_addr tmp_addr;
gchar address[INET_ADDRSTRLEN + 1];
gchar network[INET_ADDRSTRLEN + 1];
gchar gateway[INET_ADDRSTRLEN + 1];
addr = nm_setting_ip4_config_get_address (page->setting, i);
addr = nm_setting_ip_config_get_address (page->setting, i);
if (!addr)
continue;
tmp_addr.s_addr = nm_ip4_address_get_address (addr);
(void) inet_ntop (AF_INET, &tmp_addr, &address[0], sizeof (address));
tmp_addr.s_addr = nm_utils_ip4_prefix_to_netmask (nm_ip4_address_get_prefix (addr));
tmp_addr.s_addr = nm_utils_ip4_prefix_to_netmask (nm_ip_address_get_prefix (addr));
(void) inet_ntop (AF_INET, &tmp_addr, &network[0], sizeof (network));
tmp_addr.s_addr = nm_ip4_address_get_gateway (addr);
(void) inet_ntop (AF_INET, &tmp_addr, &gateway[0], sizeof (gateway));
add_address_row (page, address, network, gateway);
add_address_row (page,
nm_ip_address_get_address (addr),
network,
nm_setting_ip_config_get_gateway (page->setting));
}
if (nm_setting_ip4_config_get_num_addresses (page->setting) == 0)
if (nm_setting_ip_config_get_num_addresses (page->setting) == 0)
add_empty_address_row (page);
gtk_widget_show_all (widget);
......@@ -399,21 +395,18 @@ add_dns_section (CEPageIP4 *page)
gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
page->auto_dns = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "auto_dns_switch"));
gtk_switch_set_active (page->auto_dns, !nm_setting_ip4_config_get_ignore_auto_dns (page->setting));
gtk_switch_set_active (page->auto_dns, !nm_setting_ip_config_get_ignore_auto_dns (page->setting));
g_signal_connect (page->auto_dns, "notify::active", G_CALLBACK (switch_toggled), page);
add_section_toolbar (page, widget, G_CALLBACK (add_empty_dns_row));
for (i = 0; i < nm_setting_ip4_config_get_num_dns (page->setting); i++) {
struct in_addr tmp_addr;
gchar address[INET_ADDRSTRLEN + 1];
tmp_addr.s_addr = nm_setting_ip4_config_get_dns (page->setting, i);
(void) inet_ntop (AF_INET, &tmp_addr, &address[0], sizeof (address));
for (i = 0; i < nm_setting_ip_config_get_num_dns (page->setting); i++) {
const char *address;
address = nm_setting_ip_config_get_dns (page->setting, i);
add_dns_row (page, address);
}
if (nm_setting_ip4_config_get_num_dns (page->setting) == 0)
if (nm_setting_ip_config_get_num_dns (page->setting) == 0)
add_empty_dns_row (page);
gtk_widget_show_all (widget);
......@@ -483,7 +476,7 @@ add_route_row (CEPageIP4 *page,
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
g_object_set_data (G_OBJECT (row), "metric", widget);
if (metric > 0) {
if (metric >= 0) {
gchar *s = g_strdup_printf ("%d", metric);
gtk_entry_set_text (GTK_ENTRY (widget), s);
g_free (s);
......@@ -521,7 +514,7 @@ add_route_row (CEPageIP4 *page,
static void
add_empty_route_row (CEPageIP4 *page)
{
add_route_row (page, "", "", "", 0);
add_route_row (page, "", "", "", -1);
}
static void
......@@ -542,46 +535,35 @@ add_routes_section (CEPageIP4 *page)
gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
page->auto_routes = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "auto_routes_switch"));
gtk_switch_set_active (page->auto_routes, !nm_setting_ip4_config_get_ignore_auto_routes (page->setting));
gtk_switch_set_active (page->auto_routes, !nm_setting_ip_config_get_ignore_auto_routes (page->setting));
g_signal_connect (page->auto_routes, "notify::active", G_CALLBACK (switch_toggled), page);
add_section_toolbar (page, widget, G_CALLBACK (add_empty_route_row));
for (i = 0; i < nm_setting_ip4_config_get_num_routes (page->setting); i++) {
NMIP4Route *route;
for (i = 0; i < nm_setting_ip_config_get_num_routes (page->setting); i++) {
NMIPRoute *route;
struct in_addr tmp_addr;
gchar address[INET_ADDRSTRLEN + 1];
gchar netmask[INET_ADDRSTRLEN + 1];
gchar gateway[INET_ADDRSTRLEN + 1];
gint metric;
route = nm_setting_ip4_config_get_route (page->setting, i);
route = nm_setting_ip_config_get_route (page->setting, i);
if (!route)
continue;
tmp_addr.s_addr = nm_ip4_route_get_dest (route);
(void) inet_ntop (AF_INET, &tmp_addr, &address[0], sizeof (address));
tmp_addr.s_addr = nm_utils_ip4_prefix_to_netmask (nm_ip4_route_get_prefix (route));
tmp_addr.s_addr = nm_utils_ip4_prefix_to_netmask (nm_ip_route_get_prefix (route));
(void) inet_ntop (AF_INET, &tmp_addr, &netmask[0], sizeof (netmask));
tmp_addr.s_addr = nm_ip4_route_get_next_hop (route);
(void) inet_ntop (AF_INET, &tmp_addr, &gateway[0], sizeof (gateway));
metric = nm_ip4_route_get_metric (route);
add_route_row (page, address, netmask, gateway, metric);
add_route_row (page,
nm_ip_route_get_dest (route),
netmask,
nm_ip_route_get_next_hop (route),
nm_ip_route_get_metric (route));
}
if (nm_setting_ip4_config_get_num_routes (page->setting) == 0)
if (nm_setting_ip_config_get_num_routes (page->setting) == 0)
add_empty_route_row (page);
gtk_widget_show_all (widget);
}
static void
free_addr (gpointer addr)
{
g_array_free ((GArray *)addr, TRUE);
}
static void
connect_ip4_page (CEPageIP4 *page)
{
......@@ -599,7 +581,7 @@ connect_ip4_page (CEPageIP4 *page)
page->enabled = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "switch_enable"));
g_signal_connect (page->enabled, "notify::active", G_CALLBACK (switch_toggled), page);
str_method = nm_setting_ip4_config_get_method (page->setting);
str_method = nm_setting_ip_config_get_method (page->setting);
disabled = g_strcmp0 (str_method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0;
gtk_switch_set_active (page->enabled, !disabled);
g_signal_connect_swapped (page->enabled, "notify::active", G_CALLBACK (ce_page_changed), page);
......@@ -640,7 +622,7 @@ connect_ip4_page (CEPageIP4 *page)
page->never_default = GTK_WIDGET (gtk_builder_get_object (CE_PAGE (page)->builder, "never_default_check"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page->never_default),
nm_setting_ip4_config_get_never_default (page->setting));
nm_setting_ip_config_get_never_default (page->setting));
g_signal_connect_swapped (page->never_default, "toggled", G_CALLBACK (ce_page_changed), page);