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 "xp.h"
00039 
00040 #include "npapi.h"
00041 #include "npupp.h"
00042 
00043 #include "logger.h"
00044 
00045 extern Logger * logger;
00046 extern NPNetscapeFuncs NPNFuncs;
00047 
00048 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
00049 {
00050   if(logger)
00051     logger->logCall(action_npn_version, (DWORD)plugin_major, (DWORD)plugin_minor, (DWORD)netscape_major, (DWORD)netscape_minor);
00052 
00053   *plugin_major   = NP_VERSION_MAJOR;
00054   *plugin_minor   = NP_VERSION_MINOR;
00055   *netscape_major = HIBYTE(NPNFuncs.version);
00056   *netscape_minor = LOBYTE(NPNFuncs.version);
00057 
00058   if(logger)
00059     logger->logReturn();
00060 }
00061 
00062 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
00063 {
00064        int navMinorVers = NPNFuncs.version & 0xFF;
00065        
00066   NPError rv = NPERR_NO_ERROR;
00067 
00068   if(logger)
00069     logger->logCall(action_npn_get_url_notify, (DWORD)instance, (DWORD)url, (DWORD)target, (DWORD)notifyData);
00070 
00071   if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00072               rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
00073        else
00074               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00075 
00076   if(logger)
00077     logger->logReturn();
00078 
00079   return rv;
00080 }
00081 
00082 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
00083 {
00084   if(logger)
00085     logger->logCall(action_npn_get_url, (DWORD)instance, (DWORD)url, (DWORD)target);
00086 
00087   NPError rv = NPNFuncs.geturl(instance, url, target);
00088 
00089   if(logger)
00090     logger->logReturn();
00091 
00092   return rv;
00093 }
00094 
00095 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
00096 {
00097        int navMinorVers = NPNFuncs.version & 0xFF;
00098 
00099   NPError rv = NPERR_NO_ERROR;
00100 
00101   if(logger)
00102     logger->logCall(action_npn_post_url_notify, (DWORD)instance, (DWORD)url, (DWORD)window, (DWORD)len, (DWORD)buf, (DWORD)file, (DWORD)notifyData);
00103 
00104        if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
00105               rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
00106        else
00107               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00108 
00109   if(logger)
00110     logger->logReturn();
00111 
00112   return rv;
00113 }
00114 
00115 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
00116 {
00117   if(logger)
00118     logger->logCall(action_npn_post_url, (DWORD)instance, (DWORD)url, (DWORD)window, (DWORD)len, (DWORD)buf, (DWORD)file);
00119 
00120   NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
00121 
00122   if(logger)
00123     logger->logReturn();
00124 
00125   return rv;
00126 } 
00127 
00128 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
00129 {
00130   if(logger)
00131     logger->logCall(action_npn_request_read, (DWORD)stream, (DWORD)rangeList);
00132 
00133   NPError rv = NPNFuncs.requestread(stream, rangeList);
00134 
00135   if(logger)
00136     logger->logReturn();
00137 
00138   return rv;
00139 }
00140 
00141 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
00142 {
00143        int navMinorVersion = NPNFuncs.version & 0xFF;
00144 
00145   NPError rv = NPERR_NO_ERROR;
00146 
00147   if(logger)
00148     logger->logCall(action_npn_new_stream, (DWORD)instance, (DWORD)type, (DWORD)target, (DWORD)stream);
00149 
00150        if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00151               rv = NPNFuncs.newstream(instance, type, target, stream);
00152        else
00153               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00154 
00155   if(logger)
00156     logger->logReturn();
00157 
00158   return rv;
00159 }
00160 
00161 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
00162 {
00163        int navMinorVersion = NPNFuncs.version & 0xFF;
00164 
00165   int32 rv = 0;
00166 
00167   if(logger)
00168     logger->logCall(action_npn_write, (DWORD)instance, (DWORD)stream, (DWORD)len, (DWORD)buffer);
00169 
00170   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00171               rv = NPNFuncs.write(instance, stream, len, buffer);
00172        else
00173               rv = -1;
00174 
00175   if(logger)
00176     logger->logReturn();
00177 
00178   return rv;
00179 }
00180 
00181 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
00182 {
00183        int navMinorVersion = NPNFuncs.version & 0xFF;
00184 
00185   NPError rv = NPERR_NO_ERROR;
00186 
00187   if(logger)
00188     logger->logCall(action_npn_destroy_stream, (DWORD)instance, (DWORD)stream, (DWORD)reason);
00189 
00190   if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
00191               rv = NPNFuncs.destroystream(instance, stream, reason);
00192        else
00193               rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
00194 
00195   if(logger)
00196     logger->logReturn();
00197 
00198   return rv;
00199 }
00200 
00201 void NPN_Status(NPP instance, const char *message)
00202 {
00203   if(logger)
00204     logger->logCall(action_npn_status, (DWORD)instance, (DWORD)message);
00205 
00206   NPNFuncs.status(instance, message);
00207 }
00208 
00209 const char* NPN_UserAgent(NPP instance)
00210 {
00211   const char * rv = NULL;
00212 
00213   if(logger)
00214     logger->logCall(action_npn_user_agent, (DWORD)instance);
00215 
00216   rv = NPNFuncs.uagent(instance);
00217 
00218   if(logger)
00219     logger->logReturn();
00220 
00221   return rv;
00222 }
00223 
00224 void* NPN_MemAlloc(uint32 size)
00225 {
00226   void * rv = NULL;
00227   
00228   if(logger)
00229     logger->logCall(action_npn_mem_alloc, (DWORD)size);
00230 
00231   rv = NPNFuncs.memalloc(size);
00232 
00233   if(logger)
00234     logger->logReturn();
00235 
00236   return rv;
00237 }
00238 
00239 void NPN_MemFree(void* ptr)
00240 {
00241   if(logger)
00242     logger->logCall(action_npn_mem_free, (DWORD)ptr);
00243 
00244   NPNFuncs.memfree(ptr);
00245 }
00246 
00247 uint32 NPN_MemFlush(uint32 size)
00248 {
00249   if(logger)
00250     logger->logCall(action_npn_mem_flush, (DWORD)size);
00251 
00252   uint32 rv = NPNFuncs.memflush(size);
00253 
00254   if(logger)
00255     logger->logReturn();
00256 
00257   return rv;
00258 }
00259 
00260 void NPN_ReloadPlugins(NPBool reloadPages)
00261 {
00262   if(logger)
00263     logger->logCall(action_npn_reload_plugins, (DWORD)reloadPages);
00264 
00265   NPNFuncs.reloadplugins(reloadPages);
00266 }
00267 
00268 JRIEnv* NPN_GetJavaEnv(void)
00269 {
00270   JRIEnv * rv = NULL;
00271 
00272   if(logger)
00273     logger->logCall(action_npn_get_java_env);
00274 
00275        rv = NPNFuncs.getJavaEnv();
00276 
00277   if(logger)
00278     logger->logReturn();
00279 
00280   return rv;
00281 }
00282 
00283 jref NPN_GetJavaPeer(NPP instance)
00284 {
00285   jref rv;
00286 
00287   if(logger)
00288     logger->logCall(action_npn_get_java_peer, (DWORD)instance);
00289 
00290        rv = NPNFuncs.getJavaPeer(instance);
00291 
00292   if(logger)
00293     logger->logReturn();
00294 
00295   return rv;
00296 }
00297 
00298 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
00299 {
00300   NPError rv = NPERR_NO_ERROR;
00301 
00302   if(logger)
00303     logger->logCall(action_npn_get_value, (DWORD)instance, (DWORD)variable, (DWORD)value);
00304 
00305   rv = NPNFuncs.getvalue(instance, variable, value);
00306 
00307   if(logger)
00308     logger->logReturn(action_npn_get_value);
00309 
00310   return rv;
00311 }
00312 
00313 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
00314 {
00315   NPError rv = NPERR_NO_ERROR;
00316 
00317   if(logger)
00318     logger->logCall(action_npn_set_value, (DWORD)instance, (DWORD)variable, (DWORD)value);
00319 
00320   rv = NPNFuncs.setvalue(instance, variable, value);
00321 
00322   if(logger)
00323     logger->logReturn();
00324 
00325   return rv;
00326 }
00327 
00328 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
00329 {
00330   if(logger)
00331     logger->logCall(action_npn_invalidate_rect, (DWORD)instance, (DWORD)invalidRect);
00332 
00333   NPNFuncs.invalidaterect(instance, invalidRect);
00334 }
00335 
00336 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
00337 {
00338   if(logger)
00339     logger->logCall(action_npn_invalidate_region, (DWORD)instance, (DWORD)invalidRegion);
00340 
00341   NPNFuncs.invalidateregion(instance, invalidRegion);
00342 }
00343 
00344 void NPN_ForceRedraw(NPP instance)
00345 {
00346   if(logger)
00347     logger->logCall(action_npn_force_redraw, (DWORD)instance);
00348 
00349   NPNFuncs.forceredraw(instance);
00350 }