private void DeviceDisappeared(object o, DeviceArguments args) { Device device = new Device(args); Hyena.Log.InformationFormat("device disappeared: {0}, path: {1}", device.Uuid, args.DeviceProperties.GetStringValue("DAVolumePath")); lock (this) { var old_device = devices.Where(d => d.Uuid == device.Uuid).FirstOrDefault(); if (old_device != null) { devices.Remove(old_device); DeviceRemoved(this, new DeviceRemovedArgs(old_device.Uuid)); } } }
public Device(DeviceArguments arguments) { this.deviceArguments = arguments; // copy values from the NSDictionary so we don't rely on it later this.vendor = deviceArguments.DeviceProperties.GetStringValue("DADeviceVendor"); this.uuid = GetUUIDFromProperties(deviceArguments.DeviceProperties); this.name = deviceArguments.DeviceProperties.GetStringValue("DAVolumeName"); if (string.IsNullOrEmpty(this.name)) { this.name = deviceArguments.DeviceProperties.GetStringValue("DAMediaName"); } this.product = deviceArguments.DeviceProperties.GetStringValue("DADeviceModel"); }
private void OnDeviceAppeared(object o, DeviceArguments args) { Device device = new Device(args); Hyena.Log.DebugFormat("device appeared: {0}, path: {1}", device.Uuid, args.DeviceProperties.GetStringValue("DAVolumePath")); lock (this) { // only handle devices which have a VolumePath (=MountPoint) if (!args.DeviceProperties.HasKey("DAVolumePath")) { return; } var protocol = args.DeviceProperties.GetStringValue("DADeviceProtocol"); IDevice new_device = null; if (!string.IsNullOrEmpty(protocol) && protocol == "USB") { new_device = new UsbVolume(args); } else { new_device = new Volume(args, null); } // avoid adding a device twice - might happen since DeviceAppeared and DeviceChanged both fire var old_device = devices.Where(v => { return(v.Uuid == new_device.Uuid); }).FirstOrDefault(); if (old_device != null) { return; } if (new_device != null) { devices.Add(new_device); var added_handler = DeviceAdded; if (added_handler != null) { // Notify that a device was added (i.e. to refresh device list) added_handler(this, new DeviceAddedArgs((IDevice)new_device)); } } } }
private void OnDeviceChanged(object o, DeviceArguments args) { Device device = new Device(args); Hyena.Log.DebugFormat("device changed: {0}, path: {1}", device.Uuid, args.DeviceProperties.GetStringValue("DAVolumePath")); lock (this) { var old_device = devices.Where(d => d.Uuid == device.Uuid).FirstOrDefault(); if (old_device != null) { // a device that was currently attached has changed // remove the device and immediately re-add it devices.Remove(old_device); var remove_handler = DeviceRemoved; if (remove_handler != null) { remove_handler(old_device, new DeviceRemovedArgs(old_device.Uuid)); } } // do not add device without a VolumePath (=MountPoint) if (!args.DeviceProperties.HasKey("DAVolumePath")) { return; } IDevice new_device = null; var protocol = args.DeviceProperties.GetStringValue("DADeviceProtocol"); if (!string.IsNullOrEmpty(protocol) && protocol == "USB") { new_device = new UsbVolume(args); } else { new_device = new Volume(args); } devices.Add(new_device); var added_handler = DeviceAdded; if (added_handler != null) { added_handler(this, new DeviceAddedArgs((IDevice)new_device)); } } }
public BlockDevice(DeviceArguments arguments) : base(arguments) { this.v = new DiscVolume(arguments, this); }
public CdromDevice(DeviceArguments arguments) : base(arguments) { }
public Volume(DeviceArguments arguments, IBlockDevice blockdevice) : base(arguments) { block_parent = blockdevice; }
public Volume(DeviceArguments arguments) : base(arguments) { }
public DiscVolume(DeviceArguments arguments, IBlockDevice b) : base(arguments, b) { }
public UsbDevice(DeviceArguments arguments) : base(arguments) { }
public UsbVolume(DeviceArguments arguments) : base(arguments) { return; }