[vlc-commits] ActiveX, npapi: privatize vlc_player_option

Sergey Radionov git at videolan.org
Wed Jun 6 22:37:18 CEST 2012


npapi-vlc | branch: master | Sergey Radionov <RSATom at gmail.com> | Sat Apr 21 22:19:23 2012 +0700| [86ecac3f378f17957118a366d28de0edcdacc294] | committer: Jean-Baptiste Kempf

ActiveX, npapi: privatize vlc_player_option

Use it like a VlcPlugin/VlcPluginBase member.

Adapted-by: Jean-Baptiste Kempf <jb at videolan.org>

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/npapi-vlc.git/?a=commit;h=86ecac3f378f17957118a366d28de0edcdacc294
---

 activex/persistpropbag.cpp |    4 ++--
 activex/plugin.h           |    7 ++++++-
 activex/vlccontrol2.cpp    |    4 ++--
 npapi/vlcplugin_base.h     |    7 ++++++-
 npapi/vlcplugin_gtk.cpp    |    6 +++---
 npapi/vlcplugin_mac.cpp    |    4 ++--
 npapi/vlcplugin_win.cpp    |    2 +-
 npapi/vlcplugin_xcb.cpp    |    6 +++---
 npapi/vlcshell.cpp         |    7 ++++---
 9 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/activex/persistpropbag.cpp b/activex/persistpropbag.cpp
index 2e17d5b..f0f842e 100644
--- a/activex/persistpropbag.cpp
+++ b/activex/persistpropbag.cpp
@@ -215,7 +215,7 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
     V_VT(&value) = VT_BOOL;
     if( S_OK == pPropBag->Read(OLESTR("FullscreenEnabled"), &value, pErrorLog) )
     {
-        _p_instance->set_enable_fs(V_BOOL(&value) != VARIANT_FALSE);
+        _p_instance->get_options().set_enable_fs(V_BOOL(&value) != VARIANT_FALSE);
         VariantClear(&value);
     }
 
@@ -286,7 +286,7 @@ STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirt
     VariantClear(&value);
 
     V_VT(&value) = VT_BOOL;
-    V_BOOL(&value) = _p_instance->get_enable_fs()? VARIANT_TRUE : VARIANT_FALSE;
+    V_BOOL(&value) = _p_instance->get_options().get_enable_fs()? VARIANT_TRUE : VARIANT_FALSE;
     pPropBag->Write(OLESTR("FullscreenEnabled"), &value);
     VariantClear(&value);
 
diff --git a/activex/plugin.h b/activex/plugin.h
index bc63428..94883b8 100644
--- a/activex/plugin.h
+++ b/activex/plugin.h
@@ -75,7 +75,7 @@ private:
     LPPICTURE   _inplace_picture;
 };
 
-struct VLCPlugin : public IUnknown, public vlc_player_options
+struct VLCPlugin : public IUnknown, private vlc_player_options
 {
 public:
     VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
@@ -90,6 +90,11 @@ public:
     REFCLSID getClassID(void) { return _p_class->getClassID(); };
     REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
 
+    vlc_player_options& get_options()
+        { return *static_cast<vlc_player_options*>(this); }
+    const vlc_player_options& get_options() const
+        { return *static_cast<const vlc_player_options*>(this); }
+
     /*
     ** persistant properties
     */
diff --git a/activex/vlccontrol2.cpp b/activex/vlccontrol2.cpp
index fb38a1c..28cb940 100644
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -1476,14 +1476,14 @@ STDMETHODIMP VLCControl2::get_FullscreenEnabled(VARIANT_BOOL* enabled)
     if( NULL == enabled )
         return E_POINTER;
 
-    *enabled = varbool( _p_instance->get_enable_fs() );
+    *enabled = varbool( _p_instance->get_options().get_enable_fs() );
 
     return S_OK;
 }
 
 STDMETHODIMP VLCControl2::put_FullscreenEnabled(VARIANT_BOOL enabled)
 {
-    _p_instance->set_enable_fs( VARIANT_FALSE != enabled );
+    _p_instance->get_options().set_enable_fs( VARIANT_FALSE != enabled );
     return S_OK;
 }
 
diff --git a/npapi/vlcplugin_base.h b/npapi/vlcplugin_base.h
index f169612..56b324e 100644
--- a/npapi/vlcplugin_base.h
+++ b/npapi/vlcplugin_base.h
@@ -190,7 +190,7 @@ typedef enum vlc_toolbar_clicked_e {
     clicked_Unmute
 } vlc_toolbar_clicked_t;
 
-class VlcPluginBase: public vlc_player_options
+class VlcPluginBase: private vlc_player_options
 {
 protected:
 
@@ -198,6 +198,11 @@ public:
     VlcPluginBase( NPP, NPuint16_t );
     virtual ~VlcPluginBase();
 
+    vlc_player_options& get_options()
+        { return *static_cast<vlc_player_options*>(this); }
+    const vlc_player_options& get_options() const
+        { return *static_cast<const vlc_player_options*>(this); }
+
     NPError             init(int argc, char* const argn[], char* const argv[]);
     libvlc_instance_t*  getVLC()
                             { return libvlc_instance; };
diff --git a/npapi/vlcplugin_gtk.cpp b/npapi/vlcplugin_gtk.cpp
index 8ce5291..b167693 100644
--- a/npapi/vlcplugin_gtk.cpp
+++ b/npapi/vlcplugin_gtk.cpp
@@ -108,7 +108,7 @@ void VlcPluginGtk::do_set_fullscreen(bool yes)
 
 void VlcPluginGtk::set_fullscreen(int yes)
 {
-    if (!get_enable_fs()) return;
+    if (!get_options().get_enable_fs()) return;
     if (yes == is_fullscreen) return;
     if (yes) {
         gtk_widget_show(fullscreen_win);
@@ -217,7 +217,7 @@ void VlcPluginGtk::popup_menu()
     g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
     gtk_menu_shell_append(GTK_MENU_SHELL(popupmenu), menuitem);
     /* set fullscreen */
-    if (get_enable_fs()) {
+    if (get_options().get_enable_fs()) {
         menuitem = gtk_image_menu_item_new_from_stock(
                                     GTK_STOCK_FULLSCREEN, NULL);
         g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(menu_handler), this);
@@ -414,7 +414,7 @@ bool VlcPluginGtk::create_windows()
 
     Window socket = (Window) npwindow.window;
     GdkColor color_bg;
-    gdk_color_parse(get_bg_color().c_str(), &color_bg);
+    gdk_color_parse(get_options().get_bg_color().c_str(), &color_bg);
 
     parent = gtk_plug_new(socket);
     gtk_widget_modify_bg(parent, GTK_STATE_NORMAL, &color_bg);
diff --git a/npapi/vlcplugin_mac.cpp b/npapi/vlcplugin_mac.cpp
index 0e24e12..7846bda 100644
--- a/npapi/vlcplugin_mac.cpp
+++ b/npapi/vlcplugin_mac.cpp
@@ -42,14 +42,14 @@ void VlcPluginMac::set_player_window()
 
 void VlcPluginMac::toggle_fullscreen()
 {
-    if (!get_enable_fs()) return;
+    if (!get_options().get_enable_fs()) return;
     if (playlist_isplaying())
         libvlc_toggle_fullscreen(libvlc_media_player);
 }
 
 void VlcPluginMac::set_fullscreen(int yes)
 {
-    if (!get_enable_fs()) return;
+    if (!get_options().get_enable_fs()) return;
     if (playlist_isplaying())
         libvlc_set_fullscreen(libvlc_media_player, yes);
 }
diff --git a/npapi/vlcplugin_win.cpp b/npapi/vlcplugin_win.cpp
index 4866a1c..e0527d8 100644
--- a/npapi/vlcplugin_win.cpp
+++ b/npapi/vlcplugin_win.cpp
@@ -88,7 +88,7 @@ LRESULT CALLBACK VlcPluginWin::NPWndProcR(HWND hWnd, UINT uMsg, WPARAM wParam, L
 
 VlcPluginWin::VlcPluginWin(NPP instance, NPuint16_t mode) :
     VlcPluginBase(instance, mode), _NPWndProc(0),
-    _WindowsManager(DllGetModule(), _ViewRC, this)
+    _WindowsManager(DllGetModule(), _ViewRC, &get_options())
 {
     _ViewRC.hDeFullscreenBitmap =
         LoadImage(DllGetModule(), MAKEINTRESOURCE(3),
diff --git a/npapi/vlcplugin_xcb.cpp b/npapi/vlcplugin_xcb.cpp
index 42c7a56..21d7eba 100644
--- a/npapi/vlcplugin_xcb.cpp
+++ b/npapi/vlcplugin_xcb.cpp
@@ -48,14 +48,14 @@ void VlcPluginXcb::set_player_window()
 
 void VlcPluginXcb::toggle_fullscreen()
 {
-    if (!get_enable_fs()) return;
+    if (!get_options().get_enable_fs()) return;
     if (playlist_isplaying())
         libvlc_toggle_fullscreen(libvlc_media_player);
 }
 
 void VlcPluginXcb::set_fullscreen(int yes)
 {
-    if (!get_enable_fs()) return;
+    if (!get_options().get_enable_fs()) return;
     if (playlist_isplaying())
         libvlc_set_fullscreen(libvlc_media_player,yes);
 }
@@ -96,7 +96,7 @@ bool VlcPluginXcb::create_windows()
 
     colormap = screen->default_colormap;
     unsigned r = 0, g = 0, b = 0;
-    HTMLColor2RGB(get_bg_color().c_str(), &r, &g, &b);
+    HTMLColor2RGB(get_options().get_bg_color().c_str(), &r, &g, &b);
     xcb_alloc_color_reply_t *reply = xcb_alloc_color_reply(conn,
             xcb_alloc_color(conn, colormap,
                             (uint16_t) r << 8,
diff --git a/npapi/vlcshell.cpp b/npapi/vlcshell.cpp
index bf5b2d6..6bf2fd7 100644
--- a/npapi/vlcshell.cpp
+++ b/npapi/vlcshell.cpp
@@ -350,7 +350,8 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             p_plugin->resize_windows();
 
             /* now set plugin state to that requested in parameters */
-            p_plugin->set_toolbar_visible( p_plugin->get_show_toolbar() );
+            bool show_toolbar = p_plugin->get_options().get_show_toolbar();
+            p_plugin->set_toolbar_visible( show_toolbar );
 
             /* handle streams properly */
             if( !p_plugin->b_stream )
@@ -359,7 +360,7 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
                 {
                     if( p_plugin->playlist_add( p_plugin->psz_target ) != -1 )
                     {
-                        if( p_plugin->get_autoplay() )
+                        if( p_plugin->get_options().get_autoplay() )
                         {
                             p_plugin->playlist_play();
                         }
@@ -461,7 +462,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* )
 
     if( p_plugin->playlist_add( stream->url ) != -1 )
     {
-        if( p_plugin->get_autoplay() )
+        if( p_plugin->get_options().get_autoplay() )
         {
             p_plugin->playlist_play();
         }



More information about the vlc-commits mailing list