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 
00040 //
00041 // Implementation of Netscape entry points (NPN_*)
00042 //
00043 #include "npplat.h"
00044 
00045 extern NPNetscapeFuncs NPNFuncs;
00046 
00047 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
00048 {
00049   *plugin_major   = NP_VERSION_MAJOR;
00050   *plugin_minor   = NP_VERSION_MINOR;
00051   *netscape_major = HIBYTE(NPNFuncs.version);
00052   *netscape_minor = LOBYTE(NPNFuncs.version);
00053 }
00054 
00055 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
00056 {
00057        int navMinorVers = NPNFuncs.version & 0xFF;
00058   NPError rv = NPERR_NO_ERROR;
00059 
00060   if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00061               rv = CallNPN_GetURLNotifyProc(NPNFuncs.geturlnotify, instance, url, target, notifyData);
00062        else
00063               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00064 
00065   return rv;
00066 }
00067 
00068 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
00069 {
00070   NPError rv = CallNPN_GetURLProc(NPNFuncs.geturl, instance, url, target);
00071   return rv;
00072 }
00073 
00074 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
00075 {
00076        int navMinorVers = NPNFuncs.version & 0xFF;
00077   NPError rv = NPERR_NO_ERROR;
00078 
00079        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00080               rv = CallNPN_PostURLNotifyProc(NPNFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);
00081        else
00082               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00083 
00084   return rv;
00085 }
00086 
00087 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
00088 {
00089   NPError rv = CallNPN_PostURLProc(NPNFuncs.posturl, instance, url, window, len, buf, file);
00090   return rv;
00091 } 
00092 
00093 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00094 {
00095   NPError rv = CallNPN_RequestReadProc(NPNFuncs.requestread, stream, rangeList);
00096   return rv;
00097 }
00098 
00099 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
00100 {
00101        int navMinorVersion = NPNFuncs.version & 0xFF;
00102 
00103   NPError rv = NPERR_NO_ERROR;
00104 
00105        if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00106               rv = CallNPN_NewStreamProc(NPNFuncs.newstream, instance, type, target, stream);
00107        else
00108               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00109 
00110   return rv;
00111 }
00112 
00113 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
00114 {
00115        int navMinorVersion = NPNFuncs.version & 0xFF;
00116   int32 rv = 0;
00117 
00118   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00119               rv = CallNPN_WriteProc(NPNFuncs.write, instance, stream, len, buffer);
00120        else
00121               rv = -1;
00122 
00123   return rv;
00124 }
00125 
00126 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00127 {
00128        int navMinorVersion = NPNFuncs.version & 0xFF;
00129   NPError rv = NPERR_NO_ERROR;
00130 
00131   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00132               rv = CallNPN_DestroyStreamProc(NPNFuncs.destroystream, instance, stream, reason);
00133        else
00134               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00135 
00136   return rv;
00137 }
00138 
00139 void NPN_Status(NPP instance, const char *message)
00140 {
00141   CallNPN_StatusProc(NPNFuncs.status, instance, message);
00142 }
00143 
00144 const char* NPN_UserAgent(NPP instance)
00145 {
00146   const char * rv = NULL;
00147   rv = CallNPN_UserAgentProc(NPNFuncs.uagent, instance);
00148   return rv;
00149 }
00150 
00151 void* NPN_MemAlloc(uint32 size)
00152 {
00153   void * rv = NULL;
00154   rv = CallNPN_MemAllocProc(NPNFuncs.memalloc, size);
00155   return rv;
00156 }
00157 
00158 void NPN_MemFree(void* ptr)
00159 {
00160   CallNPN_MemFreeProc(NPNFuncs.memfree, ptr);
00161 }
00162 
00163 uint32 NPN_MemFlush(uint32 size)
00164 {
00165   uint32 rv = CallNPN_MemFlushProc(NPNFuncs.memflush, size);
00166   return rv;
00167 }
00168 
00169 void NPN_ReloadPlugins(NPBool reloadPages)
00170 {
00171   CallNPN_ReloadPluginsProc(NPNFuncs.reloadplugins, reloadPages);
00172 }
00173 
00174 #ifdef OJI
00175 JRIEnv* NPN_GetJavaEnv(void)
00176 {
00177   JRIEnv * rv = NULL;
00178        rv = CallNPN_GetJavaEnvProc(NPNFuncs.getJavaEnv);
00179   return rv;
00180 }
00181 
00182 jref NPN_GetJavaPeer(NPP instance)
00183 {
00184   jref rv;
00185   rv = CallNPN_GetJavaPeerProc(NPNFuncs.getJavaPeer, instance);
00186   return rv;
00187 }
00188 #endif
00189 
00190 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
00191 {
00192   NPError rv = CallNPN_GetValueProc(NPNFuncs.getvalue, instance, variable, value);
00193   return rv;
00194 }
00195 
00196 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00197 {
00198   NPError rv = CallNPN_SetValueProc(NPNFuncs.setvalue, instance, variable, value);
00199   return rv;
00200 }
00201 
00202 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
00203 {
00204   CallNPN_InvalidateRectProc(NPNFuncs.invalidaterect, instance, invalidRect);
00205 }
00206 
00207 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
00208 {
00209   CallNPN_InvalidateRegionProc(NPNFuncs.invalidateregion, instance, invalidRegion);
00210 }
00211 
00212 void NPN_ForceRedraw(NPP instance)
00213 {
00214   CallNPN_ForceRedrawProc(NPNFuncs.forceredraw, instance);
00215 }