From 25e3bf7a9713ad5d020936b282a921e5fe0b27b4 Mon Sep 17 00:00:00 2001 From: joe miller Date: Thu, 30 May 2019 07:57:47 -0700 Subject: [PATCH] add accessors for remaining org.freedesktop.Secret.Item properties https://specifications.freedesktop.org/secret-service/re03.html Adds methods to item: Created(), Modified(), Attributes() --- item.go | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/item.go b/item.go index f0e6ad3..748d749 100644 --- a/item.go +++ b/item.go @@ -1,6 +1,10 @@ package libsecret -import "github.com/godbus/dbus" +import ( + "time" + + "github.com/godbus/dbus" +) type Item struct { @@ -44,6 +48,45 @@ func (item *Item) Locked() (bool, error) { } +// READ Uint64 Created; +func (item *Item) Created() (time.Time, error) { + val, err := item.dbus.GetProperty("org.freedesktop.Secret.Item.Created") + if err != nil { + return time.Time{}, err + } + v := val.Value().(uint64) + tm := time.Unix(int64(v), 0) + + return tm, nil +} + + +// READ Uint64 Modified; +func (item *Item) Modified() (time.Time, error) { + val, err := item.dbus.GetProperty("org.freedesktop.Secret.Item.Modified") + if err != nil { + return time.Time{}, err + } + v := val.Value().(uint64) + tm := time.Unix(int64(v), 0) + + return tm, nil +} + + +// READWRITE Dict Attributes; +func (item *Item) Attributes() (map[string]string, error) { + attributes := make(map[string]string) + val, err := item.dbus.GetProperty("org.freedesktop.Secret.Item.Attributes") + if err != nil { + return attributes, err + } + attributes = val.Value().(map[string]string) + + return attributes, nil +} + + // GetSecret (IN ObjectPath session, OUT Secret secret); func (item *Item) GetSecret(session *Session) (*Secret, error) { secret := Secret{}