connectioncontainer.h 4.27 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 36 37 38

class VLCConnectionPoint : public IConnectionPoint
{

public:

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

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

    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;
75
    std::map<DWORD, LPUNKNOWN> _connections;
76 77 78
};

//////////////////////////////////////////////////////////////////////////
Damien Fouilleul's avatar
Damien Fouilleul committed
79 80 81 82 83 84 85 86 87 88 89 90
class VLCDispatchEvent {

public:
    VLCDispatchEvent(DISPID dispId, DISPPARAMS dispParams) :
        _dispId(dispId), _dispParams(dispParams) {};
    VLCDispatchEvent(const VLCDispatchEvent&);
    ~VLCDispatchEvent();

    DISPID      _dispId;
    DISPPARAMS  _dispParams;
};

91
class EventSystemProxyWnd;
92 93 94 95 96 97 98 99 100 101 102
class VLCConnectionPointContainer : public IConnectionPointContainer
{

public:

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

    // IUnknown methods
    STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
    {
103 104
        if( NULL == ppv)
            return E_POINTER;
105
        if( (IID_IUnknown == riid)
106 107
         || (IID_IConnectionPointContainer == riid) )
        {
108 109 110 111
            AddRef();
            *ppv = reinterpret_cast<LPVOID>(this);
            return NOERROR;
        }
Damien Fouilleul's avatar
Damien Fouilleul committed
112
        return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
113 114
    };

Damien Fouilleul's avatar
Damien Fouilleul committed
115 116
    STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
    STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
117 118 119 120 121

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

Damien Fouilleul's avatar
Damien Fouilleul committed
122
    void freezeEvents(BOOL);
123 124 125
    void fireEvent(DISPID, DISPPARAMS*);
    void firePropChangedEvent(DISPID dispId);

126 127
public:
    CRITICAL_SECTION csEvents;
128
    EventSystemProxyWnd* _ESProxyWnd;
129 130

    VLCPlugin *_p_instance;
131 132
    BOOL isRunning;
    BOOL freeze;
133 134
    VLCConnectionPoint *_p_events;
    VLCConnectionPoint *_p_props;
Damien Fouilleul's avatar
Damien Fouilleul committed
135 136
    std::vector<LPCONNECTIONPOINT> _v_cps;
    std::queue<class VLCDispatchEvent *> _q_events;
137 138 139 140
};

#endif