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{}