ADD: Support UDISKS_PRESENTATION_HIDE, UDISKS_PRESENTATION_NAME, UDISKS_AUTOMOUNT_HINT udev properties (Linux).

ADD: Option to automatically black list unmounted drives and possibility to black list by device id (for example /dev/hda1).
This commit is contained in:
cobines 2012-04-05 01:15:59 +00:00
commit 217dfd68e4
8 changed files with 97 additions and 43 deletions

View file

@ -3115,6 +3115,7 @@ end;
procedure TfrmMain.UpdateDiskCount;
var
I: Integer;
Drive: PDrive;
begin
DrivesList.Free;
DrivesList := TDriveWatcher.GetDrivesList;
@ -3123,7 +3124,10 @@ begin
{ Delete drives that in drives black list }
for I:= DrivesList.Count - 1 downto 0 do
begin
if MatchesMaskList(DrivesList[I]^.Path, gDriveBlackList) then
Drive := DrivesList[I];
if (gDriveBlackListUnmounted and not Drive^.IsMounted) or
MatchesMaskList(Drive^.Path, gDriveBlackList) or
MatchesMaskList(Drive^.DeviceId, gDriveBlackList) then
DrivesList.Remove(I);
end;
@ -4709,7 +4713,7 @@ procedure TfrmMain.SetPanelDrive(aPanel: TFilePanelSelect; Drive: PDrive);
var
aFileView, OtherFileView: TFileView;
begin
if IsAvailable(Drive, True) then
if IsAvailable(Drive, Drive^.AutoMount) then
begin
case aPanel of
fpLeft:
@ -4784,4 +4788,4 @@ initialization
TFormCommands.RegisterCommandsForm(TfrmMain, HotkeysCategory, @rsHotkeyCategoryMain);
end.

View file

@ -1,9 +1,9 @@
inherited frmOptionsBehavior: TfrmOptionsBehavior
Height = 227
Height = 276
Width = 666
ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6
ClientHeight = 227
ClientHeight = 276
ClientWidth = 666
object gbMisc1: TGroupBox[0]
AnchorSideLeft.Control = Owner
@ -11,14 +11,14 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 121
Height = 130
Top = 6
Width = 654
Anchors = [akTop, akLeft, akRight]
AutoSize = True
ChildSizing.LeftRightSpacing = 8
ChildSizing.TopBottomSpacing = 6
ClientHeight = 99
ClientHeight = 105
ClientWidth = 650
TabOrder = 0
object cbOnlyOnce: TCheckBox
@ -27,7 +27,7 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
AnchorSideRight.Control = gbMisc1
AnchorSideRight.Side = asrBottom
Left = 8
Height = 25
Height = 27
Top = 6
Width = 634
Anchors = [akTop, akLeft, akRight]
@ -42,8 +42,8 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
AnchorSideRight.Control = gbMisc1
AnchorSideRight.Side = asrBottom
Left = 8
Height = 25
Top = 37
Height = 27
Top = 39
Width = 634
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -57,8 +57,8 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
AnchorSideRight.Control = gbMisc1
AnchorSideRight.Side = asrBottom
Left = 8
Height = 25
Top = 68
Height = 27
Top = 72
Width = 634
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
@ -74,12 +74,12 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 6
Height = 89
Top = 127
Height = 121
Top = 136
Width = 654
Anchors = [akTop, akLeft, akRight]
AutoSize = True
ClientHeight = 67
ClientHeight = 96
ClientWidth = 650
TabOrder = 1
object lblDrivesBlackList: TLabel
@ -88,7 +88,7 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
Left = 8
Height = 22
Top = 2
Width = 102
Width = 115
BorderSpacing.Left = 8
BorderSpacing.Top = 2
Caption = 'Drives blacklist'
@ -101,17 +101,29 @@ inherited frmOptionsBehavior: TfrmOptionsBehavior
AnchorSideRight.Control = gbMisc2
AnchorSideRight.Side = asrBottom
Left = 8
Height = 29
Height = 31
Hint = 'Here you can enter one or more drives or mount points, separated by ";".'
Top = 30
Width = 634
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
BorderSpacing.Bottom = 4
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object cbBlacklistUnmountedDevices: TCheckBox
AnchorSideLeft.Control = edtDrivesBlackList
AnchorSideTop.Control = edtDrivesBlackList
AnchorSideTop.Side = asrBottom
Left = 8
Height = 27
Top = 65
Width = 314
BorderSpacing.Bottom = 4
Caption = 'Automatically hide unmounted devices'
TabOrder = 1
end
end
end
end

View file

@ -1,5 +1,6 @@
TFRMOPTIONSBEHAVIOR.CBONLYONCE.CAPTION=Allow only one copy of DC at a time
TFRMOPTIONSBEHAVIOR.CBMINIMIZETOTRAY.CAPTION=Mo&ve icon to system tray when minimized
TFRMOPTIONSBEHAVIOR.CBALWAYSSHOWTRAYICON.CAPTION=Always show tray icon
TFRMOPTIONSBEHAVIOR.LBLDRIVESBLACKLIST.CAPTION=Drives blacklist
TFRMOPTIONSBEHAVIOR.EDTDRIVESBLACKLIST.HINT=Here you can enter one or more drives or mount points, separated by ";".
TFRMOPTIONSBEHAVIOR.CBONLYONCE.CAPTION=Allow only one copy of DC at a time
TFRMOPTIONSBEHAVIOR.CBMINIMIZETOTRAY.CAPTION=Mo&ve icon to system tray when minimized
TFRMOPTIONSBEHAVIOR.CBALWAYSSHOWTRAYICON.CAPTION=Always show tray icon
TFRMOPTIONSBEHAVIOR.LBLDRIVESBLACKLIST.CAPTION=Drives blacklist
TFRMOPTIONSBEHAVIOR.EDTDRIVESBLACKLIST.HINT=Here you can enter one or more drives or mount points, separated by ";".
TFRMOPTIONSBEHAVIOR.CBBLACKLISTUNMOUNTEDDEVICES.CAPTION=Automatically hide unmounted devices

View file

@ -38,6 +38,7 @@ type
cbAlwaysShowTrayIcon: TCheckBox;
cbMinimizeToTray: TCheckBox;
cbOnlyOnce: TCheckBox;
cbBlacklistUnmountedDevices: TCheckBox;
edtDrivesBlackList: TEdit;
gbMisc1: TGroupBox;
gbMisc2: TGroupBox;
@ -83,6 +84,7 @@ begin
cbMinimizeToTray.Enabled:= not gAlwaysShowTrayIcon;
cbAlwaysShowTrayIcon.Checked:= gAlwaysShowTrayIcon;
edtDrivesBlackList.Text:= gDriveBlackList;
cbBlacklistUnmountedDevices.Checked:= gDriveBlackListUnmounted;
end;
function TfrmOptionsBehavior.Save: TOptionsEditorSaveFlags;
@ -93,6 +95,7 @@ begin
gMinimizeToTray:= cbMinimizeToTray.Checked;
gAlwaysShowTrayIcon:= cbAlwaysShowTrayIcon.Checked;
gDriveBlackList:= edtDrivesBlackList.Text;
gDriveBlackListUnmounted:= cbBlacklistUnmountedDevices.Checked;
end;
end.

View file

@ -314,21 +314,28 @@ begin
with DeviceInfo do
begin
Drive^.DeviceId := DeviceFile;
Drive^.DisplayName := DevicePresentationName;
if DeviceIsMounted and (Length(DeviceMountPaths) > 0) then
begin
Drive^.Path := DeviceMountPaths[0];
if Drive^.Path <> PathDelim then
Drive^.DisplayName := ExtractFileName(Drive^.Path)
else
Drive^.DisplayName := PathDelim;
if Drive^.DisplayName = EmptyStr then
begin
if Drive^.Path <> PathDelim then
Drive^.DisplayName := ExtractFileName(Drive^.Path)
else
Drive^.DisplayName := PathDelim;
end;
end
else
begin
Drive^.Path := EmptyStr;
if (IdLabel <> EmptyStr) then
Drive^.DisplayName := IdLabel
else
Drive^.DisplayName := ExtractFileName(DeviceFile);
if Drive^.DisplayName = EmptyStr then
begin
if (IdLabel <> EmptyStr) then
Drive^.DisplayName := IdLabel
else
Drive^.DisplayName := ExtractFileName(DeviceFile);
end;
end;
Drive^.DriveLabel := IdLabel;
Drive^.FileSystem := IdType;
@ -369,6 +376,7 @@ begin
Drive^.IsMediaEjectable := DeviceIsDrive and DriveIsMediaEjectable;
Drive^.IsMediaRemovable := DeviceIsRemovable;
Drive^.IsMounted := DeviceIsMounted;
Drive^.AutoMount := (DeviceAutomountHint = EmptyStr) or (DeviceAutomountHint = 'always');
end;
end;
{$ENDIF}
@ -434,6 +442,7 @@ begin
IsMediaEjectable := False;
IsMediaRemovable := False;
IsMounted := True;
AutoMount := True;
case WinDriveType of
DRIVE_REMOVABLE:
@ -587,6 +596,7 @@ begin
IsMediaEjectable:= False;
IsMediaRemovable:= False;
IsMounted:= True;
AutoMount:= True;
end;
Result.Add(Drive);
//---------------------------------------------------------------
@ -815,12 +825,19 @@ begin
if CanAddDevice(DeviceFile, MountPoint) and
UDisksGetDeviceInfo(UDisksDeviceObject, UDisksDevices, UDisksDevice) then
begin
UDisksDeviceToDrive(UDisksDevices, UDisksDevice, Drive);
Drive^.Path := MountPoint;
if MountPoint <> PathDelim then
Drive^.DisplayName := ExtractFileName(MountPoint)
else
Drive^.DisplayName := PathDelim;
if not UDisksDevice.DevicePresentationHide then
begin
UDisksDeviceToDrive(UDisksDevices, UDisksDevice, Drive);
Drive^.Path := MountPoint;
Drive^.DisplayName := UDisksDevice.DevicePresentationName;
if Drive^.DisplayName = EmptyStr then
begin
if MountPoint <> PathDelim then
Drive^.DisplayName := ExtractFileName(MountPoint)
else
Drive^.DisplayName := PathDelim;
end;
end;
end
// Even if mounted device is not listed by UDisks add it anyway the standard way.
else if I = 2 then // MntEntFileList[2] = _PATH_MOUNTED
@ -869,6 +886,7 @@ begin
// If drive from /etc/mtab then it is mounted
// else it will be checked via mtab below
IsMounted:= (MntEntFileList[I] = _PATH_MOUNTED);
AutoMount:= True;
end;
end
// Mark drive as mounted if found in mtab.
@ -913,7 +931,8 @@ begin
// Add devices reported as "filesystem".
if ((UDisksDevices[i].DeviceIsDrive and not UDisksDevices[i].DeviceIsPartitionTable) or
(UDisksDevices[i].IdUsage = 'filesystem')) and
(StrBegins(UDisksDevices[i].DeviceFile, '/dev/loop') = False) then
(StrBegins(UDisksDevices[i].DeviceFile, '/dev/loop') = False) and
(not UDisksDevices[i].DevicePresentationHide) then
begin
if (AddedDevices.IndexOf(UDisksDevices[i].DeviceFile) < 0) and
(not IsDeviceMountedAtRoot(UDisksDevices[i])) then
@ -1028,6 +1047,7 @@ begin
IsMediaEjectable := false;
IsMediaRemovable := false;
IsMounted := false;
AutoMount := true;
end; { with }
fstab := getfsent();
@ -1083,6 +1103,7 @@ begin
IsMediaEjectable := false;
IsMediaRemovable := false;
IsMounted := true;
AutoMount := true;
end; { with }
end; { for }
end;
@ -1243,4 +1264,4 @@ end;
{$ENDIF}
end.

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
Interface to UDisks service via DBUS.
Copyright (C) 2010 Przemyslaw Nagay (cobines@gmail.com)
Copyright (C) 2010-2012 Przemyslaw Nagay (cobines@gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -45,6 +45,10 @@ type
DeviceIsMediaAvailable,
DriveIsMediaEjectable: Boolean;
DeviceMountPaths: TStringArray;
DevicePresentationHide: Boolean;
DevicePresentationName: UTF8String;
DevicePresentationIconName: UTF8String;
DeviceAutomountHint: UTF8String; // Whether automatically mount or not
DriveConnectionInterface,
DriveMedia: UTF8String; // Type of media currently in the drive.
DriveMediaCompatibility: TStringArray; // Possible media types.
@ -464,7 +468,11 @@ begin
GetObjectProperty(ObjectPath, 'DeviceIsMounted', DeviceIsMounted) and
GetObjectProperty(ObjectPath, 'DeviceIsRemovable', DeviceIsRemovable) and
GetObjectProperty(ObjectPath, 'DeviceIsOpticalDisc', DeviceIsOpticalDisc) and
GetObjectProperty(ObjectPath, 'DeviceIsMediaAvailable', DeviceIsMediaAvailable);
GetObjectProperty(ObjectPath, 'DeviceIsMediaAvailable', DeviceIsMediaAvailable) and
GetObjectProperty(ObjectPath, 'DevicePresentationHide', DevicePresentationHide) and
GetObjectProperty(ObjectPath, 'DevicePresentationName', DevicePresentationName) and
GetObjectProperty(ObjectPath, 'DevicePresentationIconName', DevicePresentationIconName) and
GetObjectProperty(ObjectPath, 'DeviceAutomountHint', DeviceAutomountHint);
if Result and DeviceIsPartition then
Result := GetObjectProperty(ObjectPath, 'PartitionSlave', PartitionSlave, True);

View file

@ -56,6 +56,7 @@ type
IsMediaEjectable: Boolean; //<en Can eject media by a command.
IsMediaRemovable: Boolean; //<en If the drive has removable media.
IsMounted: Boolean; //<en Is the drive mounted.
AutoMount: Boolean; //<en Should the drive be automounted
end;
PDrive = ^TDrive;

View file

@ -192,6 +192,7 @@ var
gShortFileSizeFormat:Boolean;
gDateTimeFormat : String;
gDriveBlackList: String;
gDriveBlackListUnmounted: Boolean; // Automatically black list unmounted devices
gListFilesInThread: Boolean;
gLoadIconsSeparately: Boolean;
gDelayLoadingTabs: Boolean;
@ -733,6 +734,7 @@ begin
gDelayLoadingTabs := True;
gHighlightUpdatedFiles := True;
gDriveBlackList := '';
gDriveBlackListUnmounted := False;
{ Tools page }
SetDefaultExternalTool(gExternalTools[etViewer]);
@ -1586,6 +1588,7 @@ begin
gDelayLoadingTabs := GetValue(Node, 'DelayLoadingTabs', gDelayLoadingTabs);
gHighlightUpdatedFiles := GetValue(Node, 'HighlightUpdatedFiles', gHighlightUpdatedFiles);
gDriveBlackList := GetValue(Node, 'DriveBlackList', gDriveBlackList);
gDriveBlackListUnmounted := GetValue(Node, 'DriveBlackListUnmounted', gDriveBlackListUnmounted);
end;
{ Tools page }
@ -1940,6 +1943,7 @@ begin
SetValue(Node, 'DelayLoadingTabs', gDelayLoadingTabs);
SetValue(Node, 'HighlightUpdatedFiles', gHighlightUpdatedFiles);
SetValue(Node, 'DriveBlackList', gDriveBlackList);
SetValue(Node, 'DriveBlackListUnmounted', gDriveBlackListUnmounted);
{ Tools page }
SetExtTool(gConfig.FindNode(Root, 'Tools/Viewer', True), gExternalTools[etViewer]);
@ -2189,4 +2193,4 @@ initialization
finalization
DestroyGlobs;
end.
end.