]> git.sesse.net Git - vlc/blob - activex/plugin.h
Removes trailing spaces. Removes tabs.
[vlc] / activex / plugin.h
1 /*****************************************************************************
2  * plugin.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 __PLUGIN_H__
24 #define __PLUGIN_H__
25
26 #include <ole2.h>
27 #include <olectl.h>
28
29 #include <vlc/libvlc.h>
30
31 extern const GUID CLSID_VLCPlugin;
32 extern const GUID CLSID_VLCPlugin2;
33 extern const GUID LIBID_AXVLC;
34 extern const GUID DIID_DVLCEvents;
35
36 class VLCPluginClass : public IClassFactory
37 {
38
39 public:
40
41     VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid);
42
43     /* IUnknown methods */
44     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
45     STDMETHODIMP_(ULONG) AddRef(void);
46     STDMETHODIMP_(ULONG) Release(void);
47
48     /* IClassFactory methods */
49     STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
50     STDMETHODIMP LockServer(BOOL fLock);
51
52     REFCLSID getClassID(void) { return (REFCLSID)_classid; };
53
54     LPCTSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
55     HINSTANCE getHInstance(void) const { return _hinstance; };
56     LPPICTURE getInPlacePict(void) const
57         { if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; };
58
59 protected:
60
61     virtual ~VLCPluginClass();
62
63 private:
64
65     LPLONG      _p_class_ref;
66     HINSTANCE   _hinstance;
67     CLSID       _classid;
68     ATOM        _inplace_wndclass_atom;
69     LPPICTURE   _inplace_picture;
70 };
71
72 class VLCPlugin : public IUnknown
73 {
74
75 public:
76
77     VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
78
79     /* IUnknown methods */
80     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
81     STDMETHODIMP_(ULONG) AddRef(void);
82     STDMETHODIMP_(ULONG) Release(void);
83
84     /* custom methods */
85     HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
86     REFCLSID getClassID(void) { return _p_class->getClassID(); };
87     REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
88
89     /*
90     ** persistant properties
91     */
92     void setMRL(BSTR mrl)
93     {
94         SysFreeString(_bstr_mrl);
95         _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
96         setDirty(TRUE);
97     };
98     const BSTR getMRL(void) { return _bstr_mrl; };
99
100     inline void setAutoPlay(BOOL autoplay)
101     {
102         _b_autoplay = autoplay;
103         setDirty(TRUE);
104     };
105     inline BOOL getAutoPlay(void) { return _b_autoplay; };
106
107     inline void setAutoLoop(BOOL autoloop)
108     {
109         _b_autoloop = autoloop;
110         setDirty(TRUE);
111     };
112     inline BOOL getAutoLoop(void) { return _b_autoloop;};
113
114     void setVolume(int volume);
115     int getVolume(void) { return _i_volume; };
116
117     void setBackColor(OLE_COLOR backcolor);
118     OLE_COLOR getBackColor(void) { return _i_backcolor; };
119
120     void setVisible(BOOL fVisible);
121     BOOL getVisible(void) { return _b_visible; };
122     BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
123
124     inline void setStartTime(int time)
125     {
126         _i_time = time;
127         setDirty(TRUE);
128     };
129     inline int getStartTime(void) { return _i_time; };
130
131     void setTime(int time);
132     int  getTime(void) { return _i_time; };
133
134     void setBaseURL(BSTR url)
135     {
136         SysFreeString(_bstr_baseurl);
137         _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
138         setDirty(TRUE);
139     };
140     const BSTR getBaseURL(void) { return _bstr_baseurl; };
141
142     // control size in HIMETRIC
143     inline void setExtent(const SIZEL& extent)
144     {
145         _extent = extent;
146         setDirty(TRUE);
147     };
148     const SIZEL& getExtent(void) { return _extent; };
149
150     // transient properties
151     inline void setMute(BOOL mute) { _b_mute = mute; };
152
153     inline void setPicture(LPPICTURE pict)
154     {
155         if( NULL != _p_pict )
156             _p_pict->Release();
157         if( NULL != pict )
158             _p_pict->AddRef();
159         _p_pict = pict;
160     };
161
162     inline LPPICTURE getPicture(void)
163     {
164         if( NULL != _p_pict )
165             _p_pict->AddRef();
166         return _p_pict;
167     };
168
169     BOOL hasFocus(void);
170     void setFocus(BOOL fFocus);
171
172     inline UINT getCodePage(void) { return _i_codepage; };
173     inline void setCodePage(UINT cp)
174     {
175         // accept new codepage only if it works on this system
176         size_t mblen = WideCharToMultiByte(cp,
177                 0, L"test", -1, NULL, 0, NULL, NULL);
178         if( mblen > 0 )
179             _i_codepage = cp;
180     };
181
182     inline BOOL isUserMode(void) { return _b_usermode; };
183     inline void setUserMode(BOOL um) { _b_usermode = um; };
184
185     inline BOOL isDirty(void) { return _b_dirty; };
186     inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
187
188     inline BOOL isRunning(void) { return NULL != _p_libvlc; };
189     HRESULT getVLCObject(int *i_vlc);
190     HRESULT getVLC(libvlc_instance_t** p_vlc);
191     void setErrorInfo(REFIID riid, const char *description);
192
193     // control geometry within container
194     RECT getPosRect(void) { return _posRect; };
195     inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
196     BOOL isInPlaceActive(void);
197
198     /*
199     ** container events
200     */
201     HRESULT onInit(void);
202     HRESULT onLoad(void);
203     HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
204     HRESULT onInPlaceDeactivate(void);
205     HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
206     HRESULT onClose(DWORD dwSaveOption);
207     void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
208     void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
209             HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
210     void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
211
212     /*
213     ** control events
214     */
215     void freezeEvents(BOOL freeze);
216     void firePropChangedEvent(DISPID dispid);
217     void fireOnPlayEvent(void);
218     void fireOnPauseEvent(void);
219     void fireOnStopEvent(void);
220
221     // controlling IUnknown interface
222     LPUNKNOWN pUnkOuter;
223
224 protected:
225
226     virtual ~VLCPlugin();
227
228 private:
229
230     //implemented interfaces
231     class VLCOleObject *vlcOleObject;
232     class VLCOleControl *vlcOleControl;
233     class VLCOleInPlaceObject *vlcOleInPlaceObject;
234     class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
235     class VLCPersistStreamInit *vlcPersistStreamInit;
236     class VLCPersistStorage *vlcPersistStorage;
237     class VLCPersistPropertyBag *vlcPersistPropertyBag;
238     class VLCProvideClassInfo *vlcProvideClassInfo;
239     class VLCConnectionPointContainer *vlcConnectionPointContainer;
240     class VLCObjectSafety *vlcObjectSafety;
241     class VLCControl *vlcControl;
242     class VLCControl2 *vlcControl2;
243     class VLCViewObject *vlcViewObject;
244     class VLCDataObject *vlcDataObject;
245     class VLCSupportErrorInfo *vlcSupportErrorInfo;
246
247     // in place activated window (Plugin window)
248     HWND _inplacewnd;
249
250     VLCPluginClass* _p_class;
251     ULONG _i_ref;
252
253     libvlc_instance_t* _p_libvlc;
254     UINT _i_codepage;
255     BOOL _b_usermode;
256     RECT _posRect;
257     LPPICTURE _p_pict;
258
259     // persistable properties
260     BSTR _bstr_baseurl;
261     BSTR _bstr_mrl;
262     BOOL _b_autoplay;
263     BOOL _b_autoloop;
264     BOOL _b_visible;
265     BOOL _b_mute;
266     int  _i_volume;
267     int  _i_time;
268     SIZEL _extent;
269     OLE_COLOR _i_backcolor;
270     // indicates whether properties needs persisting
271     BOOL _b_dirty;
272 };
273
274 #endif