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 ICOM_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
) {
107 ICOM_THIS(IClassFactoryImpl
,iface
);
108 return ++(This
->ref
);
111 static ULONG WINAPI
ITSSCF_Release(LPCLASSFACTORY iface
) {
112 ICOM_THIS(IClassFactoryImpl
,iface
);
114 ULONG ref
= --This
->ref
;
117 HeapFree(GetProcessHeap(), 0, This
);
123 static HRESULT WINAPI
ITSSCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
124 REFIID riid
, LPVOID
*ppobj
) {
125 ICOM_THIS(IClassFactoryImpl
,iface
);
129 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
131 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
136 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
141 IUnknown_Release(punk
);
145 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
) {
146 ICOM_THIS(IClassFactoryImpl
,iface
);
147 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
151 static IClassFactoryVtbl ITSSCF_Vtbl
=
153 ITSSCF_QueryInterface
,
156 ITSSCF_CreateInstance
,
161 HRESULT WINAPI
ITSS_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
164 IClassFactoryImpl
*factory
;
166 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
168 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
169 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
170 return E_NOINTERFACE
;
172 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
174 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
178 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
180 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
181 return CLASS_E_CLASSNOTAVAILABLE
;
184 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
186 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
187 if (factory
== NULL
) return E_OUTOFMEMORY
;
189 factory
->ITF_IClassFactory
.lpVtbl
= &ITSSCF_Vtbl
;
192 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
194 *ppv
= &(factory
->ITF_IClassFactory
);
196 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
201 /*****************************************************************************/
204 IITStorageVtbl
*vtbl_IITStorage
;
209 HRESULT WINAPI
ITStorageImpl_QueryInterface(
214 ICOM_THIS(ITStorageImpl
,iface
);
215 if (IsEqualGUID(riid
, &IID_IUnknown
)
216 || IsEqualGUID(riid
, &IID_IITStorage
))
218 IClassFactory_AddRef(iface
);
223 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
224 return E_NOINTERFACE
;
227 ULONG WINAPI
ITStorageImpl_AddRef(
230 ICOM_THIS(ITStorageImpl
,iface
);
232 return ++(This
->ref
);
235 ULONG WINAPI
ITStorageImpl_Release(
238 ICOM_THIS(ITStorageImpl
,iface
);
239 ULONG ref
= --This
->ref
;
242 HeapFree(GetProcessHeap(), 0, This
);
247 HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
249 const WCHAR
* pwcsName
,
252 IStorage
** ppstgOpen
)
254 ICOM_THIS(ITStorageImpl
,iface
);
256 TRACE("%p %s %lu %lu %p\n", This
,
257 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
259 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
260 0, reserved
, ppstgOpen
);
263 HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
268 IStorage
** ppstgOpen
)
270 ICOM_THIS(ITStorageImpl
,iface
);
275 HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
277 const WCHAR
* pwcsName
)
279 ICOM_THIS(ITStorageImpl
,iface
);
284 HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
288 ICOM_THIS(ITStorageImpl
,iface
);
293 HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
295 const WCHAR
* pwcsName
,
296 IStorage
* pstgPriority
,
300 IStorage
** ppstgOpen
)
302 ICOM_THIS(ITStorageImpl
,iface
);
304 TRACE("%p %s %p %ld %p\n", This
, debugstr_w( pwcsName
),
305 pstgPriority
, grfMode
, snbExclude
);
307 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
308 snbExclude
, reserved
, ppstgOpen
);
311 HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
314 IStorage
* pStgPriority
,
318 IStorage
** ppstgOpen
)
320 ICOM_THIS(ITStorageImpl
,iface
);
325 HRESULT WINAPI
ITStorageImpl_StgSetTimes(
332 ICOM_THIS(ITStorageImpl
,iface
);
337 HRESULT WINAPI
ITStorageImpl_SetControlData(
339 PITS_Control_Data pControlData
)
341 ICOM_THIS(ITStorageImpl
,iface
);
346 HRESULT WINAPI
ITStorageImpl_DefaultControlData(
348 PITS_Control_Data
* ppControlData
)
350 ICOM_THIS(ITStorageImpl
,iface
);
355 HRESULT WINAPI
ITStorageImpl_Compact(
357 const WCHAR
* pwcsName
,
360 ICOM_THIS(ITStorageImpl
,iface
);
365 static IITStorageVtbl ITStorageImpl_Vtbl
=
367 ITStorageImpl_QueryInterface
,
368 ITStorageImpl_AddRef
,
369 ITStorageImpl_Release
,
370 ITStorageImpl_StgCreateDocfile
,
371 ITStorageImpl_StgCreateDocfileOnILockBytes
,
372 ITStorageImpl_StgIsStorageFile
,
373 ITStorageImpl_StgIsStorageILockBytes
,
374 ITStorageImpl_StgOpenStorage
,
375 ITStorageImpl_StgOpenStorageOnILockBytes
,
376 ITStorageImpl_StgSetTimes
,
377 ITStorageImpl_SetControlData
,
378 ITStorageImpl_DefaultControlData
,
379 ITStorageImpl_Compact
,
382 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
386 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
387 its
->vtbl_IITStorage
= &ITStorageImpl_Vtbl
;
390 TRACE("-> %p\n", its
);
391 *ppObj
= (LPVOID
) its
;
396 /*****************************************************************************/
398 HRESULT WINAPI
ITSS_DllRegisterServer(void)
404 BOOL WINAPI
ITSS_DllCanUnloadNow(void)