From 332408b836d19527fa3b61dce18803cc739c6e70 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 25 Aug 2004 17:30:18 +0000 Subject: [PATCH] Fix the ITS moniker implementation. --- dlls/itss/chm_lib.c | 2 +- dlls/itss/itss.c | 4 ++-- dlls/itss/itsstor.h | 38 ++++++++++++++++++++++++++++++++++++++ dlls/itss/moniker.c | 28 ++++++++++++++++++++++++++-- dlls/itss/storage.c | 31 ++++++++++++++++++++++++++++--- 5 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 dlls/itss/itsstor.h diff --git a/dlls/itss/chm_lib.c b/dlls/itss/chm_lib.c index d0daef24f09..0d27ecaeeb3 100644 --- a/dlls/itss/chm_lib.c +++ b/dlls/itss/chm_lib.c @@ -626,7 +626,7 @@ struct chmFile *chm_openW(const WCHAR *filename) /* open file */ if ((newHandle->fd=CreateFileW(filename, GENERIC_READ, - 0, + FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, diff --git a/dlls/itss/itss.c b/dlls/itss/itss.c index c9bee3c5fe6..25e1938b12c 100644 --- a/dlls/itss/itss.c +++ b/dlls/itss/itss.c @@ -39,6 +39,8 @@ #include "wine/unicode.h" #include "wine/debug.h" +#include "itsstor.h" + WINE_DEFAULT_DEBUG_CHANNEL(itss); #include "initguid.h" @@ -48,8 +50,6 @@ DEFINE_GUID(CLSID_ITSProtocol,0x9d148290,0xb9c8,0x11d0,0xa4,0xcc,0x00,0x00,0xf8, DEFINE_GUID(IID_IITStorage, 0x88cc31de, 0x27ab, 0x11d0, 0x9d, 0xf9, 0x0, 0xa0, 0xc9, 0x22, 0xe6, 0xec); static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj); -extern HRESULT ITS_IParseDisplayName_create(IUnknown *pUnkOuter, LPVOID *ppObj); -extern HRESULT ITSS_StgOpenStorage( const WCHAR*, IStorage*, DWORD, SNB, DWORD, IStorage** ); BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) { diff --git a/dlls/itss/itsstor.h b/dlls/itss/itsstor.h new file mode 100644 index 00000000000..b030b433cb1 --- /dev/null +++ b/dlls/itss/itsstor.h @@ -0,0 +1,38 @@ +/* + * ITSS Storage implementation + * + * Copyright 2004 Mike McCormack + * + * see http://bonedaddy.net/pabs3/hhm/#chmspec + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __WINE_ITS_STORAGE_PRIVATE__ +#define __WINE_ITS_STORAGE_PRIVATE__ + +extern HRESULT ITSS_StgOpenStorage( + const WCHAR* pwcsName, + IStorage* pstgPriority, + DWORD grfMode, + SNB snbExclude, + DWORD reserved, + IStorage** ppstgOpen); + +extern HRESULT ITS_IParseDisplayName_create( + IUnknown *pUnkOuter, + LPVOID *ppObj); + +#endif /* __WINE_ITS_STORAGE_PRIVATE__ */ diff --git a/dlls/itss/moniker.c b/dlls/itss/moniker.c index 80db9c844f2..b96db4e9b17 100644 --- a/dlls/itss/moniker.c +++ b/dlls/itss/moniker.c @@ -38,6 +38,8 @@ #include "wine/unicode.h" #include "wine/debug.h" +#include "itsstor.h" + WINE_DEFAULT_DEBUG_CHANNEL(itss); /*****************************************************************************/ @@ -153,8 +155,30 @@ static HRESULT WINAPI ITS_IMonikerImpl_BindToStorage( REFIID riid, void** ppvObj) { - FIXME("\n"); - return E_NOTIMPL; + ICOM_THIS(ITS_IMonikerImpl,iface); + DWORD grfMode = STGM_SIMPLE | STGM_READ | STGM_SHARE_EXCLUSIVE; + HRESULT r; + IStorage *stg = NULL; + + TRACE("%p %p %p %s %p\n", This, + pbc, pmkToLeft, debugstr_guid(riid), ppvObj); + + r = ITSS_StgOpenStorage( This->szFile, NULL, grfMode, 0, 0, &stg ); + if( r == S_OK ) + { + TRACE("Opened storage %s\n", debugstr_w( This->szFile ) ); + if (IsEqualGUID(riid, &IID_IStream)) + r = IStorage_OpenStream( stg, This->szHtml, + NULL, grfMode, 0, (IStream**)ppvObj ); + else if (IsEqualGUID(riid, &IID_IStorage)) + r = IStorage_OpenStorage( stg, This->szHtml, + NULL, grfMode, NULL, 0, (IStorage**)ppvObj ); + else + r = STG_E_ACCESSDENIED; + IStorage_Release( stg ); + } + + return r; } static HRESULT WINAPI ITS_IMonikerImpl_Reduce( diff --git a/dlls/itss/storage.c b/dlls/itss/storage.c index ec8bbfb7fac..066f96a4aac 100644 --- a/dlls/itss/storage.c +++ b/dlls/itss/storage.c @@ -36,6 +36,7 @@ #include "itss.h" #include "chm_lib.h" +#include "itsstor.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -330,8 +331,16 @@ HRESULT WINAPI ITSS_IStorageImpl_OpenStream( len = strlenW( This->dir ) + strlenW( pwcsName ) + 1; path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); strcpyW( path, This->dir ); + if( pwcsName[0] == '/' ) + { + WCHAR *p = &path[strlenW( path ) - 1]; + while( ( path <= p ) && ( *p = '/' ) ) + *p-- = 0; + } strcatW( path, pwcsName ); + TRACE("Resolving %s\n", debugstr_w(path)); + r = chm_resolve_object(This->chmfile, path, &ui); HeapFree( GetProcessHeap(), 0, path ); @@ -368,7 +377,10 @@ HRESULT WINAPI ITSS_IStorageImpl_OpenStorage( DWORD reserved, IStorage** ppstg) { - FIXME("\n"); + ICOM_THIS(ITSS_IStorageImpl,iface); + + FIXME("%p %s %p %lu %p %lu %p\n", This, debugstr_w(pwcsName), + pstgPriority, grfMode, snbExclude, reserved, ppstg); return E_NOTIMPL; } @@ -749,8 +761,21 @@ static HRESULT WINAPI ITSS_IStream_Stat( STATSTG* pstatstg, DWORD grfStatFlag) { - FIXME("\n"); - return E_NOTIMPL; + ICOM_THIS(IStream_Impl,iface); + + TRACE("%p %p %ld\n", This, pstatstg, grfStatFlag); + + memset( pstatstg, 0, sizeof *pstatstg ); + if( !( grfStatFlag & STATFLAG_NONAME ) ) + { + FIXME("copy the name\n"); + } + pstatstg->type = STGTY_STREAM; + pstatstg->cbSize.QuadPart = This->ui.length; + pstatstg->grfMode = STGM_READ; + memcpy( &pstatstg->clsid, &CLSID_ITStorage, sizeof (CLSID) ); + + return S_OK; } static HRESULT WINAPI ITSS_IStream_Clone(