Commit ee567bb1 authored by Mohamad Al-Jaf's avatar Mohamad Al-Jaf Committed by Alexandre Julliard

windows.applicationmodel: Implement IPackageStatics::get_Current().

parent 612375a5
......@@ -115,14 +115,134 @@ static const struct IActivationFactoryVtbl factory_vtbl =
factory_ActivateInstance,
};
DEFINE_IINSPECTABLE( package_statics, IPackageStatics, struct package_statics, IActivationFactory_iface )
struct package
{
IPackage IPackage_iface;
LONG ref;
};
static HRESULT WINAPI package_statics_get_Current( IPackageStatics *iface, IPackage **value )
static inline struct package *impl_from_IPackage( IPackage *iface )
{
return CONTAINING_RECORD( iface, struct package, IPackage_iface );
}
static HRESULT WINAPI package_QueryInterface( IPackage *iface, REFIID iid, void **out )
{
struct package *impl = impl_from_IPackage( iface );
TRACE( "iface %p, iid %s, out %p.\n", iface, debugstr_guid( iid ), out );
if (IsEqualGUID( iid, &IID_IUnknown ) ||
IsEqualGUID( iid, &IID_IInspectable ) ||
IsEqualGUID( iid, &IID_IAgileObject ) ||
IsEqualGUID( iid, &IID_IPackage ))
{
*out = &impl->IPackage_iface;
IInspectable_AddRef( *out );
return S_OK;
}
FIXME( "%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid( iid ) );
*out = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI package_AddRef( IPackage *iface )
{
struct package *impl = impl_from_IPackage( iface );
ULONG ref = InterlockedIncrement( &impl->ref );
TRACE( "iface %p increasing refcount to %lu.\n", iface, ref );
return ref;
}
static ULONG WINAPI package_Release( IPackage *iface )
{
struct package *impl = impl_from_IPackage( iface );
ULONG ref = InterlockedDecrement( &impl->ref );
TRACE( "iface %p decreasing refcount to %lu.\n", iface, ref );
if (!ref) free( impl );
return ref;
}
static HRESULT WINAPI package_GetIids( IPackage *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 package_GetRuntimeClassName( IPackage *iface, HSTRING *class_name )
{
FIXME( "iface %p, class_name %p stub!\n", iface, class_name );
return E_NOTIMPL;
}
static HRESULT WINAPI package_GetTrustLevel( IPackage *iface, TrustLevel *trust_level )
{
FIXME( "iface %p, trust_level %p stub!\n", iface, trust_level );
return E_NOTIMPL;
}
static HRESULT WINAPI package_get_Id( IPackage *iface, IPackageId **value )
{
FIXME( "iface %p, value %p stub!\n", iface, value );
return E_NOTIMPL;
}
static HRESULT WINAPI package_get_InstalledLocation( IPackage *iface, IStorageFolder **value )
{
FIXME( "iface %p, value %p stub!\n", iface, value );
return E_NOTIMPL;
}
static HRESULT WINAPI package_get_IsFramework( IPackage *iface, boolean *value )
{
FIXME( "iface %p, value %p stub!\n", iface, value );
return E_NOTIMPL;
}
static HRESULT WINAPI package_get_Dependencies( IPackage *iface, IVectorView_Package **value )
{
FIXME( "iface %p, value %p stub!\n", iface, value );
return E_NOTIMPL;
}
static const struct IPackageVtbl package_vtbl =
{
package_QueryInterface,
package_AddRef,
package_Release,
/* IInspectable methods */
package_GetIids,
package_GetRuntimeClassName,
package_GetTrustLevel,
/* IPackage methods */
package_get_Id,
package_get_InstalledLocation,
package_get_IsFramework,
package_get_Dependencies,
};
DEFINE_IINSPECTABLE( package_statics, IPackageStatics, struct package_statics, IActivationFactory_iface )
static HRESULT WINAPI package_statics_get_Current( IPackageStatics *iface, IPackage **value )
{
struct package *impl;
TRACE( "iface %p, value %p\n", iface, value );
if (!value) return E_INVALIDARG;
if (!(impl = calloc( 1, sizeof(*impl) ))) return E_OUTOFMEMORY;
impl->IPackage_iface.lpVtbl = &package_vtbl;
impl->ref = 1;
*value = &impl->IPackage_iface;
TRACE( "created IPackage %p.\n", *value );
return S_OK;
}
static const struct IPackageStaticsVtbl package_statics_vtbl =
{
package_statics_QueryInterface,
......
......@@ -33,6 +33,7 @@
#define WIDL_using_Windows_Foundation_Collections
#include "windows.foundation.h"
#define WIDL_using_Windows_ApplicationModel
#define WIDL_using_Windows_Storage
#include "windows.applicationmodel.h"
extern IActivationFactory *package_factory;
......
......@@ -58,6 +58,7 @@ static void test_PackageStatics(void)
static const WCHAR *package_statics_name = L"Windows.ApplicationModel.Package";
IPackageStatics *package_statics;
IActivationFactory *factory;
IPackage *package;
HSTRING str;
HRESULT hr;
LONG ref;
......@@ -80,6 +81,19 @@ static void test_PackageStatics(void)
hr = IActivationFactory_QueryInterface( factory, &IID_IPackageStatics, (void **)&package_statics );
ok( hr == S_OK, "got hr %#lx.\n", hr );
hr = IPackageStatics_get_Current( package_statics, NULL );
ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr );
hr = IPackageStatics_get_Current( package_statics, &package );
ok( hr == S_OK, "got hr %#lx.\n", hr );
ok( package != NULL, "got NULL package %p.\n", package );
check_interface( package, &IID_IUnknown );
check_interface( package, &IID_IInspectable );
check_interface( package, &IID_IAgileObject );
check_interface( package, &IID_IPackage );
ref = IPackage_Release( package );
ok( !ref, "got ref %ld.\n", ref );
ref = IPackageStatics_Release( package_statics );
ok( ref == 2, "got ref %ld.\n", ref );
ref = IActivationFactory_Release( factory );
......
......@@ -543,6 +543,7 @@ static void test_PackageStatics(void)
static const WCHAR *package_statics_name = L"Windows.ApplicationModel.Package";
IPackageStatics *package_statics;
IActivationFactory *factory;
IPackage *package;
HSTRING str;
HRESULT hr;
LONG ref;
......@@ -565,6 +566,12 @@ static void test_PackageStatics(void)
hr = IActivationFactory_QueryInterface( factory, &IID_IPackageStatics, (void **)&package_statics );
ok( hr == S_OK, "got hr %#lx.\n", hr );
hr = IPackageStatics_get_Current( package_statics, NULL );
ok( hr == E_INVALIDARG, "got hr %#lx.\n", hr );
hr = IPackageStatics_get_Current( package_statics, &package );
todo_wine ok( hr == 0x80073d54, "got hr %#lx.\n", hr );
todo_wine ok( !package, "got package %p.\n", package );
ref = IPackageStatics_Release( package_statics );
ok( ref == 2, "got ref %ld.\n", ref );
ref = IActivationFactory_Release( factory );
......
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