diff --git a/collection_funcs.go b/collection_funcs.go index 5fc2068..21aa087 100644 --- a/collection_funcs.go +++ b/collection_funcs.go @@ -80,7 +80,9 @@ func (c *Collection) CreateItem(label string, attrs map[string]string, secret *S } props[DbusItemLabel] = dbus.MakeVariant(label) - props[DbusItemType] = dbus.MakeVariant(typeString) + if !c.service.Legacy { + props[DbusItemType] = dbus.MakeVariant(typeString) + } props[DbusItemAttributes] = dbus.MakeVariant(attrs) props[DbusItemCreated] = dbus.MakeVariant(uint64(time.Now().Unix())) // props[DbusItemModified] = dbus.MakeVariant(uint64(time.Now().Unix())) diff --git a/item_funcs.go b/item_funcs.go index 145eaaf..0702c65 100644 --- a/item_funcs.go +++ b/item_funcs.go @@ -282,6 +282,11 @@ func (i *Item) Type() (itemType string, err error) { var variant dbus.Variant + // Legacy spec. + if i.collection.service.Legacy { + return + } + if variant, err = i.Dbus.GetProperty(DbusItemType); err != nil { return } diff --git a/types.go b/types.go index 9cce73d..8d81b2b 100644 --- a/types.go +++ b/types.go @@ -74,6 +74,17 @@ type Service struct { Session *Session `json:"-"` // IsLocked indicates if the Service is locked or not. Status updated by Service.Locked. IsLocked bool `json:"locked"` + /* + Legacy indicates that this SecretService implementation + breaks current spec by implementing the legacy/obsolete draft spec rather than current libsecret spec + for the Dbus API. + + If you're using SecretService with KeePassXC, for instance, or a much older version of Gnome-Keyring *before* libsecret integration(?), + or if you are getting strange errors when performing a Service.SearchItems, you probably need to enable this field on the Service returned + by NewService. The coverage of this field may expand in the future, but currently it only prevents the (non-existent, in legacy spec) + Type property from being read or written on Items during NewItem and Collection.CreateItem. + */ + Legacy bool `json:"is_legacy"` } /* @@ -83,7 +94,7 @@ type Service struct { */ type Session struct { *DbusObject - // collection tracks the Service this Session was created from. + // service tracks the Service this Session was created from. service *Service }