not part of the build yet, unix plugin sdk
git-svn-id: svn://10.0.0.236/trunk@129492 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = npSDKbasic
|
||||
|
||||
REQUIRES = java \
|
||||
idl \
|
||||
xpcom \
|
||||
nspr \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = plugin.cpp
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libplugingate_s.$(LIB_SUFFIX) \
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
EXTRA_DSO_LDOPTS += -L/usr/lib -L/usr/X11R6/lib -rdynamic -lXi -lXext -lX11 -lm -lXt
|
||||
|
||||
INSTALL_PLUGIN = $(CONFIG_TOOLS)/nsinstall -R
|
||||
INSTALL = true
|
||||
|
||||
ifeq ($(OS_ARCH), UNIX)
|
||||
# This needs to get defined for npapi.h on unix platforms.
|
||||
DEFINES += -DXP_UNIX
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../../include -I$(srcdir)/../../../include
|
||||
|
||||
install-plugin: $(SHARED_LIBRARY)
|
||||
ifdef SHARED_LIBRARY
|
||||
$(INSTALL_PLUGIN) $(SHARED_LIBRARY) $(DIST)/bin/plugins
|
||||
endif
|
||||
|
||||
libs:: install-plugin
|
||||
@@ -1,50 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# 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 Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
# This makefile contains some of our defines for the compiler:
|
||||
#
|
||||
# XP_UNIX This needs to get defined for npapi.h on unix platforms.
|
||||
|
||||
PLUGIN_DEFINES = -DXP_UNIX -I../../../include -I../../include -I../include
|
||||
CCC = gcc
|
||||
OPTIMIZER = -g
|
||||
CFLAGS = $(OPTIMIZER) $(PLUGIN_DEFINES) -I. -I/usr/include
|
||||
|
||||
CPPSRCS = ../../common/npn_gate.cpp \
|
||||
../../common/npp_gate.cpp \
|
||||
../../common/np_entry.cpp \
|
||||
plugin.cpp
|
||||
|
||||
OBJS = $(strip $(CPPSRCS:.cpp=.o))
|
||||
|
||||
%.o: %.cpp makefile
|
||||
$(CCC) -o $@ -c $(CFLAGS) $<
|
||||
|
||||
SHAREDTARGET=npbasic.so
|
||||
|
||||
default all: $(SHAREDTARGET)
|
||||
|
||||
$(SHAREDTARGET): $(OBJS)
|
||||
$(CC) -shared -o $(SHAREDTARGET) $(OBJS) $(LDFLAGS)
|
||||
|
||||
clean:
|
||||
$(RM) $(OBJS) $(SHAREDTARGET)
|
||||
|
||||
@@ -39,11 +39,12 @@
|
||||
|
||||
#define MIME_TYPES_HANDLED "application/basic-plugin"
|
||||
#define PLUGIN_NAME "Basic Example Plugin for Mozilla"
|
||||
#define PLUGIN_DESCRIPTION "Basic Example Plugin for Mozilla"
|
||||
#define PLUGIN_DESCRIPTION MIME_TYPES_HANDLED":bsc:"PLUGIN_NAME
|
||||
|
||||
|
||||
char* NPP_GetMIMEDescription(void)
|
||||
{
|
||||
return(MIME_TYPES_HANDLED);
|
||||
return(PLUGIN_DESCRIPTION);
|
||||
}
|
||||
|
||||
/////////////////////////////////////
|
||||
@@ -83,8 +84,10 @@ void NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
|
||||
//
|
||||
nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
|
||||
mInstance(aInstance),
|
||||
mInitialized(FALSE),
|
||||
mWindow(0),
|
||||
mInitialized(FALSE)
|
||||
mXtwidget(0),
|
||||
mFontInfo(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -113,7 +116,11 @@ void nsPluginInstance::draw()
|
||||
unsigned int w = 3 * mWidth/4;
|
||||
int x = (mWidth - w)/2; // center
|
||||
int y = h/2;
|
||||
XDrawRectangle(mDisplay, mWindow, mGC, x, y, w, h);
|
||||
if (x >= 0 && y >= 0) {
|
||||
GC gc = XCreateGC(mDisplay, mWindow, 0, NULL);
|
||||
if (!gc)
|
||||
return;
|
||||
XDrawRectangle(mDisplay, mWindow, gc, x, y, w, h);
|
||||
const char *string = getVersion();
|
||||
if (string && *string) {
|
||||
int l = strlen(string);
|
||||
@@ -122,42 +129,21 @@ void nsPluginInstance::draw()
|
||||
int fh = fmba + fmbd;
|
||||
y += fh;
|
||||
x += 32;
|
||||
XDrawString(mDisplay, mWindow, mGC, x, y, string, l);
|
||||
XDrawString(mDisplay, mWindow, gc, x, y, string, l);
|
||||
}
|
||||
XFreeGC(mDisplay, gc);
|
||||
}
|
||||
}
|
||||
|
||||
NPBool nsPluginInstance::init(NPWindow* aWindow)
|
||||
{
|
||||
|
||||
if(aWindow == NULL)
|
||||
return FALSE;
|
||||
|
||||
NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct *)aWindow->ws_info;
|
||||
mWindow = (Window) aWindow->window;
|
||||
mX = aWindow->x;
|
||||
mY = aWindow->y;
|
||||
mWidth = aWindow->width;
|
||||
mHeight = aWindow->height;
|
||||
mDisplay = ws_info->display;
|
||||
mVisual = ws_info->visual;
|
||||
mDepth = ws_info->depth;
|
||||
mColormap = ws_info->colormap;
|
||||
mFontInfo = XLoadQueryFont(mDisplay, "9x15");
|
||||
if (!mFontInfo) {
|
||||
printf("Cannot open 9X15 font\n");
|
||||
return FALSE;
|
||||
}
|
||||
mGC = XCreateGC(mDisplay, mWindow, 0, NULL);
|
||||
|
||||
// add xt event handler
|
||||
Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
|
||||
if (xtwidget) {
|
||||
long event_mask = ExposureMask;
|
||||
XSelectInput(mDisplay, mWindow, event_mask);
|
||||
XtAddEventHandler(xtwidget, event_mask, False, (XtEventHandler)xt_event_handler, this);
|
||||
}
|
||||
if (SetWindow(aWindow))
|
||||
mInitialized = TRUE;
|
||||
return TRUE;
|
||||
|
||||
return mInitialized;
|
||||
}
|
||||
|
||||
void nsPluginInstance::shut()
|
||||
@@ -185,3 +171,41 @@ NPError nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
NPError nsPluginInstance::SetWindow(NPWindow* aWindow)
|
||||
{
|
||||
if(aWindow == NULL)
|
||||
return FALSE;
|
||||
|
||||
mX = aWindow->x;
|
||||
mY = aWindow->y;
|
||||
mWidth = aWindow->width;
|
||||
mHeight = aWindow->height;
|
||||
if (mWindow == (Window) aWindow->window) {
|
||||
// The page with the plugin is being resized.
|
||||
// Save any UI information because the next time
|
||||
// around expect a SetWindow with a new window id.
|
||||
} else {
|
||||
mWindow = (Window) aWindow->window;
|
||||
NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct *)aWindow->ws_info;
|
||||
mDisplay = ws_info->display;
|
||||
mVisual = ws_info->visual;
|
||||
mDepth = ws_info->depth;
|
||||
mColormap = ws_info->colormap;
|
||||
|
||||
if (!mFontInfo) {
|
||||
if (!(mFontInfo = XLoadQueryFont(mDisplay, "9x15")))
|
||||
printf("Cannot open 9X15 font\n");
|
||||
}
|
||||
// add xt event handler
|
||||
Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
|
||||
if (xtwidget && mXtwidget != xtwidget) {
|
||||
mXtwidget = xtwidget;
|
||||
long event_mask = ExposureMask;
|
||||
XSelectInput(mDisplay, mWindow, event_mask);
|
||||
XtAddEventHandler(xtwidget, event_mask, False, (XtEventHandler)xt_event_handler, this);
|
||||
}
|
||||
}
|
||||
draw();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -49,12 +49,13 @@ class nsPluginInstance : public nsPluginInstanceBase
|
||||
{
|
||||
public:
|
||||
nsPluginInstance(NPP aInstance);
|
||||
~nsPluginInstance();
|
||||
virtual ~nsPluginInstance();
|
||||
|
||||
NPBool init(NPWindow* aWindow);
|
||||
void shut();
|
||||
NPBool isInitialized() {return mInitialized;}
|
||||
NPError GetValue(NPPVariable variable, void *value);
|
||||
NPError SetWindow(NPWindow* aWindow);
|
||||
|
||||
// locals
|
||||
const char * getVersion();
|
||||
@@ -66,6 +67,7 @@ private:
|
||||
|
||||
Window mWindow;
|
||||
Display *mDisplay;
|
||||
Widget mXtwidget;
|
||||
int mX, mY;
|
||||
int mWidth, mHeight;
|
||||
Visual* mVisual;
|
||||
|
||||
Reference in New Issue
Block a user