]> git.sesse.net Git - vlc/blob - projects/activex/connectioncontainer.h
Remove extra braces.
[vlc] / projects / activex / connectioncontainer.h
1 /*****************************************************************************
2  * connectioncontainer.h: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  * Copyright (C) 2010 M2X BV
6  *
7  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8  *          Jean-Paul Saman <jpsaman@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef __CONNECTIONCONTAINER_H__
26 #define __CONNECTIONCONTAINER_H__
27
28 #include <ocidl.h>
29 #include <vector>
30 #include <queue>
31 #include <map>
32 #include <cguid.h>
33
34 class VLCConnectionPoint : public IConnectionPoint
35 {
36
37 public:
38
39     VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid);
40     virtual ~VLCConnectionPoint();
41
42     // IUnknown methods
43     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
44     {
45         if( NULL == ppv )
46             return E_POINTER;
47         if( (IID_IUnknown == riid)
48          || (IID_IConnectionPoint == riid) )
49         {
50             AddRef();
51             *ppv = reinterpret_cast<LPVOID>(this);
52             return NOERROR;
53         }
54         // must be a standalone object
55         return E_NOINTERFACE;
56     };
57
58     STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };
59     STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };
60
61     // IConnectionPoint methods
62     STDMETHODIMP GetConnectionInterface(IID *);
63     STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);
64     STDMETHODIMP Advise(IUnknown *, DWORD *);
65     STDMETHODIMP Unadvise(DWORD);
66     STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);
67
68     void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);
69     void firePropChangedEvent(DISPID dispId);
70
71 private:
72
73     REFIID _iid;
74     IGlobalInterfaceTable *m_pGIT;
75     IConnectionPointContainer *_p_cpc;
76     std::map<DWORD, LPUNKNOWN> _connections;
77 };
78
79 //////////////////////////////////////////////////////////////////////////
80
81 class VLCDispatchEvent {
82
83 public:
84     VLCDispatchEvent(DISPID dispId, DISPPARAMS dispParams) :
85         _dispId(dispId), _dispParams(dispParams) {};
86     VLCDispatchEvent(const VLCDispatchEvent&);
87     ~VLCDispatchEvent();
88
89     DISPID      _dispId;
90     DISPPARAMS  _dispParams;
91 };
92
93 class VLCConnectionPointContainer : public IConnectionPointContainer
94 {
95
96 public:
97
98     VLCConnectionPointContainer(VLCPlugin *p_instance);
99     virtual ~VLCConnectionPointContainer();
100
101     // IUnknown methods
102     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
103     {
104         if( NULL == ppv)
105             return E_POINTER;
106         if( (IID_IUnknown == riid)
107          || (IID_IConnectionPointContainer == riid) )
108         {
109             AddRef();
110             *ppv = reinterpret_cast<LPVOID>(this);
111             return NOERROR;
112         }
113         return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
114     };
115
116     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
117     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
118
119     // IConnectionPointContainer methods
120     STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);
121     STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);
122
123     void freezeEvents(BOOL);
124     void fireEvent(DISPID, DISPPARAMS*);
125     void firePropChangedEvent(DISPID dispId);
126
127 public:
128     CRITICAL_SECTION csEvents;
129     HANDLE sEvents;
130
131     VLCPlugin *_p_instance;
132     BOOL isRunning;
133     BOOL freeze;
134     VLCConnectionPoint *_p_events;
135     VLCConnectionPoint *_p_props;
136     std::vector<LPCONNECTIONPOINT> _v_cps;
137     std::queue<class VLCDispatchEvent *> _q_events;
138
139 private:
140     HANDLE  hThread;
141 };
142
143 #endif
144