Added missing prototypes for StrRetToBuf(A|W).
[wine] / dlls / dplayx / dpclassfactory.c
1
2 #include "wine/obj_base.h"
3 #include "winerror.h"
4 #include "debugtools.h"
5 #include "dpinit.h"
6
7 DEFAULT_DEBUG_CHANNEL(dplay)
8
9
10 /*******************************************************************************
11  * DirectPlayLobby ClassFactory
12  */
13
14 typedef struct
15 {
16     /* IUnknown fields */
17     ICOM_VTABLE(IClassFactory)* lpvtbl;
18     DWORD                       ref;
19 } IClassFactoryImpl;
20
21 static HRESULT WINAPI
22 DP_and_DPL_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj) {
23         ICOM_THIS(IClassFactoryImpl,iface);
24         char buf[80];
25
26         if (HIWORD(riid))
27             WINE_StringFromCLSID(riid,buf);
28         else
29             sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
30
31         FIXME("(%p)->(%s,%p),stub!\n",This,buf,ppobj);
32
33         return E_NOINTERFACE;
34 }
35
36 static ULONG WINAPI
37 DP_and_DPL_AddRef(LPCLASSFACTORY iface) {
38         ICOM_THIS(IClassFactoryImpl,iface);
39         return ++(This->ref);
40 }
41
42 static ULONG WINAPI DP_and_DPL_Release(LPCLASSFACTORY iface) {
43         ICOM_THIS(IClassFactoryImpl,iface);
44         /* static class (reference starts @ 1), won't ever be freed */
45         return --(This->ref);
46 }
47
48 /* Not the most efficient implementation, but it's simple */
49 static HRESULT WINAPI DP_and_DPL_CreateInstance(
50         LPCLASSFACTORY iface,LPUNKNOWN pOuter,REFIID riid,LPVOID *ppobj
51 ) {
52         ICOM_THIS(IClassFactoryImpl,iface);
53         char buf[80];
54
55         WINE_StringFromCLSID(riid,buf);
56         TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,buf,ppobj);
57
58         /* FIXME: reuse already created DP/DPL object if present? */
59         if ( directPlayLobby_QueryInterface( riid, ppobj ) == S_OK )
60         {
61            return S_OK;
62         }
63         else if ( directPlay_QueryInterface( riid, ppobj ) == S_OK )
64         {
65            return S_OK;
66         }
67
68         return E_NOINTERFACE;
69 }
70
71 static HRESULT WINAPI DP_and_DPL_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
72         ICOM_THIS(IClassFactoryImpl,iface);
73         FIXME("(%p)->(%d),stub!\n",This,dolock);
74         return S_OK;
75 }
76
77 static ICOM_VTABLE(IClassFactory) DP_and_DPL_Vtbl = {
78         DP_and_DPL_QueryInterface,
79         DP_and_DPL_AddRef,
80         DP_and_DPL_Release,
81         DP_and_DPL_CreateInstance,
82         DP_and_DPL_LockServer
83 };
84
85 static IClassFactoryImpl DP_and_DPL_CF = {&DP_and_DPL_Vtbl, 1 };
86
87
88 /*******************************************************************************
89  * DllGetClassObject [DPLAYX.?]
90  * Retrieves DP or DPL class object from a DLL object
91  *
92  * NOTES
93  *    Docs say returns STDAPI
94  *
95  * PARAMS
96  *    rclsid [I] CLSID for the class object
97  *    riid   [I] Reference to identifier of interface for class object
98  *    ppv    [O] Address of variable to receive interface pointer for riid
99  *
100  * RETURNS
101  *    Success: S_OK
102  *    Failure: CLASS_E_CLASSNOTAVAILABLE, E_OUTOFMEMORY, E_INVALIDARG,
103  *             E_UNEXPECTED
104  */
105 DWORD WINAPI DP_and_DPL_DllGetClassObject(REFCLSID rclsid,REFIID riid,LPVOID *ppv)
106 {
107     char buf[80],xbuf[80];
108
109     if (HIWORD(rclsid))
110         WINE_StringFromCLSID(rclsid,xbuf);
111     else
112         sprintf(xbuf,"<guid-0x%04x>",LOWORD(rclsid));
113
114     if (HIWORD(riid))
115         WINE_StringFromCLSID(riid,buf);
116     else
117         sprintf(buf,"<guid-0x%04x>",LOWORD(riid));
118
119     WINE_StringFromCLSID(riid,xbuf);
120
121     TRACE("(%p,%p,%p)\n", xbuf, buf, ppv);
122
123     if ( IsEqualCLSID( riid, &IID_IClassFactory ) )
124     {
125         *ppv = (LPVOID)&DP_and_DPL_CF;
126         IClassFactory_AddRef( (IClassFactory*)*ppv );
127
128         return S_OK;
129     }
130
131     ERR("(%p,%p,%p): no interface found.\n", xbuf, buf, ppv);
132     return CLASS_E_CLASSNOTAVAILABLE;
133 }
134