Back to index

lightning-sunbird  0.9+nobinonly
npn_gate.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either the GNU General Public License Version 2 or later (the "GPL"), or
00026  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 //
00039 // The Mixed Mode procInfos defined in npupp.h assume Think C-
00040 // style calling conventions.  These conventions are used by
00041 // Metrowerks with the exception of pointer return types, which
00042 // in Metrowerks 68K are returned in A0, instead of the standard
00043 // D0. Thus, since NPN_MemAlloc and NPN_UserAgent return pointers,
00044 // Mixed Mode will return the values to a 68K plugin in D0, but 
00045 // a 68K plugin compiled by Metrowerks will expect the result in
00046 // A0.  The following pragma forces Metrowerks to use D0 instead.
00047 //
00048 #ifdef __MWERKS__
00049 #ifndef powerc
00050 #pragma pointers_in_D0
00051 #endif
00052 #endif
00053 
00054 #ifdef __MWERKS__
00055 #ifndef powerc
00056 #pragma pointers_in_A0
00057 #endif
00058 #endif
00059 
00060 
00062 //
00063 // Implementation of Netscape entry points (NPN_*)
00064 //
00065 #include "xp.h"
00066 
00067 extern NPNetscapeFuncs NPNFuncs;
00068 
00069 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
00070 {
00071   *plugin_major   = NP_VERSION_MAJOR;
00072   *plugin_minor   = NP_VERSION_MINOR;
00073   *netscape_major = HIBYTE(NPNFuncs.version);
00074   *netscape_minor = LOBYTE(NPNFuncs.version);
00075 }
00076 
00077 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
00078 {
00079        int navMinorVers = NPNFuncs.version & 0xFF;
00080   NPError rv = NPERR_NO_ERROR;
00081 
00082   if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00083               rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
00084        else
00085               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00086 
00087   return rv;
00088 }
00089 
00090 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
00091 {
00092   NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
00093   return rv;
00094 }
00095 
00096 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
00097 {
00098        int navMinorVers = NPNFuncs.version & 0xFF;
00099   NPError rv = NPERR_NO_ERROR;
00100 
00101        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00102               rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
00103        else
00104               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00105 
00106   return rv;
00107 }
00108 
00109 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
00110 {
00111   NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
00112   return rv;
00113 } 
00114 
00115 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00116 {
00117   NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
00118   return rv;
00119 }
00120 
00121 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
00122 {
00123        int navMinorVersion = NPNFuncs.version & 0xFF;
00124 
00125   NPError rv = NPERR_NO_ERROR;
00126 
00127        if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00128               rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
00129        else
00130               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00131 
00132   return rv;
00133 }
00134 
00135 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
00136 {
00137        int navMinorVersion = NPNFuncs.version & 0xFF;
00138   int32 rv = 0;
00139 
00140   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00141               rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
00142        else
00143               rv = -1;
00144 
00145   return rv;
00146 }
00147 
00148 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00149 {
00150        int navMinorVersion = NPNFuncs.version & 0xFF;
00151   NPError rv = NPERR_NO_ERROR;
00152 
00153   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00154               rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
00155        else
00156               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00157 
00158   return rv;
00159 }
00160 
00161 void NPN_Status(NPP instance, const char *message)
00162 {
00163   CallNPN_StatusProc(NPNFuncs.status, instance, message);
00164 }
00165 
00166 const char* NPN_UserAgent(NPP instance)
00167 {
00168   const char * rv = NULL;
00169   rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
00170   return rv;
00171 }
00172 
00173 void* NPN_MemAlloc(uint32 size)
00174 {
00175   void * rv = NULL;
00176   rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
00177   return rv;
00178 }
00179 
00180 void NPN_MemFree(void* ptr)
00181 {
00182   CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
00183 }
00184 
00185 uint32 NPN_MemFlush(uint32 size)
00186 {
00187   uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
00188   return rv;
00189 }
00190 
00191 void NPN_ReloadPlugins(NPBool reloadPages)
00192 {
00193   CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
00194 }
00195 
00196 JRIEnv* NPN_GetJavaEnv(void)
00197 {
00198   JRIEnv * rv = NULL;
00199        rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
00200   return rv;
00201 }
00202 
00203 jref NPN_GetJavaPeer(NPP instance)
00204 {
00205   jref rv;
00206   rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
00207   return rv;
00208 }
00209 
00210 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
00211 {
00212   NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
00213   return rv;
00214 }
00215 
00216 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00217 {
00218   NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
00219   return rv;
00220 }
00221 
00222 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
00223 {
00224   CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
00225 }
00226 
00227 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
00228 {
00229   CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
00230 }
00231 
00232 void NPN_ForceRedraw(NPP instance)
00233 {
00234   CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
00235 }