2005-03-02 17:47:31 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* persiststorage.cpp: ActiveX control for VLC
|
|
|
|
*****************************************************************************
|
2005-07-09 08:17:09 +02:00
|
|
|
* Copyright (C) 2005 the VideoLAN team
|
2005-03-02 17:47:31 +01:00
|
|
|
*
|
|
|
|
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "persiststorage.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
|
|
|
|
{
|
|
|
|
if( NULL == pClsID )
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pClsID = _p_instance->getClassID();
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCPersistStorage::IsDirty(void)
|
|
|
|
{
|
2005-08-21 19:40:32 +02:00
|
|
|
return _p_instance->isDirty() ? S_OK : S_FALSE;
|
2005-03-02 17:47:31 +01:00
|
|
|
};
|
|
|
|
|
2005-09-16 18:10:42 +02:00
|
|
|
STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg)
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
2005-06-27 13:41:16 +02:00
|
|
|
return _p_instance->onInit();
|
2005-03-02 17:47:31 +01:00
|
|
|
};
|
|
|
|
|
2005-09-16 18:10:42 +02:00
|
|
|
STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
|
|
|
if( NULL == pStg )
|
2005-08-21 19:40:32 +02:00
|
|
|
return E_INVALIDARG;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
2005-08-21 19:40:32 +02:00
|
|
|
LPSTREAM pStm = NULL;
|
|
|
|
HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
|
|
|
|
STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
|
|
|
|
|
|
|
|
if( FAILED(result) )
|
|
|
|
return result;
|
|
|
|
|
|
|
|
LPPERSISTSTREAMINIT pPersistStreamInit;
|
|
|
|
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
|
|
|
|
{
|
|
|
|
result = pPersistStreamInit->Load(pStm);
|
|
|
|
pPersistStreamInit->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
pStm->Release();
|
|
|
|
|
|
|
|
return result;
|
2005-03-02 17:47:31 +01:00
|
|
|
};
|
|
|
|
|
2005-09-16 18:10:42 +02:00
|
|
|
STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
|
2005-03-02 17:47:31 +01:00
|
|
|
{
|
|
|
|
if( NULL == pStg )
|
2005-08-21 19:40:32 +02:00
|
|
|
return E_INVALIDARG;
|
2005-03-02 17:47:31 +01:00
|
|
|
|
2005-08-21 19:40:32 +02:00
|
|
|
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;
|
2005-03-02 17:47:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP VLCPersistStorage::HandsOffStorage(void)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
};
|
|
|
|
|