]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/vlcshell.cpp
mozilla: cleanup
[vlc] / projects / mozilla / vlcshell.cpp
index abf61eb5a94e6009d4c6d8bc9f9cf208d4ba723d..ab4cf514d5762cc04027900911c456ec7cbacff7 100644 (file)
@@ -42,6 +42,7 @@
 #endif
 
 #include "vlcplugin.h"
+#include "vlcshell.h"
 
 /* Enable/disable debugging printf's for X11 resizing */
 #undef X11_RESIZE_DEBUG
@@ -79,19 +80,20 @@ static LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpa
  *****************************************************************************/
 char * NPP_GetMIMEDescription( void )
 {
-    return PLUGIN_MIMETYPES;
+    static char mimetype[] = PLUGIN_MIMETYPES;
+    return mimetype;
 }
 
 NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
 {
-
+    static char psz_name[] = PLUGIN_NAME;
     static char psz_desc[1000];
 
     /* plugin class variables */
     switch( variable )
     {
         case NPPVpluginNameString:
-            *((char **)value) = PLUGIN_NAME;
+            *((char **)value) = psz_name;
             return NPERR_NO_ERROR;
 
         case NPPVpluginDescriptionString:
@@ -360,9 +362,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         /* we should probably show a splash screen here */
         return NPERR_NO_ERROR;
     }
+
 #if defined(XP_UNIX) && !defined(__APPLE__)
     control = p_plugin->getControlWindow();
 #endif
+
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
     libvlc_instance_t *p_vlc = p_plugin->getVLC();
 
     /*
@@ -384,7 +391,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         if( !curwin.window || drawable != (((NP_Port*) (curwin.window))->port) )
         {
             /* set/change parent window */
-            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
+            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, &ex);
+            if( libvlc_exception_raised(&ex) )
+                fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+            libvlc_exception_clear(&ex);
         }
 
         /* as MacOS X video output is windowless, set viewport */
@@ -399,13 +409,17 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
         view.left    = ((NP_Port*) (window->window))->portx;
         view.bottom  = window->height+view.top;
         view.right   = window->width+view.left;
+
         /* clipRect coordinates are also relative to GrafPort */
         clip.top     = window->clipRect.top;
         clip.left    = window->clipRect.left;
         clip.bottom  = window->clipRect.bottom;
         clip.right   = window->clipRect.right;
 
-        libvlc_video_set_viewport(p_vlc, &view, &clip, NULL);
+        libvlc_video_set_viewport(p_vlc, &view, &clip, &ex);
+        if( libvlc_exception_raised(&ex) )
+            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+        libvlc_exception_clear(&ex);
 
         /* remember new window */
         p_plugin->setWindow(*window);
@@ -413,7 +427,12 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
     else if( curwin.window )
     {
         /* change/set parent */
-        libvlc_video_set_parent(p_vlc, 0, NULL);
+        libvlc_video_set_parent(p_vlc, 0, &ex);
+
+        if( libvlc_exception_raised(&ex) )
+            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+        libvlc_exception_clear(&ex);
+
         curwin.window = NULL;
     }
 #endif /* XP_MACOSX */
@@ -447,7 +466,10 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             SetWindowLong((HWND)drawable, GWL_STYLE, style);
 
             /* change/set parent */
-            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, NULL);
+            libvlc_video_set_parent(p_vlc, (libvlc_drawable_t)drawable, &ex);
+            if( libvlc_exception_raised(&ex) )
+                fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+            libvlc_exception_clear(&ex);
 
             /* remember new window */
             p_plugin->setWindow(*window);
@@ -457,14 +479,19 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             UpdateWindow( (HWND)drawable );
         }
     }
-    else if ( curwin.window )
+    else if( curwin.window )
     {
         /* reset WNDPROC */
         HWND oldwin = (HWND)curwin.window;
         SetWindowLong( oldwin, GWL_WNDPROC, (LONG)(p_plugin->getWindowProc()) );
         p_plugin->setWindowProc(NULL);
+
         /* change/set parent */
-        libvlc_video_set_parent(p_vlc, 0, NULL);
+        libvlc_video_set_parent(p_vlc, 0, &ex);
+        if( libvlc_exception_raised(&ex) )
+            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+        libvlc_exception_clear(&ex);
+
         curwin.window = NULL;
     }
 #endif /* XP_WIN */
@@ -518,8 +545,6 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
 /*
             libvlc_media_player_t *p_md;
 
-            libvlc_exception_t ex;
-            libvlc_exception_init(& ex );
             p_md = p_plugin->getMD( &ex );
             libvlc_exception_clear( &ex );
             libvlc_event_attach( libvlc_media_player_event_manager( p_md, &ex ),
@@ -527,12 +552,19 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
 */
 
             /* set/change parent window */
-            libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, NULL );
+            libvlc_video_set_parent( p_vlc, (libvlc_drawable_t) video, &ex );
+            if( libvlc_exception_raised(&ex) )
+                fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+            libvlc_exception_clear(&ex);
 
             /* remember window */
             p_plugin->setWindow( *window );
             p_plugin->setVideoWindow( video );
-            if( controls ) { p_plugin->setControlWindow( controls ); }
+
+            if( controls )
+            {
+                p_plugin->setControlWindow( controls );
+            }
 
             Redraw( w, (XtPointer)p_plugin, NULL );
 
@@ -543,10 +575,13 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
             }
         }
     }
-    else if ( curwin.window )
+    else if( curwin.window )
     {
         /* change/set parent */
-        libvlc_video_set_parent(p_vlc, 0, NULL);
+        libvlc_video_set_parent(p_vlc, 0, &ex);
+        if( libvlc_exception_raised(&ex) )
+            fprintf( stderr, "Exception: %s\n", libvlc_exception_get_message(&ex) );
+        libvlc_exception_clear(&ex);
         curwin.window = NULL;
     }
 #endif /* XP_UNIX */
@@ -604,7 +639,6 @@ int32 NPP_WriteReady( NPP instance, NPStream *stream )
     return 8*1024;
 }
 
-
 int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
                  int32 len, void *buffer )
 {
@@ -612,7 +646,6 @@ int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
     return len;
 }
 
-
 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
 {
     if( instance == NULL )
@@ -622,7 +655,6 @@ NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
     return NPERR_NO_ERROR;
 }
 
-
 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
 {
     if( instance == NULL )
@@ -645,7 +677,6 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
     }
 }
 
-
 void NPP_URLNotify( NPP instance, const char* url,
                     NPReason reason, void* notifyData )
 {