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 #include "npapi.h"
00039 #include "npupp.h"
00040 #include "dbg.h"
00041 
00042 extern NPNetscapeFuncs NPNFuncs;
00043 
00044 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
00045 {
00046   dbgOut1("wrapper: NPN_Version");
00047 
00048   *plugin_major   = NP_VERSION_MAJOR;
00049   *plugin_minor   = NP_VERSION_MINOR;
00050   *netscape_major = HIBYTE(NPNFuncs.version);
00051   *netscape_minor = LOBYTE(NPNFuncs.version);
00052 }
00053 
00054 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
00055 {
00056   dbgOut1("wrapper: NPN_GetURLNotify");
00057 
00058        int navMinorVers = NPNFuncs.version & 0xFF;
00059        
00060   NPError rv = NPERR_NO_ERROR;
00061 
00062   if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00063               rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
00064        else
00065               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00066 
00067   return rv;
00068 }
00069 
00070 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
00071 {
00072   dbgOut1("wrapper: NPN_GetURL");
00073 
00074   NPError rv = NPNFuncs.geturl(instance, url, target);
00075   return rv;
00076 }
00077 
00078 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
00079 {
00080   dbgOut1("wrapper: NPN_PostURLNotify");
00081 
00082        int navMinorVers = NPNFuncs.version & 0xFF;
00083 
00084   NPError rv = NPERR_NO_ERROR;
00085 
00086        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00087               rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
00088        else
00089               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00090 
00091   return rv;
00092 }
00093 
00094 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
00095 {
00096   dbgOut1("wrapper: NPN_PostURL");
00097 
00098   NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
00099   return rv;
00100 } 
00101 
00102 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00103 {
00104   dbgOut1("wrapper: NPN_RequestRead");
00105 
00106   NPError rv = NPNFuncs.requestread(stream, rangeList);
00107   return rv;
00108 }
00109 
00110 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
00111 {
00112   dbgOut1("wrapper: NPN_NewStream");
00113 
00114        int navMinorVersion = NPNFuncs.version & 0xFF;
00115 
00116   NPError rv = NPERR_NO_ERROR;
00117 
00118        if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00119               rv = NPNFuncs.newstream(instance, type, target, stream);
00120        else
00121               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00122 
00123   return rv;
00124 }
00125 
00126 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
00127 {
00128   dbgOut1("wrapper: NPN_Write");
00129 
00130        int navMinorVersion = NPNFuncs.version & 0xFF;
00131 
00132   int32 rv = 0;
00133 
00134   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00135               rv = NPNFuncs.write(instance, stream, len, buffer);
00136        else
00137               rv = -1;
00138 
00139   return rv;
00140 }
00141 
00142 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00143 {
00144   dbgOut1("wrapper: NPN_DestroyStream");
00145 
00146        int navMinorVersion = NPNFuncs.version & 0xFF;
00147 
00148   NPError rv = NPERR_NO_ERROR;
00149 
00150   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00151               rv = NPNFuncs.destroystream(instance, stream, reason);
00152        else
00153               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00154 
00155   return rv;
00156 }
00157 
00158 void NPN_Status(NPP instance, const char *message)
00159 {
00160   dbgOut1("wrapper: NPN_Status");
00161 
00162   NPNFuncs.status(instance, message);
00163 }
00164 
00165 const char* NPN_UserAgent(NPP instance)
00166 {
00167   dbgOut1("wrapper: NPN_UserAgent");
00168 
00169   const char * rv = NULL;
00170   rv = NPNFuncs.uagent(instance);
00171   return rv;
00172 }
00173 
00174 void* NPN_MemAlloc(uint32 size)
00175 {
00176   //bgOut1("wrapper: NPN_MemAlloc");
00177 
00178   void * rv = NULL;
00179   rv = NPNFuncs.memalloc(size);
00180   return rv;
00181 }
00182 
00183 void NPN_MemFree(void* ptr)
00184 {
00185   //dbgOut1("wrapper: NPN_MemFree");
00186 
00187   NPNFuncs.memfree(ptr);
00188 }
00189 
00190 uint32 NPN_MemFlush(uint32 size)
00191 {
00192   dbgOut1("wrapper: NPN_MemFlush");
00193 
00194   uint32 rv = NPNFuncs.memflush(size);
00195   return rv;
00196 }
00197 
00198 void NPN_ReloadPlugins(NPBool reloadPages)
00199 {
00200   dbgOut1("wrapper: NPN_ReloadPlugins");
00201 
00202   NPNFuncs.reloadplugins(reloadPages);
00203 }
00204 
00205 JRIEnv* NPN_GetJavaEnv(void)
00206 {
00207   dbgOut1("wrapper: NPN_GetJavaEnv");
00208 
00209   JRIEnv * rv = NULL;
00210        rv = NPNFuncs.getJavaEnv();
00211   return rv;
00212 }
00213 
00214 jref NPN_GetJavaPeer(NPP instance)
00215 {
00216   dbgOut1("wrapper: NPN_GetJavaPeer");
00217 
00218   jref rv;
00219        rv = NPNFuncs.getJavaPeer(instance);
00220   return rv;
00221 }
00222 
00223 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
00224 {
00225   dbgOut1("wrapper: NPN_GetValue");
00226 
00227   NPError rv = NPERR_NO_ERROR;
00228   rv = NPNFuncs.getvalue(instance, variable, value);
00229   return rv;
00230 }
00231 
00232 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00233 {
00234   dbgOut1("wrapper: NPN_SetValue");
00235 
00236   NPError rv = NPERR_NO_ERROR;
00237   rv = NPNFuncs.setvalue(instance, variable, value);
00238   return rv;
00239 }
00240 
00241 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
00242 {
00243   dbgOut1("wrapper: NPN_InvalidateRect");
00244 
00245   NPNFuncs.invalidaterect(instance, invalidRect);
00246 }
00247 
00248 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
00249 {
00250   dbgOut1("wrapper: NPN_InvalidateRegion");
00251 
00252   NPNFuncs.invalidateregion(instance, invalidRegion);
00253 }
00254 
00255 void NPN_ForceRedraw(NPP instance)
00256 {
00257   dbgOut1("wrapper: ForceRedraw");
00258 
00259   NPNFuncs.forceredraw(instance);
00260 }