public static void Init () { try { // Init System DBus NDesk.DBus.BusG.Init (NDesk.DBus.Bus.System); } catch (Exception e) { // Lack of specific exception Log.Error (e, "Failed to access dbus session bus. Battery monitoring will be disabled."); return; } try { Manager manager = new Manager (new Context ()); foreach (Device device in manager.FindDeviceByCapability ("ac_adapter")) { Log.Debug ("Found HAL device AC adapter for battery monitoring."); device.PropertyModified += OnPropertyModified; adapter = device; prev_on_battery = ! device.GetPropertyBoolean ("ac_adapter.present"); break; } } catch (Exception e) { Log.Error (e, "Failed to acquire a HAL device for battery monitoring"); } }
public ICollection<Device> FindDeviceStringMatch (string key, string value) { List<Device> devices = new List<Device> (); foreach (ObjectPath opath in manager.FindDeviceStringMatch (key, value)) { Device device = new Device (context, opath); devices.Add (device); } return devices; }
public ICollection<Device> FindDeviceByCapability (string capability) { List<Device> devices = new List<Device> (); foreach (ObjectPath opath in manager.FindDeviceByCapability (capability)) { Device device = new Device (context, opath); devices.Add (device); } return devices; }
public ICollection<Device> GetAllDevices () { List<Device> devices = new List<Device> (); foreach (ObjectPath opath in manager.GetAllDevices ()) { Device device = new Device (context, opath); devices.Add (device); } return devices; }
private bool IsMounted(Hal.Device device) { try { if (!device.PropertyExists("volume.mount_point")) { return(false); } } catch { return(false); } string mountPoint = device.GetPropertyString("volume.mount_point"); return(mountPoint != null && mountPoint != String.Empty); }
public void ImportUdi (string udi) { /* probably a camera we need to contruct on of our gphoto2 uris */ Hal.Device dev = new Hal.Device (Core.HalContext, udi); string mount_point = dev.GetPropertyString ("volume.mount_point"); int bus = dev.GetPropertyInt ("usb.bus_number"); int device = dev.GetPropertyInt ("usb.linux.device_number"); System.Console.WriteLine ("dev = {1} exists = {2} mount_point = {0} {3},{4}", mount_point, dev, dev.Exists, bus, device); if (! dev.Exists || mount_point != null) { ImportFile (mount_point); } else { string gphoto_uri = String.Format ("gphoto2:usb:{0},{1}", bus.ToString ("d3") , device.ToString ("d3")); System.Console.WriteLine ("gphoto_uri = {0}", gphoto_uri); ImportCamera (gphoto_uri); } }
public AccessControl (Context context, Device device) : this (context, device.ObjectPath) { }
public static Device[] UdisToDevices(Context ctx, string [] udis) { if(ctx == null) { return new Device[0]; } Device [] devices = new Device[udis.Length]; for(int i = 0; i < udis.Length; i++) { devices[i] = new Device(ctx, udis[i]); } return devices; }
public Storage (Context context, Device device) : this (context, device.ObjectPath) { }
public LaptopPanel (Context context, Device device) : this (context, device.ObjectPath) { }
public SystemPowerManagement (Context context, Device device) : this (context, device.ObjectPath) { }
public Device NewDevice () { ObjectPath opath = manager.NewDevice (); Device device = new Device (context, opath); return device; }
public bool DeviceExists (Device device) { return manager.DeviceExists (device.ObjectPath); }
public KillSwitch (Context context, Device device) : this (context, device.ObjectPath) { }
private bool IsIPod(Hal.Device device) { return(device.PropertyExists("org.podsleuth.version")); }
public void Remove (Device udi) { manager.Remove (udi.ObjectPath); }
public void CommitToGdl (Device tmp_udi, Device udi) { manager.CommitToGdl (tmp_udi.ObjectPath, udi.ObjectPath); }
public Volume (Context context, Device device) : this (context, device.ObjectPath) { }
public LightSensor (Context context, Device device) : this (context, device.ObjectPath) { }