Commit abc0c3c1 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

twinapi.appcore: Stub Windows.System.UserProfile.AdvertisingManager factory.

parent 81fb29bf
......@@ -3,6 +3,7 @@ MODULE = twinapi.appcore.dll
IMPORTS = combase advapi32
SOURCES = \
advertising_manager.c \
analytics_info.c \
classes.idl \
client_device_information.c \
......
/* WinRT Windows.Globalization implementation
*
* Copyright 2021 Rémi Bernon for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "private.h"
WINE_DEFAULT_DEBUG_CHANNEL(twinapi);
struct factory
{
IActivationFactory IActivationFactory_iface;
IAdvertisingManagerStatics IAdvertisingManagerStatics_iface;
LONG ref;
};
static inline struct factory *impl_from_IActivationFactory( IActivationFactory *iface )
{
return CONTAINING_RECORD( iface, struct factory, IActivationFactory_iface );
}
static HRESULT WINAPI activation_factory_QueryInterface( IActivationFactory *iface, REFIID iid, void **out )
{
struct factory *impl = impl_from_IActivationFactory( iface );
TRACE( "iface %p, iid %s, out %p stub!\n", iface, debugstr_guid( iid ), out );
if (IsEqualGUID( iid, &IID_IUnknown ) ||
IsEqualGUID( iid, &IID_IInspectable ) ||
IsEqualGUID( iid, &IID_IAgileObject ) ||
IsEqualGUID( iid, &IID_IActivationFactory ))
{
IActivationFactory_AddRef( (*out = &impl->IActivationFactory_iface) );
return S_OK;
}
if (IsEqualGUID( iid, &IID_IAdvertisingManagerStatics ))
{
IAdvertisingManagerStatics_AddRef( (*out = &impl->IAdvertisingManagerStatics_iface) );
return S_OK;
}
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) );
*out = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI activation_factory_AddRef( IActivationFactory *iface )
{
struct factory *impl = impl_from_IActivationFactory( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p, ref %lu.\n", iface, ref );
return ref;
}
static ULONG WINAPI activation_factory_Release( IActivationFactory *iface )
{
struct factory *impl = impl_from_IActivationFactory( iface );
ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "iface %p, ref %lu.\n", iface, ref );
return ref;
}
static HRESULT WINAPI activation_factory_GetIids( IActivationFactory *iface, ULONG *iid_count, IID **iids )
{
FIXME( "iface %p, iid_count %p, iids %p stub!\n", iface, iid_count, iids );
return E_NOTIMPL;
}
static HRESULT WINAPI activation_factory_GetRuntimeClassName( IActivationFactory *iface, HSTRING *class_name )
{
FIXME( "iface %p, class_name %p stub!\n", iface, class_name );
return E_NOTIMPL;
}
static HRESULT WINAPI activation_factory_GetTrustLevel( IActivationFactory *iface, TrustLevel *trust_level )
{
FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
return E_NOTIMPL;
}
static HRESULT WINAPI activation_factory_ActivateInstance( IActivationFactory *iface, IInspectable **instance )
{
FIXME( "iface %p, instance %p stub!\n", iface, instance );
return E_NOTIMPL;
}
static const struct IActivationFactoryVtbl activation_factory_vtbl =
{
activation_factory_QueryInterface,
activation_factory_AddRef,
activation_factory_Release,
/* IInspectable methods */
activation_factory_GetIids,
activation_factory_GetRuntimeClassName,
activation_factory_GetTrustLevel,
/* IActivationFactory methods */
activation_factory_ActivateInstance,
};
DEFINE_IINSPECTABLE( statics, IAdvertisingManagerStatics, struct factory, IActivationFactory_iface )
static HRESULT WINAPI statics_get_AdvertisingId( IAdvertisingManagerStatics *iface, HSTRING *out )
{
FIXME( "iface %p, out %p stub!\n", iface, out );
return E_NOTIMPL;
}
static const struct IAdvertisingManagerStaticsVtbl statics_vtbl =
{
statics_QueryInterface,
statics_AddRef,
statics_Release,
/* IInspectable methods */
statics_GetIids,
statics_GetRuntimeClassName,
statics_GetTrustLevel,
/* IAdvertisingManagerStatics methods */
statics_get_AdvertisingId,
};
static struct factory factory =
{
{&activation_factory_vtbl},
{&statics_vtbl},
1,
};
IActivationFactory *advertising_manager_factory = &factory.IActivationFactory_iface;
......@@ -30,5 +30,7 @@ import "windows.foundation.idl";
import "windows.globalization.idl";
#define DO_NO_IMPORTS
#define _TWINAPI_APPCORE
#include "windows.security.exchangeactivesyncprovisioning.idl"
#include "windows.system.profile.idl"
#include "windows.system.userprofile.idl"
......@@ -73,6 +73,8 @@ HRESULT WINAPI DllGetActivationFactory( HSTRING classid, IActivationFactory **fa
IActivationFactory_QueryInterface( client_device_information_factory, &IID_IActivationFactory, (void **)factory );
else if (!wcscmp( buffer, RuntimeClass_Windows_System_Profile_AnalyticsInfo ))
IActivationFactory_QueryInterface( analytics_info_factory, &IID_IActivationFactory, (void **)factory );
else if (!wcscmp( buffer, RuntimeClass_Windows_System_UserProfile_AdvertisingManager ))
IActivationFactory_QueryInterface( advertising_manager_factory, &IID_IActivationFactory, (void **)factory );
if (*factory) return S_OK;
return CLASS_E_CLASSNOTAVAILABLE;
......
......@@ -43,6 +43,7 @@
extern IActivationFactory *client_device_information_factory;
extern IActivationFactory *analytics_info_factory;
extern IActivationFactory *advertising_manager_factory;
#define DEFINE_IINSPECTABLE_( pfx, iface_type, impl_type, impl_from, iface_mem, expr ) \
static inline impl_type *impl_from( iface_type *iface ) \
......
......@@ -40,16 +40,18 @@
#include "wine/test.h"
#define check_interface( a, b, c ) check_interface_( __LINE__, a, b, c )
static void check_interface_( unsigned int line, void *iface_ptr, REFIID iid, BOOL supported )
#define check_interface( a, b, c ) check_interface_( __LINE__, a, b, c, FALSE )
static void check_interface_( unsigned int line, void *iface_ptr, REFIID iid, BOOL supported, BOOL is_broken )
{
HRESULT hr, expected_hr, broken_hr;
IUnknown *iface = iface_ptr;
HRESULT hr, expected;
IUnknown *unk;
expected = supported ? S_OK : E_NOINTERFACE;
expected_hr = supported ? S_OK : E_NOINTERFACE;
broken_hr = supported ? E_NOINTERFACE : S_OK;
hr = IUnknown_QueryInterface( iface, iid, (void **)&unk );
ok_ (__FILE__, line)( hr == expected, "got hr %#lx, expected %#lx.\n", hr, expected );
ok_(__FILE__, line)( hr == expected_hr || broken( is_broken && hr == broken_hr ),
"got hr %#lx, expected %#lx.\n", hr, expected_hr );
if (SUCCEEDED(hr)) IUnknown_Release( unk );
}
......@@ -190,6 +192,40 @@ static void test_AnalyticsVersionInfo(void)
ok( ref == 1, "got ref %ld.\n", ref );
}
static void test_AdvertisingManager(void)
{
static const WCHAR *class_name = RuntimeClass_Windows_System_UserProfile_AdvertisingManager;
IAdvertisingManagerStatics *advertising_manager_statics;
IActivationFactory *factory;
HSTRING str;
HRESULT hr;
LONG ref;
hr = WindowsCreateString( class_name, wcslen( class_name ), &str );
ok( hr == S_OK, "got hr %#lx.\n", hr );
hr = RoGetActivationFactory( str, &IID_IActivationFactory, (void **)&factory );
WindowsDeleteString( str );
ok( hr == S_OK || broken( hr == REGDB_E_CLASSNOTREG ), "got hr %#lx.\n", hr );
if (hr == REGDB_E_CLASSNOTREG)
{
win_skip( "%s runtimeclass not registered, skipping tests.\n", wine_dbgstr_w( class_name ) );
return;
}
check_interface( factory, &IID_IUnknown, TRUE );
check_interface( factory, &IID_IInspectable, TRUE );
check_interface_( __LINE__, factory, &IID_IAgileObject, TRUE, TRUE );
hr = IActivationFactory_QueryInterface( factory, &IID_IAdvertisingManagerStatics, (void **)&advertising_manager_statics );
ok( hr == S_OK, "got hr %#lx.\n", hr );
ref = IAdvertisingManagerStatics_Release( advertising_manager_statics );
ok( ref == 2, "got ref %ld.\n", ref );
ref = IActivationFactory_Release( factory );
ok( ref == 1, "got ref %ld.\n", ref );
}
START_TEST(twinapi)
{
HRESULT hr;
......@@ -199,6 +235,7 @@ START_TEST(twinapi)
test_EasClientDeviceInformation();
test_AnalyticsVersionInfo();
test_AdvertisingManager();
RoUninitialize();
}
......@@ -31,5 +31,6 @@ import "windowscontracts.idl";
import "windows.foundation.idl";
#define DO_NO_IMPORTS
#define _WINDOWS_GLOBALIZATION
#include "windows.globalization.idl"
#include "windows.system.userprofile.idl"
......@@ -64,6 +64,7 @@ namespace Windows.System.UserProfile {
[propget] HRESULT AdvertisingId([out, retval] HSTRING *value);
}
#ifndef _TWINAPI_APPCORE
[
contract(Windows.Foundation.UniversalApiContract, 1.0),
marshaling_behavior(agile),
......@@ -74,7 +75,9 @@ namespace Windows.System.UserProfile {
runtimeclass GlobalizationPreferences
{
}
#endif
#ifndef _WINDOWS_GLOBALIZATION
[
contract(Windows.Foundation.UniversalApiContract, 1.0),
marshaling_behavior(standard),
......@@ -84,5 +87,6 @@ namespace Windows.System.UserProfile {
runtimeclass AdvertisingManager
{
}
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment