qcap/tests: Add media tests for the SmartTee filter.
[wine/multimedia.git] / dlls / itss / itss.c
blobfe28ba9353337b52c7f4f9979fb0b7c9a367a44b
1 /*
2 * ITSS Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2004 Mike McCormack
7 * see http://bonedaddy.net/pabs3/hhm/#chmspec
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include "config.h"
26 #include <stdarg.h>
27 #include <stdio.h>
29 #define COBJMACROS
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "winreg.h"
35 #include "ole2.h"
36 #include "rpcproxy.h"
37 #include "advpub.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 #include "itsstor.h"
44 #include "initguid.h"
45 #include "wine/itss.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(itss);
49 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
51 LONG dll_count = 0;
52 static HINSTANCE hInst;
54 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
56 switch(fdwReason) {
57 case DLL_PROCESS_ATTACH:
58 DisableThreadLibraryCalls(hInstDLL);
59 hInst = hInstDLL;
60 break;
62 return TRUE;
65 /******************************************************************************
66 * ITSS ClassFactory
68 typedef struct {
69 IClassFactory IClassFactory_iface;
70 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
71 } IClassFactoryImpl;
73 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
75 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
78 static HRESULT WINAPI
79 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
81 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
83 if (IsEqualGUID(riid, &IID_IUnknown) ||
84 IsEqualGUID(riid, &IID_IClassFactory))
86 IClassFactory_AddRef(iface);
87 *ppobj = This;
88 return S_OK;
91 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
92 return E_NOINTERFACE;
95 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
97 ITSS_LockModule();
98 return 2;
101 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
103 ITSS_UnlockModule();
104 return 1;
108 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
109 REFIID riid, LPVOID *ppobj)
111 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
112 HRESULT hres;
113 LPUNKNOWN punk;
115 TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
117 *ppobj = NULL;
118 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
119 if (SUCCEEDED(hres)) {
120 hres = IUnknown_QueryInterface(punk, riid, ppobj);
121 IUnknown_Release(punk);
123 return hres;
126 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
128 TRACE("(%p)->(%d)\n", iface, dolock);
130 if (dolock)
131 ITSS_LockModule();
132 else
133 ITSS_UnlockModule();
135 return S_OK;
138 static const IClassFactoryVtbl ITSSCF_Vtbl =
140 ITSSCF_QueryInterface,
141 ITSSCF_AddRef,
142 ITSSCF_Release,
143 ITSSCF_CreateInstance,
144 ITSSCF_LockServer
147 static const IClassFactoryImpl ITStorage_factory = { { &ITSSCF_Vtbl }, ITSS_create };
148 static const IClassFactoryImpl MSITStore_factory = { { &ITSSCF_Vtbl }, ITS_IParseDisplayName_create };
149 static const IClassFactoryImpl ITSProtocol_factory = { { &ITSSCF_Vtbl }, ITSProtocol_create };
151 /***********************************************************************
152 * DllGetClassObject (ITSS.@)
154 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
156 const IClassFactoryImpl *factory;
158 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
160 if (IsEqualGUID(&CLSID_ITStorage, rclsid))
161 factory = &ITStorage_factory;
162 else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
163 factory = &MSITStore_factory;
164 else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
165 factory = &ITSProtocol_factory;
166 else
168 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
169 return CLASS_E_CLASSNOTAVAILABLE;
172 return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
175 /*****************************************************************************/
177 typedef struct {
178 IITStorage IITStorage_iface;
179 LONG ref;
180 } ITStorageImpl;
182 static inline ITStorageImpl *impl_from_IITStorage(IITStorage *iface)
184 return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
188 static HRESULT WINAPI ITStorageImpl_QueryInterface(
189 IITStorage* iface,
190 REFIID riid,
191 void** ppvObject)
193 ITStorageImpl *This = impl_from_IITStorage(iface);
194 if (IsEqualGUID(riid, &IID_IUnknown)
195 || IsEqualGUID(riid, &IID_IITStorage))
197 IITStorage_AddRef(iface);
198 *ppvObject = iface;
199 return S_OK;
202 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
203 return E_NOINTERFACE;
206 static ULONG WINAPI ITStorageImpl_AddRef(
207 IITStorage* iface)
209 ITStorageImpl *This = impl_from_IITStorage(iface);
210 TRACE("%p\n", This);
211 return InterlockedIncrement(&This->ref);
214 static ULONG WINAPI ITStorageImpl_Release(
215 IITStorage* iface)
217 ITStorageImpl *This = impl_from_IITStorage(iface);
218 ULONG ref = InterlockedDecrement(&This->ref);
220 if (ref == 0) {
221 HeapFree(GetProcessHeap(), 0, This);
222 ITSS_UnlockModule();
225 return ref;
228 static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
229 IITStorage* iface,
230 const WCHAR* pwcsName,
231 DWORD grfMode,
232 DWORD reserved,
233 IStorage** ppstgOpen)
235 ITStorageImpl *This = impl_from_IITStorage(iface);
237 TRACE("%p %s %u %u %p\n", This,
238 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
240 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
241 0, reserved, ppstgOpen);
244 static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
245 IITStorage* iface,
246 ILockBytes* plkbyt,
247 DWORD grfMode,
248 DWORD reserved,
249 IStorage** ppstgOpen)
251 ITStorageImpl *This = impl_from_IITStorage(iface);
252 FIXME("%p\n", This);
253 return E_NOTIMPL;
256 static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
257 IITStorage* iface,
258 const WCHAR* pwcsName)
260 ITStorageImpl *This = impl_from_IITStorage(iface);
261 FIXME("%p\n", This);
262 return E_NOTIMPL;
265 static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
266 IITStorage* iface,
267 ILockBytes* plkbyt)
269 ITStorageImpl *This = impl_from_IITStorage(iface);
270 FIXME("%p\n", This);
271 return E_NOTIMPL;
274 static HRESULT WINAPI ITStorageImpl_StgOpenStorage(
275 IITStorage* iface,
276 const WCHAR* pwcsName,
277 IStorage* pstgPriority,
278 DWORD grfMode,
279 SNB snbExclude,
280 DWORD reserved,
281 IStorage** ppstgOpen)
283 ITStorageImpl *This = impl_from_IITStorage(iface);
285 TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
286 pstgPriority, grfMode, snbExclude );
288 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
289 snbExclude, reserved, ppstgOpen);
292 static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
293 IITStorage* iface,
294 ILockBytes* plkbyt,
295 IStorage* pStgPriority,
296 DWORD grfMode,
297 SNB snbExclude,
298 DWORD reserved,
299 IStorage** ppstgOpen)
301 ITStorageImpl *This = impl_from_IITStorage(iface);
302 FIXME("%p\n", This);
303 return E_NOTIMPL;
306 static HRESULT WINAPI ITStorageImpl_StgSetTimes(
307 IITStorage* iface,
308 const WCHAR* lpszName,
309 const FILETIME* pctime,
310 const FILETIME* patime,
311 const FILETIME* pmtime)
313 ITStorageImpl *This = impl_from_IITStorage(iface);
314 FIXME("%p\n", This);
315 return E_NOTIMPL;
318 static HRESULT WINAPI ITStorageImpl_SetControlData(
319 IITStorage* iface,
320 PITS_Control_Data pControlData)
322 ITStorageImpl *This = impl_from_IITStorage(iface);
323 FIXME("%p\n", This);
324 return E_NOTIMPL;
327 static HRESULT WINAPI ITStorageImpl_DefaultControlData(
328 IITStorage* iface,
329 PITS_Control_Data* ppControlData)
331 ITStorageImpl *This = impl_from_IITStorage(iface);
332 FIXME("%p\n", This);
333 return E_NOTIMPL;
336 static HRESULT WINAPI ITStorageImpl_Compact(
337 IITStorage* iface,
338 const WCHAR* pwcsName,
339 ECompactionLev iLev)
341 ITStorageImpl *This = impl_from_IITStorage(iface);
342 FIXME("%p\n", This);
343 return E_NOTIMPL;
346 static const IITStorageVtbl ITStorageImpl_Vtbl =
348 ITStorageImpl_QueryInterface,
349 ITStorageImpl_AddRef,
350 ITStorageImpl_Release,
351 ITStorageImpl_StgCreateDocfile,
352 ITStorageImpl_StgCreateDocfileOnILockBytes,
353 ITStorageImpl_StgIsStorageFile,
354 ITStorageImpl_StgIsStorageILockBytes,
355 ITStorageImpl_StgOpenStorage,
356 ITStorageImpl_StgOpenStorageOnILockBytes,
357 ITStorageImpl_StgSetTimes,
358 ITStorageImpl_SetControlData,
359 ITStorageImpl_DefaultControlData,
360 ITStorageImpl_Compact,
363 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
365 ITStorageImpl *its;
367 if( pUnkOuter )
368 return CLASS_E_NOAGGREGATION;
370 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
371 its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl;
372 its->ref = 1;
374 TRACE("-> %p\n", its);
375 *ppObj = its;
377 ITSS_LockModule();
378 return S_OK;
381 /*****************************************************************************/
383 HRESULT WINAPI DllCanUnloadNow(void)
385 TRACE("dll_count = %u\n", dll_count);
386 return dll_count ? S_FALSE : S_OK;
389 /***********************************************************************
390 * DllRegisterServer (ITSS.@)
392 HRESULT WINAPI DllRegisterServer(void)
394 return __wine_register_resources( hInst );
397 /***********************************************************************
398 * DllUnregisterServer (ITSS.@)
400 HRESULT WINAPI DllUnregisterServer(void)
402 return __wine_unregister_resources( hInst );