connectioncontainer.h 4.37 KB
Newer Older
1 2 3
/*****************************************************************************
 * connectioncontainer.h: ActiveX control for VLC
 *****************************************************************************
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 11 12 13 14 15 16 17 18 19 20 21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24 25 26 27 28 29
 *****************************************************************************/

#ifndef __CONNECTIONCONTAINER_H__
#define __CONNECTIONCONTAINER_H__

#include <ocidl.h>
#include <vector>
Damien Fouilleul's avatar
Damien Fouilleul committed
30
#include <queue>
31
#include <map>
32
#include <cguid.h>
33

34 35
#include "plugin.h"

36 37 38 39 40
class VLCConnectionPoint : public IConnectionPoint
{

public:

41 42
    VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid);
    virtual ~VLCConnectionPoint();
43

44 45 46
    VLCConnectionPoint(const VLCConnectionPoint&) = delete;
    VLCConnectionPoint& operator=(const VLCConnectionPoint&) = delete;

47 48 49
    // IUnknown methods
    STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
    {
50 51
        if( NULL == ppv )
            return E_POINTER;
52
        if( (IID_IUnknown == riid)
53 54
         || (IID_IConnectionPoint == riid) )
        {
55 56 57 58 59 60
            AddRef();
            *ppv = reinterpret_cast<LPVOID>(this);
            return NOERROR;
        }
        // must be a standalone object
        return E_NOINTERFACE;
61
    }
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

    STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };
    STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };

    // IConnectionPoint methods
    STDMETHODIMP GetConnectionInterface(IID *);
    STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);
    STDMETHODIMP Advise(IUnknown *, DWORD *);
    STDMETHODIMP Unadvise(DWORD);
    STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);

    void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);
    void firePropChangedEvent(DISPID dispId);

private:

    REFIID _iid;
    IConnectionPointContainer *_p_cpc;
80
    std::map<DWORD, LPUNKNOWN> _connections;
81 82 83
};

//////////////////////////////////////////////////////////////////////////
Damien Fouilleul's avatar
Damien Fouilleul committed
84 85 86 87
class VLCDispatchEvent {

public:
    VLCDispatchEvent(DISPID dispId, DISPPARAMS dispParams) :
88 89 90
        _dispId(dispId), _dispParams(dispParams)
    {
    }
Damien Fouilleul's avatar
Damien Fouilleul committed
91 92 93 94 95 96
    ~VLCDispatchEvent();

    DISPID      _dispId;
    DISPPARAMS  _dispParams;
};

97
class EventSystemProxyWnd;
98 99 100 101 102 103 104 105 106 107 108
class VLCConnectionPointContainer : public IConnectionPointContainer
{

public:

    VLCConnectionPointContainer(VLCPlugin *p_instance);
    virtual ~VLCConnectionPointContainer();

    // IUnknown methods
    STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
    {
109 110
        if( NULL == ppv)
            return E_POINTER;
111
        if( (IID_IUnknown == riid)
112 113
         || (IID_IConnectionPointContainer == riid) )
        {
114 115 116 117
            AddRef();
            *ppv = reinterpret_cast<LPVOID>(this);
            return NOERROR;
        }
Damien Fouilleul's avatar
Damien Fouilleul committed
118
        return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
119
    }
120

121 122
    STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); }
    STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); }
123 124 125 126 127

    // IConnectionPointContainer methods
    STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);
    STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);

Damien Fouilleul's avatar
Damien Fouilleul committed
128
    void freezeEvents(BOOL);
129 130 131
    void fireEvent(DISPID, DISPPARAMS*);
    void firePropChangedEvent(DISPID dispId);

132 133
public:
    CRITICAL_SECTION csEvents;
134
    EventSystemProxyWnd* _ESProxyWnd;
135 136

    VLCPlugin *_p_instance;
137 138
    BOOL isRunning;
    BOOL freeze;
139 140
    VLCConnectionPoint *_p_events;
    VLCConnectionPoint *_p_props;
Damien Fouilleul's avatar
Damien Fouilleul committed
141
    std::vector<LPCONNECTIONPOINT> _v_cps;
142
    std::queue<VLCDispatchEvent *> _q_events;
143 144 145 146
};

#endif