From: Fabian Maurer dark.shadow4@web.de
--- .../main.c | 137 +++++++++++++++++- .../private.h | 40 +++++ 2 files changed, 175 insertions(+), 2 deletions(-)
diff --git a/dlls/windows.devices.geolocation.geolocator/main.c b/dlls/windows.devices.geolocation.geolocator/main.c index 4cc7faeec36..e364df0a0f3 100644 --- a/dlls/windows.devices.geolocation.geolocator/main.c +++ b/dlls/windows.devices.geolocation.geolocator/main.c @@ -36,9 +36,118 @@ static const char *debugstr_hstring(HSTRING hstr) struct geolocator { IActivationFactory IActivationFactory_iface; + IGeolocator IGeolocator_iface; LONG ref; };
+DEFINE_IINSPECTABLE(geolocator, IGeolocator, struct geolocator, IActivationFactory_iface) + +HRESULT WINAPI geolocator_DesiredAccuracy_get(IGeolocator *iface, PositionAccuracy *value) +{ + FIXME("iface %p, value %p stub.\n", iface, value); + *value = 0; + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_DesiredAccuracy_set(IGeolocator *iface, PositionAccuracy value) +{ + FIXME("iface %p, value %d stub.\n", iface, value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_MovementThreshold_get(IGeolocator *iface, DOUBLE *value) +{ + FIXME("iface %p, value %p stub.\n", iface, value); + *value = 0; + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_MovementThreshold_set(IGeolocator *iface, DOUBLE value) +{ + FIXME("iface %p, value %f stub.\n", iface, value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_ReportInterval_get(IGeolocator *iface, UINT32 *value) +{ + FIXME("iface %p, value %p stub.\n", iface, value); + *value = 0; + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_ReportInterval_set(IGeolocator *iface, UINT32 value) +{ + FIXME("iface %p, value %u stub.\n", iface, value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_LocationStatus(IGeolocator *iface, PositionStatus *value) +{ + FIXME("iface %p, value %p stub.\n", iface, value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_GetGeopositionAsync(IGeolocator *iface, IAsyncOperation_Geoposition **value) +{ + FIXME("iface %p, value %p stub.\n", iface, value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_GetGeopositionAsyncWithAgeAndTimeout(IGeolocator *iface, TimeSpan maximumAge, TimeSpan timeout, IAsyncOperation_Geoposition **value) +{ + FIXME("iface %p, maximumAge %#I64x, timeout %#I64x, value %p stub.\n", iface, maximumAge.Duration, timeout.Duration, value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_PositionChanged_add(IGeolocator *iface, ITypedEventHandler_Geolocator_PositionChangedEventArgs *handler, EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub.\n", iface, handler, token); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_PositionChanged_remove(IGeolocator *iface, EventRegistrationToken token) +{ + FIXME("iface %p, token %#I64x stub.\n", iface, token.value); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_StatusChanged_add(IGeolocator *iface, ITypedEventHandler_Geolocator_StatusChangedEventArgs *handler, EventRegistrationToken *token) +{ + FIXME("iface %p, handler %p, token %p stub.\n", iface, handler, token); + return E_NOTIMPL; +} + +HRESULT WINAPI geolocator_StatusChanged_remove(IGeolocator *iface, EventRegistrationToken token) +{ + FIXME("iface %p, token %#I64x stub.\n", iface, token.value); + return E_NOTIMPL; +} + +static const struct IGeolocatorVtbl geolocator_vtbl = +{ + geolocator_QueryInterface, + geolocator_AddRef, + geolocator_Release, + /* IInspectable methods */ + geolocator_GetIids, + geolocator_GetRuntimeClassName, + geolocator_GetTrustLevel, + /* IGeolocator methods */ + geolocator_DesiredAccuracy_get, + geolocator_DesiredAccuracy_set, + geolocator_MovementThreshold_get, + geolocator_MovementThreshold_set, + geolocator_ReportInterval_get, + geolocator_ReportInterval_set, + geolocator_LocationStatus, + geolocator_GetGeopositionAsync, + geolocator_GetGeopositionAsyncWithAgeAndTimeout, + geolocator_PositionChanged_add, + geolocator_PositionChanged_remove, + geolocator_StatusChanged_add, + geolocator_StatusChanged_remove, +}; + static inline struct geolocator *impl_from_IActivationFactory(IActivationFactory *iface) { return CONTAINING_RECORD(iface, struct geolocator, IActivationFactory_iface); @@ -60,6 +169,13 @@ static HRESULT WINAPI factory_QueryInterface(IActivationFactory *iface, REFIID i return S_OK; }
+ if (IsEqualGUID(iid, &IID_IGeolocator)) + { + *out = &impl->IGeolocator_iface; + IInspectable_AddRef(*out); + return S_OK; + } + FIXME("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); *out = NULL; return E_NOINTERFACE; @@ -99,10 +215,26 @@ static HRESULT WINAPI factory_GetTrustLevel(IActivationFactory *iface, TrustLeve return E_NOTIMPL; }
+static const struct IActivationFactoryVtbl factory_vtbl; + static HRESULT WINAPI factory_ActivateInstance(IActivationFactory *iface, IInspectable **instance) { - FIXME("iface %p, instance %p stub!\n", iface, instance); - return E_NOTIMPL; + struct geolocator *impl; + + TRACE("iface %p, instance %p.\n", iface, instance); + + if (!(impl = calloc(1, sizeof(*impl)))) + { + *instance = NULL; + return E_OUTOFMEMORY; + } + + impl->IActivationFactory_iface.lpVtbl = &factory_vtbl; + impl->IGeolocator_iface.lpVtbl = &geolocator_vtbl; + impl->ref = 1; + + *instance = (IInspectable *)&impl->IGeolocator_iface; + return S_OK; }
static const struct IActivationFactoryVtbl factory_vtbl = @@ -121,6 +253,7 @@ static const struct IActivationFactoryVtbl factory_vtbl = static struct geolocator geolocator = { {&factory_vtbl}, + {&geolocator_vtbl}, 1, };
diff --git a/dlls/windows.devices.geolocation.geolocator/private.h b/dlls/windows.devices.geolocation.geolocator/private.h index b03c6cfc9d0..15e6720f73c 100644 --- a/dlls/windows.devices.geolocation.geolocator/private.h +++ b/dlls/windows.devices.geolocation.geolocator/private.h @@ -35,4 +35,44 @@ #define WIDL_using_Windows_Devices_Geolocation #include "windows.devices.geolocation.h"
+#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \ + static inline impl_type *impl_from( iface_type *iface ) \ + { \ + return CONTAINING_RECORD( iface, impl_type, iface_mem ); \ + } \ + static HRESULT WINAPI pfx##_QueryInterface( iface_type *iface, REFIID iid, void **out ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_QueryInterface( (IInspectable *)(expr), iid, out ); \ + } \ + static ULONG WINAPI pfx##_AddRef( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_AddRef( (IInspectable *)(expr) ); \ + } \ + static ULONG WINAPI pfx##_Release( iface_type *iface ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_Release( (IInspectable *)(expr) ); \ + } \ + static HRESULT WINAPI pfx##_GetIids( iface_type *iface, ULONG *iid_count, IID **iids ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetIids( (IInspectable *)(expr), iid_count, iids ); \ + } \ + static HRESULT WINAPI pfx##_GetRuntimeClassName( iface_type *iface, HSTRING *class_name ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetRuntimeClassName( (IInspectable *)(expr), class_name ); \ + } \ + static HRESULT WINAPI pfx##_GetTrustLevel( iface_type *iface, TrustLevel *trust_level ) \ + { \ + impl_type *impl = impl_from( iface ); \ + return IInspectable_GetTrustLevel( (IInspectable *)(expr), trust_level ); \ + } +#define DEFINE_IINSPECTABLE( pfx, iface_type, impl_type, base_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, &impl->base_iface ) +#define DEFINE_IINSPECTABLE_OUTER( pfx, iface_type, impl_type, outer_iface ) \ + DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from_##iface_type, iface_type##_iface, impl->outer_iface ) + #endif