Exemplo n.º 1
0
        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));
                }
            }
        }
Exemplo n.º 2
0
        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");
        }
Exemplo n.º 3
0
        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));
                    }
                }
            }
        }
Exemplo n.º 4
0
        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));
                }
            }
        }
Exemplo n.º 5
0
 public BlockDevice(DeviceArguments arguments) : base(arguments)
 {
     this.v = new DiscVolume(arguments, this);
 }
Exemplo n.º 6
0
 public CdromDevice(DeviceArguments arguments) : base(arguments)
 {
 }
Exemplo n.º 7
0
 public Volume(DeviceArguments arguments, IBlockDevice blockdevice) : base(arguments)
 {
     block_parent = blockdevice;
 }
Exemplo n.º 8
0
 public Volume(DeviceArguments arguments) : base(arguments)
 {
 }
Exemplo n.º 9
0
 public DiscVolume(DeviceArguments arguments, IBlockDevice b) : base(arguments, b)
 {
 }
Exemplo n.º 10
0
 public UsbDevice(DeviceArguments arguments) : base(arguments)
 {
 }
Exemplo n.º 11
0
 public UsbVolume(DeviceArguments arguments) : base(arguments)
 {
     return;
 }