]> git.sesse.net Git - vlc/blob - projects/activex/vlccontrol.h
Replace libvlc_exception_get_message with libvlc_errmsg
[vlc] / projects / activex / vlccontrol.h
1 /*****************************************************************************
2  * vlccontrol.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 along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 #ifndef _VLCCONTROL_H_
24 #define _VLCCONTROL_H_
25
26 #include "axvlc_idl.h"
27
28 class VLCControl : public IVLCControl
29 {
30 public:
31
32     VLCControl(VLCPlugin *p_instance):
33         _p_instance(p_instance), _p_typeinfo(NULL) { }
34     virtual ~VLCControl();
35
36     // IUnknown methods
37     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
38     {
39         if( NULL == ppv )
40           return E_POINTER;
41         if( (IID_IUnknown == riid)
42          || (IID_IDispatch == riid)
43          || (IID_IVLCControl == riid) )
44         {
45             AddRef();
46             *ppv = reinterpret_cast<LPVOID>(this);
47             return NOERROR;
48         }
49         return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
50     }
51
52     STDMETHODIMP_(ULONG) AddRef(void)
53         { return _p_instance->pUnkOuter->AddRef(); }
54     STDMETHODIMP_(ULONG) Release(void)
55         { return _p_instance->pUnkOuter->Release(); }
56
57     // IDispatch methods
58     STDMETHODIMP GetTypeInfoCount(UINT*);
59     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
60     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
61     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
62
63     // IVLCControl methods
64     STDMETHODIMP play(void);
65     STDMETHODIMP get_Visible(VARIANT_BOOL *visible);
66     STDMETHODIMP put_Visible(VARIANT_BOOL visible);
67     STDMETHODIMP pause(void);
68     STDMETHODIMP stop(void);
69     STDMETHODIMP get_Playing(VARIANT_BOOL *isPlaying);
70     STDMETHODIMP get_Position(float *position);
71     STDMETHODIMP put_Position(float position);
72     STDMETHODIMP get_Time(int *seconds);
73     STDMETHODIMP put_Time(int seconds);
74     STDMETHODIMP shuttle(int seconds);
75     STDMETHODIMP fullscreen();
76     STDMETHODIMP get_Length(int *seconds);
77     STDMETHODIMP playFaster(void);
78     STDMETHODIMP playSlower(void);
79     STDMETHODIMP get_Volume(int *volume);
80     STDMETHODIMP put_Volume(int volume);
81     STDMETHODIMP toggleMute(void);
82     STDMETHODIMP setVariable( BSTR name, VARIANT value);
83     STDMETHODIMP getVariable( BSTR name, VARIANT *value);
84     STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position);
85     STDMETHODIMP get_PlaylistIndex(int *index);
86     STDMETHODIMP get_PlaylistCount(int *count);
87     STDMETHODIMP playlistNext(void);
88     STDMETHODIMP playlistPrev(void);
89     STDMETHODIMP playlistClear(void);
90     STDMETHODIMP get_VersionInfo(BSTR *version);
91     STDMETHODIMP get_MRL(BSTR *mrl);
92     STDMETHODIMP put_MRL(BSTR mrl);
93     STDMETHODIMP get_AutoLoop(VARIANT_BOOL *autoloop);
94     STDMETHODIMP put_AutoLoop(VARIANT_BOOL autoloop);
95     STDMETHODIMP get_AutoPlay(VARIANT_BOOL *autoplay);
96     STDMETHODIMP put_AutoPlay(VARIANT_BOOL autoplay);
97
98     static HRESULT CreateTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount);
99     static void FreeTargetOptions(char **cOptions, int cOptionCount);
100
101 private:
102
103     HRESULT      getTypeInfo();
104     HRESULT      exception_bridge(libvlc_exception_t *ex)
105     {
106         if( ! libvlc_exception_raised(ex) )
107             return NOERROR;
108         _p_instance->setErrorInfo(IID_IVLCControl, libvlc_errmsg());
109         libvlc_exception_clear(ex);
110         return E_FAIL;
111     }
112
113     VLCPlugin *_p_instance;
114     ITypeInfo *_p_typeinfo;
115 };
116
117 #endif