コード例 #1
0
        public ConnectionManager()
        {
            SystemConnectionManager = new DBusObject <IConnectionManager> (SystemBus, SettingsObjectPath);
            //SystemConnectionManager.BusObject.NewConnection += OnConnectionAdded;
            UserConnectionManager = new DBusObject <IConnectionManager> (UserBus, SettingsObjectPath);
            //UserConnectionManager.BusObject.NewConnection += OnConnectionAdded;

            UserConnections   = new List <NetworkConnection> ();
            SystemConnections = new List <NetworkConnection> ();

            UpdateConnections();
            //this workaround is necessary because NM emits bad signals, multiple times with bad data.
            GLib.Timeout.Add(1000 * 60 * 5, delegate { UpdateConnections(); return(true); });
        }
コード例 #2
0
 void SetIPs()
 {
     if (State == DeviceState.Active)
     {
         if (BusObject.Get(BusName, "Dhcp4Config").ToString() != "/")
         {
             ConType = ConnectionType.Manaul;
         }
         else
         {
             ConType = ConnectionType.DHCP;
         }
         IP4Config  = new DBusObject <IIP4Config> (NMBusName, BusObject.Get(BusName, "Ip4Config").ToString());
         IP4Address = new IPAddress(long.Parse(BusObject.Get(BusName, "Ip4Address").ToString()));
         uint[][] Addresses = (uint[][])IP4Config.BusObject.Get(IP4Config.BusName, "Addresses");
         Gateway    = new IPAddress(Addresses[0][2]);
         SubnetMask = ConvertPrefixToIp((int)Addresses[0][1]);
         uint[] NameServers = (uint[])IP4Config.BusObject.Get(IP4Config.BusName, "Nameservers");
         if (NameServers.Length > 0)
         {
             PrimaryDNS = new IPAddress(NameServers[0]);
         }
         else
         {
             PrimaryDNS = null;
         }
     }
     else
     {
         IP4Config  = null;
         ConType    = ConnectionType.Unknown;
         IP4Address = null;
         PrimaryDNS = null;
         Gateway    = null;
         SubnetMask = null;
     }
 }