// Code generated by winrt-go-gen. DO NOT EDIT. //go:build windows //nolint:all package geolocation import ( "syscall" "unsafe" "github.com/go-ole/go-ole" "github.com/saltosystems/winrt-go/windows/foundation" ) const SignatureGeolocator string = "rc(Windows.Devices.Geolocation.Geolocator;{a9c3bf62-4524-4989-8aa9-de019d2e551f})" type Geolocator struct { ole.IUnknown } func NewGeolocator() (*Geolocator, error) { inspectable, err := ole.RoActivateInstance("Windows.Devices.Geolocation.Geolocator") if err != nil { return nil, err } return (*Geolocator)(unsafe.Pointer(inspectable)), nil } func (impl *Geolocator) GetDesiredAccuracy() (PositionAccuracy, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.GetDesiredAccuracy() } func (impl *Geolocator) SetDesiredAccuracy(value PositionAccuracy) error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.SetDesiredAccuracy(value) } func (impl *Geolocator) GetMovementThreshold() (float64, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.GetMovementThreshold() } func (impl *Geolocator) SetMovementThreshold(value float64) error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.SetMovementThreshold(value) } func (impl *Geolocator) GetReportInterval() (uint32, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.GetReportInterval() } func (impl *Geolocator) SetReportInterval(value uint32) error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.SetReportInterval(value) } func (impl *Geolocator) GetLocationStatus() (PositionStatus, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.GetLocationStatus() } func (impl *Geolocator) GetGeopositionAsync() (*foundation.IAsyncOperation, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.GetGeopositionAsync() } func (impl *Geolocator) GetGeopositionAsyncWithAgeAndTimeout(maximumAge foundation.TimeSpan, timeout foundation.TimeSpan) (*foundation.IAsyncOperation, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.GetGeopositionAsyncWithAgeAndTimeout(maximumAge, timeout) } func (impl *Geolocator) AddPositionChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.AddPositionChanged(handler) } func (impl *Geolocator) RemovePositionChanged(token foundation.EventRegistrationToken) error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.RemovePositionChanged(token) } func (impl *Geolocator) AddStatusChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.AddStatusChanged(handler) } func (impl *Geolocator) RemoveStatusChanged(token foundation.EventRegistrationToken) error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator)) defer itf.Release() v := (*iGeolocator)(unsafe.Pointer(itf)) return v.RemoveStatusChanged(token) } func (impl *Geolocator) GetDesiredAccuracyInMeters() (*foundation.IReference, error) { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocatorWithScalarAccuracy)) defer itf.Release() v := (*iGeolocatorWithScalarAccuracy)(unsafe.Pointer(itf)) return v.GetDesiredAccuracyInMeters() } func (impl *Geolocator) SetDesiredAccuracyInMeters(value *foundation.IReference) error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocatorWithScalarAccuracy)) defer itf.Release() v := (*iGeolocatorWithScalarAccuracy)(unsafe.Pointer(itf)) return v.SetDesiredAccuracyInMeters(value) } func (impl *Geolocator) AllowFallbackToConsentlessPositions() error { itf := impl.MustQueryInterface(ole.NewGUID(GUIDiGeolocator2)) defer itf.Release() v := (*iGeolocator2)(unsafe.Pointer(itf)) return v.AllowFallbackToConsentlessPositions() } const GUIDiGeolocator string = "a9c3bf62-4524-4989-8aa9-de019d2e551f" const SignatureiGeolocator string = "{a9c3bf62-4524-4989-8aa9-de019d2e551f}" type iGeolocator struct { ole.IInspectable } type iGeolocatorVtbl struct { ole.IInspectableVtbl GetDesiredAccuracy uintptr SetDesiredAccuracy uintptr GetMovementThreshold uintptr SetMovementThreshold uintptr GetReportInterval uintptr SetReportInterval uintptr GetLocationStatus uintptr GetGeopositionAsync uintptr GetGeopositionAsyncWithAgeAndTimeout uintptr AddPositionChanged uintptr RemovePositionChanged uintptr AddStatusChanged uintptr RemoveStatusChanged uintptr } func (v *iGeolocator) VTable() *iGeolocatorVtbl { return (*iGeolocatorVtbl)(unsafe.Pointer(v.RawVTable)) } func (v *iGeolocator) GetDesiredAccuracy() (PositionAccuracy, error) { var out PositionAccuracy hr, _, _ := syscall.SyscallN( v.VTable().GetDesiredAccuracy, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out PositionAccuracy ) if hr != 0 { return PositionAccuracyDefault, ole.NewError(hr) } return out, nil } func (v *iGeolocator) SetDesiredAccuracy(value PositionAccuracy) error { hr, _, _ := syscall.SyscallN( v.VTable().SetDesiredAccuracy, uintptr(unsafe.Pointer(v)), // this uintptr(value), // in PositionAccuracy ) if hr != 0 { return ole.NewError(hr) } return nil } func (v *iGeolocator) GetMovementThreshold() (float64, error) { var out float64 hr, _, _ := syscall.SyscallN( v.VTable().GetMovementThreshold, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out float64 ) if hr != 0 { return 0.0, ole.NewError(hr) } return out, nil } func (v *iGeolocator) SetMovementThreshold(value float64) error { hr, _, _ := syscall.SyscallN( v.VTable().SetMovementThreshold, uintptr(unsafe.Pointer(v)), // this uintptr(value), // in float64 ) if hr != 0 { return ole.NewError(hr) } return nil } func (v *iGeolocator) GetReportInterval() (uint32, error) { var out uint32 hr, _, _ := syscall.SyscallN( v.VTable().GetReportInterval, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out uint32 ) if hr != 0 { return 0, ole.NewError(hr) } return out, nil } func (v *iGeolocator) SetReportInterval(value uint32) error { hr, _, _ := syscall.SyscallN( v.VTable().SetReportInterval, uintptr(unsafe.Pointer(v)), // this uintptr(value), // in uint32 ) if hr != 0 { return ole.NewError(hr) } return nil } func (v *iGeolocator) GetLocationStatus() (PositionStatus, error) { var out PositionStatus hr, _, _ := syscall.SyscallN( v.VTable().GetLocationStatus, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out PositionStatus ) if hr != 0 { return PositionStatusReady, ole.NewError(hr) } return out, nil } func (v *iGeolocator) GetGeopositionAsync() (*foundation.IAsyncOperation, error) { var out *foundation.IAsyncOperation hr, _, _ := syscall.SyscallN( v.VTable().GetGeopositionAsync, 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 *iGeolocator) GetGeopositionAsyncWithAgeAndTimeout(maximumAge foundation.TimeSpan, timeout foundation.TimeSpan) (*foundation.IAsyncOperation, error) { var out *foundation.IAsyncOperation hr, _, _ := syscall.SyscallN( v.VTable().GetGeopositionAsyncWithAgeAndTimeout, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&maximumAge)), // in foundation.TimeSpan uintptr(unsafe.Pointer(&timeout)), // in foundation.TimeSpan uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation ) if hr != 0 { return nil, ole.NewError(hr) } return out, nil } func (v *iGeolocator) AddPositionChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { var out foundation.EventRegistrationToken hr, _, _ := syscall.SyscallN( v.VTable().AddPositionChanged, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken ) if hr != 0 { return foundation.EventRegistrationToken{}, ole.NewError(hr) } return out, nil } func (v *iGeolocator) RemovePositionChanged(token foundation.EventRegistrationToken) error { hr, _, _ := syscall.SyscallN( v.VTable().RemovePositionChanged, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken ) if hr != 0 { return ole.NewError(hr) } return nil } func (v *iGeolocator) AddStatusChanged(handler *foundation.TypedEventHandler) (foundation.EventRegistrationToken, error) { var out foundation.EventRegistrationToken hr, _, _ := syscall.SyscallN( v.VTable().AddStatusChanged, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(handler)), // in foundation.TypedEventHandler uintptr(unsafe.Pointer(&out)), // out foundation.EventRegistrationToken ) if hr != 0 { return foundation.EventRegistrationToken{}, ole.NewError(hr) } return out, nil } func (v *iGeolocator) RemoveStatusChanged(token foundation.EventRegistrationToken) error { hr, _, _ := syscall.SyscallN( v.VTable().RemoveStatusChanged, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&token)), // in foundation.EventRegistrationToken ) if hr != 0 { return ole.NewError(hr) } return nil } const GUIDiGeolocatorWithScalarAccuracy string = "96f5d3c1-b80f-460a-994d-a96c47a51aa4" const SignatureiGeolocatorWithScalarAccuracy string = "{96f5d3c1-b80f-460a-994d-a96c47a51aa4}" type iGeolocatorWithScalarAccuracy struct { ole.IInspectable } type iGeolocatorWithScalarAccuracyVtbl struct { ole.IInspectableVtbl GetDesiredAccuracyInMeters uintptr SetDesiredAccuracyInMeters uintptr } func (v *iGeolocatorWithScalarAccuracy) VTable() *iGeolocatorWithScalarAccuracyVtbl { return (*iGeolocatorWithScalarAccuracyVtbl)(unsafe.Pointer(v.RawVTable)) } func (v *iGeolocatorWithScalarAccuracy) GetDesiredAccuracyInMeters() (*foundation.IReference, error) { var out *foundation.IReference hr, _, _ := syscall.SyscallN( v.VTable().GetDesiredAccuracyInMeters, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out foundation.IReference ) if hr != 0 { return nil, ole.NewError(hr) } return out, nil } func (v *iGeolocatorWithScalarAccuracy) SetDesiredAccuracyInMeters(value *foundation.IReference) error { hr, _, _ := syscall.SyscallN( v.VTable().SetDesiredAccuracyInMeters, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(value)), // in foundation.IReference ) if hr != 0 { return ole.NewError(hr) } return nil } const GUIDiGeolocator2 string = "d1b42e6d-8891-43b4-ad36-27c6fe9a97b1" const SignatureiGeolocator2 string = "{d1b42e6d-8891-43b4-ad36-27c6fe9a97b1}" type iGeolocator2 struct { ole.IInspectable } type iGeolocator2Vtbl struct { ole.IInspectableVtbl AllowFallbackToConsentlessPositions uintptr } func (v *iGeolocator2) VTable() *iGeolocator2Vtbl { return (*iGeolocator2Vtbl)(unsafe.Pointer(v.RawVTable)) } func (v *iGeolocator2) AllowFallbackToConsentlessPositions() error { hr, _, _ := syscall.SyscallN( v.VTable().AllowFallbackToConsentlessPositions, uintptr(unsafe.Pointer(v)), // this ) if hr != 0 { return ole.NewError(hr) } return nil } const GUIDiGeolocatorStatics string = "9a8e7571-2df5-4591-9f87-eb5fd894e9b7" const SignatureiGeolocatorStatics string = "{9a8e7571-2df5-4591-9f87-eb5fd894e9b7}" type iGeolocatorStatics struct { ole.IInspectable } type iGeolocatorStaticsVtbl struct { ole.IInspectableVtbl GeolocatorRequestAccessAsync uintptr GeolocatorGetGeopositionHistoryAsync uintptr GeolocatorGetGeopositionHistoryWithDurationAsync uintptr } func (v *iGeolocatorStatics) VTable() *iGeolocatorStaticsVtbl { return (*iGeolocatorStaticsVtbl)(unsafe.Pointer(v.RawVTable)) } func GeolocatorRequestAccessAsync() (*foundation.IAsyncOperation, error) { inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Geolocation.Geolocator", ole.NewGUID(GUIDiGeolocatorStatics)) if err != nil { return nil, err } v := (*iGeolocatorStatics)(unsafe.Pointer(inspectable)) var out *foundation.IAsyncOperation hr, _, _ := syscall.SyscallN( v.VTable().GeolocatorRequestAccessAsync, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation ) if hr != 0 { return nil, ole.NewError(hr) } return out, nil } func GeolocatorGetGeopositionHistoryAsync(startTime foundation.DateTime) (*foundation.IAsyncOperation, error) { inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Geolocation.Geolocator", ole.NewGUID(GUIDiGeolocatorStatics)) if err != nil { return nil, err } v := (*iGeolocatorStatics)(unsafe.Pointer(inspectable)) var out *foundation.IAsyncOperation hr, _, _ := syscall.SyscallN( v.VTable().GeolocatorGetGeopositionHistoryAsync, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&startTime)), // in foundation.DateTime uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation ) if hr != 0 { return nil, ole.NewError(hr) } return out, nil } func GeolocatorGetGeopositionHistoryWithDurationAsync(startTime foundation.DateTime, duration foundation.TimeSpan) (*foundation.IAsyncOperation, error) { inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Geolocation.Geolocator", ole.NewGUID(GUIDiGeolocatorStatics)) if err != nil { return nil, err } v := (*iGeolocatorStatics)(unsafe.Pointer(inspectable)) var out *foundation.IAsyncOperation hr, _, _ := syscall.SyscallN( v.VTable().GeolocatorGetGeopositionHistoryWithDurationAsync, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&startTime)), // in foundation.DateTime uintptr(unsafe.Pointer(&duration)), // in foundation.TimeSpan uintptr(unsafe.Pointer(&out)), // out foundation.IAsyncOperation ) if hr != 0 { return nil, ole.NewError(hr) } return out, nil } const GUIDiGeolocatorStatics2 string = "993011a2-fa1c-4631-a71d-0dbeb1250d9c" const SignatureiGeolocatorStatics2 string = "{993011a2-fa1c-4631-a71d-0dbeb1250d9c}" type iGeolocatorStatics2 struct { ole.IInspectable } type iGeolocatorStatics2Vtbl struct { ole.IInspectableVtbl GeolocatorGetIsDefaultGeopositionRecommended uintptr GeolocatorSetDefaultGeoposition uintptr GeolocatorGetDefaultGeoposition uintptr } func (v *iGeolocatorStatics2) VTable() *iGeolocatorStatics2Vtbl { return (*iGeolocatorStatics2Vtbl)(unsafe.Pointer(v.RawVTable)) } func GeolocatorGetIsDefaultGeopositionRecommended() (bool, error) { inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Geolocation.Geolocator", ole.NewGUID(GUIDiGeolocatorStatics2)) if err != nil { return false, err } v := (*iGeolocatorStatics2)(unsafe.Pointer(inspectable)) var out bool hr, _, _ := syscall.SyscallN( v.VTable().GeolocatorGetIsDefaultGeopositionRecommended, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out bool ) if hr != 0 { return false, ole.NewError(hr) } return out, nil } func GeolocatorSetDefaultGeoposition(value *foundation.IReference) error { inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Geolocation.Geolocator", ole.NewGUID(GUIDiGeolocatorStatics2)) if err != nil { return err } v := (*iGeolocatorStatics2)(unsafe.Pointer(inspectable)) hr, _, _ := syscall.SyscallN( v.VTable().GeolocatorSetDefaultGeoposition, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(value)), // in foundation.IReference ) if hr != 0 { return ole.NewError(hr) } return nil } func GeolocatorGetDefaultGeoposition() (*foundation.IReference, error) { inspectable, err := ole.RoGetActivationFactory("Windows.Devices.Geolocation.Geolocator", ole.NewGUID(GUIDiGeolocatorStatics2)) if err != nil { return nil, err } v := (*iGeolocatorStatics2)(unsafe.Pointer(inspectable)) var out *foundation.IReference hr, _, _ := syscall.SyscallN( v.VTable().GeolocatorGetDefaultGeoposition, uintptr(unsafe.Pointer(v)), // this uintptr(unsafe.Pointer(&out)), // out foundation.IReference ) if hr != 0 { return nil, ole.NewError(hr) } return out, nil }