Exemplo n.º 1
0
 public int CompareTo(WirelessAccessPoint other)
 {
     if (this.Strength >= other.Strength)
     {
         return(-1);
     }
     return(1);
 }
Exemplo n.º 2
0
        public void ConnectTo(WirelessAccessPoint ap)
        {
            NetworkConnection connection;

            try {
                connection = ConManager.AllConnections.OfType <WirelessConnection> ().Where(con => (con as WirelessConnection).SSID == ap.SSID).First();
                ConnectTo(connection);
            } catch {
                // FIXME We're trying to connect to an AP but no connection entry exists.
                // If we can figure out how to manually create a connection behind the scenes, we can remove this.
                Docky.Services.DockServices.System.RunOnThread(() => {
                    Process.Start("nm-connection-editor --type=802-11-wireless");
                });
            }
        }
Exemplo n.º 3
0
//		public IEnumerable<AbstractMenuArgs> GetMenuItems ()
//		{
//			List<AbstractMenuArgs> cons = new List<AbstractMenuArgs> ();
//
//			//show Wired networks (if carrier is true)
//			if (NM.DevManager.NetworkDevices.OfType<WiredDevice> ().Any (dev => (dev as WiredDevice).Carrier == true)) {
//				NM.ConManager.AllConnections.OfType<WiredConnection> ().ForEach<WiredConnection> ( con => {
//					cons.Add (MakeConEntry (con));
//				});
//			}
//
//			//show wireless connections if wireless is available
//			if (NM.DevManager.NetworkDevices.OfType<WirelessDevice> ().Any ()) {
//				cons.Add (new SeparatorMenuButtonArgs ());
//				NM.DevManager.NetworkDevices.OfType<WirelessDevice> ().ForEach<WirelessDevice> (dev => {
//					dev.VisibleAccessPoints.Values.ForEach <List<WirelessAccessPoint>> ( apList => {
//						cons.Add (MakeConEntry (apList.First ()));
//					});
//				});
//			}
//
//			foreach (AbstractMenuArgs arg in cons)
//			{
//				yield return arg;
//			}
//
//			//yield return new WidgetMenuArgs (box);
//
//			//yield return new SimpleMenuButtonArgs (() => Console.WriteLine ("asdf"),"Click me!", "network-manager");
//		}

        MenuItem MakeConEntry(WirelessAccessPoint ap)
        {
            string apName = ap.SSID;
            string icon   = APIconFromStrength(ap.Strength);
            bool   bold   = NM.DevManager.NetworkDevices.OfType <WirelessDevice> ().Any(dev => dev.ActiveAccessPoint == ap);

            bool secure = ap.Flags == APFlags.Privacy || ap.RsnFlags != AccessPointSecurity.None || ap.WpaFlags != AccessPointSecurity.None;

            Docky.Menus.MenuItem item = new Docky.Menus.MenuItem(apName, icon, (o, a) => NM.ConnectTo(ap));
            item.Bold = bold;

            if (secure)
            {
                item.Emblem = "nm-secure-lock";
            }

            return(item);
        }