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
26 //#include "winbase.h"
27 //#include "objbase.h"
28 //#include "winerror.h"
29 #include <wine/debug.h>
31 //#include "dplobby.h"
32 //#include "initguid.h"
33 #include "dplay_global.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(dplay
);
40 IClassFactory IClassFactory_iface
;
41 HRESULT (*createinstance
)(REFIID riid
, void **ppv
);
44 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
46 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
49 static HRESULT WINAPI
IClassFactoryImpl_QueryInterface(IClassFactory
*iface
, REFIID riid
,
52 TRACE("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
54 if (IsEqualGUID(&IID_IUnknown
, riid
) || IsEqualGUID(&IID_IClassFactory
, riid
))
57 IClassFactory_AddRef(iface
);
62 WARN("no interface for %s\n", debugstr_guid(riid
));
66 static ULONG WINAPI
IClassFactoryImpl_AddRef(IClassFactory
*iface
)
68 return 2; /* non-heap based object */
71 static ULONG WINAPI
IClassFactoryImpl_Release(IClassFactory
*iface
)
73 return 1; /* non-heap based object */
76 static HRESULT WINAPI
IClassFactoryImpl_CreateInstance(IClassFactory
*iface
, IUnknown
*pOuter
,
77 REFIID riid
, void **ppv
)
79 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
81 TRACE("(%p)->(%p,%s,%p)\n", iface
, pOuter
, debugstr_guid(riid
), ppv
);
84 return CLASS_E_NOAGGREGATION
;
86 return This
->createinstance(riid
, ppv
);
89 static HRESULT WINAPI
IClassFactoryImpl_LockServer(IClassFactory
*iface
, BOOL dolock
)
91 FIXME("(%p)->(%d),stub!\n", iface
, dolock
);
95 static const IClassFactoryVtbl cf_vt
= {
96 IClassFactoryImpl_QueryInterface
,
97 IClassFactoryImpl_AddRef
,
98 IClassFactoryImpl_Release
,
99 IClassFactoryImpl_CreateInstance
,
100 IClassFactoryImpl_LockServer
103 static IClassFactoryImpl dplay_cf
= {{&cf_vt
}, dplay_create
};
104 static IClassFactoryImpl dplaylobby_cf
= {{&cf_vt
}, dplobby_create
};
107 /*******************************************************************************
108 * DllGetClassObject [DPLAYX.@]
109 * Retrieves DP or DPL class object from a DLL object
112 * Docs say returns STDAPI
115 * rclsid [I] CLSID for the class object
116 * riid [I] Reference to identifier of interface for class object
117 * ppv [O] Address of variable to receive interface pointer for riid
121 * Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
124 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID riid
, LPVOID
*ppv
)
126 TRACE("(%s,%s,%p)\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
128 if (IsEqualCLSID(&CLSID_DirectPlay
, rclsid
))
129 return IClassFactory_QueryInterface(&dplay_cf
.IClassFactory_iface
, riid
, ppv
);
131 if (IsEqualCLSID(&CLSID_DirectPlayLobby
, rclsid
))
132 return IClassFactory_QueryInterface(&dplaylobby_cf
.IClassFactory_iface
, riid
, ppv
);
134 FIXME("(%s,%s,%p): no class found.\n", debugstr_guid(rclsid
), debugstr_guid(riid
), ppv
);
135 return CLASS_E_CLASSNOTAVAILABLE
;