[network-manager-applet/jk/wifi-ap-mode-bgo755663: 4/4] editor: change properties on IP4/IP6 pages if Wi-Fi mode changes
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/jk/wifi-ap-mode-bgo755663: 4/4] editor: change properties on IP4/IP6 pages if Wi-Fi mode changes
- Date: Fri, 2 Oct 2015 13:11:03 +0000 (UTC)
commit 5c73ec35b35a95d12e997ecb43cef9c4f92287ec
Author: Jiří Klimeš <jklimes redhat com>
Date: Fri Oct 2 12:49:49 2015 +0200
editor: change properties on IP4/IP6 pages if Wi-Fi mode changes
For AP (hotspot) mode, the IPv4 page needs to change method to Shared,
and the IPv6 mode should be disabled because we don't yet run IPv6 Prefix
Delegation and router advertisements on the shared interface.
src/connection-editor/nm-connection-editor.h | 1 +
src/connection-editor/page-ip4.c | 24 ++++++++++++++++++++++++
src/connection-editor/page-ip6.c | 23 +++++++++++++++++++++++
src/connection-editor/page-wifi.c | 5 +++++
4 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 5636cc5..498e073 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -80,6 +80,7 @@ typedef struct {
typedef enum {
/* Add item for inter-page changes here */
+ INTER_PAGE_CHANGE_WIFI_MODE = 1,
} InterPageChangeType;
GType nm_connection_editor_get_type (void);
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 4c5574e..0df9262 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -1230,6 +1230,29 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
+static gboolean
+inter_page_change (CEPage *page)
+{
+ CEPageIP4 *self = CE_PAGE_IP4 (page);
+ CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+ gpointer wifi_mode_ap;
+ static int method_orig = -1;
+
+ if (nm_connection_editor_inter_page_get_value (page->editor, INTER_PAGE_CHANGE_WIFI_MODE,
&wifi_mode_ap)) {
+ /* For Wi-Fi AP mode set IPv4 method to shared */
+ if (GPOINTER_TO_UINT (wifi_mode_ap)) {
+ if (method_orig == -1)
+ method_orig = gtk_combo_box_get_active (priv->method);
+ gtk_combo_box_set_active (priv->method, IP4_METHOD_SHARED);
+ } else {
+ if (method_orig != -1)
+ gtk_combo_box_set_active (priv->method, method_orig);
+ }
+g_print (">>>>> WIFI_MODE_CHANGED: %d\n", GPOINTER_TO_UINT (wifi_mode_ap));
+ }
+ return TRUE;
+}
+
static void
ce_page_ip4_init (CEPageIP4 *self)
{
@@ -1266,5 +1289,6 @@ ce_page_ip4_class_init (CEPageIP4Class *ip4_class)
/* virtual methods */
parent_class->ce_page_validate_v = ce_page_validate_v;
+ parent_class->inter_page_change = inter_page_change;
object_class->dispose = dispose;
}
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index eb252e3..1d84a7b 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -1217,6 +1217,28 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
+static gboolean
+inter_page_change (CEPage *page)
+{
+ CEPageIP6 *self = CE_PAGE_IP6 (page);
+ CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self);
+ gpointer wifi_mode_ap;
+ static int method_orig = -1;
+
+ if (nm_connection_editor_inter_page_get_value (page->editor, INTER_PAGE_CHANGE_WIFI_MODE,
&wifi_mode_ap)) {
+ /* For Wi-Fi AP mode set IPv6 method to ignored */
+ if (GPOINTER_TO_UINT (wifi_mode_ap)) {
+ if (method_orig == -1)
+ method_orig = gtk_combo_box_get_active (priv->method);
+ gtk_combo_box_set_active (priv->method, IP6_METHOD_IGNORE);
+ } else {
+ if (method_orig != -1)
+ gtk_combo_box_set_active (priv->method, method_orig);
+ }
+ }
+ return TRUE;
+}
+
static void
ce_page_ip6_init (CEPageIP6 *self)
{
@@ -1253,5 +1275,6 @@ ce_page_ip6_class_init (CEPageIP6Class *ip6_class)
/* virtual methods */
parent_class->ce_page_validate_v = ce_page_validate_v;
+ parent_class->inter_page_change = inter_page_change;
object_class->dispose = dispose;
}
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index cbcd3b0..aa4ea28 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -248,9 +248,11 @@ mode_combo_changed_cb (GtkComboBox *combo,
GtkWidget *widget_band_label, *widget_chan_label, *widget_bssid_label;
gboolean show_freq = FALSE;
gboolean show_bssid = TRUE;
+ gboolean hotspot = FALSE;
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo))) {
case 1: /* hotspot */
+ hotspot = TRUE;
case 2: /* adhoc */
/* BSSID is random and is created by kernel for Ad-Hoc networks
* http://lxr.linux.no/linux+v3.7.6/net/mac80211/ibss.c#L685
@@ -263,6 +265,9 @@ mode_combo_changed_cb (GtkComboBox *combo,
show_freq = FALSE;
break;
}
+ nm_connection_editor_inter_page_set_value (parent->editor,
+ INTER_PAGE_CHANGE_WIFI_MODE,
+ GUINT_TO_POINTER (hotspot));
widget_band_label = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wifi_band_label"));
widget_chan_label = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wifi_channel_label"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]