persistpropbag.cpp 3.57 KB
Newer Older
1 2 3
/*****************************************************************************
 * persistpropbag.cpp: ActiveX control for VLC
 *****************************************************************************
4
 * Copyright (C) 2005 the VideoLAN team
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * 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 "persistpropbag.h"

#include "utils.h"
27
#include "oleobject.h"
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42

using namespace std;

STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)
{
    if( NULL == pClsID )
        return E_POINTER;

    *pClsID = _p_instance->getClassID();

    return S_OK;
};

STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
{
43
    return _p_instance->onInit();
44 45 46 47 48 49 50
};

STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
{
    if( NULL == pPropBag )
        return E_POINTER;

51
    HRESULT hr = _p_instance->onInit();
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
    if( FAILED(hr) )
        return hr;

    VARIANT value;

    V_VT(&value) = VT_BSTR;
    if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
    {
        char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
        if( NULL != src )
        {
            _p_instance->setSourceURL(src);
            free(src);
        }
        VariantClear(&value);
    }

    V_VT(&value) = VT_BSTR;
    if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
    {
        char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
        if( NULL != src )
        {
            _p_instance->setSourceURL(src);
            free(src);
        }
        VariantClear(&value);
    }

    V_VT(&value) = VT_BOOL;
    if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) )
    {
        _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
        VariantClear(&value);
    }

    V_VT(&value) = VT_BOOL;
    if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
    {
        _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
        VariantClear(&value);
    }

    V_VT(&value) = VT_BOOL;
    if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
    {
        _p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE);
        VariantClear(&value);
    }

    V_VT(&value) = VT_BOOL;
    if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) )
    {
        _p_instance->setMute(V_BOOL(&value) != VARIANT_FALSE);
        VariantClear(&value);
    }

    V_VT(&value) = VT_BOOL;
    if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
    {
        _p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
        VariantClear(&value);
    }

116
    return _p_instance->onLoad();
117 118
};

Damien Fouilleul's avatar
Damien Fouilleul committed
119
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
120 121 122 123 124 125 126
{
    if( NULL == pPropBag )
        return E_POINTER;

    return S_OK;
};