예제 #1
0
        public GUdev.Device GudevDeviceFromGioVolume(GLib.IVolume volume)
        {
            GUdev.Device device = null;

            if (volume == null)
            {
                return(null);
            }

            var s = volume.GetIdentifier("unix-device");

            if (!String.IsNullOrEmpty(s))
            {
                device = client.QueryByDeviceFile(s);
            }

            if (device == null)
            {
                s = volume.Uuid;
                foreach (GUdev.Device d in client.QueryBySubsystem("usb"))
                {
                    if (s == d.GetSysfsAttr("serial"))
                    {
                        device = d;
                        break;
                    }
                }
            }

            return(device);
        }
예제 #2
0
 private RawVolume CreateRawVolume(GLib.IVolume volume)
 {
     GUdev.Device device;
     if (!volume_device_map.TryGetValue(volume.Handle, out device))
     {
         Hyena.Log.Debug(string.Format("No matching udev device for volume {0}/{1}", volume.Name, volume.Uuid));
         return(null);
     }
     return(new RawVolume(volume,
                          this,
                          new GioVolumeMetadataSource(volume),
                          new UdevMetadataSource(device)));
 }
예제 #3
0
        void VolumeRemoved(GLib.IVolume volume)
        {
            var h = DeviceRemoved;

            if (h != null)
            {
                var v = CreateRawVolume(volume);
                if (v == null)
                {
                    return;
                }

                h(this, new MountArgs(new Device(v)));
            }
        }
예제 #4
0
        private void VolumeChanged(GLib.IVolume volume)
        {
            if (volume == null)
            {
                Hyena.Log.Error("Gio.Manager: ignoring VolumeChanged signal with no volume");
                return;
            }

            var handler = DeviceChanged;

            if (handler != null)
            {
                var raw = CreateRawVolume(volume);
                if (raw == null)
                {
                    return;
                }
                var device = new Device(raw);
                handler(this, new MountArgs(HardwareManager.Resolve(device)));
            }
        }
예제 #5
0
        private void VolumeAdded(GLib.IVolume volume)
        {
            var device = GudevDeviceFromGioVolume(volume);

            if (device == null)
            {
                Hyena.Log.ErrorFormat("VolumeAdded: {0}/{1} with no matching udev device", volume.Name, volume.Uuid);
                return;
            }

            volume_device_map [volume.Handle] = device;
            var h = DeviceAdded;

            if (h != null)
            {
                var raw = CreateRawVolume(volume);
                if (raw == null)
                {
                    return;
                }
                var dev = new Device(raw);
                h(this, new MountArgs(HardwareManager.Resolve(dev)));
            }
        }
예제 #6
0
 public RawVolume(GLib.IVolume volume, Manager manager, GioVolumeMetadataSource gioMetadata, UdevMetadataSource udevMetadata)
     : base(manager, gioMetadata, udevMetadata)
 {
     Volume = volume;
 }