]> git.sesse.net Git - vlc/blob - projects/activex/vlccontrol.h
Fix potential segfault.
[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
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 _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) :  _p_instance(p_instance), _p_typeinfo(NULL) {};
33     virtual ~VLCControl();
34
35     // IUnknown methods
36     STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
37     {
38         if( NULL == ppv )
39           return E_POINTER;
40         if( (IID_IUnknown == riid)
41          || (IID_IDispatch == riid)
42          || (IID_IVLCControl == riid) )
43         {
44             AddRef();
45             *ppv = reinterpret_cast<LPVOID>(this);
46             return NOERROR;
47         }
48         return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
49     };
50
51     STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
52     STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
53
54     // IDispatch methods
55     STDMETHODIMP GetTypeInfoCount(UINT*);
56     STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
57     STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
58     STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
59
60     // IVLCControl methods
61     STDMETHODIMP play(void);
62     STDMETHODIMP get_Visible(VARIANT_BOOL *visible);
63     STDMETHODIMP put_Visible(VARIANT_BOOL visible);
64     STDMETHODIMP pause(void);
65     STDMETHODIMP stop(void);
66     STDMETHODIMP get_Playing(VARIANT_BOOL *isPlaying);
67     STDMETHODIMP get_Position(float *position);
68     STDMETHODIMP put_Position(float position);
69     STDMETHODIMP get_Time(int *seconds);
70     STDMETHODIMP put_Time(int seconds);
71     STDMETHODIMP shuttle(int seconds);
72     STDMETHODIMP fullscreen();
73     STDMETHODIMP get_Length(int *seconds);
74     STDMETHODIMP playFaster(void);
75     STDMETHODIMP playSlower(void);
76     STDMETHODIMP get_Volume(int *volume);
77     STDMETHODIMP put_Volume(int volume);
78     STDMETHODIMP toggleMute(void);
79     STDMETHODIMP setVariable( BSTR name, VARIANT value);
80     STDMETHODIMP getVariable( BSTR name, VARIANT *value);
81     STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position);
82     STDMETHODIMP get_PlaylistIndex(int *index);
83     STDMETHODIMP get_PlaylistCount(int *count);
84     STDMETHODIMP playlistNext(void);
85     STDMETHODIMP playlistPrev(void);
86     STDMETHODIMP playlistClear(void);
87     STDMETHODIMP get_VersionInfo(BSTR *version);
88     STDMETHODIMP get_MRL(BSTR *mrl);
89     STDMETHODIMP put_MRL(BSTR mrl);
90     STDMETHODIMP get_AutoLoop(VARIANT_BOOL *autoloop);
91     STDMETHODIMP put_AutoLoop(VARIANT_BOOL autoloop);
92     STDMETHODIMP get_AutoPlay(VARIANT_BOOL *autoplay);
93     STDMETHODIMP put_AutoPlay(VARIANT_BOOL autoplay);
94
95     static HRESULT CreateTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount);
96     static void FreeTargetOptions(char **cOptions, int cOptionCount);
97
98 private:
99
100     HRESULT      getTypeInfo();
101
102     VLCPlugin *_p_instance;
103     ITypeInfo *_p_typeinfo;
104 };
105
106 #endif