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 
00039 //
00040 // Implementation of Netscape entry points (NPN_*)
00041 //
00042 #include "npapi.h"
00043 #include "npupp.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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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   NPNFuncs.status(instance, message);
00142 }
00143 
00144 const char* NPN_UserAgent(NPP instance)
00145 {
00146   const char * rv = NULL;
00147   rv = NPNFuncs.uagent(instance);
00148   return rv;
00149 }
00150 
00151 void* NPN_MemAlloc(uint32 size)
00152 {
00153   void * rv = NULL;
00154   rv = NPNFuncs.memalloc(size);
00155   return rv;
00156 }
00157 
00158 void NPN_MemFree(void* ptr)
00159 {
00160   NPNFuncs.memfree(ptr);
00161 }
00162 
00163 uint32 NPN_MemFlush(uint32 size)
00164 {
00165   uint32 rv = NPNFuncs.memflush(size);
00166   return rv;
00167 }
00168 
00169 void NPN_ReloadPlugins(NPBool reloadPages)
00170 {
00171   NPNFuncs.reloadplugins(reloadPages);
00172 }
00173 
00174 JRIEnv* NPN_GetJavaEnv(void)
00175 {
00176   JRIEnv * rv = NULL;
00177        rv = NPNFuncs.getJavaEnv();
00178   return rv;
00179 }
00180 
00181 jref NPN_GetJavaPeer(NPP instance)
00182 {
00183   jref rv;
00184        rv = NPNFuncs.getJavaPeer(instance);
00185   return rv;
00186 }
00187 
00188 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
00189 {
00190   NPError rv = NPNFuncs.getvalue(instance, variable, value);
00191   return rv;
00192 }
00193 
00194 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00195 {
00196   NPError rv = NPNFuncs.setvalue(instance, variable, value);
00197   return rv;
00198 }
00199 
00200 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
00201 {
00202   NPNFuncs.invalidaterect(instance, invalidRect);
00203 }
00204 
00205 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
00206 {
00207   NPNFuncs.invalidateregion(instance, invalidRegion);
00208 }
00209 
00210 void NPN_ForceRedraw(NPP instance)
00211 {
00212   NPNFuncs.forceredraw(instance);
00213 }