From 8d81c5f0cc4c6620a06e153c05f7fa28e54c7bcc Mon Sep 17 00:00:00 2001 From: brent s Date: Wed, 15 Dec 2021 04:16:06 -0500 Subject: [PATCH] recursion flags set up --- consts.go | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 5 +++- go.sum | 5 ++++ types.go | 8 +++++ 4 files changed, 106 insertions(+), 1 deletion(-) diff --git a/consts.go b/consts.go index 41144c3..1023cd7 100644 --- a/consts.go +++ b/consts.go @@ -163,3 +163,92 @@ const ( // DbusPath is the path for DbusService. DbusPath string = "/modules/kwalletd5" ) + +// Recursion options. + +/* + RecurseNone specifies that no recursion should be done. + If present, it takes precedent over all over RecurseOptsFlags present. + + Performed in/from: + WalletManager + Wallet + Folder + (WalletItem) +*/ +const RecurseNone RecurseOptsFlag = 0 +const ( + /* + RecurseWallet indicates that Wallet objects should have Wallet.Update called. + + Performed in/from: WalletManager + */ + RecurseWallet RecurseOptsFlag = 1 << iota + /* + RecurseFolder indicates that Folder objects should have Folder.Update called. + + Performed in/from: + Wallet + + May be performed in/from (depending on other flags): + WalletManager + */ + RecurseFolder + /* + RecurseWalletItem indicates that all WalletItem entries should have (WalletItem).Update() called. + If present, it takes precedent over all over relevant RecurseOptsFlags present + (RecursePassword, RecurseMap, RecurseBlob, RecurseUnknown). + + Performed in/from: + Folder + + May be performed in/from (depending on other flags): + WalletManager + Wallet + */ + RecurseWalletItem + /* + RecursePassword indicates that Password objects should have Password.Update() called. + + Performed in/from: + Folder + + May be performed in/from (depending on other flags): + WalletManager + Wallet + */ + RecursePassword + /* + RecurseMap indicates that Map objects should have Map.Update() called. + + Performed in/from: + Folder + + May be performed in/from (depending on other flags): + WalletManager + Wallet + */ + RecurseMap + /* + RecurseBlob indicates that Blob objects should have Blob.Update() called. + + Performed in/from: + Folder + + May be performed in/from (depending on other flags): + WalletManager + Wallet + */ + RecurseBlob + /* + RecurseUnknown indicates that UnknownItem objects should have UnknownItem.Update() called. + + Performed in/from: + Folder + + May be performed in/from (depending on other flags): + WalletManager + Wallet + */ + RecurseUnknown +) diff --git a/go.mod b/go.mod index 9b8411b..9a39c8d 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,7 @@ module r00t2.io/gokwallet go 1.17 -require github.com/godbus/dbus/v5 v5.0.6 +require ( + github.com/godbus/dbus/v5 v5.0.6 + r00t2.io/goutils v1.0.1 +) diff --git a/go.sum b/go.sum index aeec758..acb71a9 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,7 @@ +github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro= github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/jszwec/csvutil v1.5.0/go.mod h1:Rpu7Uu9giO9subDyMCIQfHVDuLrcaC36UA4YcJjGBkg= +r00t2.io/goutils v1.0.1 h1:f1m2QRBF8XsW3peYf1I2q37npgf+5bmJBbrLzCFtm34= +r00t2.io/goutils v1.0.1/go.mod h1:CMK3RGnMSyjDSfYxeFQl/oJTkkUMS1jhSTdGTkAPpQw= +r00t2.io/sysutils v0.0.0-20210224054841-55ac47c86928/go.mod h1:XzJkBF6SHAODEszJlOcjtGoTHwYnZZNmseA6PyOujes= diff --git a/types.go b/types.go index 4b668d1..b696108 100644 --- a/types.go +++ b/types.go @@ -2,6 +2,7 @@ package gokwallet import ( "github.com/godbus/dbus/v5" + "r00t2.io/goutils/types" ) /* @@ -131,3 +132,10 @@ type UnknownItem struct { type WalletItem interface { isWalletItem() (isWalletItem bool) } + +/* + RecurseOptsFlag is used to determine whether or not to recurse into items and fully populate them. + One would use a types.BitMask as a parameter type and do .HasFlag(). + See consts.go for the actual flags. +*/ +type RecurseOptsFlag types.MaskBit