public static NetworkDevice NewForObjectPath(string objectPath) { if (!devices.ContainsKey(objectPath)) { NetworkDevice result = new NetworkDevice(objectPath); if (result.DType == DeviceType.Wired) { result = new WiredDevice(objectPath); } else if (result.DType == DeviceType.Wireless) { result = new WirelessDevice(objectPath); } devices[objectPath] = result; } return(devices[objectPath]); }
string SetDockletIcon() { try { // currently connecting (animated) NetworkDevice dev = NM.DevManager.NetworkDevices .Where(d => d.State == DeviceState.Configuring || d.State == DeviceState.IPConfiguring || d.State == DeviceState.Preparing) .FirstOrDefault(); if (dev != null) { HoverText = Catalog.GetString("Connecting..."); State |= ItemState.Wait; return("nm-no-connection"); } State &= ~ItemState.Wait; // no connection if (!NM.ActiveConnections.Any()) { HoverText = Catalog.GetString("Disconnected"); return("nm-no-connection"); } // wireless connection if (NM.ActiveConnections.OfType <WirelessConnection> ().Any()) { string ssid = NM.ActiveConnections.OfType <WirelessConnection> ().First().SSID; byte strength = NM.DevManager.NetworkDevices.OfType <WirelessDevice> ().First().APBySSID(ssid).Strength; HoverText = string.Format(Catalog.GetString("Connected: {0}"), ssid); return(APIconFromStrength(strength)); } } catch { // FIXME why do we default to this? return(APIconFromStrength((byte)100)); } // default to wired connection return("nm-device-wired"); }