Commit d3ad3bb1 authored by Damien Fouilleul's avatar Damien Fouilleul

all: reworked ActiveX plugin, which now works properly with .NET (tested with...

all: reworked ActiveX plugin, which now works properly  with .NET (tested with Visual Basic Express 2005)
     added persistent properties such as MRL, AutoPlay, AutoLoop which allows a user to play a default target
     without programming.
parent 2fd7b91d
......@@ -33,11 +33,14 @@ library AXVLC
interface IVLCControl;
dispinterface DVLCEvents;
enum VLCPlaylistMode {
enum VLCPlaylistMode
{
VLCPlayListInsert = 1,
VLCPlayListInsertAndGo = 9,
VLCPlayListReplace = 2,
VLCPlayListReplaceAndGo = 10,
VLCPlayListAppend = 4,
VLCPlayListGo = 8,
VLCPlayListAppendAndGo = 12,
VLCPlayListCheckInsert = 16
};
......@@ -45,16 +48,15 @@ library AXVLC
const int VLCPlayListEnd = -666;
// DISPID definitions
const int DISPID_Visible = 1;
const int DISPID_Playing = 2;
const int DISPID_Position = 3;
const int DISPID_Time = 4;
const int DISPID_Length = 5;
const int DISPID_Volume = 6;
const int DISPID_PlayEvent = 1;
const int DISPID_PauseEvent = 2;
const int DISPID_StopEvent = 3;
const int DISPID_Visible = 100;
const int DISPID_Playing = 101;
const int DISPID_Position = 102;
const int DISPID_Time = 103;
const int DISPID_Length = 104;
const int DISPID_Volume = 105;
const int DISPID_MRL = 106;
const int DISPID_AutoPlay = 107;
const int DISPID_AutoLoop = 108;
[
odl,
......@@ -64,8 +66,8 @@ library AXVLC
hidden,
oleautomation
]
interface IVLCControl : IDispatch {
interface IVLCControl : IDispatch
{
[id(DISPID_Visible), propget, bindable, helpstring("Shows or hides plugin.")]
HRESULT Visible([out, retval] VARIANT_BOOL* visible);
[id(DISPID_Visible), propput, bindable, helpstring("Shows or hides plugin.")]
......@@ -76,13 +78,11 @@ library AXVLC
HRESULT pause();
[helpstring("Stop playback.")]
HRESULT stop();
[id(DISPID_Playing), bindable, propget, helpstring("Specifies whether VLC is playing.")]
[id(DISPID_Playing), hidden, propget, helpstring("Returns whether VLC is playing.")]
HRESULT Playing([out, retval] VARIANT_BOOL* isPlaying);
[id(DISPID_Playing), bindable, propput, helpstring("Specifies whether VLC is playing.")]
HRESULT Playing([in] VARIANT_BOOL isPlaying);
[id(DISPID_Position), bindable, propget, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
[id(DISPID_Position), propget, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([out, retval] float* position);
[id(DISPID_Position), bindable, propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
[id(DISPID_Position), propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([in] float position);
[id(DISPID_Time), propget, helpstring("Specifies playback time relative to the start of current target in playlist.")]
HRESULT Time([out, retval] int* seconds);
......@@ -92,15 +92,15 @@ library AXVLC
HRESULT shuttle([in] int seconds);
[helpstring("Switch between normal and fullscreen video.")]
HRESULT fullscreen();
[id(DISPID_Length), bindable, propget, helpstring("Returns total length in seconds of current target in playlist, may be unknown.")]
[id(DISPID_Length), propget, hidden, helpstring("Returns total length in seconds of current target in playlist, may be unknown.")]
HRESULT Length([out, retval] int* seconds);
[helpstring("Increases playback speed, one of 1x, 2x, 4x, 8x.")]
HRESULT playFaster();
[helpstring("Decreases playback speed, one of 1x, 2x, 4x, 8x.")]
HRESULT playSlower();
[id(DISPID_Volume), bindable, propget, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
[id(DISPID_Volume), propget, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
HRESULT Volume([out, retval] int* volume);
[id(DISPID_Volume), bindable, propput, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
[id(DISPID_Volume), propput, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
HRESULT Volume([in] int volume);
[helpstring("Mute/unmute playback sound volume.")]
HRESULT toggleMute();
......@@ -126,24 +126,41 @@ library AXVLC
HRESULT playlistPrev();
[helpstring("Remove all items from playlist.")]
HRESULT playlistClear();
[propget, helpstring("Returns VLC Version.")]
[propget, hidden, helpstring("Returns VLC Version.")]
HRESULT VersionInfo([out, retval] BSTR* version);
[id(DISPID_MRL), propget, helpstring("Returns initial MRL in default playlist")]
HRESULT MRL([out, retval] BSTR* mrl);
[id(DISPID_MRL), propput, helpstring("Specifies initial MRL in default playlist")]
HRESULT MRL([in] BSTR mrl);
[id(DISPID_AutoPlay), propget, helpstring("Specifies whether default playlist is played on startup")]
HRESULT AutoPlay([out, retval] VARIANT_BOOL* autoplay);
[id(DISPID_AutoPlay), propput, helpstring("Returns whether default playlist is played on startup")]
HRESULT AutoPlay([in] VARIANT_BOOL autoplay);
[id(DISPID_AutoLoop), propget, helpstring("Specifies whether default playlist is looped")]
HRESULT AutoLoop([out, retval] VARIANT_BOOL* autoloop);
[id(DISPID_AutoLoop), propput, helpstring("Returns whether default playlist is looped")]
HRESULT AutoLoop([in] VARIANT_BOOL autoloop);
};
const int DISPID_PlayEvent = 100;
const int DISPID_PauseEvent = 101;
const int DISPID_StopEvent = 102;
[
uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
helpstring("Event interface for VLC control"),
hidden
]
dispinterface DVLCEvents {
dispinterface DVLCEvents
{
properties:
methods:
[id(DISPID_PlayEvent), helpstring("Playback in progress")]
void Play();
void play();
[id(DISPID_PauseEvent), helpstring("Playback has paused")]
void Pause();
void pause();
[id(DISPID_StopEvent), helpstring("Playback has stopped")]
void Stop();
void stop();
};
[
......@@ -151,7 +168,8 @@ library AXVLC
helpstring("VLC control"),
control
]
coclass VLCPlugin {
coclass VLCPlugin
{
[default] interface IVLCControl;
[default, source] dispinterface DVLCEvents;
};
......
No preview for this file type
......@@ -5,7 +5,7 @@
/* File created by MIDL compiler version 5.01.0164 */
/* at Tue May 10 21:24:51 2005
/* at Sun Aug 21 17:16:22 2005
*/
/* Compiler settings for axvlc.idl:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......
This diff is collapsed.
......@@ -192,18 +192,16 @@ HRESULT VLCDataObject::getMetaFileData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedi
SIZEL size = _p_instance->getExtent();
RECTL wBounds = { 0L, 0L, size.cx, size.cy };
LONG width = size.cx*GetDeviceCaps(hicTargetDev, LOGPIXELSX)/2540L;
LONG height = size.cy*GetDeviceCaps(hicTargetDev, LOGPIXELSY)/2540L;
pMetaFilePict->mm = MM_ANISOTROPIC;
pMetaFilePict->xExt = size.cx;
pMetaFilePict->yExt = size.cy;
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
SetMapMode(hdcMeta, MM_ANISOTROPIC);
SetWindowOrgEx(hdcMeta, 0, 0, NULL);
SetWindowExtEx(hdcMeta, width, height, NULL);
SetWindowExtEx(hdcMeta, size.cx, size.cy, NULL);
RECTL bounds = { 0L, 0L, width, height };
RECTL bounds = { 0L, 0L, size.cx, size.cy };
_p_instance->onDraw(pFormatEtc->ptd, hicTargetDev, hdcMeta, &bounds, &wBounds);
pMetaFilePict->hMF = CloseMetaFile(hdcMeta);
......@@ -230,10 +228,9 @@ HRESULT VLCDataObject::getEnhMetaFileData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pM
{
RECTL wBounds = { 0L, 0L, size.cx, size.cy };
LONG width = size.cx*GetDeviceCaps(hicTargetDev, LOGPIXELSX)/2540L;
LONG height = size.cy*GetDeviceCaps(hicTargetDev, LOGPIXELSY)/2540L;
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
RECTL bounds = { 0L, 0L, width, height };
RECTL bounds = { 0L, 0L, size.cx, size.cy };
_p_instance->onDraw(pFormatEtc->ptd, hicTargetDev, hdcMeta, &bounds, &wBounds);
pMedium->hEnhMetaFile = CloseEnhMetaFile(hdcMeta);
......@@ -279,6 +276,11 @@ STDMETHODIMP VLCDataObject::SetData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium,
return E_NOTIMPL;
};
/*void VLCDataObject::onDataChange(void)
{
_p_adviseHolder->SendOnDataChange(this, 0, 0);
};*/
void VLCDataObject::onClose(void)
{
_p_adviseHolder->SendOnDataChange(this, 0, ADVF_DATAONSTOP);
......
......@@ -96,7 +96,7 @@ static LPCTSTR TStrFromGUID(REFGUID clsid)
if( len > 0 )
{
clsidStr = (wchar_t *)CoTaskMemAlloc(len*sizeof(wchar_t));
WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len);
MultiByteToWideChar(CP_ACP, 0, oleStr, -1, pct_CLSID, len);
}
#endif
CoTaskMemFree(oleStr);
......
......@@ -23,8 +23,6 @@
#include "plugin.h"
#include "olecontrol.h"
#include "utils.h"
using namespace std;
STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI)
......@@ -45,12 +43,12 @@ STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg)
return E_NOTIMPL;
};
static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v)
STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)
{
HRESULT hr;
IOleObject *oleObj;
hr = instance.QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
hr = QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
if( SUCCEEDED(hr) )
{
IOleClientSite *clientSite;
......@@ -58,70 +56,11 @@ static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v
hr = oleObj->GetClientSite(&clientSite);
if( SUCCEEDED(hr) && (NULL != clientSite) )
{
hr = GetObjectProperty(clientSite, dispID, v);
_p_instance->onAmbientChanged(clientSite, dispID);
clientSite->Release();
}
oleObj->Release();
}
return hr;
};
STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)
{
switch( dispID )
{
case DISPID_AMBIENT_BACKCOLOR:
break;
case DISPID_AMBIENT_DISPLAYNAME:
break;
case DISPID_AMBIENT_FONT:
break;
case DISPID_AMBIENT_FORECOLOR:
break;
case DISPID_AMBIENT_LOCALEID:
break;
case DISPID_AMBIENT_MESSAGEREFLECT:
break;
case DISPID_AMBIENT_SCALEUNITS:
break;
case DISPID_AMBIENT_TEXTALIGN:
break;
case DISPID_AMBIENT_USERMODE:
break;
case DISPID_AMBIENT_UIDEAD:
break;
case DISPID_AMBIENT_SHOWGRABHANDLES:
break;
case DISPID_AMBIENT_SHOWHATCHING:
break;
case DISPID_AMBIENT_DISPLAYASDEFAULT:
break;
case DISPID_AMBIENT_SUPPORTSMNEMONICS:
break;
case DISPID_AMBIENT_AUTOCLIP:
break;
case DISPID_AMBIENT_APPEARANCE:
break;
case DISPID_AMBIENT_CODEPAGE:
VARIANT v;
VariantInit(&v);
V_VT(&v) = VT_I4;
if( SUCCEEDED(getAmbientProperty(*_p_instance, dispID, v)) )
{
_p_instance->setCodePage(V_I4(&v));
}
break;
case DISPID_AMBIENT_PALETTE:
break;
case DISPID_AMBIENT_CHARSET:
break;
case DISPID_AMBIENT_RIGHTTOLEFT:
break;
case DISPID_AMBIENT_TOPTOBOTTOM:
break;
default:
break;
}
return S_OK;
};
......
......@@ -28,18 +28,15 @@ using namespace std;
STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd)
{
if( NULL == pHwnd )
return E_INVALIDARG;
return E_POINTER;
*pHwnd = NULL;
if( _p_instance->isInPlaceActive() )
{
if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
return S_OK;
return E_FAIL;
}
*pHwnd = NULL;
return E_UNEXPECTED;
return E_FAIL;
};
STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable)
......
......@@ -30,18 +30,15 @@ using namespace std;
STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)
{
if( NULL == pHwnd )
return E_INVALIDARG;
return E_POINTER;
*pHwnd = NULL;
if( _p_instance->isInPlaceActive() )
{
if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
return S_OK;
return E_FAIL;
}
*pHwnd = NULL;
return E_UNEXPECTED;
return E_FAIL;
};
STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
......@@ -54,6 +51,7 @@ STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
if( _p_instance->isInPlaceActive() )
{
UIDeactivate();
_p_instance->onInPlaceDeactivate();
LPOLEOBJECT p_oleObject;
......@@ -85,26 +83,26 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
if( _p_instance->hasFocus() )
{
_p_instance->setFocus(FALSE);
}
LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
{
LPOLECLIENTSITE p_clientSite;
if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
{
LPOLECLIENTSITE p_clientSite;
if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release();
}
p_clientSite->Release();
p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release();
}
p_oleObject->Release();
p_clientSite->Release();
}
return S_OK;
p_oleObject->Release();
}
return S_OK;
}
return E_UNEXPECTED;
};
......
......@@ -37,8 +37,9 @@ _p_clientsite(NULL), _p_instance(p_instance)
VLCOleObject::~VLCOleObject()
{
SetClientSite(NULL);
Close(OLECLOSE_NOSAVE);
_p_advise_holder->Release();
SetClientSite(NULL);
};
STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
......@@ -48,8 +49,12 @@ STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
if( _p_instance->isRunning() )
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
}
return S_OK;
};
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
......@@ -115,6 +120,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
OLEINPLACEFRAMEINFO oleFrameInfo;
oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
{
lprcPosRect = &posRect;
......@@ -302,29 +308,16 @@ STDMETHODIMP VLCOleObject::IsUpToDate(void)
STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
{
if( NULL != pClientSite )
{
pClientSite->AddRef();
/*
** retrieve container ambient properties
*/
VARIANT v;
VariantInit(&v);
V_VT(&v) = VT_I4;
if( SUCCEEDED(GetObjectProperty(pClientSite, DISPID_AMBIENT_CODEPAGE, v)) )
{
_p_instance->setCodePage(V_I4(&v));
VariantClear(&v);
}
}
if( NULL != _p_clientsite )
_p_clientsite->Release();
_p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
if( NULL != pClientSite )
{
pClientSite->AddRef();
_p_instance->onAmbientChanged(pClientSite, DISPID_UNKNOWN);
}
return S_OK;
};
......
......@@ -45,59 +45,95 @@ STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
{
if( NULL == pPropBag )
return E_POINTER;
HRESULT hr = _p_instance->onInit();
if( FAILED(hr) )
return hr;
if( NULL == pPropBag )
return E_INVALIDARG;
VARIANT value;
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("mrl"), &value, pErrorLog) )
{
char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
if( NULL != src )
{
_p_instance->setSourceURL(src);
free(src);
}
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
else
{
char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
if( NULL != src )
/*
** try alternative syntax
*/
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
{
_p_instance->setSourceURL(src);
free(src);
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
else
{
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
{
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
}
VariantClear(&value);
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) )
{
_p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
{
_p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
SIZEL size = _p_instance->getExtent();
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("extentwidth"), &value, pErrorLog) )
{
size.cx = V_I4(&value);
VariantClear(&value);
}
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("extentheight"), &value, pErrorLog) )
{
_p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
size.cy = V_I4(&value);
VariantClear(&value);
}
_p_instance->setExtent(size);
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("autoloop"), &value, pErrorLog) )
{
_p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
{
_p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) )
......@@ -107,19 +143,81 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("visible"), &value, pErrorLog) )
{
_p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
{
_p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
int i_vlc = _p_instance->getVLCObject();
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("volume"), &value, pErrorLog) )
{
VLC_VolumeSet(i_vlc, V_I4(&value));
VariantClear(&value);
}
return _p_instance->onLoad();
};
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
{
if( NULL == pPropBag )
return E_POINTER;
return E_INVALIDARG;
VARIANT value;
VariantInit(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getAutoLoop()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("AutoLoop"), &value);
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getAutoPlay()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("AutoPlay"), &value);
VariantClear(&value);
SIZEL size = _p_instance->getExtent();
V_VT(&value) = VT_I4;
V_I4(&value) = size.cx;
pPropBag->Write(OLESTR("ExtentWidth"), &value);
V_I4(&value) = size.cy;
pPropBag->Write(OLESTR("ExtentHeight"), &value);
V_VT(&value) = VT_BSTR;
V_BSTR(&value) = SysAllocString(_p_instance->getMRL());
pPropBag->Write(OLESTR("MRL"), &value);
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getVisible()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("Visible"), &value);
VariantClear(&value);
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
V_VT(&value) = VT_I4;
V_I4(&value) = VLC_VolumeGet(i_vlc);
pPropBag->Write(OLESTR("Volume"), &value);
VariantClear(&value);
}
if( fClearDirty )
_p_instance->setDirty(FALSE);
return S_OK;
};
......
......@@ -37,31 +37,63 @@ STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStorage::IsDirty(void)
{
return S_FALSE;
return _p_instance->isDirty() ? S_OK : S_FALSE;
};
STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
{
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
{
if( NULL == pStg )
return E_POINTER;
return E_INVALIDARG;
return _p_instance->onInit();
LPSTREAM pStm = NULL;
HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Load(pStm);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
{
if( NULL == pStg )
return E_POINTER;
return E_INVALIDARG;
return S_OK;
if