update to 2.24
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
KeePass Password Safe - The Open-Source Password Manager
|
||||
Copyright (C) 2003-2012 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
Copyright (C) 2003-2013 Dominik Reichl <dominik.reichl@t-online.de>
|
||||
|
||||
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
|
||||
@@ -779,12 +779,12 @@ namespace KeePassLib
|
||||
|
||||
bool bOrgBackup = !bEquals;
|
||||
if(mm != PwMergeMethod.OverwriteExisting)
|
||||
bOrgBackup &= (pe.LastModificationTime > peLocal.LastModificationTime);
|
||||
bOrgBackup &= (TimeUtil.CompareLastMod(pe, peLocal, true) > 0);
|
||||
bOrgBackup &= !pe.HasBackupOfData(peLocal, false, true);
|
||||
if(bOrgBackup) peLocal.CreateBackup(null); // Maintain at end
|
||||
|
||||
bool bSrcBackup = !bEquals && (mm != PwMergeMethod.OverwriteExisting);
|
||||
bSrcBackup &= (peLocal.LastModificationTime > pe.LastModificationTime);
|
||||
bSrcBackup &= (TimeUtil.CompareLastMod(peLocal, pe, true) > 0);
|
||||
bSrcBackup &= !peLocal.HasBackupOfData(pe, false, true);
|
||||
if(bSrcBackup) pe.CreateBackup(null); // Maintain at end
|
||||
|
||||
@@ -870,9 +870,12 @@ namespace KeePassLib
|
||||
|
||||
foreach(PwDeletedObject pdo in listDelObjects)
|
||||
{
|
||||
if(pg.Uuid.EqualsValue(pdo.Uuid))
|
||||
if(pg.LastModificationTime < pdo.DeletionTime)
|
||||
if(pg.Uuid.Equals(pdo.Uuid))
|
||||
{
|
||||
if(TimeUtil.Compare(pg.LastModificationTime,
|
||||
pdo.DeletionTime, true) < 0)
|
||||
listGroupsToDelete.AddLast(pg);
|
||||
}
|
||||
}
|
||||
|
||||
return ((m_slStatus != null) ? m_slStatus.ContinueWork() : true);
|
||||
@@ -882,9 +885,12 @@ namespace KeePassLib
|
||||
{
|
||||
foreach(PwDeletedObject pdo in listDelObjects)
|
||||
{
|
||||
if(pe.Uuid.EqualsValue(pdo.Uuid))
|
||||
if(pe.LastModificationTime < pdo.DeletionTime)
|
||||
if(pe.Uuid.Equals(pdo.Uuid))
|
||||
{
|
||||
if(TimeUtil.Compare(pe.LastModificationTime,
|
||||
pdo.DeletionTime, true) < 0)
|
||||
listEntriesToDelete.AddLast(pe);
|
||||
}
|
||||
}
|
||||
|
||||
return ((m_slStatus != null) ? m_slStatus.ContinueWork() : true);
|
||||
@@ -905,7 +911,7 @@ namespace KeePassLib
|
||||
|
||||
foreach(PwDeletedObject pdoLocal in m_vDeletedObjects)
|
||||
{
|
||||
if(pdoNew.Uuid.EqualsValue(pdoLocal.Uuid))
|
||||
if(pdoNew.Uuid.Equals(pdoLocal.Uuid))
|
||||
{
|
||||
bCopy = false;
|
||||
|
||||
@@ -939,7 +945,7 @@ namespace KeePassLib
|
||||
|
||||
PwGroup pgOrgParent = ptOrg.ParentGroup;
|
||||
PwGroup pgSrcParent = ptSrc.ParentGroup;
|
||||
if(pgOrgParent.Uuid.EqualsValue(pgSrcParent.Uuid))
|
||||
if(pgOrgParent.Uuid.Equals(pgSrcParent.Uuid))
|
||||
{
|
||||
pg.LocationChanged = ((ptSrc.LocationChanged > ptOrg.LocationChanged) ?
|
||||
ptSrc.LocationChanged : ptOrg.LocationChanged);
|
||||
@@ -959,7 +965,7 @@ namespace KeePassLib
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(pg.ParentGroup.Uuid.EqualsValue(pgOrgParent.Uuid));
|
||||
Debug.Assert(pg.ParentGroup.Uuid.Equals(pgOrgParent.Uuid));
|
||||
Debug.Assert(pg.LocationChanged == ptOrg.LocationChanged);
|
||||
}
|
||||
}
|
||||
@@ -985,7 +991,7 @@ namespace KeePassLib
|
||||
|
||||
PwGroup pgOrg = ptOrg.ParentGroup;
|
||||
PwGroup pgSrc = ptSrc.ParentGroup;
|
||||
if(pgOrg.Uuid.EqualsValue(pgSrc.Uuid))
|
||||
if(pgOrg.Uuid.Equals(pgSrc.Uuid))
|
||||
{
|
||||
pe.LocationChanged = ((ptSrc.LocationChanged > ptOrg.LocationChanged) ?
|
||||
ptSrc.LocationChanged : ptOrg.LocationChanged);
|
||||
@@ -1003,7 +1009,7 @@ namespace KeePassLib
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(pe.ParentGroup.Uuid.EqualsValue(pgOrg.Uuid));
|
||||
Debug.Assert(pe.ParentGroup.Uuid.Equals(pgOrg.Uuid));
|
||||
Debug.Assert(pe.LocationChanged == ptOrg.LocationChanged);
|
||||
}
|
||||
}
|
||||
@@ -1080,7 +1086,7 @@ namespace KeePassLib
|
||||
bool bAdded = false;
|
||||
foreach(PwUuid puBefore in qRelBefore)
|
||||
{
|
||||
if(puBefore.EqualsValue(pt.Uuid))
|
||||
if(puBefore.Equals(pt.Uuid))
|
||||
{
|
||||
qBefore.Enqueue(pt);
|
||||
bAdded = true;
|
||||
@@ -1091,7 +1097,7 @@ namespace KeePassLib
|
||||
|
||||
foreach(PwUuid puAfter in qRelAfter)
|
||||
{
|
||||
if(puAfter.EqualsValue(pt.Uuid))
|
||||
if(puAfter.Equals(pt.Uuid))
|
||||
{
|
||||
qAfter.Enqueue(pt);
|
||||
bAdded = true;
|
||||
@@ -1186,7 +1192,7 @@ namespace KeePassLib
|
||||
{
|
||||
PwUuid pw = vItems[i].Uuid;
|
||||
|
||||
if(pw.EqualsValue(pwPivot)) bBefore = false;
|
||||
if(pw.Equals(pwPivot)) bBefore = false;
|
||||
else if(bBefore) qBefore.Enqueue(pw);
|
||||
else qAfter.Enqueue(pw);
|
||||
}
|
||||
@@ -1222,8 +1228,8 @@ namespace KeePassLib
|
||||
PwGroup pgSrcParent = ptSrc.ParentGroup;
|
||||
if(pgSrcParent == null) return true; // Root might be in tree
|
||||
|
||||
if(!ptFirst.ParentGroup.Uuid.EqualsValue(pgOrgParent.Uuid)) return true;
|
||||
if(!pgOrgParent.Uuid.EqualsValue(pgSrcParent.Uuid)) return true;
|
||||
if(!ptFirst.ParentGroup.Uuid.Equals(pgOrgParent.Uuid)) return true;
|
||||
if(!pgOrgParent.Uuid.Equals(pgSrcParent.Uuid)) return true;
|
||||
|
||||
List<IStructureItem> lOrg = pgOrgParent.GetObjects(false, bEntries);
|
||||
List<IStructureItem> lSrc = pgSrcParent.GetObjects(false, bEntries);
|
||||
@@ -1235,8 +1241,8 @@ namespace KeePassLib
|
||||
IStructureItem pt = vItems.GetAt(u);
|
||||
Debug.Assert(pt.ParentGroup == ptFirst.ParentGroup);
|
||||
|
||||
if(!pt.Uuid.EqualsValue(lOrg[(int)u].Uuid)) return true;
|
||||
if(!pt.Uuid.EqualsValue(lSrc[(int)u].Uuid)) return true;
|
||||
if(!pt.Uuid.Equals(lOrg[(int)u].Uuid)) return true;
|
||||
if(!pt.Uuid.Equals(lSrc[(int)u].Uuid)) return true;
|
||||
if(pt.LocationChanged != lOrg[(int)u].LocationChanged) return true;
|
||||
if(pt.LocationChanged != lSrc[(int)u].LocationChanged) return true;
|
||||
}
|
||||
@@ -1303,7 +1309,7 @@ namespace KeePassLib
|
||||
private void MergeEntryHistory(PwEntry pe, PwEntry peSource,
|
||||
PwMergeMethod mm)
|
||||
{
|
||||
if(!pe.Uuid.EqualsValue(peSource.Uuid)) { Debug.Assert(false); return; }
|
||||
if(!pe.Uuid.Equals(peSource.Uuid)) { Debug.Assert(false); return; }
|
||||
|
||||
if(pe.History.UCount == peSource.History.UCount)
|
||||
{
|
||||
@@ -1323,27 +1329,32 @@ namespace KeePassLib
|
||||
|
||||
if((m_slStatus != null) && !m_slStatus.ContinueWork()) return;
|
||||
|
||||
SortedList<DateTime, PwEntry> list = new SortedList<DateTime, PwEntry>();
|
||||
IDictionary<DateTime, PwEntry> dict =
|
||||
#if KeePassLibSD
|
||||
new SortedList<DateTime, PwEntry>();
|
||||
#else
|
||||
new SortedDictionary<DateTime, PwEntry>();
|
||||
#endif
|
||||
foreach(PwEntry peOrg in pe.History)
|
||||
{
|
||||
list[peOrg.LastModificationTime] = peOrg;
|
||||
dict[peOrg.LastModificationTime] = peOrg;
|
||||
}
|
||||
|
||||
foreach(PwEntry peSrc in peSource.History)
|
||||
{
|
||||
DateTime dt = peSrc.LastModificationTime;
|
||||
if(list.ContainsKey(dt))
|
||||
if(dict.ContainsKey(dt))
|
||||
{
|
||||
if(mm == PwMergeMethod.OverwriteExisting)
|
||||
list[dt] = peSrc.CloneDeep();
|
||||
dict[dt] = peSrc.CloneDeep();
|
||||
}
|
||||
else list[dt] = peSrc.CloneDeep();
|
||||
else dict[dt] = peSrc.CloneDeep();
|
||||
}
|
||||
|
||||
pe.History.Clear();
|
||||
foreach(KeyValuePair<DateTime, PwEntry> kvpCur in list)
|
||||
foreach(KeyValuePair<DateTime, PwEntry> kvpCur in dict)
|
||||
{
|
||||
Debug.Assert(kvpCur.Value.Uuid.EqualsValue(pe.Uuid));
|
||||
Debug.Assert(kvpCur.Value.Uuid.Equals(pe.Uuid));
|
||||
Debug.Assert(kvpCur.Value.History.UCount == 0);
|
||||
pe.History.Add(kvpCur.Value);
|
||||
}
|
||||
@@ -1385,20 +1396,34 @@ namespace KeePassLib
|
||||
/// <returns>Index of the icon.</returns>
|
||||
public int GetCustomIconIndex(PwUuid pwIconId)
|
||||
{
|
||||
int nIndex = 0;
|
||||
|
||||
foreach(PwCustomIcon pwci in m_vCustomIcons)
|
||||
for(int i = 0; i < m_vCustomIcons.Count; ++i)
|
||||
{
|
||||
if(pwci.Uuid.EqualsValue(pwIconId))
|
||||
return nIndex;
|
||||
|
||||
++nIndex;
|
||||
PwCustomIcon pwci = m_vCustomIcons[i];
|
||||
if(pwci.Uuid.Equals(pwIconId))
|
||||
return i;
|
||||
}
|
||||
|
||||
// Debug.Assert(false); // Do not assert
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int GetCustomIconIndex(byte[] pbPngData)
|
||||
{
|
||||
if(pbPngData == null) { Debug.Assert(false); return -1; }
|
||||
|
||||
for(int i = 0; i < m_vCustomIcons.Count; ++i)
|
||||
{
|
||||
PwCustomIcon pwci = m_vCustomIcons[i];
|
||||
byte[] pbEx = pwci.ImageDataPng;
|
||||
if(pbEx == null) { Debug.Assert(false); continue; }
|
||||
|
||||
if(MemUtil.ArraysEqual(pbEx, pbPngData))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a custom icon. This function can return <c>null</c>, if
|
||||
/// no cached image of the icon is available.
|
||||
@@ -1422,11 +1447,11 @@ namespace KeePassLib
|
||||
GroupHandler gh = delegate(PwGroup pg)
|
||||
{
|
||||
PwUuid uuidThis = pg.CustomIconUuid;
|
||||
if(uuidThis.EqualsValue(PwUuid.Zero)) return true;
|
||||
if(uuidThis.Equals(PwUuid.Zero)) return true;
|
||||
|
||||
foreach(PwUuid uuidDelete in vUuidsToDelete)
|
||||
{
|
||||
if(uuidThis.EqualsValue(uuidDelete))
|
||||
if(uuidThis.Equals(uuidDelete))
|
||||
{
|
||||
pg.CustomIconUuid = PwUuid.Zero;
|
||||
break;
|
||||
@@ -1461,11 +1486,11 @@ namespace KeePassLib
|
||||
private static void RemoveCustomIconUuid(PwEntry pe, List<PwUuid> vToDelete)
|
||||
{
|
||||
PwUuid uuidThis = pe.CustomIconUuid;
|
||||
if(uuidThis.EqualsValue(PwUuid.Zero)) return;
|
||||
if(uuidThis.Equals(PwUuid.Zero)) return;
|
||||
|
||||
foreach(PwUuid uuidDelete in vToDelete)
|
||||
{
|
||||
if(uuidThis.EqualsValue(uuidDelete))
|
||||
if(uuidThis.Equals(uuidDelete))
|
||||
{
|
||||
pe.CustomIconUuid = PwUuid.Zero;
|
||||
break;
|
||||
@@ -1485,7 +1510,7 @@ namespace KeePassLib
|
||||
GroupHandler gh = delegate(PwGroup pg)
|
||||
{
|
||||
foreach(PwUuid u in l)
|
||||
bAllUnique &= !pg.Uuid.EqualsValue(u);
|
||||
bAllUnique &= !pg.Uuid.Equals(u);
|
||||
l.Add(pg.Uuid);
|
||||
return bAllUnique;
|
||||
};
|
||||
@@ -1493,7 +1518,7 @@ namespace KeePassLib
|
||||
EntryHandler eh = delegate(PwEntry pe)
|
||||
{
|
||||
foreach(PwUuid u in l)
|
||||
bAllUnique &= !pe.Uuid.EqualsValue(u);
|
||||
bAllUnique &= !pe.Uuid.Equals(u);
|
||||
l.Add(pe.Uuid);
|
||||
return bAllUnique;
|
||||
};
|
||||
@@ -1591,7 +1616,7 @@ namespace KeePassLib
|
||||
PwEntry peB = l.GetAt(j);
|
||||
if(!DupEntriesEqual(peA, peB)) continue;
|
||||
|
||||
bool bDeleteA = (peA.LastModificationTime <= peB.LastModificationTime);
|
||||
bool bDeleteA = (TimeUtil.CompareLastMod(peA, peB, true) <= 0);
|
||||
if(pgRecycleBin != null)
|
||||
{
|
||||
bool bAInBin = peA.IsContainedIn(pgRecycleBin);
|
||||
@@ -1708,11 +1733,11 @@ namespace KeePassLib
|
||||
GroupHandler gh = delegate(PwGroup pg)
|
||||
{
|
||||
PwUuid pwUuid = pg.CustomIconUuid;
|
||||
if((pwUuid == null) || pwUuid.EqualsValue(PwUuid.Zero)) return true;
|
||||
if((pwUuid == null) || pwUuid.Equals(PwUuid.Zero)) return true;
|
||||
|
||||
for(int i = 0; i < lToDelete.Count; ++i)
|
||||
{
|
||||
if(lToDelete[i].EqualsValue(pwUuid))
|
||||
if(lToDelete[i].Equals(pwUuid))
|
||||
{
|
||||
lToDelete.RemoveAt(i);
|
||||
break;
|
||||
@@ -1725,11 +1750,11 @@ namespace KeePassLib
|
||||
EntryHandler eh = delegate(PwEntry pe)
|
||||
{
|
||||
PwUuid pwUuid = pe.CustomIconUuid;
|
||||
if((pwUuid == null) || pwUuid.EqualsValue(PwUuid.Zero)) return true;
|
||||
if((pwUuid == null) || pwUuid.Equals(PwUuid.Zero)) return true;
|
||||
|
||||
for(int i = 0; i < lToDelete.Count; ++i)
|
||||
{
|
||||
if(lToDelete[i].EqualsValue(pwUuid))
|
||||
if(lToDelete[i].Equals(pwUuid))
|
||||
{
|
||||
lToDelete.RemoveAt(i);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user