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
40 #include "wine/unicode.h"
41 #include "wine/debug.h"
46 #include "wine/itss.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(itss
);
50 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 const IClassFactoryVtbl
*lpVtbl
;
71 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
75 ITSSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
77 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
79 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
80 IsEqualGUID(riid
, &IID_IClassFactory
))
82 IClassFactory_AddRef(iface
);
87 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
91 static ULONG WINAPI
ITSSCF_AddRef(LPCLASSFACTORY iface
)
93 InterlockedIncrement(&dll_count
);
97 static ULONG WINAPI
ITSSCF_Release(LPCLASSFACTORY iface
)
99 InterlockedDecrement(&dll_count
);
104 static HRESULT WINAPI
ITSSCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
105 REFIID riid
, LPVOID
*ppobj
)
107 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
111 TRACE("(%p)->(%p,%s,%p)\n", This
, pOuter
, debugstr_guid(riid
), ppobj
);
114 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
115 if (SUCCEEDED(hres
)) {
116 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
117 IUnknown_Release(punk
);
122 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
, BOOL dolock
)
124 TRACE("(%p)->(%d)\n", iface
, dolock
);
127 InterlockedIncrement(&dll_count
);
129 InterlockedDecrement(&dll_count
);
134 static const IClassFactoryVtbl ITSSCF_Vtbl
=
136 ITSSCF_QueryInterface
,
139 ITSSCF_CreateInstance
,
143 static const IClassFactoryImpl ITStorage_factory
= { &ITSSCF_Vtbl
, ITSS_create
};
144 static const IClassFactoryImpl ITSProtocol_factory
= { &ITSSCF_Vtbl
, ITS_IParseDisplayName_create
};
146 /***********************************************************************
147 * DllGetClassObject (ITSS.@)
149 HRESULT WINAPI
DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
151 const IClassFactoryImpl
*factory
;
153 TRACE("%s %s %p\n", debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
155 if (IsEqualGUID(&CLSID_ITStorage
, rclsid
))
156 factory
= &ITStorage_factory
;
157 else if (IsEqualGUID(&CLSID_ITSProtocol
, rclsid
))
158 factory
= &ITSProtocol_factory
;
161 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
162 return CLASS_E_CLASSNOTAVAILABLE
;
165 return IUnknown_QueryInterface( (IUnknown
*) factory
, iid
, ppv
);
168 /*****************************************************************************/
171 const IITStorageVtbl
*vtbl_IITStorage
;
176 static HRESULT WINAPI
ITStorageImpl_QueryInterface(
181 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
182 if (IsEqualGUID(riid
, &IID_IUnknown
)
183 || IsEqualGUID(riid
, &IID_IITStorage
))
185 IClassFactory_AddRef(iface
);
190 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
191 return E_NOINTERFACE
;
194 static ULONG WINAPI
ITStorageImpl_AddRef(
197 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
199 return InterlockedIncrement(&This
->ref
);
202 static ULONG WINAPI
ITStorageImpl_Release(
205 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
206 ULONG ref
= InterlockedDecrement(&This
->ref
);
209 HeapFree(GetProcessHeap(), 0, This
);
210 InterlockedDecrement(&dll_count
);
216 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
218 const WCHAR
* pwcsName
,
221 IStorage
** ppstgOpen
)
223 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
225 TRACE("%p %s %u %u %p\n", This
,
226 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
228 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
229 0, reserved
, ppstgOpen
);
232 static HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
237 IStorage
** ppstgOpen
)
239 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
244 static HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
246 const WCHAR
* pwcsName
)
248 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
253 static HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
257 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
262 static HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
264 const WCHAR
* pwcsName
,
265 IStorage
* pstgPriority
,
269 IStorage
** ppstgOpen
)
271 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
273 TRACE("%p %s %p %d %p\n", This
, debugstr_w( pwcsName
),
274 pstgPriority
, grfMode
, snbExclude
);
276 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
277 snbExclude
, reserved
, ppstgOpen
);
280 static HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
283 IStorage
* pStgPriority
,
287 IStorage
** ppstgOpen
)
289 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
294 static HRESULT WINAPI
ITStorageImpl_StgSetTimes(
301 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
306 static HRESULT WINAPI
ITStorageImpl_SetControlData(
308 PITS_Control_Data pControlData
)
310 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
315 static HRESULT WINAPI
ITStorageImpl_DefaultControlData(
317 PITS_Control_Data
* ppControlData
)
319 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
324 static HRESULT WINAPI
ITStorageImpl_Compact(
326 const WCHAR
* pwcsName
,
329 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
334 static const IITStorageVtbl ITStorageImpl_Vtbl
=
336 ITStorageImpl_QueryInterface
,
337 ITStorageImpl_AddRef
,
338 ITStorageImpl_Release
,
339 ITStorageImpl_StgCreateDocfile
,
340 ITStorageImpl_StgCreateDocfileOnILockBytes
,
341 ITStorageImpl_StgIsStorageFile
,
342 ITStorageImpl_StgIsStorageILockBytes
,
343 ITStorageImpl_StgOpenStorage
,
344 ITStorageImpl_StgOpenStorageOnILockBytes
,
345 ITStorageImpl_StgSetTimes
,
346 ITStorageImpl_SetControlData
,
347 ITStorageImpl_DefaultControlData
,
348 ITStorageImpl_Compact
,
351 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
356 return CLASS_E_NOAGGREGATION
;
358 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
359 its
->vtbl_IITStorage
= &ITStorageImpl_Vtbl
;
362 TRACE("-> %p\n", its
);
363 *ppObj
= (LPVOID
) its
;
364 InterlockedIncrement(&dll_count
);
369 /*****************************************************************************/
371 HRESULT WINAPI
DllCanUnloadNow(void)
373 TRACE("dll_count = %u\n", dll_count
);
374 return dll_count
? S_FALSE
: S_OK
;