From 88ca24c4ef4025897834a1d4e1bb4cc4ff67964a Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Tue, 30 Jul 2019 23:10:19 +0800 Subject: [PATCH] Add Platform Interface for Mounted drives service. Add Linux-specific implementation of the interface. --- .../Platform/IMountedDriveInfoProvider.cs | 35 + .../Platform/MountedDriveInfo.cs | 28 + src/Avalonia.X11/Avalonia.X11.csproj | 1 + .../Dbus/LinuxDriveInfoProvider.cs | 157 ++ src/Avalonia.X11/Dbus/UDisks2.cs | 1395 +++++++++++++++++ 5 files changed, 1616 insertions(+) create mode 100644 src/Avalonia.Controls/Platform/IMountedDriveInfoProvider.cs create mode 100644 src/Avalonia.Controls/Platform/MountedDriveInfo.cs create mode 100644 src/Avalonia.X11/Dbus/LinuxDriveInfoProvider.cs create mode 100644 src/Avalonia.X11/Dbus/UDisks2.cs diff --git a/src/Avalonia.Controls/Platform/IMountedDriveInfoProvider.cs b/src/Avalonia.Controls/Platform/IMountedDriveInfoProvider.cs new file mode 100644 index 0000000000..1c1871466d --- /dev/null +++ b/src/Avalonia.Controls/Platform/IMountedDriveInfoProvider.cs @@ -0,0 +1,35 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using Avalonia.Platform; + +namespace Avalonia.Controls.Platform +{ + /// + /// Defines a platform-specific drive mount information provider implementation. + /// + public interface IMountedDriveInfoProvider + { + /// + /// Observable list of currently-mounted drives. + /// + ObservableCollection CurrentDrives { get; } + + /// + /// Determines if the service is currently monitoring. + /// + bool IsMonitoring { get; } + + /// + /// Start the service polling routine. + /// + void Start(); + + /// + /// Stop the service polling routine. + /// + void Stop(); + } +} diff --git a/src/Avalonia.Controls/Platform/MountedDriveInfo.cs b/src/Avalonia.Controls/Platform/MountedDriveInfo.cs new file mode 100644 index 0000000000..13b8bc45f5 --- /dev/null +++ b/src/Avalonia.Controls/Platform/MountedDriveInfo.cs @@ -0,0 +1,28 @@ +// Copyright (c) The Avalonia Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; + +namespace Avalonia.Controls.Platform +{ + /// + /// Describes a Drive's properties. + /// + public class MountedDriveInfo : IEquatable + { + public string DriveLabel { get; set; } + public string DriveName { get; set; } + public ulong DriveSizeBytes { get; set; } + public string DevicePath { get; set; } + public string MountPath { get; set; } + + public bool Equals(MountedDriveInfo other) + { + return this.DriveLabel.Equals(other.DriveLabel) && + this.DriveName.Equals(other.DriveName) && + this.DriveSizeBytes.Equals(other.DriveSizeBytes) && + this.DevicePath.Equals(other.DevicePath) && + this.MountPath.Equals(other.MountPath); + } + } +} diff --git a/src/Avalonia.X11/Avalonia.X11.csproj b/src/Avalonia.X11/Avalonia.X11.csproj index 59afc877de..4270d34e2e 100644 --- a/src/Avalonia.X11/Avalonia.X11.csproj +++ b/src/Avalonia.X11/Avalonia.X11.csproj @@ -8,6 +8,7 @@ + diff --git a/src/Avalonia.X11/Dbus/LinuxDriveInfoProvider.cs b/src/Avalonia.X11/Dbus/LinuxDriveInfoProvider.cs new file mode 100644 index 0000000000..f5e477649f --- /dev/null +++ b/src/Avalonia.X11/Dbus/LinuxDriveInfoProvider.cs @@ -0,0 +1,157 @@ +using System; +using System.IO; +using System.Linq; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +using Avalonia.Controls.Platform; +using Tmds.DBus; + +namespace Avalonia.X11.Dbus +{ + public class LinuxMountedDriveInfoProvider : IMountedDriveInfoProvider + { + private IDisposable[] Disposables; + private readonly Connection _sysDbus; + private readonly IObjectManager udisk2Manager; + + public LinuxMountedDriveInfoProvider() + { + this._sysDbus = Connection.System; + this.udisk2Manager = _sysDbus.CreateProxy("org.freedesktop.UDisks2", "/org/freedesktop/UDisks2"); + } + + public ObservableCollection CurrentDrives { get; } = new ObservableCollection(); + + private bool _isMonitoring; + public bool IsMonitoring => _isMonitoring; + + private async void Poll() + { + var newDriveList = new List(); + + var fProcMounts = File.ReadAllLines("/proc/mounts"); + + var managedObj = await udisk2Manager.GetManagedObjectsAsync(); + + var res_drives = managedObj.Where(x => x.Key.ToString().Contains("/org/freedesktop/UDisks2/drives/")) + .Select(x => x.Key); + + var res_blockdev = managedObj.Where(x => x.Key.ToString().Contains("/org/freedesktop/UDisks2/block_devices/")) + .Select(x => x); + + var res_fs = managedObj.Where(x => x.Key.ToString().Contains("system")) + .Select(x => x.Key) + .ToList(); + + foreach (var block in res_blockdev) + { + + var iblock = _sysDbus.CreateProxy("org.freedesktop.UDisks2", block.Key); + var iblockProps = await iblock.GetAllAsync(); + + var block_drive = await iblock.GetDriveAsync(); + if (!res_drives.Contains(block_drive)) continue; + + var drive_key = res_drives.Single(x => x == block_drive); + var drives = _sysDbus.CreateProxy("org.freedesktop.UDisks2", drive_key); + var drivesProps = await drives.GetAllAsync(); + + var devRawBytes = iblockProps.Device.Take(iblockProps.Device.Length - 1).ToArray(); + var devPath = System.Text.Encoding.UTF8.GetString(devRawBytes); + + var blockLabel = iblockProps.IdLabel; + var blockSize = iblockProps.Size; + var driveName = drivesProps.Id; + + // There should be something in udisks2 to + // get this data but I have no idea where. + var mountPoint = fProcMounts.Select(x => x.Split(' ')) + .Where(x => x[0] == devPath) + .Select(x => x[1]) + .SingleOrDefault(); + + if (mountPoint is null) continue; + + var k = new MountedDriveInfo() + { + DriveLabel = blockLabel, + DriveName = driveName, + DriveSizeBytes = blockSize, + DevicePath = devPath, + MountPath = mountPoint + }; + + newDriveList.Add(k); + } + + UpdateCollection(newDriveList); + } + + // https://stackoverflow.com/questions/19558644/update-an-observablecollection-from-another-collection + private void UpdateCollection(IEnumerable newCollection) + { + var newCollectionEnumerator = newCollection.GetEnumerator(); + var collectionEnumerator = CurrentDrives.GetEnumerator(); + + var itemsToDelete = new Collection(); + while (collectionEnumerator.MoveNext()) + { + var item = collectionEnumerator.Current; + + // Store item to delete (we can't do it while parse collection. + if (!newCollection.Contains(item)) + { + itemsToDelete.Add(item); + } + } + + // Handle item to delete. + foreach (var itemToDelete in itemsToDelete) + { + CurrentDrives.Remove(itemToDelete); + } + + var i = 0; + while (newCollectionEnumerator.MoveNext()) + { + var item = newCollectionEnumerator.Current; + + // Handle new item. + if (!CurrentDrives.Contains(item)) + { + CurrentDrives.Insert(i, item); + } + + // Handle existing item, move at the good index. + if (CurrentDrives.Contains(item)) + { + int oldIndex = CurrentDrives.IndexOf(item); + CurrentDrives.Move(oldIndex, i); + } + i++; + } + } + + public async void Start() + { + Disposables = new[] { + await udisk2Manager.WatchInterfacesAddedAsync(delegate { Poll(); }), + await udisk2Manager.WatchInterfacesRemovedAsync( delegate { Poll(); }) + }; + + Poll(); + + _isMonitoring = true; + } + + public void Stop() + { + foreach (var Disposable in Disposables) + Disposable.Dispose(); + + CurrentDrives?.Clear(); + _isMonitoring = false; + } + } +} diff --git a/src/Avalonia.X11/Dbus/UDisks2.cs b/src/Avalonia.X11/Dbus/UDisks2.cs new file mode 100644 index 0000000000..899c5489bb --- /dev/null +++ b/src/Avalonia.X11/Dbus/UDisks2.cs @@ -0,0 +1,1395 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; +using Tmds.DBus; + +[assembly: InternalsVisibleTo(Tmds.DBus.Connection.DynamicAssemblyName)] +namespace Avalonia.X11.Dbus +{ + [DBusInterface("org.freedesktop.DBus.ObjectManager")] + interface IObjectManager : IDBusObject + { + Task>>> GetManagedObjectsAsync(); + Task WatchInterfacesAddedAsync(Action<(ObjectPath objectPath, IDictionary> interfacesAndProperties)> handler, Action onError = null); + Task WatchInterfacesRemovedAsync(Action<(ObjectPath objectPath, string[] interfaces)> handler, Action onError = null); + } + + [DBusInterface("org.freedesktop.UDisks2.Manager")] + interface IManager : IDBusObject + { + Task<(bool available, string)> CanFormatAsync(string Type); + Task<(bool available, ulong, string)> CanResizeAsync(string Type); + Task<(bool available, string)> CanCheckAsync(string Type); + Task<(bool available, string)> CanRepairAsync(string Type); + Task LoopSetupAsync(CloseSafeHandle Fd, IDictionary Options); + Task MDRaidCreateAsync(ObjectPath[] Blocks, string Level, string Name, ulong Chunk, IDictionary Options); + Task EnableModulesAsync(bool Enable); + Task GetBlockDevicesAsync(IDictionary Options); + Task ResolveDeviceAsync(IDictionary Devspec, IDictionary Options); + Task GetAsync(string prop); + Task GetAllAsync(); + Task SetAsync(string prop, object val); + Task WatchPropertiesAsync(Action handler); + } + + [Dictionary] + class ManagerProperties + { + private string _Version = default(string); + public string Version + { + get + { + return _Version; + } + + set + { + _Version = (value); + } + } + + private string[] _SupportedFilesystems = default(string[]); + public string[] SupportedFilesystems + { + get + { + return _SupportedFilesystems; + } + + set + { + _SupportedFilesystems = (value); + } + } + } + + static class ManagerExtensions + { + public static Task GetVersionAsync(this IManager o) => o.GetAsync("Version"); + public static Task GetSupportedFilesystemsAsync(this IManager o) => o.GetAsync("SupportedFilesystems"); + } + + [DBusInterface("org.freedesktop.UDisks2.Drive.Ata")] + interface IAta : IDBusObject + { + Task SmartUpdateAsync(IDictionary Options); + Task<(byte, string, ushort, int, int, int, long, int, IDictionary)[]> SmartGetAttributesAsync(IDictionary Options); + Task SmartSelftestStartAsync(string Type, IDictionary Options); + Task SmartSelftestAbortAsync(IDictionary Options); + Task SmartSetEnabledAsync(bool Value, IDictionary Options); + Task PmGetStateAsync(IDictionary Options); + Task PmStandbyAsync(IDictionary Options); + Task PmWakeupAsync(IDictionary Options); + Task SecurityEraseUnitAsync(IDictionary Options); + Task GetAsync(string prop); + Task GetAllAsync(); + Task SetAsync(string prop, object val); + Task WatchPropertiesAsync(Action handler); + } + + [Dictionary] + class AtaProperties + { + private bool _SmartSupported = default(bool); + public bool SmartSupported + { + get + { + return _SmartSupported; + } + + set + { + _SmartSupported = (value); + } + } + + private bool _SmartEnabled = default(bool); + public bool SmartEnabled + { + get + { + return _SmartEnabled; + } + + set + { + _SmartEnabled = (value); + } + } + + private ulong _SmartUpdated = default(ulong); + public ulong SmartUpdated + { + get + { + return _SmartUpdated; + } + + set + { + _SmartUpdated = (value); + } + } + + private bool _SmartFailing = default(bool); + public bool SmartFailing + { + get + { + return _SmartFailing; + } + + set + { + _SmartFailing = (value); + } + } + + private ulong _SmartPowerOnSeconds = default(ulong); + public ulong SmartPowerOnSeconds + { + get + { + return _SmartPowerOnSeconds; + } + + set + { + _SmartPowerOnSeconds = (value); + } + } + + private double _SmartTemperature = default(double); + public double SmartTemperature + { + get + { + return _SmartTemperature; + } + + set + { + _SmartTemperature = (value); + } + } + + private int _SmartNumAttributesFailing = default(int); + public int SmartNumAttributesFailing + { + get + { + return _SmartNumAttributesFailing; + } + + set + { + _SmartNumAttributesFailing = (value); + } + } + + private int _SmartNumAttributesFailedInThePast = default(int); + public int SmartNumAttributesFailedInThePast + { + get + { + return _SmartNumAttributesFailedInThePast; + } + + set + { + _SmartNumAttributesFailedInThePast = (value); + } + } + + private long _SmartNumBadSectors = default(long); + public long SmartNumBadSectors + { + get + { + return _SmartNumBadSectors; + } + + set + { + _SmartNumBadSectors = (value); + } + } + + private string _SmartSelftestStatus = default(string); + public string SmartSelftestStatus + { + get + { + return _SmartSelftestStatus; + } + + set + { + _SmartSelftestStatus = (value); + } + } + + private int _SmartSelftestPercentRemaining = default(int); + public int SmartSelftestPercentRemaining + { + get + { + return _SmartSelftestPercentRemaining; + } + + set + { + _SmartSelftestPercentRemaining = (value); + } + } + + private bool _PmSupported = default(bool); + public bool PmSupported + { + get + { + return _PmSupported; + } + + set + { + _PmSupported = (value); + } + } + + private bool _PmEnabled = default(bool); + public bool PmEnabled + { + get + { + return _PmEnabled; + } + + set + { + _PmEnabled = (value); + } + } + + private bool _ApmSupported = default(bool); + public bool ApmSupported + { + get + { + return _ApmSupported; + } + + set + { + _ApmSupported = (value); + } + } + + private bool _ApmEnabled = default(bool); + public bool ApmEnabled + { + get + { + return _ApmEnabled; + } + + set + { + _ApmEnabled = (value); + } + } + + private bool _AamSupported = default(bool); + public bool AamSupported + { + get + { + return _AamSupported; + } + + set + { + _AamSupported = (value); + } + } + + private bool _AamEnabled = default(bool); + public bool AamEnabled + { + get + { + return _AamEnabled; + } + + set + { + _AamEnabled = (value); + } + } + + private int _AamVendorRecommendedValue = default(int); + public int AamVendorRecommendedValue + { + get + { + return _AamVendorRecommendedValue; + } + + set + { + _AamVendorRecommendedValue = (value); + } + } + + private bool _WriteCacheSupported = default(bool); + public bool WriteCacheSupported + { + get + { + return _WriteCacheSupported; + } + + set + { + _WriteCacheSupported = (value); + } + } + + private bool _WriteCacheEnabled = default(bool); + public bool WriteCacheEnabled + { + get + { + return _WriteCacheEnabled; + } + + set + { + _WriteCacheEnabled = (value); + } + } + + private bool _ReadLookaheadSupported = default(bool); + public bool ReadLookaheadSupported + { + get + { + return _ReadLookaheadSupported; + } + + set + { + _ReadLookaheadSupported = (value); + } + } + + private bool _ReadLookaheadEnabled = default(bool); + public bool ReadLookaheadEnabled + { + get + { + return _ReadLookaheadEnabled; + } + + set + { + _ReadLookaheadEnabled = (value); + } + } + + private int _SecurityEraseUnitMinutes = default(int); + public int SecurityEraseUnitMinutes + { + get + { + return _SecurityEraseUnitMinutes; + } + + set + { + _SecurityEraseUnitMinutes = (value); + } + } + + private int _SecurityEnhancedEraseUnitMinutes = default(int); + public int SecurityEnhancedEraseUnitMinutes + { + get + { + return _SecurityEnhancedEraseUnitMinutes; + } + + set + { + _SecurityEnhancedEraseUnitMinutes = (value); + } + } + + private bool _SecurityFrozen = default(bool); + public bool SecurityFrozen + { + get + { + return _SecurityFrozen; + } + + set + { + _SecurityFrozen = (value); + } + } + } + + static class AtaExtensions + { + public static Task GetSmartSupportedAsync(this IAta o) => o.GetAsync("SmartSupported"); + public static Task GetSmartEnabledAsync(this IAta o) => o.GetAsync("SmartEnabled"); + public static Task GetSmartUpdatedAsync(this IAta o) => o.GetAsync("SmartUpdated"); + public static Task GetSmartFailingAsync(this IAta o) => o.GetAsync("SmartFailing"); + public static Task GetSmartPowerOnSecondsAsync(this IAta o) => o.GetAsync("SmartPowerOnSeconds"); + public static Task GetSmartTemperatureAsync(this IAta o) => o.GetAsync("SmartTemperature"); + public static Task GetSmartNumAttributesFailingAsync(this IAta o) => o.GetAsync("SmartNumAttributesFailing"); + public static Task GetSmartNumAttributesFailedInThePastAsync(this IAta o) => o.GetAsync("SmartNumAttributesFailedInThePast"); + public static Task GetSmartNumBadSectorsAsync(this IAta o) => o.GetAsync("SmartNumBadSectors"); + public static Task GetSmartSelftestStatusAsync(this IAta o) => o.GetAsync("SmartSelftestStatus"); + public static Task GetSmartSelftestPercentRemainingAsync(this IAta o) => o.GetAsync("SmartSelftestPercentRemaining"); + public static Task GetPmSupportedAsync(this IAta o) => o.GetAsync("PmSupported"); + public static Task GetPmEnabledAsync(this IAta o) => o.GetAsync("PmEnabled"); + public static Task GetApmSupportedAsync(this IAta o) => o.GetAsync("ApmSupported"); + public static Task GetApmEnabledAsync(this IAta o) => o.GetAsync("ApmEnabled"); + public static Task GetAamSupportedAsync(this IAta o) => o.GetAsync("AamSupported"); + public static Task GetAamEnabledAsync(this IAta o) => o.GetAsync("AamEnabled"); + public static Task GetAamVendorRecommendedValueAsync(this IAta o) => o.GetAsync("AamVendorRecommendedValue"); + public static Task GetWriteCacheSupportedAsync(this IAta o) => o.GetAsync("WriteCacheSupported"); + public static Task GetWriteCacheEnabledAsync(this IAta o) => o.GetAsync("WriteCacheEnabled"); + public static Task GetReadLookaheadSupportedAsync(this IAta o) => o.GetAsync("ReadLookaheadSupported"); + public static Task GetReadLookaheadEnabledAsync(this IAta o) => o.GetAsync("ReadLookaheadEnabled"); + public static Task GetSecurityEraseUnitMinutesAsync(this IAta o) => o.GetAsync("SecurityEraseUnitMinutes"); + public static Task GetSecurityEnhancedEraseUnitMinutesAsync(this IAta o) => o.GetAsync("SecurityEnhancedEraseUnitMinutes"); + public static Task GetSecurityFrozenAsync(this IAta o) => o.GetAsync("SecurityFrozen"); + } + + [DBusInterface("org.freedesktop.UDisks2.Drive")] + interface IDrive : IDBusObject + { + Task EjectAsync(IDictionary Options); + Task SetConfigurationAsync(IDictionary Value, IDictionary Options); + Task PowerOffAsync(IDictionary Options); + Task GetAsync(string prop); + Task GetAllAsync(); + Task SetAsync(string prop, object val); + Task WatchPropertiesAsync(Action handler); + } + + [Dictionary] + class DriveProperties + { + private string _Vendor = default(string); + public string Vendor + { + get + { + return _Vendor; + } + + set + { + _Vendor = (value); + } + } + + private string _Model = default(string); + public string Model + { + get + { + return _Model; + } + + set + { + _Model = (value); + } + } + + private string _Revision = default(string); + public string Revision + { + get + { + return _Revision; + } + + set + { + _Revision = (value); + } + } + + private string _Serial = default(string); + public string Serial + { + get + { + return _Serial; + } + + set + { + _Serial = (value); + } + } + + private string _WWN = default(string); + public string WWN + { + get + { + return _WWN; + } + + set + { + _WWN = (value); + } + } + + private string _Id = default(string); + public string Id + { + get + { + return _Id; + } + + set + { + _Id = (value); + } + } + + private IDictionary _Configuration = default(IDictionary); + public IDictionary Configuration + { + get + { + return _Configuration; + } + + set + { + _Configuration = (value); + } + } + + private string _Media = default(string); + public string Media + { + get + { + return _Media; + } + + set + { + _Media = (value); + } + } + + private string[] _MediaCompatibility = default(string[]); + public string[] MediaCompatibility + { + get + { + return _MediaCompatibility; + } + + set + { + _MediaCompatibility = (value); + } + } + + private bool _MediaRemovable = default(bool); + public bool MediaRemovable + { + get + { + return _MediaRemovable; + } + + set + { + _MediaRemovable = (value); + } + } + + private bool _MediaAvailable = default(bool); + public bool MediaAvailable + { + get + { + return _MediaAvailable; + } + + set + { + _MediaAvailable = (value); + } + } + + private bool _MediaChangeDetected = default(bool); + public bool MediaChangeDetected + { + get + { + return _MediaChangeDetected; + } + + set + { + _MediaChangeDetected = (value); + } + } + + private ulong _Size = default(ulong); + public ulong Size + { + get + { + return _Size; + } + + set + { + _Size = (value); + } + } + + private ulong _TimeDetected = default(ulong); + public ulong TimeDetected + { + get + { + return _TimeDetected; + } + + set + { + _TimeDetected = (value); + } + } + + private ulong _TimeMediaDetected = default(ulong); + public ulong TimeMediaDetected + { + get + { + return _TimeMediaDetected; + } + + set + { + _TimeMediaDetected = (value); + } + } + + private bool _Optical = default(bool); + public bool Optical + { + get + { + return _Optical; + } + + set + { + _Optical = (value); + } + } + + private bool _OpticalBlank = default(bool); + public bool OpticalBlank + { + get + { + return _OpticalBlank; + } + + set + { + _OpticalBlank = (value); + } + } + + private uint _OpticalNumTracks = default(uint); + public uint OpticalNumTracks + { + get + { + return _OpticalNumTracks; + } + + set + { + _OpticalNumTracks = (value); + } + } + + private uint _OpticalNumAudioTracks = default(uint); + public uint OpticalNumAudioTracks + { + get + { + return _OpticalNumAudioTracks; + } + + set + { + _OpticalNumAudioTracks = (value); + } + } + + private uint _OpticalNumDataTracks = default(uint); + public uint OpticalNumDataTracks + { + get + { + return _OpticalNumDataTracks; + } + + set + { + _OpticalNumDataTracks = (value); + } + } + + private uint _OpticalNumSessions = default(uint); + public uint OpticalNumSessions + { + get + { + return _OpticalNumSessions; + } + + set + { + _OpticalNumSessions = (value); + } + } + + private int _RotationRate = default(int); + public int RotationRate + { + get + { + return _RotationRate; + } + + set + { + _RotationRate = (value); + } + } + + private string _ConnectionBus = default(string); + public string ConnectionBus + { + get + { + return _ConnectionBus; + } + + set + { + _ConnectionBus = (value); + } + } + + private string _Seat = default(string); + public string Seat + { + get + { + return _Seat; + } + + set + { + _Seat = (value); + } + } + + private bool _Removable = default(bool); + public bool Removable + { + get + { + return _Removable; + } + + set + { + _Removable = (value); + } + } + + private bool _Ejectable = default(bool); + public bool Ejectable + { + get + { + return _Ejectable; + } + + set + { + _Ejectable = (value); + } + } + + private string _SortKey = default(string); + public string SortKey + { + get + { + return _SortKey; + } + + set + { + _SortKey = (value); + } + } + + private bool _CanPowerOff = default(bool); + public bool CanPowerOff + { + get + { + return _CanPowerOff; + } + + set + { + _CanPowerOff = (value); + } + } + + private string _SiblingId = default(string); + public string SiblingId + { + get + { + return _SiblingId; + } + + set + { + _SiblingId = (value); + } + } + } + + static class DriveExtensions + { + public static Task GetVendorAsync(this IDrive o) => o.GetAsync("Vendor"); + public static Task GetModelAsync(this IDrive o) => o.GetAsync("Model"); + public static Task GetRevisionAsync(this IDrive o) => o.GetAsync("Revision"); + public static Task GetSerialAsync(this IDrive o) => o.GetAsync("Serial"); + public static Task GetWWNAsync(this IDrive o) => o.GetAsync("WWN"); + public static Task GetIdAsync(this IDrive o) => o.GetAsync("Id"); + public static Task> GetConfigurationAsync(this IDrive o) => o.GetAsync>("Configuration"); + public static Task GetMediaAsync(this IDrive o) => o.GetAsync("Media"); + public static Task GetMediaCompatibilityAsync(this IDrive o) => o.GetAsync("MediaCompatibility"); + public static Task GetMediaRemovableAsync(this IDrive o) => o.GetAsync("MediaRemovable"); + public static Task GetMediaAvailableAsync(this IDrive o) => o.GetAsync("MediaAvailable"); + public static Task GetMediaChangeDetectedAsync(this IDrive o) => o.GetAsync("MediaChangeDetected"); + public static Task GetSizeAsync(this IDrive o) => o.GetAsync("Size"); + public static Task GetTimeDetectedAsync(this IDrive o) => o.GetAsync("TimeDetected"); + public static Task GetTimeMediaDetectedAsync(this IDrive o) => o.GetAsync("TimeMediaDetected"); + public static Task GetOpticalAsync(this IDrive o) => o.GetAsync("Optical"); + public static Task GetOpticalBlankAsync(this IDrive o) => o.GetAsync("OpticalBlank"); + public static Task GetOpticalNumTracksAsync(this IDrive o) => o.GetAsync("OpticalNumTracks"); + public static Task GetOpticalNumAudioTracksAsync(this IDrive o) => o.GetAsync("OpticalNumAudioTracks"); + public static Task GetOpticalNumDataTracksAsync(this IDrive o) => o.GetAsync("OpticalNumDataTracks"); + public static Task GetOpticalNumSessionsAsync(this IDrive o) => o.GetAsync("OpticalNumSessions"); + public static Task GetRotationRateAsync(this IDrive o) => o.GetAsync("RotationRate"); + public static Task GetConnectionBusAsync(this IDrive o) => o.GetAsync("ConnectionBus"); + public static Task GetSeatAsync(this IDrive o) => o.GetAsync("Seat"); + public static Task GetRemovableAsync(this IDrive o) => o.GetAsync("Removable"); + public static Task GetEjectableAsync(this IDrive o) => o.GetAsync("Ejectable"); + public static Task GetSortKeyAsync(this IDrive o) => o.GetAsync("SortKey"); + public static Task GetCanPowerOffAsync(this IDrive o) => o.GetAsync("CanPowerOff"); + public static Task GetSiblingIdAsync(this IDrive o) => o.GetAsync("SiblingId"); + } + + [DBusInterface("org.freedesktop.UDisks2.Loop")] + interface ILoop : IDBusObject + { + Task DeleteAsync(IDictionary Options); + Task SetAutoclearAsync(bool Value, IDictionary Options); + Task GetAsync(string prop); + Task GetAllAsync(); + Task SetAsync(string prop, object val); + Task WatchPropertiesAsync(Action handler); + } + + [Dictionary] + class LoopProperties + { + private byte[] _BackingFile = default(byte[]); + public byte[] BackingFile + { + get + { + return _BackingFile; + } + + set + { + _BackingFile = (value); + } + } + + private bool _Autoclear = default(bool); + public bool Autoclear + { + get + { + return _Autoclear; + } + + set + { + _Autoclear = (value); + } + } + + private uint _SetupByUID = default(uint); + public uint SetupByUID + { + get + { + return _SetupByUID; + } + + set + { + _SetupByUID = (value); + } + } + } + + static class LoopExtensions + { + public static Task GetBackingFileAsync(this ILoop o) => o.GetAsync("BackingFile"); + public static Task GetAutoclearAsync(this ILoop o) => o.GetAsync("Autoclear"); + public static Task GetSetupByUIDAsync(this ILoop o) => o.GetAsync("SetupByUID"); + } + + [DBusInterface("org.freedesktop.UDisks2.Block")] + interface IBlock : IDBusObject + { + Task AddConfigurationItemAsync((string, IDictionary) Item, IDictionary Options); + Task RemoveConfigurationItemAsync((string, IDictionary) Item, IDictionary Options); + Task UpdateConfigurationItemAsync((string, IDictionary) OldItem, (string, IDictionary) NewItem, IDictionary Options); + Task<(string, IDictionary)[]> GetSecretConfigurationAsync(IDictionary Options); + Task FormatAsync(string Type, IDictionary Options); + Task OpenForBackupAsync(IDictionary Options); + Task OpenForRestoreAsync(IDictionary Options); + Task OpenForBenchmarkAsync(IDictionary Options); + Task OpenDeviceAsync(string Mode, IDictionary Options); + Task RescanAsync(IDictionary Options); + Task GetAsync(string prop); + Task GetAllAsync(); + Task SetAsync(string prop, object val); + Task WatchPropertiesAsync(Action handler); + } + + [Dictionary] + class BlockProperties + { + private byte[] _Device = default(byte[]); + public byte[] Device + { + get + { + return _Device; + } + + set + { + _Device = (value); + } + } + + private byte[] _PreferredDevice = default(byte[]); + public byte[] PreferredDevice + { + get + { + return _PreferredDevice; + } + + set + { + _PreferredDevice = (value); + } + } + + private byte[][] _Symlinks = default(byte[][]); + public byte[][] Symlinks + { + get + { + return _Symlinks; + } + + set + { + _Symlinks = (value); + } + } + + private ulong _DeviceNumber = default(ulong); + public ulong DeviceNumber + { + get + { + return _DeviceNumber; + } + + set + { + _DeviceNumber = (value); + } + } + + private string _Id = default(string); + public string Id + { + get + { + return _Id; + } + + set + { + _Id = (value); + } + } + + private ulong _Size = default(ulong); + public ulong Size + { + get + { + return _Size; + } + + set + { + _Size = (value); + } + } + + private bool _ReadOnly = default(bool); + public bool ReadOnly + { + get + { + return _ReadOnly; + } + + set + { + _ReadOnly = (value); + } + } + + private ObjectPath _Drive = default(ObjectPath); + public ObjectPath Drive + { + get + { + return _Drive; + } + + set + { + _Drive = (value); + } + } + + private ObjectPath _MDRaid = default(ObjectPath); + public ObjectPath MDRaid + { + get + { + return _MDRaid; + } + + set + { + _MDRaid = (value); + } + } + + private ObjectPath _MDRaidMember = default(ObjectPath); + public ObjectPath MDRaidMember + { + get + { + return _MDRaidMember; + } + + set + { + _MDRaidMember = (value); + } + } + + private string _IdUsage = default(string); + public string IdUsage + { + get + { + return _IdUsage; + } + + set + { + _IdUsage = (value); + } + } + + private string _IdType = default(string); + public string IdType + { + get + { + return _IdType; + } + + set + { + _IdType = (value); + } + } + + private string _IdVersion = default(string); + public string IdVersion + { + get + { + return _IdVersion; + } + + set + { + _IdVersion = (value); + } + } + + private string _IdLabel = default(string); + public string IdLabel + { + get + { + return _IdLabel; + } + + set + { + _IdLabel = (value); + } + } + + private string _IdUUID = default(string); + public string IdUUID + { + get + { + return _IdUUID; + } + + set + { + _IdUUID = (value); + } + } + + private (string, IDictionary)[] _Configuration = default((string, IDictionary)[]); + public (string, IDictionary)[] Configuration + { + get + { + return _Configuration; + } + + set + { + _Configuration = (value); + } + } + + private ObjectPath _CryptoBackingDevice = default(ObjectPath); + public ObjectPath CryptoBackingDevice + { + get + { + return _CryptoBackingDevice; + } + + set + { + _CryptoBackingDevice = (value); + } + } + + private bool _HintPartitionable = default(bool); + public bool HintPartitionable + { + get + { + return _HintPartitionable; + } + + set + { + _HintPartitionable = (value); + } + } + + private bool _HintSystem = default(bool); + public bool HintSystem + { + get + { + return _HintSystem; + } + + set + { + _HintSystem = (value); + } + } + + private bool _HintIgnore = default(bool); + public bool HintIgnore + { + get + { + return _HintIgnore; + } + + set + { + _HintIgnore = (value); + } + } + + private bool _HintAuto = default(bool); + public bool HintAuto + { + get + { + return _HintAuto; + } + + set + { + _HintAuto = (value); + } + } + + private string _HintName = default(string); + public string HintName + { + get + { + return _HintName; + } + + set + { + _HintName = (value); + } + } + + private string _HintIconName = default(string); + public string HintIconName + { + get + { + return _HintIconName; + } + + set + { + _HintIconName = (value); + } + } + + private string _HintSymbolicIconName = default(string); + public string HintSymbolicIconName + { + get + { + return _HintSymbolicIconName; + } + + set + { + _HintSymbolicIconName = (value); + } + } + + private string[] _UserspaceMountOptions = default(string[]); + public string[] UserspaceMountOptions + { + get + { + return _UserspaceMountOptions; + } + + set + { + _UserspaceMountOptions = (value); + } + } + } + + static class BlockExtensions + { + public static Task GetDeviceAsync(this IBlock o) => o.GetAsync("Device"); + public static Task GetPreferredDeviceAsync(this IBlock o) => o.GetAsync("PreferredDevice"); + public static Task GetSymlinksAsync(this IBlock o) => o.GetAsync("Symlinks"); + public static Task GetDeviceNumberAsync(this IBlock o) => o.GetAsync("DeviceNumber"); + public static Task GetIdAsync(this IBlock o) => o.GetAsync("Id"); + public static Task GetSizeAsync(this IBlock o) => o.GetAsync("Size"); + public static Task GetReadOnlyAsync(this IBlock o) => o.GetAsync("ReadOnly"); + public static Task GetDriveAsync(this IBlock o) => o.GetAsync("Drive"); + public static Task GetMDRaidAsync(this IBlock o) => o.GetAsync("MDRaid"); + public static Task GetMDRaidMemberAsync(this IBlock o) => o.GetAsync("MDRaidMember"); + public static Task GetIdUsageAsync(this IBlock o) => o.GetAsync("IdUsage"); + public static Task GetIdTypeAsync(this IBlock o) => o.GetAsync("IdType"); + public static Task GetIdVersionAsync(this IBlock o) => o.GetAsync("IdVersion"); + public static Task GetIdLabelAsync(this IBlock o) => o.GetAsync("IdLabel"); + public static Task GetIdUUIDAsync(this IBlock o) => o.GetAsync("IdUUID"); + public static Task<(string, IDictionary)[]> GetConfigurationAsync(this IBlock o) => o.GetAsync<(string, IDictionary)[]>("Configuration"); + public static Task GetCryptoBackingDeviceAsync(this IBlock o) => o.GetAsync("CryptoBackingDevice"); + public static Task GetHintPartitionableAsync(this IBlock o) => o.GetAsync("HintPartitionable"); + public static Task GetHintSystemAsync(this IBlock o) => o.GetAsync("HintSystem"); + public static Task GetHintIgnoreAsync(this IBlock o) => o.GetAsync("HintIgnore"); + public static Task GetHintAutoAsync(this IBlock o) => o.GetAsync("HintAuto"); + public static Task GetHintNameAsync(this IBlock o) => o.GetAsync("HintName"); + public static Task GetHintIconNameAsync(this IBlock o) => o.GetAsync("HintIconName"); + public static Task GetHintSymbolicIconNameAsync(this IBlock o) => o.GetAsync("HintSymbolicIconName"); + public static Task GetUserspaceMountOptionsAsync(this IBlock o) => o.GetAsync("UserspaceMountOptions"); + } +}