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
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(itss);
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)
57 case DLL_PROCESS_ATTACH:
58 DisableThreadLibraryCalls(hInstDLL);
60 case DLL_PROCESS_DETACH:
66 /******************************************************************************
70 IClassFactory ITF_IClassFactory;
73 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
76 struct object_creation_info
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 },
90 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
92 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
94 if (IsEqualGUID(riid, &IID_IUnknown)
95 || IsEqualGUID(riid, &IID_IClassFactory))
97 IClassFactory_AddRef(iface);
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)
108 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
109 return InterlockedIncrement(&This->ref);
112 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
114 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
116 ULONG ref = InterlockedDecrement(&This->ref);
119 HeapFree(GetProcessHeap(), 0, This);
125 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
126 REFIID riid, LPVOID *ppobj)
128 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
132 TRACE("(%p)->(%p,%s,%p)\n",This,pOuter,debugstr_guid(riid),ppobj);
135 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
136 if (SUCCEEDED(hres)) {
137 hres = IUnknown_QueryInterface(punk, riid, ppobj);
138 IUnknown_Release(punk);
143 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface,BOOL dolock)
145 IClassFactoryImpl *This = (IClassFactoryImpl *)iface;
146 FIXME("(%p)->(%d),stub!\n",This,dolock);
150 static IClassFactoryVtbl ITSSCF_Vtbl =
152 ITSSCF_QueryInterface,
155 ITSSCF_CreateInstance,
160 HRESULT WINAPI ITSS_DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
163 IClassFactoryImpl *factory;
165 TRACE("%s %s %p\n",debugstr_guid(rclsid), debugstr_guid(iid), ppv);
167 if ( !IsEqualGUID( &IID_IClassFactory, iid )
168 && ! IsEqualGUID( &IID_IUnknown, iid) )
169 return E_NOINTERFACE;
171 for (i=0; i < sizeof(object_creation)/sizeof(object_creation[0]); i++)
173 if (IsEqualGUID(object_creation[i].clsid, rclsid))
177 if (i == sizeof(object_creation)/sizeof(object_creation[0]))
179 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
180 return CLASS_E_CLASSNOTAVAILABLE;
183 TRACE("Creating a class factory for %s\n",object_creation[i].szClassName);
185 factory = HeapAlloc(GetProcessHeap(), 0, sizeof(*factory));
186 if (factory == NULL) return E_OUTOFMEMORY;
188 factory->ITF_IClassFactory.lpVtbl = &ITSSCF_Vtbl;
191 factory->pfnCreateInstance = object_creation[i].pfnCreateInstance;
193 *ppv = &(factory->ITF_IClassFactory);
195 TRACE("(%p) <- %p\n", ppv, &(factory->ITF_IClassFactory) );
200 /*****************************************************************************/
203 IITStorageVtbl *vtbl_IITStorage;
208 HRESULT WINAPI ITStorageImpl_QueryInterface(
213 ITStorageImpl *This = (ITStorageImpl *)iface;
214 if (IsEqualGUID(riid, &IID_IUnknown)
215 || IsEqualGUID(riid, &IID_IITStorage))
217 IClassFactory_AddRef(iface);
222 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
223 return E_NOINTERFACE;
226 ULONG WINAPI ITStorageImpl_AddRef(
229 ITStorageImpl *This = (ITStorageImpl *)iface;
231 return ++(This->ref);
234 ULONG WINAPI ITStorageImpl_Release(
237 ITStorageImpl *This = (ITStorageImpl *)iface;
238 ULONG ref = --This->ref;
241 HeapFree(GetProcessHeap(), 0, This);
246 HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
248 const WCHAR* pwcsName,
251 IStorage** ppstgOpen)
253 ITStorageImpl *This = (ITStorageImpl *)iface;
255 TRACE("%p %s %lu %lu %p\n", This,
256 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
258 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
259 0, reserved, ppstgOpen);
262 HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
267 IStorage** ppstgOpen)
269 ITStorageImpl *This = (ITStorageImpl *)iface;
274 HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
276 const WCHAR* pwcsName)
278 ITStorageImpl *This = (ITStorageImpl *)iface;
283 HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
287 ITStorageImpl *This = (ITStorageImpl *)iface;
292 HRESULT WINAPI ITStorageImpl_StgOpenStorage(
294 const WCHAR* pwcsName,
295 IStorage* pstgPriority,
299 IStorage** ppstgOpen)
301 ITStorageImpl *This = (ITStorageImpl *)iface;
303 TRACE("%p %s %p %ld %p\n", This, debugstr_w( pwcsName ),
304 pstgPriority, grfMode, snbExclude );
306 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
307 snbExclude, reserved, ppstgOpen);
310 HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
313 IStorage* pStgPriority,
317 IStorage** ppstgOpen)
319 ITStorageImpl *This = (ITStorageImpl *)iface;
324 HRESULT WINAPI ITStorageImpl_StgSetTimes(
331 ITStorageImpl *This = (ITStorageImpl *)iface;
336 HRESULT WINAPI ITStorageImpl_SetControlData(
338 PITS_Control_Data pControlData)
340 ITStorageImpl *This = (ITStorageImpl *)iface;
345 HRESULT WINAPI ITStorageImpl_DefaultControlData(
347 PITS_Control_Data* ppControlData)
349 ITStorageImpl *This = (ITStorageImpl *)iface;
354 HRESULT WINAPI ITStorageImpl_Compact(
356 const WCHAR* pwcsName,
359 ITStorageImpl *This = (ITStorageImpl *)iface;
364 static IITStorageVtbl ITStorageImpl_Vtbl =
366 ITStorageImpl_QueryInterface,
367 ITStorageImpl_AddRef,
368 ITStorageImpl_Release,
369 ITStorageImpl_StgCreateDocfile,
370 ITStorageImpl_StgCreateDocfileOnILockBytes,
371 ITStorageImpl_StgIsStorageFile,
372 ITStorageImpl_StgIsStorageILockBytes,
373 ITStorageImpl_StgOpenStorage,
374 ITStorageImpl_StgOpenStorageOnILockBytes,
375 ITStorageImpl_StgSetTimes,
376 ITStorageImpl_SetControlData,
377 ITStorageImpl_DefaultControlData,
378 ITStorageImpl_Compact,
381 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
385 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
386 its->vtbl_IITStorage = &ITStorageImpl_Vtbl;
389 TRACE("-> %p\n", its);
390 *ppObj = (LPVOID) its;
395 /*****************************************************************************/
397 HRESULT WINAPI ITSS_DllRegisterServer(void)
403 BOOL WINAPI ITSS_DllCanUnloadNow(void)