// 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/devices/bluetooth"
	"git.savin.nyc/alex/go-winrt/windows/foundation"
	"github.com/go-ole/go-ole"
)

const SignatureGattDeviceService string = "rc(Windows.Devices.Bluetooth.GenericAttributeProfile.GattDeviceService;{ac7b7c05-b33c-47cf-990f-6b8f5577df71})"

type GattDeviceService struct {
	ole.IUnknown
}

func (impl *GattDeviceService) GetUuid() (syscall.GUID, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattDeviceService))
	defer itf.Release()
	v := (*iGattDeviceService)(unsafe.Pointer(itf))
	return v.GetUuid()
}

func (impl *GattDeviceService) Close() error {
	itf := impl.MustQueryInterface(ole.NewGUID(foundation.GUIDIClosable))
	defer itf.Release()
	v := (*foundation.IClosable)(unsafe.Pointer(itf))
	return v.Close()
}

func (impl *GattDeviceService) GetCharacteristicsAsync() (*foundation.IAsyncOperation, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattDeviceService3))
	defer itf.Release()
	v := (*iGattDeviceService3)(unsafe.Pointer(itf))
	return v.GetCharacteristicsAsync()
}

func (impl *GattDeviceService) GetCharacteristicsWithCacheModeAsync(cacheMode bluetooth.BluetoothCacheMode) (*foundation.IAsyncOperation, error) {
	itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGattDeviceService3))
	defer itf.Release()
	v := (*iGattDeviceService3)(unsafe.Pointer(itf))
	return v.GetCharacteristicsWithCacheModeAsync(cacheMode)
}

const GUIDiGattDeviceService string = "ac7b7c05-b33c-47cf-990f-6b8f5577df71"
const SignatureiGattDeviceService string = "{ac7b7c05-b33c-47cf-990f-6b8f5577df71}"

type iGattDeviceService struct {
	ole.IInspectable
}

type iGattDeviceServiceVtbl struct {
	ole.IInspectableVtbl

	GetCharacteristics  uintptr
	GetIncludedServices uintptr
	GetDeviceId         uintptr
	GetUuid             uintptr
	GetAttributeHandle  uintptr
}

func (v *iGattDeviceService) VTable() *iGattDeviceServiceVtbl {
	return (*iGattDeviceServiceVtbl)(unsafe.Pointer(v.RawVTable))
}

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

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

	return out, nil
}

const GUIDiGattDeviceService2 string = "fc54520b-0b0d-4708-bae0-9ffd9489bc59"
const SignatureiGattDeviceService2 string = "{fc54520b-0b0d-4708-bae0-9ffd9489bc59}"

type iGattDeviceService2 struct {
	ole.IInspectable
}

type iGattDeviceService2Vtbl struct {
	ole.IInspectableVtbl

	GetDevice              uintptr
	GetParentServices      uintptr
	GetAllCharacteristics  uintptr
	GetAllIncludedServices uintptr
}

func (v *iGattDeviceService2) VTable() *iGattDeviceService2Vtbl {
	return (*iGattDeviceService2Vtbl)(unsafe.Pointer(v.RawVTable))
}

const GUIDiGattDeviceService3 string = "b293a950-0c53-437c-a9b3-5c3210c6e569"
const SignatureiGattDeviceService3 string = "{b293a950-0c53-437c-a9b3-5c3210c6e569}"

type iGattDeviceService3 struct {
	ole.IInspectable
}

type iGattDeviceService3Vtbl struct {
	ole.IInspectableVtbl

	GetDeviceAccessInformation                   uintptr
	GetSession                                   uintptr
	GetSharingMode                               uintptr
	RequestAccessAsync                           uintptr
	OpenAsync                                    uintptr
	GetCharacteristicsAsync                      uintptr
	GetCharacteristicsWithCacheModeAsync         uintptr
	GetCharacteristicsForUuidAsync               uintptr
	GetCharacteristicsForUuidWithCacheModeAsync  uintptr
	GetIncludedServicesAsync                     uintptr
	GetIncludedServicesWithCacheModeAsync        uintptr
	GetIncludedServicesForUuidAsync              uintptr
	GetIncludedServicesForUuidWithCacheModeAsync uintptr
}

func (v *iGattDeviceService3) VTable() *iGattDeviceService3Vtbl {
	return (*iGattDeviceService3Vtbl)(unsafe.Pointer(v.RawVTable))
}

func (v *iGattDeviceService3) GetCharacteristicsAsync() (*foundation.IAsyncOperation, error) {
	var out *foundation.IAsyncOperation
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetCharacteristicsAsync,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation
	)

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

	return out, nil
}

func (v *iGattDeviceService3) GetCharacteristicsWithCacheModeAsync(cacheMode bluetooth.BluetoothCacheMode) (*foundation.IAsyncOperation, error) {
	var out *foundation.IAsyncOperation
	hr, _, _ := syscall.SyscallN(
		v.VTable().GetCharacteristicsWithCacheModeAsync,
		uintptr(unsafe.Pointer(v)),    // this
		uintptr(cacheMode),            // in bluetooth.BluetoothCacheMode
		uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation
	)

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

	return out, nil
}
