1 | // $Id: dpclassfactory.cpp,v 1.2 2000-09-24 22:47:36 hugh Exp $
|
---|
2 | #include <string.h>
|
---|
3 |
|
---|
4 | #include <odin.h>
|
---|
5 |
|
---|
6 | #define CINTERFACE
|
---|
7 | #include "wine/obj_base.h"
|
---|
8 |
|
---|
9 | #include "winerror.h"
|
---|
10 | #include "debugtools.h"
|
---|
11 | #include "dpinit.h"
|
---|
12 |
|
---|
13 | DEFAULT_DEBUG_CHANNEL(dplay)
|
---|
14 |
|
---|
15 | /*******************************************************************************
|
---|
16 | * DirectPlayLobby ClassFactory
|
---|
17 | */
|
---|
18 |
|
---|
19 | typedef struct
|
---|
20 | {
|
---|
21 | /* IUnknown fields */
|
---|
22 | ICOM_VFIELD(IClassFactory);
|
---|
23 | DWORD ref;
|
---|
24 | } IClassFactoryImpl;
|
---|
25 |
|
---|
26 | static HRESULT WINAPI
|
---|
27 | DP_and_DPL_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
|
---|
28 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
29 |
|
---|
30 | FIXME("(%p)->(%s,%p),stub!\n",This,debugstr_guid(riid),ppobj);
|
---|
31 |
|
---|
32 | return E_NOINTERFACE;
|
---|
33 | }
|
---|
34 |
|
---|
35 | static ULONG WINAPI
|
---|
36 | DP_and_DPL_AddRef(LPCLASSFACTORY iface) {
|
---|
37 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
38 | return ++(This->ref);
|
---|
39 | }
|
---|
40 |
|
---|
41 | static ULONG WINAPI DP_and_DPL_Release(LPCLASSFACTORY iface) {
|
---|
42 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
43 | /* static class (reference starts @ 1), won't ever be freed */
|
---|
44 | return --(This->ref);
|
---|
45 | }
|
---|
46 |
|
---|
47 | static HRESULT WINAPI DP_and_DPL_CreateInstance(
|
---|
48 | LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
|
---|
49 | ) {
|
---|
50 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
51 |
|
---|
52 | TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
|
---|
53 |
|
---|
54 | if ( DPL_CreateInterface( riid, ppobj ) == S_OK )
|
---|
55 | {
|
---|
56 | return S_OK;
|
---|
57 | }
|
---|
58 | else if ( DP_CreateInterface( riid, ppobj ) == S_OK )
|
---|
59 | {
|
---|
60 | return S_OK;
|
---|
61 | }
|
---|
62 |
|
---|
63 | return E_NOINTERFACE;
|
---|
64 | }
|
---|
65 |
|
---|
66 | static HRESULT WINAPI DP_and_DPL_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
|
---|
67 | ICOM_THIS(IClassFactoryImpl,iface);
|
---|
68 | FIXME("(%p)->(%d),stub!\n",This,dolock);
|
---|
69 | return S_OK;
|
---|
70 | }
|
---|
71 |
|
---|
72 | static ICOM_VTABLE(IClassFactory) DP_and_DPL_Vtbl = {
|
---|
73 | ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
---|
74 | DP_and_DPL_QueryInterface,
|
---|
75 | DP_and_DPL_AddRef,
|
---|
76 | DP_and_DPL_Release,
|
---|
77 | DP_and_DPL_CreateInstance,
|
---|
78 | DP_and_DPL_LockServer
|
---|
79 | };
|
---|
80 |
|
---|
81 | static IClassFactoryImpl DP_and_DPL_CF = {&DP_and_DPL_Vtbl, 1 };
|
---|
82 |
|
---|
83 |
|
---|
84 | /*******************************************************************************
|
---|
85 | * DPLAYX_DllGetClassObject [DPLAYX.?]
|
---|
86 | * Retrieves DP or DPL class object from a DLL object
|
---|
87 | *
|
---|
88 | * NOTES
|
---|
89 | * Docs say returns STDAPI
|
---|
90 | *
|
---|
91 | * PARAMS
|
---|
92 | * rclsid [I] CLSID for the class object
|
---|
93 | * riid [I] Reference to identifier of interface for class object
|
---|
94 | * ppv [O] Address of variable to receive interface pointer for riid
|
---|
95 | *
|
---|
96 | * RETURNS
|
---|
97 | * Success: S_OK
|
---|
98 | * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
|
---|
99 | * E_UNEXPECTED
|
---|
100 | */
|
---|
101 | DWORD WINAPI DPLAYX_DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID *ppv)
|
---|
102 | {
|
---|
103 | TRACE("(%p,%p,%p)\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
---|
104 |
|
---|
105 | if ( IsEqualCLSID( riid, &IID_IClassFactory ) )
|
---|
106 | {
|
---|
107 | *ppv = (LPVOID)&DP_and_DPL_CF;
|
---|
108 | IClassFactory_AddRef( (IClassFactory*)*ppv );
|
---|
109 |
|
---|
110 | return S_OK;
|
---|
111 | }
|
---|
112 |
|
---|
113 | ERR("(%p,%p,%p): no interface found.\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
---|
114 | return CLASS_E_CLASSNOTAVAILABLE;
|
---|
115 | }
|
---|