Compare commits

..

1 Commits

Author SHA1 Message Date
Philipp Crocoll
c934755e1c make settings field for TrayTotp style otp entries optional
closes https://github.com/PhilippC/keepass2android/issues/2458
2024-01-03 08:06:20 +01:00
6 changed files with 16 additions and 26 deletions

View File

@@ -185,7 +185,7 @@ namespace KeePassLib.Serialization
byte[] pbFile = StrUtil.Utf8.GetBytes(sb.ToString());
s = IOConnection.OpenWrite(iocLockFile);
if(s == null) throw new IOException(UrlUtil.GetFileName(iocLockFile.Path));
if(s == null) throw new IOException(iocLockFile.GetDisplayName());
s.Write(pbFile, 0, pbFile.Length);
}
finally { if(s != null) s.Close(); }
@@ -205,7 +205,8 @@ namespace KeePassLib.Serialization
if(lfiEx != null)
{
m_iocLockFile = null; // Otherwise Dispose deletes the existing one
throw new FileLockException(UrlUtil.GetFileName(iocBaseFile.Path), lfiEx.GetOwner());
throw new FileLockException(iocBaseFile.GetDisplayName(),
lfiEx.GetOwner());
}
LockFileInfo.Create(m_iocLockFile);

View File

@@ -28,7 +28,6 @@ using System.Diagnostics;
using KeePassLib.Resources;
using KeePassLib.Serialization;
using Android.Webkit;
namespace KeePassLib.Utility
{
@@ -412,7 +411,7 @@ Clipboard.SetText(ObjectsToMessage(vLines, true));*/
public static void ShowLoadWarning(IOConnectionInfo ioConnection, Exception ex)
{
if (ioConnection != null)
ShowLoadWarning(UrlUtil.GetFileName(ioConnection.Path), ex, false);
ShowLoadWarning(ioConnection.GetDisplayName(), ex, false);
else ShowWarning(ex);
}
@@ -445,7 +444,7 @@ Clipboard.SetText(ObjectsToMessage(vLines, true));*/
bool bCorruptionWarning)
{
if (ioConnection != null)
ShowSaveWarning(UrlUtil.GetFileName(ioConnection.Path), ex, bCorruptionWarning);
ShowSaveWarning(ioConnection.GetDisplayName(), ex, bCorruptionWarning);
else ShowWarning(ex);
}

View File

@@ -124,7 +124,7 @@ namespace keepass2android.Io
&& File.Exists(VersionFilePath(ioc))
&& File.Exists(BaseVersionFilePath(ioc));
Kp2aLog.Log(GetDisplayName(ioc) + " isCached = " + result);
Kp2aLog.Log(ioc.GetDisplayName() + " isCached = " + result);
return result;
}
@@ -598,14 +598,13 @@ namespace keepass2android.Io
public string GetBaseVersionHash(IOConnectionInfo ioc)
{
string hash = File.ReadAllText(BaseVersionFilePath(ioc));
Kp2aLog.Log(GetDisplayName(ioc) + " baseVersionHash = " + hash);
Kp2aLog.Log(ioc.GetDisplayName() + " baseVersionHash = " + hash);
return hash;
}
public string GetLocalVersionHash(IOConnectionInfo ioc)
{
string hash = File.ReadAllText(VersionFilePath(ioc));
Kp2aLog.Log(GetDisplayName(ioc) + " localVersionHash = " + hash);
Kp2aLog.Log(ioc.GetDisplayName() + " localVersionHash = " + hash);
return hash;
}
public bool HasLocalChanges(IOConnectionInfo ioc)

View File

@@ -348,7 +348,7 @@ namespace keepass2android.Io
}
catch (Exception e)
{
throw new Exception("Error finding " + filename + " in " + GetDisplayName(folderPath), e);
throw new Exception("Error finding " + filename + " in " + folderPath.GetDisplayName(), e);
}
}

View File

@@ -31,17 +31,8 @@ namespace PluginTOTP
_muteWarnings = muteWarnings;
}
/// <summary>
/// Check if specified Entry contains Settings that are not null.
/// </summary>
internal bool SettingsCheck(IDictionary<string, string> entryFields)
{
string settings;
entryFields.TryGetValue(SettingsFieldName, out settings);
return !String.IsNullOrEmpty(settings);
}
internal bool SeedCheck(IDictionary<string, string> entryFields)
internal bool HasSeed(IDictionary<string, string> entryFields)
{
string seed;
entryFields.TryGetValue(SeedFieldName, out seed);
@@ -100,15 +91,15 @@ namespace PluginTOTP
}
private string[] SettingsGet(IDictionary<string, string> entryFields)
{
return entryFields[SettingsFieldName].Split(';');
}
{
return entryFields.TryGetValue(SettingsFieldName, out var settings) ? settings.Split(';') : new[] { "30", "6" };
}
public TotpData GetTotpData(IDictionary<string, string> entryFields)
{
TotpData res = new TotpData();
if (SettingsCheck(entryFields) && SeedCheck(entryFields))
if (HasSeed(entryFields))
{
bool ValidInterval; bool ValidLength; bool ValidUrl;
if (SettingsValidate(entryFields, out ValidInterval, out ValidLength, out ValidUrl))

View File

@@ -129,7 +129,7 @@ namespace OtpKeyProv
if(!OtpInfo.Save(auxFileIoc, otpInfo))
{
MessageService.ShowWarning("Failed to save auxiliary OTP info file:",
UrlUtil.GetFileName(auxFileIoc.Path));
auxFileIoc.GetDisplayName());
return false;
}