Back to index

lightning-sunbird  0.9+nobinonly
plugbase.h
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 /*************************************************************/
00039 /*                                                           */
00040 /* GUI independent part of a plugin. Base class for platform */
00041 /* specific implementations                                  */
00042 /*                                                           */
00043 /*************************************************************/
00044 
00045 #ifndef __PLUGINBASE_H__
00046 #define __PLUGINBASE_H__
00047 
00048 #include "xp.h"
00049 #include "action.h"
00050 
00051 // Prefernces profile stuff
00052 #define NPAPI_INI_FILE_NAME   "npapi.ini"
00053 
00054 #define DEFAULT_DWARG_VALUE   0xDDDDDDDD
00055 
00056 class CPluginBase
00057 {
00058 private:
00059   NPP m_pNPInstance;
00060   WORD m_wMode;
00061   NPStream * m_pStream;
00062   NPStream * m_pScriptStream;
00063   char m_szScriptCacheFile[_MAX_PATH];
00064 
00065   // a flag to indicate that incoming stream is a special script stream
00066   // and needs to be treated as such. All other streams just fall through
00067   BOOL m_bWaitingForScriptStream;
00068 
00069 public:
00070   void * m_pNPNAlloced; // used by NPN_MemFree/Alloc in manual mode
00071   void * m_pValue;      // used by NPN_Get/SetValue stuff
00072   NPAPI_Action m_firstAction; // = action_invalid;
00073 
00074 public:
00075   CPluginBase(NPP pNPInstance, WORD wMode);
00076   ~CPluginBase();
00077 
00078   // pure virtuals to be implemented in platform specific context
00079   virtual BOOL initEmbed(DWORD dwInitData) = 0;
00080   virtual void shutEmbed() = 0;
00081   virtual BOOL isInitialized() = 0; // initialized
00082   virtual void getModulePath(LPSTR szPath, int iSize) = 0;
00083   virtual int messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle) = 0;
00084   virtual BOOL isStandAlone() = 0; // is our GUI is in a separate native window
00085   virtual BOOL initStandAlone() = 0; // create separate native window
00086   virtual void shutStandAlone() = 0; // destroy separate native window
00087   virtual void outputToNativeWindow(LPSTR szString) = 0; // used to output log in StandAlone mode
00088 
00089   // virtuals just in case
00090   virtual BOOL initFull(DWORD dwInitData);
00091   virtual void shutFull();
00092   virtual BOOL init(DWORD dwInitData);
00093   virtual void shut();
00094   virtual void getLogFileName(LPSTR szLogFileName, int iSize);
00095   virtual void autoStartScriptIfNeeded();
00096 
00097   const NPP getNPInstance();
00098   const WORD getMode();
00099   const NPStream * getNPStream();
00100 
00101   // special NPP_* call handlers
00102   void onNPP_NewStream(NPP pInstance, LPSTR szMIMEType, NPStream * pStream, NPBool bSeekable, uint16 * puType);
00103   void onNPP_StreamAsFile(NPP pInstance, NPStream * pStream, const char * szFileName);
00104   void onNPP_DestroyStream(NPStream * pStream);
00105  
00106   // made it virtual just in case some GUI reflection needed
00107   virtual DWORD makeNPNCall(NPAPI_Action = action_invalid, 
00108                             DWORD dw1 = 0L, DWORD dw2 = 0L, 
00109                             DWORD dw3 = 0L, DWORD dw4 = 0L, 
00110                             DWORD dw5 = 0L, DWORD dw6 = 0L, 
00111                             DWORD dw7 = 0L);
00112 };
00113 
00114 // creation and destruction of the object of the derived class
00115 CPluginBase * CreatePlugin(NPP instance, uint16 mode);
00116 void DestroyPlugin(CPluginBase * pPlugin);
00117 
00118 #endif // __PLUGINBASE_H__