summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2013-06-05 16:55:29 +0200
committerThomas Haller <thaller@redhat.com>2015-10-01 14:32:27 +0200
commitb379e7406f137acbb05e5a97ab8b4df8b2addaa1 (patch)
tree9989d4866ad4a413c990aca2f208acd3e2251ed8
parent234d191e32d49efc0ef6863434b5c4a08a068344 (diff)
downloadnetwork-manager-applet-jk/wifi-ap-mode-bgo755663-old.tar.gz
editor: add AP mode to Wi-Fi->Mode (rh #970752)jk/wifi-ap-mode-bgo755663-old
Otherwise, connection with mode=ap are reset to mode=infrastructure by the editor. Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
-rw-r--r--src/connection-editor/ce-page-wifi.ui3
-rw-r--r--src/connection-editor/page-wifi.c56
2 files changed, 40 insertions, 19 deletions
diff --git a/src/connection-editor/ce-page-wifi.ui b/src/connection-editor/ce-page-wifi.ui
index e2e544be..0c600d71 100644
--- a/src/connection-editor/ce-page-wifi.ui
+++ b/src/connection-editor/ce-page-wifi.ui
@@ -50,6 +50,9 @@
<row>
<col id="0" translatable="yes">Ad-hoc</col>
</row>
+ <row>
+ <col id="0" translatable="yes">AP</col>
+ </row>
</data>
</object>
<object class="GtkTable" id="WifiPage">
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index a1ff7671..bfcdc7d3 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -39,6 +39,10 @@ G_DEFINE_TYPE (CEPageWifi, ce_page_wifi, CE_TYPE_PAGE)
#define CE_PAGE_WIFI_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CE_TYPE_PAGE_WIFI, CEPageWifiPrivate))
+#define WIFI_MODE_INFRA NM_SETTING_WIRELESS_MODE_INFRA /* "infrastructure" */
+#define WIFI_MODE_ADHOC NM_SETTING_WIRELESS_MODE_ADHOC /* "adhoc" */
+#define WIFI_MODE_AP NM_SETTING_WIRELESS_MODE_AP /* "ap" */
+
typedef struct {
NMSettingWireless *setting;
@@ -244,14 +248,15 @@ 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 hotspot;
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (combo))) {
case 1: /* adhoc */
- adhoc = TRUE;
+ case 2: /* ap */
+ hotspot = TRUE;
break;
default: /* infrastructure */
- adhoc = FALSE;
+ hotspot = FALSE;
break;
}
@@ -259,8 +264,8 @@ mode_combo_changed_cb (GtkComboBox *combo,
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 */
+ if (hotspot) {
+ /* For Ad-Hoc and AP show Band and Channel */
gtk_widget_show (widget_band_label);
gtk_widget_show (GTK_WIDGET (priv->band));
gtk_widget_show (widget_chan_label);
@@ -269,6 +274,9 @@ mode_combo_changed_cb (GtkComboBox *combo,
/* 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
+ *
+ * BSSID is set to MAC address of the Wi-Fi device that activates
+ * the connection by NetworkManager.
*/
gtk_widget_hide (widget_bssid_label);
gtk_widget_hide (GTK_WIDGET (priv->bssid));
@@ -283,12 +291,12 @@ mode_combo_changed_cb (GtkComboBox *combo,
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_sensitive (widget_band_label, hotspot);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->band), hotspot);
+ gtk_widget_set_sensitive (widget_chan_label, hotspot);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), hotspot);
+ gtk_widget_set_sensitive (widget_bssid_label, !hotspot);
+ gtk_widget_set_sensitive (GTK_WIDGET (priv->bssid), !hotspot);
ce_page_changed (CE_PAGE (self));
}
@@ -349,8 +357,10 @@ populate_ui (CEPageWifi *self)
/* Default to Infrastructure */
gtk_combo_box_set_active (priv->mode, 0);
- if (mode && !strcmp (mode, "adhoc"))
+ if (mode && !strcmp (mode, WIFI_MODE_ADHOC))
gtk_combo_box_set_active (priv->mode, 1);
+ if (mode && !strcmp (mode, WIFI_MODE_AP))
+ 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);
g_free (mode);
@@ -516,10 +526,18 @@ ui_to_setting (CEPageWifi *self)
ssid = ce_page_wifi_get_ssid (self);
- if (gtk_combo_box_get_active (priv->mode) == 1)
- mode = "adhoc";
- else
- mode = "infrastructure";
+ switch (gtk_combo_box_get_active (priv->mode)) {
+ case 1:
+ mode = WIFI_MODE_ADHOC;
+ break;
+ case 2:
+ mode = WIFI_MODE_AP;
+ break;
+ case 0:
+ default:
+ mode = WIFI_MODE_INFRA;
+ break;
+ }
switch (gtk_combo_box_get_active (priv->band)) {
case 1:
@@ -535,8 +553,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, not for adhoc or ap */
+ if (entry && mode && strcmp (mode, WIFI_MODE_INFRA) == 0)
bssid = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, NULL);
entry = gtk_bin_get_child (GTK_BIN (priv->device_mac));
if (entry)
@@ -648,7 +666,7 @@ wifi_connection_new (GtkWindow *parent,
settings,
user_data);
s_wifi = nm_setting_wireless_new ();
- g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
+ g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, WIFI_MODE_INFRA, NULL);
nm_connection_add_setting (connection, s_wifi);
(*result_func) (connection, FALSE, NULL, user_data);