persiststorage.cpp
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:3k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * persiststorage.cpp: ActiveX control for VLC
  3.  *****************************************************************************
  4.  * Copyright (C) 2005 the VideoLAN team
  5.  *
  6.  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
  7.  *
  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.
  12.  *
  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.
  17.  *
  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.  *****************************************************************************/
  22. #include "plugin.h"
  23. #include "persiststorage.h"
  24. using namespace std;
  25. STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
  26. {
  27.     if( NULL == pClsID )
  28.         return E_POINTER;
  29.     *pClsID = _p_instance->getClassID();
  30.     return S_OK;
  31. };
  32. STDMETHODIMP VLCPersistStorage::IsDirty(void)
  33. {
  34.     return _p_instance->isDirty() ? S_OK : S_FALSE;
  35. };
  36. STDMETHODIMP VLCPersistStorage::InitNew(LPSTORAGE pStg)
  37. {
  38.     return _p_instance->onInit();
  39. };
  40. STDMETHODIMP VLCPersistStorage::Load(LPSTORAGE pStg)
  41. {
  42.     if( NULL == pStg )
  43.         return E_INVALIDARG;
  44.     LPSTREAM pStm = NULL;
  45.     HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
  46.                         STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
  47.     if( FAILED(result) )
  48.         return result;
  49.     LPPERSISTSTREAMINIT pPersistStreamInit;
  50.     if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
  51.     {
  52.         result = pPersistStreamInit->Load(pStm);
  53.         pPersistStreamInit->Release();
  54.     }
  55.     pStm->Release();
  56.     return result;
  57. };
  58. STDMETHODIMP VLCPersistStorage::Save(LPSTORAGE pStg, BOOL fSameAsLoad)
  59. {
  60.     if( NULL == pStg )
  61.         return E_INVALIDARG;
  62.     if( fSameAsLoad && (S_FALSE == IsDirty()) )
  63.         return S_OK;
  64.     LPSTREAM pStm = NULL;
  65.     HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data",
  66.                         STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm);
  67.     if( FAILED(result) )
  68.         return result;
  69.     LPPERSISTSTREAMINIT pPersistStreamInit;
  70.     if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
  71.     {
  72.         result = pPersistStreamInit->Save(pStm, fSameAsLoad);
  73.         pPersistStreamInit->Release();
  74.     }
  75.     pStm->Release();
  76.     return result;
  77. };
  78. STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)
  79. {
  80.     return S_OK;
  81. };
  82. STDMETHODIMP VLCPersistStorage::HandsOffStorage(void)
  83. {
  84.     return S_OK;
  85. };