Merge lp:~franciscoda/docky/nm-1.0.7-docky-fix into lp:docky
- nm-1.0.7-docky-fix
- Merge into trunk
Proposed by
Francisco
Status: | Needs review |
---|---|
Proposed branch: | lp:~franciscoda/docky/nm-1.0.7-docky-fix |
Merge into: | lp:docky |
Diff against target: |
631 lines (+104/-95) 23 files modified
Docky.Services/Docky.Services/SystemService.cs (+7/-4) StandardPlugins/NetworkManager/src/ConnectionManager.cs (+4/-32) StandardPlugins/NetworkManager/src/DBusObject.cs (+18/-2) StandardPlugins/NetworkManager/src/DeviceManager.cs (+1/-1) StandardPlugins/NetworkManager/src/Enums.cs (+12/-9) StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs (+3/-2) StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs (+2/-2) StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs (+1/-1) StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs (+1/-1) StandardPlugins/NetworkManager/src/NetworkConnection.cs (+2/-2) StandardPlugins/NetworkManager/src/NetworkDevice.cs (+7/-7) StandardPlugins/NetworkManager/src/NetworkManager.cs (+20/-11) StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs (+10/-5) StandardPlugins/NetworkManager/src/WiredDevice.cs (+2/-2) StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs (+5/-5) StandardPlugins/NetworkManager/src/WirelessConnection.cs (+1/-1) StandardPlugins/NetworkManager/src/WirelessDevice.cs (+2/-2) |
To merge this branch: | bzr merge lp:~franciscoda/docky/nm-1.0.7-docky-fix |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Docky Core | Pending | ||
Review via email: mp+275815@code.launchpad.net |
Commit message
Description of the change
Fixed Network Manager plugin. Tested on NetworkManager 1.0.7
Added disconnect option for active connections by clicking on them
Most files in StandardPlugins
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Docky.Services/Docky.Services/SystemService.cs' |
2 | --- Docky.Services/Docky.Services/SystemService.cs 2014-05-06 18:12:14 +0000 |
3 | +++ Docky.Services/Docky.Services/SystemService.cs 2015-10-27 09:11:09 +0000 |
4 | @@ -117,7 +117,9 @@ |
5 | |
6 | if (Bus.System.NameHasOwner (NetworkManagerName)) { |
7 | try { |
8 | - network = Bus.System.GetObject<INetworkManager> (NetworkManagerName, new ObjectPath (NetworkManagerPath)); |
9 | + ObjectPath op = new ObjectPath (NetworkManagerPath); |
10 | + network = Bus.System.GetObject<INetworkManager> (NetworkManagerName, op); |
11 | + networkProperties = Bus.System.GetObject<org.freedesktop.DBus.Properties> (NetworkManagerName, op); |
12 | var state = State; |
13 | NetworkConnected = (state == NetworkState.ConnectedGlobal || state == NetworkState.ConnectedLocal |
14 | || state == NetworkState.ConnectedSite); |
15 | @@ -142,15 +144,16 @@ |
16 | |
17 | const string NetworkManagerName = "org.freedesktop.NetworkManager"; |
18 | const string NetworkManagerPath = "/org/freedesktop/NetworkManager"; |
19 | + org.freedesktop.DBus.Properties networkProperties; |
20 | INetworkManager network; |
21 | |
22 | [Interface(NetworkManagerName)] |
23 | - interface INetworkManager : org.freedesktop.DBus.Properties |
24 | + public interface INetworkManager |
25 | { |
26 | event StateChangedHandler StateChanged; |
27 | } |
28 | |
29 | - delegate void StateChangedHandler (uint state); |
30 | + public delegate void StateChangedHandler (uint state); |
31 | |
32 | public bool NetworkConnected { get; private set; } |
33 | |
34 | @@ -175,7 +178,7 @@ |
35 | NetworkState State { |
36 | get { |
37 | try { |
38 | - return (NetworkState) Enum.ToObject (typeof(NetworkState), network.Get (NetworkManagerName, "State")); |
39 | + return (NetworkState) Enum.ToObject (typeof(NetworkState), networkProperties.Get (NetworkManagerName, "State")); |
40 | } catch (Exception) { |
41 | return NetworkState.Unknown; |
42 | } |
43 | |
44 | === modified file 'StandardPlugins/NetworkManager/src/ConnectionManager.cs' |
45 | --- StandardPlugins/NetworkManager/src/ConnectionManager.cs 2010-10-09 12:54:14 +0000 |
46 | +++ StandardPlugins/NetworkManager/src/ConnectionManager.cs 2015-10-27 09:11:09 +0000 |
47 | @@ -29,18 +29,13 @@ |
48 | { |
49 | public class ConnectionManager |
50 | { |
51 | - const string SettingsObjectPath = "/org/freedesktop/NetworkManagerSettings"; |
52 | - const string SystemBus = "org.freedesktop.NetworkManagerSystemSettings"; |
53 | - const string UserBus = "org.freedesktop.NetworkManagerUserSettings"; |
54 | + const string SettingsObjectPath = "/org/freedesktop/NetworkManager/Settings"; |
55 | + const string SystemBus = "org.freedesktop.NetworkManager"; |
56 | |
57 | public ConnectionManager() |
58 | { |
59 | SystemConnectionManager = new DBusObject<IConnectionManager> (SystemBus, SettingsObjectPath); |
60 | - //SystemConnectionManager.BusObject.NewConnection += OnConnectionAdded; |
61 | - UserConnectionManager = new DBusObject<IConnectionManager> (UserBus, SettingsObjectPath); |
62 | - //UserConnectionManager.BusObject.NewConnection += OnConnectionAdded; |
63 | |
64 | - UserConnections = new List<NetworkConnection> (); |
65 | SystemConnections = new List<NetworkConnection> (); |
66 | |
67 | UpdateConnections (); |
68 | @@ -49,11 +44,9 @@ |
69 | } |
70 | |
71 | DBusObject<IConnectionManager> SystemConnectionManager { get; set; } |
72 | - DBusObject<IConnectionManager> UserConnectionManager { get; set; } |
73 | - public List<NetworkConnection> UserConnections { get; private set; } |
74 | public List<NetworkConnection> SystemConnections { get; private set; } |
75 | public IEnumerable<NetworkConnection> AllConnections { |
76 | - get { return UserConnections.Union (SystemConnections); } |
77 | + get { return SystemConnections; } |
78 | } |
79 | |
80 | |
81 | @@ -92,28 +85,7 @@ |
82 | Log<ConnectionManager>.Debug (e.StackTrace); |
83 | } |
84 | } |
85 | - |
86 | - lock (UserConnections) { |
87 | - UserConnections.Clear (); |
88 | - try { |
89 | - foreach (string con in UserConnectionManager.BusObject.ListConnections ()) |
90 | - { |
91 | - NetworkConnection connection = new NetworkConnection (UserBus, con, ConnectionOwner.User); |
92 | - if (connection.Settings.ContainsKey ("802-11-wireless")) |
93 | - connection = new WirelessConnection (UserBus, con, ConnectionOwner.User); |
94 | - else if (connection.Settings.ContainsKey ("802-3-ethernet")) |
95 | - connection = new WiredConnection (UserBus, con, ConnectionOwner.User); |
96 | - else |
97 | - continue; |
98 | - |
99 | - //connection.ConnectionRemoved += OnNetworkConnectionRemoved; |
100 | - UserConnections.Add (connection); |
101 | - } |
102 | - } catch (Exception e) { |
103 | - Log<ConnectionManager>.Error (e.Message); |
104 | - Log<ConnectionManager>.Debug (e.StackTrace); |
105 | - } |
106 | - } |
107 | + |
108 | } |
109 | } |
110 | } |
111 | |
112 | === modified file 'StandardPlugins/NetworkManager/src/DBusObject.cs' |
113 | --- StandardPlugins/NetworkManager/src/DBusObject.cs 2010-10-09 12:54:14 +0000 |
114 | +++ StandardPlugins/NetworkManager/src/DBusObject.cs 2015-10-27 09:11:09 +0000 |
115 | @@ -17,6 +17,7 @@ |
116 | |
117 | using System; |
118 | using System.Collections.Generic; |
119 | +using System.Linq; |
120 | |
121 | using DBus; |
122 | using org.freedesktop.DBus; |
123 | @@ -27,6 +28,7 @@ |
124 | { |
125 | public class DBusObject<T> |
126 | { |
127 | + private org.freedesktop.DBus.Properties PropGetter; |
128 | public string BusName { get; private set; } |
129 | public string ObjectPath { get; private set; } |
130 | public T BusObject { get; private set; } |
131 | @@ -35,13 +37,27 @@ |
132 | { |
133 | this.ObjectPath = objectPath; |
134 | this.BusName = busName; |
135 | - |
136 | + |
137 | + ObjectPath op = new ObjectPath(this.ObjectPath); |
138 | try { |
139 | - this.BusObject = Bus.System.GetObject<T> (BusName, new ObjectPath (ObjectPath)); |
140 | + this.BusObject = Bus.System.GetObject<T> (BusName, op); |
141 | + if (this.BusObject == null) |
142 | + throw new Exception ("Bus.System.GetObject returned null for arguments: " + busName + "," + objectPath); |
143 | } catch (Exception e) { |
144 | Log<DBusObject<T>>.Error (e.Message); |
145 | Log<DBusObject<T>>.Debug (e.StackTrace); |
146 | } |
147 | + this.PropGetter = Bus.System.GetObject<org.freedesktop.DBus.Properties>(this.BusName, op); |
148 | + } |
149 | + public object Get (string propertyName) |
150 | + { |
151 | + return this.PropGetter.Get ( |
152 | + typeof (T).GetCustomAttributes(typeof (InterfaceAttribute), true) |
153 | + .Cast<InterfaceAttribute> () |
154 | + .Select (i => i.Name) |
155 | + .FirstOrDefault(), |
156 | + propertyName |
157 | + ); |
158 | } |
159 | } |
160 | } |
161 | |
162 | === modified file 'StandardPlugins/NetworkManager/src/DeviceManager.cs' |
163 | --- StandardPlugins/NetworkManager/src/DeviceManager.cs 2010-10-09 12:54:14 +0000 |
164 | +++ StandardPlugins/NetworkManager/src/DeviceManager.cs 2015-10-27 09:11:09 +0000 |
165 | @@ -27,7 +27,7 @@ |
166 | { |
167 | public IEnumerable<string> ActiveConnections { |
168 | get { |
169 | - foreach (ObjectPath conPath in (ObjectPath[]) BusObject.Get (BusName, "ActiveConnections")) |
170 | + foreach (ObjectPath conPath in (ObjectPath[]) this.Get ("ActiveConnections")) |
171 | yield return conPath.ToString (); |
172 | } |
173 | } |
174 | |
175 | === modified file 'StandardPlugins/NetworkManager/src/Enums.cs' |
176 | --- StandardPlugins/NetworkManager/src/Enums.cs 2009-11-25 15:37:53 +0000 |
177 | +++ StandardPlugins/NetworkManager/src/Enums.cs 2015-10-27 09:11:09 +0000 |
178 | @@ -27,15 +27,18 @@ |
179 | |
180 | public enum DeviceState { |
181 | Unknown = 0, |
182 | - Unmanaged, |
183 | - Unavailable, |
184 | - Disconnected, |
185 | - Preparing, |
186 | - Configuring, |
187 | - NeedsAuth, |
188 | - IPConfiguring, |
189 | - Active, |
190 | - Failed |
191 | + Unmanaged = 10, |
192 | + Unavailable = 20, |
193 | + Disconnected = 30, |
194 | + Preparing = 40, |
195 | + Configuring = 50, |
196 | + NeedsAuth = 60, |
197 | + IPConfiguring = 70, |
198 | + IPChecking = 80, |
199 | + Secondaries = 90, |
200 | + Active = 100, |
201 | + Deactivating = 110, |
202 | + Failed = 120 |
203 | } |
204 | |
205 | public enum ConnectionOwner { |
206 | |
207 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs' |
208 | --- StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs 2010-10-09 12:54:14 +0000 |
209 | +++ StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs 2015-10-27 09:11:09 +0000 |
210 | @@ -23,7 +23,7 @@ |
211 | namespace NetworkManagerDocklet |
212 | { |
213 | [Interface ("org.freedesktop.NetworkManager.AccessPoint")] |
214 | - public interface IAccessPoint : org.freedesktop.DBus.Properties |
215 | + public interface IAccessPoint |
216 | { |
217 | } |
218 | } |
219 | |
220 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs' |
221 | --- StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs 2010-10-09 12:54:14 +0000 |
222 | +++ StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs 2015-10-27 09:11:09 +0000 |
223 | @@ -23,7 +23,7 @@ |
224 | namespace NetworkManagerDocklet |
225 | { |
226 | [Interface ("org.freedesktop.NetworkManager.Connection.Active")] |
227 | - public interface IActiveConnection : org.freedesktop.DBus.Properties |
228 | + public interface IActiveConnection |
229 | { |
230 | } |
231 | } |
232 | |
233 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs' |
234 | --- StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs 2010-10-09 12:54:14 +0000 |
235 | +++ StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs 2015-10-27 09:11:09 +0000 |
236 | @@ -24,7 +24,7 @@ |
237 | { |
238 | public delegate void ConnectionAddedHandler (string objectPath); |
239 | |
240 | - [Interface ("org.freedesktop.NetworkManagerSettings")] |
241 | + [Interface ("org.freedesktop.NetworkManager.Settings")] |
242 | public interface IConnectionManager |
243 | { |
244 | string[] ListConnections (); |
245 | |
246 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs' |
247 | --- StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs 2010-10-09 12:54:14 +0000 |
248 | +++ StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs 2015-10-27 09:11:09 +0000 |
249 | @@ -23,7 +23,7 @@ |
250 | namespace NetworkManagerDocklet |
251 | { |
252 | [Interface ("org.freedesktop.NetworkManager.DHCP4Config")] |
253 | - public interface IDHCP4Config : org.freedesktop.DBus.Properties |
254 | + public interface IDHCP4Config |
255 | { |
256 | } |
257 | } |
258 | |
259 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs' |
260 | --- StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs 2010-10-09 12:54:14 +0000 |
261 | +++ StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs 2015-10-27 09:11:09 +0000 |
262 | @@ -23,7 +23,7 @@ |
263 | namespace NetworkManagerDocklet |
264 | { |
265 | [Interface ("org.freedesktop.NetworkManager.IP4Config")] |
266 | - public interface IIP4Config : org.freedesktop.DBus.Properties |
267 | + public interface IIP4Config |
268 | { |
269 | } |
270 | } |
271 | |
272 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs' |
273 | --- StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs 2010-10-09 12:54:14 +0000 |
274 | +++ StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs 2015-10-27 09:11:09 +0000 |
275 | @@ -23,10 +23,11 @@ |
276 | namespace NetworkManagerDocklet |
277 | { |
278 | [Interface ("org.freedesktop.NetworkManager")] |
279 | - public interface INetManager : org.freedesktop.DBus.Properties |
280 | + public interface INetManager |
281 | { |
282 | ObjectPath[] GetDevices (); |
283 | - ObjectPath ActivateConnection (string serviceName, ObjectPath connection, ObjectPath device, ObjectPath specificObject); |
284 | + ObjectPath ActivateConnection (ObjectPath connection, ObjectPath device, ObjectPath specificObject); |
285 | + void DeactivateConnection (ObjectPath active_connection); |
286 | uint state (); |
287 | } |
288 | } |
289 | |
290 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs' |
291 | --- StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs 2010-10-09 12:54:14 +0000 |
292 | +++ StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs 2015-10-27 09:11:09 +0000 |
293 | @@ -23,10 +23,10 @@ |
294 | |
295 | namespace NetworkManagerDocklet |
296 | { |
297 | - [Interface("org.freedesktop.NetworkManagerSettings.Connection")] |
298 | + [Interface("org.freedesktop.NetworkManager.Settings.Connection")] |
299 | public interface INetworkConnection |
300 | { |
301 | - IDictionary<string, IDictionary<string, object>> GetSettings(); |
302 | + Dictionary<string, Dictionary<string, object>> GetSettings(); |
303 | event ConnectionRemovedHandler Removed; |
304 | } |
305 | |
306 | |
307 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs' |
308 | --- StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs 2010-10-09 12:54:14 +0000 |
309 | +++ StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs 2015-10-27 09:11:09 +0000 |
310 | @@ -23,7 +23,7 @@ |
311 | namespace NetworkManagerDocklet |
312 | { |
313 | [Interface ("org.freedesktop.NetworkManager.Device")] |
314 | - public interface INetworkDevice : org.freedesktop.DBus.Properties |
315 | + public interface INetworkDevice |
316 | { |
317 | event StateChangedHandler StateChanged; |
318 | } |
319 | |
320 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs' |
321 | --- StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs 2010-10-09 12:54:14 +0000 |
322 | +++ StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs 2015-10-27 09:11:09 +0000 |
323 | @@ -23,7 +23,7 @@ |
324 | namespace NetworkManagerDocklet |
325 | { |
326 | [Interface ("org.freedesktop.NetworkManager.Device.Wired")] |
327 | - public interface IWiredDevice : org.freedesktop.DBus.Properties |
328 | + public interface IWiredDevice |
329 | { |
330 | } |
331 | } |
332 | |
333 | === modified file 'StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs' |
334 | --- StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs 2010-10-09 12:54:14 +0000 |
335 | +++ StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs 2015-10-27 09:11:09 +0000 |
336 | @@ -23,7 +23,7 @@ |
337 | namespace NetworkManagerDocklet |
338 | { |
339 | [Interface ("org.freedesktop.NetworkManager.Device.Wireless")] |
340 | - public interface IWirelessDevice : org.freedesktop.DBus.Properties |
341 | + public interface IWirelessDevice |
342 | { |
343 | ObjectPath[] GetAccessPoints (); |
344 | event AccessPointAddRemoveHandler AccessPointAdded; |
345 | |
346 | === modified file 'StandardPlugins/NetworkManager/src/NetworkConnection.cs' |
347 | --- StandardPlugins/NetworkManager/src/NetworkConnection.cs 2010-10-09 12:54:14 +0000 |
348 | +++ StandardPlugins/NetworkManager/src/NetworkConnection.cs 2015-10-27 09:11:09 +0000 |
349 | @@ -41,11 +41,11 @@ |
350 | |
351 | public ConnectionOwner Owner { get; private set; } |
352 | |
353 | - public IDictionary<string, IDictionary<string, object>> Settings { |
354 | + public Dictionary<string, Dictionary<string, object>> Settings { |
355 | get { return BusObject.GetSettings (); } |
356 | } |
357 | |
358 | - private IDictionary<string, object> Connection { |
359 | + private Dictionary<string, object> Connection { |
360 | get { return this.Settings["connection"]; } |
361 | } |
362 | |
363 | |
364 | === modified file 'StandardPlugins/NetworkManager/src/NetworkDevice.cs' |
365 | --- StandardPlugins/NetworkManager/src/NetworkDevice.cs 2011-01-09 18:02:06 +0000 |
366 | +++ StandardPlugins/NetworkManager/src/NetworkDevice.cs 2015-10-27 09:11:09 +0000 |
367 | @@ -63,7 +63,7 @@ |
368 | public DeviceType DType { |
369 | get { |
370 | try { |
371 | - return (DeviceType) Enum.ToObject (typeof (DeviceType), BusObject.Get (BusName, "DeviceType")); |
372 | + return (DeviceType) Enum.ToObject (typeof (DeviceType), this.Get ("DeviceType")); |
373 | } catch (Exception e) { |
374 | Log<NetworkDevice>.Error (e.Message); |
375 | Log<NetworkDevice>.Debug (e.StackTrace); |
376 | @@ -75,7 +75,7 @@ |
377 | public DeviceState State { |
378 | get { |
379 | try { |
380 | - return (DeviceState) Enum.ToObject (typeof (DeviceState), BusObject.Get (BusName, "State")); |
381 | + return (DeviceState) Enum.ToObject (typeof (DeviceState), this.Get ("State")); |
382 | } catch (Exception e) { |
383 | Log<NetworkDevice>.Error (e.Message); |
384 | Log<NetworkDevice>.Debug (e.StackTrace); |
385 | @@ -93,16 +93,16 @@ |
386 | void SetIPs () |
387 | { |
388 | if (State == DeviceState.Active) { |
389 | - if (BusObject.Get (BusName, "Dhcp4Config").ToString () != "/") |
390 | + if (this.Get ("Dhcp4Config").ToString () != "/") |
391 | ConType = ConnectionType.Manaul; |
392 | else |
393 | ConType = ConnectionType.DHCP; |
394 | - IP4Config = new DBusObject<IIP4Config> (NMBusName, BusObject.Get (BusName, "Ip4Config").ToString ()); |
395 | - IP4Address = new IPAddress (long.Parse (BusObject.Get (BusName, "Ip4Address").ToString ())); |
396 | - uint[][] Addresses = (uint[][]) IP4Config.BusObject.Get (IP4Config.BusName, "Addresses"); |
397 | + IP4Config = new DBusObject<IIP4Config> (NMBusName, this.Get ("Ip4Config").ToString ()); |
398 | + IP4Address = new IPAddress (long.Parse (this.Get ("Ip4Address").ToString ())); |
399 | + uint[][] Addresses = (uint[][]) IP4Config.Get ("Addresses"); |
400 | Gateway = new IPAddress (Addresses[0][2]); |
401 | SubnetMask = ConvertPrefixToIp ((int) Addresses[0][1]); |
402 | - uint[] NameServers = (uint[]) IP4Config.BusObject.Get (IP4Config.BusName, "Nameservers"); |
403 | + uint[] NameServers = (uint[]) IP4Config.Get ("Nameservers"); |
404 | if (NameServers.Length > 0) |
405 | PrimaryDNS = new IPAddress (NameServers[0]); |
406 | else |
407 | |
408 | === modified file 'StandardPlugins/NetworkManager/src/NetworkManager.cs' |
409 | --- StandardPlugins/NetworkManager/src/NetworkManager.cs 2010-10-09 12:54:14 +0000 |
410 | +++ StandardPlugins/NetworkManager/src/NetworkManager.cs 2015-10-27 09:11:09 +0000 |
411 | @@ -21,6 +21,7 @@ |
412 | using System.Collections.Generic; |
413 | |
414 | using DBus; |
415 | +using Docky.Services; |
416 | using org.freedesktop.DBus; |
417 | |
418 | namespace NetworkManagerDocklet |
419 | @@ -38,10 +39,7 @@ |
420 | get { |
421 | foreach (string active in DevManager.ActiveConnections) { |
422 | DBusObject<IActiveConnection> ActiveConnection = new DBusObject<IActiveConnection> ("org.freedesktop.NetworkManager", active); |
423 | - if (ActiveConnection.BusObject.Get (ActiveConnection.BusName, "ServiceName").ToString ().Contains ("System")) |
424 | - yield return ConManager.SystemConnections.Where (con => con.ObjectPath == ActiveConnection.BusObject.Get (ActiveConnection.BusName, "Connection").ToString ()).First (); |
425 | - else |
426 | - yield return ConManager.UserConnections.Where (con => con.ObjectPath == ActiveConnection.BusObject.Get (ActiveConnection.BusName, "Connection").ToString ()).First (); |
427 | + yield return ConManager.SystemConnections.Where (con => con.ObjectPath == ActiveConnection.Get ("Connection").ToString ()).First (); |
428 | } |
429 | } |
430 | } |
431 | @@ -61,9 +59,12 @@ |
432 | try { |
433 | connection = ConManager.AllConnections.OfType<WirelessConnection> ().Where (con => (con as WirelessConnection).SSID == ap.SSID).First (); |
434 | ConnectTo (connection); |
435 | - } catch { |
436 | + } catch (Exception e) { |
437 | // FIXME We're trying to connect to an AP but no connection entry exists. |
438 | // If we can figure out how to manually create a connection behind the scenes, we can remove this. |
439 | + // FIXME 2: What to do if an exception is thrown because of another reason? |
440 | + Log<NetworkManager>.Error(e.Message); |
441 | + Log<NetworkManager>.Debug(e.StackTrace); |
442 | Docky.Services.DockServices.System.RunOnThread ( () => { |
443 | Process.Start ("nm-connection-editor --type=802-11-wireless"); |
444 | }); |
445 | @@ -86,14 +87,22 @@ |
446 | return; |
447 | } |
448 | |
449 | - string serviceName; |
450 | - if (con.Owner == ConnectionOwner.System) |
451 | - serviceName = "org.freedesktop.NetworkManagerSystemSettings"; |
452 | - else |
453 | - serviceName = "org.freedesktop.NetworkManagerUserSettings"; |
454 | + string serviceName = "org.freedesktop.NetworkManager.Settings"; |
455 | string conStr = con.ObjectPath; |
456 | |
457 | - DevManager.BusObject.ActivateConnection(serviceName, new ObjectPath (conStr), new ObjectPath (dev.ObjectPath), new ObjectPath (specObj)); |
458 | + DevManager.BusObject.ActivateConnection(new ObjectPath (conStr), new ObjectPath (dev.ObjectPath), new ObjectPath (specObj)); |
459 | + } |
460 | + public void DisconnectFrom (WirelessAccessPoint ap) |
461 | + { |
462 | + ObjectPath apObjectPath = new ObjectPath(ap.ObjectPath); |
463 | + foreach (string active in DevManager.ActiveConnections) { |
464 | + DBusObject<IActiveConnection> activeConnection = new DBusObject<IActiveConnection> ("org.freedesktop.NetworkManager", active); |
465 | + string specificObject = activeConnection.Get("SpecificObject").ToString(); |
466 | + if (specificObject == ap.ObjectPath) { |
467 | + DevManager.BusObject.DeactivateConnection(new ObjectPath(activeConnection.ObjectPath)); |
468 | + return; |
469 | + } |
470 | + } |
471 | } |
472 | |
473 | void OnDevStateChanged(object o, DeviceStateChangedArgs args) |
474 | |
475 | === modified file 'StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs' |
476 | --- StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs 2014-04-22 15:12:30 +0000 |
477 | +++ StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs 2015-10-27 09:11:09 +0000 |
478 | @@ -83,7 +83,7 @@ |
479 | string SetDockletIcon () |
480 | { |
481 | try { |
482 | - // currently connecting (animated) |
483 | + // currently connecting/disconnecting (animated) |
484 | NetworkDevice dev = NM.DevManager.NetworkDevices |
485 | .Where (d => d.State == DeviceState.Configuring || d.State == DeviceState.IPConfiguring || d.State == DeviceState.Preparing) |
486 | .FirstOrDefault (); |
487 | @@ -142,7 +142,7 @@ |
488 | List<MenuItem> active = list[MenuListContainer.Header]; |
489 | |
490 | foreach (WirelessAccessPoint wap in ActiveAccessPoints) { |
491 | - active.Add (MakeConEntry (wap)); |
492 | + active.Add (MakeConEntry (wap, true)); |
493 | } |
494 | |
495 | int count = 0; |
496 | @@ -156,7 +156,7 @@ |
497 | if (val.Any (wap => ActiveAccessPoints.Contains (wap))) |
498 | continue; |
499 | |
500 | - wifi.Add (MakeConEntry (val.OrderByDescending (wap => wap.Strength).First ())); |
501 | + wifi.Add (MakeConEntry (val.OrderByDescending (wap => wap.Strength).First (), false)); |
502 | count++; |
503 | } |
504 | } |
505 | @@ -200,7 +200,7 @@ |
506 | // //yield return new SimpleMenuButtonArgs (() => Console.WriteLine ("asdf"),"Click me!", "network-manager"); |
507 | // } |
508 | |
509 | - MenuItem MakeConEntry (WirelessAccessPoint ap) |
510 | + MenuItem MakeConEntry (WirelessAccessPoint ap, bool isactive) |
511 | { |
512 | string apName = ap.SSID; |
513 | string icon = APIconFromStrength (ap.Strength); |
514 | @@ -208,7 +208,12 @@ |
515 | |
516 | bool secure = ap.Flags == APFlags.Privacy || ap.RsnFlags != AccessPointSecurity.None || ap.WpaFlags != AccessPointSecurity.None; |
517 | |
518 | - Docky.Menus.MenuItem item = new Docky.Menus.MenuItem (apName, icon, (o, a) => NM.ConnectTo (ap)); |
519 | + Docky.Menus.MenuItem item; |
520 | + if (isactive) { |
521 | + item = new Docky.Menus.MenuItem (apName, icon, (o, a) => NM.DisconnectFrom(ap)); |
522 | + } else { |
523 | + item = new Docky.Menus.MenuItem (apName, icon, (o, a) => NM.ConnectTo (ap)); |
524 | + } |
525 | item.Bold = bold; |
526 | |
527 | if (secure) |
528 | |
529 | === modified file 'StandardPlugins/NetworkManager/src/WiredDevice.cs' |
530 | --- StandardPlugins/NetworkManager/src/WiredDevice.cs 2010-10-09 12:54:14 +0000 |
531 | +++ StandardPlugins/NetworkManager/src/WiredDevice.cs 2015-10-27 09:11:09 +0000 |
532 | @@ -35,13 +35,13 @@ |
533 | |
534 | public bool Carrier { |
535 | get { |
536 | - return Boolean.Parse (WiredProperties.BusObject.Get (WiredProperties.BusName, "Carrier").ToString ()); |
537 | + return Boolean.Parse (WiredProperties.Get ("Carrier").ToString ()); |
538 | } |
539 | } |
540 | |
541 | public string HWAddresss { |
542 | get { |
543 | - return WiredProperties.BusObject.Get (WiredProperties.BusName, "HwAddress").ToString (); |
544 | + return WiredProperties.Get ("HwAddress").ToString (); |
545 | } |
546 | } |
547 | } |
548 | |
549 | === modified file 'StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs' |
550 | --- StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs 2009-11-28 23:36:17 +0000 |
551 | +++ StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs 2015-10-27 09:11:09 +0000 |
552 | @@ -51,7 +51,7 @@ |
553 | public string SSID { |
554 | get { |
555 | try { |
556 | - return System.Text.ASCIIEncoding.ASCII.GetString ((byte[]) BusObject.Get (BusName, "Ssid")); |
557 | + return System.Text.ASCIIEncoding.ASCII.GetString ((byte[]) this.Get ("Ssid")); |
558 | } catch (Exception e) { |
559 | Log<WirelessAccessPoint>.Error (ObjectPath); |
560 | Log<WirelessAccessPoint>.Error (e.Message); |
561 | @@ -64,7 +64,7 @@ |
562 | public byte Strength { |
563 | get { |
564 | try { |
565 | - return (byte) BusObject.Get (BusName, "Strength"); |
566 | + return (byte) this.Get ("Strength"); |
567 | } catch (Exception e) { |
568 | Log<WirelessAccessPoint>.Error (ObjectPath); |
569 | Log<WirelessAccessPoint>.Error (e.Message); |
570 | @@ -77,7 +77,7 @@ |
571 | public APFlags Flags { |
572 | get { |
573 | try { |
574 | - return (APFlags) Convert.ToInt32 (BusObject.Get (BusName, "Flags")); |
575 | + return (APFlags) Convert.ToInt32 (this.Get ("Flags")); |
576 | } catch (Exception e) { |
577 | Log<WirelessAccessPoint>.Error (ObjectPath); |
578 | Log<WirelessAccessPoint>.Error (e.Message); |
579 | @@ -90,7 +90,7 @@ |
580 | public AccessPointSecurity RsnFlags { |
581 | get { |
582 | try { |
583 | - return (AccessPointSecurity) Convert.ToInt32 (BusObject.Get (BusName, "RsnFlags")); |
584 | + return (AccessPointSecurity) Convert.ToInt32 (this.Get ("RsnFlags")); |
585 | } catch (Exception e) { |
586 | Log<WirelessAccessPoint>.Error (ObjectPath); |
587 | Log<WirelessAccessPoint>.Error (e.Message); |
588 | @@ -103,7 +103,7 @@ |
589 | public AccessPointSecurity WpaFlags { |
590 | get { |
591 | try { |
592 | - return (AccessPointSecurity) Convert.ToInt32 (BusObject.Get (BusName, "WpaFlags")); |
593 | + return (AccessPointSecurity) Convert.ToInt32 (this.Get ("WpaFlags")); |
594 | } catch (Exception e) { |
595 | Log<WirelessAccessPoint>.Error (ObjectPath); |
596 | Log<WirelessAccessPoint>.Error (e.Message); |
597 | |
598 | === modified file 'StandardPlugins/NetworkManager/src/WirelessConnection.cs' |
599 | --- StandardPlugins/NetworkManager/src/WirelessConnection.cs 2009-11-25 15:37:53 +0000 |
600 | +++ StandardPlugins/NetworkManager/src/WirelessConnection.cs 2015-10-27 09:11:09 +0000 |
601 | @@ -27,7 +27,7 @@ |
602 | { |
603 | } |
604 | |
605 | - public IDictionary<string, object> WirelessProperties { |
606 | + public Dictionary<string, object> WirelessProperties { |
607 | get { return Settings["802-11-wireless"]; } |
608 | } |
609 | |
610 | |
611 | === modified file 'StandardPlugins/NetworkManager/src/WirelessDevice.cs' |
612 | --- StandardPlugins/NetworkManager/src/WirelessDevice.cs 2010-10-09 12:54:14 +0000 |
613 | +++ StandardPlugins/NetworkManager/src/WirelessDevice.cs 2015-10-27 09:11:09 +0000 |
614 | @@ -76,7 +76,7 @@ |
615 | |
616 | public WirelessAccessPoint ActiveAccessPoint { |
617 | get { |
618 | - string access = WirelessProperties.BusObject.Get (WirelessProperties.BusName, "ActiveAccessPoint").ToString (); |
619 | + string access = WirelessProperties.Get ("ActiveAccessPoint").ToString (); |
620 | return AccessPoints |
621 | .Where (ap => ap.ObjectPath == access) |
622 | .DefaultIfEmpty (null) |
623 | @@ -85,7 +85,7 @@ |
624 | } |
625 | |
626 | public string HWAddress { |
627 | - get { return WirelessProperties.BusObject.Get (WirelessProperties.BusName, "HwAddress").ToString (); } |
628 | + get { return WirelessProperties.Get ("HwAddress").ToString (); } |
629 | } |
630 | } |
631 | } |