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