Annotation of abimoz/plugin/npp_gate.cpp, revision 1.1

1.1     ! mikep       1: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
        !             2: /*
        !             3:  *  ***** BEGIN LICENSE BLOCK *****
        !             4:  * Version: GPL 2.0
        !             5:  *
        !             6:  * The contents of this file are subject to the GNU General Public License 
        !             7:  * Version 2.0 (the "License"); you may not use this file except in 
        !             8:  * compliance with the License. You may obtain a copy of the License at
        !             9:  * http://www.fsf.org/licenses/gpl.txt
        !            10:  * 
        !            11:  * This program is distributed in the hope that it will be useful,
        !            12:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
        !            13:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        !            14:  * GNU General Public License for more details.
        !            15:  * 
        !            16:  * You should have received a copy of the GNU General Public License
        !            17:  * along with this program; if not, write to the Free Software
        !            18:  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
        !            19:  * 
        !            20:  * The Original Code is OEone Penzilla Code.
        !            21:  * 
        !            22:  * The Initial Developer of the Original Code is
        !            23:  * OEone Corporation.
        !            24:  * Portions created by the Initial Developer are Copyright (C) 1999-2002
        !            25:  * the Initial Developer. All Rights Reserved.
        !            26:  * Some portions are based on xine code.
        !            27:  * 
        !            28:  * Contributor(s): 
        !            29:  * 
        !            30:  * 
        !            31:  * ***** END LICENSE BLOCK *****
        !            32:  */
        !            33: 
        !            34: 
        !            35: ////////////////////////////////////////////////////////////
        !            36: //
        !            37: // Implementation of plugin entry points (NPP_*)
        !            38: // most are just empty stubs for this particular plugin 
        !            39: //
        !            40: #include "nsWPPlugin.h"
        !            41: 
        !            42: char* NPP_GetMIMEDescription(void)
        !            43: {
        !            44:     return ("application/msword:.doc:Microsoft Word Documents");
        !            45: }
        !            46:     
        !            47: NPError NPP_Initialize(void)
        !            48: {
        !            49:     return NPERR_NO_ERROR;
        !            50: }
        !            51: 
        !            52: void NPP_Shutdown(void)
        !            53: {
        !            54: }
        !            55: 
        !            56: NPError NPP_New(NPMIMEType pluginType,
        !            57:                 NPP instance,
        !            58:                 uint16 mode,
        !            59:                 int16 argc,
        !            60:                 char* argn[],
        !            61:                 char* argv[],
        !            62:                 NPSavedData* saved)
        !            63: {   
        !            64:   if(instance == NULL)
        !            65:     return NPERR_INVALID_INSTANCE_ERROR;
        !            66: 
        !            67:   NPError rv = NPERR_NO_ERROR;
        !            68: 
        !            69:   nsWPPluginInstance * pPlugin = new nsWPPluginInstance(instance);
        !            70:   if(pPlugin == NULL)
        !            71:     return NPERR_OUT_OF_MEMORY_ERROR;
        !            72: 
        !            73:   instance->pdata = (void *)pPlugin;
        !            74:   return rv;
        !            75: }
        !            76: 
        !            77: // here is the place to clean up and destroy the CPlugin object
        !            78: NPError NPP_Destroy (NPP instance, NPSavedData** save)
        !            79: {
        !            80:   if(instance == NULL)
        !            81:     return NPERR_INVALID_INSTANCE_ERROR;
        !            82: 
        !            83:   NPError rv = NPERR_NO_ERROR;
        !            84: 
        !            85:   nsWPPluginInstance * pPlugin = (nsWPPluginInstance *)instance->pdata;
        !            86:   if(pPlugin != NULL) {
        !            87:     pPlugin->ShutDown();
        !            88:     delete pPlugin;
        !            89:   }
        !            90:   return rv;
        !            91: }
        !            92: 
        !            93: // during this call we know when the plugin window is ready or
        !            94: // is about to be destroyed so we can do some gui specific
        !            95: // initialization and shutdown
        !            96: NPError NPP_SetWindow (NPP instance, NPWindow* pNPWindow)
        !            97: {    
        !            98:   if(instance == NULL)
        !            99:     return NPERR_INVALID_INSTANCE_ERROR;
        !           100: 
        !           101:   NPError rv = NPERR_NO_ERROR;
        !           102: 
        !           103:   if(pNPWindow == NULL)
        !           104:     return NPERR_GENERIC_ERROR;
        !           105: 
        !           106:   nsWPPluginInstance * pPlugin = (nsWPPluginInstance *)instance->pdata;
        !           107: 
        !           108:   if(pPlugin == NULL) 
        !           109:     return NPERR_GENERIC_ERROR;
        !           110: 
        !           111:   // window just created
        !           112:   if( !pPlugin->isInitialized() && (pNPWindow->window != NULL)) { 
        !           113:     if(!pPlugin->SetWindow(pNPWindow)) {
        !           114:       delete pPlugin;
        !           115:       pPlugin = NULL;
        !           116:       return NPERR_MODULE_LOAD_FAILED_ERROR;
        !           117:     }
        !           118:   }
        !           119: 
        !           120:   // window goes away
        !           121:   if((pNPWindow->window == NULL) && pPlugin->isInitialized())
        !           122:     return NPERR_NO_ERROR;
        !           123:   
        !           124:   // window resized
        !           125:   if(pPlugin->isInitialized() && (pNPWindow->window != NULL))
        !           126:   {
        !           127:       pPlugin->SetWindow(pNPWindow);
        !           128:       return NPERR_NO_ERROR;
        !           129:   }
        !           130:     
        !           131:   // this should not happen, nothing to do
        !           132:   if((pNPWindow->window == NULL) && !pPlugin->isInitialized())
        !           133:     return NPERR_NO_ERROR;
        !           134: 
        !           135:   return rv;
        !           136: }
        !           137: 
        !           138: // ==============================
        !           139: // ! Scriptability related code !
        !           140: // ==============================
        !           141: //
        !           142: // here the plugin is asked by Mozilla to tell if it is scriptable
        !           143: // we should return a valid interface id and a pointer to 
        !           144: // nsScriptablePeer interface which we should have implemented
        !           145: // and which should be defined in the corressponding *.xpt file
        !           146: // in the bin/components folder
        !           147: NPError    NPP_GetValue(NPP instance, NPPVariable variable, void *value)
        !           148: {
        !           149:   if(instance == NULL)
        !           150:     return NPERR_INVALID_INSTANCE_ERROR;
        !           151: 
        !           152:   NPError rv = NPERR_NO_ERROR;
        !           153: 
        !           154:   if(instance == NULL)
        !           155:     return NPERR_GENERIC_ERROR;
        !           156: 
        !           157:   nsWPPluginInstance * pPlugin = (nsWPPluginInstance *)instance->pdata;
        !           158:   if(pPlugin == NULL)
        !           159:     return NPERR_GENERIC_ERROR;
        !           160: 
        !           161:   if (variable == NPPVpluginScriptableInstance) {
        !           162:     // addref happens in getter, so we don't addref here
        !           163:     nsIWPPluginInstance* scriptablePeer = pPlugin->getScriptablePeer();
        !           164:     if (scriptablePeer) {
        !           165:       *(nsISupports **)value = scriptablePeer;
        !           166:     } else {
        !           167:       rv = NPERR_OUT_OF_MEMORY_ERROR;
        !           168:     }
        !           169:   }
        !           170:   else if (variable == NPPVpluginScriptableIID) {
        !           171:     static nsIID scriptableIID = NS_IWPPLUGININSTANCE_IID;
        !           172:     nsIID* ptr = (nsIID *)NPN_MemAlloc(sizeof(nsIID));
        !           173:     if (ptr) {
        !           174:         *ptr = scriptableIID;
        !           175:         *(nsIID **)value = ptr;
        !           176:     } else {
        !           177:       rv = NPERR_OUT_OF_MEMORY_ERROR;
        !           178:     }
        !           179:   }
        !           180: 
        !           181:   return rv;
        !           182: }
        !           183: 
        !           184: NPError NPP_NewStream(NPP instance,
        !           185:                       NPMIMEType type,
        !           186:                       NPStream* stream, 
        !           187:                       NPBool seekable,
        !           188:                       uint16* stype)
        !           189: {
        !           190:   if(instance == NULL)
        !           191:     return NPERR_INVALID_INSTANCE_ERROR;
        !           192: 
        !           193:   NPError rv = NPERR_NO_ERROR;
        !           194:   return rv;
        !           195: }
        !           196: 
        !           197: int32 NPP_WriteReady (NPP instance, NPStream *stream)
        !           198: {
        !           199:   if(instance == NULL)
        !           200:     return NPERR_INVALID_INSTANCE_ERROR;
        !           201: 
        !           202:   int32 rv = 0x0fffffff;
        !           203:   return rv;
        !           204: }
        !           205: 
        !           206: int32 NPP_Write (NPP instance, NPStream *stream, int32 offset, int32 len, void *buffer)
        !           207: {   
        !           208:   if(instance == NULL)
        !           209:     return NPERR_INVALID_INSTANCE_ERROR;
        !           210: 
        !           211:   int32 rv = len;
        !           212:   return rv;
        !           213: }
        !           214: 
        !           215: NPError NPP_DestroyStream (NPP instance, NPStream *stream, NPError reason)
        !           216: {
        !           217:   if(instance == NULL)
        !           218:     return NPERR_INVALID_INSTANCE_ERROR;
        !           219: 
        !           220:   NPError rv = NPERR_NO_ERROR;
        !           221:   return rv;
        !           222: }
        !           223: 
        !           224: void NPP_StreamAsFile (NPP instance, NPStream* stream, const char* fname)
        !           225: {
        !           226:   if(instance == NULL)
        !           227:     return;
        !           228: }
        !           229: 
        !           230: void NPP_Print (NPP instance, NPPrint* printInfo)
        !           231: {
        !           232:   if(instance == NULL)
        !           233:     return;
        !           234: }
        !           235: 
        !           236: void NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData)
        !           237: {
        !           238:   if(instance == NULL)
        !           239:     return;
        !           240: }
        !           241: 
        !           242: NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
        !           243: {
        !           244:   if(instance == NULL)
        !           245:     return NPERR_INVALID_INSTANCE_ERROR;
        !           246: 
        !           247:   NPError rv = NPERR_NO_ERROR;
        !           248:   return rv;
        !           249: }
        !           250: 
        !           251: int16  NPP_HandleEvent(NPP instance, void* event)
        !           252: {
        !           253:   if(instance == NULL)
        !           254:     return 0;
        !           255: 
        !           256:   int16 rv = 0;
        !           257:   return rv;
        !           258: }
        !           259: 
        !           260: jref NPP_GetJavaClass (void)
        !           261: {
        !           262:   return NULL;
        !           263: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>