Merge lp:~donadigo/switchboard-plug-networking/hotspot into lp:~elementary-pantheon/switchboard-plug-networking/trunk

Proposed by Adam Bieńkowski
Status: Rejected
Rejected by: xapantu
Proposed branch: lp:~donadigo/switchboard-plug-networking/hotspot
Merge into: lp:~elementary-pantheon/switchboard-plug-networking/trunk
Diff against target: 1620 lines (+973/-174)
18 files modified
src/CMakeLists.txt (+2/-0)
src/Plug.vala (+2/-3)
src/Settings/ProxySettings.vala (+22/-0)
src/Utils.vala (+259/-78)
src/Widgets/Device/DeviceItem.vala (+31/-13)
src/Widgets/Device/DevicePage.vala (+4/-4)
src/Widgets/DeviceList.vala (+85/-37)
src/Widgets/Footer.vala (+2/-2)
src/Widgets/Hotspot/HotspotDialog.vala (+230/-0)
src/Widgets/Hotspot/HotspotPage.vala (+174/-0)
src/Widgets/InfoBox.vala (+2/-2)
src/Widgets/InfoScreen.vala (+2/-2)
src/Widgets/Page.vala (+1/-1)
src/Widgets/Proxy/ProxyConfigurationPage.vala (+22/-1)
src/Widgets/Proxy/ProxyExceptionsPage.vala (+22/-0)
src/Widgets/Proxy/ProxyPage.vala (+40/-1)
src/Widgets/WifiInterface.vala (+53/-25)
src/common/Widgets/AbstractWifiInterface.vala (+20/-5)
To merge this branch: bzr merge lp:~donadigo/switchboard-plug-networking/hotspot
Reviewer Review Type Date Requested Status
xapantu (community) Needs Information
Danielle Foré ux Approve
Review via email: mp+276926@code.launchpad.net

Commit message

* Added new Hotspot Mode functionality.
* Code refactor.
* Code cleanup.
* Relay only on the children of the ListBox not on "items" variable.
* Sort items instead of hardcoding them.
* Set headers based on the ItemType.
* Update links and licenses.

Description of the change

This branch introduces new Hotspot Mode functionality. Hotspot item will show in the sidebar only if the Wifi device is not in unmanaged, unknown or unavaliable mode. I also kept the common folder without changes affecting indicator-network.

Every change is described in the commit message.

To post a comment you must log in.
176. By Adam Bieńkowski

Fix not creating InfoBox from argument

177. By Adam Bieńkowski

Remove one line

178. By Adam Bieńkowski

Add licenses

179. By Adam Bieńkowski

Update links and licenses

Revision history for this message
Cody Garver (codygarver) wrote :

Your email address is missing the closing ">"

Revision history for this message
Adam Bieńkowski (donadigo) wrote :

Ahh, good catch, thanks ;)

Revision history for this message
Danielle Foré (danrabbit) wrote :

Hm, I think while you are using Wireless to create a Hotspot that the Wireless connection should show as "disabled" instead of "connected". While it's true that we are using this device and the device itself is not disabled, we are using it for the purpose of creating a hotspot so the ability to use it to connect to another wireless network is, in effect, "disabled".

180. By Adam Bieńkowski

Rebuild UI of WifiInterface; added missing > in licenses; show disconnected when in hotspot mode

181. By Adam Bieńkowski

Don't use CssProvider

Revision history for this message
Danielle Foré (danrabbit) wrote :

Hey right on. Like the alert messaging when it's in hotspot mode. Looks good :)

review: Approve (ux)
Revision history for this message
xapantu (xapantu) wrote :

Why is Utils a class in src/Utils.vala ?

review: Needs Information
Revision history for this message
xapantu (xapantu) wrote :

Superseded by the other hotspot branch.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2015-08-01 23:06:00 +0000
+++ src/CMakeLists.txt 2015-11-07 23:35:34 +0000
@@ -27,6 +27,8 @@
27 Widgets/InfoBox.vala27 Widgets/InfoBox.vala
28 Widgets/Footer.vala28 Widgets/Footer.vala
29 Widgets/InfoScreen.vala29 Widgets/InfoScreen.vala
30 Widgets/Hotspot/HotspotDialog.vala
31 Widgets/Hotspot/HotspotPage.vala
30 common/Utils.vala32 common/Utils.vala
31 common/Widgets/WifiMenuItem.vala33 common/Widgets/WifiMenuItem.vala
32 common/Widgets/AbstractWifiInterface.vala34 common/Widgets/AbstractWifiInterface.vala
3335
=== modified file 'src/Plug.vala'
--- src/Plug.vala 2015-10-30 20:42:55 +0000
+++ src/Plug.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,7 +17,7 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23/* Main client instance */23/* Main client instance */
@@ -64,7 +64,6 @@
64 }64 }
6565
66 content.remove (widget_interface);66 content.remove (widget_interface);
67
68 show_all ();67 show_all ();
69 }68 }
7069
7170
=== modified file 'src/Settings/ProxySettings.vala'
--- src/Settings/ProxySettings.vala 2015-10-09 19:12:42 +0000
+++ src/Settings/ProxySettings.vala 2015-11-07 23:35:34 +0000
@@ -1,3 +1,25 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */
22
1namespace Network {23namespace Network {
2 public class ProxySettings : Granite.Services.Settings {24 public class ProxySettings : Granite.Services.Settings {
3 public string autoconfig_url { get; set; }25 public string autoconfig_url { get; set; }
426
=== modified file 'src/Utils.vala'
--- src/Utils.vala 2015-10-22 16:46:13 +0000
+++ src/Utils.vala 2015-11-07 23:35:34 +0000
@@ -1,81 +1,262 @@
1namespace Network.Utils {1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2 public enum ItemType {2/*-
3 DEVICE = 0,3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 PROXY,4 *
5 INVALID5 * This library is free software; you can redistribute it and/or
6 }6 * modify it under the terms of the GNU Library General Public
77 * License as published by the Free Software Foundation; either
8 public Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) {8 * version 3 of the License, or (at your option) any later version.
9 var details_btn = new Gtk.Button.with_label (title);9 *
10 details_btn.clicked.connect (() => {10 * This library is distributed in the hope that it will be useful,
11 new Granite.Services.SimpleCommand ("/usr/bin",11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run ();12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 }); 13 * Library General Public License for more details.
1414 *
15 return details_btn;15 * You should have received a copy of the GNU Library General Public
16 }16 * License along with this library; if not, write to the
17 17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 public string state_to_string (NM.DeviceState state) {18 * Boston, MA 02111-1307, USA.
19 switch (state) {19 *
20 case NM.DeviceState.ACTIVATED:20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 return _("Connected");21 */
22 case NM.DeviceState.DISCONNECTED:22
23 return _("Disconnected"); 23namespace Network {
24 case NM.DeviceState.UNMANAGED:24 public class Utils {
25 return _("Unmanaged");25 public class Hotspot {
26 case NM.DeviceState.PREPARE:26 public delegate void UpdateSecretCallback ();
27 return _("In preparation");27
28 case NM.DeviceState.CONFIG:28 public static void activate_hotspot (NM.DeviceWifi wifi_device,
29 return _("Connecting...");29 ByteArray ssid,
30 case NM.DeviceState.NEED_AUTH:30 string key,
31 return _("Requires more information");31 NM.Connection? selected) {
32 case NM.DeviceState.IP_CONFIG:32 if (selected != null) {
33 return _("Requesting adresses...");33 client.activate_connection (selected, wifi_device, null, null);
34 case NM.DeviceState.IP_CHECK:34 return;
35 return _("Checking connection...");35 }
36 case NM.DeviceState.SECONDARIES:36
37 return _("Waiting for connection...");37 var hotspot_c = new NM.Connection ();
38 case NM.DeviceState.DEACTIVATING:38
39 return _("Disconnecting...");39 var setting_connection = new NM.SettingConnection ();
40 case NM.DeviceState.FAILED:40 setting_connection.@set (NM.SettingConnection.TYPE, "802-11-wireless");
41 return _("Failed to connect");41 setting_connection.@set (NM.SettingConnection.ID, "Hotspot");
42 case NM.DeviceState.UNKNOWN:42 setting_connection.autoconnect = false;
43 default:43 hotspot_c.add_setting (setting_connection);
44 return _("Unknown");44
45 }45 var setting_wireless = new NM.SettingWireless ();
46 }46
4747 string? mode = null;
48 public string type_to_string (NM.DeviceType type) {48 var caps = wifi_device.get_capabilities ();
49 switch (type) {49 if ((caps & NM.DeviceWifiCapabilities.AP) != 0) {
50 case NM.DeviceType.ETHERNET:50 mode = NM.SettingWireless.MODE_AP;
51 return _("Ethernet");51 } else {
52 case NM.DeviceType.WIFI:52 mode = NM.SettingWireless.MODE_ADHOC;
53 return _("Wi-Fi"); 53 }
54 case NM.DeviceType.UNUSED1:54
55 return _("Not used");55 setting_wireless.mode = mode;
56 case NM.DeviceType.UNUSED2:56 setting_wireless.security = "802-11-wireless-security";
57 return _("Not used");57
58 case NM.DeviceType.BT:58 hotspot_c.add_setting (setting_wireless);
59 return _("Bluetooth");59
60 case NM.DeviceType.OLPC_MESH:60 var ip4_setting = new NM.SettingIP4Config ();
61 return _("OLPC XO");61 ip4_setting.method = "shared";
62 case NM.DeviceType.WIMAX:62 hotspot_c.add_setting (ip4_setting);
63 return _("WiMAX Broadband");63
64 case NM.DeviceType.MODEM:64 setting_wireless.@set (NM.SettingWireless.SSID, ssid);
65 return _("Modem");65
66 case NM.DeviceType.INFINIBAND:66 var setting_wireless_security = new NM.SettingWirelessSecurity ();
67 return _("InfiniBand device");67
68 case NM.DeviceType.BOND:68 if (mode == NM.SettingWireless.MODE_AP) {
69 return _("Bond master");69 if ((caps & NM.DeviceWifiCapabilities.RSN) != 0) {
70 case NM.DeviceType.VLAN:70 set_wpa_key (setting_wireless_security, key);
71 return _("VLAN Interface");71 setting_wireless_security.add_proto ("rsn");
72 case NM.DeviceType.ADSL:72 setting_wireless_security.add_pairwise ("ccmp");
73 return _("ADSL Modem");73 setting_wireless_security.add_group ("ccmp");
74 case NM.DeviceType.BRIDGE:74 } else if ((caps & NM.DeviceWifiCapabilities.WPA) != 0) {
75 return _("Bridge master");75 set_wpa_key (setting_wireless_security, key);
76 case NM.DeviceType.UNKNOWN:76 setting_wireless_security.add_proto ("wpa");
77 default:77 setting_wireless_security.add_pairwise ("tkip");
78 return _("Unknown");78 setting_wireless_security.add_group ("tkip");
79 } else {
80 set_wep_key (setting_wireless_security, key);
81 }
82 } else {
83 set_wep_key (setting_wireless_security, key);
84 }
85
86 hotspot_c.add_setting (setting_wireless_security);
87 client.add_and_activate_connection (hotspot_c,
88 wifi_device,
89 null,
90 finish_connection_cb);
91 }
92
93 public static void update_secrets (NM.RemoteConnection connection, UpdateSecretCallback callback) {
94 connection.get_secrets (connection.get_setting_wireless ().get_security (), ((_connection, secrets, error) => {
95 var setting_wireless = _connection.get_setting_wireless ();
96 try {
97 _connection.update_secrets (setting_wireless.get_security (), secrets);
98 } catch (Error e) {
99 warning ("%s\n", e.message);
100 return;
101 }
102
103 callback ();
104 }));
105 }
106
107 public static void deactivate_hotspot (NM.DeviceWifi wifi_device) {
108 client.get_active_connections ().@foreach ((active_connection) => {
109 var devices = active_connection.get_devices ();
110 if (devices != null && devices.@get (0) == wifi_device) {
111 client.deactivate_connection (active_connection);
112 }
113 });
114 }
115
116 private static void set_wpa_key (NM.SettingWirelessSecurity setting, string key) {
117 setting.key_mgmt = "wpa-psk";
118 setting.psk = key;
119 }
120
121 private static void set_wep_key (NM.SettingWirelessSecurity setting, string key) {
122 setting.key_mgmt = "none";
123 setting.wep_key0 = key;
124 setting.wep_key_type = NM.WepKeyType.PASSPHRASE;
125 }
126
127 public static bool get_device_is_hotspot (NM.DeviceWifi wifi_device, NM.RemoteSettings nm_settings) {
128 if (wifi_device.get_active_connection () != null) {
129 var connection = nm_settings.get_connection_by_path (wifi_device.get_active_connection ().get_connection ());
130 if (connection != null) {
131 var ip4_setting = connection.get_setting_ip4_config ();
132 return (ip4_setting != null && ip4_setting.get_method () == "shared");
133 }
134 }
135
136 return false;
137 }
138
139 public static bool get_connection_is_hotspot (NM.Connection connection) {
140 var setting_connection = connection.get_setting_connection ();
141 if (setting_connection.get_connection_type () != "802-11-wireless") {
142 return false;
143 }
144
145 var setting_wireless = connection.get_setting_wireless ();
146 if (setting_wireless.get_mode () != "adhoc"
147 && setting_wireless.get_mode () != "ap") {
148 return false;
149 }
150
151 if (setting_wireless.get_security () != "802-11-wireless-security") {
152 return false;
153 }
154
155 var ip4_config = connection.get_setting_ip4_config ();
156 if (ip4_config.get_method () != "shared") {
157 return false;
158 }
159
160 return true;
161 }
162
163 private static void finish_connection_cb (NM.Client? cb_client,
164 NM.ActiveConnection? cb_connection,
165 string? new_connection_path,
166 Error? error) {
167 if (error != null && error.code != 0) {
168 warning ("%s\n", error.message);
169 }
170 }
171 }
172
173 public enum CustomMode {
174 PROXY_NONE = 0,
175 PROXY_MANUAL,
176 PROXY_AUTO,
177 HOTSPOT_ENABLED,
178 HOTSPOT_DISABLED,
179 INVALID
180 }
181
182 public enum ItemType {
183 DEVICE = 0,
184 VIRTUAL,
185 INVALID
186 }
187
188 public static Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) {
189 var details_btn = new Gtk.Button.with_label (title);
190 details_btn.clicked.connect (() => {
191 new Granite.Services.SimpleCommand ("/usr/bin",
192 "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run ();
193 });
194
195 return details_btn;
196 }
197
198 public static string state_to_string (NM.DeviceState state) {
199 switch (state) {
200 case NM.DeviceState.ACTIVATED:
201 return _("Connected");
202 case NM.DeviceState.DISCONNECTED:
203 return _("Disconnected");
204 case NM.DeviceState.UNMANAGED:
205 return _("Unmanaged");
206 case NM.DeviceState.PREPARE:
207 return _("In preparation");
208 case NM.DeviceState.CONFIG:
209 return _("Connecting...");
210 case NM.DeviceState.NEED_AUTH:
211 return _("Requires more information");
212 case NM.DeviceState.IP_CONFIG:
213 return _("Requesting adresses...");
214 case NM.DeviceState.IP_CHECK:
215 return _("Checking connection...");
216 case NM.DeviceState.SECONDARIES:
217 return _("Waiting for connection...");
218 case NM.DeviceState.DEACTIVATING:
219 return _("Disconnecting...");
220 case NM.DeviceState.FAILED:
221 return _("Failed to connect");
222 case NM.DeviceState.UNKNOWN:
223 default:
224 return _("Unknown");
225 }
226 }
227
228 public static string type_to_string (NM.DeviceType type) {
229 switch (type) {
230 case NM.DeviceType.ETHERNET:
231 return _("Ethernet");
232 case NM.DeviceType.WIFI:
233 return _("Wi-Fi");
234 case NM.DeviceType.UNUSED1:
235 return _("Not used");
236 case NM.DeviceType.UNUSED2:
237 return _("Not used");
238 case NM.DeviceType.BT:
239 return _("Bluetooth");
240 case NM.DeviceType.OLPC_MESH:
241 return _("OLPC XO");
242 case NM.DeviceType.WIMAX:
243 return _("WiMAX Broadband");
244 case NM.DeviceType.MODEM:
245 return _("Modem");
246 case NM.DeviceType.INFINIBAND:
247 return _("InfiniBand device");
248 case NM.DeviceType.BOND:
249 return _("Bond master");
250 case NM.DeviceType.VLAN:
251 return _("VLAN Interface");
252 case NM.DeviceType.ADSL:
253 return _("ADSL Modem");
254 case NM.DeviceType.BRIDGE:
255 return _("Bridge master");
256 case NM.DeviceType.UNKNOWN:
257 default:
258 return _("Unknown");
259 }
79 }260 }
80 }261 }
81}262}
82263
=== modified file 'src/Widgets/Device/DeviceItem.vala'
--- src/Widgets/Device/DeviceItem.vala 2015-10-20 20:34:36 +0000
+++ src/Widgets/Device/DeviceItem.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,12 +17,13 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23namespace Network.Widgets {23namespace Network.Widgets {
24 public class DeviceItem : Gtk.ListBoxRow {24 public class DeviceItem : Gtk.ListBoxRow {
25 public NM.Device? device = null;25 public NM.Device? device = null;
26 private NM.RemoteSettings? nm_settings = null;
26 public Gtk.Box? page = null;27 public Gtk.Box? page = null;
27 public Utils.ItemType type;28 public Utils.ItemType type;
2829
@@ -30,7 +31,7 @@
30 private Gtk.Image row_image;31 private Gtk.Image row_image;
31 private Gtk.Image status_image;32 private Gtk.Image status_image;
3233
33 private string title;34 public string title;
34 private string subtitle;35 private string subtitle;
35 private string icon_name;36 private string icon_name;
3637
@@ -63,10 +64,15 @@
63 this.icon_name = _icon_name;64 this.icon_name = _icon_name;
6465
65 create_ui (icon_name);66 create_ui (icon_name);
66 switch_status (device.get_state ());67 switch_status (Utils.CustomMode.INVALID, device.get_state ());
6768
68 device.state_changed.connect ( () => {69 nm_settings = new NM.RemoteSettings (null);
69 switch_status (device.get_state ());70 nm_settings.connections_read.connect (() => {
71 switch_status (Utils.CustomMode.INVALID, device.get_state ());
72 });
73
74 device.state_changed.connect (() => {
75 switch_status (Utils.CustomMode.INVALID, device.get_state ());
70 });76 });
71 }77 }
7278
@@ -120,8 +126,15 @@
120 return icon_name;126 return icon_name;
121 }127 }
122128
123 public void switch_status (NM.DeviceState? state = null, string proxy_mode = "") {129 public void switch_status (Utils.CustomMode custom_mode, NM.DeviceState? state = null) {
124 if (state != null) {130 if (state != null) {
131 if (device != null
132 && nm_settings != null
133 && device is NM.DeviceWifi
134 && Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)) {
135 state = NM.DeviceState.DISCONNECTED;
136 }
137
125 switch (state) {138 switch (state) {
126 case NM.DeviceState.ACTIVATED:139 case NM.DeviceState.ACTIVATED:
127 status_image.icon_name = "user-available";140 status_image.icon_name = "user-available";
@@ -148,20 +161,25 @@
148 row_description.label = Utils.state_to_string (state);161 row_description.label = Utils.state_to_string (state);
149 }162 }
150163
151 if (proxy_mode != "") {164 if (custom_mode != Utils.CustomMode.INVALID) {
152 switch (proxy_mode) {165 switch (custom_mode) {
153 case "none":166 case Utils.CustomMode.PROXY_NONE:
167 case Utils.CustomMode.HOTSPOT_DISABLED:
154 row_description.label = _("Disabled");168 row_description.label = _("Disabled");
155 status_image.icon_name = "user-offline";169 status_image.icon_name = "user-offline";
156 break;170 break;
157 case "manual":171 case Utils.CustomMode.PROXY_MANUAL:
158 row_description.label = _("Enabled (manual mode)");172 row_description.label = _("Enabled (manual mode)");
159 status_image.icon_name = "user-available";173 status_image.icon_name = "user-available";
160 break;174 break;
161 case "auto":175 case Utils.CustomMode.PROXY_AUTO:
162 row_description.label = _("Enabled (auto mode)");176 row_description.label = _("Enabled (auto mode)");
163 status_image.icon_name = "user-available";177 status_image.icon_name = "user-available";
164 break;178 break;
179 case Utils.CustomMode.HOTSPOT_ENABLED:
180 row_description.label = _("Enabled");
181 status_image.icon_name = "user-available";
182 break;
165 }183 }
166 }184 }
167185
168186
=== modified file 'src/Widgets/Device/DevicePage.vala'
--- src/Widgets/Device/DevicePage.vala 2015-10-08 19:04:34 +0000
+++ src/Widgets/Device/DevicePage.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,14 +17,14 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23namespace Network.Widgets {23namespace Network.Widgets {
24 public class DevicePage : Network.WidgetNMInterface {24 public class DevicePage : Network.WidgetNMInterface {
2525
26 public DevicePage (NM.Client client, NM.RemoteSettings settings, NM.Device device) {26 public DevicePage (NM.Client client, NM.RemoteSettings settings, NM.Device device) {
27 info_box = new info_box.from_device (device);27 info_box = new InfoBox.from_device (device);
28 this.init (device, info_box);28 this.init (device, info_box);
2929
30 bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE;30 bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE;
@@ -45,7 +45,7 @@
45 }45 }
4646
47 public DevicePage.from_owner (DeviceItem? owner) {47 public DevicePage.from_owner (DeviceItem? owner) {
48 info_box = new info_box.from_owner (owner);48 info_box = new InfoBox.from_owner (owner);
49 this.init (owner.get_item_device (), info_box);49 this.init (owner.get_item_device (), info_box);
5050
51 this.icon_name = owner.get_item_icon_name ();51 this.icon_name = owner.get_item_icon_name ();
5252
=== modified file 'src/Widgets/DeviceList.vala'
--- src/Widgets/DeviceList.vala 2015-10-22 17:08:56 +0000
+++ src/Widgets/DeviceList.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,59 +17,54 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23namespace Network.Widgets {23namespace Network.Widgets {
24 public class DeviceList : Gtk.ListBox {24 public class DeviceList : Gtk.ListBox {
25 public signal void show_no_devices (bool show);25 public signal void show_no_devices (bool show);
26 26
27 public NM.Client client;27 private Gtk.Label virtual_l;
28
29 private List<DeviceItem> items;
30 private DeviceItem item;
31
32 private Gtk.Label settings_l;
33 private Gtk.Label devices_l;28 private Gtk.Label devices_l;
34 private DeviceItem proxy;29 private DeviceItem proxy;
3530
36 private int wireless_item = 0;31 private int wireless_item = 0;
3732
38 public DeviceList () {33 public DeviceList () {
34 virtual_l = new Gtk.Label (_("Virtual"));
35 virtual_l.get_style_context ().add_class ("h4");
36 virtual_l.halign = Gtk.Align.START;
37
38 devices_l = new Gtk.Label (_("Devices"));
39 devices_l.get_style_context ().add_class ("h4");
40 devices_l.halign = Gtk.Align.START;
41
39 this.selection_mode = Gtk.SelectionMode.SINGLE;42 this.selection_mode = Gtk.SelectionMode.SINGLE;
40 this.activate_on_single_click = true; 43 this.activate_on_single_click = true;
41 this.set_header_func (update_headers);44 this.set_header_func (update_headers);
4245 this.set_sort_func (sort_items);
43 items = new List<DeviceItem> ();46
4447 bool show = (get_children ().length () > 0);
45 settings_l = new Gtk.Label (_("Virtual"));
46 settings_l.get_style_context ().add_class ("h4");
47 settings_l.halign = Gtk.Align.START;
48
49 devices_l = new Gtk.Label (_("Devices"));
50 devices_l.get_style_context ().add_class ("h4");
51 devices_l.halign = Gtk.Align.START;
52
53 bool show = (items.length () > 0);
54 this.show_no_devices (!show);48 this.show_no_devices (!show);
55 this.add_proxy ();49 this.add_proxy ();
56 }50 }
5751
58 public void add_device_to_list (WidgetNMInterface iface) {52 public void add_device_to_list (WidgetNMInterface iface) {
53 DeviceItem item;
54 if (!iface.device.get_managed ()) {
55 warning ("Unmanaged device, probably something that has just been added.");
56 }
57
59 if (iface.device.get_device_type () == NM.DeviceType.WIFI) {58 if (iface.device.get_device_type () == NM.DeviceType.WIFI) {
60 string title = _("Wireless");59 string title = _("Wireless");
61 if (wireless_item > 0) {60 if (wireless_item > 0) {
62 title += SUFFIX + wireless_item.to_string ();61 title = _("Wireless %s".printf (wireless_item.to_string ()));
63 }62 }
6463
65 item = new DeviceItem.from_interface (iface, "network-wireless", title);64 item = new DeviceItem.from_interface (iface, "network-wireless", title);
65 add_hotspot (iface, wireless_item);
66 wireless_item++;66 wireless_item++;
67 } else {67 } else {
68
69 if (!iface.device.get_managed ()) {
70 warning ("Unmanaged device, probably something that has just been added.");
71 }
72
73 if (iface.device.get_iface ().has_prefix ("usb")) {68 if (iface.device.get_iface ().has_prefix ("usb")) {
74 item = new DeviceItem.from_interface (iface, "drive-removable-media");69 item = new DeviceItem.from_interface (iface, "drive-removable-media");
75 } else {70 } else {
@@ -77,16 +72,15 @@
77 }72 }
78 }73 }
7974
80 items.append (item);75 add (item);
81 insert (item, (int) items.length () - 1);
82 show_all ();76 show_all ();
83 }77 }
8478
85 public void remove_device_from_list (NM.Device device) {79 public void remove_device_from_list (NM.Device device) {
86 foreach (var list_item in items) {80 foreach (Gtk.Widget _list_item in get_children ()) {
81 var list_item = (DeviceItem)_list_item;
87 if (list_item.device == device) {82 if (list_item.device == device) {
88 remove_row_from_list (list_item);83 remove_row_from_list (list_item);
89 break;
90 }84 }
91 }85 }
92 }86 }
@@ -96,14 +90,39 @@
96 wireless_item--;90 wireless_item--;
97 } 91 }
9892
99 items.remove (item);
100 this.remove (item);93 this.remove (item);
94 show_all ();
95 }
96
97 private void add_hotspot (WidgetNMInterface iface, int wireless_item) {
98 string title = _("Hotspot");
99 if (wireless_item > 0) {
100 title = _("Hotspot %s".printf (wireless_item.to_string ()));
101 }
102
103 var hotspot = new DeviceItem (title, "", "network-wireless-hotspot");
104 hotspot.no_show_all = true;
105 iface.device.state_changed.connect ((state) => {
106 hotspot.visible = (state != NM.DeviceState.UNAVAILABLE
107 && state != NM.DeviceState.UNMANAGED
108 && state != NM.DeviceState.UNKNOWN);
109 });
110
111 hotspot.device = iface.device;
112 hotspot.type = Utils.ItemType.VIRTUAL;
113
114 var hotspot_page = new HotspotPage (hotspot, ((WifiInterface)iface));
115 hotspot_page.title = title;
116 hotspot.page = hotspot_page;
117
118 this.add (hotspot);
101 }119 }
102120
103 private void add_proxy () {121 private void add_proxy () {
104 proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network");122 proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network");
105 proxy.page = new Widgets.ProxyPage (proxy);123 proxy.page = new ProxyPage (proxy);
106 proxy.type = Utils.ItemType.PROXY;124 proxy.type = Utils.ItemType.VIRTUAL;
125
107 this.add (proxy);126 this.add (proxy);
108 }127 }
109 128
@@ -111,14 +130,43 @@
111 this.get_row_at_index (0).activate ();130 this.get_row_at_index (0).activate ();
112 } 131 }
113132
133 private int sort_items (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
134 if (((DeviceItem) row1).type == Utils.ItemType.DEVICE) {
135 return -1;
136 } else if (((DeviceItem) row1).type == Utils.ItemType.VIRTUAL) {
137 return 1;
138 } else {
139 return 0;
140 }
141 }
142
114 private void update_headers (Gtk.ListBoxRow row, Gtk.ListBoxRow? before = null) {143 private void update_headers (Gtk.ListBoxRow row, Gtk.ListBoxRow? before = null) {
115 if (((DeviceItem) row).type != Utils.ItemType.DEVICE) {144 if (((DeviceItem) row).type == Utils.ItemType.VIRTUAL) {
116 row.set_header (settings_l);145 if (before != null && ((DeviceItem) before).type == Utils.ItemType.VIRTUAL) {
117 } else if (row == items.nth_data (0)) {146 return;
147 }
148
149 remove_headers_for_type (Utils.ItemType.VIRTUAL);
150 row.set_header (virtual_l);
151 } else if (((DeviceItem) row).type == Utils.ItemType.DEVICE) {
152 if (before != null && ((DeviceItem) before).type == Utils.ItemType.DEVICE) {
153 return;
154 }
155
156 remove_headers_for_type (Utils.ItemType.DEVICE);
118 row.set_header (devices_l);157 row.set_header (devices_l);
119 } else {158 } else {
120 row.set_header (null);159 row.set_header (null);
121 }160 }
122 }161 }
162
163 private void remove_headers_for_type (Utils.ItemType type) {
164 foreach (Gtk.Widget _item in get_children ()) {
165 var item = (DeviceItem)_item;
166 if (item.type == type) {
167 item.set_header (null);
168 }
169 }
170 }
123 }171 }
124}172}
125173
=== modified file 'src/Widgets/Footer.vala'
--- src/Widgets/Footer.vala 2015-10-08 17:08:13 +0000
+++ src/Widgets/Footer.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,7 +17,7 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23namespace Network {23namespace Network {
2424
=== added directory 'src/Widgets/Hotspot'
=== added file 'src/Widgets/Hotspot/HotspotDialog.vala'
--- src/Widgets/Hotspot/HotspotDialog.vala 1970-01-01 00:00:00 +0000
+++ src/Widgets/Hotspot/HotspotDialog.vala 2015-11-07 23:35:34 +0000
@@ -0,0 +1,230 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */
22
23namespace Network.Widgets {
24 public class HotspotDialog : Gtk.Dialog {
25 private const string NEW_ID = "0";
26 private Gtk.Entry ssid_entry;
27 private Gtk.Entry key_entry;
28
29 private Gtk.Label ssid_label;
30 private Gtk.Label key_label;
31
32 private Gtk.ComboBoxText conn_combo;
33
34 private Gtk.CheckButton check_btn;
35 private Gtk.Label dumb;
36
37 private Gtk.Button create_btn;
38
39 private HashTable<string, NM.Connection> conn_hash;
40 private unowned List<NM.Connection> available;
41
42 public HotspotDialog (NM.AccessPoint? active, List<NM.Connection> _available) {
43 this.available = _available;
44 this.deletable = false;
45 this.resizable = false;
46 this.border_width = 6;
47
48 conn_hash = new HashTable<string, NM.Connection> (str_hash, str_equal);
49
50 var content_area = this.get_content_area ();
51 content_area.halign = content_area.valign = Gtk.Align.CENTER;
52
53 var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
54 var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
55
56 vbox.margin_left = vbox.margin_right = 6;
57
58 string? ssid_str = null;
59 if (active != null) {
60 ssid_str = NM.Utils.ssid_to_utf8 (active.get_ssid ());
61 } else {
62 ssid_str = _("current");
63 }
64
65 var title = new Gtk.Label ("<span weight='bold' size='larger'>" + _("Wireless Hotspot") + "</span>");
66 title.use_markup = true;
67 title.halign = Gtk.Align.START;
68
69 var image = new Gtk.Image.from_icon_name ("network-wireless-hotspot", Gtk.IconSize.DIALOG);
70 image.valign = Gtk.Align.START;
71 main_box.add (image);
72
73 var info_label = new Gtk.Label (_("Enabling Wireless Hotspot will disconnect from %s network.").printf (ssid_str) + "\n" +
74 _("You will not be able to connect to a wireless network while Hotspot is active."));
75 info_label.halign = Gtk.Align.START;
76 info_label.margin_top = 6;
77 info_label.use_markup = true;
78
79 var grid = new Gtk.Grid ();
80 grid.hexpand = true;
81 grid.row_spacing = 6;
82 grid.column_spacing = 12;
83 grid.vexpand_set = true;
84
85 ssid_entry = new Gtk.Entry ();
86 ssid_entry.hexpand = true;
87 ssid_entry.text = get_ssid_for_hotspot ();
88
89 key_entry = new Gtk.Entry ();
90 key_entry.hexpand = true;
91 key_entry.visibility = false;
92 key_entry.secondary_icon_tooltip_text = _("Password needs to be at least 8 characters long.");
93
94 check_btn = new Gtk.CheckButton.with_label (_("Show Password"));
95 check_btn.toggled.connect (() => {
96 key_entry.visibility = check_btn.active;
97 });
98
99 ssid_entry.changed.connect (update);
100 key_entry.changed.connect (update);
101
102 ssid_label = new Gtk.Label (_("Network Name:"));
103 ssid_label.halign = Gtk.Align.END;
104
105 key_label = new Gtk.Label (_("Password:"));
106 key_label.halign = Gtk.Align.END;
107
108 conn_combo = new Gtk.ComboBoxText ();
109 conn_combo.append (NEW_ID, _("New…"));
110 int i = 1;
111 foreach (var connection in available) {
112 var setting_wireless = connection.get_setting_wireless ();
113 conn_combo.append (i.to_string (), NM.Utils.ssid_to_utf8 (setting_wireless.get_ssid ()));
114 conn_hash.insert (i.to_string (), connection);
115 i++;
116 }
117
118 conn_combo.active_id = NEW_ID;
119 conn_combo.changed.connect (update);
120
121 var conn_label = new Gtk.Label (_("Connection:"));
122 conn_label.halign = Gtk.Align.END;
123
124 grid.attach (conn_label, 0, 0, 1, 1);
125 grid.attach_next_to (conn_combo, conn_label, Gtk.PositionType.RIGHT, 1, 1);
126
127 dumb = new Gtk.Label ("");
128
129 grid.attach_next_to (ssid_label, conn_label, Gtk.PositionType.BOTTOM, 1, 1);
130 grid.attach_next_to (ssid_entry, ssid_label, Gtk.PositionType.RIGHT, 1, 1);
131 grid.attach_next_to (key_label, ssid_label, Gtk.PositionType.BOTTOM, 1, 1);
132 grid.attach_next_to (key_entry, key_label, Gtk.PositionType.RIGHT, 1, 1);
133 grid.attach_next_to (dumb, key_label, Gtk.PositionType.BOTTOM, 1, 1);
134 grid.attach_next_to (check_btn, dumb, Gtk.PositionType.RIGHT, 1, 1);
135
136 var cancel_btn = new Gtk.Button.with_label (_("Cancel"));
137 create_btn = new Gtk.Button.with_label (_("Enable Hotspot"));
138 if (active != null) {
139 create_btn.label = _("Switch to Hotspot");
140 }
141
142 create_btn.get_style_context ().add_class ("suggested-action");
143
144 this.add_action_widget (cancel_btn, 0);
145 this.add_action_widget (create_btn, 1);
146
147 vbox.add (title);
148 vbox.add (info_label);
149 vbox.add (grid);
150
151 update ();
152
153 main_box.add (vbox);
154 content_area.add (main_box);
155 this.show_all ();
156 }
157
158 public ByteArray get_ssid () {
159 var byte_array = new ByteArray ();
160 byte_array.append (ssid_entry.get_text ().data);
161 return byte_array;
162 }
163
164 public string get_key () {
165 return key_entry.get_text ();
166 }
167
168 public NM.Connection? get_selected_connection () {
169 return conn_hash[conn_combo.get_active_id ()];
170 }
171
172 private string get_ssid_for_hotspot () {
173 string hostname = "";
174 try {
175 Process.spawn_command_line_sync ("hostname", out hostname, null, null);
176 } catch (SpawnError e) {
177 warning ("%s\n", e.message);
178 }
179
180 return hostname.strip ().replace ("\n", "");
181 }
182
183 private void update () {
184 bool sensitive = (conn_combo.get_active_id () == NEW_ID);
185 ssid_label.sensitive = sensitive;
186 key_label.sensitive = sensitive;
187
188 ssid_entry.sensitive = sensitive;
189 key_entry.sensitive = sensitive;
190
191 check_btn.sensitive = sensitive;
192 dumb.sensitive = sensitive;
193
194 string? secret = null;
195 if (get_selected_connection () != null) {
196 var setting_wireless_security = get_selected_connection ().get_setting_wireless_security ();
197
198 string key_mgmt = setting_wireless_security.get_key_mgmt ();
199 if (key_mgmt == "none") {
200 secret = setting_wireless_security.get_wep_key (0);
201 } else if (key_mgmt == "wpa-psk" ||
202 key_mgmt == "wpa-none") {
203 secret = setting_wireless_security.get_psk ();
204 }
205
206 if (secret == null) {
207 var connection = get_selected_connection ();
208 Utils.Hotspot.update_secrets (((NM.RemoteConnection) connection), update);
209 }
210 }
211
212 if (conn_combo.get_active_id () != NEW_ID) {
213 ssid_entry.text = NM.Utils.ssid_to_utf8 (get_selected_connection ().get_setting_wireless ().get_ssid ());
214 if (secret == null) {
215 secret = "";
216 }
217
218 key_entry.text = secret;
219 }
220
221 create_btn.sensitive = ((ssid_entry.get_text () != "" && key_entry.get_text ().to_utf8 ().length >= 8) || !sensitive);
222
223 if (key_entry.get_text ().to_utf8 ().length < 8 && key_entry.get_text () != "") {
224 key_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "process-error-symbolic");
225 } else {
226 key_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "");
227 }
228 }
229 }
230}
0\ No newline at end of file231\ No newline at end of file
1232
=== added file 'src/Widgets/Hotspot/HotspotPage.vala'
--- src/Widgets/Hotspot/HotspotPage.vala 1970-01-01 00:00:00 +0000
+++ src/Widgets/Hotspot/HotspotPage.vala 2015-11-07 23:35:34 +0000
@@ -0,0 +1,174 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */
22
23 namespace Network.Widgets {
24 public class HotspotPage : Network.WidgetNMInterface {
25 private DeviceItem owner;
26
27 private WifiInterface root_iface;
28 private NM.RemoteSettings nm_settings;
29 private Gtk.Revealer hotspot_revealer;
30 private Gtk.Button hotspot_settings_btn;
31 private Gtk.Label ssid_label;
32 private Gtk.Label key_label;
33 private bool switch_updating = false;
34
35 public HotspotPage (DeviceItem _owner, WifiInterface _root_iface) {
36 owner = _owner;
37 root_iface = _root_iface;
38 nm_settings = root_iface.get_nm_settings ();
39 info_box = new InfoBox.from_device (owner.get_item_device ());
40 this.init (owner.get_item_device (), info_box);
41
42 this.icon_name = owner.get_item_icon_name ();
43 this.title = Utils.type_to_string (device.get_device_type ());
44
45 hotspot_revealer = new Gtk.Revealer ();
46 hotspot_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
47
48 hotspot_settings_btn = Utils.get_advanced_button_from_device (device, _("Hotspot Settings…"));
49
50 var hinfo_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6);
51
52 ssid_label = new Gtk.Label ("");
53 ssid_label.halign = Gtk.Align.START;
54
55 key_label = new Gtk.Label ("");
56 key_label.halign = Gtk.Align.START;
57
58 hinfo_box.add (ssid_label);
59 hinfo_box.add (key_label);
60 hotspot_revealer.add (hinfo_box);
61
62 bottom_revealer = new Gtk.Revealer ();
63
64 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
65 button_box.pack_end (hotspot_settings_btn, false, false, 0);
66 bottom_revealer.add (button_box);
67
68 nm_settings.connections_read.connect (update);
69 device.state_changed.connect (update);
70
71 update ();
72
73 this.add (hotspot_revealer);
74 this.pack_end (bottom_revealer, false, false);
75 this.show_all ();
76 }
77
78 protected override void update () {
79 if (hotspot_settings_btn != null) {
80 hotspot_settings_btn.sensitive = (Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings));
81 }
82
83 update_hotspot_info ();
84 base.update ();
85 }
86
87 protected override void update_switch () {
88 switch_updating = true;
89 control_switch.active = (Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings));
90 switch_updating = false;
91 }
92
93 protected override void control_switch_activated () {
94 if (switch_updating) {
95 switch_updating = false;
96 return;
97 }
98
99 var wifi_device = (NM.DeviceWifi)device;
100 if (!control_switch.active && Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) {
101 Utils.Hotspot.deactivate_hotspot (wifi_device);
102 } else {
103 var hotspot_dialog = new HotspotDialog (wifi_device.get_active_access_point (), get_hotspot_connections ());
104 hotspot_dialog.response.connect ((response) => {
105 if (response == 1) {
106 Utils.Hotspot.activate_hotspot (wifi_device,
107 hotspot_dialog.get_ssid (),
108 hotspot_dialog.get_key (),
109 hotspot_dialog.get_selected_connection ());
110
111 }
112 });
113
114 hotspot_dialog.run ();
115 hotspot_dialog.destroy ();
116 }
117 }
118
119 private void update_hotspot_info () {
120 var wifi_device = (NM.DeviceWifi)device;
121 bool hotspot_mode = Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings);
122
123 var mode = Utils.CustomMode.HOTSPOT_DISABLED;
124 if (hotspot_mode) {
125 mode = Utils.CustomMode.HOTSPOT_ENABLED;
126 }
127
128 owner.switch_status (mode);
129
130 hotspot_revealer.set_reveal_child (hotspot_mode);
131
132 if (hotspot_mode) {
133 var connection = nm_settings.get_connection_by_path (wifi_device.get_active_connection ().get_connection ());
134
135 var setting_wireless = connection.get_setting_wireless ();
136 ssid_label.label = _("Network Name (SSID): %s").printf (NM.Utils.ssid_to_utf8 (setting_wireless.get_ssid ()));
137
138 var setting_wireless_security = connection.get_setting_wireless_security ();
139
140 string key_mgmt = setting_wireless_security.get_key_mgmt ();
141 string? secret = null;
142 string security = "";
143 if (key_mgmt == "none") {
144 secret = setting_wireless_security.get_wep_key (0);
145 security = _("(WEP)");
146 } else if (key_mgmt == "wpa-psk" ||
147 key_mgmt == "wpa-none") {
148 security = _("(WPA)");
149 secret = setting_wireless_security.get_psk ();
150 }
151
152 if (secret == null) {
153 Utils.Hotspot.update_secrets (connection, update);
154 return;
155 }
156
157 key_label.label = _("Password %s: %s").printf (security, secret);
158 }
159 }
160
161 private List<NM.Connection> get_hotspot_connections () {
162 var list = new List<NM.Connection> ();
163 var connections = nm_settings.list_connections ();
164
165 foreach (var connection in connections) {
166 if (Utils.Hotspot.get_connection_is_hotspot (connection)) {
167 list.append (connection);
168 }
169 }
170
171 return list;
172 }
173 }
174}
0175
=== modified file 'src/Widgets/InfoBox.vala'
--- src/Widgets/InfoBox.vala 2015-10-20 20:34:36 +0000
+++ src/Widgets/InfoBox.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,7 +17,7 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23namespace Network.Widgets { 23namespace Network.Widgets {
2424
=== modified file 'src/Widgets/InfoScreen.vala'
--- src/Widgets/InfoScreen.vala 2015-07-18 16:56:50 +0000
+++ src/Widgets/InfoScreen.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,7 +17,7 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23namespace Network {23namespace Network {
2424
=== modified file 'src/Widgets/Page.vala'
--- src/Widgets/Page.vala 2015-10-09 19:12:42 +0000
+++ src/Widgets/Page.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
77
=== modified file 'src/Widgets/Proxy/ProxyConfigurationPage.vala'
--- src/Widgets/Proxy/ProxyConfigurationPage.vala 2015-10-09 19:12:42 +0000
+++ src/Widgets/Proxy/ProxyConfigurationPage.vala 2015-11-07 23:35:34 +0000
@@ -1,5 +1,26 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com
21 */
22
1namespace Network.Widgets {23namespace Network.Widgets {
2
3 public class ConfigurationPage : Gtk.Box {24 public class ConfigurationPage : Gtk.Box {
4 private const string DEFAULT_PROXY = "host:port";25 private const string DEFAULT_PROXY = "host:port";
5 private bool syntax_error = false;26 private bool syntax_error = false;
627
=== modified file 'src/Widgets/Proxy/ProxyExceptionsPage.vala'
--- src/Widgets/Proxy/ProxyExceptionsPage.vala 2015-08-03 00:16:24 +0000
+++ src/Widgets/Proxy/ProxyExceptionsPage.vala 2015-11-07 23:35:34 +0000
@@ -1,3 +1,25 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */
22
1namespace Network.Widgets {23namespace Network.Widgets {
2 public class ExecepionsPage : Gtk.Box {24 public class ExecepionsPage : Gtk.Box {
3 private Gtk.ListBox ignored_list;25 private Gtk.ListBox ignored_list;
426
=== modified file 'src/Widgets/Proxy/ProxyPage.vala'
--- src/Widgets/Proxy/ProxyPage.vala 2015-10-20 20:34:36 +0000
+++ src/Widgets/Proxy/ProxyPage.vala 2015-11-07 23:35:34 +0000
@@ -1,3 +1,26 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 3 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */
22
23
1namespace Network.Widgets {24namespace Network.Widgets {
2 public class ProxyPage : Gtk.Box {25 public class ProxyPage : Gtk.Box {
3 public Gtk.Stack stack;26 public Gtk.Stack stack;
@@ -34,7 +57,23 @@
34 }57 }
3558
36 public void update_mode () {59 public void update_mode () {
37 owner.switch_status (null, proxy_settings.mode);60 var mode = Utils.CustomMode.INVALID;
61 switch (proxy_settings.mode) {
62 case "none":
63 mode = Utils.CustomMode.PROXY_NONE;
64 break;
65 case "manual":
66 mode = Utils.CustomMode.PROXY_MANUAL;
67 break;
68 case "auto":
69 mode = Utils.CustomMode.PROXY_AUTO;
70 break;
71 default:
72 mode = Utils.CustomMode.INVALID;
73 break;
74 }
75
76 owner.switch_status (mode);
38 }77 }
39 }78 }
40}79}
4180
=== modified file 'src/Widgets/WifiInterface.vala'
--- src/Widgets/WifiInterface.vala 2015-10-09 19:12:42 +0000
+++ src/Widgets/WifiInterface.vala 2015-11-07 23:35:34 +0000
@@ -1,6 +1,6 @@
1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-1// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-
2/*-2/*-
3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug)3 * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking)
4 *4 *
5 * This library is free software; you can redistribute it and/or5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public6 * modify it under the terms of the GNU Library General Public
@@ -17,7 +17,7 @@
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.18 * Boston, MA 02111-1307, USA.
19 *19 *
20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com20 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
21 */21 */
2222
23using Network.Widgets;23using Network.Widgets;
@@ -25,6 +25,9 @@
25namespace Network {25namespace Network {
26 public class WifiInterface : AbstractWifiInterface {26 public class WifiInterface : AbstractWifiInterface {
27 protected Gtk.Frame connected_frame;27 protected Gtk.Frame connected_frame;
28 protected Gtk.Stack list_stack;
29 protected Gtk.ScrolledWindow scrolled;
30 protected Gtk.Box hotspot_mode_box;
28 protected Gtk.Box? connected_box = null;31 protected Gtk.Box? connected_box = null;
29 protected Gtk.Revealer top_revealer;32 protected Gtk.Revealer top_revealer;
30 protected Gtk.Button disconnect_btn;33 protected Gtk.Button disconnect_btn;
@@ -32,17 +35,10 @@
32 protected Gtk.ToggleButton info_btn;35 protected Gtk.ToggleButton info_btn;
33 protected Gtk.Popover popover;36 protected Gtk.Popover popover;
3437
35 public WifiInterface (NM.Client nm_client, NM.RemoteSettings settings, NM.Device device_) {38 public WifiInterface (NM.Client nm_client, NM.RemoteSettings settings, NM.Device _device) {
36 info_box = new InfoBox.from_device (device_);39 info_box = new InfoBox.from_device (_device);
37 info_box.margin = 12;40 info_box.margin = 12;
38 this.init (device_, info_box);41 this.init (_device, info_box);
39
40 var css_provider = new Gtk.CssProvider ();
41 try {
42 css_provider.load_from_data ("GtkFrame {\nbackground: #ffffff;\n}", -1);
43 } catch (Error e) {
44 warning ("%s\n", e.message);
45 }
4642
47 popover = new Gtk.Popover (info_btn);43 popover = new Gtk.Popover (info_btn);
48 popover.position = Gtk.PositionType.BOTTOM;44 popover.position = Gtk.PositionType.BOTTOM;
@@ -52,13 +48,13 @@
52 });48 });
5349
54 connected_frame = new Gtk.Frame (null);50 connected_frame = new Gtk.Frame (null);
55 connected_frame.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);51 connected_frame.override_background_color (0, { 255, 255, 255, 255 });
5652
57 top_revealer = new Gtk.Revealer ();53 top_revealer = new Gtk.Revealer ();
58 top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;54 top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN;
59 top_revealer.add (connected_frame);55 top_revealer.add (connected_frame);
60 56
61 init_wifi_interface (nm_client, settings, device_);57 init_wifi_interface (nm_client, settings, device);
6258
63 this.icon_name = "network-wireless";59 this.icon_name = "network-wireless";
64 this.title = _("Wireless");60 this.title = _("Wireless");
@@ -66,15 +62,35 @@
6662
67 control_box.margin_bottom = 12;63 control_box.margin_bottom = 12;
6864
65 list_stack = new Gtk.Stack ();
66
67 hotspot_mode_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
68 hotspot_mode_box.visible = true;
69 hotspot_mode_box.valign = Gtk.Align.CENTER;
70
71 var main_frame = new Gtk.Frame (null);
72 main_frame.margin_bottom = 24;
73 main_frame.margin_top = 12;
74 main_frame.vexpand = true;
75 main_frame.override_background_color (0, { 255, 255, 255, 255 });
76
77 var hotspot_mode = construct_placeholder_label (_("This device is in Hotspot Mode"), true);
78 var hotspot_mode_desc = construct_placeholder_label (_("Turn off the Hotspot Mode to connect to other Access Points."), false);
79 hotspot_mode_box.add (hotspot_mode);
80 hotspot_mode_box.add (hotspot_mode_desc);
81
69 wifi_list.selection_mode = Gtk.SelectionMode.SINGLE;82 wifi_list.selection_mode = Gtk.SelectionMode.SINGLE;
70 wifi_list.activate_on_single_click = false; 83 wifi_list.activate_on_single_click = false;
84 wifi_list.visible = true;
7185
72 var scrolled = new Gtk.ScrolledWindow (null, null);86 scrolled = new Gtk.ScrolledWindow (null, null);
73 scrolled.margin_bottom = 24;
74 scrolled.margin_top = 12;
75 scrolled.add (wifi_list);87 scrolled.add (wifi_list);
76 scrolled.vexpand = true;88
77 scrolled.shadow_type = Gtk.ShadowType.OUT;89 list_stack.add (hotspot_mode_box);
90 list_stack.add (scrolled);
91 list_stack.visible_child = scrolled;
92
93 main_frame.add (list_stack);
7894
79 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);95 var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
8096
@@ -83,14 +99,18 @@
8399
84 button_box.pack_start (hidden_btn, false, false, 0);100 button_box.pack_start (hidden_btn, false, false, 0);
85101
86 update ();
87
88 bottom_box.add (button_box);102 bottom_box.add (button_box);
89103
90 this.add (top_revealer);104 this.add (top_revealer);
91 this.add (scrolled);105 this.add (main_frame);
92 this.add (bottom_revealer);106 this.add (bottom_revealer);
93 this.show_all (); 107 this.show_all ();
108
109 update ();
110 }
111
112 public NM.RemoteSettings get_nm_settings () {
113 return nm_settings;
94 }114 }
95115
96 public override void update () {116 public override void update () {
@@ -111,7 +131,15 @@
111131
112 base.update ();132 base.update ();
113133
114 top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null);134 bool is_hotspot = Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings);
135
136 top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null && !is_hotspot);
137
138 if (is_hotspot) {
139 list_stack.visible_child = hotspot_mode_box;
140 } else {
141 list_stack.visible_child = scrolled;
142 }
115143
116 if (wifi_device.get_active_access_point () == null && old_active != null) { 144 if (wifi_device.get_active_access_point () == null && old_active != null) {
117 old_active.no_show_all = false;145 old_active.no_show_all = false;
@@ -186,7 +214,7 @@
186214
187 protected override void control_switch_activated () {215 protected override void control_switch_activated () {
188 var active = control_switch.active;216 var active = control_switch.active;
189 if (active != !software_locked) {217 if (active == software_locked) {
190 rfkill.set_software_lock (RFKillDeviceType.WLAN, !active);218 rfkill.set_software_lock (RFKillDeviceType.WLAN, !active);
191 client.wireless_set_enabled (active);219 client.wireless_set_enabled (active);
192 }220 }
193221
=== modified file 'src/common/Widgets/AbstractWifiInterface.vala'
--- src/common/Widgets/AbstractWifiInterface.vala 2015-10-22 16:46:13 +0000
+++ src/common/Widgets/AbstractWifiInterface.vala 2015-11-07 23:35:34 +0000
@@ -39,7 +39,7 @@
39 this.nm_client = nm_client;39 this.nm_client = nm_client;
40 this.nm_settings = nm_settings;40 this.nm_settings = nm_settings;
41 device = _device;41 device = _device;
42 wifi_device = device as NM.DeviceWifi;42 wifi_device = (NM.DeviceWifi)device;
43 blank_item = new WifiMenuItem.blank ();43 blank_item = new WifiMenuItem.blank ();
44 active_wifi_item = null;44 active_wifi_item = null;
45 45
@@ -82,7 +82,6 @@
82 scanning_box.visible = true;82 scanning_box.visible = true;
83 scanning_box.valign = Gtk.Align.CENTER; 83 scanning_box.valign = Gtk.Align.CENTER;
84 84
85
86 placeholder.add_named (no_aps_box, "no-aps");85 placeholder.add_named (no_aps_box, "no-aps");
87 placeholder.add_named (wireless_off_box, "wireless-off");86 placeholder.add_named (wireless_off_box, "wireless-off");
88 placeholder.add_named (scanning_box, "scanning");87 placeholder.add_named (scanning_box, "scanning");
@@ -99,7 +98,9 @@
99 rfkill.device_changed.connect (update);98 rfkill.device_changed.connect (update);
100 rfkill.device_deleted.connect (update);99 rfkill.device_deleted.connect (update);
101 100
102 wifi_device.notify["active-access-point"].connect (() => { update (); });101 nm_settings.connections_read.connect (update);
102
103 wifi_device.notify["active-access-point"].connect (update);
103 wifi_device.access_point_added.connect (access_point_added_cb);104 wifi_device.access_point_added.connect (access_point_added_cb);
104 wifi_device.access_point_removed.connect (access_point_removed_cb);105 wifi_device.access_point_removed.connect (access_point_removed_cb);
105 wifi_device.state_changed.connect (update);106 wifi_device.state_changed.connect (update);
@@ -112,7 +113,7 @@
112 update();113 update();
113 }114 }
114115
115 Gtk.Label construct_placeholder_label (string text, bool title) {116 protected Gtk.Label construct_placeholder_label (string text, bool title) {
116 var label = new Gtk.Label (text);117 var label = new Gtk.Label (text);
117 label.visible = true;118 label.visible = true;
118 label.use_markup = true;119 label.use_markup = true;
@@ -157,7 +158,6 @@
157 item.user_action.connect (wifi_activate_cb);158 item.user_action.connect (wifi_activate_cb);
158159
159 wifi_list.add (item);160 wifi_list.add (item);
160
161 wifi_list.show_all ();161 wifi_list.show_all ();
162162
163 update ();163 update ();
@@ -241,6 +241,13 @@
241 }241 }
242242
243 public override void update () {243 public override void update () {
244#if PLUG_NETWORK
245 if (Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) {
246 state = State.DISCONNECTED;
247 return;
248 }
249#endif
250
244 switch (wifi_device.state) {251 switch (wifi_device.state) {
245 case NM.DeviceState.UNKNOWN:252 case NM.DeviceState.UNKNOWN:
246 case NM.DeviceState.UNMANAGED:253 case NM.DeviceState.UNMANAGED:
@@ -275,6 +282,7 @@
275 282
276 case NM.DeviceState.ACTIVATED:283 case NM.DeviceState.ACTIVATED:
277 set_scan_placeholder ();284 set_scan_placeholder ();
285
278 /* That can happen if active_ap has not been added yet, at startup. */286 /* That can happen if active_ap has not been added yet, at startup. */
279 if (active_ap != null) {287 if (active_ap != null) {
280 state = strength_to_state(active_ap.get_strength());288 state = strength_to_state(active_ap.get_strength());
@@ -298,6 +306,7 @@
298 if (device.hardware_lock)306 if (device.hardware_lock)
299 hardware_locked = true;307 hardware_locked = true;
300 }308 }
309
301 locked = hardware_locked || software_locked;310 locked = hardware_locked || software_locked;
302311
303 update_active_ap ();312 update_active_ap ();
@@ -319,6 +328,12 @@
319 cancel_scan ();328 cancel_scan ();
320 wifi_device.request_scan_simple (null);329 wifi_device.request_scan_simple (null);
321 timeout_scan = Timeout.add(5000, () => {330 timeout_scan = Timeout.add(5000, () => {
331#if PLUG_NETWORK
332 if (Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) {
333 return false;
334 }
335#endif
336
322 timeout_scan = 0;337 timeout_scan = 0;
323 placeholder.visible_child_name = "no-aps";338 placeholder.visible_child_name = "no-aps";
324 return false;339 return false;

Subscribers

People subscribed via source and target branches

to all changes: