Back to index

lightning-sunbird  0.9+nobinonly
ns4xPluginInstance.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  *   Tim Copperfield <timecop@network.email.ne.jp>
00024  *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either the GNU General Public License Version 2 or later (the "GPL"), or
00028  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef ns4xPluginInstance_h__
00041 #define ns4xPluginInstance_h__
00042 
00043 #define _UINT32
00044 
00045 /* On HPUX, int32 is already defined in /usr/include/moduel.h */
00046 /* #ifndef hpux */
00047 #ifndef HPUX11
00048 #define _INT32
00049 #endif /* HPUX11 */
00050 
00051 #include "nsCOMPtr.h"
00052 #include "nsVoidArray.h"
00053 #include "nsIPlugin.h"
00054 #include "nsIPluginInstance.h"
00055 #include "nsIPluginInstancePeer.h"
00056 #include "nsIPluginTagInfo2.h"
00057 #include "nsIScriptablePlugin.h"
00058 #include "nsIPluginInstanceInternal.h"
00059 
00060 #include "npupp.h"
00061 #ifdef OJI
00062 #include "jri.h"
00063 #endif
00064 #include "prlink.h"  // for PRLibrary
00065 
00066 #if defined (MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
00067 #include <gtk/gtk.h>
00068 #elif defined (MOZ_WIDGET_XLIB)
00069 #include "xlibxtbin.h"
00070 #endif
00071 
00073 
00074 class ns4xPluginStreamListener;
00075 class nsIDOMWindow;
00076 
00077 struct nsInstanceStream
00078 {
00079     nsInstanceStream *mNext;
00080     ns4xPluginStreamListener *mPluginStreamListener;
00081 
00082     nsInstanceStream();
00083     ~nsInstanceStream();
00084 };
00085 
00086 class ns4xPluginInstance : public nsIPluginInstance,
00087                            public nsIScriptablePlugin,
00088                            public nsIPluginInstanceInternal
00089 {
00090 public:
00091 
00092     NS_DECL_ISUPPORTS
00093 
00095     // nsIPluginInstance methods
00096 
00103     NS_METHOD Initialize(nsIPluginInstancePeer* peer);
00104 
00105     NS_IMETHOD GetPeer(nsIPluginInstancePeer* *resultingPeer);
00106 
00107     NS_IMETHOD Start(void);
00108 
00109     NS_IMETHOD Stop(void);
00110 
00111     NS_IMETHOD Destroy(void);
00112 
00113     NS_IMETHOD SetWindow(nsPluginWindow* window);
00114 
00115     NS_IMETHOD NewStream(nsIPluginStreamListener** listener);
00116 
00117     NS_IMETHOD Print(nsPluginPrint* platformPrint);
00118 
00119     NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
00120 
00121     NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
00122     
00124     // nsIScriptablePlugin methods
00125 
00126     NS_IMETHOD GetScriptablePeer(void * *aScriptablePeer);
00127 
00128     NS_IMETHOD GetScriptableInterface(nsIID * *aScriptableInterface);
00129 
00131     // nsIPluginInstanceInternal methods
00132 
00133     virtual JSObject *GetJSObject(JSContext *cx);
00134 
00135     virtual nsresult GetFormValue(nsAString& aValue);
00136 
00137     virtual void PushPopupsEnabledState(PRBool aEnabled);
00138     virtual void PopPopupsEnabledState();
00139 
00140     virtual PRUint16 GetPluginAPIVersion();
00141 
00143     // ns4xPluginInstance-specific methods
00144 
00148     nsresult GetNPP(NPP * aNPP);
00149 
00153     nsresult GetCallbacks(const NPPluginFuncs ** aCallbacks);
00154 
00155     nsresult SetWindowless(PRBool aWindowless);
00156 
00157     nsresult SetTransparent(PRBool aTransparent);
00158 
00159     nsresult NewNotifyStream(nsIPluginStreamListener** listener, 
00160                              void* notifyData, 
00161                              PRBool aCallNotify,
00162                              const char * aURL);
00163 
00168     ns4xPluginInstance(NPPluginFuncs* callbacks, PRLibrary* aLibrary);
00169 
00170     // Use Release() to destroy this
00171     virtual ~ns4xPluginInstance(void);
00172 
00173     // returns the state of mStarted
00174     PRBool IsStarted(void);
00175 
00176     // cache this 4.x plugin like an XPCOM plugin
00177     nsresult SetCached(PRBool aCache) { mCached = aCache; return NS_OK; };
00178 
00179     // Non-refcounting accessor for faster access to the peer.
00180     nsIPluginInstancePeer *Peer()
00181     {
00182         return mPeer;
00183     }
00184 
00185     already_AddRefed<nsIDOMWindow> GetDOMWindow();
00186 
00187 protected:
00188 
00189     nsresult InitializePlugin(nsIPluginInstancePeer* peer);
00190 
00194     nsresult GetValueInternal(NPPVariable variable, void* value);
00195     
00199     nsCOMPtr<nsIPluginInstancePeer> mPeer;
00200 
00206     NPPluginFuncs* fCallbacks;
00207 
00208 #if defined (MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
00209 
00213    GtkWidget *mXtBin;
00214 #elif defined (MOZ_WIDGET_XLIB)
00215    xtbin *mXlibXtBin;
00216 #endif
00217 
00222     NPP_t fNPP;
00223 
00224     //these are used to store the windowless properties
00225     //which the browser will later query
00226 
00227     PRPackedBool  mWindowless;
00228     PRPackedBool  mTransparent;
00229     PRPackedBool  mStarted;
00230     PRPackedBool  mCached;
00231 
00232 public:
00233     PRLibrary* fLibrary;
00234     nsInstanceStream *mStreams;
00235 
00236     nsVoidArray mPopupStates;
00237 };
00238 
00239 #endif // ns4xPluginInstance_h__