Merge lp:~franciscoda/docky/nm-1.0.7-docky-fix into lp:docky

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
Reviewer Review Type Date Requested Status
Docky Core Pending
Review via email: mp+275815@code.launchpad.net

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/NetworkManager affected

To post a comment you must log in.

Unmerged revisions

1866. By Francisco

fixes network manager plugin. working for networkmanager 1.0.7
adds disconnect option

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Docky.Services/Docky.Services/SystemService.cs'
--- Docky.Services/Docky.Services/SystemService.cs 2014-05-06 18:12:14 +0000
+++ Docky.Services/Docky.Services/SystemService.cs 2015-10-27 09:11:09 +0000
@@ -117,7 +117,9 @@
117 117
118 if (Bus.System.NameHasOwner (NetworkManagerName)) {118 if (Bus.System.NameHasOwner (NetworkManagerName)) {
119 try {119 try {
120 network = Bus.System.GetObject<INetworkManager> (NetworkManagerName, new ObjectPath (NetworkManagerPath));120 ObjectPath op = new ObjectPath (NetworkManagerPath);
121 network = Bus.System.GetObject<INetworkManager> (NetworkManagerName, op);
122 networkProperties = Bus.System.GetObject<org.freedesktop.DBus.Properties> (NetworkManagerName, op);
121 var state = State;123 var state = State;
122 NetworkConnected = (state == NetworkState.ConnectedGlobal || state == NetworkState.ConnectedLocal124 NetworkConnected = (state == NetworkState.ConnectedGlobal || state == NetworkState.ConnectedLocal
123 || state == NetworkState.ConnectedSite);125 || state == NetworkState.ConnectedSite);
@@ -142,15 +144,16 @@
142 144
143 const string NetworkManagerName = "org.freedesktop.NetworkManager";145 const string NetworkManagerName = "org.freedesktop.NetworkManager";
144 const string NetworkManagerPath = "/org/freedesktop/NetworkManager";146 const string NetworkManagerPath = "/org/freedesktop/NetworkManager";
147 org.freedesktop.DBus.Properties networkProperties;
145 INetworkManager network;148 INetworkManager network;
146 149
147 [Interface(NetworkManagerName)]150 [Interface(NetworkManagerName)]
148 interface INetworkManager : org.freedesktop.DBus.Properties151 public interface INetworkManager
149 {152 {
150 event StateChangedHandler StateChanged;153 event StateChangedHandler StateChanged;
151 }154 }
152 155
153 delegate void StateChangedHandler (uint state);156 public delegate void StateChangedHandler (uint state);
154 157
155 public bool NetworkConnected { get; private set; }158 public bool NetworkConnected { get; private set; }
156 159
@@ -175,7 +178,7 @@
175 NetworkState State {178 NetworkState State {
176 get {179 get {
177 try {180 try {
178 return (NetworkState) Enum.ToObject (typeof(NetworkState), network.Get (NetworkManagerName, "State"));181 return (NetworkState) Enum.ToObject (typeof(NetworkState), networkProperties.Get (NetworkManagerName, "State"));
179 } catch (Exception) {182 } catch (Exception) {
180 return NetworkState.Unknown;183 return NetworkState.Unknown;
181 }184 }
182185
=== modified file 'StandardPlugins/NetworkManager/src/ConnectionManager.cs'
--- StandardPlugins/NetworkManager/src/ConnectionManager.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/ConnectionManager.cs 2015-10-27 09:11:09 +0000
@@ -29,18 +29,13 @@
29{29{
30 public class ConnectionManager30 public class ConnectionManager
31 {31 {
32 const string SettingsObjectPath = "/org/freedesktop/NetworkManagerSettings";32 const string SettingsObjectPath = "/org/freedesktop/NetworkManager/Settings";
33 const string SystemBus = "org.freedesktop.NetworkManagerSystemSettings";33 const string SystemBus = "org.freedesktop.NetworkManager";
34 const string UserBus = "org.freedesktop.NetworkManagerUserSettings";
35 34
36 public ConnectionManager()35 public ConnectionManager()
37 {36 {
38 SystemConnectionManager = new DBusObject<IConnectionManager> (SystemBus, SettingsObjectPath);37 SystemConnectionManager = new DBusObject<IConnectionManager> (SystemBus, SettingsObjectPath);
39 //SystemConnectionManager.BusObject.NewConnection += OnConnectionAdded;
40 UserConnectionManager = new DBusObject<IConnectionManager> (UserBus, SettingsObjectPath);
41 //UserConnectionManager.BusObject.NewConnection += OnConnectionAdded;
42 38
43 UserConnections = new List<NetworkConnection> ();
44 SystemConnections = new List<NetworkConnection> ();39 SystemConnections = new List<NetworkConnection> ();
45 40
46 UpdateConnections ();41 UpdateConnections ();
@@ -49,11 +44,9 @@
49 }44 }
50 45
51 DBusObject<IConnectionManager> SystemConnectionManager { get; set; }46 DBusObject<IConnectionManager> SystemConnectionManager { get; set; }
52 DBusObject<IConnectionManager> UserConnectionManager { get; set; }
53 public List<NetworkConnection> UserConnections { get; private set; }
54 public List<NetworkConnection> SystemConnections { get; private set; }47 public List<NetworkConnection> SystemConnections { get; private set; }
55 public IEnumerable<NetworkConnection> AllConnections {48 public IEnumerable<NetworkConnection> AllConnections {
56 get { return UserConnections.Union (SystemConnections); }49 get { return SystemConnections; }
57 }50 }
58 51
59 52
@@ -92,28 +85,7 @@
92 Log<ConnectionManager>.Debug (e.StackTrace);85 Log<ConnectionManager>.Debug (e.StackTrace);
93 }86 }
94 }87 }
95 88
96 lock (UserConnections) {
97 UserConnections.Clear ();
98 try {
99 foreach (string con in UserConnectionManager.BusObject.ListConnections ())
100 {
101 NetworkConnection connection = new NetworkConnection (UserBus, con, ConnectionOwner.User);
102 if (connection.Settings.ContainsKey ("802-11-wireless"))
103 connection = new WirelessConnection (UserBus, con, ConnectionOwner.User);
104 else if (connection.Settings.ContainsKey ("802-3-ethernet"))
105 connection = new WiredConnection (UserBus, con, ConnectionOwner.User);
106 else
107 continue;
108
109 //connection.ConnectionRemoved += OnNetworkConnectionRemoved;
110 UserConnections.Add (connection);
111 }
112 } catch (Exception e) {
113 Log<ConnectionManager>.Error (e.Message);
114 Log<ConnectionManager>.Debug (e.StackTrace);
115 }
116 }
117 }89 }
118 }90 }
119}91}
12092
=== modified file 'StandardPlugins/NetworkManager/src/DBusObject.cs'
--- StandardPlugins/NetworkManager/src/DBusObject.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/DBusObject.cs 2015-10-27 09:11:09 +0000
@@ -17,6 +17,7 @@
1717
18using System;18using System;
19using System.Collections.Generic;19using System.Collections.Generic;
20using System.Linq;
2021
21using DBus;22using DBus;
22using org.freedesktop.DBus;23using org.freedesktop.DBus;
@@ -27,6 +28,7 @@
27{28{
28 public class DBusObject<T>29 public class DBusObject<T>
29 {30 {
31 private org.freedesktop.DBus.Properties PropGetter;
30 public string BusName { get; private set; }32 public string BusName { get; private set; }
31 public string ObjectPath { get; private set; }33 public string ObjectPath { get; private set; }
32 public T BusObject { get; private set; }34 public T BusObject { get; private set; }
@@ -35,13 +37,27 @@
35 {37 {
36 this.ObjectPath = objectPath;38 this.ObjectPath = objectPath;
37 this.BusName = busName;39 this.BusName = busName;
38 40
41 ObjectPath op = new ObjectPath(this.ObjectPath);
39 try {42 try {
40 this.BusObject = Bus.System.GetObject<T> (BusName, new ObjectPath (ObjectPath));43 this.BusObject = Bus.System.GetObject<T> (BusName, op);
44 if (this.BusObject == null)
45 throw new Exception ("Bus.System.GetObject returned null for arguments: " + busName + "," + objectPath);
41 } catch (Exception e) {46 } catch (Exception e) {
42 Log<DBusObject<T>>.Error (e.Message);47 Log<DBusObject<T>>.Error (e.Message);
43 Log<DBusObject<T>>.Debug (e.StackTrace);48 Log<DBusObject<T>>.Debug (e.StackTrace);
44 }49 }
50 this.PropGetter = Bus.System.GetObject<org.freedesktop.DBus.Properties>(this.BusName, op);
51 }
52 public object Get (string propertyName)
53 {
54 return this.PropGetter.Get (
55 typeof (T).GetCustomAttributes(typeof (InterfaceAttribute), true)
56 .Cast<InterfaceAttribute> ()
57 .Select (i => i.Name)
58 .FirstOrDefault(),
59 propertyName
60 );
45 }61 }
46 }62 }
47}63}
4864
=== modified file 'StandardPlugins/NetworkManager/src/DeviceManager.cs'
--- StandardPlugins/NetworkManager/src/DeviceManager.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/DeviceManager.cs 2015-10-27 09:11:09 +0000
@@ -27,7 +27,7 @@
27 {27 {
28 public IEnumerable<string> ActiveConnections {28 public IEnumerable<string> ActiveConnections {
29 get {29 get {
30 foreach (ObjectPath conPath in (ObjectPath[]) BusObject.Get (BusName, "ActiveConnections"))30 foreach (ObjectPath conPath in (ObjectPath[]) this.Get ("ActiveConnections"))
31 yield return conPath.ToString ();31 yield return conPath.ToString ();
32 }32 }
33 }33 }
3434
=== modified file 'StandardPlugins/NetworkManager/src/Enums.cs'
--- StandardPlugins/NetworkManager/src/Enums.cs 2009-11-25 15:37:53 +0000
+++ StandardPlugins/NetworkManager/src/Enums.cs 2015-10-27 09:11:09 +0000
@@ -27,15 +27,18 @@
27 27
28 public enum DeviceState {28 public enum DeviceState {
29 Unknown = 0,29 Unknown = 0,
30 Unmanaged,30 Unmanaged = 10,
31 Unavailable,31 Unavailable = 20,
32 Disconnected,32 Disconnected = 30,
33 Preparing,33 Preparing = 40,
34 Configuring,34 Configuring = 50,
35 NeedsAuth,35 NeedsAuth = 60,
36 IPConfiguring,36 IPConfiguring = 70,
37 Active,37 IPChecking = 80,
38 Failed38 Secondaries = 90,
39 Active = 100,
40 Deactivating = 110,
41 Failed = 120
39 }42 }
4043
41 public enum ConnectionOwner {44 public enum ConnectionOwner {
4245
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IAccessPoint.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.AccessPoint")]25 [Interface ("org.freedesktop.NetworkManager.AccessPoint")]
26 public interface IAccessPoint : org.freedesktop.DBus.Properties26 public interface IAccessPoint
27 {27 {
28 }28 }
29}29}
3030
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IActiveConnection.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.Connection.Active")]25 [Interface ("org.freedesktop.NetworkManager.Connection.Active")]
26 public interface IActiveConnection : org.freedesktop.DBus.Properties26 public interface IActiveConnection
27 {27 {
28 }28 }
29}29}
3030
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IConnectionManager.cs 2015-10-27 09:11:09 +0000
@@ -24,7 +24,7 @@
24{24{
25 public delegate void ConnectionAddedHandler (string objectPath);25 public delegate void ConnectionAddedHandler (string objectPath);
26 26
27 [Interface ("org.freedesktop.NetworkManagerSettings")]27 [Interface ("org.freedesktop.NetworkManager.Settings")]
28 public interface IConnectionManager28 public interface IConnectionManager
29 {29 {
30 string[] ListConnections ();30 string[] ListConnections ();
3131
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IDHCP4Config.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.DHCP4Config")]25 [Interface ("org.freedesktop.NetworkManager.DHCP4Config")]
26 public interface IDHCP4Config : org.freedesktop.DBus.Properties26 public interface IDHCP4Config
27 {27 {
28 }28 }
29}29}
3030
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IIP4Config.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.IP4Config")]25 [Interface ("org.freedesktop.NetworkManager.IP4Config")]
26 public interface IIP4Config : org.freedesktop.DBus.Properties26 public interface IIP4Config
27 {27 {
28 }28 }
29}29}
3030
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/INetManager.cs 2015-10-27 09:11:09 +0000
@@ -23,10 +23,11 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager")]25 [Interface ("org.freedesktop.NetworkManager")]
26 public interface INetManager : org.freedesktop.DBus.Properties26 public interface INetManager
27 {27 {
28 ObjectPath[] GetDevices ();28 ObjectPath[] GetDevices ();
29 ObjectPath ActivateConnection (string serviceName, ObjectPath connection, ObjectPath device, ObjectPath specificObject);29 ObjectPath ActivateConnection (ObjectPath connection, ObjectPath device, ObjectPath specificObject);
30 void DeactivateConnection (ObjectPath active_connection);
30 uint state ();31 uint state ();
31 }32 }
32}33}
3334
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/INetworkConnection.cs 2015-10-27 09:11:09 +0000
@@ -23,10 +23,10 @@
2323
24namespace NetworkManagerDocklet24namespace NetworkManagerDocklet
25{25{
26 [Interface("org.freedesktop.NetworkManagerSettings.Connection")]26 [Interface("org.freedesktop.NetworkManager.Settings.Connection")]
27 public interface INetworkConnection 27 public interface INetworkConnection
28 {28 {
29 IDictionary<string, IDictionary<string, object>> GetSettings();29 Dictionary<string, Dictionary<string, object>> GetSettings();
30 event ConnectionRemovedHandler Removed;30 event ConnectionRemovedHandler Removed;
31 }31 }
32 32
3333
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/INetworkDevice.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.Device")]25 [Interface ("org.freedesktop.NetworkManager.Device")]
26 public interface INetworkDevice : org.freedesktop.DBus.Properties26 public interface INetworkDevice
27 {27 {
28 event StateChangedHandler StateChanged;28 event StateChangedHandler StateChanged;
29 }29 }
3030
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IWiredDevice.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.Device.Wired")]25 [Interface ("org.freedesktop.NetworkManager.Device.Wired")]
26 public interface IWiredDevice : org.freedesktop.DBus.Properties26 public interface IWiredDevice
27 {27 {
28 }28 }
29}29}
3030
=== modified file 'StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs'
--- StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/Interfaces/IWirelessDevice.cs 2015-10-27 09:11:09 +0000
@@ -23,7 +23,7 @@
23namespace NetworkManagerDocklet23namespace NetworkManagerDocklet
24{24{
25 [Interface ("org.freedesktop.NetworkManager.Device.Wireless")]25 [Interface ("org.freedesktop.NetworkManager.Device.Wireless")]
26 public interface IWirelessDevice : org.freedesktop.DBus.Properties26 public interface IWirelessDevice
27 {27 {
28 ObjectPath[] GetAccessPoints ();28 ObjectPath[] GetAccessPoints ();
29 event AccessPointAddRemoveHandler AccessPointAdded;29 event AccessPointAddRemoveHandler AccessPointAdded;
3030
=== modified file 'StandardPlugins/NetworkManager/src/NetworkConnection.cs'
--- StandardPlugins/NetworkManager/src/NetworkConnection.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/NetworkConnection.cs 2015-10-27 09:11:09 +0000
@@ -41,11 +41,11 @@
41 41
42 public ConnectionOwner Owner { get; private set; }42 public ConnectionOwner Owner { get; private set; }
43 43
44 public IDictionary<string, IDictionary<string, object>> Settings {44 public Dictionary<string, Dictionary<string, object>> Settings {
45 get { return BusObject.GetSettings (); }45 get { return BusObject.GetSettings (); }
46 }46 }
47 47
48 private IDictionary<string, object> Connection {48 private Dictionary<string, object> Connection {
49 get { return this.Settings["connection"]; }49 get { return this.Settings["connection"]; }
50 }50 }
51 51
5252
=== modified file 'StandardPlugins/NetworkManager/src/NetworkDevice.cs'
--- StandardPlugins/NetworkManager/src/NetworkDevice.cs 2011-01-09 18:02:06 +0000
+++ StandardPlugins/NetworkManager/src/NetworkDevice.cs 2015-10-27 09:11:09 +0000
@@ -63,7 +63,7 @@
63 public DeviceType DType {63 public DeviceType DType {
64 get { 64 get {
65 try {65 try {
66 return (DeviceType) Enum.ToObject (typeof (DeviceType), BusObject.Get (BusName, "DeviceType"));66 return (DeviceType) Enum.ToObject (typeof (DeviceType), this.Get ("DeviceType"));
67 } catch (Exception e) {67 } catch (Exception e) {
68 Log<NetworkDevice>.Error (e.Message);68 Log<NetworkDevice>.Error (e.Message);
69 Log<NetworkDevice>.Debug (e.StackTrace);69 Log<NetworkDevice>.Debug (e.StackTrace);
@@ -75,7 +75,7 @@
75 public DeviceState State {75 public DeviceState State {
76 get { 76 get {
77 try {77 try {
78 return (DeviceState) Enum.ToObject (typeof (DeviceState), BusObject.Get (BusName, "State")); 78 return (DeviceState) Enum.ToObject (typeof (DeviceState), this.Get ("State"));
79 } catch (Exception e) {79 } catch (Exception e) {
80 Log<NetworkDevice>.Error (e.Message);80 Log<NetworkDevice>.Error (e.Message);
81 Log<NetworkDevice>.Debug (e.StackTrace);81 Log<NetworkDevice>.Debug (e.StackTrace);
@@ -93,16 +93,16 @@
93 void SetIPs ()93 void SetIPs ()
94 {94 {
95 if (State == DeviceState.Active) {95 if (State == DeviceState.Active) {
96 if (BusObject.Get (BusName, "Dhcp4Config").ToString () != "/")96 if (this.Get ("Dhcp4Config").ToString () != "/")
97 ConType = ConnectionType.Manaul;97 ConType = ConnectionType.Manaul;
98 else98 else
99 ConType = ConnectionType.DHCP;99 ConType = ConnectionType.DHCP;
100 IP4Config = new DBusObject<IIP4Config> (NMBusName, BusObject.Get (BusName, "Ip4Config").ToString ());100 IP4Config = new DBusObject<IIP4Config> (NMBusName, this.Get ("Ip4Config").ToString ());
101 IP4Address = new IPAddress (long.Parse (BusObject.Get (BusName, "Ip4Address").ToString ()));101 IP4Address = new IPAddress (long.Parse (this.Get ("Ip4Address").ToString ()));
102 uint[][] Addresses = (uint[][]) IP4Config.BusObject.Get (IP4Config.BusName, "Addresses");102 uint[][] Addresses = (uint[][]) IP4Config.Get ("Addresses");
103 Gateway = new IPAddress (Addresses[0][2]);103 Gateway = new IPAddress (Addresses[0][2]);
104 SubnetMask = ConvertPrefixToIp ((int) Addresses[0][1]);104 SubnetMask = ConvertPrefixToIp ((int) Addresses[0][1]);
105 uint[] NameServers = (uint[]) IP4Config.BusObject.Get (IP4Config.BusName, "Nameservers");105 uint[] NameServers = (uint[]) IP4Config.Get ("Nameservers");
106 if (NameServers.Length > 0)106 if (NameServers.Length > 0)
107 PrimaryDNS = new IPAddress (NameServers[0]);107 PrimaryDNS = new IPAddress (NameServers[0]);
108 else108 else
109109
=== modified file 'StandardPlugins/NetworkManager/src/NetworkManager.cs'
--- StandardPlugins/NetworkManager/src/NetworkManager.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/NetworkManager.cs 2015-10-27 09:11:09 +0000
@@ -21,6 +21,7 @@
21using System.Collections.Generic;21using System.Collections.Generic;
2222
23using DBus;23using DBus;
24using Docky.Services;
24using org.freedesktop.DBus;25using org.freedesktop.DBus;
2526
26namespace NetworkManagerDocklet27namespace NetworkManagerDocklet
@@ -38,10 +39,7 @@
38 get {39 get {
39 foreach (string active in DevManager.ActiveConnections) {40 foreach (string active in DevManager.ActiveConnections) {
40 DBusObject<IActiveConnection> ActiveConnection = new DBusObject<IActiveConnection> ("org.freedesktop.NetworkManager", active);41 DBusObject<IActiveConnection> ActiveConnection = new DBusObject<IActiveConnection> ("org.freedesktop.NetworkManager", active);
41 if (ActiveConnection.BusObject.Get (ActiveConnection.BusName, "ServiceName").ToString ().Contains ("System"))42 yield return ConManager.SystemConnections.Where (con => con.ObjectPath == ActiveConnection.Get ("Connection").ToString ()).First ();
42 yield return ConManager.SystemConnections.Where (con => con.ObjectPath == ActiveConnection.BusObject.Get (ActiveConnection.BusName, "Connection").ToString ()).First ();
43 else
44 yield return ConManager.UserConnections.Where (con => con.ObjectPath == ActiveConnection.BusObject.Get (ActiveConnection.BusName, "Connection").ToString ()).First ();
45 }43 }
46 }44 }
47 }45 }
@@ -61,9 +59,12 @@
61 try {59 try {
62 connection = ConManager.AllConnections.OfType<WirelessConnection> ().Where (con => (con as WirelessConnection).SSID == ap.SSID).First ();60 connection = ConManager.AllConnections.OfType<WirelessConnection> ().Where (con => (con as WirelessConnection).SSID == ap.SSID).First ();
63 ConnectTo (connection);61 ConnectTo (connection);
64 } catch {62 } catch (Exception e) {
65 // FIXME We're trying to connect to an AP but no connection entry exists.63 // FIXME We're trying to connect to an AP but no connection entry exists.
66 // If we can figure out how to manually create a connection behind the scenes, we can remove this.64 // If we can figure out how to manually create a connection behind the scenes, we can remove this.
65 // FIXME 2: What to do if an exception is thrown because of another reason?
66 Log<NetworkManager>.Error(e.Message);
67 Log<NetworkManager>.Debug(e.StackTrace);
67 Docky.Services.DockServices.System.RunOnThread ( () => {68 Docky.Services.DockServices.System.RunOnThread ( () => {
68 Process.Start ("nm-connection-editor --type=802-11-wireless");69 Process.Start ("nm-connection-editor --type=802-11-wireless");
69 });70 });
@@ -86,14 +87,22 @@
86 return;87 return;
87 }88 }
88 89
89 string serviceName;90 string serviceName = "org.freedesktop.NetworkManager.Settings";
90 if (con.Owner == ConnectionOwner.System)
91 serviceName = "org.freedesktop.NetworkManagerSystemSettings";
92 else
93 serviceName = "org.freedesktop.NetworkManagerUserSettings";
94 string conStr = con.ObjectPath;91 string conStr = con.ObjectPath;
95 92
96 DevManager.BusObject.ActivateConnection(serviceName, new ObjectPath (conStr), new ObjectPath (dev.ObjectPath), new ObjectPath (specObj));93 DevManager.BusObject.ActivateConnection(new ObjectPath (conStr), new ObjectPath (dev.ObjectPath), new ObjectPath (specObj));
94 }
95 public void DisconnectFrom (WirelessAccessPoint ap)
96 {
97 ObjectPath apObjectPath = new ObjectPath(ap.ObjectPath);
98 foreach (string active in DevManager.ActiveConnections) {
99 DBusObject<IActiveConnection> activeConnection = new DBusObject<IActiveConnection> ("org.freedesktop.NetworkManager", active);
100 string specificObject = activeConnection.Get("SpecificObject").ToString();
101 if (specificObject == ap.ObjectPath) {
102 DevManager.BusObject.DeactivateConnection(new ObjectPath(activeConnection.ObjectPath));
103 return;
104 }
105 }
97 }106 }
98107
99 void OnDevStateChanged(object o, DeviceStateChangedArgs args)108 void OnDevStateChanged(object o, DeviceStateChangedArgs args)
100109
=== modified file 'StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs'
--- StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs 2014-04-22 15:12:30 +0000
+++ StandardPlugins/NetworkManager/src/NetworkManagerDocklet.cs 2015-10-27 09:11:09 +0000
@@ -83,7 +83,7 @@
83 string SetDockletIcon ()83 string SetDockletIcon ()
84 {84 {
85 try {85 try {
86 // currently connecting (animated)86 // currently connecting/disconnecting (animated)
87 NetworkDevice dev = NM.DevManager.NetworkDevices87 NetworkDevice dev = NM.DevManager.NetworkDevices
88 .Where (d => d.State == DeviceState.Configuring || d.State == DeviceState.IPConfiguring || d.State == DeviceState.Preparing)88 .Where (d => d.State == DeviceState.Configuring || d.State == DeviceState.IPConfiguring || d.State == DeviceState.Preparing)
89 .FirstOrDefault ();89 .FirstOrDefault ();
@@ -142,7 +142,7 @@
142 List<MenuItem> active = list[MenuListContainer.Header];142 List<MenuItem> active = list[MenuListContainer.Header];
143 143
144 foreach (WirelessAccessPoint wap in ActiveAccessPoints) {144 foreach (WirelessAccessPoint wap in ActiveAccessPoints) {
145 active.Add (MakeConEntry (wap));145 active.Add (MakeConEntry (wap, true));
146 }146 }
147 147
148 int count = 0;148 int count = 0;
@@ -156,7 +156,7 @@
156 if (val.Any (wap => ActiveAccessPoints.Contains (wap)))156 if (val.Any (wap => ActiveAccessPoints.Contains (wap)))
157 continue;157 continue;
158 158
159 wifi.Add (MakeConEntry (val.OrderByDescending (wap => wap.Strength).First ()));159 wifi.Add (MakeConEntry (val.OrderByDescending (wap => wap.Strength).First (), false));
160 count++;160 count++;
161 }161 }
162 }162 }
@@ -200,7 +200,7 @@
200// //yield return new SimpleMenuButtonArgs (() => Console.WriteLine ("asdf"),"Click me!", "network-manager");200// //yield return new SimpleMenuButtonArgs (() => Console.WriteLine ("asdf"),"Click me!", "network-manager");
201// }201// }
202 202
203 MenuItem MakeConEntry (WirelessAccessPoint ap)203 MenuItem MakeConEntry (WirelessAccessPoint ap, bool isactive)
204 {204 {
205 string apName = ap.SSID;205 string apName = ap.SSID;
206 string icon = APIconFromStrength (ap.Strength);206 string icon = APIconFromStrength (ap.Strength);
@@ -208,7 +208,12 @@
208 208
209 bool secure = ap.Flags == APFlags.Privacy || ap.RsnFlags != AccessPointSecurity.None || ap.WpaFlags != AccessPointSecurity.None;209 bool secure = ap.Flags == APFlags.Privacy || ap.RsnFlags != AccessPointSecurity.None || ap.WpaFlags != AccessPointSecurity.None;
210 210
211 Docky.Menus.MenuItem item = new Docky.Menus.MenuItem (apName, icon, (o, a) => NM.ConnectTo (ap));211 Docky.Menus.MenuItem item;
212 if (isactive) {
213 item = new Docky.Menus.MenuItem (apName, icon, (o, a) => NM.DisconnectFrom(ap));
214 } else {
215 item = new Docky.Menus.MenuItem (apName, icon, (o, a) => NM.ConnectTo (ap));
216 }
212 item.Bold = bold;217 item.Bold = bold;
213 218
214 if (secure)219 if (secure)
215220
=== modified file 'StandardPlugins/NetworkManager/src/WiredDevice.cs'
--- StandardPlugins/NetworkManager/src/WiredDevice.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/WiredDevice.cs 2015-10-27 09:11:09 +0000
@@ -35,13 +35,13 @@
35 35
36 public bool Carrier {36 public bool Carrier {
37 get {37 get {
38 return Boolean.Parse (WiredProperties.BusObject.Get (WiredProperties.BusName, "Carrier").ToString ());38 return Boolean.Parse (WiredProperties.Get ("Carrier").ToString ());
39 }39 }
40 }40 }
41 41
42 public string HWAddresss {42 public string HWAddresss {
43 get {43 get {
44 return WiredProperties.BusObject.Get (WiredProperties.BusName, "HwAddress").ToString ();44 return WiredProperties.Get ("HwAddress").ToString ();
45 }45 }
46 }46 }
47 }47 }
4848
=== modified file 'StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs'
--- StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs 2009-11-28 23:36:17 +0000
+++ StandardPlugins/NetworkManager/src/WirelessAccessPoint.cs 2015-10-27 09:11:09 +0000
@@ -51,7 +51,7 @@
51 public string SSID {51 public string SSID {
52 get {52 get {
53 try {53 try {
54 return System.Text.ASCIIEncoding.ASCII.GetString ((byte[]) BusObject.Get (BusName, "Ssid"));54 return System.Text.ASCIIEncoding.ASCII.GetString ((byte[]) this.Get ("Ssid"));
55 } catch (Exception e) {55 } catch (Exception e) {
56 Log<WirelessAccessPoint>.Error (ObjectPath);56 Log<WirelessAccessPoint>.Error (ObjectPath);
57 Log<WirelessAccessPoint>.Error (e.Message);57 Log<WirelessAccessPoint>.Error (e.Message);
@@ -64,7 +64,7 @@
64 public byte Strength {64 public byte Strength {
65 get {65 get {
66 try {66 try {
67 return (byte) BusObject.Get (BusName, "Strength");67 return (byte) this.Get ("Strength");
68 } catch (Exception e) {68 } catch (Exception e) {
69 Log<WirelessAccessPoint>.Error (ObjectPath);69 Log<WirelessAccessPoint>.Error (ObjectPath);
70 Log<WirelessAccessPoint>.Error (e.Message);70 Log<WirelessAccessPoint>.Error (e.Message);
@@ -77,7 +77,7 @@
77 public APFlags Flags {77 public APFlags Flags {
78 get {78 get {
79 try {79 try {
80 return (APFlags) Convert.ToInt32 (BusObject.Get (BusName, "Flags"));80 return (APFlags) Convert.ToInt32 (this.Get ("Flags"));
81 } catch (Exception e) {81 } catch (Exception e) {
82 Log<WirelessAccessPoint>.Error (ObjectPath);82 Log<WirelessAccessPoint>.Error (ObjectPath);
83 Log<WirelessAccessPoint>.Error (e.Message);83 Log<WirelessAccessPoint>.Error (e.Message);
@@ -90,7 +90,7 @@
90 public AccessPointSecurity RsnFlags {90 public AccessPointSecurity RsnFlags {
91 get {91 get {
92 try {92 try {
93 return (AccessPointSecurity) Convert.ToInt32 (BusObject.Get (BusName, "RsnFlags"));93 return (AccessPointSecurity) Convert.ToInt32 (this.Get ("RsnFlags"));
94 } catch (Exception e) {94 } catch (Exception e) {
95 Log<WirelessAccessPoint>.Error (ObjectPath);95 Log<WirelessAccessPoint>.Error (ObjectPath);
96 Log<WirelessAccessPoint>.Error (e.Message);96 Log<WirelessAccessPoint>.Error (e.Message);
@@ -103,7 +103,7 @@
103 public AccessPointSecurity WpaFlags {103 public AccessPointSecurity WpaFlags {
104 get {104 get {
105 try {105 try {
106 return (AccessPointSecurity) Convert.ToInt32 (BusObject.Get (BusName, "WpaFlags"));106 return (AccessPointSecurity) Convert.ToInt32 (this.Get ("WpaFlags"));
107 } catch (Exception e) {107 } catch (Exception e) {
108 Log<WirelessAccessPoint>.Error (ObjectPath);108 Log<WirelessAccessPoint>.Error (ObjectPath);
109 Log<WirelessAccessPoint>.Error (e.Message);109 Log<WirelessAccessPoint>.Error (e.Message);
110110
=== modified file 'StandardPlugins/NetworkManager/src/WirelessConnection.cs'
--- StandardPlugins/NetworkManager/src/WirelessConnection.cs 2009-11-25 15:37:53 +0000
+++ StandardPlugins/NetworkManager/src/WirelessConnection.cs 2015-10-27 09:11:09 +0000
@@ -27,7 +27,7 @@
27 {27 {
28 }28 }
29 29
30 public IDictionary<string, object> WirelessProperties {30 public Dictionary<string, object> WirelessProperties {
31 get { return Settings["802-11-wireless"]; }31 get { return Settings["802-11-wireless"]; }
32 }32 }
33 33
3434
=== modified file 'StandardPlugins/NetworkManager/src/WirelessDevice.cs'
--- StandardPlugins/NetworkManager/src/WirelessDevice.cs 2010-10-09 12:54:14 +0000
+++ StandardPlugins/NetworkManager/src/WirelessDevice.cs 2015-10-27 09:11:09 +0000
@@ -76,7 +76,7 @@
7676
77 public WirelessAccessPoint ActiveAccessPoint {77 public WirelessAccessPoint ActiveAccessPoint {
78 get {78 get {
79 string access = WirelessProperties.BusObject.Get (WirelessProperties.BusName, "ActiveAccessPoint").ToString ();79 string access = WirelessProperties.Get ("ActiveAccessPoint").ToString ();
80 return AccessPoints80 return AccessPoints
81 .Where (ap => ap.ObjectPath == access)81 .Where (ap => ap.ObjectPath == access)
82 .DefaultIfEmpty (null)82 .DefaultIfEmpty (null)
@@ -85,7 +85,7 @@
85 }85 }
86 86
87 public string HWAddress {87 public string HWAddress {
88 get { return WirelessProperties.BusObject.Get (WirelessProperties.BusName, "HwAddress").ToString (); }88 get { return WirelessProperties.Get ("HwAddress").ToString (); }
89 }89 }
90 }90 }
91}91}

Subscribers

People subscribed via source and target branches

to status/vote changes: