summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-09-14 18:23:24 +0200
committerJiří Klimeš <jklimes@redhat.com>2015-09-16 08:48:14 +0200
commit6ed3aa339d6222a1f08796787171ff6dc86d0385 (patch)
tree4017c92d493227b3102ab470985a1d9ff70045ec
parent9aa77ea2ca2b0699f8a86e5c7c2a5c92a7256f48 (diff)
downloadnetwork-manager-applet-6ed3aa339d6222a1f08796787171ff6dc86d0385.tar.gz
editor: add Wake-on-LAN settings to the editor Ethernet page (bgo #755039)
With some changes by thaller. https://bugzilla.gnome.org/show_bug.cgi?id=755039
-rw-r--r--src/connection-editor/ce-page-ethernet.ui166
-rw-r--r--src/connection-editor/page-ethernet.c116
2 files changed, 281 insertions, 1 deletions
diff --git a/src/connection-editor/ce-page-ethernet.ui b/src/connection-editor/ce-page-ethernet.ui
index 1bade41c..a0f74776 100644
--- a/src/connection-editor/ce-page-ethernet.ui
+++ b/src/connection-editor/ce-page-ethernet.ui
@@ -279,5 +279,171 @@
<property name="y_options">GTK_FILL</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label30">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Wake on LAN:</property>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="resize_mode">immediate</property>
+ <property name="column_spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="wol_default">
+ <property name="label" translatable="yes">De_fault</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="margin_right">12</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wol_phy">
+ <property name="label" translatable="yes">_Phy</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wol_unicast">
+ <property name="label" translatable="yes">_Unicast</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wol_multicast">
+ <property name="label" translatable="yes">Mul_ticast</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wol_broadcast">
+ <property name="label" translatable="yes">_Broadcast</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wol_arp">
+ <property name="label" translatable="yes">_Arp</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="wol_magic">
+ <property name="label" translatable="yes">Ma_gic</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label31">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Wake on LAN password:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">ethernet_wol_passwd</property>
+ </object>
+ <packing>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="ethernet_wol_passwd">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="tooltip_text" translatable="yes">Wake-on-LAN password (an Ethernet MAC). It is only valid for magic packets.</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
+ <property name="y_options"/>
+ </packing>
+ </child>
</object>
</interface>
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index d52e00cf..7a56d356 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -44,6 +44,9 @@ typedef struct {
GtkToggleButton *duplex;
GtkToggleButton *autonegotiate;
GtkSpinButton *mtu;
+ GtkToggleButton *wol_default, *wol_phy, *wol_unicast, *wol_multicast,
+ *wol_broadcast, *wol_arp, *wol_magic;
+ GtkEntry *wol_passwd;
} CEPageEthernetPrivate;
#define PORT_DEFAULT 0
@@ -90,6 +93,14 @@ ethernet_private_init (CEPageEthernet *self)
priv->duplex = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "ethernet_duplex"));
priv->autonegotiate = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "ethernet_autonegotiate"));
priv->mtu = GTK_SPIN_BUTTON (gtk_builder_get_object (builder, "ethernet_mtu"));
+ priv->wol_default = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_default"));
+ priv->wol_phy = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_phy"));
+ priv->wol_unicast = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_unicast"));
+ priv->wol_multicast = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_multicast"));
+ priv->wol_broadcast = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_broadcast"));
+ priv->wol_arp = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_arp"));
+ priv->wol_magic = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "wol_magic"));
+ priv->wol_passwd = GTK_ENTRY (gtk_builder_get_object (builder, "ethernet_wol_passwd"));
}
static void
@@ -99,6 +110,43 @@ stuff_changed (GtkWidget *w, gpointer user_data)
}
static void
+wol_default_toggled_cb (GtkWidget *widget, gpointer user_data)
+{
+ CEPageEthernet *self = CE_PAGE_ETHERNET (user_data);
+ CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
+ gboolean enabled, enabled_passwd;
+
+ enabled = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_phy), !enabled);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_unicast), !enabled);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_multicast), !enabled);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_broadcast), !enabled);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_arp), !enabled);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_magic), !enabled);
+
+ enabled_passwd = !enabled && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->wol_magic));
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_passwd), enabled_passwd);
+
+ stuff_changed (NULL, self);
+}
+
+static void
+wol_magic_toggled_cb (GtkWidget *widget, gpointer user_data)
+{
+ CEPageEthernet *self = CE_PAGE_ETHERNET (user_data);
+ CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
+ gboolean enabled;
+
+ enabled = gtk_widget_get_sensitive (widget)
+ && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
+
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->wol_passwd), enabled);
+
+ stuff_changed (NULL, self);
+}
+
+static void
populate_ui (CEPageEthernet *self)
{
CEPageEthernetPrivate *priv = CE_PAGE_ETHERNET_GET_PRIVATE (self);
@@ -108,7 +156,8 @@ populate_ui (CEPageEthernet *self)
int port_idx = PORT_DEFAULT;
int speed_idx;
int mtu_def;
- const char *s_mac, *s_ifname;
+ const char *s_mac, *s_ifname, *s_wol_passwd;
+ NMSettingWiredWakeOnLan wol;
/* Port */
port = nm_setting_wired_get_port (setting);
@@ -176,6 +225,31 @@ populate_ui (CEPageEthernet *self)
GINT_TO_POINTER (mtu_def));
gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wired_get_mtu (setting));
+
+ /* Wake-on-LAN */
+ wol = nm_setting_wired_get_wake_on_lan (priv->setting);
+ if (wol == NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT)
+ gtk_toggle_button_set_active (priv->wol_default, TRUE);
+ else {
+ if (wol & NM_SETTING_WIRED_WAKE_ON_LAN_PHY)
+ gtk_toggle_button_set_active (priv->wol_phy, TRUE);
+ if (wol & NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST)
+ gtk_toggle_button_set_active (priv->wol_unicast, TRUE);
+ if (wol & NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST)
+ gtk_toggle_button_set_active (priv->wol_multicast, TRUE);
+ if (wol & NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST)
+ gtk_toggle_button_set_active (priv->wol_broadcast, TRUE);
+ if (wol & NM_SETTING_WIRED_WAKE_ON_LAN_ARP)
+ gtk_toggle_button_set_active (priv->wol_arp, TRUE);
+ if (wol & NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)
+ gtk_toggle_button_set_active (priv->wol_magic, TRUE);
+ }
+
+ /* Wake-on LAN password */
+ s_wol_passwd = nm_setting_wired_get_wake_on_lan_password (setting);
+ if (s_wol_passwd)
+ gtk_entry_set_text (priv->wol_passwd, s_wol_passwd);
+ g_signal_connect (priv->wol_passwd, "changed", G_CALLBACK (stuff_changed), self);
}
static void
@@ -196,6 +270,16 @@ finish_setup (CEPageEthernet *self, gpointer unused, GError *error, gpointer use
g_signal_connect (priv->autonegotiate, "toggled", G_CALLBACK (stuff_changed), self);
g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->wol_default, "toggled", G_CALLBACK (wol_default_toggled_cb), self);
+ wol_default_toggled_cb (GTK_WIDGET (priv->wol_default), self);
+ g_signal_connect (priv->wol_phy, "toggled", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->wol_unicast, "toggled", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->wol_multicast, "toggled", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->wol_broadcast, "toggled", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->wol_arp, "toggled", G_CALLBACK (stuff_changed), self);
+ g_signal_connect (priv->wol_magic, "toggled", G_CALLBACK (wol_magic_toggled_cb), self);
+ wol_magic_toggled_cb (GTK_WIDGET (priv->wol_magic), self);
+
/* Hide widgets we don't yet support */
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "ethernet_port_label"));
gtk_widget_hide (widget);
@@ -260,6 +344,8 @@ ui_to_setting (CEPageEthernet *self)
char *device_mac = NULL;
const char *cloned_mac;
GtkWidget *entry;
+ NMSettingWiredWakeOnLan wol = NM_SETTING_WIRED_WAKE_ON_LAN_NONE;
+ const char *wol_passwd = NULL;
s_con = nm_connection_get_setting_connection (CE_PAGE (self)->connection);
g_return_if_fail (s_con != NULL);
@@ -307,6 +393,27 @@ ui_to_setting (CEPageEthernet *self)
ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac, NULL, NULL);
cloned_mac = gtk_entry_get_text (priv->cloned_mac);
+ /* Wake-on-LAN */
+ if (gtk_toggle_button_get_active (priv->wol_default))
+ wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
+ else {
+ if (gtk_toggle_button_get_active (priv->wol_phy))
+ wol |= NM_SETTING_WIRED_WAKE_ON_LAN_PHY;
+ if (gtk_toggle_button_get_active (priv->wol_unicast))
+ wol |= NM_SETTING_WIRED_WAKE_ON_LAN_UNICAST;
+ if (gtk_toggle_button_get_active (priv->wol_multicast))
+ wol |= NM_SETTING_WIRED_WAKE_ON_LAN_MULTICAST;
+ if (gtk_toggle_button_get_active (priv->wol_broadcast))
+ wol |= NM_SETTING_WIRED_WAKE_ON_LAN_BROADCAST;
+ if (gtk_toggle_button_get_active (priv->wol_arp))
+ wol |= NM_SETTING_WIRED_WAKE_ON_LAN_ARP;
+ if (gtk_toggle_button_get_active (priv->wol_magic))
+ wol |= NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC;
+ }
+
+ if (gtk_widget_get_sensitive (GTK_WIDGET (priv->wol_passwd)))
+ wol_passwd = gtk_entry_get_text (priv->wol_passwd);
+
g_object_set (s_con,
NM_SETTING_CONNECTION_INTERFACE_NAME, ifname,
NULL);
@@ -318,6 +425,8 @@ ui_to_setting (CEPageEthernet *self)
NM_SETTING_WIRED_DUPLEX, gtk_toggle_button_get_active (priv->duplex) ? "full" : "half",
NM_SETTING_WIRED_AUTO_NEGOTIATE, gtk_toggle_button_get_active (priv->autonegotiate),
NM_SETTING_WIRED_MTU, (guint32) gtk_spin_button_get_value_as_int (priv->mtu),
+ NM_SETTING_WIRED_WAKE_ON_LAN, wol,
+ NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, wol_passwd && *wol_passwd ? wol_passwd : NULL,
NULL);
g_free (ifname);
@@ -340,6 +449,11 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
if (!ce_page_mac_entry_valid (priv->cloned_mac, ARPHRD_ETHER, _("cloned MAC"), error))
return FALSE;
+ if (gtk_widget_get_sensitive (GTK_WIDGET (priv->wol_passwd))) {
+ if (!ce_page_mac_entry_valid (priv->wol_passwd, ARPHRD_ETHER, _("Wake-on-LAN password"), error))
+ return FALSE;
+ }
+
ui_to_setting (self);
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}