~cszikszoy/do-plugins/nmdocklet

« back to all changes in this revision

Viewing changes to NetworkManagerDocklet/src/NetworkManager/NetworkDevice.cs

  • Committer: Chris S.
  • Date: 2009-06-26 03:51:28 UTC
  • Revision ID: chris@szikszoy.com-20090626035128-7pb93roemhzdns3k
changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
                void OnStateChanged (DeviceState new_state, DeviceState old_state, uint reason)
30
30
                {
31
 
                        SetIPs ();
 
31
                        if (new_state == DeviceState.Active)
 
32
                                SetIPs ();
32
33
                        DeviceStateChangedHandler handler = StateChanged;
33
34
                        if (handler != null) {
34
35
                                DeviceStateChangedArgs args = new DeviceStateChangedArgs ();
65
66
                                else
66
67
                                        this.ConType = ConnectionType.DHCP;
67
68
                                this.IP4Config = new DBusObject<IIP4Config> (NMBusName, BusObject.Get (BusName, "Ip4Config").ToString ());
 
69
                                this.IP4Address = new IPAddress (long.Parse (BusObject.Get (BusName, "Ip4Address").ToString ()));
68
70
                                uint[][] Addresses = (uint[][]) IP4Config.BusObject.Get (IP4Config.BusName, "Addresses");
69
 
                                this.IP4Address = new IPAddress (long.Parse (BusObject.Get (BusName, "Ip4Address").ToString ()));
70
71
                                this.Gateway = new IPAddress (Addresses[0][2]);
71
72
                                this.SubnetMask = ConvPrefixToIp ((int) Addresses[0][1]);
72
73
                                uint[] NameServers = (uint[]) IP4Config.BusObject.Get (IP4Config.BusName, "Nameservers");
73
 
                                this.PrimaryDNS = new IPAddress (NameServers[0]);
 
74
                                if (NameServers.Length > 0)
 
75
                                        this.PrimaryDNS = new IPAddress (NameServers[0]);
 
76
                                else
 
77
                                        this.PrimaryDNS = null;
74
78
                        } else {
75
79
                                this.IP4Config = null;
76
80
                                this.ConType = ConnectionType.Unknown;