1 /* COM class factory for direct play lobby interfaces.
3 * Copyright 1999, 2000 Peter Hunnisett
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "dplayx_global.h"
24 IClassFactory IClassFactory_iface
;
25 HRESULT (*createinstance
)(REFIID riid
, void **ppv
);
28 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
30 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
33 static HRESULT WINAPI
IClassFactoryImpl_QueryInterface(IClassFactory
*iface
, REFIID riid
,
36 TRACE("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
38 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
))
41 IClassFactory_AddRef(iface
);
46 WARN("no interface for %s\n", debugstr_guid(riid
));
50 static ULONG WINAPI
IClassFactoryImpl_AddRef(IClassFactory
*iface
)
52 return 2; /* non-heap based object */
55 static ULONG WINAPI
IClassFactoryImpl_Release(IClassFactory
*iface
)
57 return 1; /* non-heap based object */
60 static HRESULT WINAPI
IClassFactoryImpl_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
61 REFIID riid
, void **ppv
)
63 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
65 TRACE("(%p)->(%p,%s,%p)\n", iface
, pOuter
, debugstr_guid(riid
), ppv
);
68 return CLASS_E_NOAGGREGATION
;
70 return This
->createinstance(riid
, ppv
);
73 static HRESULT WINAPI
IClassFactoryImpl_LockServer(IClassFactory
*iface
, BOOL dolock
)
75 FIXME("(%p)->(%d),stub!\n", iface
, dolock
);
79 static const IClassFactoryVtbl cf_vt
= {
80 IClassFactoryImpl_QueryInterface
,
81 IClassFactoryImpl_AddRef
,
82 IClassFactoryImpl_Release
,
83 IClassFactoryImpl_CreateInstance
,
84 IClassFactoryImpl_LockServer
87 static IClassFactoryImpl dplay_cf
= {{&cf_vt
}, dplay_create
};
88 static IClassFactoryImpl dplaylobby_cf
= {{&cf_vt
}, dplobby_create
};
91 /*******************************************************************************
92 * DllGetClassObject [DPLAYX.@]
93 * Retrieves DP or DPL class object from a DLL object
96 * Docs say returns STDAPI
99 * rclsid [I] CLSID for the class object
100 * riid [I] Reference to identifier of interface for class object
101 * ppv [O] Address of variable to receive interface pointer for riid
105 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
108 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
110 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
112 if (IsEqualCLSID(&CLSID_DirectPlay
, rclsid
))
113 return IClassFactory_QueryInterface(&dplay_cf
.IClassFactory_iface
, riid
, ppv
);
115 if (IsEqualCLSID(&CLSID_DirectPlayLobby
, rclsid
))
116 return IClassFactory_QueryInterface(&dplaylobby_cf
.IClassFactory_iface
, riid
, ppv
);
118 FIXME("(%s,%s,%p): no class found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
119 return CLASS_E_CLASSNOTAVAILABLE
;