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 "persistpropbag.h"
00025
00026 #include "utils.h"
00027 #include "oleobject.h"
00028
00029 using namespace std;
00030
00031 STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)
00032 {
00033 if( NULL == pClsID )
00034 return E_POINTER;
00035
00036 *pClsID = _p_instance->getClassID();
00037
00038 return S_OK;
00039 };
00040
00041 STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
00042 {
00043 return _p_instance->onInit();
00044 };
00045
00046 STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
00047 {
00048 HRESULT hr = _p_instance->onInit();
00049 if( FAILED(hr) )
00050 return hr;
00051
00052 if( NULL == pPropBag )
00053 return E_INVALIDARG;
00054
00055 VARIANT value;
00056
00057 V_VT(&value) = VT_BSTR;
00058 if( S_OK == pPropBag->Read(OLESTR("mrl"), &value, pErrorLog) )
00059 {
00060 _p_instance->setMRL(V_BSTR(&value));
00061 VariantClear(&value);
00062 }
00063 else
00064 {
00065
00066
00067
00068 V_VT(&value) = VT_BSTR;
00069 if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
00070 {
00071 _p_instance->setMRL(V_BSTR(&value));
00072 VariantClear(&value);
00073 }
00074 else
00075 {
00076 V_VT(&value) = VT_BSTR;
00077 if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
00078 {
00079 _p_instance->setMRL(V_BSTR(&value));
00080 VariantClear(&value);
00081 }
00082 }
00083 }
00084
00085 V_VT(&value) = VT_BOOL;
00086 if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) )
00087 {
00088 _p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
00089 VariantClear(&value);
00090 }
00091 else
00092 {
00093
00094
00095
00096 V_VT(&value) = VT_BOOL;
00097 if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
00098 {
00099 _p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
00100 VariantClear(&value);
00101 }
00102 }
00103
00104 SIZEL size = _p_instance->getExtent();
00105 V_VT(&value) = VT_I4;
00106 if( S_OK == pPropBag->Read(OLESTR("extentwidth"), &value, pErrorLog) )
00107 {
00108 size.cx = V_I4(&value);
00109 VariantClear(&value);
00110 }
00111 V_VT(&value) = VT_I4;
00112 if( S_OK == pPropBag->Read(OLESTR("extentheight"), &value, pErrorLog) )
00113 {
00114 size.cy = V_I4(&value);
00115 VariantClear(&value);
00116 }
00117 _p_instance->setExtent(size);
00118
00119 V_VT(&value) = VT_BOOL;
00120 if( S_OK == pPropBag->Read(OLESTR("autoloop"), &value, pErrorLog) )
00121 {
00122 _p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
00123 VariantClear(&value);
00124 }
00125 else
00126 {
00127
00128
00129
00130 V_VT(&value) = VT_BOOL;
00131 if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
00132 {
00133 _p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
00134 VariantClear(&value);
00135 }
00136 }
00137
00138 V_VT(&value) = VT_BOOL;
00139 if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) )
00140 {
00141 _p_instance->setMute(V_BOOL(&value) != VARIANT_FALSE);
00142 VariantClear(&value);
00143 }
00144
00145 V_VT(&value) = VT_BOOL;
00146 if( S_OK == pPropBag->Read(OLESTR("visible"), &value, pErrorLog) )
00147 {
00148 _p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
00149 VariantClear(&value);
00150 }
00151 else
00152 {
00153
00154
00155
00156 V_VT(&value) = VT_BOOL;
00157 if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
00158 {
00159 _p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
00160 VariantClear(&value);
00161 }
00162 }
00163
00164 int i_vlc = _p_instance->getVLCObject();
00165 V_VT(&value) = VT_I4;
00166 if( S_OK == pPropBag->Read(OLESTR("volume"), &value, pErrorLog) )
00167 {
00168 VLC_VolumeSet(i_vlc, V_I4(&value));
00169 VariantClear(&value);
00170 }
00171 return _p_instance->onLoad();
00172 };
00173
00174 STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
00175 {
00176 if( NULL == pPropBag )
00177 return E_INVALIDARG;
00178
00179 VARIANT value;
00180
00181 VariantInit(&value);
00182
00183 V_VT(&value) = VT_BOOL;
00184 V_BOOL(&value) = _p_instance->getAutoLoop()? VARIANT_TRUE : VARIANT_FALSE;
00185 pPropBag->Write(OLESTR("AutoLoop"), &value);
00186 VariantClear(&value);
00187
00188 V_VT(&value) = VT_BOOL;
00189 V_BOOL(&value) = _p_instance->getAutoPlay()? VARIANT_TRUE : VARIANT_FALSE;
00190 pPropBag->Write(OLESTR("AutoPlay"), &value);
00191 VariantClear(&value);
00192
00193 SIZEL size = _p_instance->getExtent();
00194 V_VT(&value) = VT_I4;
00195 V_I4(&value) = size.cx;
00196 pPropBag->Write(OLESTR("ExtentWidth"), &value);
00197 V_I4(&value) = size.cy;
00198 pPropBag->Write(OLESTR("ExtentHeight"), &value);
00199
00200 V_VT(&value) = VT_BSTR;
00201 V_BSTR(&value) = SysAllocStringLen(_p_instance->getMRL(),
00202 SysStringLen(_p_instance->getMRL()));
00203 pPropBag->Write(OLESTR("MRL"), &value);
00204 VariantClear(&value);
00205
00206 V_VT(&value) = VT_BOOL;
00207 V_BOOL(&value) = _p_instance->getVisible()? VARIANT_TRUE : VARIANT_FALSE;
00208 pPropBag->Write(OLESTR("Visible"), &value);
00209 VariantClear(&value);
00210
00211 int i_vlc = _p_instance->getVLCObject();
00212 if( i_vlc )
00213 {
00214 V_VT(&value) = VT_I4;
00215 V_I4(&value) = VLC_VolumeGet(i_vlc);
00216 pPropBag->Write(OLESTR("Volume"), &value);
00217 VariantClear(&value);
00218 }
00219
00220 if( fClearDirty )
00221 _p_instance->setDirty(FALSE);
00222
00223 return S_OK;
00224 };
00225