Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmoniker.c
Go to the documentation of this file.
00001 /* 00002 * ITSS Moniker implementation 00003 * 00004 * Copyright 2004 Mike McCormack 00005 * 00006 * Implementation of the infamous mk:@MSITStore moniker 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00021 */ 00022 00023 #include "config.h" 00024 00025 #include <stdarg.h> 00026 #include <stdio.h> 00027 00028 #define COBJMACROS 00029 00030 #include "windef.h" 00031 #include "winbase.h" 00032 #include "winuser.h" 00033 #include "ole2.h" 00034 00035 #include "wine/itss.h" 00036 #include "wine/unicode.h" 00037 #include "wine/debug.h" 00038 00039 #include "itsstor.h" 00040 00041 WINE_DEFAULT_DEBUG_CHANNEL(itss); 00042 00043 /*****************************************************************************/ 00044 00045 typedef struct { 00046 IMoniker IMoniker_iface; 00047 LONG ref; 00048 LPWSTR szHtml; 00049 WCHAR szFile[1]; 00050 } ITS_IMonikerImpl; 00051 00052 static inline ITS_IMonikerImpl *impl_from_IMoniker(IMoniker *iface) 00053 { 00054 return CONTAINING_RECORD(iface, ITS_IMonikerImpl, IMoniker_iface); 00055 } 00056 00057 /*** IUnknown methods ***/ 00058 static HRESULT WINAPI ITS_IMonikerImpl_QueryInterface( 00059 IMoniker* iface, 00060 REFIID riid, 00061 void** ppvObject) 00062 { 00063 ITS_IMonikerImpl *This = impl_from_IMoniker(iface); 00064 00065 if (IsEqualGUID(riid, &IID_IUnknown) 00066 || IsEqualGUID(riid, &IID_IParseDisplayName)) 00067 { 00068 IClassFactory_AddRef(iface); 00069 *ppvObject = This; 00070 return S_OK; 00071 } 00072 00073 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject); 00074 return E_NOINTERFACE; 00075 } 00076 00077 static ULONG WINAPI ITS_IMonikerImpl_AddRef( 00078 IMoniker* iface) 00079 { 00080 ITS_IMonikerImpl *This = impl_from_IMoniker(iface); 00081 TRACE("%p\n", This); 00082 return InterlockedIncrement(&This->ref); 00083 } 00084 00085 static ULONG WINAPI ITS_IMonikerImpl_Release( 00086 IMoniker* iface) 00087 { 00088 ITS_IMonikerImpl *This = impl_from_IMoniker(iface); 00089 ULONG ref = InterlockedDecrement(&This->ref); 00090 00091 if (ref == 0) { 00092 HeapFree(GetProcessHeap(), 0, This); 00093 ITSS_UnlockModule(); 00094 } 00095 00096 return ref; 00097 } 00098 00099 /*** IPersist methods ***/ 00100 static HRESULT WINAPI ITS_IMonikerImpl_GetClassID( 00101 IMoniker* iface, 00102 CLSID* pClassID) 00103 { 00104 ITS_IMonikerImpl *This = impl_from_IMoniker(iface); 00105 00106 TRACE("%p %p\n", This, pClassID); 00107 *pClassID = CLSID_ITStorage; 00108 return S_OK; 00109 } 00110 00111 /*** IPersistStream methods ***/ 00112 static HRESULT WINAPI ITS_IMonikerImpl_IsDirty( 00113 IMoniker* iface) 00114 { 00115 FIXME("\n"); 00116 return E_NOTIMPL; 00117 } 00118 00119 static HRESULT WINAPI ITS_IMonikerImpl_Load( 00120 IMoniker* iface, 00121 IStream* pStm) 00122 { 00123 FIXME("\n"); 00124 return E_NOTIMPL; 00125 } 00126 00127 static HRESULT WINAPI ITS_IMonikerImpl_Save( 00128 IMoniker* iface, 00129 IStream* pStm, 00130 BOOL fClearDirty) 00131 { 00132 FIXME("\n"); 00133 return E_NOTIMPL; 00134 } 00135 00136 static HRESULT WINAPI ITS_IMonikerImpl_GetSizeMax( 00137 IMoniker* iface, 00138 ULARGE_INTEGER* pcbSize) 00139 { 00140 FIXME("\n"); 00141 return E_NOTIMPL; 00142 } 00143 00144 /*** IMoniker methods ***/ 00145 static HRESULT WINAPI ITS_IMonikerImpl_BindToObject( 00146 IMoniker* iface, 00147 IBindCtx* pbc, 00148 IMoniker* pmkToLeft, 00149 REFIID riidResult, 00150 void** ppvResult) 00151 { 00152 FIXME("\n"); 00153 return E_NOTIMPL; 00154 } 00155 00156 static HRESULT WINAPI ITS_IMonikerImpl_BindToStorage( 00157 IMoniker* iface, 00158 IBindCtx* pbc, 00159 IMoniker* pmkToLeft, 00160 REFIID riid, 00161 void** ppvObj) 00162 { 00163 ITS_IMonikerImpl *This = impl_from_IMoniker(iface); 00164 DWORD grfMode = STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE; 00165 HRESULT r; 00166 IStorage *stg = NULL; 00167 00168 TRACE("%p %p %p %s %p\n", This, 00169 pbc, pmkToLeft, debugstr_guid(riid), ppvObj); 00170 00171 r = ITSS_StgOpenStorage( This->szFile, NULL, grfMode, 0, 0, &stg ); 00172 if( r == S_OK ) 00173 { 00174 TRACE("Opened storage %s\n", debugstr_w( This->szFile ) ); 00175 if (IsEqualGUID(riid, &IID_IStream)) 00176 r = IStorage_OpenStream( stg, This->szHtml, 00177 NULL, grfMode, 0, (IStream**)ppvObj ); 00178 else if (IsEqualGUID(riid, &IID_IStorage)) 00179 r = IStorage_OpenStorage( stg, This->szHtml, 00180 NULL, grfMode, NULL, 0, (IStorage**)ppvObj ); 00181 else 00182 r = STG_E_ACCESSDENIED; 00183 IStorage_Release( stg ); 00184 } 00185 00186 return r; 00187 } 00188 00189 static HRESULT WINAPI ITS_IMonikerImpl_Reduce( 00190 IMoniker* iface, 00191 IBindCtx* pbc, 00192 DWORD dwReduceHowFar, 00193 IMoniker** ppmkToLeft, 00194 IMoniker** ppmkReduced) 00195 { 00196 FIXME("\n"); 00197 return E_NOTIMPL; 00198 } 00199 00200 static HRESULT WINAPI ITS_IMonikerImpl_ComposeWith( 00201 IMoniker* iface, 00202 IMoniker* pmkRight, 00203 BOOL fOnlyIfNotGeneric, 00204 IMoniker** ppmkComposite) 00205 { 00206 FIXME("\n"); 00207 return E_NOTIMPL; 00208 } 00209 00210 static HRESULT WINAPI ITS_IMonikerImpl_Enum( 00211 IMoniker* iface, 00212 BOOL fForward, 00213 IEnumMoniker** ppenumMoniker) 00214 { 00215 FIXME("\n"); 00216 return E_NOTIMPL; 00217 } 00218 00219 static HRESULT WINAPI ITS_IMonikerImpl_IsEqual( 00220 IMoniker* iface, 00221 IMoniker* pmkOtherMoniker) 00222 { 00223 FIXME("\n"); 00224 return E_NOTIMPL; 00225 } 00226 00227 static HRESULT WINAPI ITS_IMonikerImpl_Hash( 00228 IMoniker* iface, 00229 DWORD* pdwHash) 00230 { 00231 FIXME("\n"); 00232 return E_NOTIMPL; 00233 } 00234 00235 static HRESULT WINAPI ITS_IMonikerImpl_IsRunning( 00236 IMoniker* iface, 00237 IBindCtx* pbc, 00238 IMoniker* pmkToLeft, 00239 IMoniker* pmkNewlyRunning) 00240 { 00241 FIXME("\n"); 00242 return E_NOTIMPL; 00243 } 00244 00245 static HRESULT WINAPI ITS_IMonikerImpl_GetTimeOfLastChange( 00246 IMoniker* iface, 00247 IBindCtx* pbc, 00248 IMoniker* pmkToLeft, 00249 FILETIME* pFileTime) 00250 { 00251 FIXME("\n"); 00252 return E_NOTIMPL; 00253 } 00254 00255 static HRESULT WINAPI ITS_IMonikerImpl_Inverse( 00256 IMoniker* iface, 00257 IMoniker** ppmk) 00258 { 00259 FIXME("\n"); 00260 return E_NOTIMPL; 00261 } 00262 00263 static HRESULT WINAPI ITS_IMonikerImpl_CommonPrefixWith( 00264 IMoniker* iface, 00265 IMoniker* pmkOther, 00266 IMoniker** ppmkPrefix) 00267 { 00268 FIXME("\n"); 00269 return E_NOTIMPL; 00270 } 00271 00272 static HRESULT WINAPI ITS_IMonikerImpl_RelativePathTo( 00273 IMoniker* iface, 00274 IMoniker* pmkOther, 00275 IMoniker** ppmkRelPath) 00276 { 00277 FIXME("\n"); 00278 return E_NOTIMPL; 00279 } 00280 00281 static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName( 00282 IMoniker* iface, 00283 IBindCtx* pbc, 00284 IMoniker* pmkToLeft, 00285 LPOLESTR* ppszDisplayName) 00286 { 00287 ITS_IMonikerImpl *This = impl_from_IMoniker(iface); 00288 static const WCHAR szFormat[] = { 00289 'm','s','-','i','t','s',':','%','s',':',':','%','s',0 }; 00290 DWORD len = sizeof szFormat / sizeof(WCHAR); 00291 LPWSTR str; 00292 00293 TRACE("%p %p %p %p\n", iface, pbc, pmkToLeft, ppszDisplayName); 00294 00295 len = strlenW( This->szFile ) + strlenW( This->szHtml ); 00296 str = CoTaskMemAlloc( len*sizeof(WCHAR) ); 00297 sprintfW( str, szFormat, This->szFile, This->szHtml ); 00298 00299 *ppszDisplayName = str; 00300 00301 return S_OK; 00302 } 00303 00304 static HRESULT WINAPI ITS_IMonikerImpl_ParseDisplayName( 00305 IMoniker* iface, 00306 IBindCtx* pbc, 00307 IMoniker* pmkToLeft, 00308 LPOLESTR pszDisplayName, 00309 ULONG* pchEaten, 00310 IMoniker** ppmkOut) 00311 { 00312 FIXME("\n"); 00313 return E_NOTIMPL; 00314 } 00315 00316 static HRESULT WINAPI ITS_IMonikerImpl_IsSystemMoniker( 00317 IMoniker* iface, 00318 DWORD* pdwMksys) 00319 { 00320 FIXME("\n"); 00321 return E_NOTIMPL; 00322 } 00323 00324 static const IMonikerVtbl ITS_IMonikerImpl_Vtbl = 00325 { 00326 ITS_IMonikerImpl_QueryInterface, 00327 ITS_IMonikerImpl_AddRef, 00328 ITS_IMonikerImpl_Release, 00329 ITS_IMonikerImpl_GetClassID, 00330 ITS_IMonikerImpl_IsDirty, 00331 ITS_IMonikerImpl_Load, 00332 ITS_IMonikerImpl_Save, 00333 ITS_IMonikerImpl_GetSizeMax, 00334 ITS_IMonikerImpl_BindToObject, 00335 ITS_IMonikerImpl_BindToStorage, 00336 ITS_IMonikerImpl_Reduce, 00337 ITS_IMonikerImpl_ComposeWith, 00338 ITS_IMonikerImpl_Enum, 00339 ITS_IMonikerImpl_IsEqual, 00340 ITS_IMonikerImpl_Hash, 00341 ITS_IMonikerImpl_IsRunning, 00342 ITS_IMonikerImpl_GetTimeOfLastChange, 00343 ITS_IMonikerImpl_Inverse, 00344 ITS_IMonikerImpl_CommonPrefixWith, 00345 ITS_IMonikerImpl_RelativePathTo, 00346 ITS_IMonikerImpl_GetDisplayName, 00347 ITS_IMonikerImpl_ParseDisplayName, 00348 ITS_IMonikerImpl_IsSystemMoniker 00349 }; 00350 00351 static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n ) 00352 { 00353 ITS_IMonikerImpl *itsmon; 00354 DWORD sz; 00355 00356 /* szFile[1] has space for one character already */ 00357 sz = sizeof(ITS_IMonikerImpl) + strlenW( name )*sizeof(WCHAR); 00358 00359 itsmon = HeapAlloc( GetProcessHeap(), 0, sz ); 00360 itsmon->IMoniker_iface.lpVtbl = &ITS_IMonikerImpl_Vtbl; 00361 itsmon->ref = 1; 00362 strcpyW( itsmon->szFile, name ); 00363 itsmon->szHtml = &itsmon->szFile[n]; 00364 00365 while( *itsmon->szHtml == ':' ) 00366 *itsmon->szHtml++ = 0; 00367 00368 TRACE("-> %p %s %s\n", itsmon, 00369 debugstr_w(itsmon->szFile), debugstr_w(itsmon->szHtml) ); 00370 *ppObj = &itsmon->IMoniker_iface; 00371 00372 ITSS_LockModule(); 00373 return S_OK; 00374 } 00375 00376 /*****************************************************************************/ 00377 00378 typedef struct { 00379 IParseDisplayName IParseDisplayName_iface; 00380 LONG ref; 00381 } ITS_IParseDisplayNameImpl; 00382 00383 static inline ITS_IParseDisplayNameImpl *impl_from_IParseDisplayName(IParseDisplayName *iface) 00384 { 00385 return CONTAINING_RECORD(iface, ITS_IParseDisplayNameImpl, IParseDisplayName_iface); 00386 } 00387 00388 static HRESULT WINAPI ITS_IParseDisplayNameImpl_QueryInterface( 00389 IParseDisplayName* iface, 00390 REFIID riid, 00391 void** ppvObject) 00392 { 00393 ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface); 00394 00395 if (IsEqualGUID(riid, &IID_IUnknown) 00396 || IsEqualGUID(riid, &IID_IParseDisplayName)) 00397 { 00398 IClassFactory_AddRef(iface); 00399 *ppvObject = This; 00400 return S_OK; 00401 } 00402 00403 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject); 00404 return E_NOINTERFACE; 00405 } 00406 00407 static ULONG WINAPI ITS_IParseDisplayNameImpl_AddRef( 00408 IParseDisplayName* iface) 00409 { 00410 ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface); 00411 TRACE("%p\n", This); 00412 return InterlockedIncrement(&This->ref); 00413 } 00414 00415 static ULONG WINAPI ITS_IParseDisplayNameImpl_Release( 00416 IParseDisplayName* iface) 00417 { 00418 ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface); 00419 ULONG ref = InterlockedDecrement(&This->ref); 00420 00421 if (ref == 0) { 00422 HeapFree(GetProcessHeap(), 0, This); 00423 ITSS_UnlockModule(); 00424 } 00425 00426 return ref; 00427 } 00428 00429 static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName( 00430 IParseDisplayName *iface, 00431 IBindCtx * pbc, 00432 LPOLESTR pszDisplayName, 00433 ULONG * pchEaten, 00434 IMoniker ** ppmkOut) 00435 { 00436 static const WCHAR szPrefix[] = { 00437 '@','M','S','I','T','S','t','o','r','e',':',0 }; 00438 const DWORD prefix_len = (sizeof szPrefix/sizeof szPrefix[0])-1; 00439 DWORD n; 00440 00441 ITS_IParseDisplayNameImpl *This = impl_from_IParseDisplayName(iface); 00442 00443 TRACE("%p %s %p %p\n", This, 00444 debugstr_w( pszDisplayName ), pchEaten, ppmkOut ); 00445 00446 if( strncmpiW( pszDisplayName, szPrefix, prefix_len ) ) 00447 return MK_E_SYNTAX; 00448 00449 /* search backwards for a double colon */ 00450 for( n = strlenW( pszDisplayName ) - 3; prefix_len <= n; n-- ) 00451 if( ( pszDisplayName[n] == ':' ) && ( pszDisplayName[n+1] == ':' ) ) 00452 break; 00453 00454 if( n < prefix_len ) 00455 return MK_E_SYNTAX; 00456 00457 if( !pszDisplayName[n+2] ) 00458 return MK_E_SYNTAX; 00459 00460 *pchEaten = strlenW( pszDisplayName ) - n - 3; 00461 00462 return ITS_IMoniker_create( ppmkOut, 00463 &pszDisplayName[prefix_len], n-prefix_len ); 00464 } 00465 00466 static const IParseDisplayNameVtbl ITS_IParseDisplayNameImpl_Vtbl = 00467 { 00468 ITS_IParseDisplayNameImpl_QueryInterface, 00469 ITS_IParseDisplayNameImpl_AddRef, 00470 ITS_IParseDisplayNameImpl_Release, 00471 ITS_IParseDisplayNameImpl_ParseDisplayName 00472 }; 00473 00474 HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj) 00475 { 00476 ITS_IParseDisplayNameImpl *its; 00477 00478 if( pUnkOuter ) 00479 return CLASS_E_NOAGGREGATION; 00480 00481 its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITS_IParseDisplayNameImpl) ); 00482 its->IParseDisplayName_iface.lpVtbl = &ITS_IParseDisplayNameImpl_Vtbl; 00483 its->ref = 1; 00484 00485 TRACE("-> %p\n", its); 00486 *ppObj = its; 00487 00488 ITSS_LockModule(); 00489 return S_OK; 00490 } Generated on Sun May 27 2012 04:24:14 for ReactOS by
1.7.6.1
|