Compile fix + handle case with no xml:base
[vlc.git] / activex / connectioncontainer.h
blob0e3b65bf8843b89716bc494e0e33b22ff2a7f187
1 /*****************************************************************************
2 * connectioncontainer.h: 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 #ifndef __CONNECTIONCONTAINER_H__
24 #define __CONNECTIONCONTAINER_H__
26 #include <ocidl.h>
27 #include <vector>
28 #include <queue>
29 #include <map>
31 class VLCConnectionPoint : public IConnectionPoint
34 public:
36 VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid) :
37 _iid(iid), _p_cpc(p_cpc) {};
38 virtual ~VLCConnectionPoint() {};
40 // IUnknown methods
41 STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
43 if( NULL == ppv )
44 return E_POINTER;
45 if( (IID_IUnknown == riid)
46 || (IID_IConnectionPoint == riid) )
48 AddRef();
49 *ppv = reinterpret_cast<LPVOID>(this);
50 return NOERROR;
52 // must be a standalone object
53 return E_NOINTERFACE;
56 STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };
57 STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };
59 // IConnectionPoint methods
60 STDMETHODIMP GetConnectionInterface(IID *);
61 STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);
62 STDMETHODIMP Advise(IUnknown *, DWORD *);
63 STDMETHODIMP Unadvise(DWORD);
64 STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);
66 void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);
67 void firePropChangedEvent(DISPID dispId);
69 private:
71 REFIID _iid;
72 IConnectionPointContainer *_p_cpc;
73 std::map<DWORD, LPUNKNOWN> _connections;
76 //////////////////////////////////////////////////////////////////////////
78 class VLCDispatchEvent {
80 public:
81 VLCDispatchEvent(DISPID dispId, DISPPARAMS dispParams) :
82 _dispId(dispId), _dispParams(dispParams) {};
83 VLCDispatchEvent(const VLCDispatchEvent&);
84 ~VLCDispatchEvent();
86 DISPID _dispId;
87 DISPPARAMS _dispParams;
90 class VLCConnectionPointContainer : public IConnectionPointContainer
93 public:
95 VLCConnectionPointContainer(VLCPlugin *p_instance);
96 virtual ~VLCConnectionPointContainer();
98 // IUnknown methods
99 STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
101 if( NULL == ppv)
102 return E_POINTER;
103 if( (IID_IUnknown == riid)
104 || (IID_IConnectionPointContainer == riid) )
106 AddRef();
107 *ppv = reinterpret_cast<LPVOID>(this);
108 return NOERROR;
110 return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
113 STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
114 STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
116 // IConnectionPointContainer methods
117 STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);
118 STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);
120 void freezeEvents(BOOL);
121 void fireEvent(DISPID, DISPPARAMS*);
122 void firePropChangedEvent(DISPID dispId);
124 private:
126 VLCPlugin *_p_instance;
127 BOOL _b_freeze;
128 VLCConnectionPoint *_p_events;
129 VLCConnectionPoint *_p_props;
130 std::vector<LPCONNECTIONPOINT> _v_cps;
131 std::queue<class VLCDispatchEvent *> _q_events;
134 #endif