Commit d86fd156 authored by Simon Latapie's avatar Simon Latapie

* mozilla plugin on MacOSX. Not fully implemented yet.

 * compiled with mozilla 1.4 (won't probably work with <1.4)
 * TODO:
 *     - make XPCOM work (play,pause,stop buttons)
 *     - fullscreen implementation (quite difficult on MacOSX because only
 *       the main thread can create windows)
parent 10afbf83
B/* Localized versions of Info.plist keys */
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>Vlc Plugin</string>
<key>CFBundleIdentifier</key>
<string>com.netscape.vlc</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>NSPL</string>
<key>CFBundleSignature</key>
<string>MOSS</string>
<key>CFBundleVersion</key>
<string>0.12</string>
<key>CSResourcesFileMapped</key>
<true/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PBXProjectSourcePath</key>
<string>/Users/garf/cavapasmerder/VlcPlugin.pbproj</string>
</dict>
</plist>
......@@ -2,7 +2,7 @@
* vout.h: MacOS X interface plugin
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: vout.h,v 1.11 2003/05/01 01:11:17 hartman Exp $
* $Id: vout.h,v 1.12 2003/08/14 12:38:03 garf Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -81,10 +81,15 @@ struct vout_sys_t
#ifdef __QUICKTIME__
CodecType i_codec;
CGrafPtr p_qdport;
CGrafPtr p_qdportold;
ImageSequence i_seq;
MatrixRecordPtr p_matrix;
DecompressorComponent img_dc;
ImageDescriptionHandle h_img_descr;
Ptr p_fullscreen_state;
RgnHandle mask;
int portx;
int porty;
int isplugin;
#endif
};
/*****************************************************************************
* vout.m: MacOS X video output plugin
/* vout.m: MacOS X video output plugin
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
* $Id: vout.m,v 1.50 2003/06/03 23:17:43 massiot Exp $
* $Id: vout.m,v 1.51 2003/08/14 12:38:03 garf Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Florian G. Pflug <fgp@phlo.org>
......@@ -51,6 +51,7 @@ struct picture_sys_t
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int vout_Init ( vout_thread_t * );
static void vout_End ( vout_thread_t * );
static int vout_Manage ( vout_thread_t * );
......@@ -79,6 +80,9 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
vout_thread_t * p_vout = (vout_thread_t *)p_this;
OSErr err;
int i_timeout;
vlc_value_t value_drawable;
var_Get( p_vout->p_vlc, "drawable", &value_drawable );
p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
if( p_vout->p_sys == NULL )
......@@ -89,41 +93,46 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );
/* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
for( i_timeout = 20 ; i_timeout-- ; )
/* We don't need an intf in mozilla plugin */
if( value_drawable.i_int == 0 )
{
if( NSApp == NULL )
/* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */
for( i_timeout = 20 ; i_timeout-- ; )
{
msleep( INTF_IDLE_SLEEP );
}
}
if( NSApp == NULL )
{
/* no MacOS X intf, unable to communicate with MT */
msg_Err( p_vout, "no MacOS X interface present" );
free( p_vout->p_sys );
return( 1 );
}
if( [NSApp respondsToSelector: @selector(getIntf)] )
{
intf_thread_t * p_intf;
for( i_timeout = 10 ; i_timeout-- ; )
{
if( ( p_intf = [NSApp getIntf] ) == NULL )
if( NSApp == NULL )
{
msleep( INTF_IDLE_SLEEP );
}
}
if( p_intf == NULL )
if( NSApp == NULL )
{
msg_Err( p_vout, "MacOS X intf has getIntf, but is NULL" );
/* no MacOS X intf, unable to communicate with MT */
msg_Err( p_vout, "no MacOS X interface present" );
free( p_vout->p_sys );
return( 1 );
}
if( [NSApp respondsToSelector: @selector(getIntf)] )
{
intf_thread_t * p_intf;
for( i_timeout = 10 ; i_timeout-- ; )
{
if( ( p_intf = [NSApp getIntf] ) == NULL )
{
msleep( INTF_IDLE_SLEEP );
}
}
if( p_intf == NULL )
{
msg_Err( p_vout, "MacOS X intf has getIntf, but is NULL" );
free( p_vout->p_sys );
return( 1 );
}
}
}
p_vout->p_sys->h_img_descr =
......@@ -135,6 +144,17 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
p_vout->p_sys->b_mouse_moved = YES;
p_vout->p_sys->i_time_mouse_last_moved = mdate();
if( value_drawable.i_int != 0 )
{
p_vout->p_sys->mask = NewRgn();
p_vout->p_sys->isplugin = 1 ;
} else
{
p_vout->p_sys->mask = NULL;
p_vout->p_sys->isplugin = 0 ;
}
/* set window size */
p_vout->p_sys->s_rect.size.width = p_vout->i_window_width;
p_vout->p_sys->s_rect.size.height = p_vout->i_window_height;
......@@ -219,13 +239,17 @@ int E_(OpenVideo) ( vlc_object_t *p_this )
}
[o_pool release];
if( CoCreateWindow( p_vout ) )
/* We don't need a window either in the mozilla plugin */
if( p_vout->p_sys->isplugin == 0 )
{
msg_Err( p_vout, "unable to create window" );
free( p_vout->p_sys->p_matrix );
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
free( p_vout->p_sys );
return( 1 );
if( CoCreateWindow( p_vout ) )
{
msg_Err( p_vout, "unable to create window" );
free( p_vout->p_sys->p_matrix );
DisposeHandle( (Handle)p_vout->p_sys->h_img_descr );
free( p_vout->p_sys );
return( 1 );
}
}
p_vout->pf_init = vout_Init;
......@@ -244,6 +268,7 @@ static int vout_Init( vout_thread_t *p_vout )
{
int i_index;
picture_t *p_pic;
vlc_value_t val;
I_OUTPUTPICTURES = 0;
......@@ -254,6 +279,13 @@ static int vout_Init( vout_thread_t *p_vout )
p_vout->output.i_height = p_vout->render.i_height;
p_vout->output.i_aspect = p_vout->render.i_aspect;
var_Get( p_vout->p_vlc, "drawable", &val );
if( p_vout->p_sys->isplugin )
{
p_vout->p_sys->p_qdport = val.i_int;
}
SetPort( p_vout->p_sys->p_qdport );
QTScaleMatrix( p_vout );
......@@ -317,11 +349,14 @@ static void vout_End( vout_thread_t *p_vout )
*****************************************************************************/
void E_(CloseVideo) ( vlc_object_t *p_this )
{
vout_thread_t * p_vout = (vout_thread_t *)p_this;
vout_thread_t * p_vout = (vout_thread_t *)p_this;
if( CoDestroyWindow( p_vout ) )
if ( p_vout->p_sys->isplugin == 0)
{
msg_Err( p_vout, "unable to destroy window" );
if( CoDestroyWindow( p_vout ) )
{
msg_Err( p_vout, "unable to destroy window" );
}
}
if ( p_vout->p_sys->p_fullscreen_state != NULL )
......@@ -343,6 +378,9 @@ void E_(CloseVideo) ( vlc_object_t *p_this )
*****************************************************************************/
static int vout_Manage( vout_thread_t *p_vout )
{
vlc_value_t val1;
var_Get( p_vout->p_vlc, "drawableredraw", &val1 );
if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE )
{
if( CoToggleFullscreen( p_vout ) )
......@@ -353,13 +391,21 @@ static int vout_Manage( vout_thread_t *p_vout )
p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;
}
if( p_vout->i_changes & VOUT_SIZE_CHANGE )
if( (p_vout->i_changes & VOUT_SIZE_CHANGE) || (val1.i_int == 1))
{
if (val1.i_int == 1)
{
val1.i_int = 0;
var_Set( p_vout->p_vlc, "drawableredraw", val1 );
SetDSequenceMask( p_vout->p_sys->i_seq , p_vout->p_sys->mask );
} else if (p_vout->i_changes & VOUT_SIZE_CHANGE)
{
p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
}
QTScaleMatrix( p_vout );
SetDSequenceMatrix( p_vout->p_sys->i_seq,
p_vout->p_sys->p_matrix );
p_vout->i_changes &= ~VOUT_SIZE_CHANGE;
}
/* hide/show mouse cursor
......@@ -421,17 +467,45 @@ static void vout_Display( vout_thread_t *p_vout, picture_t *p_pic )
OSErr err;
CodecFlags flags;
if( ( err = DecompressSequenceFrameS(
p_vout->p_sys->i_seq,
p_pic->p_sys->p_info,
p_pic->p_sys->i_size,
codecFlagUseImageBuffer, &flags, nil ) != noErr ) )
if( p_vout->p_sys->isplugin )
{
msg_Warn( p_vout, "DecompressSequenceFrameS failed: %d", err );
/* In mozilla plugin, mozilla browser also draws things in
* the windows. So we have to update the port/Origin for each
* picture. FIXME : the vout should lock something ! */
GetPort( &p_vout->p_sys->p_qdportold );
SetPort( p_vout->p_sys->p_qdport );
SetOrigin( p_vout->p_sys->portx , p_vout->p_sys->porty );
if( ( err = DecompressSequenceFrameS(
p_vout->p_sys->i_seq,
p_pic->p_sys->p_info,
p_pic->p_sys->i_size,
codecFlagUseImageBuffer, &flags, nil ) != noErr ) )
{
msg_Warn( p_vout, "DecompressSequenceFrameS failed: %d", err );
}
else
{
QDFlushPortBuffer( p_vout->p_sys->p_qdport, nil );
}
SetPort( p_vout->p_sys->p_qdportold );
}
else
{
QDFlushPortBuffer( p_vout->p_sys->p_qdport, nil );
{
if( ( err = DecompressSequenceFrameS(
p_vout->p_sys->i_seq,
p_pic->p_sys->p_info,
p_pic->p_sys->i_size,
codecFlagUseImageBuffer, &flags, nil ) != noErr ) )
{
msg_Warn( p_vout, "DecompressSequenceFrameS failed: %d", err );
}
else
{
QDFlushPortBuffer( p_vout->p_sys->p_qdport, nil );
}
}
}
......@@ -518,9 +592,6 @@ static int CoToggleFullscreen( vout_thread_t *p_vout )
return( 1 );
}
SetPort( p_vout->p_sys->p_qdport );
QTScaleMatrix( p_vout );
if( QTCreateSequence( p_vout ) )
{
msg_Err( p_vout, "unable to create sequence" );
......@@ -572,12 +643,45 @@ static void QTScaleMatrix( vout_thread_t *p_vout )
Fixed factor_x, factor_y;
unsigned int i_offset_x = 0;
unsigned int i_offset_y = 0;
vlc_value_t val;
vlc_value_t valt;
vlc_value_t vall;
vlc_value_t valb;
vlc_value_t valr;
vlc_value_t valx;
vlc_value_t valy;
vlc_value_t valw;
vlc_value_t valh;
vlc_value_t valportx;
vlc_value_t valporty;
GetPortBounds( p_vout->p_sys->p_qdport, &s_rect );
i_width = s_rect.right - s_rect.left;
i_height = s_rect.bottom - s_rect.top;
var_Get( p_vout->p_vlc, "drawable", &val );
var_Get( p_vout->p_vlc, "drawablet", &valt );
var_Get( p_vout->p_vlc, "drawablel", &vall );
var_Get( p_vout->p_vlc, "drawableb", &valb );
var_Get( p_vout->p_vlc, "drawabler", &valr );
var_Get( p_vout->p_vlc, "drawablex", &valx );
var_Get( p_vout->p_vlc, "drawabley", &valy );
var_Get( p_vout->p_vlc, "drawablew", &valw );
var_Get( p_vout->p_vlc, "drawableh", &valh );
var_Get( p_vout->p_vlc, "drawableportx", &valportx );
var_Get( p_vout->p_vlc, "drawableporty", &valporty );
if( p_vout->p_sys->isplugin )
{
p_vout->p_sys->portx = valportx.i_int;
p_vout->p_sys->porty = valporty.i_int;
p_vout->p_sys->p_qdport = val.i_int;
i_width = valw.i_int;
i_height = valh.i_int;
SetRectRgn( p_vout->p_sys->mask , 0 , 0 , valr.i_int - vall.i_int , valb.i_int - valt.i_int );
}
if( i_height * p_vout->output.i_aspect < i_width * VOUT_ASPECT_FACTOR )
{
int i_adj_width = i_height * p_vout->output.i_aspect /
......@@ -588,7 +692,7 @@ static void QTScaleMatrix( vout_thread_t *p_vout )
factor_y = FixDiv( Long2Fix( i_height ),
Long2Fix( p_vout->output.i_height ) );
i_offset_x = (i_width - i_adj_width) / 2;
i_offset_x = (i_width - i_adj_width) / 2 + i_offset_x;
}
else
{
......@@ -600,7 +704,7 @@ static void QTScaleMatrix( vout_thread_t *p_vout )
factor_y = FixDiv( Long2Fix( i_adj_height ),
Long2Fix( p_vout->output.i_height ) );
i_offset_y = (i_height - i_adj_height) / 2;
i_offset_y = (i_height - i_adj_height) / 2 + i_offset_y;
}
SetIdentityMatrix( p_vout->p_sys->p_matrix );
......@@ -612,6 +716,7 @@ static void QTScaleMatrix( vout_thread_t *p_vout )
TranslateMatrix( p_vout->p_sys->p_matrix,
Long2Fix(i_offset_x),
Long2Fix(i_offset_y) );
}
/*****************************************************************************
......@@ -642,8 +747,10 @@ static int QTCreateSequence( vout_thread_t *p_vout )
p_descr->dataSize = 0;
p_descr->depth = 24;
HUnlock( (Handle)p_vout->p_sys->h_img_descr );
if( ( err = DecompressSequenceBeginS(
&p_vout->p_sys->i_seq,
p_vout->p_sys->h_img_descr,
......@@ -651,7 +758,7 @@ static int QTCreateSequence( vout_thread_t *p_vout )
p_vout->p_sys->p_qdport,
NULL, NULL,
p_vout->p_sys->p_matrix,
0, NULL,
0, p_vout->p_sys->mask,
codecFlagUseImageBuffer,
codecLosslessQuality,
p_vout->p_sys->img_dc ) ) )
......@@ -660,6 +767,7 @@ static int QTCreateSequence( vout_thread_t *p_vout )
return( 1 );
}
return( 0 );
}
......@@ -810,7 +918,7 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
newsize.width = (int) ( p_vout->render.i_width * factor );
newsize.height = (int) ( i_corrected_height * factor );
}
[self setContentSize: newsize];
[self setFrameTopLeftPoint: topleftscreen];
......@@ -1309,12 +1417,14 @@ static void QTFreePicture( vout_thread_t *p_vout, picture_t *p_pic )
}
o_view = [[VLCView alloc] init];
/* FIXME: [o_view setMenu:] */
[p_vout->p_sys->o_window setContentView: o_view];
[o_view autorelease];
[o_view lockFocus];
p_vout->p_sys->p_qdport = [o_view qdPort];
[o_view unlockFocus];
[p_vout->p_sys->o_window updateTitle];
......
......@@ -29,8 +29,13 @@ SOURCES_win32 = support/npwin.cpp
CPPFLAGS_mozilla_EXTRA = -DXP_WIN -DXP_WIN32
else
if HAVE_DARWIN
# We don't define LIBRARIES_mozilla because we'll be using project builder
SOURCES_macosx = support/npmac.cpp
# We don't define LIBRARIES_mozilla because we'll be using project builder, or not...
BUNDLE_mozilla = VLC\ Plugin.plugin
vlc_moz_FLAGS = `$(VLC_CONFIG) --libs vlc builtin pic mozilla`
moz_CFLAGS = `$(MOZILLA_CONFIG) --cflags plugin java nspr/obsolete nspr oji xpcom xpconnect`
moz_plugin_FLAGS = -c -F/System/Library/Frameworks/CoreFoundation.framework $(moz_CFLAGS) -I/Developer/Headers/FlatCarbon -arch ppc -fno-common -fpascal-strings -O0 -Wmost -Wno-four-char-constants -Wno-unknown-pragmas -DXP_MACOSX=1 -DNO_X11=1 -DUSE_SYSTEM_CONSOLE=1 -pipe -fmessage-length=0 -g -include mozilla-config.h
else
LIBRARIES_mozilla = libvlcplugin$(LIBEXT)
SOURCES_unix = support/npunix.c
......@@ -52,7 +57,7 @@ libplugin_a_DEPENDENCIES = $(DATA_npvlc_rc)
BUILT_SOURCES_mozilla = vlcintf.h
$(SOURCES_mozilla): vlcintf.h
plugin_DATA = $(LIBRARIES_mozilla)
plugin_DATA = $(LIBRARIES_mozilla) $(BUNDLE_mozilla)
plugindir = $(libdir)/mozilla/plugins
$(LIBRARIES_mozilla): $(libplugin_a_OBJECTS) \
$(libplugin_a_DEPENDENCIES) stamp-pic
......@@ -75,14 +80,29 @@ DATA_npvlc_rc = $(noinst_npvlc_rc_DATA)
noinst_npvlc_rc_DATA = npvlc_rc.$(OBJEXT)
noinst_npvlc_rcdir = $(libdir)
npvlc_rc.$(OBJEXT): npvlc_rc.rc
$(WINDRES) --include-dir $(srcdir)/mozilla -i $< -o $@
$(WINDRES) --include-dir $(srcdir) -i $< -o $@
endif
if HAVE_DARWIN
VLC\ Plugin.plugin:
rm -rf $(srcdir)/VLC\ Plugin.plugin
mkdir -p $(srcdir)/VLC\ Plugin.plugin/Contents/MacOS
mkdir -p $(srcdir)/VLC\ Plugin.plugin/Contents/Resources
/usr/bin/g++3 $(moz_plugin_FLAGS) $(srcdir)/vlcplugin.cpp -o $(srcdir)/libplugin_a-vlcplugin.o
/usr/bin/g++3 $(moz_plugin_FLAGS) $(srcdir)/vlcshell.cpp -o $(srcdir)/libplugin_a-vlcshell.o
/usr/bin/g++3 $(moz_plugin_FLAGS) $(srcdir)/vlcpeer.cpp -o $(srcdir)/libplugin_a-vlcpeer.o
/usr/bin/g++3 $(moz_plugin_FLAGS) $(srcdir)/support/npmac.cpp -o $(srcdir)/libplugin_a-npmac.o
/usr/bin/g++3 $(srcdir)/libplugin_a-vlcplugin.o $(srcdir)/libplugin_a-vlcshell.o $(srcdir)/libplugin_a-vlcpeer.o $(srcdir)/libplugin_a-npmac.o -o $(srcdir)/VLC\ Plugin.plugin/Contents/MacOS/VLC\ Plugin -L/usr/lib -F/System/Library/Frameworks/CoreFoundation.framework -framework CoreFoundation -arch ppc -bundle -read_only_relocs suppress $(top_srcdir)/lib/libvlc_pic.a -dylib $(vlc_moz_FLAGS)
cp $(top_srcdir)/extras/MacOSX/plugin/Info.plist $(srcdir)/VLC\ Plugin.plugin/Contents/Info.plist
cp $(top_srcdir)/extras/MacOSX/plugin/pbdevelopment.plist $(srcdir)/VLC\ Plugin.plugin/Contents/pbdevelopment.plist
cp -r $(top_srcdir)/extras/MacOSX/plugin/English.lproj $(srcdir)/VLC\ Plugin.plugin/Contents/Resources/
Rez /Developer/Headers/FlatCarbon/Types.r $(srcdir)/vlc.r -o $(srcdir)/VLC\ Plugin.plugin/Contents/Resources/Vlc\ Plugin.rsrc
endif
endif
###############################################################################
# Stamp rules
###############################################################################
clean: clean-stamp
clean: clean-stamp clean-bundle
clean-stamp:
rm -f stamp-pic
......@@ -95,6 +115,9 @@ stamp-pic: FORCE
done
@if test ! -f $@; then printf "" > $@; fi
clean-bundle:
rm -rf $(srcdir)/VLC\ Plugin.plugin
###############################################################################
# Force rule
###############################################################################
......
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// npmac.cpp
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#include <string.h>
#include <Processes.h>
#include <Gestalt.h>
#include <CodeFragments.h>
......@@ -48,26 +14,23 @@
#include <ToolUtils.h>
#define XP_MAC 1
#define NDEBUG 1
//
// A4Stuff.h contains the definition of EnterCodeResource and
// EnterCodeResource, used for setting up the code resources
// EnterCodeResource, used for setting up the code resources
// globals for 68K (analagous to the function SetCurrentA5
// defined by the toolbox).
//
// A4Stuff does not exist as of CW 7. Define them to nothing.
//
#if defined(XP_MACOSX) || (defined(__MWERKS__) && (__MWERKS__ >= 0x2400))
#if (defined(__MWERKS__) && (__MWERKS__ >= 0x2400)) || defined(__GNUC__)
#define EnterCodeResource()
#define ExitCodeResource()
#else
#include <A4Stuff.h>
#endif
#include "nscore.h"
#include "jri.h"
#include "npapi.h"
//
......@@ -94,7 +57,7 @@
#endif
#endif
// The following fix for static initializers (which fixes a preious
// The following fix for static initializers (which fixes a previous
// incompatibility with some parts of PowerPlant, was submitted by
// Jan Ulbrich.
#ifdef __MWERKS__
......@@ -117,7 +80,7 @@
// Define PLUGIN_TRACE to 1 to have the wrapper functions emit
// DebugStr messages whenever they are called.
//
#define PLUGIN_TRACE 0
//#define PLUGIN_TRACE 1
#if PLUGIN_TRACE
#define PLUGINDEBUGSTR(msg) ::DebugStr(msg)
......@@ -126,9 +89,92 @@
#endif
#ifdef XP_MACOSX
// glue for mapping outgoing Macho function pointers to TVectors
struct TFPtoTVGlue{
void* glue[2];
};
struct {
TFPtoTVGlue newp;
TFPtoTVGlue destroy;
TFPtoTVGlue setwindow;
TFPtoTVGlue newstream;
TFPtoTVGlue destroystream;
TFPtoTVGlue asfile;
TFPtoTVGlue writeready;
TFPtoTVGlue write;
TFPtoTVGlue print;
TFPtoTVGlue event;
TFPtoTVGlue urlnotify;
TFPtoTVGlue getvalue;
TFPtoTVGlue setvalue;
TFPtoTVGlue shutdown;
} gPluginFuncsGlueTable;
static inline void* SetupFPtoTVGlue(TFPtoTVGlue* functionGlue, void* fp)
{
functionGlue->glue[0] = fp;
functionGlue->glue[1] = 0;
return functionGlue;
}
#define PLUGIN_TO_HOST_GLUE(name, fp) (SetupFPtoTVGlue(&gPluginFuncsGlueTable.name, (void*)fp))
// glue for mapping netscape TVectors to Macho function pointers
struct TTVtoFPGlue {
uint32 glue[6];
};
struct {
TTVtoFPGlue geturl;
TTVtoFPGlue posturl;
TTVtoFPGlue requestread;
TTVtoFPGlue newstream;
TTVtoFPGlue write;
TTVtoFPGlue destroystream;
TTVtoFPGlue status;
TTVtoFPGlue uagent;
TTVtoFPGlue memalloc;
TTVtoFPGlue memfree;
TTVtoFPGlue memflush;
TTVtoFPGlue reloadplugins;
TTVtoFPGlue getJavaEnv;
TTVtoFPGlue getJavaPeer;
TTVtoFPGlue geturlnotify;
TTVtoFPGlue posturlnotify;
TTVtoFPGlue getvalue;
TTVtoFPGlue setvalue;
TTVtoFPGlue invalidaterect;
TTVtoFPGlue invalidateregion;
TTVtoFPGlue forceredraw;
} gNetscapeFuncsGlueTable;
static void* SetupTVtoFPGlue(TTVtoFPGlue* functionGlue, void* tvp)
{
static const TTVtoFPGlue glueTemplate = { 0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420 };
memcpy(functionGlue, &glueTemplate, sizeof(TTVtoFPGlue));
functionGlue->glue[0] |= ((UInt32)tvp >> 16);
functionGlue->glue[1] |= ((UInt32)tvp & 0xFFFF);
::MakeDataExecutable(functionGlue, sizeof(TTVtoFPGlue));
return functionGlue;
}
#define HOST_TO_PLUGIN_GLUE(name, fp) (SetupTVtoFPGlue(&gNetscapeFuncsGlueTable.name, (void*)fp))
#else
#define PLUGIN_TO_HOST_GLUE(name, fp) (fp)
#define HOST_TO_PLUGIN_GLUE(name, fp) (fp)
#endif /* XP_MACOSX */
#pragma mark -
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
......@@ -136,13 +182,12 @@
//
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#if !OPAQUE_TOOLBOX_STRUCTS || !TARGET_API_MAC_CARBON
QDGlobals* gQDPtr; // Pointer to Netscapes QuickDraw globals
#if !TARGET_API_MAC_CARBON
QDGlobals* gQDPtr; // Pointer to Netscapes QuickDraw globals
#endif
short gResFile; // Refnum of the plugins resource file
short gResFile; // Refnum of the plugins resource file
NPNetscapeFuncs gNetscapeFuncs; // Function table for procs in Netscape called by plugin
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//
// Wrapper functions for all calls from the plugin to Netscape.
......@@ -267,24 +312,14 @@ const char* NPN_UserAgent(NPP instance)
return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
}
#define DEBUG_MEMORY 0