From 92d3f5da55340778a53ad4dbe8d749f0c9752d75 Mon Sep 17 00:00:00 2001 From: Roger Ye Date: Sat, 2 Jul 2022 18:28:36 +0800 Subject: [PATCH 1/6] Changed GetCustomIcon() in PxItem.cs --- PassXYZLib/PxItem.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/PassXYZLib/PxItem.cs b/PassXYZLib/PxItem.cs index 1c7ddb3..b7352a6 100644 --- a/PassXYZLib/PxItem.cs +++ b/PassXYZLib/PxItem.cs @@ -452,12 +452,23 @@ public static string GetCustomIcon(this Item item) } else { - Debug.WriteLine("SetIcon: PasswordDb is closed"); + Debug.WriteLine("GetCustomIcon: PasswordDb is closed"); } } else { - Debug.WriteLine("SetIcon: No PasswordDb instance"); + Debug.WriteLine("GetCustomIcon: No PasswordDb instance"); + } + } + else + { + if (item.IsGroup) + { + return "folder.svg"; + } + else + { + return "file.svg"; } } return string.Empty; From dc4b66d9db47806391ef54467af9ce630dad7c61 Mon Sep 17 00:00:00 2001 From: Roger Ye Date: Sun, 17 Jul 2022 12:36:12 +0800 Subject: [PATCH 2/6] Fixed bug in UpdateField() and added FindEncodeKey() --- PassXYZLib/PwEntryEx.cs | 18 ++++++++++++++++++ PassXYZLib/PxItem.cs | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/PassXYZLib/PwEntryEx.cs b/PassXYZLib/PwEntryEx.cs index 5f9aaf3..51421ab 100644 --- a/PassXYZLib/PwEntryEx.cs +++ b/PassXYZLib/PwEntryEx.cs @@ -46,6 +46,24 @@ public static void SetPxEntry(this PwEntry entry) entry.CustomData.Set(PxDefs.PxCustomDataItemSubType, ItemSubType.PxEntry.ToString()); } + /// + /// Find the encoded key using a key in the field. + /// + /// an instance of PwEntry + /// key of Field + /// encoded key + public static string FindEncodeKey(this PwEntry entry, string key) + { + if (PxDefs.IsPxEntry(entry)) + { + return PxDefs.FindEncodeKey(entry.Strings, key); + } + else + { + return key; + } + } + /// /// Create a new encoded key for PxEntry. /// diff --git a/PassXYZLib/PxItem.cs b/PassXYZLib/PxItem.cs index b7352a6..1452127 100644 --- a/PassXYZLib/PxItem.cs +++ b/PassXYZLib/PxItem.cs @@ -571,7 +571,7 @@ public static Field AddField(this Item item, string key, string value, bool isPr if (entry.IsPxEntry()) { - field = new Field(k, value, isProtected, FieldIcons.GetImage, entry.EncodeKey(k)); + field = new Field(key, value, isProtected, FieldIcons.GetImage, entry.EncodeKey(k)); } else { @@ -615,7 +615,7 @@ public static void UpdateField(this Item item, string key, string value, bool is { if (item is PwEntry entry) { - string k = entry.IsPxEntry() ? entry.EncodeKey(key) : key; + string k = entry.IsPxEntry() ? entry.FindEncodeKey(key) : key; if (entry.Strings.Exists(k)) { entry.Strings.Set(k, new ProtectedString(isProtected, value)); From 02e0cfdc0c0f5ad04bff2cada07d63858635793f Mon Sep 17 00:00:00 2001 From: Roger Ye Date: Sun, 17 Jul 2022 14:16:05 +0800 Subject: [PATCH 3/6] Added extension method GetItemSubType() --- PassXYZLib/PxDefs.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/PassXYZLib/PxDefs.cs b/PassXYZLib/PxDefs.cs index 4f65d2e..0947094 100644 --- a/PassXYZLib/PxDefs.cs +++ b/PassXYZLib/PxDefs.cs @@ -310,6 +310,7 @@ public static string GetDatabaseType(string fileName) return "KeePass"; } } + public static ItemSubType GetItemSubType(this ItemSubType subType, string type) // The end of PxDefs } From 40f2ef520acf6507bd4a4a38942125ce37147d1f Mon Sep 17 00:00:00 2001 From: Roger Ye Date: Sun, 17 Jul 2022 14:16:27 +0800 Subject: [PATCH 4/6] Added extension method GetItemSubType() --- PassXYZLib/PxDefs.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/PassXYZLib/PxDefs.cs b/PassXYZLib/PxDefs.cs index 0947094..ad25be3 100644 --- a/PassXYZLib/PxDefs.cs +++ b/PassXYZLib/PxDefs.cs @@ -309,8 +309,18 @@ public static string GetDatabaseType(string fileName) { return "KeePass"; } + } + + public static ItemSubType GetItemSubType(this ItemSubType subType, string type) + { + if (type == ItemSubType.Group.ToString()) return ItemSubType.Group; + if (type == ItemSubType.Entry.ToString()) return ItemSubType.Entry; + if (type == ItemSubType.Notes.ToString()) return ItemSubType.Notes; + if (type == ItemSubType.PxEntry.ToString()) return ItemSubType.PxEntry; + + return ItemSubType.None; } - public static ItemSubType GetItemSubType(this ItemSubType subType, string type) + // The end of PxDefs } From 90d08e74ee2001dc617ba97209536d1a7a1681a1 Mon Sep 17 00:00:00 2001 From: Roger Ye Date: Sat, 6 Aug 2022 17:44:04 +0800 Subject: [PATCH 5/6] Added IKeyValue, NewField and NewItem --- PassXYZLib/IKeyValue.cs | 15 +++++++++++++++ PassXYZLib/NewField.cs | 15 +++++++++++++++ PassXYZLib/NewItem.cs | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 PassXYZLib/IKeyValue.cs create mode 100644 PassXYZLib/NewField.cs create mode 100644 PassXYZLib/NewItem.cs diff --git a/PassXYZLib/IKeyValue.cs b/PassXYZLib/IKeyValue.cs new file mode 100644 index 0000000..9bc47bc --- /dev/null +++ b/PassXYZLib/IKeyValue.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PassXYZLib +{ + public interface IKeyValue + { + string Key { get; set; } + string Value { get; set; } + bool IsValid { get => !(string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(Value)); } + } +} diff --git a/PassXYZLib/NewField.cs b/PassXYZLib/NewField.cs new file mode 100644 index 0000000..f2aab2d --- /dev/null +++ b/PassXYZLib/NewField.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PassXYZLib +{ + public class NewField : Field + { + public NewField(string key = "", string value="", bool isProtected=false) : base(key, value, isProtected) + { + } + } +} diff --git a/PassXYZLib/NewItem.cs b/PassXYZLib/NewItem.cs new file mode 100644 index 0000000..12e100a --- /dev/null +++ b/PassXYZLib/NewItem.cs @@ -0,0 +1,37 @@ +using KPCLib; +using PassXYZLib; + +namespace PassXYZLib +{ + public class NewItem : Item + { + private readonly Guid uid = new(); + public override string Id + { + get + { + return uid.ToString(); + } + } + public override string Name { get; set; } = default!; + public override string Notes { get; set; } = default!; + public override bool IsGroup { get => (SubType == ItemSubType.Group); } + public override DateTime LastModificationTime { get; set; } = default!; + public override string Description + { + get + { + return $"{ItemType} | {LastModificationTime.ToString("yyyy'-'MM'-'dd")} | {Notes}".Truncate(50); + } + } + public ItemSubType SubType { get; set; } = ItemSubType.Group; + public string ItemType + { + get => SubType.ToString(); + set + { + SubType = SubType.GetItemSubType(value); + } + } + } +} From cd74bf678ae2ab816cdaa3b5086e65ef0df296fb Mon Sep 17 00:00:00 2001 From: Roger Ye Date: Wed, 24 Aug 2022 11:14:33 +0800 Subject: [PATCH 6/6] Build 2.0.2 --- CHANGELOG.md | 3 +++ PassXYZLib.nuspec | 41 +++++++++++++----------------------- PassXYZLib/PassXYZLib.csproj | 2 +- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68f0501..7e1d96b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Change log +### 2.0.2 +- Built for .NET MAUI GA release + ### 2.0.1-rc.1 - Upgraded to .NET MAUI RC1 - PassXYZLib moved to a separate project diff --git a/PassXYZLib.nuspec b/PassXYZLib.nuspec index 02d9e96..cae4e0d 100644 --- a/PassXYZLib.nuspec +++ b/PassXYZLib.nuspec @@ -2,7 +2,7 @@ PassXYZLib - 2.0.1-rc.1 + 2.0.2 Roger Ye Roger Ye false @@ -13,47 +13,37 @@ - Fixed dependency issue Roger Ye - + - - - + - - - + - + - - - + - + - - - + - - - + PassXYZLib added additional features for .NET MAUI. @@ -62,14 +52,13 @@ - - - - - - - + + + + + + diff --git a/PassXYZLib/PassXYZLib.csproj b/PassXYZLib/PassXYZLib.csproj index 5894266..11b0107 100644 --- a/PassXYZLib/PassXYZLib.csproj +++ b/PassXYZLib/PassXYZLib.csproj @@ -17,7 +17,7 @@ True - 2.0.1 + 2.0.2 en-US