MSW: fix DisableScreensaver and RestoreScreensaver definitions
[vlc/asuraparaju-public.git] / projects / activex / persiststorage.cpp
blob5bac3012aca1bd5cca7e078fc3e969f02d1c93d5
1 /*****************************************************************************
2 * persiststorage.cpp: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #include "plugin.h"
24 #include "persiststorage.h"
26 using namespace std;
28 STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
30 if( NULL == pClsID )
31 return E_POINTER;
33 *pClsID = _p_instance->getClassID();
35 return S_OK;
38 STDMETHODIMP VLCPersistStorage::IsDirty(void)
40 return _p_instance->isDirty() ? S_OK : S_FALSE;
43 STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg)
45 return _p_instance->onInit();
48 STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
50 if( NULL == pStg )
51 return E_INVALIDARG;
53 LPSTREAM pStm = NULL;
54 HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
55 STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
57 if( FAILED(result) )
58 return result;
60 LPPERSISTSTREAMINIT pPersistStreamInit;
61 if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
63 result = pPersistStreamInit->Load(pStm);
64 pPersistStreamInit->Release();
67 pStm->Release();
69 return result;
72 STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
74 if( NULL == pStg )
75 return E_INVALIDARG;
77 if( fSameAsLoad && (S_FALSE == IsDirty()) )
78 return S_OK;
80 LPSTREAM pStm = NULL;
81 HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data",
82 STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm);
84 if( FAILED(result) )
85 return result;
87 LPPERSISTSTREAMINIT pPersistStreamInit;
88 if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
90 result = pPersistStreamInit->Save(pStm, fSameAsLoad);
91 pPersistStreamInit->Release();
94 pStm->Release();
96 return result;
99 STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)
101 return S_OK;
104 STDMETHODIMP VLCPersistStorage::HandsOffStorage(void)
106 return S_OK;