Change messages about config file to registry.
[wine/multimedia.git] / dlls / itss / itss.c
blobd781d604b33dd7fb706c7aef94370d17ab3ec4db
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 "winnls.h"
35 #include "winreg.h"
36 #include "ole2.h"
38 #include "uuids.h"
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
43 #include "itsstor.h"
45 #define ITSS_INITGUID
46 #include "itss.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(itss);
50 #include "initguid.h"
52 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
54 ULONG dll_count = 0;
56 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
58 switch(fdwReason) {
59 case DLL_PROCESS_ATTACH:
60 DisableThreadLibraryCalls(hInstDLL);
61 break;
62 case DLL_PROCESS_DETACH:
63 break;
65 return TRUE;
68 /******************************************************************************
69 * ITSS ClassFactory
71 typedef struct {
72 IClassFactory ITF_IClassFactory;
74 DWORD ref;
75 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
76 } IClassFactoryImpl;
78 struct object_creation_info
80 const CLSID *clsid;
81 LPCSTR szClassName;
82 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
85 static const struct object_creation_info object_creation[] =
87 { &CLSID_ITStorage, "ITStorage", ITSS_create },
88 { &CLSID_ITSProtocol, "ITSProtocol", ITS_IParseDisplayName_create },
91 static HRESULT WINAPI
92 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
94 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
96 if (IsEqualGUID(riid, &IID_IUnknown)
97 || IsEqualGUID(riid, &IID_IClassFactory))
99 IClassFactory_AddRef(iface);
100 *ppobj = This;
101 return S_OK;
104 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
105 return E_NOINTERFACE;
108 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
110 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
111 return InterlockedIncrement(&This->ref);
114 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
116 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
118 ULONG ref = InterlockedDecrement(&This->ref);
120 if (ref == 0) {
121 HeapFree(GetProcessHeap(), 0, This);
122 InterlockedDecrement(&dll_count);
125 return ref;
129 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
130 REFIID riid, LPVOID *ppobj)
132 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
133 HRESULT hres;
134 LPUNKNOWN punk;
136 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
138 *ppobj = NULL;
139 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
140 if (SUCCEEDED(hres)) {
141 hres = IUnknown_QueryInterface(punk, riid, ppobj);
142 IUnknown_Release(punk);
144 return hres;
147 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
149 TRACE("(%p)->(%d)\n", iface, dolock);
151 if(dolock)
152 InterlockedIncrement(&dll_count);
153 else
154 InterlockedDecrement(&dll_count);
156 return S_OK;
159 static const IClassFactoryVtbl ITSSCF_Vtbl =
161 ITSSCF_QueryInterface,
162 ITSSCF_AddRef,
163 ITSSCF_Release,
164 ITSSCF_CreateInstance,
165 ITSSCF_LockServer
169 /***********************************************************************
170 * DllGetClassObject (ITSS.@)
172 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
174 DWORD i;
175 IClassFactoryImpl *factory;
177 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
179 if ( !IsEqualGUID( &IID_IClassFactory, iid )
180 && ! IsEqualGUID( &IID_IUnknown, iid) )
181 return E_NOINTERFACE;
183 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
185 if (IsEqualGUID(object_creation[i].clsid, rclsid))
186 break;
189 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
191 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
192 return CLASS_E_CLASSNOTAVAILABLE;
195 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
197 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
198 if (factory == NULL) return E_OUTOFMEMORY;
200 factory->ITF_IClassFactory.lpVtbl = &ITSSCF_Vtbl;
201 factory->ref = 1;
203 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
205 *ppv = &(factory->ITF_IClassFactory);
206 InterlockedIncrement(&dll_count);
208 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
210 return S_OK;
213 /*****************************************************************************/
215 typedef struct {
216 const IITStorageVtbl *vtbl_IITStorage;
217 DWORD ref;
218 } ITStorageImpl;
221 HRESULT WINAPI ITStorageImpl_QueryInterface(
222 IITStorage* iface,
223 REFIID riid,
224 void** ppvObject)
226 ITStorageImpl *This = (ITStorageImpl *)iface;
227 if (IsEqualGUID(riid, &IID_IUnknown)
228 || IsEqualGUID(riid, &IID_IITStorage))
230 IClassFactory_AddRef(iface);
231 *ppvObject = This;
232 return S_OK;
235 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
236 return E_NOINTERFACE;
239 ULONG WINAPI ITStorageImpl_AddRef(
240 IITStorage* iface)
242 ITStorageImpl *This = (ITStorageImpl *)iface;
243 TRACE("%p\n", This);
244 return InterlockedIncrement(&This->ref);
247 ULONG WINAPI ITStorageImpl_Release(
248 IITStorage* iface)
250 ITStorageImpl *This = (ITStorageImpl *)iface;
251 ULONG ref = InterlockedDecrement(&This->ref);
253 if (ref == 0) {
254 HeapFree(GetProcessHeap(), 0, This);
255 InterlockedDecrement(&dll_count);
258 return ref;
261 HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
262 IITStorage* iface,
263 const WCHAR* pwcsName,
264 DWORD grfMode,
265 DWORD reserved,
266 IStorage** ppstgOpen)
268 ITStorageImpl *This = (ITStorageImpl *)iface;
270 TRACE("%p %s %lu %lu %p\n", This,
271 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
273 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
274 0, reserved, ppstgOpen);
277 HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
278 IITStorage* iface,
279 ILockBytes* plkbyt,
280 DWORD grfMode,
281 DWORD reserved,
282 IStorage** ppstgOpen)
284 ITStorageImpl *This = (ITStorageImpl *)iface;
285 FIXME("%p\n", This);
286 return E_NOTIMPL;
289 HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
290 IITStorage* iface,
291 const WCHAR* pwcsName)
293 ITStorageImpl *This = (ITStorageImpl *)iface;
294 FIXME("%p\n", This);
295 return E_NOTIMPL;
298 HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
299 IITStorage* iface,
300 ILockBytes* plkbyt)
302 ITStorageImpl *This = (ITStorageImpl *)iface;
303 FIXME("%p\n", This);
304 return E_NOTIMPL;
307 HRESULT WINAPI ITStorageImpl_StgOpenStorage(
308 IITStorage* iface,
309 const WCHAR* pwcsName,
310 IStorage* pstgPriority,
311 DWORD grfMode,
312 SNB snbExclude,
313 DWORD reserved,
314 IStorage** ppstgOpen)
316 ITStorageImpl *This = (ITStorageImpl *)iface;
318 TRACE("%p %s %p %ld %p\n", This, debugstr_w( pwcsName ),
319 pstgPriority, grfMode, snbExclude );
321 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
322 snbExclude, reserved, ppstgOpen);
325 HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
326 IITStorage* iface,
327 ILockBytes* plkbyt,
328 IStorage* pStgPriority,
329 DWORD grfMode,
330 SNB snbExclude,
331 DWORD reserved,
332 IStorage** ppstgOpen)
334 ITStorageImpl *This = (ITStorageImpl *)iface;
335 FIXME("%p\n", This);
336 return E_NOTIMPL;
339 HRESULT WINAPI ITStorageImpl_StgSetTimes(
340 IITStorage* iface,
341 WCHAR* lpszName,
342 FILETIME* pctime,
343 FILETIME* patime,
344 FILETIME* pmtime)
346 ITStorageImpl *This = (ITStorageImpl *)iface;
347 FIXME("%p\n", This);
348 return E_NOTIMPL;
351 HRESULT WINAPI ITStorageImpl_SetControlData(
352 IITStorage* iface,
353 PITS_Control_Data pControlData)
355 ITStorageImpl *This = (ITStorageImpl *)iface;
356 FIXME("%p\n", This);
357 return E_NOTIMPL;
360 HRESULT WINAPI ITStorageImpl_DefaultControlData(
361 IITStorage* iface,
362 PITS_Control_Data* ppControlData)
364 ITStorageImpl *This = (ITStorageImpl *)iface;
365 FIXME("%p\n", This);
366 return E_NOTIMPL;
369 HRESULT WINAPI ITStorageImpl_Compact(
370 IITStorage* iface,
371 const WCHAR* pwcsName,
372 ECompactionLev iLev)
374 ITStorageImpl *This = (ITStorageImpl *)iface;
375 FIXME("%p\n", This);
376 return E_NOTIMPL;
379 static const IITStorageVtbl ITStorageImpl_Vtbl =
381 ITStorageImpl_QueryInterface,
382 ITStorageImpl_AddRef,
383 ITStorageImpl_Release,
384 ITStorageImpl_StgCreateDocfile,
385 ITStorageImpl_StgCreateDocfileOnILockBytes,
386 ITStorageImpl_StgIsStorageFile,
387 ITStorageImpl_StgIsStorageILockBytes,
388 ITStorageImpl_StgOpenStorage,
389 ITStorageImpl_StgOpenStorageOnILockBytes,
390 ITStorageImpl_StgSetTimes,
391 ITStorageImpl_SetControlData,
392 ITStorageImpl_DefaultControlData,
393 ITStorageImpl_Compact,
396 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
398 ITStorageImpl *its;
400 if( pUnkOuter )
401 return CLASS_E_NOAGGREGATION;
403 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
404 its->vtbl_IITStorage = &ITStorageImpl_Vtbl;
405 its->ref = 1;
407 TRACE("-> %p\n", its);
408 *ppObj = (LPVOID) its;
409 InterlockedIncrement(&dll_count);
411 return S_OK;
414 /*****************************************************************************/
416 HRESULT WINAPI DllRegisterServer(void)
418 FIXME("\n");
419 return S_OK;
422 HRESULT WINAPI DllCanUnloadNow(void)
424 TRACE("dll_count = %lu\n", dll_count);
425 return dll_count ? S_FALSE : S_OK;