mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
More queries/commands
This commit is contained in:
33
ModernKeePass.Infrastructure/KeePass/EntryFieldMapper.cs
Normal file
33
ModernKeePass.Infrastructure/KeePass/EntryFieldMapper.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using ModernKeePass.Domain.Enums;
|
||||
using ModernKeePassLib;
|
||||
|
||||
namespace ModernKeePass.Infrastructure.KeePass
|
||||
{
|
||||
public static class EntryFieldMapper
|
||||
{
|
||||
public static string MapPwDefsToField(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case PwDefs.TitleField: return EntryFieldName.Title;
|
||||
case PwDefs.UserNameField: return EntryFieldName.UserName;
|
||||
case PwDefs.PasswordField: return EntryFieldName.Password;
|
||||
case PwDefs.NotesField: return EntryFieldName.Notes;
|
||||
case PwDefs.UrlField: return EntryFieldName.Url;
|
||||
default: return value;
|
||||
}
|
||||
}
|
||||
public static string MapFieldToPwDef(string value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case EntryFieldName.Title: return PwDefs.TitleField;
|
||||
case EntryFieldName.UserName: return PwDefs.UserNameField;
|
||||
case EntryFieldName.Password: return PwDefs.PasswordField;
|
||||
case EntryFieldName.Notes: return PwDefs.NotesField;
|
||||
case EntryFieldName.Url: return PwDefs.UrlField;
|
||||
default: return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@ using ModernKeePassLib;
|
||||
using ModernKeePassLib.Cryptography.KeyDerivation;
|
||||
using ModernKeePassLib.Interfaces;
|
||||
using ModernKeePassLib.Keys;
|
||||
using ModernKeePassLib.Security;
|
||||
using ModernKeePassLib.Serialization;
|
||||
using ModernKeePassLib.Utility;
|
||||
|
||||
@@ -196,12 +197,15 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
});
|
||||
}
|
||||
|
||||
public Task UpdateEntry(string entry)
|
||||
public void UpdateEntry(string entryId, string fieldName, string fieldValue)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var pwEntry = _pwDatabase.RootGroup.FindEntry(BuildIdFromString(entryId), true);
|
||||
pwEntry.Touch(true);
|
||||
pwEntry.CreateBackup(null);
|
||||
pwEntry.Strings.Set(EntryFieldMapper.MapFieldToPwDef(fieldName), new ProtectedString(true, fieldValue));
|
||||
}
|
||||
|
||||
public Task UpdateGroup(string group)
|
||||
public void UpdateGroup(string group)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
Reference in New Issue
Block a user