Don't define COBJMACROS in objbase.h.
[wine/multimedia.git] / dlls / itss / itss.c
blobe7c415795fb78228a8c61c36932beb24e3ac9f8f
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 "itss.h"
39 #include "uuids.h"
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
44 #include "itsstor.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(itss);
48 #include "initguid.h"
50 DEFINE_GUID(CLSID_ITStorage,0x5d02926a,0x212e,0x11d0,0x9d,0xf9,0x00,0xa0,0xc9,0x22,0xe6,0xec );
51 DEFINE_GUID(CLSID_ITSProtocol,0x9d148290,0xb9c8,0x11d0,0xa4,0xcc,0x00,0x00,0xf8,0x01,0x49,0xf6);
52 DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec);
54 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
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);
123 return ref;
127 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
128 REFIID riid, LPVOID *ppobj)
130 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
131 HRESULT hres;
132 LPUNKNOWN punk;
134 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
136 *ppobj = NULL;
137 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
138 if (SUCCEEDED(hres)) {
139 hres = IUnknown_QueryInterface(punk, riid, ppobj);
140 IUnknown_Release(punk);
142 return hres;
145 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
147 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
148 FIXME("(%p)->(%d),stub!\n",This,dolock);
149 return S_OK;
152 static IClassFactoryVtbl ITSSCF_Vtbl =
154 ITSSCF_QueryInterface,
155 ITSSCF_AddRef,
156 ITSSCF_Release,
157 ITSSCF_CreateInstance,
158 ITSSCF_LockServer
162 HRESULT WINAPI ITSS_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
164 int i;
165 IClassFactoryImpl *factory;
167 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
169 if ( !IsEqualGUID( &IID_IClassFactory, iid )
170 && ! IsEqualGUID( &IID_IUnknown, iid) )
171 return E_NOINTERFACE;
173 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
175 if (IsEqualGUID(object_creation[i].clsid, rclsid))
176 break;
179 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
181 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
182 return CLASS_E_CLASSNOTAVAILABLE;
185 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
187 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
188 if (factory == NULL) return E_OUTOFMEMORY;
190 factory->ITF_IClassFactory.lpVtbl = &ITSSCF_Vtbl;
191 factory->ref = 1;
193 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
195 *ppv = &(factory->ITF_IClassFactory);
197 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
199 return S_OK;
202 /*****************************************************************************/
204 typedef struct {
205 IITStorageVtbl *vtbl_IITStorage;
206 DWORD ref;
207 } ITStorageImpl;
210 HRESULT WINAPI ITStorageImpl_QueryInterface(
211 IITStorage* iface,
212 REFIID riid,
213 void** ppvObject)
215 ITStorageImpl *This = (ITStorageImpl *)iface;
216 if (IsEqualGUID(riid, &IID_IUnknown)
217 || IsEqualGUID(riid, &IID_IITStorage))
219 IClassFactory_AddRef(iface);
220 *ppvObject = This;
221 return S_OK;
224 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
225 return E_NOINTERFACE;
228 ULONG WINAPI ITStorageImpl_AddRef(
229 IITStorage* iface)
231 ITStorageImpl *This = (ITStorageImpl *)iface;
232 TRACE("%p\n", This);
233 return ++(This->ref);
236 ULONG WINAPI ITStorageImpl_Release(
237 IITStorage* iface)
239 ITStorageImpl *This = (ITStorageImpl *)iface;
240 ULONG ref = --This->ref;
242 if (ref == 0)
243 HeapFree(GetProcessHeap(), 0, This);
245 return ref;
248 HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
249 IITStorage* iface,
250 const WCHAR* pwcsName,
251 DWORD grfMode,
252 DWORD reserved,
253 IStorage** ppstgOpen)
255 ITStorageImpl *This = (ITStorageImpl *)iface;
257 TRACE("%p %s %lu %lu %p\n", This,
258 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
260 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
261 0, reserved, ppstgOpen);
264 HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
265 IITStorage* iface,
266 ILockBytes* plkbyt,
267 DWORD grfMode,
268 DWORD reserved,
269 IStorage** ppstgOpen)
271 ITStorageImpl *This = (ITStorageImpl *)iface;
272 FIXME("%p\n", This);
273 return E_NOTIMPL;
276 HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
277 IITStorage* iface,
278 const WCHAR* pwcsName)
280 ITStorageImpl *This = (ITStorageImpl *)iface;
281 FIXME("%p\n", This);
282 return E_NOTIMPL;
285 HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
286 IITStorage* iface,
287 ILockBytes* plkbyt)
289 ITStorageImpl *This = (ITStorageImpl *)iface;
290 FIXME("%p\n", This);
291 return E_NOTIMPL;
294 HRESULT WINAPI ITStorageImpl_StgOpenStorage(
295 IITStorage* iface,
296 const WCHAR* pwcsName,
297 IStorage* pstgPriority,
298 DWORD grfMode,
299 SNB snbExclude,
300 DWORD reserved,
301 IStorage** ppstgOpen)
303 ITStorageImpl *This = (ITStorageImpl *)iface;
305 TRACE("%p %s %p %ld %p\n", This, debugstr_w( pwcsName ),
306 pstgPriority, grfMode, snbExclude );
308 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
309 snbExclude, reserved, ppstgOpen);
312 HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
313 IITStorage* iface,
314 ILockBytes* plkbyt,
315 IStorage* pStgPriority,
316 DWORD grfMode,
317 SNB snbExclude,
318 DWORD reserved,
319 IStorage** ppstgOpen)
321 ITStorageImpl *This = (ITStorageImpl *)iface;
322 FIXME("%p\n", This);
323 return E_NOTIMPL;
326 HRESULT WINAPI ITStorageImpl_StgSetTimes(
327 IITStorage* iface,
328 WCHAR* lpszName,
329 FILETIME* pctime,
330 FILETIME* patime,
331 FILETIME* pmtime)
333 ITStorageImpl *This = (ITStorageImpl *)iface;
334 FIXME("%p\n", This);
335 return E_NOTIMPL;
338 HRESULT WINAPI ITStorageImpl_SetControlData(
339 IITStorage* iface,
340 PITS_Control_Data pControlData)
342 ITStorageImpl *This = (ITStorageImpl *)iface;
343 FIXME("%p\n", This);
344 return E_NOTIMPL;
347 HRESULT WINAPI ITStorageImpl_DefaultControlData(
348 IITStorage* iface,
349 PITS_Control_Data* ppControlData)
351 ITStorageImpl *This = (ITStorageImpl *)iface;
352 FIXME("%p\n", This);
353 return E_NOTIMPL;
356 HRESULT WINAPI ITStorageImpl_Compact(
357 IITStorage* iface,
358 const WCHAR* pwcsName,
359 ECompactionLev iLev)
361 ITStorageImpl *This = (ITStorageImpl *)iface;
362 FIXME("%p\n", This);
363 return E_NOTIMPL;
366 static IITStorageVtbl ITStorageImpl_Vtbl =
368 ITStorageImpl_QueryInterface,
369 ITStorageImpl_AddRef,
370 ITStorageImpl_Release,
371 ITStorageImpl_StgCreateDocfile,
372 ITStorageImpl_StgCreateDocfileOnILockBytes,
373 ITStorageImpl_StgIsStorageFile,
374 ITStorageImpl_StgIsStorageILockBytes,
375 ITStorageImpl_StgOpenStorage,
376 ITStorageImpl_StgOpenStorageOnILockBytes,
377 ITStorageImpl_StgSetTimes,
378 ITStorageImpl_SetControlData,
379 ITStorageImpl_DefaultControlData,
380 ITStorageImpl_Compact,
383 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
385 ITStorageImpl *its;
387 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
388 its->vtbl_IITStorage = &ITStorageImpl_Vtbl;
389 its->ref = 1;
391 TRACE("-> %p\n", its);
392 *ppObj = (LPVOID) its;
394 return S_OK;
397 /*****************************************************************************/
399 HRESULT WINAPI ITSS_DllRegisterServer(void)
401 FIXME("\n");
402 return S_OK;
405 BOOL WINAPI ITSS_DllCanUnloadNow(void)
407 FIXME("\n");
409 return FALSE;