Back to index

lightning-sunbird  0.9+nobinonly
plugin.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 #ifndef __PLUGIN_H__
00039 #define __PLUGIN_H__
00040 
00041 #include "plugbase.h"
00042 
00043 typedef enum
00044 {
00045   sg_manual = 1,
00046   sg_auto
00047 } ShowGUI;
00048 
00049 typedef enum
00050 {
00051   gp_mode = 1,
00052   gp_logfile,
00053   gp_scriptfile,
00054   gp_tofile,
00055   gp_toframe,
00056   gp_flush,
00057   gp_rememberlast,
00058   gp_standalone,
00059   gp_autostartscript
00060 }GUIPrefs;
00061 
00062 class CPlugin : public CPluginBase
00063 {
00064 // public interface
00065 public:
00066   CPlugin(NPP pNPInstance, WORD wMode);
00067   ~CPlugin();
00068 
00069   BOOL initEmbed(DWORD dwInitData);
00070   BOOL initFull(DWORD dwInitData);
00071   void shutEmbed();
00072   void shutFull();
00073   BOOL isInitialized();
00074   void getModulePath(LPSTR szPath, int iSize);
00075   int messageBox(LPSTR szMessage, LPSTR szTitle, UINT uStyle);
00076   void getLogFileName(LPSTR szLogFileName, int iSize);
00077   BOOL initStandAlone(); // create separate native window
00078   void shutStandAlone(); // destroy separate native window
00079   BOOL isStandAlone(); // is our GUI is in a separate native window
00080   void outputToNativeWindow(LPSTR szString); // used to output log in StandAlone mode
00081 
00082   void autoStartScriptIfNeeded();
00083 
00084   DWORD makeNPNCall(NPAPI_Action = action_invalid, 
00085                     DWORD dw1 = 0L, DWORD dw2 = 0L, 
00086                     DWORD dw3 = 0L, DWORD dw4 = 0L, 
00087                     DWORD dw5 = 0L, DWORD dw6 = 0L, 
00088                     DWORD dw7 = 0L);
00089 
00090   //
00091   // Windows specific methods
00092   //
00093   const HINSTANCE getInstance();
00094   const HWND getWindow();
00095   const HWND getParent();
00096 
00097   // tester interface (GUI stuff)
00098   BOOL createTester();
00099   void destroyTester();
00100   void showGUI(ShowGUI sg);
00101 
00102   // utilities
00103   void restorePreferences();
00104   void savePreferences();
00105   void updatePrefs(GUIPrefs prefs, int iValue, char * szValue = NULL);
00106 
00107   // Window message handlers
00108   void onInit(HWND hWnd, HWND hWndManual, HWND hWndAuto);
00109   void onDestroy();
00110   void onLogToFile(BOOL bLofToFile);
00111 
00112 private:
00113   HINSTANCE m_hInst;
00114   HWND m_hWnd;
00115   HWND m_hWndParent;
00116   HWND m_hWndStandAloneLogWindow;
00117   HWND m_hWndManual;
00118   HWND m_hWndAuto;
00119   BOOL m_bPluginReady;
00120 
00121 // some GUI data
00122 public:
00123   HWND m_hWndLastEditFocus;
00124   int m_iWidth;
00125   int m_iHeight;
00126 
00127 // GUI preferences
00128   ShowGUI m_Pref_ShowGUI;
00129   char m_Pref_szLogFile[256];
00130   char m_Pref_szScriptFile[256];
00131   BOOL m_Pref_bToFile;
00132   BOOL m_Pref_bToFrame;
00133   BOOL m_Pref_bFlushNow;
00134   BOOL m_Pref_bRememberLastCall;
00135   BOOL m_Pref_bStandAlone;
00136   BOOL m_Pref_bAutoStartScript;
00137 };
00138 
00139 #endif // __PLUGIN_H__