]> git.sesse.net Git - vlc/blob - activex/connectioncontainer.h
compilation fixes for MSVC
[vlc] / activex / connectioncontainer.h
1 /*****************************************************************************
2  * connectioncontainer.h: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2005 VideoLAN
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
29 using namespace std;
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 ) return E_POINTER;
44         if( (IID_IUnknown == riid) 
45          && (IID_IConnectionPoint == riid) ) {
46             AddRef();
47             *ppv = reinterpret_cast<LPVOID>(this);
48             return NOERROR;
49         }
50         // must be a standalone object
51         return E_NOINTERFACE;
52     };
53
54     STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };
55     STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };
56
57     // IConnectionPoint methods
58     STDMETHODIMP GetConnectionInterface(IID *);
59     STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);
60     STDMETHODIMP Advise(IUnknown *, DWORD *);
61     STDMETHODIMP Unadvise(DWORD);
62     STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);
63
64     void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);
65     void firePropChangedEvent(DISPID dispId);
66
67 private:
68
69     REFIID _iid;
70     IConnectionPointContainer *_p_cpc;
71     vector<CONNECTDATA> _connections;
72 };
73
74 //////////////////////////////////////////////////////////////////////////
75
76 class VLCConnectionPointContainer : public IConnectionPointContainer
77 {
78
79 public:
80
81     VLCConnectionPointContainer(VLCPlugin *p_instance);
82     virtual ~VLCConnectionPointContainer();
83
84     // IUnknown methods
85     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
86     {
87         if( (NULL != ppv)
88          && (IID_IUnknown == riid) 
89          && (IID_IConnectionPointContainer == riid) ) {
90             AddRef();
91             *ppv = reinterpret_cast<LPVOID>(this);
92             return NOERROR;
93         }
94         return _p_instance->QueryInterface(riid, ppv);
95     };
96
97     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };
98     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };
99
100     // IConnectionPointContainer methods
101     STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);
102     STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);
103
104     void fireEvent(DISPID, DISPPARAMS*);
105     void firePropChangedEvent(DISPID dispId);
106
107 private:
108
109     VLCPlugin *_p_instance;
110     VLCConnectionPoint *_p_events;
111     VLCConnectionPoint *_p_props;
112     vector<LPCONNECTIONPOINT> _v_cps;
113 };
114
115 #endif
116