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
41 #include "wine/unicode.h"
42 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(itss
);
50 DEFINE_GUID(CLSID_ITStorage
,0x5d02926a,0x212e,0x11d0,0x9d,0xf9,0x00,0xa0,0xc9,0x22,0xe6,0xec );
51 DEFINE_GUID(CLSID_ITSProtocol
,0x9d148290,0xb9c8,0x11d0,0xa4,0xcc,0x00,0x00,0xf8,0x01,0x49,0xf6);
52 DEFINE_GUID(IID_IITStorage
, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec);
54 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
56 BOOL WINAPI
DllMain(HINSTANCE hInstDLL
, DWORD fdwReason
, LPVOID lpv
)
59 case DLL_PROCESS_ATTACH
:
60 DisableThreadLibraryCalls(hInstDLL
);
62 case DLL_PROCESS_DETACH
:
68 /******************************************************************************
72 IClassFactory ITF_IClassFactory
;
75 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
78 struct object_creation_info
82 HRESULT (*pfnCreateInstance
)(IUnknown
*pUnkOuter
, LPVOID
*ppObj
);
85 static const struct object_creation_info object_creation
[] =
87 { &CLSID_ITStorage
, "ITStorage", ITSS_create
},
88 { &CLSID_ITSProtocol
, "ITSProtocol", ITS_IParseDisplayName_create
},
92 ITSSCF_QueryInterface(LPCLASSFACTORY iface
,REFIID riid
,LPVOID
*ppobj
)
94 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
96 if (IsEqualGUID(riid
, &IID_IUnknown
)
97 || IsEqualGUID(riid
, &IID_IClassFactory
))
99 IClassFactory_AddRef(iface
);
104 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppobj
);
105 return E_NOINTERFACE
;
108 static ULONG WINAPI
ITSSCF_AddRef(LPCLASSFACTORY iface
)
110 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
111 return InterlockedIncrement(&This
->ref
);
114 static ULONG WINAPI
ITSSCF_Release(LPCLASSFACTORY iface
)
116 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
118 ULONG ref
= InterlockedDecrement(&This
->ref
);
121 HeapFree(GetProcessHeap(), 0, This
);
127 static HRESULT WINAPI
ITSSCF_CreateInstance(LPCLASSFACTORY iface
, LPUNKNOWN pOuter
,
128 REFIID riid
, LPVOID
*ppobj
)
130 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
134 TRACE("(%p)->(%p,%s,%p)\n",This
,pOuter
,debugstr_guid(riid
),ppobj
);
137 hres
= This
->pfnCreateInstance(pOuter
, (LPVOID
*) &punk
);
138 if (SUCCEEDED(hres
)) {
139 hres
= IUnknown_QueryInterface(punk
, riid
, ppobj
);
140 IUnknown_Release(punk
);
145 static HRESULT WINAPI
ITSSCF_LockServer(LPCLASSFACTORY iface
,BOOL dolock
)
147 IClassFactoryImpl
*This
= (IClassFactoryImpl
*)iface
;
148 FIXME("(%p)->(%d),stub!\n",This
,dolock
);
152 static IClassFactoryVtbl ITSSCF_Vtbl
=
154 ITSSCF_QueryInterface
,
157 ITSSCF_CreateInstance
,
162 HRESULT WINAPI
ITSS_DllGetClassObject(REFCLSID rclsid
, REFIID iid
, LPVOID
*ppv
)
165 IClassFactoryImpl
*factory
;
167 TRACE("%s %s %p\n",debugstr_guid(rclsid
), debugstr_guid(iid
), ppv
);
169 if ( !IsEqualGUID( &IID_IClassFactory
, iid
)
170 && ! IsEqualGUID( &IID_IUnknown
, iid
) )
171 return E_NOINTERFACE
;
173 for (i
=0; i
< sizeof(object_creation
)/sizeof(object_creation
[0]); i
++)
175 if (IsEqualGUID(object_creation
[i
].clsid
, rclsid
))
179 if (i
== sizeof(object_creation
)/sizeof(object_creation
[0]))
181 FIXME("%s: no class found.\n", debugstr_guid(rclsid
));
182 return CLASS_E_CLASSNOTAVAILABLE
;
185 TRACE("Creating a class factory for %s\n",object_creation
[i
].szClassName
);
187 factory
= HeapAlloc(GetProcessHeap(), 0, sizeof(*factory
));
188 if (factory
== NULL
) return E_OUTOFMEMORY
;
190 factory
->ITF_IClassFactory
.lpVtbl
= &ITSSCF_Vtbl
;
193 factory
->pfnCreateInstance
= object_creation
[i
].pfnCreateInstance
;
195 *ppv
= &(factory
->ITF_IClassFactory
);
197 TRACE("(%p) <- %p\n", ppv
, &(factory
->ITF_IClassFactory
) );
202 /*****************************************************************************/
205 IITStorageVtbl
*vtbl_IITStorage
;
210 HRESULT WINAPI
ITStorageImpl_QueryInterface(
215 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
216 if (IsEqualGUID(riid
, &IID_IUnknown
)
217 || IsEqualGUID(riid
, &IID_IITStorage
))
219 IClassFactory_AddRef(iface
);
224 WARN("(%p)->(%s,%p),not found\n",This
,debugstr_guid(riid
),ppvObject
);
225 return E_NOINTERFACE
;
228 ULONG WINAPI
ITStorageImpl_AddRef(
231 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
233 return ++(This
->ref
);
236 ULONG WINAPI
ITStorageImpl_Release(
239 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
240 ULONG ref
= --This
->ref
;
243 HeapFree(GetProcessHeap(), 0, This
);
248 HRESULT WINAPI
ITStorageImpl_StgCreateDocfile(
250 const WCHAR
* pwcsName
,
253 IStorage
** ppstgOpen
)
255 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
257 TRACE("%p %s %lu %lu %p\n", This
,
258 debugstr_w(pwcsName
), grfMode
, reserved
, ppstgOpen
);
260 return ITSS_StgOpenStorage( pwcsName
, NULL
, grfMode
,
261 0, reserved
, ppstgOpen
);
264 HRESULT WINAPI
ITStorageImpl_StgCreateDocfileOnILockBytes(
269 IStorage
** ppstgOpen
)
271 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
276 HRESULT WINAPI
ITStorageImpl_StgIsStorageFile(
278 const WCHAR
* pwcsName
)
280 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
285 HRESULT WINAPI
ITStorageImpl_StgIsStorageILockBytes(
289 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
294 HRESULT WINAPI
ITStorageImpl_StgOpenStorage(
296 const WCHAR
* pwcsName
,
297 IStorage
* pstgPriority
,
301 IStorage
** ppstgOpen
)
303 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
305 TRACE("%p %s %p %ld %p\n", This
, debugstr_w( pwcsName
),
306 pstgPriority
, grfMode
, snbExclude
);
308 return ITSS_StgOpenStorage( pwcsName
, pstgPriority
, grfMode
,
309 snbExclude
, reserved
, ppstgOpen
);
312 HRESULT WINAPI
ITStorageImpl_StgOpenStorageOnILockBytes(
315 IStorage
* pStgPriority
,
319 IStorage
** ppstgOpen
)
321 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
326 HRESULT WINAPI
ITStorageImpl_StgSetTimes(
333 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
338 HRESULT WINAPI
ITStorageImpl_SetControlData(
340 PITS_Control_Data pControlData
)
342 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
347 HRESULT WINAPI
ITStorageImpl_DefaultControlData(
349 PITS_Control_Data
* ppControlData
)
351 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
356 HRESULT WINAPI
ITStorageImpl_Compact(
358 const WCHAR
* pwcsName
,
361 ITStorageImpl
*This
= (ITStorageImpl
*)iface
;
366 static IITStorageVtbl ITStorageImpl_Vtbl
=
368 ITStorageImpl_QueryInterface
,
369 ITStorageImpl_AddRef
,
370 ITStorageImpl_Release
,
371 ITStorageImpl_StgCreateDocfile
,
372 ITStorageImpl_StgCreateDocfileOnILockBytes
,
373 ITStorageImpl_StgIsStorageFile
,
374 ITStorageImpl_StgIsStorageILockBytes
,
375 ITStorageImpl_StgOpenStorage
,
376 ITStorageImpl_StgOpenStorageOnILockBytes
,
377 ITStorageImpl_StgSetTimes
,
378 ITStorageImpl_SetControlData
,
379 ITStorageImpl_DefaultControlData
,
380 ITStorageImpl_Compact
,
383 static HRESULT
ITSS_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
387 its
= HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl
) );
388 its
->vtbl_IITStorage
= &ITStorageImpl_Vtbl
;
391 TRACE("-> %p\n", its
);
392 *ppObj
= (LPVOID
) its
;
397 /*****************************************************************************/
399 HRESULT WINAPI
ITSS_DllRegisterServer(void)
405 BOOL WINAPI
ITSS_DllCanUnloadNow(void)