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
38 #include "wine/debug.h"
43 #include "wine/itss.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(itss
);
47 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
51 /******************************************************************************
55 IClassFactory IClassFactory_iface
;
56 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
59 static inline IClassFactoryImpl
*impl_from_IClassFactory(IClassFactory
*iface
)
61 return CONTAINING_RECORD(iface
, IClassFactoryImpl
, IClassFactory_iface
);
65 ITSSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
67 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
69 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
70 IsEqualGUID(riid
, &IID_IClassFactory
))
72 IClassFactory_AddRef(iface
);
73 *ppobj
= &This
->IClassFactory_iface
;
77 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
81 static ULONG WINAPI
ITSSCF_AddRef(LPCLASSFACTORY iface
)
87 static ULONG WINAPI
ITSSCF_Release(LPCLASSFACTORY iface
)
94 static HRESULT WINAPI
ITSSCF_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
,
95 REFIID riid
, void **ppv
)
97 IClassFactoryImpl
*This
= impl_from_IClassFactory(iface
);
101 TRACE("(%p)->(%p %s %p)\n", This
, outer
, debugstr_guid(riid
), ppv
);
103 if(outer
&& !IsEqualGUID(riid
, &IID_IUnknown
)) {
105 return CLASS_E_NOAGGREGATION
;
108 hres
= This
->pfnCreateInstance(outer
, (void**)&unk
);
114 if(!IsEqualGUID(riid
, &IID_IUnknown
)) {
115 hres
= IUnknown_QueryInterface(unk
, riid
, ppv
);
116 IUnknown_Release(unk
);
123 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
125 TRACE("(%p)->(%d)\n", iface
, dolock
);
135 static const IClassFactoryVtbl ITSSCF_Vtbl
=
137 ITSSCF_QueryInterface
,
140 ITSSCF_CreateInstance
,
144 static const IClassFactoryImpl ITStorage_factory
= { { &ITSSCF_Vtbl
}, ITSS_create
};
145 static const IClassFactoryImpl MSITStore_factory
= { { &ITSSCF_Vtbl
}, ITS_IParseDisplayName_create
};
146 static const IClassFactoryImpl ITSProtocol_factory
= { { &ITSSCF_Vtbl
}, ITSProtocol_create
};
148 /***********************************************************************
149 * DllGetClassObject (ITSS.@)
151 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
153 const IClassFactoryImpl
*factory
;
155 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
157 if (IsEqualGUID(&CLSID_ITStorage
, rclsid
))
158 factory
= &ITStorage_factory
;
159 else if (IsEqualGUID(&CLSID_MSITStore
, rclsid
))
160 factory
= &MSITStore_factory
;
161 else if (IsEqualGUID(&CLSID_ITSProtocol
, rclsid
))
162 factory
= &ITSProtocol_factory
;
165 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
166 return CLASS_E_CLASSNOTAVAILABLE
;
169 return IUnknown_QueryInterface( (IUnknown
*) factory
, iid
, ppv
);
172 /*****************************************************************************/
175 IITStorage IITStorage_iface
;
179 static inline ITStorageImpl
*impl_from_IITStorage(IITStorage
*iface
)
181 return CONTAINING_RECORD(iface
, ITStorageImpl
, IITStorage_iface
);
185 static HRESULT WINAPI
ITStorageImpl_QueryInterface(
190 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
191 if (IsEqualGUID(riid
, &IID_IUnknown
)
192 || IsEqualGUID(riid
, &IID_IITStorage
))
194 IITStorage_AddRef(iface
);
199 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
200 return E_NOINTERFACE
;
203 static ULONG WINAPI
ITStorageImpl_AddRef(
206 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
208 return InterlockedIncrement(&This
->ref
);
211 static ULONG WINAPI
ITStorageImpl_Release(
214 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
215 ULONG ref
= InterlockedDecrement(&This
->ref
);
218 HeapFree(GetProcessHeap(), 0, This
);
225 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
227 const WCHAR
* pwcsName
,
230 IStorage
** ppstgOpen
)
232 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
234 TRACE("%p %s %u %u %p\n", This
,
235 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
237 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
238 0, reserved
, ppstgOpen
);
241 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
246 IStorage
** ppstgOpen
)
248 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
253 static HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
255 const WCHAR
* pwcsName
)
257 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
262 static HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
266 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
271 static HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
273 const WCHAR
* pwcsName
,
274 IStorage
* pstgPriority
,
278 IStorage
** ppstgOpen
)
280 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
282 TRACE("%p %s %p %d %p\n", This
, debugstr_w( pwcsName
),
283 pstgPriority
, grfMode
, snbExclude
);
285 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
286 snbExclude
, reserved
, ppstgOpen
);
289 static HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
292 IStorage
* pStgPriority
,
296 IStorage
** ppstgOpen
)
298 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
303 static HRESULT WINAPI
ITStorageImpl_StgSetTimes(
305 const WCHAR
* lpszName
,
306 const FILETIME
* pctime
,
307 const FILETIME
* patime
,
308 const FILETIME
* pmtime
)
310 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
315 static HRESULT WINAPI
ITStorageImpl_SetControlData(
317 PITS_Control_Data pControlData
)
319 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
324 static HRESULT WINAPI
ITStorageImpl_DefaultControlData(
326 PITS_Control_Data
* ppControlData
)
328 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
333 static HRESULT WINAPI
ITStorageImpl_Compact(
335 const WCHAR
* pwcsName
,
338 ITStorageImpl
*This
= impl_from_IITStorage(iface
);
343 static const IITStorageVtbl ITStorageImpl_Vtbl
=
345 ITStorageImpl_QueryInterface
,
346 ITStorageImpl_AddRef
,
347 ITStorageImpl_Release
,
348 ITStorageImpl_StgCreateDocfile
,
349 ITStorageImpl_StgCreateDocfileOnILockBytes
,
350 ITStorageImpl_StgIsStorageFile
,
351 ITStorageImpl_StgIsStorageILockBytes
,
352 ITStorageImpl_StgOpenStorage
,
353 ITStorageImpl_StgOpenStorageOnILockBytes
,
354 ITStorageImpl_StgSetTimes
,
355 ITStorageImpl_SetControlData
,
356 ITStorageImpl_DefaultControlData
,
357 ITStorageImpl_Compact
,
360 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
365 return CLASS_E_NOAGGREGATION
;
367 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
368 its
->IITStorage_iface
.lpVtbl
= &ITStorageImpl_Vtbl
;
371 TRACE("-> %p\n", its
);
378 /*****************************************************************************/
380 HRESULT WINAPI
DllCanUnloadNow(void)
382 TRACE("dll_count = %u\n", dll_count
);
383 return dll_count
? S_FALSE
: S_OK
;