Merge lp:~donadigo/switchboard-plug-networking/hotspot into lp:~elementary-pantheon/switchboard-plug-networking/trunk
- hotspot
- Merge into trunk
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 |
Related bugs: |
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.
- 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
Cody Garver (codygarver) wrote : | # |
Adam Bieńkowski (donadigo) wrote : | # |
Ahh, good catch, thanks ;)
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
Danielle Foré (danrabbit) wrote : | # |
Hey right on. Like the alert messaging when it's in hotspot mode. Looks good :)
xapantu (xapantu) wrote : | # |
Why is Utils a class in src/Utils.vala ?
xapantu (xapantu) wrote : | # |
Superseded by the other hotspot branch.
Unmerged revisions
Preview Diff
1 | === modified file 'src/CMakeLists.txt' |
2 | --- src/CMakeLists.txt 2015-08-01 23:06:00 +0000 |
3 | +++ src/CMakeLists.txt 2015-11-07 23:35:34 +0000 |
4 | @@ -27,6 +27,8 @@ |
5 | Widgets/InfoBox.vala |
6 | Widgets/Footer.vala |
7 | Widgets/InfoScreen.vala |
8 | + Widgets/Hotspot/HotspotDialog.vala |
9 | + Widgets/Hotspot/HotspotPage.vala |
10 | common/Utils.vala |
11 | common/Widgets/WifiMenuItem.vala |
12 | common/Widgets/AbstractWifiInterface.vala |
13 | |
14 | === modified file 'src/Plug.vala' |
15 | --- src/Plug.vala 2015-10-30 20:42:55 +0000 |
16 | +++ src/Plug.vala 2015-11-07 23:35:34 +0000 |
17 | @@ -1,6 +1,6 @@ |
18 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
19 | /*- |
20 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
21 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
22 | * |
23 | * This library is free software; you can redistribute it and/or |
24 | * modify it under the terms of the GNU Library General Public |
25 | @@ -17,7 +17,7 @@ |
26 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
27 | * Boston, MA 02111-1307, USA. |
28 | * |
29 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
30 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
31 | */ |
32 | |
33 | /* Main client instance */ |
34 | @@ -64,7 +64,6 @@ |
35 | } |
36 | |
37 | content.remove (widget_interface); |
38 | - |
39 | show_all (); |
40 | } |
41 | |
42 | |
43 | === modified file 'src/Settings/ProxySettings.vala' |
44 | --- src/Settings/ProxySettings.vala 2015-10-09 19:12:42 +0000 |
45 | +++ src/Settings/ProxySettings.vala 2015-11-07 23:35:34 +0000 |
46 | @@ -1,3 +1,25 @@ |
47 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
48 | +/*- |
49 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
50 | + * |
51 | + * This library is free software; you can redistribute it and/or |
52 | + * modify it under the terms of the GNU Library General Public |
53 | + * License as published by the Free Software Foundation; either |
54 | + * version 3 of the License, or (at your option) any later version. |
55 | + * |
56 | + * This library is distributed in the hope that it will be useful, |
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
59 | + * Library General Public License for more details. |
60 | + * |
61 | + * You should have received a copy of the GNU Library General Public |
62 | + * License along with this library; if not, write to the |
63 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
64 | + * Boston, MA 02111-1307, USA. |
65 | + * |
66 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
67 | + */ |
68 | + |
69 | namespace Network { |
70 | public class ProxySettings : Granite.Services.Settings { |
71 | public string autoconfig_url { get; set; } |
72 | |
73 | === modified file 'src/Utils.vala' |
74 | --- src/Utils.vala 2015-10-22 16:46:13 +0000 |
75 | +++ src/Utils.vala 2015-11-07 23:35:34 +0000 |
76 | @@ -1,81 +1,262 @@ |
77 | -namespace Network.Utils { |
78 | - public enum ItemType { |
79 | - DEVICE = 0, |
80 | - PROXY, |
81 | - INVALID |
82 | - } |
83 | - |
84 | - public Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) { |
85 | - var details_btn = new Gtk.Button.with_label (title); |
86 | - details_btn.clicked.connect (() => { |
87 | - new Granite.Services.SimpleCommand ("/usr/bin", |
88 | - "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run (); |
89 | - }); |
90 | - |
91 | - return details_btn; |
92 | - } |
93 | - |
94 | - public string state_to_string (NM.DeviceState state) { |
95 | - switch (state) { |
96 | - case NM.DeviceState.ACTIVATED: |
97 | - return _("Connected"); |
98 | - case NM.DeviceState.DISCONNECTED: |
99 | - return _("Disconnected"); |
100 | - case NM.DeviceState.UNMANAGED: |
101 | - return _("Unmanaged"); |
102 | - case NM.DeviceState.PREPARE: |
103 | - return _("In preparation"); |
104 | - case NM.DeviceState.CONFIG: |
105 | - return _("Connecting..."); |
106 | - case NM.DeviceState.NEED_AUTH: |
107 | - return _("Requires more information"); |
108 | - case NM.DeviceState.IP_CONFIG: |
109 | - return _("Requesting adresses..."); |
110 | - case NM.DeviceState.IP_CHECK: |
111 | - return _("Checking connection..."); |
112 | - case NM.DeviceState.SECONDARIES: |
113 | - return _("Waiting for connection..."); |
114 | - case NM.DeviceState.DEACTIVATING: |
115 | - return _("Disconnecting..."); |
116 | - case NM.DeviceState.FAILED: |
117 | - return _("Failed to connect"); |
118 | - case NM.DeviceState.UNKNOWN: |
119 | - default: |
120 | - return _("Unknown"); |
121 | - } |
122 | - } |
123 | - |
124 | - public string type_to_string (NM.DeviceType type) { |
125 | - switch (type) { |
126 | - case NM.DeviceType.ETHERNET: |
127 | - return _("Ethernet"); |
128 | - case NM.DeviceType.WIFI: |
129 | - return _("Wi-Fi"); |
130 | - case NM.DeviceType.UNUSED1: |
131 | - return _("Not used"); |
132 | - case NM.DeviceType.UNUSED2: |
133 | - return _("Not used"); |
134 | - case NM.DeviceType.BT: |
135 | - return _("Bluetooth"); |
136 | - case NM.DeviceType.OLPC_MESH: |
137 | - return _("OLPC XO"); |
138 | - case NM.DeviceType.WIMAX: |
139 | - return _("WiMAX Broadband"); |
140 | - case NM.DeviceType.MODEM: |
141 | - return _("Modem"); |
142 | - case NM.DeviceType.INFINIBAND: |
143 | - return _("InfiniBand device"); |
144 | - case NM.DeviceType.BOND: |
145 | - return _("Bond master"); |
146 | - case NM.DeviceType.VLAN: |
147 | - return _("VLAN Interface"); |
148 | - case NM.DeviceType.ADSL: |
149 | - return _("ADSL Modem"); |
150 | - case NM.DeviceType.BRIDGE: |
151 | - return _("Bridge master"); |
152 | - case NM.DeviceType.UNKNOWN: |
153 | - default: |
154 | - return _("Unknown"); |
155 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
156 | +/*- |
157 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
158 | + * |
159 | + * This library is free software; you can redistribute it and/or |
160 | + * modify it under the terms of the GNU Library General Public |
161 | + * License as published by the Free Software Foundation; either |
162 | + * version 3 of the License, or (at your option) any later version. |
163 | + * |
164 | + * This library is distributed in the hope that it will be useful, |
165 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
166 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
167 | + * Library General Public License for more details. |
168 | + * |
169 | + * You should have received a copy of the GNU Library General Public |
170 | + * License along with this library; if not, write to the |
171 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
172 | + * Boston, MA 02111-1307, USA. |
173 | + * |
174 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
175 | + */ |
176 | + |
177 | +namespace Network { |
178 | + public class Utils { |
179 | + public class Hotspot { |
180 | + public delegate void UpdateSecretCallback (); |
181 | + |
182 | + public static void activate_hotspot (NM.DeviceWifi wifi_device, |
183 | + ByteArray ssid, |
184 | + string key, |
185 | + NM.Connection? selected) { |
186 | + if (selected != null) { |
187 | + client.activate_connection (selected, wifi_device, null, null); |
188 | + return; |
189 | + } |
190 | + |
191 | + var hotspot_c = new NM.Connection (); |
192 | + |
193 | + var setting_connection = new NM.SettingConnection (); |
194 | + setting_connection.@set (NM.SettingConnection.TYPE, "802-11-wireless"); |
195 | + setting_connection.@set (NM.SettingConnection.ID, "Hotspot"); |
196 | + setting_connection.autoconnect = false; |
197 | + hotspot_c.add_setting (setting_connection); |
198 | + |
199 | + var setting_wireless = new NM.SettingWireless (); |
200 | + |
201 | + string? mode = null; |
202 | + var caps = wifi_device.get_capabilities (); |
203 | + if ((caps & NM.DeviceWifiCapabilities.AP) != 0) { |
204 | + mode = NM.SettingWireless.MODE_AP; |
205 | + } else { |
206 | + mode = NM.SettingWireless.MODE_ADHOC; |
207 | + } |
208 | + |
209 | + setting_wireless.mode = mode; |
210 | + setting_wireless.security = "802-11-wireless-security"; |
211 | + |
212 | + hotspot_c.add_setting (setting_wireless); |
213 | + |
214 | + var ip4_setting = new NM.SettingIP4Config (); |
215 | + ip4_setting.method = "shared"; |
216 | + hotspot_c.add_setting (ip4_setting); |
217 | + |
218 | + setting_wireless.@set (NM.SettingWireless.SSID, ssid); |
219 | + |
220 | + var setting_wireless_security = new NM.SettingWirelessSecurity (); |
221 | + |
222 | + if (mode == NM.SettingWireless.MODE_AP) { |
223 | + if ((caps & NM.DeviceWifiCapabilities.RSN) != 0) { |
224 | + set_wpa_key (setting_wireless_security, key); |
225 | + setting_wireless_security.add_proto ("rsn"); |
226 | + setting_wireless_security.add_pairwise ("ccmp"); |
227 | + setting_wireless_security.add_group ("ccmp"); |
228 | + } else if ((caps & NM.DeviceWifiCapabilities.WPA) != 0) { |
229 | + set_wpa_key (setting_wireless_security, key); |
230 | + setting_wireless_security.add_proto ("wpa"); |
231 | + setting_wireless_security.add_pairwise ("tkip"); |
232 | + setting_wireless_security.add_group ("tkip"); |
233 | + } else { |
234 | + set_wep_key (setting_wireless_security, key); |
235 | + } |
236 | + } else { |
237 | + set_wep_key (setting_wireless_security, key); |
238 | + } |
239 | + |
240 | + hotspot_c.add_setting (setting_wireless_security); |
241 | + client.add_and_activate_connection (hotspot_c, |
242 | + wifi_device, |
243 | + null, |
244 | + finish_connection_cb); |
245 | + } |
246 | + |
247 | + public static void update_secrets (NM.RemoteConnection connection, UpdateSecretCallback callback) { |
248 | + connection.get_secrets (connection.get_setting_wireless ().get_security (), ((_connection, secrets, error) => { |
249 | + var setting_wireless = _connection.get_setting_wireless (); |
250 | + try { |
251 | + _connection.update_secrets (setting_wireless.get_security (), secrets); |
252 | + } catch (Error e) { |
253 | + warning ("%s\n", e.message); |
254 | + return; |
255 | + } |
256 | + |
257 | + callback (); |
258 | + })); |
259 | + } |
260 | + |
261 | + public static void deactivate_hotspot (NM.DeviceWifi wifi_device) { |
262 | + client.get_active_connections ().@foreach ((active_connection) => { |
263 | + var devices = active_connection.get_devices (); |
264 | + if (devices != null && devices.@get (0) == wifi_device) { |
265 | + client.deactivate_connection (active_connection); |
266 | + } |
267 | + }); |
268 | + } |
269 | + |
270 | + private static void set_wpa_key (NM.SettingWirelessSecurity setting, string key) { |
271 | + setting.key_mgmt = "wpa-psk"; |
272 | + setting.psk = key; |
273 | + } |
274 | + |
275 | + private static void set_wep_key (NM.SettingWirelessSecurity setting, string key) { |
276 | + setting.key_mgmt = "none"; |
277 | + setting.wep_key0 = key; |
278 | + setting.wep_key_type = NM.WepKeyType.PASSPHRASE; |
279 | + } |
280 | + |
281 | + public static bool get_device_is_hotspot (NM.DeviceWifi wifi_device, NM.RemoteSettings nm_settings) { |
282 | + if (wifi_device.get_active_connection () != null) { |
283 | + var connection = nm_settings.get_connection_by_path (wifi_device.get_active_connection ().get_connection ()); |
284 | + if (connection != null) { |
285 | + var ip4_setting = connection.get_setting_ip4_config (); |
286 | + return (ip4_setting != null && ip4_setting.get_method () == "shared"); |
287 | + } |
288 | + } |
289 | + |
290 | + return false; |
291 | + } |
292 | + |
293 | + public static bool get_connection_is_hotspot (NM.Connection connection) { |
294 | + var setting_connection = connection.get_setting_connection (); |
295 | + if (setting_connection.get_connection_type () != "802-11-wireless") { |
296 | + return false; |
297 | + } |
298 | + |
299 | + var setting_wireless = connection.get_setting_wireless (); |
300 | + if (setting_wireless.get_mode () != "adhoc" |
301 | + && setting_wireless.get_mode () != "ap") { |
302 | + return false; |
303 | + } |
304 | + |
305 | + if (setting_wireless.get_security () != "802-11-wireless-security") { |
306 | + return false; |
307 | + } |
308 | + |
309 | + var ip4_config = connection.get_setting_ip4_config (); |
310 | + if (ip4_config.get_method () != "shared") { |
311 | + return false; |
312 | + } |
313 | + |
314 | + return true; |
315 | + } |
316 | + |
317 | + private static void finish_connection_cb (NM.Client? cb_client, |
318 | + NM.ActiveConnection? cb_connection, |
319 | + string? new_connection_path, |
320 | + Error? error) { |
321 | + if (error != null && error.code != 0) { |
322 | + warning ("%s\n", error.message); |
323 | + } |
324 | + } |
325 | + } |
326 | + |
327 | + public enum CustomMode { |
328 | + PROXY_NONE = 0, |
329 | + PROXY_MANUAL, |
330 | + PROXY_AUTO, |
331 | + HOTSPOT_ENABLED, |
332 | + HOTSPOT_DISABLED, |
333 | + INVALID |
334 | + } |
335 | + |
336 | + public enum ItemType { |
337 | + DEVICE = 0, |
338 | + VIRTUAL, |
339 | + INVALID |
340 | + } |
341 | + |
342 | + public static Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) { |
343 | + var details_btn = new Gtk.Button.with_label (title); |
344 | + details_btn.clicked.connect (() => { |
345 | + new Granite.Services.SimpleCommand ("/usr/bin", |
346 | + "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run (); |
347 | + }); |
348 | + |
349 | + return details_btn; |
350 | + } |
351 | + |
352 | + public static string state_to_string (NM.DeviceState state) { |
353 | + switch (state) { |
354 | + case NM.DeviceState.ACTIVATED: |
355 | + return _("Connected"); |
356 | + case NM.DeviceState.DISCONNECTED: |
357 | + return _("Disconnected"); |
358 | + case NM.DeviceState.UNMANAGED: |
359 | + return _("Unmanaged"); |
360 | + case NM.DeviceState.PREPARE: |
361 | + return _("In preparation"); |
362 | + case NM.DeviceState.CONFIG: |
363 | + return _("Connecting..."); |
364 | + case NM.DeviceState.NEED_AUTH: |
365 | + return _("Requires more information"); |
366 | + case NM.DeviceState.IP_CONFIG: |
367 | + return _("Requesting adresses..."); |
368 | + case NM.DeviceState.IP_CHECK: |
369 | + return _("Checking connection..."); |
370 | + case NM.DeviceState.SECONDARIES: |
371 | + return _("Waiting for connection..."); |
372 | + case NM.DeviceState.DEACTIVATING: |
373 | + return _("Disconnecting..."); |
374 | + case NM.DeviceState.FAILED: |
375 | + return _("Failed to connect"); |
376 | + case NM.DeviceState.UNKNOWN: |
377 | + default: |
378 | + return _("Unknown"); |
379 | + } |
380 | + } |
381 | + |
382 | + public static string type_to_string (NM.DeviceType type) { |
383 | + switch (type) { |
384 | + case NM.DeviceType.ETHERNET: |
385 | + return _("Ethernet"); |
386 | + case NM.DeviceType.WIFI: |
387 | + return _("Wi-Fi"); |
388 | + case NM.DeviceType.UNUSED1: |
389 | + return _("Not used"); |
390 | + case NM.DeviceType.UNUSED2: |
391 | + return _("Not used"); |
392 | + case NM.DeviceType.BT: |
393 | + return _("Bluetooth"); |
394 | + case NM.DeviceType.OLPC_MESH: |
395 | + return _("OLPC XO"); |
396 | + case NM.DeviceType.WIMAX: |
397 | + return _("WiMAX Broadband"); |
398 | + case NM.DeviceType.MODEM: |
399 | + return _("Modem"); |
400 | + case NM.DeviceType.INFINIBAND: |
401 | + return _("InfiniBand device"); |
402 | + case NM.DeviceType.BOND: |
403 | + return _("Bond master"); |
404 | + case NM.DeviceType.VLAN: |
405 | + return _("VLAN Interface"); |
406 | + case NM.DeviceType.ADSL: |
407 | + return _("ADSL Modem"); |
408 | + case NM.DeviceType.BRIDGE: |
409 | + return _("Bridge master"); |
410 | + case NM.DeviceType.UNKNOWN: |
411 | + default: |
412 | + return _("Unknown"); |
413 | + } |
414 | } |
415 | } |
416 | } |
417 | |
418 | === modified file 'src/Widgets/Device/DeviceItem.vala' |
419 | --- src/Widgets/Device/DeviceItem.vala 2015-10-20 20:34:36 +0000 |
420 | +++ src/Widgets/Device/DeviceItem.vala 2015-11-07 23:35:34 +0000 |
421 | @@ -1,6 +1,6 @@ |
422 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
423 | /*- |
424 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
425 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
426 | * |
427 | * This library is free software; you can redistribute it and/or |
428 | * modify it under the terms of the GNU Library General Public |
429 | @@ -17,12 +17,13 @@ |
430 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
431 | * Boston, MA 02111-1307, USA. |
432 | * |
433 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
434 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
435 | */ |
436 | |
437 | namespace Network.Widgets { |
438 | public class DeviceItem : Gtk.ListBoxRow { |
439 | public NM.Device? device = null; |
440 | + private NM.RemoteSettings? nm_settings = null; |
441 | public Gtk.Box? page = null; |
442 | public Utils.ItemType type; |
443 | |
444 | @@ -30,7 +31,7 @@ |
445 | private Gtk.Image row_image; |
446 | private Gtk.Image status_image; |
447 | |
448 | - private string title; |
449 | + public string title; |
450 | private string subtitle; |
451 | private string icon_name; |
452 | |
453 | @@ -63,10 +64,15 @@ |
454 | this.icon_name = _icon_name; |
455 | |
456 | create_ui (icon_name); |
457 | - switch_status (device.get_state ()); |
458 | - |
459 | - device.state_changed.connect ( () => { |
460 | - switch_status (device.get_state ()); |
461 | + switch_status (Utils.CustomMode.INVALID, device.get_state ()); |
462 | + |
463 | + nm_settings = new NM.RemoteSettings (null); |
464 | + nm_settings.connections_read.connect (() => { |
465 | + switch_status (Utils.CustomMode.INVALID, device.get_state ()); |
466 | + }); |
467 | + |
468 | + device.state_changed.connect (() => { |
469 | + switch_status (Utils.CustomMode.INVALID, device.get_state ()); |
470 | }); |
471 | } |
472 | |
473 | @@ -120,8 +126,15 @@ |
474 | return icon_name; |
475 | } |
476 | |
477 | - public void switch_status (NM.DeviceState? state = null, string proxy_mode = "") { |
478 | + public void switch_status (Utils.CustomMode custom_mode, NM.DeviceState? state = null) { |
479 | if (state != null) { |
480 | + if (device != null |
481 | + && nm_settings != null |
482 | + && device is NM.DeviceWifi |
483 | + && Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)) { |
484 | + state = NM.DeviceState.DISCONNECTED; |
485 | + } |
486 | + |
487 | switch (state) { |
488 | case NM.DeviceState.ACTIVATED: |
489 | status_image.icon_name = "user-available"; |
490 | @@ -148,20 +161,25 @@ |
491 | row_description.label = Utils.state_to_string (state); |
492 | } |
493 | |
494 | - if (proxy_mode != "") { |
495 | - switch (proxy_mode) { |
496 | - case "none": |
497 | + if (custom_mode != Utils.CustomMode.INVALID) { |
498 | + switch (custom_mode) { |
499 | + case Utils.CustomMode.PROXY_NONE: |
500 | + case Utils.CustomMode.HOTSPOT_DISABLED: |
501 | row_description.label = _("Disabled"); |
502 | status_image.icon_name = "user-offline"; |
503 | break; |
504 | - case "manual": |
505 | + case Utils.CustomMode.PROXY_MANUAL: |
506 | row_description.label = _("Enabled (manual mode)"); |
507 | status_image.icon_name = "user-available"; |
508 | break; |
509 | - case "auto": |
510 | + case Utils.CustomMode.PROXY_AUTO: |
511 | row_description.label = _("Enabled (auto mode)"); |
512 | status_image.icon_name = "user-available"; |
513 | break; |
514 | + case Utils.CustomMode.HOTSPOT_ENABLED: |
515 | + row_description.label = _("Enabled"); |
516 | + status_image.icon_name = "user-available"; |
517 | + break; |
518 | } |
519 | } |
520 | |
521 | |
522 | === modified file 'src/Widgets/Device/DevicePage.vala' |
523 | --- src/Widgets/Device/DevicePage.vala 2015-10-08 19:04:34 +0000 |
524 | +++ src/Widgets/Device/DevicePage.vala 2015-11-07 23:35:34 +0000 |
525 | @@ -1,6 +1,6 @@ |
526 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
527 | /*- |
528 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
529 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
530 | * |
531 | * This library is free software; you can redistribute it and/or |
532 | * modify it under the terms of the GNU Library General Public |
533 | @@ -17,14 +17,14 @@ |
534 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
535 | * Boston, MA 02111-1307, USA. |
536 | * |
537 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
538 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
539 | */ |
540 | |
541 | namespace Network.Widgets { |
542 | public class DevicePage : Network.WidgetNMInterface { |
543 | |
544 | public DevicePage (NM.Client client, NM.RemoteSettings settings, NM.Device device) { |
545 | - info_box = new info_box.from_device (device); |
546 | + info_box = new InfoBox.from_device (device); |
547 | this.init (device, info_box); |
548 | |
549 | bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE; |
550 | @@ -45,7 +45,7 @@ |
551 | } |
552 | |
553 | public DevicePage.from_owner (DeviceItem? owner) { |
554 | - info_box = new info_box.from_owner (owner); |
555 | + info_box = new InfoBox.from_owner (owner); |
556 | this.init (owner.get_item_device (), info_box); |
557 | |
558 | this.icon_name = owner.get_item_icon_name (); |
559 | |
560 | === modified file 'src/Widgets/DeviceList.vala' |
561 | --- src/Widgets/DeviceList.vala 2015-10-22 17:08:56 +0000 |
562 | +++ src/Widgets/DeviceList.vala 2015-11-07 23:35:34 +0000 |
563 | @@ -1,6 +1,6 @@ |
564 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
565 | /*- |
566 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
567 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
568 | * |
569 | * This library is free software; you can redistribute it and/or |
570 | * modify it under the terms of the GNU Library General Public |
571 | @@ -17,59 +17,54 @@ |
572 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
573 | * Boston, MA 02111-1307, USA. |
574 | * |
575 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
576 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
577 | */ |
578 | |
579 | namespace Network.Widgets { |
580 | public class DeviceList : Gtk.ListBox { |
581 | public signal void show_no_devices (bool show); |
582 | - |
583 | - public NM.Client client; |
584 | - |
585 | - private List<DeviceItem> items; |
586 | - private DeviceItem item; |
587 | - |
588 | - private Gtk.Label settings_l; |
589 | + |
590 | + private Gtk.Label virtual_l; |
591 | private Gtk.Label devices_l; |
592 | private DeviceItem proxy; |
593 | |
594 | private int wireless_item = 0; |
595 | |
596 | public DeviceList () { |
597 | + virtual_l = new Gtk.Label (_("Virtual")); |
598 | + virtual_l.get_style_context ().add_class ("h4"); |
599 | + virtual_l.halign = Gtk.Align.START; |
600 | + |
601 | + devices_l = new Gtk.Label (_("Devices")); |
602 | + devices_l.get_style_context ().add_class ("h4"); |
603 | + devices_l.halign = Gtk.Align.START; |
604 | + |
605 | this.selection_mode = Gtk.SelectionMode.SINGLE; |
606 | this.activate_on_single_click = true; |
607 | this.set_header_func (update_headers); |
608 | - |
609 | - items = new List<DeviceItem> (); |
610 | - |
611 | - settings_l = new Gtk.Label (_("Virtual")); |
612 | - settings_l.get_style_context ().add_class ("h4"); |
613 | - settings_l.halign = Gtk.Align.START; |
614 | - |
615 | - devices_l = new Gtk.Label (_("Devices")); |
616 | - devices_l.get_style_context ().add_class ("h4"); |
617 | - devices_l.halign = Gtk.Align.START; |
618 | - |
619 | - bool show = (items.length () > 0); |
620 | + this.set_sort_func (sort_items); |
621 | + |
622 | + bool show = (get_children ().length () > 0); |
623 | this.show_no_devices (!show); |
624 | this.add_proxy (); |
625 | } |
626 | |
627 | public void add_device_to_list (WidgetNMInterface iface) { |
628 | + DeviceItem item; |
629 | + if (!iface.device.get_managed ()) { |
630 | + warning ("Unmanaged device, probably something that has just been added."); |
631 | + } |
632 | + |
633 | if (iface.device.get_device_type () == NM.DeviceType.WIFI) { |
634 | string title = _("Wireless"); |
635 | if (wireless_item > 0) { |
636 | - title += SUFFIX + wireless_item.to_string (); |
637 | + title = _("Wireless %s".printf (wireless_item.to_string ())); |
638 | } |
639 | |
640 | item = new DeviceItem.from_interface (iface, "network-wireless", title); |
641 | + add_hotspot (iface, wireless_item); |
642 | wireless_item++; |
643 | } else { |
644 | - |
645 | - if (!iface.device.get_managed ()) { |
646 | - warning ("Unmanaged device, probably something that has just been added."); |
647 | - } |
648 | - |
649 | if (iface.device.get_iface ().has_prefix ("usb")) { |
650 | item = new DeviceItem.from_interface (iface, "drive-removable-media"); |
651 | } else { |
652 | @@ -77,16 +72,15 @@ |
653 | } |
654 | } |
655 | |
656 | - items.append (item); |
657 | - insert (item, (int) items.length () - 1); |
658 | + add (item); |
659 | show_all (); |
660 | } |
661 | |
662 | public void remove_device_from_list (NM.Device device) { |
663 | - foreach (var list_item in items) { |
664 | + foreach (Gtk.Widget _list_item in get_children ()) { |
665 | + var list_item = (DeviceItem)_list_item; |
666 | if (list_item.device == device) { |
667 | remove_row_from_list (list_item); |
668 | - break; |
669 | } |
670 | } |
671 | } |
672 | @@ -96,14 +90,39 @@ |
673 | wireless_item--; |
674 | } |
675 | |
676 | - items.remove (item); |
677 | this.remove (item); |
678 | + show_all (); |
679 | + } |
680 | + |
681 | + private void add_hotspot (WidgetNMInterface iface, int wireless_item) { |
682 | + string title = _("Hotspot"); |
683 | + if (wireless_item > 0) { |
684 | + title = _("Hotspot %s".printf (wireless_item.to_string ())); |
685 | + } |
686 | + |
687 | + var hotspot = new DeviceItem (title, "", "network-wireless-hotspot"); |
688 | + hotspot.no_show_all = true; |
689 | + iface.device.state_changed.connect ((state) => { |
690 | + hotspot.visible = (state != NM.DeviceState.UNAVAILABLE |
691 | + && state != NM.DeviceState.UNMANAGED |
692 | + && state != NM.DeviceState.UNKNOWN); |
693 | + }); |
694 | + |
695 | + hotspot.device = iface.device; |
696 | + hotspot.type = Utils.ItemType.VIRTUAL; |
697 | + |
698 | + var hotspot_page = new HotspotPage (hotspot, ((WifiInterface)iface)); |
699 | + hotspot_page.title = title; |
700 | + hotspot.page = hotspot_page; |
701 | + |
702 | + this.add (hotspot); |
703 | } |
704 | |
705 | private void add_proxy () { |
706 | proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network"); |
707 | - proxy.page = new Widgets.ProxyPage (proxy); |
708 | - proxy.type = Utils.ItemType.PROXY; |
709 | + proxy.page = new ProxyPage (proxy); |
710 | + proxy.type = Utils.ItemType.VIRTUAL; |
711 | + |
712 | this.add (proxy); |
713 | } |
714 | |
715 | @@ -111,14 +130,43 @@ |
716 | this.get_row_at_index (0).activate (); |
717 | } |
718 | |
719 | + private int sort_items (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) { |
720 | + if (((DeviceItem) row1).type == Utils.ItemType.DEVICE) { |
721 | + return -1; |
722 | + } else if (((DeviceItem) row1).type == Utils.ItemType.VIRTUAL) { |
723 | + return 1; |
724 | + } else { |
725 | + return 0; |
726 | + } |
727 | + } |
728 | + |
729 | private void update_headers (Gtk.ListBoxRow row, Gtk.ListBoxRow? before = null) { |
730 | - if (((DeviceItem) row).type != Utils.ItemType.DEVICE) { |
731 | - row.set_header (settings_l); |
732 | - } else if (row == items.nth_data (0)) { |
733 | + if (((DeviceItem) row).type == Utils.ItemType.VIRTUAL) { |
734 | + if (before != null && ((DeviceItem) before).type == Utils.ItemType.VIRTUAL) { |
735 | + return; |
736 | + } |
737 | + |
738 | + remove_headers_for_type (Utils.ItemType.VIRTUAL); |
739 | + row.set_header (virtual_l); |
740 | + } else if (((DeviceItem) row).type == Utils.ItemType.DEVICE) { |
741 | + if (before != null && ((DeviceItem) before).type == Utils.ItemType.DEVICE) { |
742 | + return; |
743 | + } |
744 | + |
745 | + remove_headers_for_type (Utils.ItemType.DEVICE); |
746 | row.set_header (devices_l); |
747 | } else { |
748 | row.set_header (null); |
749 | } |
750 | } |
751 | + |
752 | + private void remove_headers_for_type (Utils.ItemType type) { |
753 | + foreach (Gtk.Widget _item in get_children ()) { |
754 | + var item = (DeviceItem)_item; |
755 | + if (item.type == type) { |
756 | + item.set_header (null); |
757 | + } |
758 | + } |
759 | + } |
760 | } |
761 | } |
762 | |
763 | === modified file 'src/Widgets/Footer.vala' |
764 | --- src/Widgets/Footer.vala 2015-10-08 17:08:13 +0000 |
765 | +++ src/Widgets/Footer.vala 2015-11-07 23:35:34 +0000 |
766 | @@ -1,6 +1,6 @@ |
767 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
768 | /*- |
769 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
770 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
771 | * |
772 | * This library is free software; you can redistribute it and/or |
773 | * modify it under the terms of the GNU Library General Public |
774 | @@ -17,7 +17,7 @@ |
775 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
776 | * Boston, MA 02111-1307, USA. |
777 | * |
778 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
779 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
780 | */ |
781 | |
782 | namespace Network { |
783 | |
784 | === added directory 'src/Widgets/Hotspot' |
785 | === added file 'src/Widgets/Hotspot/HotspotDialog.vala' |
786 | --- src/Widgets/Hotspot/HotspotDialog.vala 1970-01-01 00:00:00 +0000 |
787 | +++ src/Widgets/Hotspot/HotspotDialog.vala 2015-11-07 23:35:34 +0000 |
788 | @@ -0,0 +1,230 @@ |
789 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
790 | +/*- |
791 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
792 | + * |
793 | + * This library is free software; you can redistribute it and/or |
794 | + * modify it under the terms of the GNU Library General Public |
795 | + * License as published by the Free Software Foundation; either |
796 | + * version 3 of the License, or (at your option) any later version. |
797 | + * |
798 | + * This library is distributed in the hope that it will be useful, |
799 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
800 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
801 | + * Library General Public License for more details. |
802 | + * |
803 | + * You should have received a copy of the GNU Library General Public |
804 | + * License along with this library; if not, write to the |
805 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
806 | + * Boston, MA 02111-1307, USA. |
807 | + * |
808 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
809 | + */ |
810 | + |
811 | +namespace Network.Widgets { |
812 | + public class HotspotDialog : Gtk.Dialog { |
813 | + private const string NEW_ID = "0"; |
814 | + private Gtk.Entry ssid_entry; |
815 | + private Gtk.Entry key_entry; |
816 | + |
817 | + private Gtk.Label ssid_label; |
818 | + private Gtk.Label key_label; |
819 | + |
820 | + private Gtk.ComboBoxText conn_combo; |
821 | + |
822 | + private Gtk.CheckButton check_btn; |
823 | + private Gtk.Label dumb; |
824 | + |
825 | + private Gtk.Button create_btn; |
826 | + |
827 | + private HashTable<string, NM.Connection> conn_hash; |
828 | + private unowned List<NM.Connection> available; |
829 | + |
830 | + public HotspotDialog (NM.AccessPoint? active, List<NM.Connection> _available) { |
831 | + this.available = _available; |
832 | + this.deletable = false; |
833 | + this.resizable = false; |
834 | + this.border_width = 6; |
835 | + |
836 | + conn_hash = new HashTable<string, NM.Connection> (str_hash, str_equal); |
837 | + |
838 | + var content_area = this.get_content_area (); |
839 | + content_area.halign = content_area.valign = Gtk.Align.CENTER; |
840 | + |
841 | + var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); |
842 | + var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); |
843 | + |
844 | + vbox.margin_left = vbox.margin_right = 6; |
845 | + |
846 | + string? ssid_str = null; |
847 | + if (active != null) { |
848 | + ssid_str = NM.Utils.ssid_to_utf8 (active.get_ssid ()); |
849 | + } else { |
850 | + ssid_str = _("current"); |
851 | + } |
852 | + |
853 | + var title = new Gtk.Label ("<span weight='bold' size='larger'>" + _("Wireless Hotspot") + "</span>"); |
854 | + title.use_markup = true; |
855 | + title.halign = Gtk.Align.START; |
856 | + |
857 | + var image = new Gtk.Image.from_icon_name ("network-wireless-hotspot", Gtk.IconSize.DIALOG); |
858 | + image.valign = Gtk.Align.START; |
859 | + main_box.add (image); |
860 | + |
861 | + var info_label = new Gtk.Label (_("Enabling Wireless Hotspot will disconnect from %s network.").printf (ssid_str) + "\n" + |
862 | + _("You will not be able to connect to a wireless network while Hotspot is active.")); |
863 | + info_label.halign = Gtk.Align.START; |
864 | + info_label.margin_top = 6; |
865 | + info_label.use_markup = true; |
866 | + |
867 | + var grid = new Gtk.Grid (); |
868 | + grid.hexpand = true; |
869 | + grid.row_spacing = 6; |
870 | + grid.column_spacing = 12; |
871 | + grid.vexpand_set = true; |
872 | + |
873 | + ssid_entry = new Gtk.Entry (); |
874 | + ssid_entry.hexpand = true; |
875 | + ssid_entry.text = get_ssid_for_hotspot (); |
876 | + |
877 | + key_entry = new Gtk.Entry (); |
878 | + key_entry.hexpand = true; |
879 | + key_entry.visibility = false; |
880 | + key_entry.secondary_icon_tooltip_text = _("Password needs to be at least 8 characters long."); |
881 | + |
882 | + check_btn = new Gtk.CheckButton.with_label (_("Show Password")); |
883 | + check_btn.toggled.connect (() => { |
884 | + key_entry.visibility = check_btn.active; |
885 | + }); |
886 | + |
887 | + ssid_entry.changed.connect (update); |
888 | + key_entry.changed.connect (update); |
889 | + |
890 | + ssid_label = new Gtk.Label (_("Network Name:")); |
891 | + ssid_label.halign = Gtk.Align.END; |
892 | + |
893 | + key_label = new Gtk.Label (_("Password:")); |
894 | + key_label.halign = Gtk.Align.END; |
895 | + |
896 | + conn_combo = new Gtk.ComboBoxText (); |
897 | + conn_combo.append (NEW_ID, _("New…")); |
898 | + int i = 1; |
899 | + foreach (var connection in available) { |
900 | + var setting_wireless = connection.get_setting_wireless (); |
901 | + conn_combo.append (i.to_string (), NM.Utils.ssid_to_utf8 (setting_wireless.get_ssid ())); |
902 | + conn_hash.insert (i.to_string (), connection); |
903 | + i++; |
904 | + } |
905 | + |
906 | + conn_combo.active_id = NEW_ID; |
907 | + conn_combo.changed.connect (update); |
908 | + |
909 | + var conn_label = new Gtk.Label (_("Connection:")); |
910 | + conn_label.halign = Gtk.Align.END; |
911 | + |
912 | + grid.attach (conn_label, 0, 0, 1, 1); |
913 | + grid.attach_next_to (conn_combo, conn_label, Gtk.PositionType.RIGHT, 1, 1); |
914 | + |
915 | + dumb = new Gtk.Label (""); |
916 | + |
917 | + grid.attach_next_to (ssid_label, conn_label, Gtk.PositionType.BOTTOM, 1, 1); |
918 | + grid.attach_next_to (ssid_entry, ssid_label, Gtk.PositionType.RIGHT, 1, 1); |
919 | + grid.attach_next_to (key_label, ssid_label, Gtk.PositionType.BOTTOM, 1, 1); |
920 | + grid.attach_next_to (key_entry, key_label, Gtk.PositionType.RIGHT, 1, 1); |
921 | + grid.attach_next_to (dumb, key_label, Gtk.PositionType.BOTTOM, 1, 1); |
922 | + grid.attach_next_to (check_btn, dumb, Gtk.PositionType.RIGHT, 1, 1); |
923 | + |
924 | + var cancel_btn = new Gtk.Button.with_label (_("Cancel")); |
925 | + create_btn = new Gtk.Button.with_label (_("Enable Hotspot")); |
926 | + if (active != null) { |
927 | + create_btn.label = _("Switch to Hotspot"); |
928 | + } |
929 | + |
930 | + create_btn.get_style_context ().add_class ("suggested-action"); |
931 | + |
932 | + this.add_action_widget (cancel_btn, 0); |
933 | + this.add_action_widget (create_btn, 1); |
934 | + |
935 | + vbox.add (title); |
936 | + vbox.add (info_label); |
937 | + vbox.add (grid); |
938 | + |
939 | + update (); |
940 | + |
941 | + main_box.add (vbox); |
942 | + content_area.add (main_box); |
943 | + this.show_all (); |
944 | + } |
945 | + |
946 | + public ByteArray get_ssid () { |
947 | + var byte_array = new ByteArray (); |
948 | + byte_array.append (ssid_entry.get_text ().data); |
949 | + return byte_array; |
950 | + } |
951 | + |
952 | + public string get_key () { |
953 | + return key_entry.get_text (); |
954 | + } |
955 | + |
956 | + public NM.Connection? get_selected_connection () { |
957 | + return conn_hash[conn_combo.get_active_id ()]; |
958 | + } |
959 | + |
960 | + private string get_ssid_for_hotspot () { |
961 | + string hostname = ""; |
962 | + try { |
963 | + Process.spawn_command_line_sync ("hostname", out hostname, null, null); |
964 | + } catch (SpawnError e) { |
965 | + warning ("%s\n", e.message); |
966 | + } |
967 | + |
968 | + return hostname.strip ().replace ("\n", ""); |
969 | + } |
970 | + |
971 | + private void update () { |
972 | + bool sensitive = (conn_combo.get_active_id () == NEW_ID); |
973 | + ssid_label.sensitive = sensitive; |
974 | + key_label.sensitive = sensitive; |
975 | + |
976 | + ssid_entry.sensitive = sensitive; |
977 | + key_entry.sensitive = sensitive; |
978 | + |
979 | + check_btn.sensitive = sensitive; |
980 | + dumb.sensitive = sensitive; |
981 | + |
982 | + string? secret = null; |
983 | + if (get_selected_connection () != null) { |
984 | + var setting_wireless_security = get_selected_connection ().get_setting_wireless_security (); |
985 | + |
986 | + string key_mgmt = setting_wireless_security.get_key_mgmt (); |
987 | + if (key_mgmt == "none") { |
988 | + secret = setting_wireless_security.get_wep_key (0); |
989 | + } else if (key_mgmt == "wpa-psk" || |
990 | + key_mgmt == "wpa-none") { |
991 | + secret = setting_wireless_security.get_psk (); |
992 | + } |
993 | + |
994 | + if (secret == null) { |
995 | + var connection = get_selected_connection (); |
996 | + Utils.Hotspot.update_secrets (((NM.RemoteConnection) connection), update); |
997 | + } |
998 | + } |
999 | + |
1000 | + if (conn_combo.get_active_id () != NEW_ID) { |
1001 | + ssid_entry.text = NM.Utils.ssid_to_utf8 (get_selected_connection ().get_setting_wireless ().get_ssid ()); |
1002 | + if (secret == null) { |
1003 | + secret = ""; |
1004 | + } |
1005 | + |
1006 | + key_entry.text = secret; |
1007 | + } |
1008 | + |
1009 | + create_btn.sensitive = ((ssid_entry.get_text () != "" && key_entry.get_text ().to_utf8 ().length >= 8) || !sensitive); |
1010 | + |
1011 | + if (key_entry.get_text ().to_utf8 ().length < 8 && key_entry.get_text () != "") { |
1012 | + key_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "process-error-symbolic"); |
1013 | + } else { |
1014 | + key_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, ""); |
1015 | + } |
1016 | + } |
1017 | + } |
1018 | +} |
1019 | \ No newline at end of file |
1020 | |
1021 | === added file 'src/Widgets/Hotspot/HotspotPage.vala' |
1022 | --- src/Widgets/Hotspot/HotspotPage.vala 1970-01-01 00:00:00 +0000 |
1023 | +++ src/Widgets/Hotspot/HotspotPage.vala 2015-11-07 23:35:34 +0000 |
1024 | @@ -0,0 +1,174 @@ |
1025 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1026 | +/*- |
1027 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1028 | + * |
1029 | + * This library is free software; you can redistribute it and/or |
1030 | + * modify it under the terms of the GNU Library General Public |
1031 | + * License as published by the Free Software Foundation; either |
1032 | + * version 3 of the License, or (at your option) any later version. |
1033 | + * |
1034 | + * This library is distributed in the hope that it will be useful, |
1035 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1036 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1037 | + * Library General Public License for more details. |
1038 | + * |
1039 | + * You should have received a copy of the GNU Library General Public |
1040 | + * License along with this library; if not, write to the |
1041 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1042 | + * Boston, MA 02111-1307, USA. |
1043 | + * |
1044 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1045 | + */ |
1046 | + |
1047 | + namespace Network.Widgets { |
1048 | + public class HotspotPage : Network.WidgetNMInterface { |
1049 | + private DeviceItem owner; |
1050 | + |
1051 | + private WifiInterface root_iface; |
1052 | + private NM.RemoteSettings nm_settings; |
1053 | + private Gtk.Revealer hotspot_revealer; |
1054 | + private Gtk.Button hotspot_settings_btn; |
1055 | + private Gtk.Label ssid_label; |
1056 | + private Gtk.Label key_label; |
1057 | + private bool switch_updating = false; |
1058 | + |
1059 | + public HotspotPage (DeviceItem _owner, WifiInterface _root_iface) { |
1060 | + owner = _owner; |
1061 | + root_iface = _root_iface; |
1062 | + nm_settings = root_iface.get_nm_settings (); |
1063 | + info_box = new InfoBox.from_device (owner.get_item_device ()); |
1064 | + this.init (owner.get_item_device (), info_box); |
1065 | + |
1066 | + this.icon_name = owner.get_item_icon_name (); |
1067 | + this.title = Utils.type_to_string (device.get_device_type ()); |
1068 | + |
1069 | + hotspot_revealer = new Gtk.Revealer (); |
1070 | + hotspot_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN; |
1071 | + |
1072 | + hotspot_settings_btn = Utils.get_advanced_button_from_device (device, _("Hotspot Settings…")); |
1073 | + |
1074 | + var hinfo_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); |
1075 | + |
1076 | + ssid_label = new Gtk.Label (""); |
1077 | + ssid_label.halign = Gtk.Align.START; |
1078 | + |
1079 | + key_label = new Gtk.Label (""); |
1080 | + key_label.halign = Gtk.Align.START; |
1081 | + |
1082 | + hinfo_box.add (ssid_label); |
1083 | + hinfo_box.add (key_label); |
1084 | + hotspot_revealer.add (hinfo_box); |
1085 | + |
1086 | + bottom_revealer = new Gtk.Revealer (); |
1087 | + |
1088 | + var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); |
1089 | + button_box.pack_end (hotspot_settings_btn, false, false, 0); |
1090 | + bottom_revealer.add (button_box); |
1091 | + |
1092 | + nm_settings.connections_read.connect (update); |
1093 | + device.state_changed.connect (update); |
1094 | + |
1095 | + update (); |
1096 | + |
1097 | + this.add (hotspot_revealer); |
1098 | + this.pack_end (bottom_revealer, false, false); |
1099 | + this.show_all (); |
1100 | + } |
1101 | + |
1102 | + protected override void update () { |
1103 | + if (hotspot_settings_btn != null) { |
1104 | + hotspot_settings_btn.sensitive = (Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)); |
1105 | + } |
1106 | + |
1107 | + update_hotspot_info (); |
1108 | + base.update (); |
1109 | + } |
1110 | + |
1111 | + protected override void update_switch () { |
1112 | + switch_updating = true; |
1113 | + control_switch.active = (Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)); |
1114 | + switch_updating = false; |
1115 | + } |
1116 | + |
1117 | + protected override void control_switch_activated () { |
1118 | + if (switch_updating) { |
1119 | + switch_updating = false; |
1120 | + return; |
1121 | + } |
1122 | + |
1123 | + var wifi_device = (NM.DeviceWifi)device; |
1124 | + if (!control_switch.active && Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) { |
1125 | + Utils.Hotspot.deactivate_hotspot (wifi_device); |
1126 | + } else { |
1127 | + var hotspot_dialog = new HotspotDialog (wifi_device.get_active_access_point (), get_hotspot_connections ()); |
1128 | + hotspot_dialog.response.connect ((response) => { |
1129 | + if (response == 1) { |
1130 | + Utils.Hotspot.activate_hotspot (wifi_device, |
1131 | + hotspot_dialog.get_ssid (), |
1132 | + hotspot_dialog.get_key (), |
1133 | + hotspot_dialog.get_selected_connection ()); |
1134 | + |
1135 | + } |
1136 | + }); |
1137 | + |
1138 | + hotspot_dialog.run (); |
1139 | + hotspot_dialog.destroy (); |
1140 | + } |
1141 | + } |
1142 | + |
1143 | + private void update_hotspot_info () { |
1144 | + var wifi_device = (NM.DeviceWifi)device; |
1145 | + bool hotspot_mode = Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings); |
1146 | + |
1147 | + var mode = Utils.CustomMode.HOTSPOT_DISABLED; |
1148 | + if (hotspot_mode) { |
1149 | + mode = Utils.CustomMode.HOTSPOT_ENABLED; |
1150 | + } |
1151 | + |
1152 | + owner.switch_status (mode); |
1153 | + |
1154 | + hotspot_revealer.set_reveal_child (hotspot_mode); |
1155 | + |
1156 | + if (hotspot_mode) { |
1157 | + var connection = nm_settings.get_connection_by_path (wifi_device.get_active_connection ().get_connection ()); |
1158 | + |
1159 | + var setting_wireless = connection.get_setting_wireless (); |
1160 | + ssid_label.label = _("Network Name (SSID): %s").printf (NM.Utils.ssid_to_utf8 (setting_wireless.get_ssid ())); |
1161 | + |
1162 | + var setting_wireless_security = connection.get_setting_wireless_security (); |
1163 | + |
1164 | + string key_mgmt = setting_wireless_security.get_key_mgmt (); |
1165 | + string? secret = null; |
1166 | + string security = ""; |
1167 | + if (key_mgmt == "none") { |
1168 | + secret = setting_wireless_security.get_wep_key (0); |
1169 | + security = _("(WEP)"); |
1170 | + } else if (key_mgmt == "wpa-psk" || |
1171 | + key_mgmt == "wpa-none") { |
1172 | + security = _("(WPA)"); |
1173 | + secret = setting_wireless_security.get_psk (); |
1174 | + } |
1175 | + |
1176 | + if (secret == null) { |
1177 | + Utils.Hotspot.update_secrets (connection, update); |
1178 | + return; |
1179 | + } |
1180 | + |
1181 | + key_label.label = _("Password %s: %s").printf (security, secret); |
1182 | + } |
1183 | + } |
1184 | + |
1185 | + private List<NM.Connection> get_hotspot_connections () { |
1186 | + var list = new List<NM.Connection> (); |
1187 | + var connections = nm_settings.list_connections (); |
1188 | + |
1189 | + foreach (var connection in connections) { |
1190 | + if (Utils.Hotspot.get_connection_is_hotspot (connection)) { |
1191 | + list.append (connection); |
1192 | + } |
1193 | + } |
1194 | + |
1195 | + return list; |
1196 | + } |
1197 | + } |
1198 | +} |
1199 | |
1200 | === modified file 'src/Widgets/InfoBox.vala' |
1201 | --- src/Widgets/InfoBox.vala 2015-10-20 20:34:36 +0000 |
1202 | +++ src/Widgets/InfoBox.vala 2015-11-07 23:35:34 +0000 |
1203 | @@ -1,6 +1,6 @@ |
1204 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1205 | /*- |
1206 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
1207 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1208 | * |
1209 | * This library is free software; you can redistribute it and/or |
1210 | * modify it under the terms of the GNU Library General Public |
1211 | @@ -17,7 +17,7 @@ |
1212 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1213 | * Boston, MA 02111-1307, USA. |
1214 | * |
1215 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
1216 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1217 | */ |
1218 | |
1219 | namespace Network.Widgets { |
1220 | |
1221 | === modified file 'src/Widgets/InfoScreen.vala' |
1222 | --- src/Widgets/InfoScreen.vala 2015-07-18 16:56:50 +0000 |
1223 | +++ src/Widgets/InfoScreen.vala 2015-11-07 23:35:34 +0000 |
1224 | @@ -1,6 +1,6 @@ |
1225 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1226 | /*- |
1227 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
1228 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1229 | * |
1230 | * This library is free software; you can redistribute it and/or |
1231 | * modify it under the terms of the GNU Library General Public |
1232 | @@ -17,7 +17,7 @@ |
1233 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1234 | * Boston, MA 02111-1307, USA. |
1235 | * |
1236 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
1237 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1238 | */ |
1239 | |
1240 | namespace Network { |
1241 | |
1242 | === modified file 'src/Widgets/Page.vala' |
1243 | --- src/Widgets/Page.vala 2015-10-09 19:12:42 +0000 |
1244 | +++ src/Widgets/Page.vala 2015-11-07 23:35:34 +0000 |
1245 | @@ -1,6 +1,6 @@ |
1246 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1247 | /*- |
1248 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
1249 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1250 | * |
1251 | * This library is free software; you can redistribute it and/or |
1252 | * modify it under the terms of the GNU Library General Public |
1253 | |
1254 | === modified file 'src/Widgets/Proxy/ProxyConfigurationPage.vala' |
1255 | --- src/Widgets/Proxy/ProxyConfigurationPage.vala 2015-10-09 19:12:42 +0000 |
1256 | +++ src/Widgets/Proxy/ProxyConfigurationPage.vala 2015-11-07 23:35:34 +0000 |
1257 | @@ -1,5 +1,26 @@ |
1258 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1259 | +/*- |
1260 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1261 | + * |
1262 | + * This library is free software; you can redistribute it and/or |
1263 | + * modify it under the terms of the GNU Library General Public |
1264 | + * License as published by the Free Software Foundation; either |
1265 | + * version 3 of the License, or (at your option) any later version. |
1266 | + * |
1267 | + * This library is distributed in the hope that it will be useful, |
1268 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1269 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1270 | + * Library General Public License for more details. |
1271 | + * |
1272 | + * You should have received a copy of the GNU Library General Public |
1273 | + * License along with this library; if not, write to the |
1274 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1275 | + * Boston, MA 02111-1307, USA. |
1276 | + * |
1277 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
1278 | + */ |
1279 | + |
1280 | namespace Network.Widgets { |
1281 | - |
1282 | public class ConfigurationPage : Gtk.Box { |
1283 | private const string DEFAULT_PROXY = "host:port"; |
1284 | private bool syntax_error = false; |
1285 | |
1286 | === modified file 'src/Widgets/Proxy/ProxyExceptionsPage.vala' |
1287 | --- src/Widgets/Proxy/ProxyExceptionsPage.vala 2015-08-03 00:16:24 +0000 |
1288 | +++ src/Widgets/Proxy/ProxyExceptionsPage.vala 2015-11-07 23:35:34 +0000 |
1289 | @@ -1,3 +1,25 @@ |
1290 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1291 | +/*- |
1292 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1293 | + * |
1294 | + * This library is free software; you can redistribute it and/or |
1295 | + * modify it under the terms of the GNU Library General Public |
1296 | + * License as published by the Free Software Foundation; either |
1297 | + * version 3 of the License, or (at your option) any later version. |
1298 | + * |
1299 | + * This library is distributed in the hope that it will be useful, |
1300 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1301 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1302 | + * Library General Public License for more details. |
1303 | + * |
1304 | + * You should have received a copy of the GNU Library General Public |
1305 | + * License along with this library; if not, write to the |
1306 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1307 | + * Boston, MA 02111-1307, USA. |
1308 | + * |
1309 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1310 | + */ |
1311 | + |
1312 | namespace Network.Widgets { |
1313 | public class ExecepionsPage : Gtk.Box { |
1314 | private Gtk.ListBox ignored_list; |
1315 | |
1316 | === modified file 'src/Widgets/Proxy/ProxyPage.vala' |
1317 | --- src/Widgets/Proxy/ProxyPage.vala 2015-10-20 20:34:36 +0000 |
1318 | +++ src/Widgets/Proxy/ProxyPage.vala 2015-11-07 23:35:34 +0000 |
1319 | @@ -1,3 +1,26 @@ |
1320 | +// -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1321 | +/*- |
1322 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1323 | + * |
1324 | + * This library is free software; you can redistribute it and/or |
1325 | + * modify it under the terms of the GNU Library General Public |
1326 | + * License as published by the Free Software Foundation; either |
1327 | + * version 3 of the License, or (at your option) any later version. |
1328 | + * |
1329 | + * This library is distributed in the hope that it will be useful, |
1330 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1331 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
1332 | + * Library General Public License for more details. |
1333 | + * |
1334 | + * You should have received a copy of the GNU Library General Public |
1335 | + * License along with this library; if not, write to the |
1336 | + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1337 | + * Boston, MA 02111-1307, USA. |
1338 | + * |
1339 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1340 | + */ |
1341 | + |
1342 | + |
1343 | namespace Network.Widgets { |
1344 | public class ProxyPage : Gtk.Box { |
1345 | public Gtk.Stack stack; |
1346 | @@ -34,7 +57,23 @@ |
1347 | } |
1348 | |
1349 | public void update_mode () { |
1350 | - owner.switch_status (null, proxy_settings.mode); |
1351 | + var mode = Utils.CustomMode.INVALID; |
1352 | + switch (proxy_settings.mode) { |
1353 | + case "none": |
1354 | + mode = Utils.CustomMode.PROXY_NONE; |
1355 | + break; |
1356 | + case "manual": |
1357 | + mode = Utils.CustomMode.PROXY_MANUAL; |
1358 | + break; |
1359 | + case "auto": |
1360 | + mode = Utils.CustomMode.PROXY_AUTO; |
1361 | + break; |
1362 | + default: |
1363 | + mode = Utils.CustomMode.INVALID; |
1364 | + break; |
1365 | + } |
1366 | + |
1367 | + owner.switch_status (mode); |
1368 | } |
1369 | } |
1370 | } |
1371 | |
1372 | === modified file 'src/Widgets/WifiInterface.vala' |
1373 | --- src/Widgets/WifiInterface.vala 2015-10-09 19:12:42 +0000 |
1374 | +++ src/Widgets/WifiInterface.vala 2015-11-07 23:35:34 +0000 |
1375 | @@ -1,6 +1,6 @@ |
1376 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1377 | /*- |
1378 | - * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) |
1379 | + * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1380 | * |
1381 | * This library is free software; you can redistribute it and/or |
1382 | * modify it under the terms of the GNU Library General Public |
1383 | @@ -17,7 +17,7 @@ |
1384 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1385 | * Boston, MA 02111-1307, USA. |
1386 | * |
1387 | - * Authored by: Adam Bieńkowski <donadigos159@gmail.com |
1388 | + * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1389 | */ |
1390 | |
1391 | using Network.Widgets; |
1392 | @@ -25,6 +25,9 @@ |
1393 | namespace Network { |
1394 | public class WifiInterface : AbstractWifiInterface { |
1395 | protected Gtk.Frame connected_frame; |
1396 | + protected Gtk.Stack list_stack; |
1397 | + protected Gtk.ScrolledWindow scrolled; |
1398 | + protected Gtk.Box hotspot_mode_box; |
1399 | protected Gtk.Box? connected_box = null; |
1400 | protected Gtk.Revealer top_revealer; |
1401 | protected Gtk.Button disconnect_btn; |
1402 | @@ -32,17 +35,10 @@ |
1403 | protected Gtk.ToggleButton info_btn; |
1404 | protected Gtk.Popover popover; |
1405 | |
1406 | - public WifiInterface (NM.Client nm_client, NM.RemoteSettings settings, NM.Device device_) { |
1407 | - info_box = new InfoBox.from_device (device_); |
1408 | + public WifiInterface (NM.Client nm_client, NM.RemoteSettings settings, NM.Device _device) { |
1409 | + info_box = new InfoBox.from_device (_device); |
1410 | info_box.margin = 12; |
1411 | - this.init (device_, info_box); |
1412 | - |
1413 | - var css_provider = new Gtk.CssProvider (); |
1414 | - try { |
1415 | - css_provider.load_from_data ("GtkFrame {\nbackground: #ffffff;\n}", -1); |
1416 | - } catch (Error e) { |
1417 | - warning ("%s\n", e.message); |
1418 | - } |
1419 | + this.init (_device, info_box); |
1420 | |
1421 | popover = new Gtk.Popover (info_btn); |
1422 | popover.position = Gtk.PositionType.BOTTOM; |
1423 | @@ -52,13 +48,13 @@ |
1424 | }); |
1425 | |
1426 | connected_frame = new Gtk.Frame (null); |
1427 | - connected_frame.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); |
1428 | + connected_frame.override_background_color (0, { 255, 255, 255, 255 }); |
1429 | |
1430 | top_revealer = new Gtk.Revealer (); |
1431 | top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN; |
1432 | top_revealer.add (connected_frame); |
1433 | |
1434 | - init_wifi_interface (nm_client, settings, device_); |
1435 | + init_wifi_interface (nm_client, settings, device); |
1436 | |
1437 | this.icon_name = "network-wireless"; |
1438 | this.title = _("Wireless"); |
1439 | @@ -66,15 +62,35 @@ |
1440 | |
1441 | control_box.margin_bottom = 12; |
1442 | |
1443 | + list_stack = new Gtk.Stack (); |
1444 | + |
1445 | + hotspot_mode_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); |
1446 | + hotspot_mode_box.visible = true; |
1447 | + hotspot_mode_box.valign = Gtk.Align.CENTER; |
1448 | + |
1449 | + var main_frame = new Gtk.Frame (null); |
1450 | + main_frame.margin_bottom = 24; |
1451 | + main_frame.margin_top = 12; |
1452 | + main_frame.vexpand = true; |
1453 | + main_frame.override_background_color (0, { 255, 255, 255, 255 }); |
1454 | + |
1455 | + var hotspot_mode = construct_placeholder_label (_("This device is in Hotspot Mode"), true); |
1456 | + var hotspot_mode_desc = construct_placeholder_label (_("Turn off the Hotspot Mode to connect to other Access Points."), false); |
1457 | + hotspot_mode_box.add (hotspot_mode); |
1458 | + hotspot_mode_box.add (hotspot_mode_desc); |
1459 | + |
1460 | wifi_list.selection_mode = Gtk.SelectionMode.SINGLE; |
1461 | - wifi_list.activate_on_single_click = false; |
1462 | + wifi_list.activate_on_single_click = false; |
1463 | + wifi_list.visible = true; |
1464 | |
1465 | - var scrolled = new Gtk.ScrolledWindow (null, null); |
1466 | - scrolled.margin_bottom = 24; |
1467 | - scrolled.margin_top = 12; |
1468 | + scrolled = new Gtk.ScrolledWindow (null, null); |
1469 | scrolled.add (wifi_list); |
1470 | - scrolled.vexpand = true; |
1471 | - scrolled.shadow_type = Gtk.ShadowType.OUT; |
1472 | + |
1473 | + list_stack.add (hotspot_mode_box); |
1474 | + list_stack.add (scrolled); |
1475 | + list_stack.visible_child = scrolled; |
1476 | + |
1477 | + main_frame.add (list_stack); |
1478 | |
1479 | var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); |
1480 | |
1481 | @@ -83,14 +99,18 @@ |
1482 | |
1483 | button_box.pack_start (hidden_btn, false, false, 0); |
1484 | |
1485 | - update (); |
1486 | - |
1487 | bottom_box.add (button_box); |
1488 | |
1489 | this.add (top_revealer); |
1490 | - this.add (scrolled); |
1491 | + this.add (main_frame); |
1492 | this.add (bottom_revealer); |
1493 | this.show_all (); |
1494 | + |
1495 | + update (); |
1496 | + } |
1497 | + |
1498 | + public NM.RemoteSettings get_nm_settings () { |
1499 | + return nm_settings; |
1500 | } |
1501 | |
1502 | public override void update () { |
1503 | @@ -111,7 +131,15 @@ |
1504 | |
1505 | base.update (); |
1506 | |
1507 | - top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null); |
1508 | + bool is_hotspot = Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings); |
1509 | + |
1510 | + top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null && !is_hotspot); |
1511 | + |
1512 | + if (is_hotspot) { |
1513 | + list_stack.visible_child = hotspot_mode_box; |
1514 | + } else { |
1515 | + list_stack.visible_child = scrolled; |
1516 | + } |
1517 | |
1518 | if (wifi_device.get_active_access_point () == null && old_active != null) { |
1519 | old_active.no_show_all = false; |
1520 | @@ -186,7 +214,7 @@ |
1521 | |
1522 | protected override void control_switch_activated () { |
1523 | var active = control_switch.active; |
1524 | - if (active != !software_locked) { |
1525 | + if (active == software_locked) { |
1526 | rfkill.set_software_lock (RFKillDeviceType.WLAN, !active); |
1527 | client.wireless_set_enabled (active); |
1528 | } |
1529 | |
1530 | === modified file 'src/common/Widgets/AbstractWifiInterface.vala' |
1531 | --- src/common/Widgets/AbstractWifiInterface.vala 2015-10-22 16:46:13 +0000 |
1532 | +++ src/common/Widgets/AbstractWifiInterface.vala 2015-11-07 23:35:34 +0000 |
1533 | @@ -39,7 +39,7 @@ |
1534 | this.nm_client = nm_client; |
1535 | this.nm_settings = nm_settings; |
1536 | device = _device; |
1537 | - wifi_device = device as NM.DeviceWifi; |
1538 | + wifi_device = (NM.DeviceWifi)device; |
1539 | blank_item = new WifiMenuItem.blank (); |
1540 | active_wifi_item = null; |
1541 | |
1542 | @@ -82,7 +82,6 @@ |
1543 | scanning_box.visible = true; |
1544 | scanning_box.valign = Gtk.Align.CENTER; |
1545 | |
1546 | - |
1547 | placeholder.add_named (no_aps_box, "no-aps"); |
1548 | placeholder.add_named (wireless_off_box, "wireless-off"); |
1549 | placeholder.add_named (scanning_box, "scanning"); |
1550 | @@ -99,7 +98,9 @@ |
1551 | rfkill.device_changed.connect (update); |
1552 | rfkill.device_deleted.connect (update); |
1553 | |
1554 | - wifi_device.notify["active-access-point"].connect (() => { update (); }); |
1555 | + nm_settings.connections_read.connect (update); |
1556 | + |
1557 | + wifi_device.notify["active-access-point"].connect (update); |
1558 | wifi_device.access_point_added.connect (access_point_added_cb); |
1559 | wifi_device.access_point_removed.connect (access_point_removed_cb); |
1560 | wifi_device.state_changed.connect (update); |
1561 | @@ -112,7 +113,7 @@ |
1562 | update(); |
1563 | } |
1564 | |
1565 | - Gtk.Label construct_placeholder_label (string text, bool title) { |
1566 | + protected Gtk.Label construct_placeholder_label (string text, bool title) { |
1567 | var label = new Gtk.Label (text); |
1568 | label.visible = true; |
1569 | label.use_markup = true; |
1570 | @@ -157,7 +158,6 @@ |
1571 | item.user_action.connect (wifi_activate_cb); |
1572 | |
1573 | wifi_list.add (item); |
1574 | - |
1575 | wifi_list.show_all (); |
1576 | |
1577 | update (); |
1578 | @@ -241,6 +241,13 @@ |
1579 | } |
1580 | |
1581 | public override void update () { |
1582 | +#if PLUG_NETWORK |
1583 | + if (Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) { |
1584 | + state = State.DISCONNECTED; |
1585 | + return; |
1586 | + } |
1587 | +#endif |
1588 | + |
1589 | switch (wifi_device.state) { |
1590 | case NM.DeviceState.UNKNOWN: |
1591 | case NM.DeviceState.UNMANAGED: |
1592 | @@ -275,6 +282,7 @@ |
1593 | |
1594 | case NM.DeviceState.ACTIVATED: |
1595 | set_scan_placeholder (); |
1596 | + |
1597 | /* That can happen if active_ap has not been added yet, at startup. */ |
1598 | if (active_ap != null) { |
1599 | state = strength_to_state(active_ap.get_strength()); |
1600 | @@ -298,6 +306,7 @@ |
1601 | if (device.hardware_lock) |
1602 | hardware_locked = true; |
1603 | } |
1604 | + |
1605 | locked = hardware_locked || software_locked; |
1606 | |
1607 | update_active_ap (); |
1608 | @@ -319,6 +328,12 @@ |
1609 | cancel_scan (); |
1610 | wifi_device.request_scan_simple (null); |
1611 | timeout_scan = Timeout.add(5000, () => { |
1612 | +#if PLUG_NETWORK |
1613 | + if (Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) { |
1614 | + return false; |
1615 | + } |
1616 | +#endif |
1617 | + |
1618 | timeout_scan = 0; |
1619 | placeholder.visible_child_name = "no-aps"; |
1620 | return false; |
Your email address is missing the closing ">"