]> git.sesse.net Git - vlc/blob - mozilla/vlcshell.cpp
* string review.
[vlc] / mozilla / vlcshell.cpp
1 /*****************************************************************************
2  * vlcshell.cpp: a VLC plugin for Mozilla
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id: vlcshell.cpp,v 1.28 2004/01/25 16:17:03 anil Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /* XXX: disable VLC here */
25 #define USE_LIBVLC 1
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "config.h"
31
32 #include <stdio.h>
33 #include <string.h>
34 #include <stdlib.h>
35
36 /* vlc stuff */
37 #ifdef USE_LIBVLC
38 #   include <vlc/vlc.h>
39 #endif
40
41 /* Mozilla stuff */
42 #ifdef HAVE_MOZILLA_CONFIG_H
43 #   include <mozilla-config.h>
44 #endif
45 #include <nsISupports.h>
46 #include <nsMemory.h>
47 #include <npapi.h>
48 #include <jri.h>
49
50 #if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
51 #define XP_UNIX 1
52 #elif defined(XP_MACOSX)
53 #undef XP_UNIX
54 #endif
55
56 #ifdef XP_WIN
57     /* Windows stuff */
58 #endif
59
60 #ifdef XP_MACOSX
61     /* Mac OS X stuff */
62 #   include <Quickdraw.h>
63 #endif
64
65 #ifdef XP_UNIX
66     /* X11 stuff */
67 #   include <X11/Xlib.h>
68 #   include <X11/Intrinsic.h>
69 #   include <X11/StringDefs.h>
70 #endif
71
72 #include "vlcpeer.h"
73 #include "vlcplugin.h"
74
75 #if USE_LIBVLC
76 #   define WINDOW_TEXT _("(no picture)")
77 #else
78 #   define WINDOW_TEXT _("(no libvlc)")
79 #endif
80
81 /*****************************************************************************
82  * Unix-only declarations
83 ******************************************************************************/
84 #ifdef XP_UNIX
85 #   define VOUT_PLUGINS "xvideo,x11,dummy"
86 #   define AOUT_PLUGINS "oss,dummy"
87
88 static void Redraw( Widget w, XtPointer closure, XEvent *event );
89 #endif
90
91 /*****************************************************************************
92  * MacOS-only declarations
93 ******************************************************************************/
94 #ifdef XP_MACOSX
95 #   define VOUT_PLUGINS "macosx"
96 #   define AOUT_PLUGINS "macosx"
97
98 #endif
99
100 /*****************************************************************************
101  * Windows-only declarations
102  *****************************************************************************/
103 #ifdef XP_WIN
104 #   define VOUT_PLUGINS "directx,wingdi,dummy"
105 #   define AOUT_PLUGINS "directx,waveout,dummy"
106
107 #if defined(XP_WIN) && !USE_LIBVLC
108 LRESULT CALLBACK Manage( HWND, UINT, WPARAM, LPARAM );
109 #endif
110 #endif
111
112 /******************************************************************************
113  * UNIX-only API calls
114  *****************************************************************************/
115 char * NPP_GetMIMEDescription( void )
116 {
117     return PLUGIN_MIMETYPES;
118 }
119
120 NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
121 {
122
123     static nsIID nsid = VLCINTF_IID;
124     static char psz_desc[1000];
125
126     switch( variable )
127     {
128         case NPPVpluginNameString:
129             *((char **)value) = PLUGIN_NAME;
130             return NPERR_NO_ERROR;
131
132         case NPPVpluginDescriptionString:
133 #if USE_LIBVLC
134             snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, VLC_Version() );
135 #else
136             snprintf( psz_desc, 1000-1, PLUGIN_DESCRIPTION, _("(disabled)") );
137 #endif
138             psz_desc[1000-1] = 0;
139             *((char **)value) = psz_desc;
140             return NPERR_NO_ERROR;
141
142         default:
143             /* go on... */
144             break;
145     }
146
147     if( instance == NULL )
148     {
149         return NPERR_INVALID_INSTANCE_ERROR;
150     }
151
152     VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;
153
154     switch( variable )
155     {
156         case NPPVpluginScriptableInstance:
157             *(nsISupports**)value = p_plugin->GetPeer();
158             if( *(nsISupports**)value == NULL )
159             {
160                 return NPERR_OUT_OF_MEMORY_ERROR;
161             }
162             break;
163
164         case NPPVpluginScriptableIID:
165             *(nsIID**)value = (nsIID*)NPN_MemAlloc( sizeof(nsIID) );
166             if( *(nsIID**)value == NULL )
167             {
168                 return NPERR_OUT_OF_MEMORY_ERROR;
169             }
170             **(nsIID**)value = nsid;
171             break;
172
173         default:
174             return NPERR_GENERIC_ERROR;
175     }
176
177     return NPERR_NO_ERROR;
178 }
179
180 /******************************************************************************
181  * Mac-only API calls
182  *****************************************************************************/
183 #ifdef XP_MACOSX
184 int16 NPP_HandleEvent( NPP instance, void * event )
185 {
186     VlcPlugin *p_plugin = (VlcPlugin*)instance->pdata;
187     vlc_value_t value;
188
189     if( instance == NULL )
190     {
191         return false;
192     }
193
194     EventRecord *pouetEvent = (EventRecord*)event;
195
196     if (pouetEvent->what == 6)
197     {
198         value.i_int = 1;
199         VLC_Set( p_plugin->i_vlc, "drawableredraw", value );
200         return true;
201     }
202
203     Boolean eventHandled = false;
204
205     return eventHandled;
206 }
207 #endif
208
209 /******************************************************************************
210  * General Plug-in Calls
211  *****************************************************************************/
212 NPError NPP_Initialize( void )
213 {
214     return NPERR_NO_ERROR;
215 }
216
217 jref NPP_GetJavaClass( void )
218 {
219     return NULL;
220 }
221
222 void NPP_Shutdown( void )
223 {
224     ;
225 }
226
227 NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
228                  char* argn[], char* argv[], NPSavedData* saved )
229 {
230     int i;
231
232 #if USE_LIBVLC
233     vlc_value_t value;
234     int i_ret;
235
236 #endif
237
238     if( instance == NULL )
239     {
240         return NPERR_INVALID_INSTANCE_ERROR;
241     }
242
243     VlcPlugin * p_plugin = new VlcPlugin( instance );
244
245     if( p_plugin == NULL )
246     {
247         return NPERR_OUT_OF_MEMORY_ERROR;
248     }
249
250     instance->pdata = p_plugin;
251
252 #ifdef XP_WIN
253     p_plugin->p_hwnd = NULL;
254     p_plugin->pf_wndproc = NULL;
255 #endif
256
257 #ifdef XP_UNIX
258     p_plugin->window = 0;
259     p_plugin->p_display = NULL;
260 #endif
261
262     p_plugin->p_npwin = NULL;
263     p_plugin->i_npmode = mode;
264     p_plugin->i_width = 0;
265     p_plugin->i_height = 0;
266
267 #if USE_LIBVLC
268     p_plugin->i_vlc = VLC_Create();
269     if( p_plugin->i_vlc < 0 )
270     {
271         p_plugin->i_vlc = 0;
272         delete p_plugin;
273         p_plugin = NULL;
274         return NPERR_GENERIC_ERROR;
275     }
276
277     {
278 #ifdef XP_MACOSX
279         char *home_user;
280         char *directory;
281         char *plugin_path;
282         char *ppsz_argv[] = { "vlc", "--plugin-path", NULL };
283
284         home_user = strdup( getenv("HOME") );
285         directory = strdup( "/Library/Internet Plug-Ins/VLC Plugin.plugin/"
286                             "Contents/MacOS/modules" );
287         plugin_path = malloc( strlen( directory ) + strlen( home_user ) );
288         memcpy( plugin_path , home_user , strlen(home_user) );
289         memcpy( plugin_path + strlen( home_user ) , directory ,
290                 strlen( directory ) );
291
292         ppsz_argv[2] = plugin_path;
293
294 #elif defined(XP_WIN)
295         char *ppsz_argv[] = { NULL, "-vv" };
296         HKEY h_key;
297         DWORD i_type, i_data = MAX_PATH + 1;
298         char p_data[MAX_PATH + 1];
299         if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",
300                           0, KEY_READ, &h_key ) == ERROR_SUCCESS )
301         {
302              if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,
303                                   (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )
304              {
305                  if( i_type == REG_SZ )
306                  {
307                      strcat( p_data, "\\vlc" );
308                      ppsz_argv[0] = p_data;
309                  }
310              }
311              RegCloseKey( h_key );
312         }
313
314         if( !ppsz_argv[0] ) ppsz_argv[0] = "vlc";
315
316 #else
317         char *ppsz_argv[] =
318         {
319             "vlc"
320             /*, "--plugin-path", "/home/sam/videolan/vlc_MAIN/plugins"*/
321         };
322
323 #endif
324
325         i_ret = VLC_Init( p_plugin->i_vlc, sizeof(ppsz_argv)/sizeof(char*),
326                           ppsz_argv );
327
328 #ifdef XP_MACOSX
329         free( home_user );
330         free( directory );
331         free( plugin_path );
332 #endif
333     }
334
335     if( i_ret )
336     {
337         VLC_Destroy( p_plugin->i_vlc );
338         p_plugin->i_vlc = 0;
339         delete p_plugin;
340         p_plugin = NULL;
341         return NPERR_GENERIC_ERROR;
342     }
343
344     value.psz_string = "dummy";
345     VLC_Set( p_plugin->i_vlc, "conf::intf", value );
346     value.psz_string = VOUT_PLUGINS;
347     VLC_Set( p_plugin->i_vlc, "conf::vout", value );
348     value.psz_string = AOUT_PLUGINS;
349     VLC_Set( p_plugin->i_vlc, "conf::aout", value );
350
351 #else
352     p_plugin->i_vlc = 1;
353
354 #endif /* USE_LIBVLC */
355
356     p_plugin->b_stream = VLC_FALSE;
357     p_plugin->b_autoplay = VLC_FALSE;
358     p_plugin->psz_target = NULL;
359
360     for( i = 0; i < argc ; i++ )
361     {
362         if( !strcmp( argn[i], "target" ) )
363         {
364             p_plugin->psz_target = argv[i];
365         }
366         else if( !strcmp( argn[i], "autoplay" ) )
367         {
368             if( !strcmp( argv[i], "yes" ) )
369             {
370                 p_plugin->b_autoplay = 1;
371             }
372         }
373         else if( !strcmp( argn[i], "autostart" ) )
374         {
375             if( !strcmp( argv[i], "1" ) || !strcmp( argv[i], "true" ) )
376             {
377                 p_plugin->b_autoplay = 1;
378             }
379         }
380         else if( !strcmp( argn[i], "filename" ) )
381         {
382             p_plugin->psz_target = argv[i];
383         }
384         else if( !strcmp( argn[i], "src" ) )
385         {
386             p_plugin->psz_target = argv[i];
387         }
388
389 #if USE_LIBVLC
390         else if( !strcmp( argn[i], "loop" ) )
391         {
392             if( !strcmp( argv[i], "yes" ) )
393             {
394                 value.b_bool = VLC_TRUE;
395                 VLC_Set( p_plugin->i_vlc, "conf::loop", value );
396             }
397         }
398 #endif
399     }
400
401     if( p_plugin->psz_target )
402     {
403         p_plugin->psz_target = strdup( p_plugin->psz_target );
404     }
405
406     return NPERR_NO_ERROR;
407 }
408
409 NPError NPP_Destroy( NPP instance, NPSavedData** save )
410 {
411     if( instance == NULL )
412     {
413         return NPERR_INVALID_INSTANCE_ERROR;
414     }
415
416     VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
417
418     if( p_plugin != NULL )
419     {
420         if( p_plugin->i_vlc )
421         {
422 #if USE_LIBVLC
423             VLC_Stop( p_plugin->i_vlc );
424             VLC_Destroy( p_plugin->i_vlc );
425 #endif
426             p_plugin->i_vlc = 0;
427         }
428
429         if( p_plugin->psz_target )
430         {
431             free( p_plugin->psz_target );
432             p_plugin->psz_target = NULL;
433         }
434
435         delete p_plugin;
436     }
437
438     instance->pdata = NULL;
439
440     return NPERR_NO_ERROR;
441 }
442
443 NPError NPP_SetWindow( NPP instance, NPWindow* window )
444 {
445     vlc_value_t value;
446 #ifdef XP_MACOSX
447     vlc_value_t valuex;
448     vlc_value_t valuey;
449     vlc_value_t valuew;
450     vlc_value_t valueh;
451     vlc_value_t valuet;
452     vlc_value_t valuel;
453     vlc_value_t valueb;
454     vlc_value_t valuer;
455     vlc_value_t valueportx;
456     vlc_value_t valueporty;
457     Rect black_rect;
458     char * text;
459 #endif
460
461     if( instance == NULL )
462     {
463         return NPERR_INVALID_INSTANCE_ERROR;
464     }
465
466     VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
467
468     /* Write the window ID for vlc */
469 #if USE_LIBVLC
470
471 #ifdef XP_MACOSX
472     value.i_int = ((NP_Port*) (window->window))->port;
473     VLC_Set( p_plugin->i_vlc, "drawable", value );
474
475     valueportx.i_int = ((NP_Port*) (window->window))->portx;
476     valueporty.i_int = ((NP_Port*) (window->window))->porty;
477     VLC_Set( p_plugin->i_vlc, "drawableportx", valueportx );
478     VLC_Set( p_plugin->i_vlc, "drawableporty", valueporty );
479
480     valuex.i_int = window->x;
481     valuey.i_int = window->y;
482     valuew.i_int = window->width;
483     valueh.i_int = window->height;
484     valuet.i_int = window->clipRect.top;
485     valuel.i_int = window->clipRect.left;
486     valueb.i_int = window->clipRect.bottom;
487     valuer.i_int = window->clipRect.right;
488
489     VLC_Set( p_plugin->i_vlc, "drawablet", valuet );
490     VLC_Set( p_plugin->i_vlc, "drawablel", valuel );
491     VLC_Set( p_plugin->i_vlc, "drawableb", valueb );
492     VLC_Set( p_plugin->i_vlc, "drawabler", valuer );
493     VLC_Set( p_plugin->i_vlc, "drawablex", valuex );
494     VLC_Set( p_plugin->i_vlc, "drawabley", valuey );
495     VLC_Set( p_plugin->i_vlc, "drawablew", valuew );
496     VLC_Set( p_plugin->i_vlc, "drawableh", valueh );
497
498     p_plugin->window = window;
499
500     /* draw the beautiful "No Picture" */
501
502     black_rect.top = valuet.i_int - valuey.i_int;
503     black_rect.left = valuel.i_int - valuex.i_int;
504     black_rect.bottom = valueb.i_int - valuey.i_int;
505     black_rect.right = valuer.i_int - valuex.i_int;
506
507     SetPort( value.i_int );
508     SetOrigin( valueportx.i_int , valueporty.i_int );
509     ForeColor(blackColor);
510     PenMode( patCopy );
511     PaintRect( &black_rect );
512
513     ForeColor(whiteColor);
514     text = strdup( WINDOW_TEXT );
515     MoveTo( valuew.i_int / 2 - 40 , valueh.i_int / 2 );
516     DrawText( text , 0 , strlen(text) );
517     free(text);
518
519 #else
520     /* FIXME: this cast sucks */
521     value.i_int = (int) (ptrdiff_t) (void *) window->window;
522     VLC_Set( p_plugin->i_vlc, "drawable", value );
523 #endif
524
525 #endif
526
527     /*
528      * PLUGIN DEVELOPERS:
529      *  Before setting window to point to the
530      *  new window, you may wish to compare the new window
531      *  info to the previous window (if any) to note window
532      *  size changes, etc.
533      */
534
535 #ifdef XP_WIN
536     if( !window || !window->window )
537     {
538         /* Window was destroyed. Invalidate everything. */
539         if( p_plugin->p_npwin )
540         {
541 #if !USE_LIBVLC
542             SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
543                            (LONG)p_plugin->pf_wndproc );
544 #endif
545             p_plugin->pf_wndproc = NULL;
546             p_plugin->p_hwnd = NULL;
547         }
548
549         p_plugin->p_npwin = window;
550         return NPERR_NO_ERROR;
551     }
552
553     if( p_plugin->p_npwin )
554     {
555         if( p_plugin->p_hwnd == (HWND)window->window )
556         {
557             /* Same window, but something may have changed. First we
558              * update the plugin structure, then we redraw the window */
559             p_plugin->i_width = window->width;
560             p_plugin->i_height = window->height;
561             p_plugin->p_npwin = window;
562 #if !USE_LIBVLC
563             InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
564             UpdateWindow( p_plugin->p_hwnd );
565 #endif
566             return NPERR_NO_ERROR;
567         }
568
569         /* Window has changed. Destroy the one we have, and go
570          * on as if it was a real initialization. */
571 #if !USE_LIBVLC
572         SetWindowLong( p_plugin->p_hwnd, GWL_WNDPROC,
573                        (LONG)p_plugin->pf_wndproc );
574 #endif
575         p_plugin->pf_wndproc = NULL;
576         p_plugin->p_hwnd = NULL;
577     }
578
579 #if !USE_LIBVLC
580     p_plugin->pf_wndproc = (WNDPROC)SetWindowLong( (HWND)window->window,
581                                                    GWL_WNDPROC, (LONG)Manage );
582 #endif
583
584     p_plugin->p_hwnd = (HWND)window->window;
585     SetProp( p_plugin->p_hwnd, "w00t", (HANDLE)p_plugin );
586     InvalidateRect( p_plugin->p_hwnd, NULL, TRUE );
587     UpdateWindow( p_plugin->p_hwnd );
588 #endif
589
590 #ifdef XP_UNIX
591     p_plugin->window = (Window) window->window;
592     p_plugin->p_display = ((NPSetWindowCallbackStruct *)window->ws_info)->display;
593
594     Widget w = XtWindowToWidget( p_plugin->p_display, p_plugin->window );
595     XtAddEventHandler( w, ExposureMask, FALSE,
596                        (XtEventHandler)Redraw, p_plugin );
597     Redraw( w, (XtPointer)p_plugin, NULL );
598 #endif
599
600     p_plugin->p_npwin = window;
601
602     p_plugin->i_width = window->width;
603     p_plugin->i_height = window->height;
604
605     if( !p_plugin->b_stream )
606     {
607         int i_mode = PLAYLIST_APPEND;
608
609         if( p_plugin->b_autoplay )
610         {
611             i_mode |= PLAYLIST_GO;
612         }
613
614         if( p_plugin->psz_target )
615         {
616 #if USE_LIBVLC
617             VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target,
618                            0, 0, i_mode, PLAYLIST_END );
619 #endif
620             p_plugin->b_stream = VLC_TRUE;
621         }
622     }
623
624     return NPERR_NO_ERROR;
625 }
626
627 NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
628                        NPBool seekable, uint16 *stype )
629 {
630     if( instance == NULL )
631     {
632         return NPERR_INVALID_INSTANCE_ERROR;
633     }
634
635 #if 0
636     VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
637 #endif
638
639     /* fprintf(stderr, "NPP_NewStream - FILE mode !!\n"); */
640
641     /* We want a *filename* ! */
642     *stype = NP_ASFILE;
643
644 #if 0
645     if( !p_plugin->b_stream )
646     {
647         p_plugin->psz_target = strdup( stream->url );
648         p_plugin->b_stream = VLC_TRUE;
649     }
650 #endif
651
652     return NPERR_NO_ERROR;
653 }
654
655 int32 STREAMBUFSIZE = 0X0FFFFFFF; /* If we are reading from a file in NPAsFile
656                    * mode so we can take any size stream in our
657                    * write call (since we ignore it) */
658
659 #define SARASS_SIZE (1024*1024)
660
661 int32 NPP_WriteReady( NPP instance, NPStream *stream )
662 {
663     VlcPlugin* p_plugin;
664
665     /* fprintf(stderr, "NPP_WriteReady\n"); */
666
667     if (instance != NULL)
668     {
669         p_plugin = (VlcPlugin*) instance->pdata;
670         /* Muahahahahahahaha */
671         return STREAMBUFSIZE;
672         /*return SARASS_SIZE;*/
673     }
674
675     /* Number of bytes ready to accept in NPP_Write() */
676     return STREAMBUFSIZE;
677     /*return 0;*/
678 }
679
680
681 int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
682                  int32 len, void *buffer )
683 {
684     /* fprintf(stderr, "NPP_Write %i\n", (int)len); */
685
686     if( instance != NULL )
687     {
688         /*VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;*/
689     }
690
691     return len;         /* The number of bytes accepted */
692 }
693
694
695 NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
696 {
697     if( instance == NULL )
698     {
699         return NPERR_INVALID_INSTANCE_ERROR;
700     }
701
702     return NPERR_NO_ERROR;
703 }
704
705
706 void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
707 {
708     if( instance == NULL )
709     {
710         return;
711     }
712
713     /* fprintf(stderr, "NPP_StreamAsFile %s\n", fname); */
714
715 #if USE_LIBVLC
716     VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
717
718     VLC_AddTarget( p_plugin->i_vlc, fname, 0, 0,
719                    PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
720 #endif
721 }
722
723
724 void NPP_URLNotify( NPP instance, const char* url,
725                     NPReason reason, void* notifyData )
726 {
727     /***** Insert NPP_URLNotify code here *****\
728     PluginInstance* p_plugin;
729     if (instance != NULL)
730         p_plugin = (PluginInstance*) instance->pdata;
731     \*********************************************/
732 }
733
734
735 void NPP_Print( NPP instance, NPPrint* printInfo )
736 {
737     if( printInfo == NULL )
738     {
739         return;
740     }
741
742     if( instance != NULL )
743     {
744         /***** Insert NPP_Print code here *****\
745         PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
746         \**************************************/
747
748         if( printInfo->mode == NP_FULL )
749         {
750             /*
751              * PLUGIN DEVELOPERS:
752              *  If your plugin would like to take over
753              *  printing completely when it is in full-screen mode,
754              *  set printInfo->pluginPrinted to TRUE and print your
755              *  plugin as you see fit.  If your plugin wants Netscape
756              *  to handle printing in this case, set
757              *  printInfo->pluginPrinted to FALSE (the default) and
758              *  do nothing.  If you do want to handle printing
759              *  yourself, printOne is true if the print button
760              *  (as opposed to the print menu) was clicked.
761              *  On the Macintosh, platformPrint is a THPrint; on
762              *  Windows, platformPrint is a structure
763              *  (defined in npapi.h) containing the printer name, port,
764              *  etc.
765              */
766
767             /***** Insert NPP_Print code here *****\
768             void* platformPrint =
769                 printInfo->print.fullPrint.platformPrint;
770             NPBool printOne =
771                 printInfo->print.fullPrint.printOne;
772             \**************************************/
773
774             /* Do the default*/
775             printInfo->print.fullPrint.pluginPrinted = FALSE;
776         }
777         else
778         {
779             /* If not fullscreen, we must be embedded */
780             /*
781              * PLUGIN DEVELOPERS:
782              *  If your plugin is embedded, or is full-screen
783              *  but you returned false in pluginPrinted above, NPP_Print
784              *  will be called with mode == NP_EMBED.  The NPWindow
785              *  in the printInfo gives the location and dimensions of
786              *  the embedded plugin on the printed page.  On the
787              *  Macintosh, platformPrint is the printer port; on
788              *  Windows, platformPrint is the handle to the printing
789              *  device context.
790              */
791
792             /***** Insert NPP_Print code here *****\
793             NPWindow* printWindow =
794                 &(printInfo->print.embedPrint.window);
795             void* platformPrint =
796                 printInfo->print.embedPrint.platformPrint;
797             \**************************************/
798         }
799     }
800 }
801
802 /******************************************************************************
803  * Windows-only methods
804  *****************************************************************************/
805 #if defined(XP_WIN) && !USE_LIBVLC
806 LRESULT CALLBACK Manage( HWND p_hwnd, UINT i_msg, WPARAM wpar, LPARAM lpar )
807 {
808     VlcPlugin* p_plugin = (VlcPlugin*) GetProp( p_hwnd, "w00t" );
809
810     switch( i_msg )
811     {
812         case WM_PAINT:
813         {
814             PAINTSTRUCT paintstruct;
815             HDC hdc;
816             RECT rect;
817
818             hdc = BeginPaint( p_hwnd, &paintstruct );
819
820             GetClientRect( p_hwnd, &rect );
821             FillRect( hdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH) );
822             TextOut( hdc, p_plugin->i_width / 2 - 40, p_plugin->i_height / 2,
823                      WINDOW_TEXT, strlen(WINDOW_TEXT) );
824
825             EndPaint( p_hwnd, &paintstruct );
826             break;
827         }
828         default:
829             p_plugin->pf_wndproc( p_hwnd, i_msg, wpar, lpar );
830             break;
831     }
832     return 0;
833 }
834 #endif
835
836 /******************************************************************************
837  * UNIX-only methods
838  *****************************************************************************/
839 #ifdef XP_UNIX
840 static void Redraw( Widget w, XtPointer closure, XEvent *event )
841 {
842     VlcPlugin* p_plugin = (VlcPlugin*)closure;
843     GC gc;
844     XGCValues gcv;
845
846     gcv.foreground = BlackPixel( p_plugin->p_display, 0 );
847     gc = XCreateGC( p_plugin->p_display, p_plugin->window, GCForeground, &gcv );
848
849     XFillRectangle( p_plugin->p_display, p_plugin->window, gc,
850                     0, 0, p_plugin->i_width, p_plugin->i_height );
851
852     gcv.foreground = WhitePixel( p_plugin->p_display, 0 );
853     XChangeGC( p_plugin->p_display, gc, GCForeground, &gcv );
854
855     XDrawString( p_plugin->p_display, p_plugin->window, gc,
856                  p_plugin->i_width / 2 - 40, p_plugin->i_height / 2,
857                  WINDOW_TEXT, strlen(WINDOW_TEXT) );
858
859     XFreeGC( p_plugin->p_display, gc );
860 }
861 #endif
862