]> git.sesse.net Git - vlc/blob - activex/connectioncontainer.h
bump version to 0.8.4-test3
[vlc] / activex / connectioncontainer.h
1 /*****************************************************************************
2  * connectioncontainer.h: 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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 #ifndef __CONNECTIONCONTAINER_H__
24 #define __CONNECTIONCONTAINER_H__
25
26 #include <ocidl.h>
27 #include <vector>
28 #include <queue>
29
30 class VLCConnectionPoint : public IConnectionPoint
31 {
32
33 public:
34
35     VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid) :
36         _iid(iid), _p_cpc(p_cpc) {};
37     virtual ~VLCConnectionPoint() {};
38
39     // IUnknown methods
40     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
41     {
42         if( NULL == ppv ) return E_POINTER;
43         if( (IID_IUnknown == riid) 
44          && (IID_IConnectionPoint == riid) ) {
45             AddRef();
46             *ppv = reinterpret_cast<LPVOID>(this);
47             return NOERROR;
48         }
49         // must be a standalone object
50         return E_NOINTERFACE;
51     };
52
53     STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };
54     STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };
55
56     // IConnectionPoint methods
57     STDMETHODIMP GetConnectionInterface(IID *);
58     STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);
59     STDMETHODIMP Advise(IUnknown *, DWORD *);
60     STDMETHODIMP Unadvise(DWORD);
61     STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);
62
63     void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);
64     void firePropChangedEvent(DISPID dispId);
65
66 private:
67
68     REFIID _iid;
69     IConnectionPointContainer *_p_cpc;
70     std::vector<CONNECTDATA> _connections;
71 };
72
73 //////////////////////////////////////////////////////////////////////////
74
75 class VLCDispatchEvent {
76
77 public:
78     VLCDispatchEvent(DISPID dispId, DISPPARAMS dispParams) :
79         _dispId(dispId), _dispParams(dispParams) {};
80     VLCDispatchEvent(const VLCDispatchEvent&);
81     ~VLCDispatchEvent();
82
83     DISPID      _dispId;
84     DISPPARAMS  _dispParams;
85 };
86
87 class VLCConnectionPointContainer : public IConnectionPointContainer
88 {
89
90 public:
91
92     VLCConnectionPointContainer(VLCPlugin *p_instance);
93     virtual ~VLCConnectionPointContainer();
94
95     // IUnknown methods
96     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
97     {
98         if( (NULL != ppv)
99          && (IID_IUnknown == riid) 
100          && (IID_IConnectionPointContainer == riid) ) {
101             AddRef();
102             *ppv = reinterpret_cast<LPVOID>(this);
103             return NOERROR;
104         }
105         return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
106     };
107
108     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
109     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
110
111     // IConnectionPointContainer methods
112     STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);
113     STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);
114
115     void freezeEvents(BOOL);
116     void fireEvent(DISPID, DISPPARAMS*);
117     void firePropChangedEvent(DISPID dispId);
118
119 private:
120
121     VLCPlugin *_p_instance;
122     BOOL _b_freeze;
123     VLCConnectionPoint *_p_events;
124     VLCConnectionPoint *_p_props;
125     std::vector<LPCONNECTIONPOINT> _v_cps;
126     std::queue<class VLCDispatchEvent *> _q_events;
127 };
128
129 #endif
130