Пример #1
0
// CreateItem (IN Dict<String,Variant> properties, IN Secret secret, IN Boolean replace, OUT ObjectPath item, OUT ObjectPath prompt);
func (collection *Collection) CreateItem(label string, secret *Secret, replace bool) (*Item, error) {
	properties := make(map[string]dbus.Variant)
	attributes := make(map[string]string)

	attributes["profile"] = label
	properties["org.freedesktop.Secret.Item.Label"] = dbus.MakeVariant(label)
	properties["org.freedesktop.Secret.Item.Attributes"] = dbus.MakeVariant(attributes)

	var path dbus.ObjectPath
	var prompt dbus.ObjectPath

	err := collection.dbus.Call("org.freedesktop.Secret.Collection.CreateItem", 0, properties, secret, replace).Store(&path, &prompt)
	if err != nil {
		return &Item{}, err
	}

	if isPrompt(prompt) {
		prompt := NewPrompt(collection.conn, prompt)

		result, err := prompt.Prompt()
		if err != nil {
			return &Item{}, err
		}

		path = result.Value().(dbus.ObjectPath)
	}

	return NewItem(collection.conn, path), nil
}
Пример #2
0
// CreateCollection (IN Dict<String,Variant> properties, IN String alias, OUT ObjectPath collection, OUT ObjectPath prompt);
func (service *Service) CreateCollection(label string) (*Collection, error) {
	properties := make(map[string]dbus.Variant)
	properties["org.freedesktop.Secret.Collection.Label"] = dbus.MakeVariant(label)

	var path dbus.ObjectPath
	var prompt dbus.ObjectPath

	err := service.dbus.Call("org.freedesktop.Secret.Service.CreateCollection", 0, properties, "").Store(&path, &prompt)
	if err != nil {
		return &Collection{}, err
	}

	if isPrompt(prompt) {
		prompt := NewPrompt(service.conn, prompt)

		result, err := prompt.Prompt()
		if err != nil {
			return &Collection{}, err
		}

		path = result.Value().(dbus.ObjectPath)
	}

	return NewCollection(service.conn, path), nil
}
Пример #3
0
// Delete (OUT ObjectPath Prompt);
func (item *Item) Delete() error {
	var prompt dbus.ObjectPath

	err := item.dbus.Call("org.freedesktop.Secret.Item.Delete", 0).Store(&prompt)
	if err != nil {
		return err
	}

	if isPrompt(prompt) {
		prompt := NewPrompt(item.conn, prompt)
		if _, err := prompt.Prompt(); err != nil {
			return err
		}
	}

	return nil
}
Пример #4
0
// Delete (OUT ObjectPath prompt);
func (collection *Collection) Delete() error {
	var prompt dbus.ObjectPath

	err := collection.dbus.Call("org.freedesktop.Secret.Collection.Delete", 0).Store(&prompt)
	if err != nil {
		return err
	}

	if isPrompt(prompt) {
		prompt := NewPrompt(collection.conn, prompt)

		_, err := prompt.Prompt()
		if err != nil {
			return err
		}
	}

	return nil
}
Пример #5
0
// Unlock (IN Array<ObjectPath> objects, OUT Array<ObjectPath> unlocked, OUT ObjectPath prompt);
func (service *Service) Unlock(object DBusObject) error {
	objects := []dbus.ObjectPath{object.Path()}

	var unlocked []dbus.ObjectPath
	var prompt dbus.ObjectPath

	err := service.dbus.Call("org.freedesktop.Secret.Service.Unlock", 0, objects).Store(&unlocked, &prompt)
	if err != nil {
		return err
	}

	if isPrompt(prompt) {
		prompt := NewPrompt(service.conn, prompt)
		if _, err := prompt.Prompt(); err != nil {
			return err
		}
	}

	return nil
}