Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

persiststorage.cpp

00001 /*****************************************************************************
00002  * persiststorage.cpp: ActiveX control for VLC
00003  *****************************************************************************
00004  * Copyright (C) 2005 the VideoLAN team
00005  *
00006  * Authors: Damien Fouilleul <[email protected]>
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program 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
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00021  *****************************************************************************/
00022 
00023 #include "plugin.h"
00024 #include "persiststorage.h"
00025 
00026 using namespace std;
00027 
00028 STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
00029 {
00030     if( NULL == pClsID )
00031         return E_POINTER;
00032 
00033     *pClsID = _p_instance->getClassID();
00034 
00035     return S_OK;
00036 };
00037 
00038 STDMETHODIMP VLCPersistStorage::IsDirty(void)
00039 {
00040     return _p_instance->isDirty() ? S_OK : S_FALSE;
00041 };
00042 
00043 STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg)
00044 {
00045     return _p_instance->onInit();
00046 };
00047 
00048 STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
00049 {
00050     if( NULL == pStg )
00051         return E_INVALIDARG;
00052 
00053     LPSTREAM pStm = NULL;
00054     HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
00055                         STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
00056 
00057     if( FAILED(result) )
00058         return result;
00059 
00060     LPPERSISTSTREAMINIT pPersistStreamInit;
00061     if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
00062     {
00063         result = pPersistStreamInit->Load(pStm);
00064         pPersistStreamInit->Release();
00065     }
00066 
00067     pStm->Release();
00068 
00069     return result;
00070 };
00071 
00072 STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
00073 {
00074     if( NULL == pStg )
00075         return E_INVALIDARG;
00076 
00077     if( fSameAsLoad && (S_FALSE == IsDirty()) )
00078         return S_OK;
00079 
00080     LPSTREAM pStm = NULL;
00081     HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data",
00082                         STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm);
00083 
00084     if( FAILED(result) )
00085         return result;
00086 
00087     LPPERSISTSTREAMINIT pPersistStreamInit;
00088     if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
00089     {
00090         result = pPersistStreamInit->Save(pStm, fSameAsLoad);
00091         pPersistStreamInit->Release();
00092     }
00093 
00094     pStm->Release();
00095 
00096     return result;
00097 };
00098 
00099 STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)
00100 {
00101     return S_OK;
00102 };
00103 
00104 STDMETHODIMP VLCPersistStorage::HandsOffStorage(void)
00105 {
00106     return S_OK;
00107 };
00108 

Generated on Tue Dec 20 10:14:18 2005 for vlc-0.8.4a by  doxygen 1.4.2