Clipboard action now sets an expiration timer

WIP Max History count (back-end done, front-end todo)
This commit is contained in:
Geoffroy BONNEVILLE
2020-05-12 18:43:37 +02:00
parent f8f7c19f65
commit 7ac1595aaa
11 changed files with 64 additions and 9 deletions

View File

@@ -106,6 +106,7 @@
<Compile Include="Parameters\Commands\SetCipher\SetCipherCommand.cs" />
<Compile Include="Parameters\Commands\SetCompression\SetCompressionCommand.cs" />
<Compile Include="Parameters\Commands\SetHasRecycleBin\SetHasRecycleBinCommand.cs" />
<Compile Include="Parameters\Commands\SetMaxHistoryCount\SetHistoryCountCommand.cs" />
<Compile Include="Parameters\Commands\SetKeyDerivation\SetKeyDerivationCommand.cs" />
<Compile Include="Parameters\Commands\SetRecycleBin\SetRecycleBinCommand.cs" />
<Compile Include="Parameters\Models\CipherVm.cs" />

View File

@@ -22,6 +22,7 @@ namespace ModernKeePass.Application.Common.Interfaces
string FileAccessToken { get; set; }
int Size { get; set; }
bool IsDirty { get; set; }
int MaxHistoryCount { get; set; }
Task Open(byte[] file, Credentials credentials);
Task ReOpen(byte[] file);

View File

@@ -12,5 +12,6 @@
public string KeyDerivationId { get; set; }
public int Size { get; internal set; }
public bool IsDirty { get; internal set; }
public int MaxHistoryCount { get; set; }
}
}

View File

@@ -33,6 +33,7 @@ namespace ModernKeePass.Application.Database.Queries.GetDatabase
database.KeyDerivationId = _databaseProxy.KeyDerivationId;
database.Size = _databaseProxy.Size;
database.IsDirty = _databaseProxy.IsDirty;
database.MaxHistoryCount = _databaseProxy.MaxHistoryCount;
}
return database;
}

View File

@@ -0,0 +1,27 @@
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Parameters.Commands.SetMaxHistoryCount
{
public class SetMaxHistoryCountCommand : IRequest
{
public int MaxHistoryCount { get; set; }
public class SetMaxHistoryCountCommandHandler : IRequestHandler<SetMaxHistoryCountCommand>
{
private readonly IDatabaseProxy _database;
public SetMaxHistoryCountCommandHandler(IDatabaseProxy database)
{
_database = database;
}
public void Handle(SetMaxHistoryCountCommand message)
{
if (_database.IsOpen) _database.MaxHistoryCount = message.MaxHistoryCount;
else throw new DatabaseClosedException();
}
}
}
}

View File

@@ -40,6 +40,12 @@ namespace ModernKeePass.Infrastructure.KeePass
public int Size { get; set; }
public bool IsDirty { get; set; }
public int MaxHistoryCount
{
get { return _pwDatabase.HistoryMaxItems; }
set { _pwDatabase.HistoryMaxItems = value; }
}
// Settings
public bool IsRecycleBinEnabled
{

View File

@@ -166,14 +166,6 @@ namespace ModernKeePass
#if DEBUG
_notification.Show("App resumed", "Nothing to do, no previous database opened");
#endif
}
catch (Exception ex)
{
_hockey.TrackException(ex);
_hockey.Flush();
}
finally
{
_navigation.NavigateTo(Constants.Navigation.MainPage);
}
}

View File

@@ -1,5 +1,7 @@
Support for additional fields
Support for attachments
Add an expiration timer for clipboard data
Ability to manually reorder groups
Ability to set max history count
Design changes
Update to KeePassLib version 2.45

View File

@@ -1,5 +1,7 @@
Ajout des champs additionnels
Ajout des pi<70>ces-jointes
Ajout d'une expiration du presse papier
Possibilite de reorganiser les groupes manuellement
Possibilite de parametrer le nombre max d'historique
Quelques changements de design
Mise a jour de la KeePassLib version 2.45

View File

@@ -1,11 +1,17 @@
using Windows.ApplicationModel.DataTransfer;
using System;
using Windows.ApplicationModel.DataTransfer;
using Windows.UI.Xaml;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Xaml.Interactivity;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Common;
namespace ModernKeePass.Actions
{
public class ClipboardAction : DependencyObject, IAction
{
private DispatcherTimer _dispatcher;
public string Text
{
get { return (string)GetValue(TextProperty); }
@@ -18,10 +24,24 @@ namespace ModernKeePass.Actions
public object Execute(object sender, object parameter)
{
if (string.IsNullOrEmpty(Text)) return null;
var settings = App.Services.GetRequiredService<ISettingsProxy>();
_dispatcher = new DispatcherTimer {Interval = TimeSpan.FromSeconds(settings.GetSetting(Constants.Settings.ClipboardTimeout, 10))};
_dispatcher.Tick += Dispatcher_Tick;
var dataPackage = new DataPackage { RequestedOperation = DataPackageOperation.Copy };
dataPackage.SetText(Text);
Clipboard.SetContent(dataPackage);
_dispatcher.Start();
return null;
}
private void Dispatcher_Tick(object sender, object e)
{
Clipboard.SetContent(null);
_dispatcher.Stop();
}
}
}

View File

@@ -19,6 +19,8 @@
public static string SaveSuspend => nameof(SaveSuspend);
public static string Sample => nameof(Sample);
public static string DefaultFileFormat => nameof(DefaultFileFormat);
public static string ClipboardTimeout => nameof(ClipboardTimeout);
public static string HistoryMaxCount => nameof(HistoryMaxCount);
}
}
}