Fix the ITS moniker implementation.
[wine/multimedia.git] / dlls / itss / itss.c
blob25e1938b12c0e71467eb16183a8f1f06b4775f0f
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 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "winnls.h"
33 #include "winreg.h"
34 #include "ole2.h"
36 #include "itss.h"
37 #include "uuids.h"
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
42 #include "itsstor.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(itss);
46 #include "initguid.h"
48 DEFINE_GUID(CLSID_ITStorage,0x5d02926a,0x212e,0x11d0,0x9d,0xf9,0x00,0xa0,0xc9,0x22,0xe6,0xec );
49 DEFINE_GUID(CLSID_ITSProtocol,0x9d148290,0xb9c8,0x11d0,0xa4,0xcc,0x00,0x00,0xf8,0x01,0x49,0xf6);
50 DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec);
52 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
54 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
56 switch(fdwReason) {
57 case DLL_PROCESS_ATTACH:
58 DisableThreadLibraryCalls(hInstDLL);
59 break;
60 case DLL_PROCESS_DETACH:
61 break;
63 return TRUE;
66 /******************************************************************************
67 * ITSS ClassFactory
69 typedef struct {
70 IClassFactory ITF_IClassFactory;
72 DWORD ref;
73 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
74 } IClassFactoryImpl;
76 struct object_creation_info
78 const CLSID *clsid;
79 LPCSTR szClassName;
80 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
83 static const struct object_creation_info object_creation[] =
85 { &CLSID_ITStorage, "ITStorage", ITSS_create },
86 { &CLSID_ITSProtocol, "ITSProtocol", ITS_IParseDisplayName_create },
89 static HRESULT WINAPI
90 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
92 ICOM_THIS(IClassFactoryImpl,iface);
94 if (IsEqualGUID(riid, &IID_IUnknown)
95 || IsEqualGUID(riid, &IID_IClassFactory))
97 IClassFactory_AddRef(iface);
98 *ppobj = This;
99 return S_OK;
102 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
103 return E_NOINTERFACE;
106 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface) {
107 ICOM_THIS(IClassFactoryImpl,iface);
108 return ++(This->ref);
111 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface) {
112 ICOM_THIS(IClassFactoryImpl,iface);
114 ULONG ref = --This->ref;
116 if (ref == 0)
117 HeapFree(GetProcessHeap(), 0, This);
119 return ref;
123 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
124 REFIID riid, LPVOID *ppobj) {
125 ICOM_THIS(IClassFactoryImpl,iface);
126 HRESULT hres;
127 LPUNKNOWN punk;
129 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
131 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
132 if (FAILED(hres)) {
133 *ppobj = NULL;
134 return hres;
136 hres = IUnknown_QueryInterface(punk, riid, ppobj);
137 if (FAILED(hres)) {
138 *ppobj = NULL;
139 return hres;
141 IUnknown_Release(punk);
142 return hres;
145 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock) {
146 ICOM_THIS(IClassFactoryImpl,iface);
147 FIXME("(%p)->(%d),stub!\n",This,dolock);
148 return S_OK;
151 static IClassFactoryVtbl ITSSCF_Vtbl =
153 ITSSCF_QueryInterface,
154 ITSSCF_AddRef,
155 ITSSCF_Release,
156 ITSSCF_CreateInstance,
157 ITSSCF_LockServer
161 HRESULT WINAPI ITSS_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
163 int i;
164 IClassFactoryImpl *factory;
166 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
168 if ( !IsEqualGUID( &IID_IClassFactory, iid )
169 && ! IsEqualGUID( &IID_IUnknown, iid) )
170 return E_NOINTERFACE;
172 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
174 if (IsEqualGUID(object_creation[i].clsid, rclsid))
175 break;
178 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
180 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
181 return CLASS_E_CLASSNOTAVAILABLE;
184 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
186 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
187 if (factory == NULL) return E_OUTOFMEMORY;
189 factory->ITF_IClassFactory.lpVtbl = &ITSSCF_Vtbl;
190 factory->ref = 1;
192 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
194 *ppv = &(factory->ITF_IClassFactory);
196 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
198 return S_OK;
201 /*****************************************************************************/
203 typedef struct {
204 IITStorageVtbl *vtbl_IITStorage;
205 DWORD ref;
206 } ITStorageImpl;
209 HRESULT WINAPI ITStorageImpl_QueryInterface(
210 IITStorage* iface,
211 REFIID riid,
212 void** ppvObject)
214 ICOM_THIS(ITStorageImpl,iface);
215 if (IsEqualGUID(riid, &IID_IUnknown)
216 || IsEqualGUID(riid, &IID_IITStorage))
218 IClassFactory_AddRef(iface);
219 *ppvObject = This;
220 return S_OK;
223 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
224 return E_NOINTERFACE;
227 ULONG WINAPI ITStorageImpl_AddRef(
228 IITStorage* iface)
230 ICOM_THIS(ITStorageImpl,iface);
231 TRACE("%p\n", This);
232 return ++(This->ref);
235 ULONG WINAPI ITStorageImpl_Release(
236 IITStorage* iface)
238 ICOM_THIS(ITStorageImpl,iface);
239 ULONG ref = --This->ref;
241 if (ref == 0)
242 HeapFree(GetProcessHeap(), 0, This);
244 return ref;
247 HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
248 IITStorage* iface,
249 const WCHAR* pwcsName,
250 DWORD grfMode,
251 DWORD reserved,
252 IStorage** ppstgOpen)
254 ICOM_THIS(ITStorageImpl,iface);
256 TRACE("%p %s %lu %lu %p\n", This,
257 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
259 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
260 0, reserved, ppstgOpen);
263 HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
264 IITStorage* iface,
265 ILockBytes* plkbyt,
266 DWORD grfMode,
267 DWORD reserved,
268 IStorage** ppstgOpen)
270 ICOM_THIS(ITStorageImpl,iface);
271 FIXME("%p\n", This);
272 return E_NOTIMPL;
275 HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
276 IITStorage* iface,
277 const WCHAR* pwcsName)
279 ICOM_THIS(ITStorageImpl,iface);
280 FIXME("%p\n", This);
281 return E_NOTIMPL;
284 HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
285 IITStorage* iface,
286 ILockBytes* plkbyt)
288 ICOM_THIS(ITStorageImpl,iface);
289 FIXME("%p\n", This);
290 return E_NOTIMPL;
293 HRESULT WINAPI ITStorageImpl_StgOpenStorage(
294 IITStorage* iface,
295 const WCHAR* pwcsName,
296 IStorage* pstgPriority,
297 DWORD grfMode,
298 SNB snbExclude,
299 DWORD reserved,
300 IStorage** ppstgOpen)
302 ICOM_THIS(ITStorageImpl,iface);
304 TRACE("%p %s %p %ld %p\n", This, debugstr_w( pwcsName ),
305 pstgPriority, grfMode, snbExclude );
307 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
308 snbExclude, reserved, ppstgOpen);
311 HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
312 IITStorage* iface,
313 ILockBytes* plkbyt,
314 IStorage* pStgPriority,
315 DWORD grfMode,
316 SNB snbExclude,
317 DWORD reserved,
318 IStorage** ppstgOpen)
320 ICOM_THIS(ITStorageImpl,iface);
321 FIXME("%p\n", This);
322 return E_NOTIMPL;
325 HRESULT WINAPI ITStorageImpl_StgSetTimes(
326 IITStorage* iface,
327 WCHAR* lpszName,
328 FILETIME* pctime,
329 FILETIME* patime,
330 FILETIME* pmtime)
332 ICOM_THIS(ITStorageImpl,iface);
333 FIXME("%p\n", This);
334 return E_NOTIMPL;
337 HRESULT WINAPI ITStorageImpl_SetControlData(
338 IITStorage* iface,
339 PITS_Control_Data pControlData)
341 ICOM_THIS(ITStorageImpl,iface);
342 FIXME("%p\n", This);
343 return E_NOTIMPL;
346 HRESULT WINAPI ITStorageImpl_DefaultControlData(
347 IITStorage* iface,
348 PITS_Control_Data* ppControlData)
350 ICOM_THIS(ITStorageImpl,iface);
351 FIXME("%p\n", This);
352 return E_NOTIMPL;
355 HRESULT WINAPI ITStorageImpl_Compact(
356 IITStorage* iface,
357 const WCHAR* pwcsName,
358 ECompactionLev iLev)
360 ICOM_THIS(ITStorageImpl,iface);
361 FIXME("%p\n", This);
362 return E_NOTIMPL;
365 static IITStorageVtbl ITStorageImpl_Vtbl =
367 ITStorageImpl_QueryInterface,
368 ITStorageImpl_AddRef,
369 ITStorageImpl_Release,
370 ITStorageImpl_StgCreateDocfile,
371 ITStorageImpl_StgCreateDocfileOnILockBytes,
372 ITStorageImpl_StgIsStorageFile,
373 ITStorageImpl_StgIsStorageILockBytes,
374 ITStorageImpl_StgOpenStorage,
375 ITStorageImpl_StgOpenStorageOnILockBytes,
376 ITStorageImpl_StgSetTimes,
377 ITStorageImpl_SetControlData,
378 ITStorageImpl_DefaultControlData,
379 ITStorageImpl_Compact,
382 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
384 ITStorageImpl *its;
386 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
387 its->vtbl_IITStorage = &ITStorageImpl_Vtbl;
388 its->ref = 1;
390 TRACE("-> %p\n", its);
391 *ppObj = (LPVOID) its;
393 return S_OK;
396 /*****************************************************************************/
398 HRESULT WINAPI ITSS_DllRegisterServer(void)
400 FIXME("\n");
401 return S_OK;
404 BOOL WINAPI ITSS_DllCanUnloadNow(void)
406 FIXME("\n");
408 return FALSE;