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

//go:build windows

//nolint:all
package advertisement

import (
	"syscall"
	"unsafe"

	"github.com/go-ole/go-ole"
)

const SignatureBluetoothLEAdvertisementPublisher string = "rc(Windows.Devices.Bluetooth.Advertisement.BluetoothLEAdvertisementPublisher;{cde820f9-d9fa-43d6-a264-ddd8b7da8b78})"

type BluetoothLEAdvertisementPublisher struct {
	ole.IUnknown
}

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

func (impl *BluetoothLEAdvertisementPublisher) GetStatus() (BluetoothLEAdvertisementPublisherStatus, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiBluetoothLEAdvertisementPublisher))
	defer itf.Release()
	v := (*iBluetoothLEAdvertisementPublisher)(unsafe.Pointer(itf))
	return v.GetStatus()
}

func (impl *BluetoothLEAdvertisementPublisher) GetAdvertisement() (*BluetoothLEAdvertisement, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiBluetoothLEAdvertisementPublisher))
	defer itf.Release()
	v := (*iBluetoothLEAdvertisementPublisher)(unsafe.Pointer(itf))
	return v.GetAdvertisement()
}

func (impl *BluetoothLEAdvertisementPublisher) Start() error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiBluetoothLEAdvertisementPublisher))
	defer itf.Release()
	v := (*iBluetoothLEAdvertisementPublisher)(unsafe.Pointer(itf))
	return v.Start()
}

func (impl *BluetoothLEAdvertisementPublisher) Stop() error {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiBluetoothLEAdvertisementPublisher))
	defer itf.Release()
	v := (*iBluetoothLEAdvertisementPublisher)(unsafe.Pointer(itf))
	return v.Stop()
}

const GUIDiBluetoothLEAdvertisementPublisher string = "cde820f9-d9fa-43d6-a264-ddd8b7da8b78"
const SignatureiBluetoothLEAdvertisementPublisher string = "{cde820f9-d9fa-43d6-a264-ddd8b7da8b78}"

type iBluetoothLEAdvertisementPublisher struct {
	ole.IInspectable
}

type iBluetoothLEAdvertisementPublisherVtbl struct {
	ole.IInspectableVtbl

	GetStatus           uintptr
	GetAdvertisement    uintptr
	Start               uintptr
	Stop                uintptr
	AddStatusChanged    uintptr
	RemoveStatusChanged uintptr
}

func (v *iBluetoothLEAdvertisementPublisher) VTable() *iBluetoothLEAdvertisementPublisherVtbl {
	return (*iBluetoothLEAdvertisementPublisherVtbl)(unsafe.Pointer(v.RawVTable))
}

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

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

	return out, nil
}

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

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

	return out, nil
}

func (v *iBluetoothLEAdvertisementPublisher) Start() error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().Start,
		uintptr(unsafe.Pointer(v)), // this
	)

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

	return nil
}

func (v *iBluetoothLEAdvertisementPublisher) Stop() error {
	hr, _, _ := syscall.SyscallN(
		v.VTable().Stop,
		uintptr(unsafe.Pointer(v)), // this
	)

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

	return nil
}

const GUIDiBluetoothLEAdvertisementPublisher2 string = "fbdb545e-56f1-510f-a434-217fbd9e7bd2"
const SignatureiBluetoothLEAdvertisementPublisher2 string = "{fbdb545e-56f1-510f-a434-217fbd9e7bd2}"

type iBluetoothLEAdvertisementPublisher2 struct {
	ole.IInspectable
}

type iBluetoothLEAdvertisementPublisher2Vtbl struct {
	ole.IInspectableVtbl

	GetPreferredTransmitPowerLevelInDBm uintptr
	SetPreferredTransmitPowerLevelInDBm uintptr
	GetUseExtendedAdvertisement         uintptr
	SetUseExtendedAdvertisement         uintptr
	GetIsAnonymous                      uintptr
	SetIsAnonymous                      uintptr
	GetIncludeTransmitPowerLevel        uintptr
	SetIncludeTransmitPowerLevel        uintptr
}

func (v *iBluetoothLEAdvertisementPublisher2) VTable() *iBluetoothLEAdvertisementPublisher2Vtbl {
	return (*iBluetoothLEAdvertisementPublisher2Vtbl)(unsafe.Pointer(v.RawVTable))
}
