00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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