X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=activex%2Fpersiststorage.cpp;h=5bac3012aca1bd5cca7e078fc3e969f02d1c93d5;hb=bf490f9f931c4ac5d36fe82331bc51bed4782b56;hp=54b17ae9f63294e293c57ead8497340faa8f750e;hpb=3d831e04ece115bb9ca379b9552370755453e46e;p=vlc diff --git a/activex/persiststorage.cpp b/activex/persiststorage.cpp index 54b17ae9f6..5bac3012ac 100644 --- a/activex/persiststorage.cpp +++ b/activex/persiststorage.cpp @@ -1,7 +1,7 @@ /***************************************************************************** * persiststorage.cpp: ActiveX control for VLC ***************************************************************************** - * Copyright (C) 2005 VideoLAN + * Copyright (C) 2005 the VideoLAN team * * Authors: Damien Fouilleul * @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #include "plugin.h" @@ -37,38 +37,67 @@ STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID) STDMETHODIMP VLCPersistStorage::IsDirty(void) { - return S_FALSE; + return _p_instance->isDirty() ? S_OK : S_FALSE; }; -STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg) +STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg) { - if( NULL == pStg ) - return E_POINTER; - - return _p_instance->onInitNew(); + return _p_instance->onInit(); }; -STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) +STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg) { if( NULL == pStg ) - return E_POINTER; + return E_INVALIDARG; + + LPSTREAM pStm = NULL; + HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL, + STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm); - return _p_instance->onInitNew(); + if( FAILED(result) ) + return result; + + LPPERSISTSTREAMINIT pPersistStreamInit; + if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) ) + { + result = pPersistStreamInit->Load(pStm); + pPersistStreamInit->Release(); + } + + pStm->Release(); + + return result; }; -STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad) +STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad) { if( NULL == pStg ) - return E_POINTER; + return E_INVALIDARG; - return S_OK; + if( fSameAsLoad && (S_FALSE == IsDirty()) ) + return S_OK; + + LPSTREAM pStm = NULL; + HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data", + STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm); + + if( FAILED(result) ) + return result; + + LPPERSISTSTREAMINIT pPersistStreamInit; + if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) ) + { + result = pPersistStreamInit->Save(pStm, fSameAsLoad); + pPersistStreamInit->Release(); + } + + pStm->Release(); + + return result; }; STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg) { - if( NULL == pStg ) - return E_POINTER; - return S_OK; };