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
39 #include "wine/unicode.h"
40 #include "wine/debug.h"
45 #include "wine/itss.h"
47 WINE_DEFAULT_DEBUG_CHANNEL(itss);
49 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
52 static HINSTANCE hInst;
54 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
57 case DLL_PROCESS_ATTACH:
58 DisableThreadLibraryCalls(hInstDLL);
61 case DLL_PROCESS_DETACH:
67 /******************************************************************************
71 IClassFactory IClassFactory_iface;
72 HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
75 static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
77 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
81 ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
83 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
85 if (IsEqualGUID(riid, &IID_IUnknown) ||
86 IsEqualGUID(riid, &IID_IClassFactory))
88 IClassFactory_AddRef(iface);
93 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
97 static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
103 static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
110 static HRESULT WINAPI ITSSCF_CreateInstance(LPCLASSFACTORY iface, LPUNKNOWN pOuter,
111 REFIID riid, LPVOID *ppobj)
113 IClassFactoryImpl *This = impl_from_IClassFactory(iface);
117 TRACE("(%p)->(%p,%s,%p)\n", This, pOuter, debugstr_guid(riid), ppobj);
120 hres = This->pfnCreateInstance(pOuter, (LPVOID *) &punk);
121 if (SUCCEEDED(hres)) {
122 hres = IUnknown_QueryInterface(punk, riid, ppobj);
123 IUnknown_Release(punk);
128 static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
130 TRACE("(%p)->(%d)\n", iface, dolock);
140 static const IClassFactoryVtbl ITSSCF_Vtbl =
142 ITSSCF_QueryInterface,
145 ITSSCF_CreateInstance,
149 static const IClassFactoryImpl ITStorage_factory = { { &ITSSCF_Vtbl }, ITSS_create };
150 static const IClassFactoryImpl MSITStore_factory = { { &ITSSCF_Vtbl }, ITS_IParseDisplayName_create };
151 static const IClassFactoryImpl ITSProtocol_factory = { { &ITSSCF_Vtbl }, ITSProtocol_create };
153 /***********************************************************************
154 * DllGetClassObject (ITSS.@)
156 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
158 const IClassFactoryImpl *factory;
160 TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
162 if (IsEqualGUID(&CLSID_ITStorage, rclsid))
163 factory = &ITStorage_factory;
164 else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
165 factory = &MSITStore_factory;
166 else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
167 factory = &ITSProtocol_factory;
170 FIXME("%s: no class found.\n", debugstr_guid(rclsid));
171 return CLASS_E_CLASSNOTAVAILABLE;
174 return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
177 /*****************************************************************************/
180 IITStorage IITStorage_iface;
184 static inline ITStorageImpl *impl_from_IITStorage(IITStorage *iface)
186 return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
190 static HRESULT WINAPI ITStorageImpl_QueryInterface(
195 ITStorageImpl *This = impl_from_IITStorage(iface);
196 if (IsEqualGUID(riid, &IID_IUnknown)
197 || IsEqualGUID(riid, &IID_IITStorage))
199 IClassFactory_AddRef(iface);
204 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
205 return E_NOINTERFACE;
208 static ULONG WINAPI ITStorageImpl_AddRef(
211 ITStorageImpl *This = impl_from_IITStorage(iface);
213 return InterlockedIncrement(&This->ref);
216 static ULONG WINAPI ITStorageImpl_Release(
219 ITStorageImpl *This = impl_from_IITStorage(iface);
220 ULONG ref = InterlockedDecrement(&This->ref);
223 HeapFree(GetProcessHeap(), 0, This);
230 static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
232 const WCHAR* pwcsName,
235 IStorage** ppstgOpen)
237 ITStorageImpl *This = impl_from_IITStorage(iface);
239 TRACE("%p %s %u %u %p\n", This,
240 debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
242 return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
243 0, reserved, ppstgOpen);
246 static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
251 IStorage** ppstgOpen)
253 ITStorageImpl *This = impl_from_IITStorage(iface);
258 static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
260 const WCHAR* pwcsName)
262 ITStorageImpl *This = impl_from_IITStorage(iface);
267 static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
271 ITStorageImpl *This = impl_from_IITStorage(iface);
276 static HRESULT WINAPI ITStorageImpl_StgOpenStorage(
278 const WCHAR* pwcsName,
279 IStorage* pstgPriority,
283 IStorage** ppstgOpen)
285 ITStorageImpl *This = impl_from_IITStorage(iface);
287 TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
288 pstgPriority, grfMode, snbExclude );
290 return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
291 snbExclude, reserved, ppstgOpen);
294 static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
297 IStorage* pStgPriority,
301 IStorage** ppstgOpen)
303 ITStorageImpl *This = impl_from_IITStorage(iface);
308 static HRESULT WINAPI ITStorageImpl_StgSetTimes(
310 const WCHAR* lpszName,
311 const FILETIME* pctime,
312 const FILETIME* patime,
313 const FILETIME* pmtime)
315 ITStorageImpl *This = impl_from_IITStorage(iface);
320 static HRESULT WINAPI ITStorageImpl_SetControlData(
322 PITS_Control_Data pControlData)
324 ITStorageImpl *This = impl_from_IITStorage(iface);
329 static HRESULT WINAPI ITStorageImpl_DefaultControlData(
331 PITS_Control_Data* ppControlData)
333 ITStorageImpl *This = impl_from_IITStorage(iface);
338 static HRESULT WINAPI ITStorageImpl_Compact(
340 const WCHAR* pwcsName,
343 ITStorageImpl *This = impl_from_IITStorage(iface);
348 static const IITStorageVtbl ITStorageImpl_Vtbl =
350 ITStorageImpl_QueryInterface,
351 ITStorageImpl_AddRef,
352 ITStorageImpl_Release,
353 ITStorageImpl_StgCreateDocfile,
354 ITStorageImpl_StgCreateDocfileOnILockBytes,
355 ITStorageImpl_StgIsStorageFile,
356 ITStorageImpl_StgIsStorageILockBytes,
357 ITStorageImpl_StgOpenStorage,
358 ITStorageImpl_StgOpenStorageOnILockBytes,
359 ITStorageImpl_StgSetTimes,
360 ITStorageImpl_SetControlData,
361 ITStorageImpl_DefaultControlData,
362 ITStorageImpl_Compact,
365 static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
370 return CLASS_E_NOAGGREGATION;
372 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
373 its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl;
376 TRACE("-> %p\n", its);
383 /*****************************************************************************/
385 HRESULT WINAPI DllCanUnloadNow(void)
387 TRACE("dll_count = %u\n", dll_count);
388 return dll_count ? S_FALSE : S_OK;
391 /***********************************************************************
392 * DllRegisterServer (ITSS.@)
394 HRESULT WINAPI DllRegisterServer(void)
396 return __wine_register_resources( hInst );
399 /***********************************************************************
400 * DllUnregisterServer (ITSS.@)
402 HRESULT WINAPI DllUnregisterServer(void)
404 return __wine_unregister_resources( hInst );