// Code generated by winrt-go-gen. DO NOT EDIT.

//go:build windows

//nolint:all
package genericattributeprofile

import (
	"syscall"
	"unsafe"

	"git.savin.nyc/alex/go-winrt/windows/storage/streams"
	"github.com/go-ole/go-ole"
)

const SignatureGattLocalDescriptorParameters string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalDescriptorParameters;{5fdede6a-f3c1-4b66-8c4b-e3d2293b40e9})"

type GattLocalDescriptorParameters struct {
	ole.IUnknown
}

func NewGattLocalDescriptorParameters() (*GattLocalDescriptorParameters, error) {
	inspectable, err := ole.RoActivateInstance("Windows.Devices.Bluetooth.GenericAttributeProfile.GattLocalDescriptorParameters")
	if err != nil {
		return nil, err
	}
	return (*GattLocalDescriptorParameters)(unsafe.Pointer(inspectable)), nil
}

func (impl *GattLocalDescriptorParameters) SetStaticValue(value *streams.IBuffer) error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters))
	defer itf.Release()
	v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf))
	return v.SetStaticValue(value)
}

func (impl *GattLocalDescriptorParameters) GetStaticValue() (*streams.IBuffer, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters))
	defer itf.Release()
	v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf))
	return v.GetStaticValue()
}

func (impl *GattLocalDescriptorParameters) SetReadProtectionLevel(value GattProtectionLevel) error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters))
	defer itf.Release()
	v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf))
	return v.SetReadProtectionLevel(value)
}

func (impl *GattLocalDescriptorParameters) GetReadProtectionLevel() (GattProtectionLevel, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters))
	defer itf.Release()
	v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf))
	return v.GetReadProtectionLevel()
}

func (impl *GattLocalDescriptorParameters) SetWriteProtectionLevel(value GattProtectionLevel) error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters))
	defer itf.Release()
	v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf))
	return v.SetWriteProtectionLevel(value)
}

func (impl *GattLocalDescriptorParameters) GetWriteProtectionLevel() (GattProtectionLevel, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattLocalDescriptorParameters))
	defer itf.Release()
	v := (*iGattLocalDescriptorParameters)(unsafe.Pointer(itf))
	return v.GetWriteProtectionLevel()
}

const GUIDiGattLocalDescriptorParameters string = "5fdede6a-f3c1-4b66-8c4b-e3d2293b40e9"
const SignatureiGattLocalDescriptorParameters string = "{5fdede6a-f3c1-4b66-8c4b-e3d2293b40e9}"

type iGattLocalDescriptorParameters struct {
	ole.IInspectable
}

type iGattLocalDescriptorParametersVtbl struct {
	ole.IInspectableVtbl

	SetStaticValue          uintptr
	GetStaticValue          uintptr
	SetReadProtectionLevel  uintptr
	GetReadProtectionLevel  uintptr
	SetWriteProtectionLevel uintptr
	GetWriteProtectionLevel uintptr
}

func (v *iGattLocalDescriptorParameters) VTable() *iGattLocalDescriptorParametersVtbl {
	return (*iGattLocalDescriptorParametersVtbl)(unsafe.Pointer(v.RawVTable))
}

func (v *iGattLocalDescriptorParameters) SetStaticValue(value *streams.IBuffer) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().SetStaticValue,
		uintptr(unsafe.Pointer(v)),     // this
		uintptr(unsafe.Pointer(value)), // in streams.IBuffer
	)

	if hr != 0 {
		return ole.NewError(hr)
	}

	return nil
}

func (v *iGattLocalDescriptorParameters) GetStaticValue() (*streams.IBuffer, error) {
	var out *streams.IBuffer
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetStaticValue,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out streams.IBuffer
	)

	if hr != 0 {
		return nil, ole.NewError(hr)
	}

	return out, nil
}

func (v *iGattLocalDescriptorParameters) SetReadProtectionLevel(value GattProtectionLevel) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().SetReadProtectionLevel,
		uintptr(unsafe.Pointer(v)), // this
		uintptr(value),             // in GattProtectionLevel
	)

	if hr != 0 {
		return ole.NewError(hr)
	}

	return nil
}

func (v *iGattLocalDescriptorParameters) GetReadProtectionLevel() (GattProtectionLevel, error) {
	var out GattProtectionLevel
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetReadProtectionLevel,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel
	)

	if hr != 0 {
		return GattProtectionLevelPlain, ole.NewError(hr)
	}

	return out, nil
}

func (v *iGattLocalDescriptorParameters) SetWriteProtectionLevel(value GattProtectionLevel) error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().SetWriteProtectionLevel,
		uintptr(unsafe.Pointer(v)), // this
		uintptr(value),             // in GattProtectionLevel
	)

	if hr != 0 {
		return ole.NewError(hr)
	}

	return nil
}

func (v *iGattLocalDescriptorParameters) GetWriteProtectionLevel() (GattProtectionLevel, error) {
	var out GattProtectionLevel
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetWriteProtectionLevel,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out GattProtectionLevel
	)

	if hr != 0 {
		return GattProtectionLevelPlain, ole.NewError(hr)
	}

	return out, nil
}
