summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-10-14 09:48:12 +0200
committerJiří Klimeš <jklimes@redhat.com>2015-10-14 09:48:12 +0200
commit8ef1a4c92f2a7634b43213692eff2f68b0cbd8f3 (patch)
tree681bc22e0256f37ead033184f0f8e31bad0ebd73
parent8813ca1b98d20f236f79fb126996d98edc1a421f (diff)
parent0294378068e990f8129095e481c5cc2ac8c3b617 (diff)
downloadnetwork-manager-applet-8ef1a4c92f2a7634b43213692eff2f68b0cbd8f3.tar.gz
merge: hotspot mode support for the editor (bgo #755663)
It adds the AP (hotspot) mode to the editor and changes IPv4/IPv6 methods accordingly. https://bugzilla.gnome.org/show_bug.cgi?id=755663
-rw-r--r--src/connection-editor/ce-page-wifi.ui5
-rw-r--r--src/connection-editor/ce-page.c20
-rw-r--r--src/connection-editor/ce-page.h10
-rw-r--r--src/connection-editor/nm-connection-editor.c38
-rw-r--r--src/connection-editor/nm-connection-editor.h15
-rw-r--r--src/connection-editor/page-8021x-security.c4
-rw-r--r--src/connection-editor/page-8021x-security.h3
-rw-r--r--src/connection-editor/page-bluetooth.c4
-rw-r--r--src/connection-editor/page-bluetooth.h3
-rw-r--r--src/connection-editor/page-bond.c12
-rw-r--r--src/connection-editor/page-bond.h3
-rw-r--r--src/connection-editor/page-bridge-port.c4
-rw-r--r--src/connection-editor/page-bridge-port.h3
-rw-r--r--src/connection-editor/page-bridge.c4
-rw-r--r--src/connection-editor/page-bridge.h3
-rw-r--r--src/connection-editor/page-dcb.c4
-rw-r--r--src/connection-editor/page-dcb.h3
-rw-r--r--src/connection-editor/page-dsl.c4
-rw-r--r--src/connection-editor/page-dsl.h3
-rw-r--r--src/connection-editor/page-ethernet.c4
-rw-r--r--src/connection-editor/page-ethernet.h3
-rw-r--r--src/connection-editor/page-general.c4
-rw-r--r--src/connection-editor/page-general.h3
-rw-r--r--src/connection-editor/page-infiniband.c4
-rw-r--r--src/connection-editor/page-infiniband.h3
-rw-r--r--src/connection-editor/page-ip4.c111
-rw-r--r--src/connection-editor/page-ip4.h3
-rw-r--r--src/connection-editor/page-ip6.c111
-rw-r--r--src/connection-editor/page-ip6.h3
-rw-r--r--src/connection-editor/page-mobile.c4
-rw-r--r--src/connection-editor/page-mobile.h3
-rw-r--r--src/connection-editor/page-ppp.c4
-rw-r--r--src/connection-editor/page-ppp.h3
-rw-r--r--src/connection-editor/page-team-port.c4
-rw-r--r--src/connection-editor/page-team-port.h3
-rw-r--r--src/connection-editor/page-team.c12
-rw-r--r--src/connection-editor/page-team.h3
-rw-r--r--src/connection-editor/page-vlan.c4
-rw-r--r--src/connection-editor/page-vlan.h3
-rw-r--r--src/connection-editor/page-vpn.c4
-rw-r--r--src/connection-editor/page-vpn.h3
-rw-r--r--src/connection-editor/page-wifi-security.c115
-rw-r--r--src/connection-editor/page-wifi-security.h3
-rw-r--r--src/connection-editor/page-wifi.c85
-rw-r--r--src/connection-editor/page-wifi.h3
-rw-r--r--src/wireless-security/wireless-security.c9
-rw-r--r--src/wireless-security/wireless-security.h3
-rw-r--r--src/wireless-security/ws-dynamic-wep.c1
-rw-r--r--src/wireless-security/ws-leap.c1
-rw-r--r--src/wireless-security/ws-wpa-eap.c1
50 files changed, 524 insertions, 141 deletions
diff --git a/src/connection-editor/ce-page-wifi.ui b/src/connection-editor/ce-page-wifi.ui
index b5f6ea55..1ab2f2b9 100644
--- a/src/connection-editor/ce-page-wifi.ui
+++ b/src/connection-editor/ce-page-wifi.ui
@@ -45,7 +45,10 @@
</columns>
<data>
<row>
- <col id="0" translatable="yes">Infrastructure</col>
+ <col id="0" translatable="yes">Client</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Hotspot</col>
</row>
<row>
<col id="0" translatable="yes">Ad-hoc</col>
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 1194ed90..3f79c22b 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -151,6 +151,24 @@ ce_page_last_update (CEPage *self, NMConnection *connection, GError **error)
return TRUE;
}
+gboolean
+ce_page_inter_page_change (CEPage *self)
+{
+ gboolean ret = FALSE;
+
+ g_return_val_if_fail (CE_IS_PAGE (self), FALSE);
+
+ if (self->inter_page_change_running)
+ return FALSE;
+
+ self->inter_page_change_running = TRUE;
+ if (CE_PAGE_GET_CLASS (self)->inter_page_change)
+ ret = CE_PAGE_GET_CLASS (self)->inter_page_change (self);
+ self->inter_page_change_running = FALSE;
+
+ return ret;
+}
+
static void
_set_active_combo_item (GtkComboBox *combo, const char *item,
const char *combo_item, int combo_idx)
@@ -766,6 +784,7 @@ ce_page_new_connection (const char *format,
CEPage *
ce_page_new (GType page_type,
+ NMConnectionEditor *editor,
NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
@@ -786,6 +805,7 @@ ce_page_new (GType page_type,
NULL));
self->title = g_strdup (title);
self->client = client;
+ self->editor = editor;
if (ui_file) {
if (!gtk_builder_add_from_file (self->builder, ui_file, &error)) {
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index 2c115142..efafc03f 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -30,6 +30,7 @@
#include <NetworkManager.h>
+#include "nm-connection-editor.h"
#include "utils.h"
/* for ARPHRD_ETHER / ARPHRD_INFINIBAND for MAC utilies */
@@ -63,12 +64,14 @@ typedef struct {
GObject parent;
gboolean initialized;
+ gboolean inter_page_change_running;
GtkBuilder *builder;
GtkWidget *page;
char *title;
gulong secrets_done_validate;
+ NMConnectionEditor *editor;
NMConnection *connection;
GtkWindow *parent_window;
NMClient *client;
@@ -80,6 +83,7 @@ typedef struct {
/* Virtual functions */
gboolean (*ce_page_validate_v) (CEPage *self, NMConnection *connection, GError **error);
gboolean (*last_update) (CEPage *self, NMConnection *connection, GError **error);
+ gboolean (*inter_page_change) (CEPage *self);
/* Signals */
void (*changed) (CEPage *self);
@@ -87,7 +91,8 @@ typedef struct {
} CEPageClass;
-typedef CEPage* (*CEPageNewFunc)(NMConnection *connection,
+typedef CEPage* (*CEPageNewFunc)(NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
@@ -102,6 +107,7 @@ const char * ce_page_get_title (CEPage *self);
gboolean ce_page_validate (CEPage *self, NMConnection *connection, GError **error);
gboolean ce_page_last_update (CEPage *self, NMConnection *connection, GError **error);
+gboolean ce_page_inter_page_change (CEPage *self);
void ce_page_setup_mac_combo (CEPage *self, GtkComboBox *combo,
const char *mac, char **mac_list);
@@ -146,6 +152,7 @@ NMConnection *ce_page_new_connection (const char *format,
gpointer user_data);
CEPage *ce_page_new (GType page_type,
+ NMConnectionEditor *editor,
NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
@@ -153,5 +160,6 @@ CEPage *ce_page_new (GType page_type,
const char *widget_name,
const char *title);
+
#endif /* __CE_PAGE_H__ */
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 9c7a1ef4..8de06809 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -258,6 +258,12 @@ permissions_changed_cb (NMClient *client,
}
static void
+destroy_inter_page_item (gpointer data)
+{
+ return;
+}
+
+static void
nm_connection_editor_init (NMConnectionEditor *editor)
{
GtkWidget *dialog;
@@ -290,6 +296,8 @@ nm_connection_editor_init (NMConnectionEditor *editor)
editor->cancel_button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "cancel_button"));
editor->export_button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "export_button"));
+
+ editor->inter_page_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) destroy_inter_page_item);
}
static void
@@ -361,6 +369,8 @@ dispose (GObject *object)
g_clear_pointer (&editor->last_validation_error, g_free);
+ g_hash_table_destroy (editor->inter_page_hash);
+
out:
G_OBJECT_CLASS (nm_connection_editor_parent_class)->dispose (object);
}
@@ -507,6 +517,14 @@ static void
page_changed (CEPage *page, gpointer user_data)
{
NMConnectionEditor *editor = NM_CONNECTION_EDITOR (user_data);
+ GSList *iter;
+
+ /* Do page interdependent changes */
+ for (iter = editor->pages; iter; iter = g_slist_next (iter))
+ ce_page_inter_page_change (CE_PAGE (iter->data));
+
+ if (editor_is_initialized (editor))
+ nm_connection_editor_inter_page_clear_data (editor);
connection_editor_validate (editor);
}
@@ -695,7 +713,7 @@ add_page (NMConnectionEditor *editor,
g_return_val_if_fail (func != NULL, FALSE);
g_return_val_if_fail (connection != NULL, FALSE);
- page = (*func) (connection, GTK_WINDOW (editor->window), editor->client,
+ page = (*func) (editor, connection, GTK_WINDOW (editor->window), editor->client,
&secrets_setting_name, error);
if (page) {
g_object_set_data_full (G_OBJECT (page),
@@ -1119,3 +1137,21 @@ nm_connection_editor_warning (GtkWindow *parent, const char *heading, const char
va_end (args);
}
+void
+nm_connection_editor_inter_page_set_value (NMConnectionEditor *editor, InterPageChangeType type, gpointer value)
+{
+ g_hash_table_insert (editor->inter_page_hash, GUINT_TO_POINTER (type), value);
+}
+
+gboolean
+nm_connection_editor_inter_page_get_value (NMConnectionEditor *editor, InterPageChangeType type, gpointer *value)
+{
+ return g_hash_table_lookup_extended (editor->inter_page_hash, GUINT_TO_POINTER (type), NULL, value);
+}
+
+void
+nm_connection_editor_inter_page_clear_data (NMConnectionEditor *editor)
+{
+ g_hash_table_remove_all (editor->inter_page_hash);
+}
+
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 259e8dc2..6275baf5 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -66,6 +66,8 @@ typedef struct {
guint validate_id;
char *last_validation_error;
+
+ GHashTable *inter_page_hash;
} NMConnectionEditor;
typedef struct {
@@ -75,6 +77,11 @@ typedef struct {
void (*done) (NMConnectionEditor *editor, gint result, GError *error);
} NMConnectionEditorClass;
+typedef enum {
+ /* Add item for inter-page changes here */
+ INTER_PAGE_CHANGE_WIFI_MODE = 1,
+} InterPageChangeType;
+
GType nm_connection_editor_get_type (void);
NMConnectionEditor *nm_connection_editor_new (GtkWindow *parent_window,
NMConnection *connection,
@@ -98,4 +105,12 @@ void nm_connection_editor_warning (GtkWindow *parent,
const char *format,
...);
+void nm_connection_editor_inter_page_set_value (NMConnectionEditor *editor,
+ InterPageChangeType type,
+ gpointer value);
+gboolean nm_connection_editor_inter_page_get_value (NMConnectionEditor *editor,
+ InterPageChangeType type,
+ gpointer *value);
+void nm_connection_editor_inter_page_clear_data (NMConnectionEditor *editor);
+
#endif
diff --git a/src/connection-editor/page-8021x-security.c b/src/connection-editor/page-8021x-security.c
index f484a5d2..0ff13aeb 100644
--- a/src/connection-editor/page-8021x-security.c
+++ b/src/connection-editor/page-8021x-security.c
@@ -91,7 +91,8 @@ finish_setup (CEPage8021xSecurity *self, gpointer unused, GError *error, gpointe
}
CEPage *
-ce_page_8021x_security_new (NMConnection *connection,
+ce_page_8021x_security_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -102,6 +103,7 @@ ce_page_8021x_security_new (NMConnection *connection,
CEPage *parent;
self = CE_PAGE_8021X_SECURITY (ce_page_new (CE_TYPE_PAGE_8021X_SECURITY,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-8021x-security.h b/src/connection-editor/page-8021x-security.h
index b06e33f0..439360ce 100644
--- a/src/connection-editor/page-8021x-security.h
+++ b/src/connection-editor/page-8021x-security.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_8021x_security_get_type (void);
-CEPage *ce_page_8021x_security_new (NMConnection *connection,
+CEPage *ce_page_8021x_security_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-bluetooth.c b/src/connection-editor/page-bluetooth.c
index 23ec596a..de51127b 100644
--- a/src/connection-editor/page-bluetooth.c
+++ b/src/connection-editor/page-bluetooth.c
@@ -90,7 +90,8 @@ finish_setup (CEPageBluetooth *self, gpointer unused, GError *error, gpointer us
}
CEPage *
-ce_page_bluetooth_new (NMConnection *connection,
+ce_page_bluetooth_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -100,6 +101,7 @@ ce_page_bluetooth_new (NMConnection *connection,
CEPageBluetoothPrivate *priv;
self = CE_PAGE_BLUETOOTH (ce_page_new (CE_TYPE_PAGE_BLUETOOTH,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-bluetooth.h b/src/connection-editor/page-bluetooth.h
index dd2207a0..ae2df50c 100644
--- a/src/connection-editor/page-bluetooth.h
+++ b/src/connection-editor/page-bluetooth.h
@@ -47,7 +47,8 @@ typedef struct {
GType ce_page_bluetooth_get_type (void);
-CEPage *ce_page_bluetooth_new (NMConnection *connection,
+CEPage *ce_page_bluetooth_new (NMConnectionEditor *edit,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index 9d3b7898..af608d0a 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -426,16 +426,18 @@ finish_setup (CEPageBond *self, gpointer unused, GError *error, gpointer user_da
}
CEPage *
-ce_page_bond_new (NMConnection *connection,
- GtkWindow *parent_window,
- NMClient *client,
- const char **out_secrets_setting_name,
- GError **error)
+ce_page_bond_new (NMConnectionEditor *editor,
+ NMConnection *connection,
+ GtkWindow *parent_window,
+ NMClient *client,
+ const char **out_secrets_setting_name,
+ GError **error)
{
CEPageBond *self;
CEPageBondPrivate *priv;
self = CE_PAGE_BOND (ce_page_new (CE_TYPE_PAGE_BOND,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-bond.h b/src/connection-editor/page-bond.h
index 646abe1c..5b75e090 100644
--- a/src/connection-editor/page-bond.h
+++ b/src/connection-editor/page-bond.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_bond_get_type (void);
-CEPage *ce_page_bond_new (NMConnection *connection,
+CEPage *ce_page_bond_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-bridge-port.c b/src/connection-editor/page-bridge-port.c
index 52e62601..129f73dd 100644
--- a/src/connection-editor/page-bridge-port.c
+++ b/src/connection-editor/page-bridge-port.c
@@ -88,7 +88,8 @@ finish_setup (CEPageBridgePort *self, gpointer unused, GError *error, gpointer u
}
CEPage *
-ce_page_bridge_port_new (NMConnection *connection,
+ce_page_bridge_port_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -98,6 +99,7 @@ ce_page_bridge_port_new (NMConnection *connection,
CEPageBridgePortPrivate *priv;
self = CE_PAGE_BRIDGE_PORT (ce_page_new (CE_TYPE_PAGE_BRIDGE_PORT,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-bridge-port.h b/src/connection-editor/page-bridge-port.h
index a74f7f85..748d269b 100644
--- a/src/connection-editor/page-bridge-port.h
+++ b/src/connection-editor/page-bridge-port.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_bridge_port_get_type (void);
-CEPage *ce_page_bridge_port_new (NMConnection *connection,
+CEPage *ce_page_bridge_port_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-bridge.c b/src/connection-editor/page-bridge.c
index d3007a41..1ec84ea2 100644
--- a/src/connection-editor/page-bridge.c
+++ b/src/connection-editor/page-bridge.c
@@ -192,7 +192,8 @@ finish_setup (CEPageBridge *self, gpointer unused, GError *error, gpointer user_
}
CEPage *
-ce_page_bridge_new (NMConnection *connection,
+ce_page_bridge_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -202,6 +203,7 @@ ce_page_bridge_new (NMConnection *connection,
CEPageBridgePrivate *priv;
self = CE_PAGE_BRIDGE (ce_page_new (CE_TYPE_PAGE_BRIDGE,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-bridge.h b/src/connection-editor/page-bridge.h
index 4b1873fa..3581b063 100644
--- a/src/connection-editor/page-bridge.h
+++ b/src/connection-editor/page-bridge.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_bridge_get_type (void);
-CEPage *ce_page_bridge_new (NMConnection *connection,
+CEPage *ce_page_bridge_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-dcb.c b/src/connection-editor/page-dcb.c
index b8405fe1..632a2879 100644
--- a/src/connection-editor/page-dcb.c
+++ b/src/connection-editor/page-dcb.c
@@ -584,7 +584,8 @@ finish_setup (CEPageDcb *self, gpointer unused, GError *error, gpointer user_dat
}
CEPage *
-ce_page_dcb_new (NMConnection *connection,
+ce_page_dcb_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -596,6 +597,7 @@ ce_page_dcb_new (NMConnection *connection,
NMSettingDcb *s_dcb;
self = CE_PAGE_DCB (ce_page_new (CE_TYPE_PAGE_DCB,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-dcb.h b/src/connection-editor/page-dcb.h
index ad34520e..9019cc64 100644
--- a/src/connection-editor/page-dcb.h
+++ b/src/connection-editor/page-dcb.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_dcb_get_type (void);
-CEPage *ce_page_dcb_new (NMConnection *connection,
+CEPage *ce_page_dcb_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index aeb9f55e..7177a06b 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -110,7 +110,8 @@ finish_setup (CEPageDsl *self, gpointer unused, GError *error, gpointer user_dat
}
CEPage *
-ce_page_dsl_new (NMConnection *connection,
+ce_page_dsl_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -120,6 +121,7 @@ ce_page_dsl_new (NMConnection *connection,
CEPageDslPrivate *priv;
self = CE_PAGE_DSL (ce_page_new (CE_TYPE_PAGE_DSL,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-dsl.h b/src/connection-editor/page-dsl.h
index e893c9a3..b5c6f1bf 100644
--- a/src/connection-editor/page-dsl.h
+++ b/src/connection-editor/page-dsl.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_dsl_get_type (void);
-CEPage *ce_page_dsl_new (NMConnection *connection,
+CEPage *ce_page_dsl_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index 7a56d356..cc754b99 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -298,7 +298,8 @@ finish_setup (CEPageEthernet *self, gpointer unused, GError *error, gpointer use
}
CEPage *
-ce_page_ethernet_new (NMConnection *connection,
+ce_page_ethernet_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -308,6 +309,7 @@ ce_page_ethernet_new (NMConnection *connection,
CEPageEthernetPrivate *priv;
self = CE_PAGE_ETHERNET (ce_page_new (CE_TYPE_PAGE_ETHERNET,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-ethernet.h b/src/connection-editor/page-ethernet.h
index 0a06a57b..68ff57d2 100644
--- a/src/connection-editor/page-ethernet.h
+++ b/src/connection-editor/page-ethernet.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_ethernet_get_type (void);
-CEPage *ce_page_ethernet_new (NMConnection *connection,
+CEPage *ce_page_ethernet_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c
index 1f713287..13e8aa22 100644
--- a/src/connection-editor/page-general.c
+++ b/src/connection-editor/page-general.c
@@ -331,7 +331,8 @@ finish_setup (CEPageGeneral *self, gpointer unused, GError *error, gpointer user
}
CEPage *
-ce_page_general_new (NMConnection *connection,
+ce_page_general_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -341,6 +342,7 @@ ce_page_general_new (NMConnection *connection,
CEPageGeneralPrivate *priv;
self = CE_PAGE_GENERAL (ce_page_new (CE_TYPE_PAGE_GENERAL,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-general.h b/src/connection-editor/page-general.h
index 23ee94d5..1e2f3bef 100644
--- a/src/connection-editor/page-general.h
+++ b/src/connection-editor/page-general.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_general_get_type (void);
-CEPage *ce_page_general_new (NMConnection *connection,
+CEPage *ce_page_general_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-infiniband.c b/src/connection-editor/page-infiniband.c
index 09c9b8f9..a0ce48ad 100644
--- a/src/connection-editor/page-infiniband.c
+++ b/src/connection-editor/page-infiniband.c
@@ -133,7 +133,8 @@ finish_setup (CEPageInfiniband *self, gpointer unused, GError *error, gpointer u
}
CEPage *
-ce_page_infiniband_new (NMConnection *connection,
+ce_page_infiniband_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -143,6 +144,7 @@ ce_page_infiniband_new (NMConnection *connection,
CEPageInfinibandPrivate *priv;
self = CE_PAGE_INFINIBAND (ce_page_new (CE_TYPE_PAGE_INFINIBAND,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-infiniband.h b/src/connection-editor/page-infiniband.h
index ab452773..9feca14b 100644
--- a/src/connection-editor/page-infiniband.h
+++ b/src/connection-editor/page-infiniband.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_infiniband_get_type (void);
-CEPage *ce_page_infiniband_new (NMConnection *connection,
+CEPage *ce_page_infiniband_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 48d6041f..120a2d22 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -54,6 +54,8 @@ typedef struct {
GtkComboBox *method;
GtkListStore *method_store;
+ int normal_method_idx;
+ int hotspot_method_idx;
/* Addresses */
GtkWidget *addr_label;
@@ -94,6 +96,7 @@ typedef struct {
#define METHOD_COL_NAME 0
#define METHOD_COL_NUM 1
+#define METHOD_COL_ENABLED 2
#define IP4_METHOD_AUTO 0
#define IP4_METHOD_AUTO_ADDRESSES 1
@@ -111,6 +114,7 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
NMSettingConnection *s_con;
const char *connection_type;
char *str_auto = NULL, *str_auto_only = NULL;
+ GList *cells;
builder = CE_PAGE (self)->builder;
@@ -137,19 +141,24 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
}
priv->method = GTK_COMBO_BOX (gtk_builder_get_object (builder, "ip4_method"));
+ cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->method));
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->method), cells->data,
+ "sensitive", METHOD_COL_ENABLED);
- priv->method_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT);
+ priv->method_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_BOOLEAN);
gtk_list_store_append (priv->method_store, &iter);
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, str_auto,
METHOD_COL_NUM, IP4_METHOD_AUTO,
+ METHOD_COL_ENABLED, TRUE,
-1);
gtk_list_store_append (priv->method_store, &iter);
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, str_auto_only,
METHOD_COL_NUM, IP4_METHOD_AUTO_ADDRESSES,
+ METHOD_COL_ENABLED, TRUE,
-1);
/* Manual is pointless for Mobile Broadband */
@@ -160,6 +169,7 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Manual"),
METHOD_COL_NUM, IP4_METHOD_MANUAL,
+ METHOD_COL_ENABLED, TRUE,
-1);
}
@@ -172,12 +182,14 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Link-Local Only"),
METHOD_COL_NUM, IP4_METHOD_LINK_LOCAL,
+ METHOD_COL_ENABLED, TRUE,
-1);
gtk_list_store_append (priv->method_store, &iter);
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Shared to other computers"),
METHOD_COL_NUM, IP4_METHOD_SHARED,
+ METHOD_COL_ENABLED, TRUE,
-1);
}
@@ -187,6 +199,7 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Disabled"),
METHOD_COL_NUM, IP4_METHOD_DISABLED,
+ METHOD_COL_ENABLED, TRUE,
-1);
}
gtk_combo_box_set_model (priv->method, GTK_TREE_MODEL (priv->method_store));
@@ -1128,7 +1141,8 @@ finish_setup (CEPageIP4 *self, gpointer unused, GError *error, gpointer user_dat
}
CEPage *
-ce_page_ip4_new (NMConnection *connection,
+ce_page_ip4_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -1139,6 +1153,7 @@ ce_page_ip4_new (NMConnection *connection,
NMSettingConnection *s_con;
self = CE_PAGE_IP4 (ce_page_new (CE_TYPE_PAGE_IP4,
+ editor,
connection,
parent_window,
client,
@@ -1372,12 +1387,103 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
+static gboolean
+get_iter_for_method (GtkTreeModel *model, int column, GtkTreeIter *iter)
+{
+ int col;
+
+ if (gtk_tree_model_get_iter_first (model, iter)) {
+ do {
+ gtk_tree_model_get (model, iter, METHOD_COL_NUM, &col, -1);
+ if (col == column)
+ return TRUE;
+ } while (gtk_tree_model_iter_next (model, iter));
+ }
+ return FALSE;
+}
+
+static void
+toggle_method_sensitivity (CEPage *page, int column, gboolean sensitive)
+{
+ CEPageIP4 *self = CE_PAGE_IP4 (page);
+ CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->method_store);
+ GtkTreeIter iter;
+
+ if (get_iter_for_method (model, column, &iter))
+ gtk_list_store_set (priv->method_store, &iter, METHOD_COL_ENABLED, sensitive, -1);
+}
+
+static gboolean
+get_method_sensitivity (CEPage *page, int column)
+{
+ CEPageIP4 *self = CE_PAGE_IP4 (page);
+ CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->method_store);
+ GtkTreeIter iter;
+ gboolean sensitive = FALSE;
+
+ if (get_iter_for_method (model, column, &iter))
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->method_store), &iter, METHOD_COL_ENABLED, &sensitive, -1);
+ return sensitive;
+}
+
+static void
+change_method_combo (CEPage *page, gboolean is_hotspot)
+{
+ CEPageIP4 *self = CE_PAGE_IP4 (page);
+ CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+
+ /* Store previous active method */
+ if (get_method_sensitivity (page, IP4_METHOD_AUTO))
+ priv->normal_method_idx = gtk_combo_box_get_active (priv->method);
+ else
+ priv->hotspot_method_idx = gtk_combo_box_get_active (priv->method);
+
+ /* Set active method */
+ if (is_hotspot) {
+ if (priv->hotspot_method_idx == -1) {
+ int method = IP4_METHOD_SHARED;
+ if (g_strcmp0 (nm_setting_ip_config_get_method (priv->setting),
+ NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0)
+ method = IP4_METHOD_DISABLED;
+ gtk_combo_box_set_active (priv->method, method);
+ } else
+ gtk_combo_box_set_active (priv->method, priv->hotspot_method_idx);
+ } else {
+ if (priv->normal_method_idx != -1)
+ gtk_combo_box_set_active (priv->method, priv->normal_method_idx);
+ }
+
+ toggle_method_sensitivity (page, IP4_METHOD_AUTO, !is_hotspot);
+ toggle_method_sensitivity (page, IP4_METHOD_AUTO_ADDRESSES, !is_hotspot);
+ toggle_method_sensitivity (page, IP4_METHOD_MANUAL, !is_hotspot);
+ toggle_method_sensitivity (page, IP4_METHOD_LINK_LOCAL, !is_hotspot);
+}
+
+static gboolean
+inter_page_change (CEPage *page)
+{
+ gpointer wifi_mode_ap;
+
+ if (nm_connection_editor_inter_page_get_value (page->editor, INTER_PAGE_CHANGE_WIFI_MODE, &wifi_mode_ap)) {
+ /* For Wi-Fi AP mode restrict IPv4 methods to shared and disabled */
+ if (GPOINTER_TO_UINT (wifi_mode_ap))
+ change_method_combo (page, TRUE);
+ else
+ change_method_combo (page, FALSE);
+ }
+ return TRUE;
+}
+
static void
ce_page_ip4_init (CEPageIP4 *self)
{
CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
priv->last_column = -1;
+ priv->normal_method_idx = -1;
+ priv->hotspot_method_idx = -1;
}
static void
@@ -1408,5 +1514,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-ip4.h b/src/connection-editor/page-ip4.h
index e9886cf8..64903931 100644
--- a/src/connection-editor/page-ip4.h
+++ b/src/connection-editor/page-ip4.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_ip4_get_type (void);
-CEPage *ce_page_ip4_new (NMConnection *connection,
+CEPage *ce_page_ip4_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 439858ab..db95b03f 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -53,6 +53,8 @@ typedef struct {
GtkComboBox *method;
GtkListStore *method_store;
+ int normal_method_idx;
+ int hotspot_method_idx;
/* Addresses */
GtkWidget *addr_label;
@@ -141,7 +143,7 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
priv->method = GTK_COMBO_BOX (gtk_builder_get_object (builder, "ip6_method"));
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (priv->method));
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->method), cells->data,
- "sensitive", METHOD_COL_ENABLED);
+ "sensitive", METHOD_COL_ENABLED);
priv->method_store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_BOOLEAN);
@@ -149,21 +151,21 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Ignore"),
METHOD_COL_NUM, IP6_METHOD_IGNORE,
- METHOD_COL_ENABLED, TRUE,
+ METHOD_COL_ENABLED, TRUE,
-1);
gtk_list_store_append (priv->method_store, &iter);
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, str_auto,
METHOD_COL_NUM, IP6_METHOD_AUTO,
- METHOD_COL_ENABLED, TRUE,
+ METHOD_COL_ENABLED, TRUE,
-1);
gtk_list_store_append (priv->method_store, &iter);
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, str_auto_only,
METHOD_COL_NUM, IP6_METHOD_AUTO_ADDRESSES,
- METHOD_COL_ENABLED, TRUE,
+ METHOD_COL_ENABLED, TRUE,
-1);
/* DHCP only used on Wi-Fi and ethernet for now */
@@ -173,7 +175,7 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Automatic, DHCP only"),
METHOD_COL_NUM, IP6_METHOD_AUTO_DHCP_ONLY,
- METHOD_COL_ENABLED, TRUE,
+ METHOD_COL_ENABLED, TRUE,
-1);
}
@@ -185,7 +187,7 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Manual"),
METHOD_COL_NUM, IP6_METHOD_MANUAL,
- METHOD_COL_ENABLED, TRUE,
+ METHOD_COL_ENABLED, TRUE,
-1);
}
@@ -198,14 +200,14 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Link-Local Only"),
METHOD_COL_NUM, IP6_METHOD_LINK_LOCAL,
- METHOD_COL_ENABLED, TRUE,
+ METHOD_COL_ENABLED, TRUE,
-1);
gtk_list_store_append (priv->method_store, &iter);
gtk_list_store_set (priv->method_store, &iter,
METHOD_COL_NAME, _("Shared to other computers"),
METHOD_COL_NUM, IP6_METHOD_SHARED,
- METHOD_COL_ENABLED, FALSE,
+ METHOD_COL_ENABLED, FALSE,
-1);
}
@@ -1136,7 +1138,8 @@ finish_setup (CEPageIP6 *self, gpointer unused, GError *error, gpointer user_dat
}
CEPage *
-ce_page_ip6_new (NMConnection *connection,
+ce_page_ip6_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -1147,6 +1150,7 @@ ce_page_ip6_new (NMConnection *connection,
NMSettingConnection *s_con;
self = CE_PAGE_IP6 (ce_page_new (CE_TYPE_PAGE_IP6,
+ editor,
connection,
parent_window,
client,
@@ -1367,12 +1371,100 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
return nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
}
+static gboolean
+get_iter_for_method (GtkTreeModel *model, int column, GtkTreeIter *iter)
+{
+ int col;
+
+ if (gtk_tree_model_get_iter_first (model, iter)) {
+ do {
+ gtk_tree_model_get (model, iter, METHOD_COL_NUM, &col, -1);
+ if (col == column)
+ return TRUE;
+ } while (gtk_tree_model_iter_next (model, iter));
+ }
+ return FALSE;
+}
+
+static void
+toggle_method_sensitivity (CEPage *page, int column, gboolean sensitive)
+{
+ CEPageIP6 *self = CE_PAGE_IP6 (page);
+ CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->method_store);
+ GtkTreeIter iter;
+
+ if (get_iter_for_method (model, column, &iter))
+ gtk_list_store_set (priv->method_store, &iter, METHOD_COL_ENABLED, sensitive, -1);
+}
+
+static gboolean
+get_method_sensitivity (CEPage *page, int column)
+{
+ CEPageIP6 *self = CE_PAGE_IP6 (page);
+ CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self);
+ GtkTreeModel *model = GTK_TREE_MODEL (priv->method_store);
+ GtkTreeIter iter;
+ gboolean sensitive = FALSE;
+
+ if (get_iter_for_method (model, column, &iter))
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->method_store), &iter, METHOD_COL_ENABLED, &sensitive, -1);
+ return sensitive;
+}
+
+static void
+change_method_combo (CEPage *page, gboolean is_hotspot)
+{
+ CEPageIP6 *self = CE_PAGE_IP6 (page);
+ CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self);
+
+ /* Store previous active method */
+ if (get_method_sensitivity (page, IP6_METHOD_AUTO))
+ priv->normal_method_idx = gtk_combo_box_get_active (priv->method);
+ else
+ priv->hotspot_method_idx = gtk_combo_box_get_active (priv->method);
+
+ /* Set active method */
+ if (is_hotspot) {
+ if (priv->hotspot_method_idx != -1)
+ gtk_combo_box_set_active (priv->method, priv->hotspot_method_idx);
+ else
+ gtk_combo_box_set_active (priv->method, IP6_METHOD_IGNORE);
+ } else {
+ if (priv->normal_method_idx != -1)
+ gtk_combo_box_set_active (priv->method, priv->normal_method_idx);
+ }
+
+ toggle_method_sensitivity (page, IP6_METHOD_AUTO, !is_hotspot);
+ toggle_method_sensitivity (page, IP6_METHOD_AUTO_ADDRESSES, !is_hotspot);
+ toggle_method_sensitivity (page, IP6_METHOD_AUTO_DHCP_ONLY, !is_hotspot);
+ toggle_method_sensitivity (page, IP6_METHOD_MANUAL, !is_hotspot);
+ toggle_method_sensitivity (page, IP6_METHOD_LINK_LOCAL, !is_hotspot);
+}
+
+static gboolean
+inter_page_change (CEPage *page)
+{
+ gpointer wifi_mode_ap;
+
+ if (nm_connection_editor_inter_page_get_value (page->editor, INTER_PAGE_CHANGE_WIFI_MODE, &wifi_mode_ap)) {
+ /* For Wi-Fi AP mode restrict IPv6 methods to ignore */
+ if (GPOINTER_TO_UINT (wifi_mode_ap))
+ change_method_combo (page, TRUE);
+ else
+ change_method_combo (page, FALSE);
+ }
+ return TRUE;
+}
+
static void
ce_page_ip6_init (CEPageIP6 *self)
{
CEPageIP6Private *priv = CE_PAGE_IP6_GET_PRIVATE (self);
priv->last_column = -1;
+ priv->normal_method_idx = -1;
+ priv->hotspot_method_idx = -1;
}
static void
@@ -1403,5 +1495,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-ip6.h b/src/connection-editor/page-ip6.h
index defc23cb..4a671f4d 100644
--- a/src/connection-editor/page-ip6.h
+++ b/src/connection-editor/page-ip6.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_ip6_get_type (void);
-CEPage *ce_page_ip6_new (NMConnection *connection,
+CEPage *ce_page_ip6_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index 375b7173..671ece19 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -291,7 +291,8 @@ finish_setup (CEPageMobile *self, gpointer unused, GError *error, gpointer user_
}
CEPage *
-ce_page_mobile_new (NMConnection *connection,
+ce_page_mobile_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -301,6 +302,7 @@ ce_page_mobile_new (NMConnection *connection,
CEPageMobilePrivate *priv;
self = CE_PAGE_MOBILE (ce_page_new (CE_TYPE_PAGE_MOBILE,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-mobile.h b/src/connection-editor/page-mobile.h
index 914e8cdb..750c736d 100644
--- a/src/connection-editor/page-mobile.h
+++ b/src/connection-editor/page-mobile.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_mobile_get_type (void);
-CEPage *ce_page_mobile_new (NMConnection *connection,
+CEPage *ce_page_mobile_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-ppp.c b/src/connection-editor/page-ppp.c
index a6e28ee8..1a0363a7 100644
--- a/src/connection-editor/page-ppp.c
+++ b/src/connection-editor/page-ppp.c
@@ -262,7 +262,8 @@ finish_setup (CEPagePpp *self, gpointer unused, GError *error, gpointer user_dat
}
CEPage *
-ce_page_ppp_new (NMConnection *connection,
+ce_page_ppp_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -273,6 +274,7 @@ ce_page_ppp_new (NMConnection *connection,
NMSettingConnection *s_con;
self = CE_PAGE_PPP (ce_page_new (CE_TYPE_PAGE_PPP,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-ppp.h b/src/connection-editor/page-ppp.h
index b7315359..c8e92467 100644
--- a/src/connection-editor/page-ppp.h
+++ b/src/connection-editor/page-ppp.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_ppp_get_type (void);
-CEPage *ce_page_ppp_new (NMConnection *connection,
+CEPage *ce_page_ppp_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-team-port.c b/src/connection-editor/page-team-port.c
index ebf86e01..dbad57fe 100644
--- a/src/connection-editor/page-team-port.c
+++ b/src/connection-editor/page-team-port.c
@@ -131,7 +131,8 @@ finish_setup (CEPageTeamPort *self, gpointer unused, GError *error, gpointer use
}
CEPage *
-ce_page_team_port_new (NMConnection *connection,
+ce_page_team_port_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -141,6 +142,7 @@ ce_page_team_port_new (NMConnection *connection,
CEPageTeamPortPrivate *priv;
self = CE_PAGE_TEAM_PORT (ce_page_new (CE_TYPE_PAGE_TEAM_PORT,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-team-port.h b/src/connection-editor/page-team-port.h
index e086de40..62d24cdc 100644
--- a/src/connection-editor/page-team-port.h
+++ b/src/connection-editor/page-team-port.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_team_port_get_type (void);
-CEPage *ce_page_team_port_new (NMConnection *connection,
+CEPage *ce_page_team_port_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index 1ac337fb..2ddf4d15 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -249,16 +249,18 @@ finish_setup (CEPageTeam *self, gpointer unused, GError *error, gpointer user_da
}
CEPage *
-ce_page_team_new (NMConnection *connection,
- GtkWindow *parent_window,
- NMClient *client,
- const char **out_secrets_setting_name,
- GError **error)
+ce_page_team_new (NMConnectionEditor *editor,
+ NMConnection *connection,
+ GtkWindow *parent_window,
+ NMClient *client,
+ const char **out_secrets_setting_name,
+ GError **error)
{
CEPageTeam *self;
CEPageTeamPrivate *priv;
self = CE_PAGE_TEAM (ce_page_new (CE_TYPE_PAGE_TEAM,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-team.h b/src/connection-editor/page-team.h
index d3a5270a..68f5ff2a 100644
--- a/src/connection-editor/page-team.h
+++ b/src/connection-editor/page-team.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_team_get_type (void);
-CEPage *ce_page_team_new (NMConnection *connection,
+CEPage *ce_page_team_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c
index 5df091c4..ea2891c5 100644
--- a/src/connection-editor/page-vlan.c
+++ b/src/connection-editor/page-vlan.c
@@ -571,7 +571,8 @@ finish_setup (CEPageVlan *self, gpointer unused, GError *error, gpointer user_da
}
CEPage *
-ce_page_vlan_new (NMConnection *connection,
+ce_page_vlan_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -581,6 +582,7 @@ ce_page_vlan_new (NMConnection *connection,
CEPageVlanPrivate *priv;
self = CE_PAGE_VLAN (ce_page_new (CE_TYPE_PAGE_VLAN,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-vlan.h b/src/connection-editor/page-vlan.h
index 5a96e02f..f0f72380 100644
--- a/src/connection-editor/page-vlan.h
+++ b/src/connection-editor/page-vlan.h
@@ -43,7 +43,8 @@ typedef struct {
GType ce_page_vlan_get_type (void);
-CEPage *ce_page_vlan_new (NMConnection *connection,
+CEPage *ce_page_vlan_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 376a40a3..6e100f60 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -84,7 +84,8 @@ finish_setup (CEPageVpn *self, gpointer unused, GError *error, gpointer user_dat
}
CEPage *
-ce_page_vpn_new (NMConnection *connection,
+ce_page_vpn_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -95,6 +96,7 @@ ce_page_vpn_new (NMConnection *connection,
const char *service_type;
self = CE_PAGE_VPN (ce_page_new (CE_TYPE_PAGE_VPN,
+ editor,
connection,
parent_window,
client,
diff --git a/src/connection-editor/page-vpn.h b/src/connection-editor/page-vpn.h
index d9df6a14..62a4d9d0 100644
--- a/src/connection-editor/page-vpn.h
+++ b/src/connection-editor/page-vpn.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_vpn_get_type (void);
-CEPage *ce_page_vpn_new (NMConnection *connection,
+CEPage *ce_page_vpn_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-wifi-security.c b/src/connection-editor/page-wifi-security.c
index 67611a9e..b6fade01 100644
--- a/src/connection-editor/page-wifi-security.c
+++ b/src/connection-editor/page-wifi-security.c
@@ -39,12 +39,13 @@ G_DEFINE_TYPE (CEPageWifiSecurity, ce_page_wifi_security, CE_TYPE_PAGE)
typedef struct {
GtkSizeGroup *group;
GtkComboBox *security_combo;
- gboolean adhoc;
+ NM80211Mode mode;
} CEPageWifiSecurityPrivate;
#define S_NAME_COLUMN 0
#define S_SEC_COLUMN 1
#define S_ADHOC_VALID_COLUMN 2
+#define S_HOTSPOT_VALID_COLUMN 3
static gboolean
find_proto (NMSettingWirelessSecurity *sec, const char *item)
@@ -182,7 +183,8 @@ add_security_item (CEPageWifiSecurity *self,
GtkListStore *model,
GtkTreeIter *iter,
const char *text,
- gboolean adhoc_valid)
+ gboolean adhoc_valid,
+ gboolean hotspot_valid)
{
wireless_security_set_changed_notify (sec, stuff_changed_cb, self);
gtk_list_store_append (model, iter);
@@ -190,6 +192,7 @@ add_security_item (CEPageWifiSecurity *self,
S_NAME_COLUMN, text,
S_SEC_COLUMN, sec,
S_ADHOC_VALID_COLUMN, adhoc_valid,
+ S_HOTSPOT_VALID_COLUMN, hotspot_valid,
-1);
wireless_security_unref (sec);
}
@@ -201,16 +204,47 @@ set_sensitive (GtkCellLayout *cell_layout,
GtkTreeIter *iter,
gpointer data)
{
- gboolean *adhoc = data;
- gboolean sensitive = TRUE, adhoc_valid = TRUE;
+ NM80211Mode *mode = data;
+ gboolean sensitive = TRUE;
- gtk_tree_model_get (tree_model, iter, S_ADHOC_VALID_COLUMN, &adhoc_valid, -1);
- if (*adhoc && !adhoc_valid)
- sensitive = FALSE;
+ if (*mode == NM_802_11_MODE_ADHOC)
+ gtk_tree_model_get (tree_model, iter, S_ADHOC_VALID_COLUMN, &sensitive, -1);
+ else if (*mode == NM_802_11_MODE_AP)
+ gtk_tree_model_get (tree_model, iter, S_HOTSPOT_VALID_COLUMN, &sensitive, -1);
g_object_set (cell, "sensitive", sensitive, NULL);
}
+static gboolean
+security_valid (NMUtilsSecurityType sectype, NM80211Mode mode)
+{
+ guint32 dev_caps = 0;
+
+ /* Fake some device capabilities here since we don't know about the
+ * NMDevice object to get the card's real capabilities.
+ */
+ dev_caps = NM_WIFI_DEVICE_CAP_CIPHER_WEP40
+ | NM_WIFI_DEVICE_CAP_CIPHER_WEP104
+ | NM_WIFI_DEVICE_CAP_CIPHER_TKIP
+ | NM_WIFI_DEVICE_CAP_CIPHER_CCMP
+ | NM_WIFI_DEVICE_CAP_WPA
+ | NM_WIFI_DEVICE_CAP_RSN;
+
+ switch (mode) {
+ case NM_802_11_MODE_AP:
+ return nm_utils_ap_mode_security_valid (sectype, NM_WIFI_DEVICE_CAP_AP);
+ case NM_802_11_MODE_ADHOC:
+ case NM_802_11_MODE_INFRA:
+ default:
+ return nm_utils_security_valid (sectype,
+ dev_caps,
+ FALSE,
+ (mode == NM_802_11_MODE_ADHOC),
+ 0, 0, 0);
+ }
+ g_assert_not_reached ();
+}
+
static void
finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer user_data)
{
@@ -219,11 +253,9 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMConnection *connection = parent->connection;
- gboolean is_adhoc = FALSE;
+ NM80211Mode mode = NM_802_11_MODE_INFRA;
GtkListStore *sec_model;
GtkTreeIter iter;
- const char *mode;
- guint32 dev_caps = 0;
NMUtilsSecurityType default_type = NMU_SEC_NONE;
int active = -1;
int item = 0;
@@ -236,39 +268,31 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer
s_wireless = nm_connection_get_setting_wireless (connection);
g_assert (s_wireless);
- combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "wifi_security_combo"));
-
- dev_caps = NM_WIFI_DEVICE_CAP_CIPHER_WEP40
- | NM_WIFI_DEVICE_CAP_CIPHER_WEP104
- | NM_WIFI_DEVICE_CAP_CIPHER_TKIP
- | NM_WIFI_DEVICE_CAP_CIPHER_CCMP
- | NM_WIFI_DEVICE_CAP_WPA
- | NM_WIFI_DEVICE_CAP_RSN;
-
- mode = nm_setting_wireless_get_mode (s_wireless);
- if (mode && !strcmp (mode, "adhoc"))
- is_adhoc = TRUE;
- priv->adhoc = is_adhoc;
+ if (!g_strcmp0 (nm_setting_wireless_get_mode (s_wireless), "adhoc"))
+ mode = NM_802_11_MODE_ADHOC;
+ else if (!g_strcmp0 (nm_setting_wireless_get_mode (s_wireless), "ap"))
+ mode = NM_802_11_MODE_AP;
s_wireless_sec = nm_connection_get_setting_wireless_security (connection);
if (s_wireless_sec)
default_type = get_default_type_for_security (s_wireless_sec);
- sec_model = gtk_list_store_new (3, G_TYPE_STRING, wireless_security_get_type (), G_TYPE_BOOLEAN);
+ sec_model = gtk_list_store_new (4, G_TYPE_STRING, wireless_security_get_type (), G_TYPE_BOOLEAN, G_TYPE_BOOLEAN);
- if (nm_utils_security_valid (NMU_SEC_NONE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
+ if (security_valid (NMU_SEC_NONE, mode)) {
gtk_list_store_append (sec_model, &iter);
gtk_list_store_set (sec_model, &iter,
S_NAME_COLUMN, C_("Wi-Fi/Ethernet security", "None"),
S_ADHOC_VALID_COLUMN, TRUE,
+ S_HOTSPOT_VALID_COLUMN, TRUE,
-1);
if (default_type == NMU_SEC_NONE)
active = item;
item++;
}
- if (nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
+ if (security_valid (NMU_SEC_STATIC_WEP, mode)) {
WirelessSecurityWEPKey *ws_wep;
NMWepKeyType wep_type = NM_WEP_KEY_TYPE_KEY;
@@ -286,7 +310,7 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
&iter, _("WEP 40/128-bit Key (Hex or ASCII)"),
- TRUE);
+ TRUE, TRUE);
if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_KEY))
active = item;
item++;
@@ -295,74 +319,73 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer
ws_wep = ws_wep_key_new (connection, NM_WEP_KEY_TYPE_PASSPHRASE, FALSE, FALSE);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 128-bit Passphrase"), TRUE);
+ &iter, _("WEP 128-bit Passphrase"), TRUE, TRUE);
if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (wep_type == NM_WEP_KEY_TYPE_PASSPHRASE))
active = item;
item++;
}
}
- if (nm_utils_security_valid (NMU_SEC_LEAP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
+ if (security_valid (NMU_SEC_LEAP, mode)) {
WirelessSecurityLEAP *ws_leap;
ws_leap = ws_leap_new (connection, FALSE);
if (ws_leap) {
add_security_item (self, WIRELESS_SECURITY (ws_leap), sec_model,
- &iter, _("LEAP"), FALSE);
+ &iter, _("LEAP"), FALSE, FALSE);
if ((active < 0) && (default_type == NMU_SEC_LEAP))
active = item;
item++;
}
}
- if (nm_utils_security_valid (NMU_SEC_DYNAMIC_WEP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
+ if (security_valid (NMU_SEC_DYNAMIC_WEP, mode)) {
WirelessSecurityDynamicWEP *ws_dynamic_wep;
ws_dynamic_wep = ws_dynamic_wep_new (connection, TRUE, FALSE);
if (ws_dynamic_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_dynamic_wep), sec_model,
- &iter, _("Dynamic WEP (802.1x)"), FALSE);
+ &iter, _("Dynamic WEP (802.1x)"), FALSE, FALSE);
if ((active < 0) && (default_type == NMU_SEC_DYNAMIC_WEP))
active = item;
item++;
}
}
- if ( nm_utils_security_valid (NMU_SEC_WPA_PSK, dev_caps, FALSE, is_adhoc, 0, 0, 0)
- || nm_utils_security_valid (NMU_SEC_WPA2_PSK, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
+ if (security_valid (NMU_SEC_WPA_PSK, mode) || security_valid (NMU_SEC_WPA2_PSK, mode)) {
WirelessSecurityWPAPSK *ws_wpa_psk;
ws_wpa_psk = ws_wpa_psk_new (connection, FALSE);
if (ws_wpa_psk) {
add_security_item (self, WIRELESS_SECURITY (ws_wpa_psk), sec_model,
- &iter, _("WPA & WPA2 Personal"), FALSE);
+ &iter, _("WPA & WPA2 Personal"), FALSE, TRUE);
if ((active < 0) && ((default_type == NMU_SEC_WPA_PSK) || (default_type == NMU_SEC_WPA2_PSK)))
active = item;
item++;
}
}
- if ( nm_utils_security_valid (NMU_SEC_WPA_ENTERPRISE, dev_caps, FALSE, is_adhoc, 0, 0, 0)
- || nm_utils_security_valid (NMU_SEC_WPA2_ENTERPRISE, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
+ if (security_valid (NMU_SEC_WPA_ENTERPRISE, mode) || security_valid (NMU_SEC_WPA2_ENTERPRISE, mode)) {
WirelessSecurityWPAEAP *ws_wpa_eap;
ws_wpa_eap = ws_wpa_eap_new (connection, TRUE, FALSE);
if (ws_wpa_eap) {
add_security_item (self, WIRELESS_SECURITY (ws_wpa_eap), sec_model,
- &iter, _("WPA & WPA2 Enterprise"), FALSE);
+ &iter, _("WPA & WPA2 Enterprise"), FALSE, FALSE);
if ((active < 0) && ((default_type == NMU_SEC_WPA_ENTERPRISE) || (default_type == NMU_SEC_WPA2_ENTERPRISE)))
active = item;
item++;
}
}
+ combo = GTK_COMBO_BOX (gtk_builder_get_object (parent->builder, "wifi_security_combo"));
gtk_combo_box_set_model (combo, GTK_TREE_MODEL (sec_model));
gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo));
renderer = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", S_NAME_COLUMN, NULL);
- gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer, set_sensitive, &priv->adhoc, NULL);
+ gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer, set_sensitive, &priv->mode, NULL);
gtk_combo_box_set_active (combo, active < 0 ? 0 : (guint32) active);
g_object_unref (G_OBJECT (sec_model));
@@ -376,7 +399,8 @@ finish_setup (CEPageWifiSecurity *self, gpointer unused, GError *error, gpointer
}
CEPage *
-ce_page_wifi_security_new (NMConnection *connection,
+ce_page_wifi_security_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -394,6 +418,7 @@ ce_page_wifi_security_new (NMConnection *connection,
}
self = CE_PAGE_WIFI_SECURITY (ce_page_new (CE_TYPE_PAGE_WIFI_SECURITY,
+ editor,
connection,
parent_window,
client,
@@ -461,14 +486,16 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
g_assert (s_wireless);
/* Kernel Ad-Hoc WPA support is busted; it creates open networks. Disable
- * WPA when Ad-Hoc is selected. set_sensitive() will pick up priv->adhoc
+ * WPA when Ad-Hoc is selected. set_sensitive() will pick up priv->mode
* and do the right thing.
*/
mode = nm_setting_wireless_get_mode (s_wireless);
if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0)
- priv->adhoc = TRUE;
+ priv->mode = NM_802_11_MODE_ADHOC;
+ else if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_AP) == 0)
+ priv->mode = NM_802_11_MODE_AP;
else
- priv->adhoc = FALSE;
+ priv->mode = NM_802_11_MODE_INFRA;
sec = wireless_security_combo_get_active (self);
if (sec) {
@@ -483,7 +510,7 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
valid = FALSE;
}
- if (priv->adhoc) {
+ if (priv->mode == NM_802_11_MODE_ADHOC) {
if (!wireless_security_adhoc_compatible (sec)) {
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("Security not compatible with Ad-Hoc mode"));
valid = FALSE;
diff --git a/src/connection-editor/page-wifi-security.h b/src/connection-editor/page-wifi-security.h
index a4b2d489..1565cc1f 100644
--- a/src/connection-editor/page-wifi-security.h
+++ b/src/connection-editor/page-wifi-security.h
@@ -46,7 +46,8 @@ typedef struct {
GType ce_page_wifi_security_get_type (void);
-CEPage *ce_page_wifi_security_new (NMConnection *connection,
+CEPage *ce_page_wifi_security_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index b0455ff7..63367c61 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -28,6 +28,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include "nm-connection-editor.h"
#include "page-wifi.h"
G_DEFINE_TYPE (CEPageWifi, ce_page_wifi, CE_TYPE_PAGE)
@@ -242,51 +243,46 @@ mode_combo_changed_cb (GtkComboBox *combo,
CEPageWifiPrivate *priv = CE_PAGE_WIFI_GET_PRIVATE (self);
CEPage *parent = CE_PAGE (self);
GtkWidget *widget_band_label, *widget_chan_label, *widget_bssid_label;
- gboolean adhoc;
+ gboolean show_freq = FALSE;
+ gboolean show_bssid = TRUE;
+ gboolean hotspot = FALSE;
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo))) {
- case 1: /* adhoc */
- adhoc = TRUE;
+ 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
+ * For AP-mode, the BSSID is the MAC address of the device.
+ */
+ show_bssid = FALSE;
+ show_freq = TRUE;
break;
default: /* infrastructure */
- adhoc = FALSE;
+ 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"));
widget_bssid_label = GTK_WIDGET (gtk_builder_get_object (parent->builder, "wifi_bssid_label"));
- if (adhoc) {
- /* For Ad-Hoc show Band and Channel */
- gtk_widget_show (widget_band_label);
- gtk_widget_show (GTK_WIDGET (priv->band));
- gtk_widget_show (widget_chan_label);
- gtk_widget_show (GTK_WIDGET (priv->channel));
+ gtk_widget_set_visible (widget_band_label, show_freq);
+ gtk_widget_set_sensitive (widget_band_label, show_freq);
+ gtk_widget_set_visible (GTK_WIDGET (priv->band), show_freq);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->band), show_freq);
+ gtk_widget_set_visible (widget_chan_label, show_freq);
+ gtk_widget_set_sensitive (widget_chan_label, show_freq);
+ gtk_widget_set_visible (GTK_WIDGET (priv->channel), show_freq);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), show_freq);
- /* and hide BSSID
- * 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
- */
- gtk_widget_hide (widget_bssid_label);
- gtk_widget_hide (GTK_WIDGET (priv->bssid));
- } else {
- /* Do opposite for Infrastructure mode */
- gtk_widget_hide (widget_band_label);
- gtk_widget_hide (GTK_WIDGET (priv->band));
- gtk_widget_hide (widget_chan_label);
- gtk_widget_hide (GTK_WIDGET (priv->channel));
-
- gtk_widget_show (widget_bssid_label);
- gtk_widget_show (GTK_WIDGET (priv->bssid));
- }
-
- gtk_widget_set_sensitive (widget_band_label, adhoc);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->band), adhoc);
- gtk_widget_set_sensitive (widget_chan_label, adhoc);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), adhoc);
- gtk_widget_set_sensitive (widget_bssid_label, !adhoc);
- gtk_widget_set_sensitive (GTK_WIDGET (priv->bssid), !adhoc);
+ gtk_widget_set_visible (widget_bssid_label, show_bssid);
+ gtk_widget_set_sensitive (widget_bssid_label, show_bssid);
+ gtk_widget_set_visible (GTK_WIDGET (priv->bssid), show_bssid);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->bssid), show_bssid);
ce_page_changed (CE_PAGE (self));
}
@@ -342,8 +338,10 @@ populate_ui (CEPageWifi *self)
/* Default to Infrastructure */
gtk_combo_box_set_active (priv->mode, 0);
- if (mode && !strcmp (mode, "adhoc"))
+ if (!g_strcmp0 (mode, "ap"))
gtk_combo_box_set_active (priv->mode, 1);
+ if (!g_strcmp0 (mode, "adhoc"))
+ gtk_combo_box_set_active (priv->mode, 2);
mode_combo_changed_cb (priv->mode, self);
g_signal_connect (priv->mode, "changed", G_CALLBACK (mode_combo_changed_cb), self);
@@ -430,7 +428,8 @@ finish_setup (CEPageWifi *self, gpointer unused, GError *error, gpointer user_da
}
CEPage *
-ce_page_wifi_new (NMConnection *connection,
+ce_page_wifi_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent_window,
NMClient *client,
const char **out_secrets_setting_name,
@@ -442,6 +441,7 @@ ce_page_wifi_new (NMConnection *connection,
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
self = CE_PAGE_WIFI (ce_page_new (CE_TYPE_PAGE_WIFI,
+ editor,
connection,
parent_window,
client,
@@ -505,10 +505,17 @@ ui_to_setting (CEPageWifi *self)
ssid = ce_page_wifi_get_ssid (self);
- if (gtk_combo_box_get_active (priv->mode) == 1)
+ switch (gtk_combo_box_get_active (priv->mode)) {
+ case 1:
+ mode = "ap";
+ break;
+ case 2:
mode = "adhoc";
- else
+ break;
+ default:
mode = "infrastructure";
+ break;
+ }
switch (gtk_combo_box_get_active (priv->band)) {
case 1:
@@ -524,8 +531,8 @@ ui_to_setting (CEPageWifi *self)
}
entry = gtk_bin_get_child (GTK_BIN (priv->bssid));
- /* BSSID is only valid for infrastructure not for adhoc */
- if (entry && mode && strcmp (mode, "adhoc") != 0)
+ /* BSSID is only valid for infrastructure */
+ if (entry && mode && strcmp (mode, "infrastructure") == 0)
bssid = gtk_entry_get_text (GTK_ENTRY (entry));
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry)
diff --git a/src/connection-editor/page-wifi.h b/src/connection-editor/page-wifi.h
index c12c0290..d1f0d63e 100644
--- a/src/connection-editor/page-wifi.h
+++ b/src/connection-editor/page-wifi.h
@@ -45,7 +45,8 @@ typedef struct {
GType ce_page_wifi_get_type (void);
-CEPage *ce_page_wifi_new (NMConnection *connection,
+CEPage *ce_page_wifi_new (NMConnectionEditor *editor,
+ NMConnection *connection,
GtkWindow *parent,
NMClient *client,
const char **out_secrets_setting_name,
diff --git a/src/wireless-security/wireless-security.c b/src/wireless-security/wireless-security.c
index 8c4e798f..f769c371 100644
--- a/src/wireless-security/wireless-security.c
+++ b/src/wireless-security/wireless-security.c
@@ -193,6 +193,7 @@ wireless_security_init (gsize obj_size,
sec->destroy = destroy;
sec->adhoc_compatible = TRUE;
+ sec->hotspot_compatible = TRUE;
return sec;
}
@@ -205,6 +206,14 @@ wireless_security_adhoc_compatible (WirelessSecurity *sec)
return sec->adhoc_compatible;
}
+gboolean
+wireless_security_hotspot_compatible (WirelessSecurity *sec)
+{
+ g_return_val_if_fail (sec != NULL, FALSE);
+
+ return sec->hotspot_compatible;
+}
+
void
wireless_security_set_userpass (WirelessSecurity *sec,
const char *user,
diff --git a/src/wireless-security/wireless-security.h b/src/wireless-security/wireless-security.h
index 2cd845e4..e9bcf630 100644
--- a/src/wireless-security/wireless-security.h
+++ b/src/wireless-security/wireless-security.h
@@ -54,6 +54,7 @@ struct _WirelessSecurity {
gpointer changed_notify_data;
const char *default_field;
gboolean adhoc_compatible;
+ gboolean hotspot_compatible;
char *username, *password;
gboolean always_ask, show_password;
@@ -87,6 +88,8 @@ void wireless_security_update_secrets (WirelessSecurity *sec,
gboolean wireless_security_adhoc_compatible (WirelessSecurity *sec);
+gboolean wireless_security_hotspot_compatible (WirelessSecurity *sec);
+
void wireless_security_set_userpass (WirelessSecurity *sec,
const char *user,
const char *password,
diff --git a/src/wireless-security/ws-dynamic-wep.c b/src/wireless-security/ws-dynamic-wep.c
index a5431adc..3b083b76 100644
--- a/src/wireless-security/ws-dynamic-wep.c
+++ b/src/wireless-security/ws-dynamic-wep.c
@@ -115,6 +115,7 @@ ws_dynamic_wep_new (NMConnection *connection,
return NULL;
parent->adhoc_compatible = FALSE;
+ parent->hotspot_compatible = FALSE;
widget = ws_802_1x_auth_combo_init (parent,
"dynamic_wep_auth_combo",
diff --git a/src/wireless-security/ws-leap.c b/src/wireless-security/ws-leap.c
index b247e31b..a39558d7 100644
--- a/src/wireless-security/ws-leap.c
+++ b/src/wireless-security/ws-leap.c
@@ -165,6 +165,7 @@ ws_leap_new (NMConnection *connection, gboolean secrets_only)
}
parent->adhoc_compatible = FALSE;
+ parent->hotspot_compatible = FALSE;
sec = (WirelessSecurityLEAP *) parent;
sec->editing_connection = secrets_only ? FALSE : TRUE;
sec->password_flags_name = NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD;
diff --git a/src/wireless-security/ws-wpa-eap.c b/src/wireless-security/ws-wpa-eap.c
index 273479f3..d82112cb 100644
--- a/src/wireless-security/ws-wpa-eap.c
+++ b/src/wireless-security/ws-wpa-eap.c
@@ -116,6 +116,7 @@ ws_wpa_eap_new (NMConnection *connection,
return NULL;
parent->adhoc_compatible = FALSE;
+ parent->hotspot_compatible = FALSE;
widget = ws_802_1x_auth_combo_init (parent,
"wpa_eap_auth_combo",