1 |
commit: c4b935e51b5eb23600ff21c9407feb07f5ed06b1 |
2 |
Author: Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Feb 23 13:48:27 2011 +0000 |
4 |
Commit: Nirbheek Chauhan <nirbheek <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 23 14:09:12 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gnome.git;a=commit;h=c4b935e5 |
7 |
|
8 |
gnome-base/gnome-shell: update nm-applet patch, update networkmanager-9999 |
9 |
|
10 |
* New patch added to NM, needed for gnome-shell now |
11 |
|
12 |
--- |
13 |
...> gnome-shell-experimental-nm-applet-1.0.patch} | 1121 +++++++++++--------- |
14 |
gnome-base/gnome-shell/gnome-shell-9999.ebuild | 2 +- |
15 |
.../files/networkmanager-more-gi-annotations.patch | 43 + |
16 |
net-misc/networkmanager/networkmanager-9999.ebuild | 3 + |
17 |
4 files changed, 663 insertions(+), 506 deletions(-) |
18 |
|
19 |
diff --git a/gnome-base/gnome-shell/files/gnome-shell-experimental-nm-applet.patch b/gnome-base/gnome-shell/files/gnome-shell-experimental-nm-applet-1.0.patch |
20 |
similarity index 63% |
21 |
rename from gnome-base/gnome-shell/files/gnome-shell-experimental-nm-applet.patch |
22 |
rename to gnome-base/gnome-shell/files/gnome-shell-experimental-nm-applet-1.0.patch |
23 |
index 64aa99c..15a560b 100644 |
24 |
--- a/gnome-base/gnome-shell/files/gnome-shell-experimental-nm-applet.patch |
25 |
+++ b/gnome-base/gnome-shell/files/gnome-shell-experimental-nm-applet-1.0.patch |
26 |
@@ -1,4 +1,4 @@ |
27 |
-From 11400d81fd9775bac7db3e49e620004bb9d6fab5 Mon Sep 17 00:00:00 2001 |
28 |
+From f8a4fa0646aa4ab620331c0bbcae4334173b614d Mon Sep 17 00:00:00 2001 |
29 |
From: Giovanni Campagna <gcampagna@×××××××××.org> |
30 |
Date: Tue, 25 Jan 2011 22:08:12 +0100 |
31 |
Subject: [PATCH] Status area: add NetworkManager indicator |
32 |
@@ -10,15 +10,35 @@ dialogs. |
33 |
|
34 |
https://bugzilla.gnome.org/show_bug.cgi?id=621707 |
35 |
--- |
36 |
+ data/theme/gnome-shell.css | 8 + |
37 |
js/Makefile.am | 2 + |
38 |
- js/misc/modemManager.js | 93 +++ |
39 |
+ js/misc/modemManager.js | 103 +++ |
40 |
js/ui/panel.js | 3 +- |
41 |
- js/ui/status/network.js | 1656 +++++++++++++++++++++++++++++++++++++++ |
42 |
- tools/build/gnome-shell.modules | 19 + |
43 |
- 5 files changed, 1772 insertions(+), 1 deletions(-) |
44 |
+ js/ui/status/network.js | 1754 +++++++++++++++++++++++++++++++++++++++ |
45 |
+ tools/build/gnome-shell.modules | 17 + |
46 |
+ 6 files changed, 1886 insertions(+), 1 deletions(-) |
47 |
create mode 100644 js/misc/modemManager.js |
48 |
create mode 100644 js/ui/status/network.js |
49 |
|
50 |
+diff --git a/data/theme/gnome-shell.css b/data/theme/gnome-shell.css |
51 |
+index 1da6619..8f0fb52 100644 |
52 |
+--- a/data/theme/gnome-shell.css |
53 |
++++ b/data/theme/gnome-shell.css |
54 |
+@@ -154,6 +154,14 @@ StTooltip StLabel { |
55 |
+ spacing: .5em; |
56 |
+ } |
57 |
+ |
58 |
++.popup-inactive-menu-item { |
59 |
++ font-style: italic; |
60 |
++} |
61 |
++ |
62 |
++.popup-subtitle-menu-item { |
63 |
++ font-weight: bold; |
64 |
++} |
65 |
++ |
66 |
+ .popup-menu-icon { |
67 |
+ icon-size: 1.14em; |
68 |
+ } |
69 |
diff --git a/js/Makefile.am b/js/Makefile.am |
70 |
index e4a4145..53f80d4 100644 |
71 |
--- a/js/Makefile.am |
72 |
@@ -41,10 +61,10 @@ index e4a4145..53f80d4 100644 |
73 |
ui/status/bluetooth.js \ |
74 |
diff --git a/js/misc/modemManager.js b/js/misc/modemManager.js |
75 |
new file mode 100644 |
76 |
-index 0000000..104262b |
77 |
+index 0000000..b368511 |
78 |
--- /dev/null |
79 |
+++ b/js/misc/modemManager.js |
80 |
-@@ -0,0 +1,93 @@ |
81 |
+@@ -0,0 +1,103 @@ |
82 |
+// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- |
83 |
+const DBus = imports.dbus; |
84 |
+const Lang = imports.lang; |
85 |
@@ -56,15 +76,15 @@ index 0000000..104262b |
86 |
+const ModemGsmNetworkInterface = { |
87 |
+ name: 'org.freedesktop.ModemManager.Modem.Gsm.Network', |
88 |
+ methods: [ |
89 |
-+ { name: 'GetRegistrationInfo', inSignature: '', outSignature: 'uss' }, |
90 |
-+ { name: 'GetSignalQuality', inSignature: '', outSignature: 'u' }, |
91 |
++ { name: 'GetRegistrationInfo', inSignature: '', outSignature: 'uss' }, |
92 |
++ { name: 'GetSignalQuality', inSignature: '', outSignature: 'u' }, |
93 |
+ ], |
94 |
+ properties: [ |
95 |
-+ { name: 'AccessTechnology', signature: 'u', access: 'read' } |
96 |
++ { name: 'AccessTechnology', signature: 'u', access: 'read' } |
97 |
+ ], |
98 |
+ signals: [ |
99 |
-+ { name: 'SignalQuality', inSignature: 'u' }, |
100 |
-+ { name: 'RegistrationInfo', inSignature: 'uss' } |
101 |
++ { name: 'SignalQuality', inSignature: 'u' }, |
102 |
++ { name: 'RegistrationInfo', inSignature: 'uss' } |
103 |
+ ] |
104 |
+}; |
105 |
+const ModemGsmNetworkProxy = DBus.makeProxyClass(ModemGsmNetworkInterface); |
106 |
@@ -72,11 +92,11 @@ index 0000000..104262b |
107 |
+const ModemCdmaInterface = { |
108 |
+ name: 'org.freedesktop.ModemManager.Modem.Cdma', |
109 |
+ methods: [ |
110 |
-+ { name: 'GetSignalQuality', inSignature: '', outSignature: 'u' }, |
111 |
-+ { name: 'GetServingSystem', inSignature: '', outSignature: 'usu' }, |
112 |
++ { name: 'GetSignalQuality', inSignature: '', outSignature: 'u' }, |
113 |
++ { name: 'GetServingSystem', inSignature: '', outSignature: 'usu' }, |
114 |
+ ], |
115 |
+ signals: [ |
116 |
-+ { name: 'SignalQuality', inSignature: 'u' } |
117 |
++ { name: 'SignalQuality', inSignature: 'u' } |
118 |
+ ] |
119 |
+}; |
120 |
+const ModemCdmaProxy = DBus.makeProxyClass(ModemCdmaInterface); |
121 |
@@ -88,29 +108,37 @@ index 0000000..104262b |
122 |
+ |
123 |
+ModemGsm.prototype = { |
124 |
+ _init: function(path) { |
125 |
-+ this._proxy = new ModemGsmNetworkProxy(DBus.system, 'org.freedesktop.ModemManager', path); |
126 |
-+ |
127 |
-+ this.signal_quality = 0; |
128 |
-+ this.operator_name = null; |
129 |
-+ this._proxy.connect('SignalQuality', Lang.bind(this, this._qualityChanged)); |
130 |
-+ this._proxy.connect('RegistrationInfo', Lang.bind(this, this._registrationInfoChanged)); |
131 |
-+ this._proxy.GetRegistrationInfoRemote(Lang.bind(this, this._registrationInfoChanged)); |
132 |
-+ this._proxy.GetSignalQualityRemote(Lang.bind(this, this._qualityChanged)); |
133 |
-+ }, |
134 |
++ this._proxy = new ModemGsmNetworkProxy(DBus.system, 'org.freedesktop.ModemManager', path); |
135 |
+ |
136 |
-+ _registrationInfoChanged: function(status, code, name) { |
137 |
-+ if (name.length > 0) |
138 |
-+ this.operator_name = name; |
139 |
-+ else |
140 |
-+ this.operator_name = null; |
141 |
-+ this.emit('notify::operator-name'); |
142 |
-+ }, |
143 |
++ this.signal_quality = 0; |
144 |
++ this.operator_name = null; |
145 |
+ |
146 |
-+ _qualityChanged: function(quality) { |
147 |
-+ this.signal_quality = quality; |
148 |
-+ this.emit('notify::signal-quality'); |
149 |
++ // Code is duplicated because the function have different signatures |
150 |
++ this._proxy.connect('SignalQuality', Lang.bind(this, function(proxy, quality) { |
151 |
++ this.signal_quality = quality; |
152 |
++ this.emit('notify::signal-quality'); |
153 |
++ })); |
154 |
++ this._proxy.connect('RegistrationInfo', Lang.bind(this, function(proxy, status, code, name) { |
155 |
++ if (name.length > 0) |
156 |
++ this.operator_name = name; |
157 |
++ else |
158 |
++ this.operator_name = null; |
159 |
++ this.emit('notify::operator-name'); |
160 |
++ })); |
161 |
++ this._proxy.GetRegistrationInfoRemote(Lang.bind(this, function(status, code, name) { |
162 |
++ if (name.length > 0) |
163 |
++ this.operator_name = name; |
164 |
++ else |
165 |
++ this.operator_name = null; |
166 |
++ this.emit('notify::operator-name'); |
167 |
++ })); |
168 |
++ this._proxy.GetSignalQualityRemote(Lang.bind(this, function(quality) { |
169 |
++ this.signal_quality = quality; |
170 |
++ this.emit('notify::signal-quality'); |
171 |
++ })); |
172 |
+ } |
173 |
+} |
174 |
++Signals.addSignalMethods(ModemGsm.prototype); |
175 |
+ |
176 |
+function ModemCdma() { |
177 |
+ this._init.apply(this, arguments); |
178 |
@@ -122,28 +150,29 @@ index 0000000..104262b |
179 |
+ |
180 |
+ this.signal_quality = 0; |
181 |
+ this.operator_name = null; |
182 |
-+ this._proxy.connect('SignalQuality', Lang.bind(this, this._qualityChanged)); |
183 |
-+ this._proxy.GetSignalQualityRemote(Lang.bind(this, this._qualityChanged)); |
184 |
-+ this._proxy.GetServingSystemRemote(Lang.bind(this, function(status, name, code) { |
185 |
++ this._proxy.connect('SignalQuality', Lang.bind(this, function(quality) { |
186 |
++ this.signal_quality = quality; |
187 |
++ this.emit('notify::signal-quality'); |
188 |
++ })); |
189 |
++ this._proxy.GetSignalQualityRemote(Lang.bind(this, function(proxy, quality) { |
190 |
++ this.signal_quality = quality; |
191 |
++ this.emit('notify::signal-quality'); |
192 |
++ })); |
193 |
++ this._proxy.GetServingSystemRemote(Lang.bind(this, function(proxy, status, name, code) { |
194 |
+ if (name.length > 0) |
195 |
+ this.operator_name = name; |
196 |
+ else |
197 |
+ this.operator_name = null; |
198 |
+ this.emit('notify::operator-name'); |
199 |
+ })); |
200 |
-+ }, |
201 |
-+ |
202 |
-+ _qualityChanged: function(quality) { |
203 |
-+ this.signal_quality = quality; |
204 |
-+ this.emit('notify::signal-quality'); |
205 |
+ } |
206 |
+}; |
207 |
-\ No newline at end of file |
208 |
++Signals.addSignalMethods(ModemCdma.prototype); |
209 |
diff --git a/js/ui/panel.js b/js/ui/panel.js |
210 |
-index f1a5e90..46355c4 100644 |
211 |
+index 1c23ae8..ab7a656 100644 |
212 |
--- a/js/ui/panel.js |
213 |
+++ b/js/ui/panel.js |
214 |
-@@ -37,7 +37,8 @@ const STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION = { |
215 |
+@@ -38,7 +38,8 @@ const STANDARD_TRAY_ICON_SHELL_IMPLEMENTATION = { |
216 |
'a11y': imports.ui.status.accessibility.ATIndicator, |
217 |
'volume': imports.ui.status.volume.Indicator, |
218 |
'battery': imports.ui.status.power.Indicator, |
219 |
@@ -155,10 +184,10 @@ index f1a5e90..46355c4 100644 |
220 |
if (Config.HAVE_BLUETOOTH) |
221 |
diff --git a/js/ui/status/network.js b/js/ui/status/network.js |
222 |
new file mode 100644 |
223 |
-index 0000000..a0cd576 |
224 |
+index 0000000..04e9c87 |
225 |
--- /dev/null |
226 |
+++ b/js/ui/status/network.js |
227 |
-@@ -0,0 +1,1656 @@ |
228 |
+@@ -0,0 +1,1754 @@ |
229 |
+// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- |
230 |
+const ByteArray = imports.byteArray; |
231 |
+const DBus = imports.dbus; |
232 |
@@ -181,6 +210,13 @@ index 0000000..a0cd576 |
233 |
+const Gettext = imports.gettext.domain('gnome-shell'); |
234 |
+const _ = Gettext.gettext; |
235 |
+ |
236 |
++const NMConnectionCategory = { |
237 |
++ WIRED: 'wired', |
238 |
++ WIRELESS: 'wireless', |
239 |
++ WWAN: 'wwan', |
240 |
++ VPN: 'vpn' |
241 |
++}; |
242 |
++ |
243 |
+const NMAppletIface = { |
244 |
+ name: 'org.freedesktop.NetworkManager.Applet', |
245 |
+ methods: [ |
246 |
@@ -191,16 +227,9 @@ index 0000000..a0cd576 |
247 |
+const NMAppletProxy = DBus.makeProxyClass(NMAppletIface); |
248 |
+ |
249 |
+function macToArray(string) { |
250 |
-+ const regexp = /([A-Fa-f0-9]{2}):([A-Fa-f0-9]{2}):([A-Fa-f0-9]{2}):([A-Fa-f0-9]{2}):([A-Fa-f0-9]{2}):([A-Fa-f0-9]{2})/; |
251 |
-+ let match = regexp.exec(string); |
252 |
-+ if (match) { |
253 |
-+ // remove the global match |
254 |
-+ match.splice(0, 1); |
255 |
-+ return match.map(function(el) { |
256 |
-+ return parseInt(el, 16); |
257 |
-+ }); |
258 |
-+ } else |
259 |
-+ return new Array(6); |
260 |
++ return string.split(':').map(function(el) { |
261 |
++ return parseInt(el, 16); |
262 |
++ }); |
263 |
+} |
264 |
+ |
265 |
+function macCompare(one, two) { |
266 |
@@ -211,75 +240,101 @@ index 0000000..a0cd576 |
267 |
+ return true; |
268 |
+} |
269 |
+ |
270 |
-+/** |
271 |
-+ * makeClassKey: |
272 |
-+ * @object: any Object |
273 |
-+ * |
274 |
-+ * Returns a string which can be used to identify @object's [[Class]] |
275 |
-+ */ |
276 |
-+function makeClassKey(object) { |
277 |
-+ return Object.prototype.toString.call(object); |
278 |
-+} |
279 |
-+ |
280 |
-+function addChipersFromFlags(settings, flags) { |
281 |
-+ // helper copied from nm-applet |
282 |
-+ |
283 |
-+ if (flags & NetworkManager['802_11_AP_SEC_PAIR_TKIP']) |
284 |
-+ settings.add_pairwise('tkip'); |
285 |
-+ if (flags & NetworkManager['802_11_AP_SEC_PAIR_CCMP']) |
286 |
-+ settings.add_pairwise('ccmp'); |
287 |
-+ |
288 |
-+ if (flags & NetworkManager['802_11_AP_SEC_GROUP_WEP40']) |
289 |
-+ settings.add_group('wep40'); |
290 |
-+ if (flags & NetworkManager['802_11_AP_SEC_GROUP_WEP104']) |
291 |
-+ settings.add_group('wep104'); |
292 |
-+ if (flags & NetworkManager['802_11_AP_SEC_GROUP_TKIP']) |
293 |
-+ settings.add_group('tkip'); |
294 |
-+ if (flags & NetworkManager['802_11_AP_SEC_GROUP_CCMP']) |
295 |
-+ settings.add_group('ccmp'); |
296 |
++function ssidCompare(one, two) { |
297 |
++ if (one.length != two.length) |
298 |
++ return false; |
299 |
++ for (let i = 0; i < one.length; i++) { |
300 |
++ if (one[i] != two[i]) |
301 |
++ return false; |
302 |
++ } |
303 |
++ return true; |
304 |
+} |
305 |
+ |
306 |
-+// shared between NMAccessPointMenuItem and NMDeviceWWAN |
307 |
++// shared between NMNetworkMenuItem and NMDeviceWWAN |
308 |
+function signalToIcon(value) { |
309 |
-+ if(value > 80) |
310 |
++ if (value > 80) |
311 |
+ return 'excellent'; |
312 |
-+ if(value > 55) |
313 |
++ if (value > 55) |
314 |
+ return 'good'; |
315 |
-+ if(value > 30) |
316 |
++ if (value > 30) |
317 |
+ return 'ok'; |
318 |
-+ if(value > 5) |
319 |
++ if (value > 5) |
320 |
+ return 'weak'; |
321 |
+ return 'none'; |
322 |
+} |
323 |
+ |
324 |
-+function NMAccessPointMenuItem() { |
325 |
++// shared between NMNetworkMenuItem and NMDeviceWireless |
326 |
++function sortAccessPoints(accessPoints) { |
327 |
++ return accessPoints.sort(function (one, two) { |
328 |
++ return two.strength - one.strength; |
329 |
++ }); |
330 |
++} |
331 |
++ |
332 |
++function NMNetworkMenuItem() { |
333 |
+ this._init.apply(this, arguments); |
334 |
+} |
335 |
+ |
336 |
-+NMAccessPointMenuItem.prototype = { |
337 |
++NMNetworkMenuItem.prototype = { |
338 |
+ __proto__: PopupMenu.PopupImageMenuItem.prototype, |
339 |
+ |
340 |
-+ _init: function(accessPoint, title, params) { |
341 |
-+ this._accessPoint = accessPoint; |
342 |
-+ this._title = title || String(accessPoint.get_ssid()); |
343 |
++ _init: function(accessPoints, title, params) { |
344 |
++ accessPoints = sortAccessPoints(accessPoints); |
345 |
++ this.bestAP = accessPoints[0]; |
346 |
++ |
347 |
++ let ssid = this.bestAP.get_ssid(); |
348 |
++ title = title || NetworkManager.utils_ssid_to_utf8(ssid, ssid.length) || _("<unknown>"); |
349 |
++ |
350 |
++ PopupMenu.PopupImageMenuItem.prototype._init.call(this, title, this._getIcon(), params); |
351 |
++ |
352 |
++ this._accessPoints = [ ]; |
353 |
++ for (let i = 0; i < accessPoints.length; i++) { |
354 |
++ let ap = accessPoints[i]; |
355 |
++ // need a wrapper object here, because the access points can be shared |
356 |
++ // between many NMNetworkMenuItems |
357 |
++ let apObj = { |
358 |
++ ap: ap, |
359 |
++ updateId: ap.connect('notify::strength', Lang.bind(this, this._updated)) |
360 |
++ }; |
361 |
++ this._accessPoints.push(apObj); |
362 |
++ } |
363 |
++ }, |
364 |
+ |
365 |
-+ PopupMenu.PopupImageMenuItem.prototype._init.call(this, this._title, this._get_icon(), params); |
366 |
++ _updated: function(ap, strength) { |
367 |
++ if (strength > this._bestAP.strength) |
368 |
++ this.bestAP = ap; |
369 |
+ |
370 |
-+ this._updateId = this._accessPoint.connect('notify::strength', Lang.bind(this, this._updated)); |
371 |
++ this.setIcon(this._getIcon()); |
372 |
+ }, |
373 |
+ |
374 |
-+ _updated: function() { |
375 |
-+ this.setIcon(this._get_icon()); |
376 |
++ _getIcon: function() { |
377 |
++ return 'network-wireless-signal-' + signalToIcon(this.bestAP.strength); |
378 |
+ }, |
379 |
+ |
380 |
-+ _get_icon: function() { |
381 |
-+ return 'network-wireless-signal-' + signalToIcon(this._accessPoint.strength); |
382 |
++ updateAccessPoints: function(accessPoints) { |
383 |
++ for (let i = 0; i < this._accessPoints.length; i++) { |
384 |
++ let apObj = this._accessPoints[i]; |
385 |
++ apObj.ap.disconnect(apObj.updateId); |
386 |
++ apObj.updateId = 0; |
387 |
++ } |
388 |
++ |
389 |
++ accessPoints = sortAccessPoints(accessPoints); |
390 |
++ this.bestAP = accessPoints[0]; |
391 |
++ this._accessPoints = [ ]; |
392 |
++ for (let i = 0; i < accessPoints; i++) { |
393 |
++ let ap = accessPoints[i]; |
394 |
++ let apObj = { |
395 |
++ ap: ap, |
396 |
++ updateId: ap.connect('notify::strength', Lang.bind(this, this._updated)) |
397 |
++ }; |
398 |
++ this._accessPoints.push(apObj); |
399 |
++ } |
400 |
+ }, |
401 |
+ |
402 |
+ destroy: function() { |
403 |
-+ if (this._updateId) { |
404 |
-+ this._accessPoint.disconnect(this._updateId); |
405 |
-+ this._updateId = 0; |
406 |
++ for (let i = 0; i < this._accessPoints.length; i++) { |
407 |
++ let apObj = this._accessPoints[i]; |
408 |
++ apObj.ap.disconnect(apObj.updateId); |
409 |
++ apObj.updateId = 0; |
410 |
+ } |
411 |
+ |
412 |
+ PopupMenu.PopupImageMenuItem.prototype.destroy.call(this); |
413 |
@@ -287,20 +342,20 @@ index 0000000..a0cd576 |
414 |
+}; |
415 |
+ |
416 |
+function NMDevice() { |
417 |
-+ throw TypeError('Instantanting abstract class NMDevice'); |
418 |
++ throw new TypeError('Instantanting abstract class NMDevice'); |
419 |
+} |
420 |
+ |
421 |
+NMDevice.prototype = { |
422 |
+ _init: function(client, device, connections, activeConnectionPosition) { |
423 |
-+ /* <protected> */ |
424 |
-+ this.client = client; |
425 |
+ this.device = device; |
426 |
+ if (device) { |
427 |
+ this.device._delegate = this; |
428 |
+ this.device.connect('state-changed', Lang.bind(this, this.deviceStateChanged)); |
429 |
+ } |
430 |
+ |
431 |
-+ this.connections = [ ]; |
432 |
++ // protected |
433 |
++ this._client = client; |
434 |
++ this._connections = [ ]; |
435 |
+ for (let i = 0; i < connections.length; i++) { |
436 |
+ if (!connections[i]._uuid) |
437 |
+ continue; |
438 |
@@ -312,42 +367,42 @@ index 0000000..a0cd576 |
439 |
+ name: connections[i]._name, |
440 |
+ uuid: connections[i]._uuid, |
441 |
+ }; |
442 |
-+ this.connections.push(obj); |
443 |
++ this._connections.push(obj); |
444 |
+ } |
445 |
-+ this.activeConnection = null; |
446 |
-+ this.activeConnectionItem = null; |
447 |
-+ this.disconnectItem = null; |
448 |
-+ this.autoConnectionItem = null; |
449 |
-+ this.statusItem = null; |
450 |
++ this._activeConnection = null; |
451 |
++ this._activeConnectionItem = null; |
452 |
++ this._disconnectItem = null; |
453 |
++ this._autoConnectionItem = null; |
454 |
++ this._statusItem = null; |
455 |
+ |
456 |
-+ /* <private> */ |
457 |
++ // private |
458 |
+ this._activeConnectionPosition = activeConnectionPosition || 0; |
459 |
+ |
460 |
-+ /* <public> */ |
461 |
-+ this.titleItem = new PopupMenu.PopupMenuItem(this.device._description, { reactive: false, style_class: 'popup-subtitle-menu-item' }); |
462 |
++ if (this.device) |
463 |
++ this.titleItem = new PopupMenu.PopupMenuItem(this.device._description, { reactive: false, style_class: 'popup-subtitle-menu-item' }); |
464 |
+ this.section = new PopupMenu.PopupMenuSection(); |
465 |
+ |
466 |
-+ this.createSection(); |
467 |
++ this._createSection(); |
468 |
+ }, |
469 |
+ |
470 |
+ setActiveConnection: function(activeConnection) { |
471 |
-+ if (this.activeConnection && activeConnection == this.activeConnection) |
472 |
++ if (activeConnection == this._activeConnection) |
473 |
+ // nothing to do |
474 |
+ return; |
475 |
+ |
476 |
+ // remove any UI |
477 |
-+ if (this.activeConnectionItem) { |
478 |
-+ this.activeConnectionItem.destroy(); |
479 |
-+ this.activeConnectionItem = null; |
480 |
++ if (this._activeConnectionItem) { |
481 |
++ this._activeConnectionItem.destroy(); |
482 |
++ this._activeConnectionItem = null; |
483 |
+ } |
484 |
+ |
485 |
-+ if (this.disconnectItem) { |
486 |
-+ this.disconnectItem.destroy(); |
487 |
-+ this.disconnectItem = null; |
488 |
++ if (this._disconnectItem) { |
489 |
++ this._disconnectItem.destroy(); |
490 |
++ this._disconnectItem = null; |
491 |
+ } |
492 |
+ |
493 |
-+ let previousActive = this.activeConnection; |
494 |
-+ this.activeConnection == null; |
495 |
++ let previousActive = this._activeConnection; |
496 |
++ this._activeConnection == null; |
497 |
+ |
498 |
+ if (previousActive && previousActive._connection) { |
499 |
+ // add the connection back as a normal one, by removing and adding it |
500 |
@@ -358,25 +413,25 @@ index 0000000..a0cd576 |
501 |
+ if (activeConnection) { |
502 |
+ if (activeConnection._connection) { |
503 |
+ // remove the connection if it was already seen |
504 |
-+ let pos = this.findConnection(activeConnection._connection._uuid); |
505 |
++ let pos = this._findConnection(activeConnection._connection._uuid); |
506 |
+ if (pos != -1) { |
507 |
-+ let obj = this.connections[pos]; |
508 |
++ let obj = this._connections[pos]; |
509 |
+ if (obj.item) |
510 |
+ obj.item.destroy(); |
511 |
+ obj.item = null; |
512 |
+ } |
513 |
+ } |
514 |
+ |
515 |
-+ this.activeConnection = activeConnection; |
516 |
-+ this.createActiveConnectionItems(); |
517 |
-+ if (this.disconnectItem) |
518 |
-+ this.section.addMenuItem(this.disconnectItem, this._activeConnectionPosition); |
519 |
-+ this.section.addMenuItem(this.activeConnectionItem, this._activeConnectionPosition); |
520 |
++ this._activeConnection = activeConnection; |
521 |
++ this._createActiveConnectionItems(); |
522 |
++ if (this._disconnectItem) |
523 |
++ this.section.addMenuItem(this._disconnectItem, this._activeConnectionPosition); |
524 |
++ this.section.addMenuItem(this._activeConnectionItem, this._activeConnectionPosition); |
525 |
+ } |
526 |
+ }, |
527 |
+ |
528 |
+ addConnection: function(connection) { |
529 |
-+ if (this.findConnection(connection._uuid) != -1) { |
530 |
++ if (this._findConnection(connection._uuid) != -1) { |
531 |
+ log('Connection already added to menu, not adding again'); |
532 |
+ return; |
533 |
+ } |
534 |
@@ -387,157 +442,139 @@ index 0000000..a0cd576 |
535 |
+ name: connection._name, |
536 |
+ uuid: connection._uuid, |
537 |
+ }; |
538 |
-+ this.connections.push(obj); |
539 |
++ this._connections.push(obj); |
540 |
+ |
541 |
+ if (!this.device || |
542 |
+ (this.device.state == NetworkManager.DeviceState.DISCONNECTED || |
543 |
+ this.device.state == NetworkManager.DeviceState.ACTIVATED)) { |
544 |
-+ // we need to show this connection |
545 |
-+ if (!this.hasAuto) { |
546 |
-+ // already showing the connection list |
547 |
-+ obj.item = this.createConnectionItem(obj); |
548 |
++ // we're showing a connection list, so we need to append this one |
549 |
++ if (this._connections.length > 1) { |
550 |
++ // already showing real connections |
551 |
++ obj.item = this._createConnectionItem(obj); |
552 |
+ this.section.addMenuItem(obj.item); |
553 |
+ } else { |
554 |
-+ // First connection in the list |
555 |
-+ this.clearSection(); |
556 |
-+ this.createSection(); |
557 |
++ // first connection in the list, destroy the automatic one |
558 |
++ this._clearSection(); |
559 |
++ this._createSection(); |
560 |
+ } |
561 |
+ } |
562 |
+ }, |
563 |
+ |
564 |
+ removeConnection: function(connection, skipCreateAuto) { |
565 |
-+ if (!connection._uuid) |
566 |
++ if (!connection._uuid) { |
567 |
++ log('Cannot remove a connection without an UUID'); |
568 |
+ return; |
569 |
-+ let pos = this.findConnection(connection._uuid); |
570 |
-+ if (pos == -1) |
571 |
++ } |
572 |
++ let pos = this._findConnection(connection._uuid); |
573 |
++ if (pos == -1) { |
574 |
++ log('Connection was never added, cannot remove'); |
575 |
+ return; |
576 |
++ } |
577 |
+ |
578 |
-+ let obj = this.connections[pos]; |
579 |
++ let obj = this._connections[pos]; |
580 |
+ if (obj.item) |
581 |
+ obj.item.destroy(); |
582 |
-+ this.connections.splice(pos, 1); |
583 |
++ this._connections.splice(pos, 1); |
584 |
+ |
585 |
-+ if (this.connections.length == 0 && !skipCreateAuto) { |
586 |
++ if (this._connections.length == 0 && !skipCreateAuto) { |
587 |
+ // We need to show the automatic connection again |
588 |
-+ this.clearSection(); |
589 |
-+ this.createSection(); |
590 |
++ this._clearSection(); |
591 |
++ this._createSection(); |
592 |
+ } |
593 |
+ }, |
594 |
+ |
595 |
+ connectionValid: function(connection) { |
596 |
-+ throw TypeError('Invoking pure virtual function NMDevice.connectionValid'); |
597 |
++ throw new TypeError('Invoking pure virtual function NMDevice.connectionValid'); |
598 |
+ }, |
599 |
+ |
600 |
-+ /* <protected> */ |
601 |
-+ createAutomaticConnection: function() { |
602 |
-+ throw TypeError('Invoking pure virtual function NMDevice.createAutomaticConnection'); |
603 |
++ // protected |
604 |
++ _createAutomaticConnection: function() { |
605 |
++ throw new TypeError('Invoking pure virtual function NMDevice.createAutomaticConnection'); |
606 |
+ }, |
607 |
+ |
608 |
-+ findConnection: function(uuid) { |
609 |
-+ for (let i = 0; i < this.connections.length; i++) { |
610 |
-+ let obj = this.connections[i]; |
611 |
++ _findConnection: function(uuid) { |
612 |
++ for (let i = 0; i < this._connections.length; i++) { |
613 |
++ let obj = this._connections[i]; |
614 |
+ if (obj.uuid == uuid) |
615 |
+ return i; |
616 |
+ } |
617 |
+ return -1; |
618 |
+ }, |
619 |
+ |
620 |
-+ clearSection: function() { |
621 |
++ _clearSection: function() { |
622 |
+ // Clear everything |
623 |
+ this.section.removeAll(); |
624 |
-+ this.autoConnectionItem = null; |
625 |
-+ this.activeConnectionItem = null; |
626 |
-+ this.disconnectItem = null; |
627 |
-+ this.statusItem = null; |
628 |
-+ for (let i = 0; i < this.connections.length; i++) { |
629 |
-+ this.connections[i].item = null; |
630 |
++ this._autoConnectionItem = null; |
631 |
++ this._activeConnectionItem = null; |
632 |
++ this._disconnectItem = null; |
633 |
++ this._statusItem = null; |
634 |
++ for (let i = 0; i < this._connections.length; i++) { |
635 |
++ this._connections[i].item = null; |
636 |
+ } |
637 |
+ }, |
638 |
+ |
639 |
-+ createSection: function() { |
640 |
++ _createSection: function() { |
641 |
+ let status; |
642 |
+ if (!this.device || |
643 |
+ (this.device.state == NetworkManager.DeviceState.DISCONNECTED || |
644 |
+ this.device.state == NetworkManager.DeviceState.ACTIVATED)) |
645 |
-+ this.createConnectionList(); |
646 |
++ this._createConnectionList(); |
647 |
+ else if (this.device.state != NetworkManager.DeviceState.UNMANAGED) { |
648 |
-+ let title = this.getStatusLabel(); |
649 |
-+ this.statusItem = new PopupMenu.PopupMenuItem(title, { reactive: false, style_class: 'popup-inactive-menu-item' }); |
650 |
-+ this.section.addMenuItem(this.statusItem); |
651 |
++ let title = this._getStatusLabel(); |
652 |
++ this._statusItem = new PopupMenu.PopupMenuItem(title, |
653 |
++ { reactive: false, |
654 |
++ style_class: 'popup-inactive-menu-item' |
655 |
++ }); |
656 |
++ this.section.addMenuItem(this._statusItem); |
657 |
+ } |
658 |
+ // else do nothing, the menu should remain empty |
659 |
+ }, |
660 |
+ |
661 |
-+ getStatusLabel: function() { |
662 |
-+ switch(this.device.state) { |
663 |
-+ case NetworkManager.DeviceState.DISCONNECTED: |
664 |
-+ case NetworkManager.DeviceState.ACTIVATED: |
665 |
-+ log('Attempt to show status for a disconnected / activate device, should be showing connection list instead'); |
666 |
-+ return 'invalid'; |
667 |
-+ case NetworkManager.DeviceState.PREPARE: |
668 |
-+ case NetworkManager.DeviceState.CONFIG: |
669 |
-+ case NetworkManager.DeviceState.IP_CONFIG: |
670 |
-+ return _("connecting..."); |
671 |
-+ case NetworkManager.DeviceState.NEED_AUTH: |
672 |
-+ return _("authentication required"); |
673 |
-+ case NetworkManager.DeviceState.UNAVAILABLE: |
674 |
-+ if ((this.device.capabilities & NetworkManager.DeviceCapabilities.CARRIER_DETECT) && |
675 |
-+ !this.device.carrier) |
676 |
-+ return _("network cable unplugged"); |
677 |
-+ else |
678 |
-+ return _("network unavailable"); |
679 |
-+ case NetworkManager.DeviceState.FAILED: |
680 |
-+ return _("connection failed"); |
681 |
-+ default: |
682 |
-+ log('Device state invalid, is %d'.format(this.device.state)); |
683 |
-+ return 'invalid'; |
684 |
-+ } |
685 |
-+ }, |
686 |
-+ |
687 |
-+ createConnectionList: function() { |
688 |
-+ if (this.activeConnection) { |
689 |
-+ this.createActiveConnectionItems(); |
690 |
-+ this.section.addMenuItem(this.activeConnectionItem); |
691 |
-+ if (this.disconnectItem) |
692 |
-+ this.section.addMenuItem(this.disconnectItem); |
693 |
++ _createConnectionList: function() { |
694 |
++ if (this._activeConnection) { |
695 |
++ this._createActiveConnectionItems(); |
696 |
++ this.section.addMenuItem(this._activeConnectionItem); |
697 |
++ if (this._disconnectItem) |
698 |
++ this.section.addMenuItem(this._disconnectItem); |
699 |
+ } |
700 |
-+ if (this.connections.length > 0) { |
701 |
-+ for(let j = 0; j < this.connections.length; ++j) { |
702 |
-+ let obj = this.connections[j]; |
703 |
-+ if (this.activeConnection && obj.connection == this.activeConnection._connection) |
704 |
++ if (this._connections.length > 0) { |
705 |
++ for(let j = 0; j < this._connections.length; ++j) { |
706 |
++ let obj = this._connections[j]; |
707 |
++ if (this._activeConnection && |
708 |
++ obj.connection == this._activeConnection._connection) |
709 |
+ continue; |
710 |
-+ obj.item = this.createConnectionItem(obj); |
711 |
++ obj.item = this._createConnectionItem(obj); |
712 |
+ this.section.addMenuItem(obj.item); |
713 |
+ } |
714 |
-+ } else if (this.autoConnectionName) { |
715 |
-+ this.autoConnectionItem = new PopupMenu.PopupMenuItem(this.autoConnectionName); |
716 |
-+ this.autoConnectionItem.connect('activate', Lang.bind(this, function() { |
717 |
-+ let connection = this.createAutomaticConnection(); |
718 |
-+ this.client.add_and_activate_connection(connection, this.device, null, function() { }); |
719 |
++ } else if (this._autoConnectionName) { |
720 |
++ this._autoConnectionItem = new PopupMenu.PopupMenuItem(this._autoConnectionName); |
721 |
++ this._autoConnectionItem.connect('activate', Lang.bind(this, function() { |
722 |
++ let connection = this._createAutomaticConnection(); |
723 |
++ this._client.add_and_activate_connection(connection, this.device, null, null); |
724 |
+ })); |
725 |
-+ this.section.addMenuItem(this.autoConnectionItem); |
726 |
++ this.section.addMenuItem(this._autoConnectionItem); |
727 |
+ } |
728 |
+ }, |
729 |
+ |
730 |
-+ createConnectionItem: function(obj) { |
731 |
++ _createConnectionItem: function(obj) { |
732 |
+ let path = obj.connection.path; |
733 |
+ let item = new PopupMenu.PopupMenuItem(obj.name); |
734 |
+ item.connect('activate', Lang.bind(this, function() { |
735 |
-+ this.client.activate_connection(path, this.device, null, function() { }); |
736 |
++ this._client.activate_connection(path, this.device, null, null); |
737 |
+ })); |
738 |
+ return item; |
739 |
+ }, |
740 |
+ |
741 |
-+ createActiveConnectionItems: function() { |
742 |
++ _createActiveConnectionItems: function() { |
743 |
+ let title; |
744 |
-+ let active = this.activeConnection._connection; |
745 |
-+ this.disconnectItem = null; |
746 |
++ let active = this._activeConnection._connection; |
747 |
++ this._disconnectItem = null; |
748 |
+ if (active) { |
749 |
+ title = active._name; |
750 |
-+ this.disconnectItem = new PopupMenu.PopupMenuItem(_("Disconnect")); |
751 |
-+ this.disconnectItem.connect('activate', Lang.bind(this, function() { |
752 |
++ this._disconnectItem = new PopupMenu.PopupMenuItem(_("Disconnect")); |
753 |
++ this._disconnectItem.connect('activate', Lang.bind(this, function() { |
754 |
+ /* The correct approach would be |
755 |
-+ this.client.deactivate_connection(this.activeConnection); |
756 |
++ this.client.deactivate_connection(this._activeConnection); |
757 |
+ but with this, NM insists in restarting the connection immediately |
758 |
+ */ |
759 |
+ this.device.disconnect(function() { }); |
760 |
@@ -547,8 +584,35 @@ index 0000000..a0cd576 |
761 |
+ and we cannot access its settings (including the name) */ |
762 |
+ title = _("Connected (private)"); |
763 |
+ } |
764 |
-+ this.activeConnectionItem = new PopupMenu.PopupMenuItem(title, { reactive: false }); |
765 |
-+ this.activeConnectionItem.setShowDot(true); |
766 |
++ this._activeConnectionItem = new PopupMenu.PopupMenuItem(title, { reactive: false }); |
767 |
++ this._activeConnectionItem.setShowDot(true); |
768 |
++ }, |
769 |
++ |
770 |
++ // private |
771 |
++ _getStatusLabel: function() { |
772 |
++ switch(this.device.state) { |
773 |
++ case NetworkManager.DeviceState.DISCONNECTED: |
774 |
++ case NetworkManager.DeviceState.ACTIVATED: |
775 |
++ log('Attempt to show status for a disconnected / activate device, should be showing connection list instead'); |
776 |
++ return 'invalid'; |
777 |
++ case NetworkManager.DeviceState.PREPARE: |
778 |
++ case NetworkManager.DeviceState.CONFIG: |
779 |
++ case NetworkManager.DeviceState.IP_CONFIG: |
780 |
++ return _("connecting..."); |
781 |
++ case NetworkManager.DeviceState.NEED_AUTH: |
782 |
++ return _("authentication required"); |
783 |
++ case NetworkManager.DeviceState.UNAVAILABLE: |
784 |
++ if ((this.device.capabilities & NetworkManager.DeviceCapabilities.CARRIER_DETECT) && |
785 |
++ !this.device.carrier) |
786 |
++ return _("network cable unplugged"); |
787 |
++ else |
788 |
++ return _("network unavailable"); |
789 |
++ case NetworkManager.DeviceState.FAILED: |
790 |
++ return _("connection failed"); |
791 |
++ default: |
792 |
++ log('Device state invalid, is %d'.format(this.device.state)); |
793 |
++ return 'invalid'; |
794 |
++ } |
795 |
+ }, |
796 |
+ |
797 |
+ deviceStateChanged: function(device, newstate, oldstate, reason) { |
798 |
@@ -564,10 +628,11 @@ index 0000000..a0cd576 |
799 |
+ switch(newstate) { |
800 |
+ case NetworkManager.DeviceState.UNMANAGED: |
801 |
+ // clear everything and be quiet |
802 |
-+ this.clearSection(); |
803 |
++ this._clearSection(); |
804 |
+ return; |
805 |
+ case NetworkManager.DeviceState.NEED_AUTH: |
806 |
+ // FIXME: make this have a real effect |
807 |
++ // (currently we rely on a running nm-applet) |
808 |
+ this.emit('need-auth'); |
809 |
+ break; |
810 |
+ case NetworkManager.DeviceState.FAILED: |
811 |
@@ -581,13 +646,13 @@ index 0000000..a0cd576 |
812 |
+ oldstate != NetworkManager.DeviceState.ACTIVATED && |
813 |
+ oldstate != NetworkManager.DeviceState.UNMANAGED) { |
814 |
+ // a transition between states that show the status label |
815 |
-+ this.statusItem.label.text = this.getStatusLabel(); |
816 |
++ this._statusItem.label.text = this._getStatusLabel(); |
817 |
+ return; |
818 |
+ } |
819 |
+ |
820 |
+ // just refresh everything |
821 |
-+ this.clearSection(); |
822 |
-+ this.createSection(); |
823 |
++ this._clearSection(); |
824 |
++ this._createSection(); |
825 |
+ } |
826 |
+}; |
827 |
+Signals.addSignalMethods(NMDevice.prototype); |
828 |
@@ -601,31 +666,31 @@ index 0000000..a0cd576 |
829 |
+ __proto__: NMDevice.prototype, |
830 |
+ |
831 |
+ _init: function(client, device, connections) { |
832 |
-+ this.autoConnectionName = _("Auto Ethernet"); |
833 |
-+ this.category = 'wired'; |
834 |
++ this._autoConnectionName = _("Auto Ethernet"); |
835 |
++ this.category = NMConnectionCategory.WIRED; |
836 |
+ |
837 |
+ NMDevice.prototype._init.call(this, client, device, connections); |
838 |
+ }, |
839 |
+ |
840 |
+ connectionValid: function(connection) { |
841 |
-+ if (connection._type != '802-3-ethernet') |
842 |
++ if (connection._type != NetworkManager.SETTING_WIRED_SETTING_NAME) |
843 |
+ return false; |
844 |
+ |
845 |
-+ let ethernetSettings = connection.get_setting_by_name('802-3-ethernet'); |
846 |
++ let ethernetSettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRED_SETTING_NAME); |
847 |
+ let fixedMac = ethernetSettings.get_mac_address(); |
848 |
+ if (fixedMac) |
849 |
+ return macCompare(fixedMac, macToArray(this.device.perm_hw_address)); |
850 |
+ return true; |
851 |
+ }, |
852 |
+ |
853 |
-+ createAutomaticConnection: function() { |
854 |
++ _createAutomaticConnection: function() { |
855 |
+ let connection = new NetworkManager.Connection(); |
856 |
+ connection._uuid = NetworkManager.utils_uuid_generate(); |
857 |
+ connection.add_setting(new NetworkManager.SettingWired()); |
858 |
+ connection.add_setting(new NetworkManager.SettingConnection({ |
859 |
+ uuid: connection._uuid, |
860 |
-+ id: this.autoConnectionName, |
861 |
-+ type: '802-3-ethernet', |
862 |
++ id: this._autoConnectionName, |
863 |
++ type: NetworkManager.SETTING_WIRED_SETTING_NAME, |
864 |
+ autoconnect: true |
865 |
+ })); |
866 |
+ return connection; |
867 |
@@ -640,15 +705,15 @@ index 0000000..a0cd576 |
868 |
+ __proto__: NMDevice.prototype, |
869 |
+ |
870 |
+ _init: function(client, device, connections) { |
871 |
-+ this.autoConnectionName = _("New Mobile Broadband connection..."); |
872 |
-+ this.category = 'wwan'; |
873 |
++ this._autoConnectionName = _("New Mobile Broadband connection..."); |
874 |
++ this.category = NMConnectionCategory.WWAN; |
875 |
+ |
876 |
+ if (device instanceof NMClient.GsmDevice) { |
877 |
+ this.mobileDevice = new ModemManager.ModemGsm(device.udi); |
878 |
-+ this._connectionType = 'gsm'; |
879 |
++ this._connectionType = NetworkManager.SETTING_GSM_SETTING_NAME; |
880 |
+ } else if (device instanceof NMClient.CdmaDevice) { |
881 |
+ this.mobileDevice = new ModemManager.ModemCdma(device.udi); |
882 |
-+ this._connectionType = 'cdma'; |
883 |
++ this._connectionType = NetworkManager.SETTING_CDMA_SETTING_NAME; |
884 |
+ } |
885 |
+ |
886 |
+ this.mobileDevice.connect('notify::operator-name', Lang.bind(this, function() { |
887 |
@@ -663,43 +728,46 @@ index 0000000..a0cd576 |
888 |
+ })); |
889 |
+ this.mobileDevice.connect('notify::signal-quality', Lang.bind(this, function() { |
890 |
+ if (this._operatorItem) { |
891 |
-+ this._operatorItem.setIcon(this._get_signal_icon()); |
892 |
++ this._operatorItem.setIcon(this._getSignalIcon()); |
893 |
+ } |
894 |
+ })); |
895 |
+ |
896 |
+ NMDevice.prototype._init.call(this, client, device, connections, 1); |
897 |
+ }, |
898 |
+ |
899 |
-+ _get_signal_icon: function() { |
900 |
++ _getSignalIcon: function() { |
901 |
+ return 'network-cellular-signal-' + signalToIcon(this.mobileDevice.signal_quality); |
902 |
+ }, |
903 |
+ |
904 |
-+ createSection: function() { |
905 |
-+ NMDevice.prototype.createSection.call(this); |
906 |
++ _createSection: function() { |
907 |
++ NMDevice.prototype._createSection.call(this); |
908 |
+ |
909 |
-+ this._operatorItem = new PopupMenu.PopupImageMenuItem(this.mobileDevice.operator_name || '', this._get_signal_icon(), { reactive: false }); |
910 |
++ this._operatorItem = new PopupMenu.PopupImageMenuItem(this.mobileDevice.operator_name || '', |
911 |
++ this._getSignalIcon(), |
912 |
++ { reactive: false }); |
913 |
+ this.section.addMenuItem(this._operatorItem, 0); |
914 |
+ }, |
915 |
+ |
916 |
+ clearSection: function() { |
917 |
+ this._operatorItem = null; |
918 |
+ |
919 |
-+ NMDevice.prototype.clearSection.call(this); |
920 |
++ NMDevice.prototype._clearSection.call(this); |
921 |
+ }, |
922 |
+ |
923 |
+ connectionValid: function(connection) { |
924 |
+ return connection._type == this._connectionType; |
925 |
+ }, |
926 |
+ |
927 |
-+ createAutomaticConnection: function() { |
928 |
++ _createAutomaticConnection: function() { |
929 |
+ // FIXME: we need to summon the mobile wizard here |
930 |
+ // or NM will not have the necessary parameters to complete the connection |
931 |
++ // (the same FIXME is currently in nm-applet, actually) |
932 |
+ |
933 |
+ let connection = new NetworkManager.Connection; |
934 |
+ connection._uuid = NetworkManager.utils_uuid_generate(); |
935 |
+ connection.add_setting(new NetworkManager.SettingConnection({ |
936 |
+ uuid: connection._uuid, |
937 |
-+ id: this.autoConnectionName, |
938 |
++ id: this._autoConnectionName, |
939 |
+ type: this._connectionType, |
940 |
+ autoconnect: false |
941 |
+ })); |
942 |
@@ -715,17 +783,17 @@ index 0000000..a0cd576 |
943 |
+ __proto__: NMDevice.prototype, |
944 |
+ |
945 |
+ _init: function(client, device, connections) { |
946 |
-+ this.autoConnectionName = _("New Mobile Broadband connection..."); |
947 |
-+ this.category = 'wwan'; |
948 |
++ this._autoConnectionName = _("New Mobile Broadband connection..."); |
949 |
++ this.category = NMConnectionCategory.WWAN; |
950 |
+ |
951 |
+ NMDevice.prototype._init.call(this, client, device, connections); |
952 |
+ }, |
953 |
+ |
954 |
+ connectionValid: function(connection) { |
955 |
-+ if (connection._type != 'bluetooth') |
956 |
++ if (connection._type != NetworkManager.SETTING_BLUETOOTH_SETTING_NAME) |
957 |
+ return false; |
958 |
+ |
959 |
-+ let bluetoothSettings = connection.get_setting_by_name('bluetooth'); |
960 |
++ let bluetoothSettings = connection.get_setting_by_name(NetworkManager.SETTING_BLUETOOTH_SETTING_NAME); |
961 |
+ let fixedBdaddr = bluetoothSettings.get_bdaddr(); |
962 |
+ if (fixedBdaddr) |
963 |
+ return macCompare(fixedBdaddr, macToArray(this.device.hw_address)); |
964 |
@@ -733,15 +801,16 @@ index 0000000..a0cd576 |
965 |
+ return true; |
966 |
+ }, |
967 |
+ |
968 |
-+ createAutomaticConnection: function() { |
969 |
++ _createAutomaticConnection: function() { |
970 |
+ // XXX: is this enough? or do we need other stuff from bluetoothd? |
971 |
+ |
972 |
+ let connection = new NetworkManager.Connection; |
973 |
+ connection._uuid = NetworkManager.utils_uuid_generate(); |
974 |
++ connection.add_setting(new NetworkManager.SettingBluetooth); |
975 |
+ connection.add_setting(new NetworkManager.SettingConnection({ |
976 |
+ uuid: connection._uuid, |
977 |
-+ id: this.autoConnectionName, |
978 |
-+ type: 'gsm', |
979 |
++ id: this._autoConnectionName, |
980 |
++ type: NetworkManager.SETTING_BLUETOOTH_SETTING_NAME, |
981 |
+ autoconnect: false |
982 |
+ })); |
983 |
+ return connection; |
984 |
@@ -759,14 +828,18 @@ index 0000000..a0cd576 |
985 |
+ |
986 |
+ _init: function(client) { |
987 |
+ // Disable autoconnections |
988 |
-+ this.autoConnectionName = null; |
989 |
-+ this.category = 'vpn'; |
990 |
++ this._autoConnectionName = null; |
991 |
++ this.category = NMConnectionCategory.VPN; |
992 |
+ |
993 |
+ NMDevice.prototype._init.call(this, client, null, [ ]); |
994 |
+ }, |
995 |
+ |
996 |
+ connectionValid: function(connection) { |
997 |
-+ return connection._type == 'vpn'; |
998 |
++ return connection._type == NetworkManager.SETTING_VPN_SETTING_NAME; |
999 |
++ }, |
1000 |
++ |
1001 |
++ get empty() { |
1002 |
++ return this._connections.length == 0; |
1003 |
+ } |
1004 |
+}; |
1005 |
+ |
1006 |
@@ -778,10 +851,10 @@ index 0000000..a0cd576 |
1007 |
+ __proto__: NMDevice.prototype, |
1008 |
+ |
1009 |
+ _init: function(client, device, connections) { |
1010 |
-+ this.category = 'wireless'; |
1011 |
++ this.category = NMConnectionCategory.WIRELESS; |
1012 |
+ |
1013 |
+ this._overflowItem = null; |
1014 |
-+ this._accessPoints = [ ]; |
1015 |
++ this._networks = [ ]; |
1016 |
+ |
1017 |
+ // XXX: breaking the layers with this, but cannot call |
1018 |
+ // this.connectionValid until I have a device |
1019 |
@@ -794,22 +867,19 @@ index 0000000..a0cd576 |
1020 |
+ for (let i = 0; i < accessPoints.length; i++) { |
1021 |
+ // Access points are grouped by network name |
1022 |
+ let ap = accessPoints[i]; |
1023 |
-+ let name = String(ap.get_ssid()); |
1024 |
-+ let pos = this._findAccessPoint(name); |
1025 |
++ let ssid = ap.get_ssid(); |
1026 |
++ let pos = this._findNetwork(ssid); |
1027 |
+ let obj; |
1028 |
+ if (pos != -1) { |
1029 |
-+ obj = this._accessPoints[pos]; |
1030 |
++ obj = this._networks[pos]; |
1031 |
+ obj.accessPoints.push(ap); |
1032 |
-+ obj.accessPoints.sort(function(one, two) { |
1033 |
-+ return two.strength - one.strength; |
1034 |
-+ }); |
1035 |
+ } else { |
1036 |
-+ obj = { name: name, |
1037 |
++ obj = { ssid: ssid, |
1038 |
+ connections: [ ], |
1039 |
+ item: null, |
1040 |
+ accessPoints: [ ap ] |
1041 |
+ }; |
1042 |
-+ this._accessPoints.push(obj); |
1043 |
++ this._networks.push(obj); |
1044 |
+ } |
1045 |
+ |
1046 |
+ // Check if some connection is valid for this AP |
1047 |
@@ -827,32 +897,28 @@ index 0000000..a0cd576 |
1048 |
+ NMDevice.prototype._init.call(this, client, device, validConnections); |
1049 |
+ }, |
1050 |
+ |
1051 |
-+ _findAccessPoint: function(name) { |
1052 |
-+ for (let i = 0; i < this._accessPoints.length; i++) { |
1053 |
-+ if (this._accessPoints[i].name == name) |
1054 |
++ _findNetwork: function(ssid) { |
1055 |
++ for (let i = 0; i < this._networks.length; i++) { |
1056 |
++ if (ssidCompare(this._networks[i].ssid, ssid)) |
1057 |
+ return i; |
1058 |
+ } |
1059 |
+ return -1; |
1060 |
+ }, |
1061 |
+ |
1062 |
+ _accessPointAdded: function(device, accessPoint) { |
1063 |
-+ let name = String(accessPoint.get_ssid()); |
1064 |
-+ let pos = this._findAccessPoint(name); |
1065 |
++ let ssid = accessPoint.get_ssid(); |
1066 |
++ let pos = this._findNetwork(ssid); |
1067 |
+ let apObj; |
1068 |
+ if (pos != -1) { |
1069 |
-+ apObj = this._accessPoints[pos]; |
1070 |
++ apObj = this._network[pos]; |
1071 |
+ if (apObj.accessPoints.indexOf(accessPoint) != -1) { |
1072 |
-+ // already seen this AP |
1073 |
++ log('Access point was already seen, not adding again'); |
1074 |
+ return; |
1075 |
+ } |
1076 |
+ |
1077 |
+ apObj.accessPoints.push(accessPoint); |
1078 |
-+ apObj.accessPoints.sort(function(one, two) { |
1079 |
-+ return two.strength - one.strength; |
1080 |
-+ }); |
1081 |
-+ |
1082 |
+ } else { |
1083 |
-+ apObj = { name: name, |
1084 |
++ apObj = { ssid: ssid, |
1085 |
+ connections: [ ], |
1086 |
+ item: null, |
1087 |
+ accessPoints: [ accessPoint ] |
1088 |
@@ -861,8 +927,8 @@ index 0000000..a0cd576 |
1089 |
+ } |
1090 |
+ |
1091 |
+ // check if this enables new connections for this group |
1092 |
-+ for (let i = 0; i < this.connections.length; i++) { |
1093 |
-+ let connection = this.connections[i].connection; |
1094 |
++ for (let i = 0; i < this._connections.length; i++) { |
1095 |
++ let connection = this._connections[i].connection; |
1096 |
+ if (this._connectionValidForAP(connection, accessPoint) && |
1097 |
+ apObj.connections.indexOf(connection) == -1) { |
1098 |
+ apObj.connections.push(connection); |
1099 |
@@ -872,21 +938,21 @@ index 0000000..a0cd576 |
1100 |
+ if (this.device.state == NetworkManager.DeviceState.DISCONNECTED || |
1101 |
+ this.device.state == NetworkManager.DeviceState.ACTIVATED) { |
1102 |
+ // update everything (it would be too complicated to update just what has changed) |
1103 |
-+ this.clearSection(); |
1104 |
-+ this.createConnectionList(); |
1105 |
++ this._clearSection(); |
1106 |
++ this._createConnectionList(); |
1107 |
+ } |
1108 |
+ }, |
1109 |
+ |
1110 |
+ _accessPointRemoved: function(device, accessPoint) { |
1111 |
-+ let name = String(accessPoint.get_ssid()); |
1112 |
-+ let pos = this._findAccessPoint(name); |
1113 |
++ let ssid = accessPoint.get_ssid(); |
1114 |
++ let pos = this._findNetwork(ssid); |
1115 |
+ |
1116 |
+ if (pos == -1) { |
1117 |
+ log('Removing an access point that was never added'); |
1118 |
+ return; |
1119 |
+ } |
1120 |
+ |
1121 |
-+ let apObj = this._accessPoints[pos]; |
1122 |
++ let apObj = this._networks[pos]; |
1123 |
+ let i = apObj.accessPoints.indexOf(accessPoint); |
1124 |
+ |
1125 |
+ if (i == -1) { |
1126 |
@@ -899,25 +965,19 @@ index 0000000..a0cd576 |
1127 |
+ if (apObj.accessPoints.length == 0) { |
1128 |
+ if (apObj.item) |
1129 |
+ apObj.item.destroy(); |
1130 |
-+ this._accessPoints.splice(pos, 1); |
1131 |
-+ } |
1132 |
++ this._networks.splice(pos, 1); |
1133 |
++ } else if (apObj.item) |
1134 |
++ apObj.item.updateAccessPoints(apObj.accessPoints); |
1135 |
+ }, |
1136 |
+ |
1137 |
+ _createAPItem: function(connection, accessPointObj, useConnectionName) { |
1138 |
-+ accessPointObj.accessPoints.sort(function(one, two) { |
1139 |
-+ return two.strength - one.strength; |
1140 |
-+ }); |
1141 |
-+ let item = new NMAccessPointMenuItem(accessPointObj.accessPoints[0], useConnectionName ? connection._name : undefined); |
1142 |
++ let item = new NMNetworkMenuItem(accessPointObj.accessPoints, useConnectionName ? connection._name : undefined); |
1143 |
+ item._connection = connection; |
1144 |
+ item.connect('activate', Lang.bind(this, function() { |
1145 |
-+ // always connect to the strongest access point in a group |
1146 |
-+ let apList = accessPointObj.accessPoints; |
1147 |
-+ apList.sort(function(one, two) { |
1148 |
-+ return two.strength - one.strength; |
1149 |
-+ }); |
1150 |
-+ for (let i = 0; i < apList.length; i++) { |
1151 |
-+ if (this._connectionValidForAP(connection, apList[i])) { |
1152 |
-+ this.client.activate_connection(connection.path, this.device, apList[i].dbus_path, function() { }); |
1153 |
++ let accessPoints = sortAccessPoints(accessPointObj.accessPoints); |
1154 |
++ for (let i = 0; i < accessPoints.length; i++) { |
1155 |
++ if (this._connectionValidForAP(connection, accessPoints[i])) { |
1156 |
++ this._client.activate_connection(connection.path, this.device, accessPoints[i].dbus_path, null); |
1157 |
+ break; |
1158 |
+ } |
1159 |
+ } |
1160 |
@@ -926,11 +986,11 @@ index 0000000..a0cd576 |
1161 |
+ }, |
1162 |
+ |
1163 |
+ connectionValid: function(connection) { |
1164 |
-+ if (connection._type != '802-11-wireless') |
1165 |
++ if (connection._type != NetworkManager.SETTING_WIRELESS_SETTING_NAME) |
1166 |
+ return false; |
1167 |
+ |
1168 |
-+ let wirelessSettings = connection.get_setting_by_name('802-11-wireless'); |
1169 |
-+ let wirelessSecuritySettings = connection.get_setting_by_name('802-11-wireless-security'); |
1170 |
++ let wirelessSettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SETTING_NAME); |
1171 |
++ let wirelessSecuritySettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SECURITY_SETTING_NAME); |
1172 |
+ |
1173 |
+ let fixedMac = wirelessSettings.get_mac_address(); |
1174 |
+ if (fixedMac && !macCompare(fixedMac, macToArray(this.device.perm_hw_address))) |
1175 |
@@ -959,27 +1019,29 @@ index 0000000..a0cd576 |
1176 |
+ return true; |
1177 |
+ }, |
1178 |
+ |
1179 |
-+ clearSection: function() { |
1180 |
-+ NMDevice.prototype.clearSection.call(this); |
1181 |
++ _clearSection: function() { |
1182 |
++ NMDevice.prototype._clearSection.call(this); |
1183 |
+ |
1184 |
-+ for (let i = 0; i < this._accessPoints.length; i++) |
1185 |
-+ this._accessPoints[i].item = null; |
1186 |
++ for (let i = 0; i < this._networks.length; i++) |
1187 |
++ this._networks[i].item = null; |
1188 |
+ this._overflowItem = null; |
1189 |
+ }, |
1190 |
+ |
1191 |
+ removeConnection: function(connection, skipCreateAuto) { |
1192 |
+ if (!connection._uuid) |
1193 |
+ return; |
1194 |
-+ let pos = this.findConnection(connection._uuid); |
1195 |
-+ if (pos == -1) |
1196 |
++ let pos = this._findConnection(connection._uuid); |
1197 |
++ if (pos == -1) { |
1198 |
++ log('Removing connection that was never added'); |
1199 |
+ return; |
1200 |
++ } |
1201 |
+ |
1202 |
-+ let obj = this.connections[pos]; |
1203 |
-+ this.connections.splice(pos, 1); |
1204 |
++ let obj = this._connections[pos]; |
1205 |
++ this._connections.splice(pos, 1); |
1206 |
+ |
1207 |
+ let anyauto = false, forceupdate = false; |
1208 |
-+ for (let i = 0; i < this._accessPoints.length; i++) { |
1209 |
-+ let apObj = this._accessPoints[i]; |
1210 |
++ for (let i = 0; i < this._networks.length; i++) { |
1211 |
++ let apObj = this._networks[i]; |
1212 |
+ let connections = apObj.connections; |
1213 |
+ for (let k = 0; k < connections.length; k++) { |
1214 |
+ if (connections[k]._uuid == connection._uuid) { |
1215 |
@@ -1010,13 +1072,13 @@ index 0000000..a0cd576 |
1216 |
+ } |
1217 |
+ |
1218 |
+ if (forceupdate || (anyauto && !skipCreateAuto)) { |
1219 |
-+ this.clearSection(); |
1220 |
-+ this.createConnectionList(); |
1221 |
++ this._clearSection(); |
1222 |
++ this._createConnectionList(); |
1223 |
+ } |
1224 |
+ }, |
1225 |
+ |
1226 |
+ addConnection: function(connection) { |
1227 |
-+ if (this.findConnection(connection._uuid) != -1) { |
1228 |
++ if (this._findConnection(connection._uuid) != -1) { |
1229 |
+ log('Connection already added to menu, not adding again'); |
1230 |
+ return; |
1231 |
+ } |
1232 |
@@ -1027,12 +1089,12 @@ index 0000000..a0cd576 |
1233 |
+ name: connection._name, |
1234 |
+ uuid: connection._uuid, |
1235 |
+ }; |
1236 |
-+ this.connections.push(obj); |
1237 |
++ this._connections.push(obj); |
1238 |
+ |
1239 |
+ // find an appropriate access point |
1240 |
-+ let any = false; |
1241 |
-+ for (let i = 0; i < this._accessPoints.length; i++) { |
1242 |
-+ let apObj = this._accessPoints[i]; |
1243 |
++ let any = false, forceupdate = false; |
1244 |
++ for (let i = 0; i < this._networks.length; i++) { |
1245 |
++ let apObj = this._networks[i]; |
1246 |
+ |
1247 |
+ // Check if connection is valid for any of these access points |
1248 |
+ let any = false; |
1249 |
@@ -1049,7 +1111,7 @@ index 0000000..a0cd576 |
1250 |
+ (this.device.state == NetworkManager.DeviceState.DISCONNECTED || |
1251 |
+ this.device.state == NetworkManager.DeviceState.ACTIVATED)) { |
1252 |
+ // we need to show this connection |
1253 |
-+ if (apObj.item && apObj.connections.length > 2) { |
1254 |
++ if (apObj.item && apObj.item.menu) { |
1255 |
+ // We're already showing the submenu for this access point |
1256 |
+ apObj.item.menu.addMenuItem(this._createAPItem(connection, apObj, true)); |
1257 |
+ } else { |
1258 |
@@ -1057,23 +1119,29 @@ index 0000000..a0cd576 |
1259 |
+ apObj.item.destroy(); |
1260 |
+ if (apObj.connections.length == 1) { |
1261 |
+ apObj.item = this._createAPItem(connection, apObj, false); |
1262 |
++ this.section.addMenuItem(apObj.item); |
1263 |
+ } else { |
1264 |
-+ apObj.item = new PopupMenu.PopupSubMenuMenuItem(apObj.name); |
1265 |
-+ apObj.item.menu.addMenuItem(this._createAPItem(connection, apObj, true)); |
1266 |
++ apObj.item = null; |
1267 |
++ // we need to force an update to create the submenu |
1268 |
++ forceupdate = true; |
1269 |
+ } |
1270 |
-+ this.section.addMenuItem(apObj.item); |
1271 |
+ } |
1272 |
+ } |
1273 |
+ } |
1274 |
++ |
1275 |
++ if (forceupdate) { |
1276 |
++ this._clearSection(); |
1277 |
++ this._createSection(); |
1278 |
++ } |
1279 |
+ }, |
1280 |
+ |
1281 |
+ _connectionValidForAP: function(connection, ap) { |
1282 |
+ // copied and adapted from nm-applet |
1283 |
-+ let wirelessSettings = connection.get_setting_by_name('802-11-wireless'); |
1284 |
-+ if (wirelessSettings.get_ssid() != String(ap.get_ssid())) |
1285 |
++ let wirelessSettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SETTING_NAME); |
1286 |
++ if (!ssidCompare(wirelessSettings.get_ssid(), ap.get_ssid())) |
1287 |
+ return false; |
1288 |
+ |
1289 |
-+ let wirelessSecuritySettings = connection.get_setting_by_name('802-11-wireless-security'); |
1290 |
++ let wirelessSecuritySettings = connection.get_setting_by_name(NetworkManager.SETTING_WIRELESS_SECURITY_SETTING_NAME); |
1291 |
+ |
1292 |
+ let fixedBssid = wirelessSettings.get_bssid(); |
1293 |
+ if (fixedBssid && !macCompare(fixedBssid, macToArray(ap.hw_address))) |
1294 |
@@ -1097,44 +1165,52 @@ index 0000000..a0cd576 |
1295 |
+ return true; |
1296 |
+ }, |
1297 |
+ |
1298 |
-+ createActiveConnectionItems: function() { |
1299 |
++ _createActiveConnectionItems: function() { |
1300 |
+ let activeAp = this.device.active_access_point; |
1301 |
+ let icon, title; |
1302 |
-+ if (this.activeConnection._connection) { |
1303 |
-+ let connection = this.activeConnection._connection; |
1304 |
++ if (this._activeConnection._connection) { |
1305 |
++ let connection = this._activeConnection._connection; |
1306 |
+ if (activeAp) |
1307 |
-+ this.activeConnectionItem = new NMAccessPointMenuItem(activeAp, undefined, { reactive: false }); |
1308 |
++ this._activeConnectionItem = new NMNetworkMenuItem([ activeAp ], undefined, |
1309 |
++ { reactive: false }); |
1310 |
+ else |
1311 |
-+ this.activeConnectionItem = new PopupMenu.PopupImageMenuItem(connection._name, 'network-wireless-connected', { reactive: false }); |
1312 |
-+ this.disconnectItem = new PopupMenu.PopupMenuItem(_("Disconnect")); |
1313 |
-+ this.disconnectItem.connect('activate', Lang.bind(this, function() { |
1314 |
++ this._activeConnectionItem = new PopupMenu.PopupImageMenuItem(connection._name, |
1315 |
++ 'network-wireless-connected', |
1316 |
++ { reactive: false }); |
1317 |
++ this._disconnectItem = new PopupMenu.PopupMenuItem(_("Disconnect")); |
1318 |
++ this._disconnectItem.connect('activate', Lang.bind(this, function() { |
1319 |
+ this.device.disconnect(function() { }); |
1320 |
+ })); |
1321 |
+ } else { |
1322 |
-+ // We cannot read the connection (due to ACL, most likely), but we still show signal if we have it |
1323 |
++ // We cannot read the connection (due to ACL, or API incompatibility), but we still show signal if we have it |
1324 |
+ let menuItem; |
1325 |
+ if (activeAp) |
1326 |
-+ this.activeConnectionItem = new NMAccessPointMenuItem(activeAp, undefined, { reactive: false }); |
1327 |
++ this._activeConnectionItem = new NMNetworkMenuItem([ activeAp ], undefined, |
1328 |
++ { reactive: false }); |
1329 |
+ else |
1330 |
-+ this.activeConnectionItem = new PopupMenu.PopupImageMenuItem(_("Connected (private)"), 'network-wireless-connected', { reactive: false }); |
1331 |
++ this._activeConnectionItem = new PopupMenu.PopupImageMenuItem(_("Connected (private)"), |
1332 |
++ 'network-wireless-connected', |
1333 |
++ { reactive: false }); |
1334 |
+ } |
1335 |
-+ this.activeConnectionItem.setShowDot(true); |
1336 |
++ this._activeConnectionItem.setShowDot(true); |
1337 |
+ }, |
1338 |
+ |
1339 |
-+ createConnectionList: function() { |
1340 |
-+ if(this.activeConnection) { |
1341 |
-+ this.createActiveConnectionItems(); |
1342 |
-+ this.section.addMenuItem(this.activeConnectionItem); |
1343 |
-+ if (this.disconnectItem) |
1344 |
-+ this.section.addMenuItem(this.disconnectItem); |
1345 |
++ _createConnectionList: function() { |
1346 |
++ if(this._activeConnection) { |
1347 |
++ this._createActiveConnectionItems(); |
1348 |
++ this.section.addMenuItem(this._activeConnectionItem); |
1349 |
++ if (this._disconnectItem) |
1350 |
++ this.section.addMenuItem(this._disconnectItem); |
1351 |
+ } |
1352 |
+ |
1353 |
+ let activeAp = this.device.active_access_point; |
1354 |
-+ let activeApName = activeAp ? String(activeAp.get_ssid()) : null; |
1355 |
++ // Use undefined instead of null, so we're sure not to match anything |
1356 |
++ // that comes from NetworkManager |
1357 |
++ let activeApSsid = activeAp ? activeAp.get_ssid() : null; |
1358 |
+ |
1359 |
-+ for(let j = 0; j < this._accessPoints.length; j++) { |
1360 |
-+ let apObj = this._accessPoints[j]; |
1361 |
-+ if(apObj.name == activeApName) |
1362 |
++ for(let j = 0; j < this._networks.length; j++) { |
1363 |
++ let apObj = this._networks[j]; |
1364 |
++ if(activeAp && ssidCompare(apObj.ssid, activeApSsid)) |
1365 |
+ continue; |
1366 |
+ |
1367 |
+ let menuItem; |
1368 |
@@ -1142,26 +1218,35 @@ index 0000000..a0cd576 |
1369 |
+ if (apObj.connections.length == 1) |
1370 |
+ apObj.item = this._createAPItem(apObj.connections[0], apObj, false); |
1371 |
+ else { |
1372 |
-+ apObj.item = new PopupMenu.PopupSubMenuMenuItem(apObj.name); |
1373 |
++ let title = NetworkManager.utils_ssid_to_utf8(apObj.ssid, apObj.ssid.length) || _("<unknown>"); |
1374 |
++ apObj.item = new PopupMenu.PopupSubMenuMenuItem(title); |
1375 |
+ apObj.item._apObj = apObj; |
1376 |
+ for (let i = 0; i < apObj.connections.length; i++) |
1377 |
-+ menuItem.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true)); |
1378 |
++ apObj.item.menu.addMenuItem(this._createAPItem(apObj.connections[i], apObj, true)); |
1379 |
+ } |
1380 |
+ } else { |
1381 |
-+ apObj.item = new NMAccessPointMenuItem(apObj.accessPoints[0]); |
1382 |
++ apObj.item = new NMNetworkMenuItem(apObj.accessPoints); |
1383 |
+ apObj.item._apObj = apObj; |
1384 |
+ apObj.item.connect('activate', Lang.bind(this, function() { |
1385 |
++ let name; |
1386 |
++ let ssid = NetworkManager.utils_ssid_to_utf8(apObj.ssid, apObj.ssid.length); |
1387 |
++ if (ssid) { |
1388 |
++ /* TRANSLATORS: this the automatic wireless connection name (including the network name) */ |
1389 |
++ name = _("Auto %s").format(ssid); |
1390 |
++ } else |
1391 |
++ name = _("Auto wireless"); |
1392 |
++ |
1393 |
+ let connection = new NetworkManager.Connection(); |
1394 |
+ connection.add_setting(new NetworkManager.SettingWireless()); |
1395 |
+ connection.add_setting(new NetworkManager.SettingConnection({ |
1396 |
-+ /* TRANSLATORS: this the automatic wireless connection name (including the network name) */ |
1397 |
-+ id: _("Auto %s").format(apObj.name), |
1398 |
++ id: name, |
1399 |
+ autoconnect: true, // NetworkManager will know to ignore this if appropriate |
1400 |
+ uuid: NetworkManager.utils_uuid_generate(), |
1401 |
-+ type: '802-11-wireless' |
1402 |
++ type: NetworkManager.SETTING_WIRELESS_SETTING_NAME |
1403 |
+ })); |
1404 |
+ |
1405 |
-+ this.client.add_and_activate_connection(connection, this.device, apObj.accessPoints[0].dbus_path, function() { }) |
1406 |
++ accessPoints = sortAccessPoints(apObj.accessPoints); |
1407 |
++ this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null) |
1408 |
+ })); |
1409 |
+ } |
1410 |
+ |
1411 |
@@ -1170,6 +1255,7 @@ index 0000000..a0cd576 |
1412 |
+ else { |
1413 |
+ if (!this._overflowItem) { |
1414 |
+ this._overflowItem = new PopupMenu.PopupSubMenuMenuItem(_("More...")); |
1415 |
++ this.section.addMenuItem(this._overflowItem); |
1416 |
+ } |
1417 |
+ this._overflowItem.menu.addMenuItem(menuItem); |
1418 |
+ } |
1419 |
@@ -1198,16 +1284,17 @@ index 0000000..a0cd576 |
1420 |
+ this._statusSection.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); |
1421 |
+ this.menu.addMenuItem(this._statusSection); |
1422 |
+ |
1423 |
-+ this._allSections = [ ]; |
1424 |
++ this._deviceSections = [ ]; |
1425 |
+ |
1426 |
+ this._wiredSection = new PopupMenu.PopupMenuSection(); |
1427 |
-+ this._wiredItem = new PopupMenu.PopupMenuItem(_("Wired networks"), { style_class: 'popup-subtitle-menu-item', reactive: false }); |
1428 |
++ this._wiredItem = new PopupMenu.PopupMenuItem(_("Wired networks"), |
1429 |
++ { style_class: 'popup-subtitle-menu-item', reactive: false }); |
1430 |
+ this._wiredDevices = [ ]; |
1431 |
+ |
1432 |
+ this._wiredSection.addMenuItem(this._wiredItem); |
1433 |
+ this._wiredSection.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); |
1434 |
+ this._wiredSection.actor.hide(); |
1435 |
-+ this._allSections.push(this._wiredSection); |
1436 |
++ this._deviceSections.push(this._wiredSection); |
1437 |
+ this.menu.addMenuItem(this._wiredSection); |
1438 |
+ |
1439 |
+ this._wirelessSection = new PopupMenu.PopupMenuSection(); |
1440 |
@@ -1221,7 +1308,7 @@ index 0000000..a0cd576 |
1441 |
+ })); |
1442 |
+ this._wirelessSection.addMenuItem(newAdhocWireless); |
1443 |
+ |
1444 |
-+ let newHiddenWireless = new PopupMenu.PopupMenuItem(_("Connect to hidden wireless network...")); |
1445 |
++ let newHiddenWireless = new PopupMenu.PopupMenuItem(_("Other networks...")); |
1446 |
+ newHiddenWireless.connect('activate', Lang.bind(this, function() { |
1447 |
+ this._nmApplet.ConnectToHiddenNetworkRemote(); |
1448 |
+ })); |
1449 |
@@ -1229,7 +1316,7 @@ index 0000000..a0cd576 |
1450 |
+ |
1451 |
+ this._wirelessSection.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); |
1452 |
+ this._wirelessSection.actor.hide(); |
1453 |
-+ this._allSections.push(this._wirelessSection); |
1454 |
++ this._deviceSections.push(this._wirelessSection); |
1455 |
+ this.menu.addMenuItem(this._wirelessSection); |
1456 |
+ |
1457 |
+ this._wwanSection = new PopupMenu.PopupMenuSection(); |
1458 |
@@ -1239,13 +1326,18 @@ index 0000000..a0cd576 |
1459 |
+ this._wwanSection.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); |
1460 |
+ |
1461 |
+ this._wwanSection.actor.hide(); |
1462 |
-+ this._allSections.push(this._wwanSection); |
1463 |
++ this._deviceSections.push(this._wwanSection); |
1464 |
+ this.menu.addMenuItem(this._wwanSection); |
1465 |
+ |
1466 |
-+ // this._vpnDevice = new NMDeviceVPN(); |
1467 |
-+ // this._vpnSection = this._vpnDevice.section |
1468 |
-+ // this._allSections.push(this._vpnSection) |
1469 |
-+ // this.menu.addMenuItem(this._vpnSection); |
1470 |
++ this._vpnDevice = new NMDeviceVPN(); |
1471 |
++ this._vpnItem = new PopupMenu.PopupMenuItem(_("VPN Connections"), |
1472 |
++ { style_class: 'popup-subtitle-menu-item', reactive: false }); |
1473 |
++ this._vpnSection = new PopupMenu.PopupMenuSection(); |
1474 |
++ this._vpnSection.addMenuItem(this._vpnItem); |
1475 |
++ this._vpnSection.addMenuItem(this._vpnDevice.section); |
1476 |
++ this._vpnSection.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); |
1477 |
++ this._deviceSections.push(this._vpnSection); |
1478 |
++ this.menu.addMenuItem(this._vpnSection); |
1479 |
+ |
1480 |
+ this.menu.addAction(_("Network Settings"), function() { |
1481 |
+ Util.spawnDesktop('gnome-network-panel'); |
1482 |
@@ -1262,48 +1354,45 @@ index 0000000..a0cd576 |
1483 |
+ |
1484 |
+ // Device types |
1485 |
+ this._dtypes = { }; |
1486 |
-+ this._dtypes[makeClassKey(NMClient.DeviceEthernet.prototype)] = NMDeviceWired; |
1487 |
-+ this._dtypes[makeClassKey(NMClient.DeviceWifi.prototype)] = NMDeviceWireless; |
1488 |
-+ this._dtypes[makeClassKey(NMClient.GsmDevice.prototype)] = NMDeviceWWAN; |
1489 |
-+ this._dtypes[makeClassKey(NMClient.CdmaDevice.prototype)] = NMDeviceWWAN; |
1490 |
-+ this._dtypes[makeClassKey(NMClient.DeviceBt.prototype)] = NMDeviceBluetooth; |
1491 |
++ this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired; |
1492 |
++ this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless; |
1493 |
++ this._dtypes[NetworkManager.DeviceType.GSM] = NMDeviceWWAN; |
1494 |
++ this._dtypes[NetworkManager.DeviceType.CDMA] = NMDeviceWWAN; |
1495 |
++ this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth; |
1496 |
+ // FIXME: WWAN support (if enabled) |
1497 |
+ |
1498 |
+ // Connection types |
1499 |
+ this._ctypes = { }; |
1500 |
-+ this._ctypes['802-11-wireless'] = 'wireless'; |
1501 |
-+ this._ctypes['802-3-ethernet'] = this._ctypes['pppoe'] = 'wired'; |
1502 |
-+ this._ctypes['bluetooth'] = this._ctypes['cdma'] = this._ctypes['gsm'] = 'wwan'; |
1503 |
-+ this._ctypes['vpn'] = 'vpn'; |
1504 |
++ this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS; |
1505 |
++ this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED; |
1506 |
++ this._ctypes[NetworkManager.SETTING_PPPOE_SETTING_NAME] = NMConnectionCategory.WIRED; |
1507 |
++ this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN; |
1508 |
++ this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN; |
1509 |
++ this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN; |
1510 |
++ this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN; |
1511 |
+ |
1512 |
+ this._settings = NMClient.RemoteSettings.new(null); |
1513 |
+ this._settings.connect('connections-read', Lang.bind(this, function() { |
1514 |
-+ this._read_connections(); |
1515 |
-+ this._read_devices(); |
1516 |
-+ this._sync_nm_state(); |
1517 |
++ this._readConnections(); |
1518 |
++ this._readDevices(); |
1519 |
++ this._syncNMState(); |
1520 |
+ |
1521 |
+ // Connect to signals late so that early signals don't find in inconsistent state |
1522 |
-+ this._client.connect('notify::manager-running', Lang.bind(this, this._sync_nm_state)); |
1523 |
-+ this._client.connect('notify::networking-enabled', Lang.bind(this, this._sync_nm_state)); |
1524 |
-+ this._client.connect('notify::state', Lang.bind(this, this._sync_nm_state)); |
1525 |
-+ this._client.connect('notify::active-connections', Lang.bind(this, this._update_icon)); |
1526 |
-+ this._client.connect('device-added', Lang.bind(this, this._device_added)); |
1527 |
-+ this._client.connect('device-removed', Lang.bind(this, this._device_removed)); |
1528 |
-+ this._settings.connect('new-connection', Lang.bind(this, this._new_connection)); |
1529 |
++ this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState)); |
1530 |
++ this._client.connect('notify::networking-enabled', Lang.bind(this, this._syncNMState)); |
1531 |
++ this._client.connect('notify::state', Lang.bind(this, this._syncNMState)); |
1532 |
++ this._client.connect('notify::active-connections', Lang.bind(this, this._updateIcon)); |
1533 |
++ this._client.connect('device-added', Lang.bind(this, this._deviceAdded)); |
1534 |
++ this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved)); |
1535 |
++ this._settings.connect('new-connection', Lang.bind(this, this._newConnection)); |
1536 |
+ })); |
1537 |
-+ //this._sync_nm_state(); |
1538 |
+ }, |
1539 |
+ |
1540 |
+ _ensureSource: function() { |
1541 |
+ if (!this._source) { |
1542 |
-+ this._source = new MessageTray.Source(_("Network Manager")); |
1543 |
-+ let icon = new St.Icon({ icon_name: 'network-transmit-receive', |
1544 |
-+ icon_type: St.IconType.SYMBOLIC, |
1545 |
-+ icon_size: this._source.ICON_SIZE |
1546 |
-+ }); |
1547 |
-+ this._source._setSummaryIcon(icon); |
1548 |
++ this._source = new NMMessageTraySource(); |
1549 |
+ this._source._destroyId = this._source.connect('destroy', Lang.bind(this, function() { |
1550 |
-+ this._source.disconnect(this._source._destroyId); |
1551 |
++ this._source._destroyId = 0; |
1552 |
+ this._source = null; |
1553 |
+ })); |
1554 |
+ Main.messageTray.add(this._source); |
1555 |
@@ -1346,21 +1435,20 @@ index 0000000..a0cd576 |
1556 |
+ }); |
1557 |
+ |
1558 |
+ this._client.connect('notify::' + type + '-enabled', handler); |
1559 |
-+ this._client.connect('notify::' + type + 'hardware-enabled', handler); |
1560 |
++ this._client.connect('notify::' + type + '-hardware-enabled', handler); |
1561 |
+ this['_' + type + 'Item'] = item; |
1562 |
+ handler(); |
1563 |
+ }, |
1564 |
+ |
1565 |
-+ _read_devices: function() { |
1566 |
++ _readDevices: function() { |
1567 |
+ let devices = this._client.get_devices(); |
1568 |
+ for (let i = 0; i < devices.length; ++i) { |
1569 |
-+ this._device_added(this._client, devices[i]); |
1570 |
++ this._deviceAdded(this._client, devices[i]); |
1571 |
+ } |
1572 |
+ }, |
1573 |
+ |
1574 |
-+ _device_added: function(client, device) { |
1575 |
-+ let objKey = makeClassKey(device); |
1576 |
-+ let wrapperClass = this._dtypes[objKey]; |
1577 |
++ _deviceAdded: function(client, device) { |
1578 |
++ let wrapperClass = this._dtypes[device.get_device_type()]; |
1579 |
+ if (wrapperClass) { |
1580 |
+ // XXX: check what nm-applet does here |
1581 |
+ device._description = device.get_product(); |
1582 |
@@ -1393,6 +1481,10 @@ index 0000000..a0cd576 |
1583 |
+ { icon: icon }); |
1584 |
+ this._source.notify(notification); |
1585 |
+ })); |
1586 |
++ wrapper._destroyId = wrapper.connect('destroy', function(wrapper) { |
1587 |
++ wrapper.disconnect(wrapper._networkLostId); |
1588 |
++ wrapper.disconnect(wrapper._activationFailedId); |
1589 |
++ }); |
1590 |
+ let section = this['_' + wrapper.category + 'Section']; |
1591 |
+ let devices = this['_' + wrapper.category + 'Devices']; |
1592 |
+ |
1593 |
@@ -1408,10 +1500,10 @@ index 0000000..a0cd576 |
1594 |
+ devices[i].titleItem.actor.hide(); |
1595 |
+ } |
1596 |
+ } else |
1597 |
-+ log('Invalid network device class, is ' + objKey); |
1598 |
++ log('Invalid network device type, is ' + device.get_device_type()); |
1599 |
+ }, |
1600 |
+ |
1601 |
-+ _device_removed: function(client, device) { |
1602 |
++ _deviceRemoved: function(client, device) { |
1603 |
+ if (!device._delegate) { |
1604 |
+ log('Removing a network device that was not added (race condition?)'); |
1605 |
+ return; |
1606 |
@@ -1436,7 +1528,7 @@ index 0000000..a0cd576 |
1607 |
+ } |
1608 |
+ }, |
1609 |
+ |
1610 |
-+ _sync_active_connections: function() { |
1611 |
++ _syncActiveConnections: function() { |
1612 |
+ let closedConnections = [ ]; |
1613 |
+ let newActiveConnections = this._client.get_active_connections() || [ ]; |
1614 |
+ for (let i = 0; i < this._activeConnections.length; i++) { |
1615 |
@@ -1469,10 +1561,16 @@ index 0000000..a0cd576 |
1616 |
+ let a = this._activeConnections[i]; |
1617 |
+ |
1618 |
+ if (!a._inited) { |
1619 |
-+ a._notifyDefaultId = a.connect('notify::default', Lang.bind(this, this._update_icon)); |
1620 |
-+ a._notifyDefault6Id = a.connect('notify::default6', Lang.bind(this, this._update_icon)); |
1621 |
++ a._notifyDefaultId = a.connect('notify::default', Lang.bind(this, this._updateIcon)); |
1622 |
++ a._notifyDefault6Id = a.connect('notify::default6', Lang.bind(this, this._updateIcon)); |
1623 |
+ if (a.state == NetworkManager.ActiveConnectionState.ACTIVATING) // prepare to notify to the user |
1624 |
-+ a._notifyStateId = a.connect('notify::state', Lang.bind(this, this._notify_active_connection)); |
1625 |
++ a._notifyStateId = a.connect('notify::state', Lang.bind(this, this._notifyActiveConnection)); |
1626 |
++ else { |
1627 |
++ // notify immediately |
1628 |
++ Mainloop.idle_add(Lang.bind(this, function() { |
1629 |
++ this._notifyActiveConnection(a); |
1630 |
++ })); |
1631 |
++ } |
1632 |
+ |
1633 |
+ a._inited = true; |
1634 |
+ } |
1635 |
@@ -1486,6 +1584,7 @@ index 0000000..a0cd576 |
1636 |
+ } else { |
1637 |
+ a._connection = null; |
1638 |
+ a._type = null; |
1639 |
++ a._section = null; |
1640 |
+ log('Cannot find connection for active (or connection cannot be read)'); |
1641 |
+ } |
1642 |
+ } |
1643 |
@@ -1507,7 +1606,7 @@ index 0000000..a0cd576 |
1644 |
+ } |
1645 |
+ |
1646 |
+ if (!a._primaryDevice) { |
1647 |
-+ if (a._type != 'vpn') { |
1648 |
++ if (a._type != NetworkManager.SETTING_VPN_SETTING_NAME) { |
1649 |
+ // find a good device to be considered primary |
1650 |
+ // XXX: check what nm-applet does here |
1651 |
+ a._primaryDevice = null; |
1652 |
@@ -1527,36 +1626,32 @@ index 0000000..a0cd576 |
1653 |
+ } |
1654 |
+ } |
1655 |
+ |
1656 |
-+ if (activating) |
1657 |
-+ this._mainConnection = activating; |
1658 |
-+ else if (default_ip4) |
1659 |
-+ this._mainConnection = default_ip4; |
1660 |
-+ else |
1661 |
-+ this._mainConnection = default_ip6; |
1662 |
++ this._mainConnection = activating || default_ip4 || default_ip6 || this._activeConnections[0] || null; |
1663 |
+ }, |
1664 |
+ |
1665 |
-+ _notify_active_connection: function(active) { |
1666 |
-+ if (active.state == NetworkManager.ActiveConnectionState.ACTIVE) { |
1667 |
++ _notifyActiveConnection: function(active) { |
1668 |
++ if (active.state == NetworkManager.ActiveConnectionState.ACTIVATED) { |
1669 |
+ this._ensureSource(); |
1670 |
+ |
1671 |
+ let icon; |
1672 |
+ let banner; |
1673 |
-+ switch (active._type) { |
1674 |
-+ case 'gsm': |
1675 |
-+ case 'cdma': |
1676 |
-+ case 'bluetooth': |
1677 |
++ switch (active._section) { |
1678 |
++ case NMConnectionCategory.WWAN: |
1679 |
+ icon = 'network-cellular-signal-excellent'; |
1680 |
+ banner = _("You're now connected to mobile broadband connection '%s'").format(active._connection._name); |
1681 |
+ break; |
1682 |
-+ case '802-11-wireless': |
1683 |
++ case NMConnectionCategory.WIRELESS: |
1684 |
+ icon = 'network-wireless-signal-excellent'; |
1685 |
+ banner = _("You're now connected to wireless network '%s'").format(active._connection._name); |
1686 |
+ break; |
1687 |
-+ case '802-3-ethernet': |
1688 |
-+ case 'pppoe': |
1689 |
++ case NMConnectionCategory.WIRED: |
1690 |
+ icon = 'network-wired'; |
1691 |
+ banner = _("You're now connected to wired network '%s'").format(active._connection._name); |
1692 |
+ break; |
1693 |
++ case NMConnectionCategory.VPN: |
1694 |
++ icon = 'network-vpn'; |
1695 |
++ banner = _("You're now connected to VPN network '%s'").format(active._connection._name); |
1696 |
++ break; |
1697 |
+ default: |
1698 |
+ // a fallback for a generic 'connected' icon |
1699 |
+ icon = 'network-transmit-receive'; |
1700 |
@@ -1564,7 +1659,7 @@ index 0000000..a0cd576 |
1701 |
+ } |
1702 |
+ |
1703 |
+ let iconActor = new St.Icon({ icon_name: icon, |
1704 |
-+ con_type: St.IconType.SYMBOLIC, |
1705 |
++ icon_type: St.IconType.SYMBOLIC, |
1706 |
+ icon_size: this._source.ICON_SIZE |
1707 |
+ }); |
1708 |
+ let notification = new MessageTray.Notification(this._source, |
1709 |
@@ -1573,14 +1668,16 @@ index 0000000..a0cd576 |
1710 |
+ { icon: iconActor }); |
1711 |
+ this._source.notify(notification); |
1712 |
+ |
1713 |
-+ active.disconnect(active._stateChangeId); |
1714 |
-+ active._stateChangeId = 0; |
1715 |
++ if (active._stateChangeId) { |
1716 |
++ active.disconnect(active._stateChangeId); |
1717 |
++ active._stateChangeId = 0; |
1718 |
++ } |
1719 |
+ } |
1720 |
+ |
1721 |
-+ this._sync_nm_state(); |
1722 |
++ this._syncNMState(); |
1723 |
+ }, |
1724 |
+ |
1725 |
-+ _read_connections: function() { |
1726 |
++ _readConnections: function() { |
1727 |
+ let connections = this._settings.list_connections(); |
1728 |
+ for (let i = 0; i < connections.length; i++) { |
1729 |
+ let connection = connections[i]; |
1730 |
@@ -1588,75 +1685,77 @@ index 0000000..a0cd576 |
1731 |
+ log('Connection was already seen, when reading the connections for the first time (race condition?)'); |
1732 |
+ continue; |
1733 |
+ } |
1734 |
-+ connection.connect('removed', Lang.bind(this, this._connection_removed)); |
1735 |
-+ // we don't connect to 'updated' because GJS currently cannot deliver it |
1736 |
-+ // (it needs to type overrides from GIR) |
1737 |
-+ //connection.connect('updated', Lang.bind(this, this._update_connection)); |
1738 |
-+ |
1739 |
-+ let connectionSettings = connection.get_setting_by_name('connection'); |
1740 |
-+ connection._type = connectionSettings.type; |
1741 |
-+ connection._section = this._ctypes[connection._type]; |
1742 |
-+ connection._name = connectionSettings.id; |
1743 |
-+ connection._uuid = connectionSettings.uuid; |
1744 |
++ connection.connect('removed', Lang.bind(this, this._connectionRemoved)); |
1745 |
++ connection.connect('updated', Lang.bind(this, this._updateConnection)); |
1746 |
++ |
1747 |
++ this._updateConnection(connection); |
1748 |
+ this._connections.push(connection); |
1749 |
+ } |
1750 |
+ }, |
1751 |
+ |
1752 |
-+ _new_connection: function(settings, connection) { |
1753 |
++ _newConnection: function(settings, connection) { |
1754 |
+ if (connection._uuid) { |
1755 |
+ log('Connection was already seen, not adding again...'); |
1756 |
+ return; |
1757 |
+ } |
1758 |
+ |
1759 |
-+ connection.connect('removed', Lang.bind(this, this._connection_removed)); |
1760 |
-+ //connection.connect('updated', Lang.bind(this, this._update_connection)); |
1761 |
++ connection.connect('removed', Lang.bind(this, this._connectionRemoved)); |
1762 |
++ connection.connect('updated', Lang.bind(this, this._updateConnection)); |
1763 |
+ |
1764 |
-+ let connectionSettings = connection.get_setting_by_name('connection'); |
1765 |
-+ connection._type = connectionSettings.type; |
1766 |
-+ connection._section = this._ctypes[connection._type]; |
1767 |
-+ connection._name = connectionSettings.id; |
1768 |
-+ connection._uuid = connectionSettings.uuid; |
1769 |
++ this._updateConnection(connection); |
1770 |
+ this._connections.push(connection); |
1771 |
+ |
1772 |
-+ this._update_icon(); |
1773 |
++ this._updateIcon(); |
1774 |
+ }, |
1775 |
+ |
1776 |
-+ _connection_removed: function(connection) { |
1777 |
++ _connectionRemoved: function(connection) { |
1778 |
+ let pos = this._connections.indexOf(connection); |
1779 |
+ if (pos != -1) |
1780 |
+ this._connections.splice(connection); |
1781 |
+ |
1782 |
-+ if (!connection._ever_added) |
1783 |
++ if (!connection._everAdded) |
1784 |
+ return; |
1785 |
+ |
1786 |
+ let section = connection._section; |
1787 |
-+ let devices = this['_' + section + 'Devices']; |
1788 |
-+ for (let i = 0; i < devices.length; i++) |
1789 |
-+ devices[i].removeConnection(connection); |
1790 |
++ if (section == NMConnectionCategory.VPN) { |
1791 |
++ this._vpnDevice.removeConnection(connection); |
1792 |
++ if (this._vpnDevice.empty) |
1793 |
++ this._vpnSection.actor.hide(); |
1794 |
++ } else { |
1795 |
++ let devices = this['_' + section + 'Devices']; |
1796 |
++ for (let i = 0; i < devices.length; i++) |
1797 |
++ devices[i].removeConnection(connection); |
1798 |
++ } |
1799 |
+ }, |
1800 |
+ |
1801 |
-+ _update_connection: function(connection) { |
1802 |
-+ this._connection_removed(connection); |
1803 |
++ _updateConnection: function(connection) { |
1804 |
++ this._connectionRemoved(connection); |
1805 |
+ |
1806 |
-+ let connectionSettings = connection.get_setting_by_name('connection'); |
1807 |
++ let connectionSettings = connection.get_setting_by_name(NetworkManager.SETTING_CONNECTION_SETTING_NAME); |
1808 |
+ connection._type = connectionSettings.type; |
1809 |
+ connection._section = this._ctypes[connection._type]; |
1810 |
+ connection._name = connectionSettings.id; |
1811 |
+ connection._uuid = connectionSettings.uuid; |
1812 |
+ |
1813 |
+ let section = connection._section; |
1814 |
-+ let devices = this['_' + section + 'Devices']; |
1815 |
-+ for (let i = 0; i < devices.length; i++) { |
1816 |
-+ if (devices[i].connectionValid(connection)) { |
1817 |
-+ devices[i].addConnection(connection); |
1818 |
-+ connection._ever_added = true; |
1819 |
++ if (section == NMConnectionCategory.VPN) { |
1820 |
++ this._vpnDevice.addConnection(connection); |
1821 |
++ this._vpnSection.actor.show(); |
1822 |
++ connection._everAdded = true; |
1823 |
++ } else { |
1824 |
++ let devices = this['_' + section + 'Devices']; |
1825 |
++ for (let i = 0; i < devices.length; i++) { |
1826 |
++ if (devices[i].connectionValid(connection)) { |
1827 |
++ devices[i].addConnection(connection); |
1828 |
++ connection._everAdded = true; |
1829 |
++ } |
1830 |
+ } |
1831 |
+ } |
1832 |
+ }, |
1833 |
+ |
1834 |
-+ _hideAll: function() { |
1835 |
-+ for (let i = 0; i < this._allSections.length; i++) { |
1836 |
-+ let item = this._allSections[i]; |
1837 |
++ _hideDevices: function() { |
1838 |
++ for (let i = 0; i < this._deviceSections.length; i++) { |
1839 |
++ let item = this._deviceSections[i]; |
1840 |
+ item.actor.hide(); |
1841 |
+ } |
1842 |
+ }, |
1843 |
@@ -1666,17 +1765,26 @@ index 0000000..a0cd576 |
1844 |
+ |
1845 |
+ if (this._wiredDevices.length > 0) |
1846 |
+ this._wiredSection.actor.show(); |
1847 |
++ else |
1848 |
++ this._wiredSection.actor.hide(); |
1849 |
+ |
1850 |
+ if (this._wirelessDevices.length > 0) |
1851 |
+ this._wirelessSection.actor.show(); |
1852 |
++ else |
1853 |
++ this._wirelessSection.actor.hide(); |
1854 |
+ |
1855 |
+ if (this._wwanDevices.length > 0) |
1856 |
+ this._wwanSection.actor.show(); |
1857 |
++ else |
1858 |
++ this._wwanSection.actor.hide(); |
1859 |
+ |
1860 |
-+ // this._vpnSection.actor.show(); |
1861 |
++ if (!this._vpnDevice.empty) |
1862 |
++ this._vpnSection.actor.show(); |
1863 |
++ else |
1864 |
++ this._vpnSection.actor.hide(); |
1865 |
+ }, |
1866 |
+ |
1867 |
-+ _sync_nm_state: function() { |
1868 |
++ _syncNMState: function() { |
1869 |
+ if (!this._client.manager_running) { |
1870 |
+ log('NetworkManager is not running, hiding...'); |
1871 |
+ this.menu.close(); |
1872 |
@@ -1687,18 +1795,18 @@ index 0000000..a0cd576 |
1873 |
+ |
1874 |
+ if (!this._client.networking_enabled) { |
1875 |
+ this.setIcon('network-offline'); |
1876 |
-+ this._hideAll(); |
1877 |
++ this._hideDevices(); |
1878 |
+ this._statusItem.label.text = _("Networking is disabled"); |
1879 |
+ this._statusSection.actor.show(); |
1880 |
+ return; |
1881 |
+ } |
1882 |
+ |
1883 |
+ this._showNormal(); |
1884 |
-+ this._update_icon(); |
1885 |
++ this._updateIcon(); |
1886 |
+ }, |
1887 |
+ |
1888 |
-+ _update_icon: function() { |
1889 |
-+ this._sync_active_connections(); |
1890 |
++ _updateIcon: function() { |
1891 |
++ this._syncActiveConnections(); |
1892 |
+ let mc = this._mainConnection; |
1893 |
+ let hasApIcon = false; |
1894 |
+ let hasMobileIcon = false; |
1895 |
@@ -1712,22 +1820,23 @@ index 0000000..a0cd576 |
1896 |
+ log('NetworkManager is connecting, but we have no ActiveConnection activating'); |
1897 |
+ break; |
1898 |
+ } |
1899 |
-+ switch (mc._type) { |
1900 |
-+ case 'gsm': |
1901 |
-+ case 'cdma': |
1902 |
-+ case 'bluetooth': |
1903 |
++ switch (mc._section) { |
1904 |
++ case NMConnectionCategory.WWAN: |
1905 |
+ this.setIcon('network-cellular-acquiring'); |
1906 |
+ break; |
1907 |
-+ case '802-11-wireless': |
1908 |
++ case NMConnectionCategory.WIRELESS: |
1909 |
+ this.setIcon('network-wireless-acquiring'); |
1910 |
+ break; |
1911 |
-+ case '802-3-ethernet': |
1912 |
-+ case 'pppoe': |
1913 |
++ case NMConnectionCategory.WIRED: |
1914 |
+ this.setIcon('network-wired-acquiring'); |
1915 |
+ break; |
1916 |
++ case NMConnectionCategory.VPN: |
1917 |
++ // XXX: there is no network-vpn-acquiring |
1918 |
++ this.setIcon('network-vpn'); |
1919 |
++ break; |
1920 |
+ default: |
1921 |
+ this.setIcon('network-error'); |
1922 |
-+ log ('Invalid active connection type ' + mc._type); |
1923 |
++ log('Invalid active connection type ' + mc._section); |
1924 |
+ } |
1925 |
+ break; |
1926 |
+ case NetworkManager.State.CONNECTED_LOCAL: |
1927 |
@@ -1738,18 +1847,19 @@ index 0000000..a0cd576 |
1928 |
+ break; |
1929 |
+ } |
1930 |
+ let dev; |
1931 |
-+ switch (mc._type) { |
1932 |
-+ case '802-11-wireless': |
1933 |
++ switch (mc._section) { |
1934 |
++ case NMConnectionCategory.WIRELESS: |
1935 |
+ dev = mc._primaryDevice; |
1936 |
+ if (dev) { |
1937 |
+ let ap = dev.device.active_access_point; |
1938 |
+ let mode = dev.device.mode; |
1939 |
+ if (!ap) { |
1940 |
+ if (mode != NetworkManager['80211Mode'].ADHOC) { |
1941 |
-+ log ('An active wireless connection, in infrastructure mode, involves no access point?'); |
1942 |
++ log('An active wireless connection, in infrastructure mode, involves no access point?'); |
1943 |
+ break; |
1944 |
+ } |
1945 |
-+ this.setIcon('network-wireless-connected'); |
1946 |
++ // XXX: there is no network-wireless-connected |
1947 |
++ this.setIcon('network-wireless-signal-excellent'); |
1948 |
+ } else { |
1949 |
+ if (this._accessPointUpdateId && this._activeAccessPoint != ap) { |
1950 |
+ this._activeAccessPoint.disconnect(this._accessPointUpdateId); |
1951 |
@@ -1763,20 +1873,19 @@ index 0000000..a0cd576 |
1952 |
+ } |
1953 |
+ break; |
1954 |
+ } else { |
1955 |
-+ log ('Active connection with no primary device?'); |
1956 |
++ log('Active connection with no primary device?'); |
1957 |
+ break; |
1958 |
+ } |
1959 |
-+ case '802-3-ethernet': |
1960 |
-+ case 'pppoe': |
1961 |
-+ case 'serial': |
1962 |
++ case NMConnectionCategory.WIRED: |
1963 |
+ this.setIcon('network-wired-symbolic'); |
1964 |
+ break; |
1965 |
-+ case 'bluetooth': |
1966 |
-+ // XXX: NetworkManager does not give us signal for bluetooth |
1967 |
-+ this.setIcon('network-cellular-signal-excellent'); |
1968 |
-+ break; |
1969 |
-+ case 'cdma': |
1970 |
-+ case 'gsm': |
1971 |
++ case NMConnectionCategory.WWAN: |
1972 |
++ if (mc._type == NetworkManager.SETTING_BLUETOOTH_SETTING_NAME) { |
1973 |
++ // XXX: NetworkManager does not give us signal for bluetooth |
1974 |
++ this.setIcon('network-cellular-signal-excellent'); |
1975 |
++ break; |
1976 |
++ } |
1977 |
++ |
1978 |
+ dev = mc._primaryDevice; |
1979 |
+ if (this._mobileUpdateId && this._mobileUpdateDevice != dev) { |
1980 |
+ this._mobileUpdateDevice.disconnect(this._mobileUpdateId); |
1981 |
@@ -1788,11 +1897,11 @@ index 0000000..a0cd576 |
1982 |
+ this.setIcon('network-cellular-signal-' + signalToIcon(dev.mobileDevice.signal_quality)); |
1983 |
+ hasMobileIcon = true; |
1984 |
+ break; |
1985 |
-+ case 'vpn': |
1986 |
++ case NMConnectionCategory.VPN: |
1987 |
+ this.setIcon('network-vpn'); |
1988 |
+ break; |
1989 |
+ default: |
1990 |
-+ log('Invalid active connection type ' + mc._type); |
1991 |
++ log('Invalid active connection type ' + mc._section); |
1992 |
+ this.setIcon('network-error'); |
1993 |
+ break; |
1994 |
+ } |
1995 |
@@ -1815,8 +1924,26 @@ index 0000000..a0cd576 |
1996 |
+ } |
1997 |
+ } |
1998 |
+}; |
1999 |
++ |
2000 |
++function NMMessageTraySource() { |
2001 |
++ this._init(); |
2002 |
++} |
2003 |
++ |
2004 |
++NMMessageTraySource.prototype = { |
2005 |
++ __proto__: MessageTray.Source.prototype, |
2006 |
++ |
2007 |
++ _init: function() { |
2008 |
++ MessageTray.Source.prototype._init.call(this, _("Network Manager")); |
2009 |
++ |
2010 |
++ let icon = new St.Icon({ icon_name: 'network-transmit-receive', |
2011 |
++ icon_type: St.IconType.SYMBOLIC, |
2012 |
++ icon_size: this.ICON_SIZE |
2013 |
++ }); |
2014 |
++ this._setSummaryIcon(icon); |
2015 |
++ } |
2016 |
++}; |
2017 |
diff --git a/tools/build/gnome-shell.modules b/tools/build/gnome-shell.modules |
2018 |
-index e8b5493..b14fd53 100644 |
2019 |
+index e8b5493..2f44c5d 100644 |
2020 |
--- a/tools/build/gnome-shell.modules |
2021 |
+++ b/tools/build/gnome-shell.modules |
2022 |
@@ -9,6 +9,8 @@ |
2023 |
@@ -1828,23 +1955,7 @@ index e8b5493..b14fd53 100644 |
2024 |
<repository type="tarball" name="cairo.org" |
2025 |
href="http://cairographics.org/"/> |
2026 |
<repository type="tarball" name="0pointer.de" |
2027 |
-@@ -237,6 +239,7 @@ |
2028 |
- <dep package="gnome-settings-daemon"/> |
2029 |
- <dep package="gnome-bluetooth"/> |
2030 |
- <dep package="telepathy-glib"/> |
2031 |
-+ <dep package="NetworkManager"/> |
2032 |
- </dependencies> |
2033 |
- </autotools> |
2034 |
- |
2035 |
-@@ -255,6 +258,7 @@ |
2036 |
- <dep package="gnome-themes-standard"/> |
2037 |
- <dep package="gnome-shell"/> |
2038 |
- <dep package="gnome-power-manager"/> |
2039 |
-+ <dep package="network-manager-applet"/> |
2040 |
- </dependencies> |
2041 |
- </metamodule> |
2042 |
- |
2043 |
-@@ -315,4 +319,19 @@ |
2044 |
+@@ -315,4 +317,19 @@ |
2045 |
</dependencies> |
2046 |
</autotools> |
2047 |
|
2048 |
|
2049 |
diff --git a/gnome-base/gnome-shell/gnome-shell-9999.ebuild b/gnome-base/gnome-shell/gnome-shell-9999.ebuild |
2050 |
index ef3cd5a..f3a6869 100644 |
2051 |
--- a/gnome-base/gnome-shell/gnome-shell-9999.ebuild |
2052 |
+++ b/gnome-base/gnome-shell/gnome-shell-9999.ebuild |
2053 |
@@ -91,7 +91,7 @@ src_prepare() { |
2054 |
ewarn "Adding support for the experimental NetworkManager applet." |
2055 |
ewarn "This needs the latest NetworkManager & nm-applet trunk." |
2056 |
ewarn "Report bugs about this to 'nirbheek' on #gentoo-desktop @ FreeNode." |
2057 |
- epatch "${FILESDIR}/${PN}-experimental-nm-applet.patch" |
2058 |
+ epatch "${FILESDIR}/${PN}-experimental-nm-applet-1.0.patch" |
2059 |
fi |
2060 |
|
2061 |
gnome2_src_prepare |
2062 |
|
2063 |
diff --git a/net-misc/networkmanager/files/networkmanager-more-gi-annotations.patch b/net-misc/networkmanager/files/networkmanager-more-gi-annotations.patch |
2064 |
new file mode 100644 |
2065 |
index 0000000..e6bac7d |
2066 |
--- /dev/null |
2067 |
+++ b/net-misc/networkmanager/files/networkmanager-more-gi-annotations.patch |
2068 |
@@ -0,0 +1,43 @@ |
2069 |
+From a420d59ea24a1eb82a7c1dc96e3cf5b38b0fd757 Mon Sep 17 00:00:00 2001 |
2070 |
+From: Giovanni Campagna <gcampagna@×××××××××.org> |
2071 |
+Date: Tue, 22 Feb 2011 23:34:41 +0100 |
2072 |
+Subject: [PATCH] libnm-util: another introspection annotation |
2073 |
+ |
2074 |
+nm_utils_ssid_to_utf8 has gchar* in the signature, but it accepts |
2075 |
+an array of bytes, not a string. Fix with the appropriate |
2076 |
+annotation. |
2077 |
+ |
2078 |
+https://bugzilla.gnome.org/show_bug.cgi?id=643011 |
2079 |
+--- |
2080 |
+ libnm-util/nm-utils.c | 9 +++++---- |
2081 |
+ 1 files changed, 5 insertions(+), 4 deletions(-) |
2082 |
+ |
2083 |
+diff --git a/libnm-util/nm-utils.c b/libnm-util/nm-utils.c |
2084 |
+index 87c5d5f..c2134db 100644 |
2085 |
+--- a/libnm-util/nm-utils.c |
2086 |
++++ b/libnm-util/nm-utils.c |
2087 |
+@@ -304,7 +304,8 @@ nm_utils_deinit (void) |
2088 |
+ |
2089 |
+ /** |
2090 |
+ * nm_utils_ssid_to_utf8: |
2091 |
+- * @ssid: pointer to a buffer containing the SSID data |
2092 |
++ * @ssid: (array length=len) (element-type guint8): pointer to a buffer |
2093 |
++ * containing the SSID data |
2094 |
+ * @len: length of the SSID data in @ssid |
2095 |
+ * |
2096 |
+ * WiFi SSIDs are byte arrays, they are _not_ strings. Thus, an SSID may |
2097 |
+@@ -330,9 +331,9 @@ nm_utils_deinit (void) |
2098 |
+ * Again, this function should be used for debugging and display purposes |
2099 |
+ * _only_. |
2100 |
+ * |
2101 |
+- * Returns: an allocated string containing a UTF-8 representation of the |
2102 |
+- * SSID, which must be freed by the caller using g_free(). Returns NULL |
2103 |
+- * on errors. |
2104 |
++ * Returns: (transfer full): an allocated string containing a UTF-8 representation |
2105 |
++ * of the SSID, which must be freed by the caller using g_free(). Returns |
2106 |
++ * NULL on errors. |
2107 |
+ **/ |
2108 |
+ char * |
2109 |
+ nm_utils_ssid_to_utf8 (const char *ssid, guint32 len) |
2110 |
+-- |
2111 |
+1.7.4 |
2112 |
\ No newline at end of file |
2113 |
|
2114 |
diff --git a/net-misc/networkmanager/networkmanager-9999.ebuild b/net-misc/networkmanager/networkmanager-9999.ebuild |
2115 |
index d4bbdd6..686bad1 100644 |
2116 |
--- a/net-misc/networkmanager/networkmanager-9999.ebuild |
2117 |
+++ b/net-misc/networkmanager/networkmanager-9999.ebuild |
2118 |
@@ -133,6 +133,9 @@ src_prepare() { |
2119 |
# FIXME: does not apply |
2120 |
#epatch "${FILESDIR}/${PN}-0.8.2-shared-connection.patch" |
2121 |
|
2122 |
+ # https://bugzilla.gnome.org/show_bug.cgi?id=643011 |
2123 |
+ epatch "${FILESDIR}/${PN}-more-gi-annotations.patch" |
2124 |
+ |
2125 |
gnome2_src_prepare |
2126 |
} |