Back to index

lightning-sunbird  0.9+nobinonly
npsimple.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  *   Pierre Phaneuf <pp@ludusdesign.com>
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 /*******************************************************************************
00040  * npsimple.cpp
00041  ******************************************************************************
00042  * Simple Sample Plugin
00043  * Copyright (c) 1996 Netscape Communications. All rights reserved.
00044  ******************************************************************************
00045  * OVERVIEW
00046  * --------
00047  * Section 1 - Includes
00048  * Section 2 - Instance Structs
00049  * Section 3 - API Plugin Implementations
00050  * Section 4 - Utility Method Implementations
00051  *******************************************************************************/
00052 
00053 /*******************************************************************************
00054  * SECTION 1 - Includes
00055  ******************************************************************************/
00056 #include <stdio.h>
00057 #include <string.h>
00058 #include "nsplugin.h"
00059 #include "nsIServiceManager.h"
00060 #include "nsISupports.h"
00061 #include "nsIFactory.h"
00062 #include "nsIGenericFactory.h"
00063 #include "nsMemory.h"
00064 #include "nsString.h"
00065 #include "simpleCID.h"
00066 
00067 #include "nsISimplePluginInstance.h"
00068 #include "nsIScriptablePlugin.h"
00069 
00070 /*------------------------------------------------------------------------------
00071  * Windows Includes
00072  *----------------------------------------------------------------------------*/
00073 #ifdef _WINDOWS /* Windows Includes */
00074 #include <windows.h>
00075 #endif /* _WINDOWS */
00076 /*------------------------------------------------------------------------------
00077  * UNIX includes
00078  *----------------------------------------------------------------------------*/
00079 #ifdef XP_UNIX
00080 #include <gdk/gdk.h>
00081 #include <gdk/gdkprivate.h>
00082 #include <gtk/gtk.h>
00083 #include <gdksuperwin.h>
00084 #include <gtkmozbox.h>
00085 #endif /* XP_UNIX */
00086 
00087 #ifdef XP_UNIX
00088 
00089 gboolean draw (GtkWidget *widget, GdkEventExpose *event, gpointer data);
00090 
00091 #endif
00092 
00093 
00094 /*******************************************************************************
00095  * SECTION 2 - Instance Structs
00096  *******************************************************************************
00097  * Instance state information about the plugin.
00098  *
00099  * PLUGIN DEVELOPERS:
00100  *     Use this struct to hold per-instance information that you'll
00101  *     need in the various functions in this file.
00102  ******************************************************************************
00103  * First comes the PlatformInstance struct, which contains platform specific
00104  * information for each instance.
00105  *****************************************************************************/
00106  
00107 /*------------------------------------------------------------------------------
00108  * Windows PlatformInstance
00109  *----------------------------------------------------------------------------*/
00110 
00111 #if defined(XP_WIN) // XXXX OS2TODO
00112 typedef struct _PlatformInstance
00113 {
00114     HWND             fhWnd;
00115     WNDPROC          fDefaultWindowProc;
00116 } PlatformInstance;
00117 
00118 /*------------------------------------------------------------------------------
00119  * UNIX PlatformInstance
00120  *----------------------------------------------------------------------------*/
00121 
00122 #elif defined(XP_UNIX)
00123 typedef struct _PlatformInstance
00124 {
00125     Window                  window;
00126     GtkWidget         *moz_box;
00127     GdkSuperWin       *superwin;
00128     GtkWidget         *label;
00129     Display *           display;
00130     uint32                  x, y;
00131     uint32                  width, height;
00132 } PlatformInstance;
00133 
00134 /*------------------------------------------------------------------------------
00135  * Macintosh PlatformInstance
00136  *----------------------------------------------------------------------------*/
00137 
00138 #elif defined(XP_MAC)
00139 typedef struct _PlatformInstance
00140 {
00141     int                     placeholder;
00142 } PlatformInstance;
00143 
00144 /*------------------------------------------------------------------------------
00145  * Stub PlatformInstance
00146  *----------------------------------------------------------------------------*/
00147 
00148 #else
00149 typedef struct _PlatformInstance
00150 {
00151     int                     placeholder;
00152 } PlatformInstance;
00153 #endif /* end Section 2 */
00154 
00155 
00156 // Define constants for easy use
00157 static NS_DEFINE_CID(kSimplePluginCID, NS_SIMPLEPLUGIN_CID);
00158 static NS_DEFINE_CID(kPluginManagerCID, NS_PLUGINMANAGER_CID);
00159 
00160 #define PLUGIN_MIME_TYPE "application/x-simple"
00161 
00162 static const char kPluginName[] = "Simple Sample Plug-in";
00163 static const char kPluginDescription[] = "Demonstrates a simple plug-in.";
00164 
00165 static const char* kMimeTypes[] = {
00166     PLUGIN_MIME_TYPE
00167 };
00168 
00169 static const char* kMimeDescriptions[] = {
00170     "Simple Sample Plug-in"
00171 };
00172 
00173 static const char* kFileExtensions[] = {
00174     "smp"
00175 };
00176 
00177 static const PRInt32 kNumMimeTypes = sizeof(kMimeTypes) / sizeof(*kMimeTypes);
00178 
00179 
00180 
00182 // Simple Plugin Classes
00184 
00186 // SimplePluginInstance represents an instance of the simple plugin class.
00187 
00188 class SimplePluginInstance : 
00189     public nsIPluginInstance, 
00190     public nsIScriptablePlugin,
00191     public nsISimplePluginInstance {
00192 
00193 public:
00195     // for implementing a generic module
00196     static NS_METHOD
00197     Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
00198 
00199     static NS_METHOD
00200     RegisterSelf(nsIComponentManager* aCompMgr,
00201                  nsIFile* aPath,
00202                  const char* aRegistryLocation,
00203                  const char* aComponentType,
00204                  const nsModuleComponentInfo *info);
00205 
00206     static NS_METHOD
00207     UnregisterSelf(nsIComponentManager* aCompMgr,
00208                    nsIFile* aPath,
00209                    const char* aRegistryLocation,
00210                    const nsModuleComponentInfo *info);
00211 
00212 
00213     NS_DECL_ISUPPORTS
00214     NS_DECL_NSISCRIPTABLEPLUGIN
00215     NS_DECL_NSISIMPLEPLUGININSTANCE
00216 
00218     // from nsIEventHandler:
00219 
00220     // (Corresponds to NPP_HandleEvent.)
00221     // Note that for Unix and Mac the nsPluginEvent structure is different
00222     // from the old NPEvent structure -- it's no longer the native event
00223     // record, but is instead a struct. This was done for future extensibility,
00224     // and so that the Mac could receive the window argument too. For Windows
00225     // and OS2, it's always been a struct, so there's no change for them.
00226     NS_IMETHOD
00227     HandleEvent(nsPluginEvent* event, PRBool* handled);
00228 
00230     // from nsIPluginInstance:
00231 
00232     NS_IMETHOD
00233     Initialize(nsIPluginInstancePeer* peer);
00234 
00235     // Required backpointer to the peer.
00236     NS_IMETHOD
00237     GetPeer(nsIPluginInstancePeer* *result);
00238 
00239     // See comment for nsIPlugin::CreateInstance, above.
00240     NS_IMETHOD
00241     Start(void);
00242 
00243     // The old NPP_Destroy call has been factored into two plugin instance 
00244     // methods:
00245     //
00246     // Stop -- called when the plugin instance is to be stopped (e.g. by 
00247     // displaying another plugin manager window, causing the page containing 
00248     // the plugin to become removed from the display).
00249     //
00250     // Destroy -- called once, before the plugin instance peer is to be 
00251     // destroyed. This method is used to destroy the plugin instance. 
00252 
00253     NS_IMETHOD
00254     Stop(void);
00255 
00256     NS_IMETHOD
00257     Destroy(void);
00258 
00259     // (Corresponds to NPP_SetWindow.)
00260     NS_IMETHOD
00261     SetWindow(nsPluginWindow* window);
00262 
00263     NS_IMETHOD
00264     NewStream(nsIPluginStreamListener** listener);
00265 
00266     // (Corresponds to NPP_Print.)
00267     NS_IMETHOD
00268     Print(nsPluginPrint* platformPrint);
00269 
00270     NS_IMETHOD
00271     GetValue(nsPluginInstanceVariable variable, void *value);
00272 
00273 
00275     // SimplePluginInstance specific methods:
00276 
00277     SimplePluginInstance(void);
00278     virtual ~SimplePluginInstance(void);
00279 
00280     void            PlatformNew(void);
00281     nsresult        PlatformDestroy(void);
00282     nsresult         PlatformSetWindow(nsPluginWindow* window);
00283     PRInt16         PlatformHandleEvent(nsPluginEvent* event);
00284 
00285     void SetMode(nsPluginMode mode) { fMode = mode; }
00286 
00287 #ifdef XP_UNIX
00288     NS_IMETHOD Repaint(void);
00289 #endif
00290 
00291 #ifdef XP_WIN
00292     static LRESULT CALLBACK 
00293     PluginWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
00294 #endif
00295 
00296     char*                       fText;
00297 
00298 protected:
00299     nsIPluginInstancePeer*      fPeer;
00300     nsPluginWindow*             fWindow;
00301     nsPluginMode                fMode;
00302     PlatformInstance            fPlatform;
00303 };
00304 
00306 // SimplePluginStream represents the stream used by SimplePluginInstances
00307 // to receive data from the browser. 
00308 
00309 class SimplePluginStreamListener : public nsIPluginStreamListener {
00310 public:
00311 
00312     NS_DECL_ISUPPORTS
00313 
00315     // from nsIPluginStreamListener:
00316 
00324     NS_IMETHOD
00325     OnStartBinding(nsIPluginStreamInfo* pluginInfo);
00326 
00337     NS_IMETHOD
00338     OnDataAvailable(nsIPluginStreamInfo* pluginInfo, 
00339                                             nsIInputStream* input, 
00340                                             PRUint32 length);
00341 
00342     NS_IMETHOD
00343     OnFileAvailable(nsIPluginStreamInfo* pluginInfo, const char* fileName);
00344 
00356     NS_IMETHOD
00357     OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
00358 
00359     NS_IMETHOD
00360     OnNotify(const char* url, nsresult status);
00361 
00362     NS_IMETHOD
00363     GetStreamType(nsPluginStreamType *result);
00364 
00366     // SimplePluginStreamListener specific methods:
00367 
00368     SimplePluginStreamListener(SimplePluginInstance* inst, const char* url);
00369     virtual ~SimplePluginStreamListener(void);
00370 
00371 protected:
00372     const char*                 fMessageName;
00373 };
00374 
00375 /*******************************************************************************
00376  * SECTION 3 - API Plugin Implementations
00377  ******************************************************************************/
00378 
00379 // XXXwaterson document!
00380 static const nsModuleComponentInfo gComponentInfo[] = {
00381     { "Simple Plugin",
00382       NS_SIMPLEPLUGIN_CID,
00383       NS_INLINE_PLUGIN_CONTRACTID_PREFIX PLUGIN_MIME_TYPE,
00384       SimplePluginInstance::Create,
00385       SimplePluginInstance::RegisterSelf,
00386       SimplePluginInstance::UnregisterSelf },
00387 };
00388 
00389 NS_IMPL_NSGETMODULE(SimplePlugin, gComponentInfo)
00390 
00391 
00392 
00393 
00394 // nsIScriptablePlugin methods
00396 NS_METHOD
00397 SimplePluginInstance::GetScriptablePeer(void **aScriptablePeer)
00398 {
00399    // We implement the interface we want to be scriptable by
00400    // (nsISimplePluginInstance) so we just return this.
00401 
00402    // NOTE if this function returns something other than
00403    // nsIPluginInstance, then that object will also need to implement
00404    // nsISecurityCheckedComponent to be scriptable.  The security
00405    // system knows to special-case nsIPluginInstance when checking
00406    // security, but in general, XPCOM components must implement
00407    // nsISecurityCheckedComponent to be scriptable from content
00408    // javascript.
00409 
00410    *aScriptablePeer = NS_STATIC_CAST(nsISimplePluginInstance *, this);
00411    NS_ADDREF(NS_STATIC_CAST(nsISimplePluginInstance *, *aScriptablePeer));
00412    return NS_OK;
00413 }
00414 
00415 NS_METHOD
00416 SimplePluginInstance::GetScriptableInterface(nsIID **aScriptableInterface)
00417 {
00418   *aScriptableInterface = (nsIID *)nsMemory::Alloc(sizeof(nsIID));
00419   NS_ENSURE_TRUE(*aScriptableInterface, NS_ERROR_OUT_OF_MEMORY);
00420 
00421   **aScriptableInterface = NS_GET_IID(nsISimplePluginInstance);
00422 
00423   return NS_OK;
00424 }
00425 
00427 // SimplePluginInstance Methods
00429 
00430 NS_METHOD
00431 SimplePluginInstance::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
00432 {
00433     NS_PRECONDITION(aOuter == nsnull, "no aggregation");
00434     if (aOuter)
00435         return NS_ERROR_NO_AGGREGATION;
00436 
00437     SimplePluginInstance* plugin = new SimplePluginInstance();
00438     if (! plugin)
00439         return NS_ERROR_OUT_OF_MEMORY;
00440 
00441     nsresult rv;
00442     NS_ADDREF(plugin);
00443     rv = plugin->QueryInterface(aIID, aResult);
00444     NS_RELEASE(plugin);
00445     return rv;
00446 }
00447 
00448 NS_METHOD
00449 SimplePluginInstance::RegisterSelf(nsIComponentManager* aCompMgr,
00450                                    nsIFile* aPath,
00451                                    const char* aRegistryLocation,
00452                                    const char* aComponentType,
00453                                    const nsModuleComponentInfo *info)
00454 {
00455     nsresult rv;
00456 
00457     nsIServiceManager *svcMgr;
00458     rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
00459                                   NS_REINTERPRET_CAST(void**, &svcMgr));
00460     if (NS_FAILED(rv))
00461         return rv;
00462 
00463     nsIPluginManager* pm;
00464     rv = svcMgr->GetService(kPluginManagerCID,
00465                             NS_GET_IID(nsIPluginManager),
00466                             NS_REINTERPRET_CAST(void**, &pm));
00467     NS_RELEASE(svcMgr);
00468 
00469     if (NS_SUCCEEDED(rv)) {
00470         rv = pm->RegisterPlugin(kSimplePluginCID,
00471                                 kPluginName,
00472                                 kPluginDescription,
00473                                 kMimeTypes,
00474                                 kMimeDescriptions,
00475                                 kFileExtensions,
00476                                 kNumMimeTypes);
00477 
00478         NS_RELEASE(pm);
00479     }
00480 
00481     return rv;
00482 }
00483 
00484 
00485 NS_METHOD
00486 SimplePluginInstance::UnregisterSelf(nsIComponentManager* aCompMgr,
00487                                      nsIFile* aPath,
00488                                      const char* aRegistryLocation,
00489                                      const nsModuleComponentInfo *info)
00490 {
00491     nsresult rv;
00492 
00493     nsIServiceManager *svcMgr;
00494     rv = aCompMgr->QueryInterface(NS_GET_IID(nsIServiceManager),
00495                                   NS_REINTERPRET_CAST(void**, &svcMgr));
00496     if (NS_FAILED(rv))
00497         return rv;
00498 
00499     nsIPluginManager* pm;
00500     rv = svcMgr->GetService(kPluginManagerCID,
00501                             NS_GET_IID(nsIPluginManager),
00502                             NS_REINTERPRET_CAST(void**, &pm));
00503     NS_RELEASE(svcMgr);
00504 
00505     if (NS_SUCCEEDED(rv)) {
00506         rv = pm->UnregisterPlugin(kSimplePluginCID);
00507         NS_RELEASE(pm);
00508     }
00509 
00510     return rv;
00511 }
00512 
00513 
00514 SimplePluginInstance::SimplePluginInstance(void)
00515     : fText(NULL), fPeer(NULL), fWindow(NULL), fMode(nsPluginMode_Embedded)
00516 {
00517     static const char text[] = "Hello World!";
00518     fText = (char*) nsMemory::Clone(text, sizeof(text));
00519 
00520 #ifdef XP_UNIX
00521     fPlatform.moz_box = nsnull;
00522     fPlatform.superwin = nsnull;
00523     fPlatform.label = nsnull;
00524 #endif
00525 
00526 }
00527 
00528 SimplePluginInstance::~SimplePluginInstance(void)
00529 {
00530     if(fText)
00531         nsMemory::Free(fText);
00532     PlatformDestroy(); // Perform platform specific cleanup
00533 }
00534 
00535 // These macros produce simple version of QueryInterface and AddRef.
00536 // See the nsISupports.h header file for details.
00537 
00538 NS_IMPL_ISUPPORTS3(SimplePluginInstance, nsIPluginInstance, nsISimplePluginInstance, nsIScriptablePlugin)
00539 
00540 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00541  * NewInstance:
00542  * Creates a new instance of a plug-in and returns an error value. 
00543  * 
00544  * NewInstance creates a new instance of your plug-in with MIME type specified
00545  * by pluginType. The parameter mode is NP_EMBED if the instance was created
00546  * by an EMBED tag, or NP_FULL if the instance was created by a separate file.
00547  * You can allocate any instance-specific private data in instance->pdata at this
00548  * time. The NPP pointer is valid until the instance is destroyed. 
00549  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00550 
00551 NS_METHOD
00552 SimplePluginInstance::Initialize(nsIPluginInstancePeer* peer)
00553 {
00554 #ifdef NS_DEBUG
00555     printf("SimplePluginInstance::Initialize\n");
00556 #endif
00557     
00558     NS_ASSERTION(peer != NULL, "null peer");
00559 
00560     fPeer = peer;
00561     nsIPluginTagInfo* taginfo;
00562     const char* const* names = nsnull;
00563     const char* const* values = nsnull;
00564     PRUint16 count = 0;
00565     nsresult result;
00566 
00567     peer->AddRef();
00568     result = peer->GetMode(&fMode);
00569     if (NS_FAILED(result)) return result;
00570 
00571    result = peer->QueryInterface(NS_GET_IID(nsIPluginTagInfo), (void **)&taginfo);
00572 
00573     if (NS_SUCCEEDED(result))
00574     {
00575         taginfo->GetAttributes(count, names, values);
00576         NS_IF_RELEASE(taginfo);
00577     }
00578 
00579 #ifdef NS_DEBUG
00580     printf("Attribute count = %d\n", count);
00581 
00582     for (int i = 0; i < count; i++)
00583     {
00584         printf("plugin param=%s, value=%s\n", names[i], values[i]);
00585     }
00586 #endif
00587 
00588     PlatformNew();   /* Call Platform-specific initializations */
00589     return NS_OK;
00590 }
00591 
00592 NS_METHOD
00593 SimplePluginInstance::GetPeer(nsIPluginInstancePeer* *result)
00594 {
00595 #ifdef NS_DEBUG
00596     printf("SimplePluginInstance::GetPeer\n");
00597 #endif
00598 
00599     fPeer->AddRef();
00600     *result = fPeer;
00601     return NS_OK;
00602 }
00603 
00604 NS_METHOD
00605 SimplePluginInstance::Start(void)
00606 {
00607 #ifdef NS_DEBUG
00608     printf("SimplePluginInstance::Start\n");
00609 #endif
00610 
00611     return NS_OK;
00612 }
00613 
00614 NS_METHOD
00615 SimplePluginInstance::Stop(void)
00616 {
00617 #ifdef NS_DEBUG
00618     printf("SimplePluginInstance::Stop\n");
00619 #endif
00620 
00621     return NS_OK;
00622 }
00623 
00624 NS_METHOD
00625 SimplePluginInstance::Destroy(void)
00626 {
00627 #ifdef NS_DEBUG
00628     printf("SimplePluginInstance::Destroy\n");
00629 #endif
00630 
00631     return NS_OK;
00632 }
00633 
00634 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00635  * NPP_SetWindow:
00636  * Sets the window in which a plug-in draws, and returns an error value. 
00637  * 
00638  * NPP_SetWindow informs the plug-in instance specified by instance of the
00639  * the window denoted by window in which the instance draws. This nsPluginWindow
00640  * pointer is valid for the life of the instance, or until NPP_SetWindow is called
00641  * again with a different value. Subsequent calls to NPP_SetWindow for a given
00642  * instance typically indicate that the window has been resized. If either window
00643  * or window->window are NULL, the plug-in must not perform any additional
00644  * graphics operations on the window and should free any resources associated
00645  * with the window. 
00646  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00647 
00648 NS_METHOD
00649 SimplePluginInstance::SetWindow(nsPluginWindow* window)
00650 {
00651 #ifdef NS_DEBUG
00652     printf("SimplePluginInstance::SetWindow\n");
00653 #endif
00654 
00655     nsresult result;
00656 
00657     /*
00658      * PLUGIN DEVELOPERS:
00659      * Before setting window to point to the
00660      * new window, you may wish to compare the new window
00661      * info to the previous window (if any) to note window
00662      * size changes, etc.
00663      */
00664     result = PlatformSetWindow(window);
00665     fWindow = window;
00666     return result;
00667 }
00668 
00669 NS_METHOD
00670 SimplePluginInstance::NewStream(nsIPluginStreamListener** listener)
00671 {
00672 #ifdef NS_DEBUG
00673     printf("SimplePluginInstance::NewStream\n");
00674 #endif
00675 
00676     if(listener != NULL)
00677     {
00678         SimplePluginStreamListener* sl = 
00679                 new SimplePluginStreamListener(this, "http://www.mozilla.org");
00680         if(!sl)
00681             return NS_ERROR_UNEXPECTED;
00682         sl->AddRef();
00683         *listener = sl;
00684     }
00685     
00686     return NS_OK;
00687 }
00688 
00689 
00690 /* attribute string text; */
00691 NS_IMETHODIMP SimplePluginInstance::GetText(char * *aText)
00692 {
00693 #ifdef NS_DEBUG
00694     printf("SimplePluginInstance::GetText\n");
00695 #endif
00696     
00697     if(!fText)
00698     {
00699         *aText = NULL;
00700         return NS_OK;        
00701     }
00702     char* ptr = *aText = (char*) nsMemory::Clone(fText, strlen(fText)+1);
00703     return ptr ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
00704 }
00705 NS_IMETHODIMP SimplePluginInstance::SetText(const char * aText)
00706 {
00707 #ifdef NS_DEBUG
00708     printf("SimplePluginInstance::SetText\n");
00709 #endif
00710 
00711     if(fText)
00712     {
00713         nsMemory::Free(fText);
00714         fText = NULL;
00715     }
00716 
00717     if(aText)
00718     {
00719         fText = (char*) nsMemory::Clone(aText, strlen(aText)+1);
00720         if(!fText)
00721             return NS_ERROR_OUT_OF_MEMORY;
00722 
00723 #ifdef XP_WIN
00724         if(fPlatform.fhWnd) {
00725             InvalidateRect( fPlatform.fhWnd, NULL, TRUE );
00726             UpdateWindow( fPlatform.fhWnd );
00727         }
00728 #endif
00729 
00730 #ifdef XP_UNIX
00731         // force a redraw
00732         Repaint();
00733 #endif
00734 
00735     }
00736 
00737     return NS_OK;
00738 }
00739 
00740 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00741  * NPP_Print:
00742  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00743 
00744 NS_METHOD
00745 SimplePluginInstance::Print(nsPluginPrint* printInfo)
00746 {
00747 #ifdef NS_DEBUG
00748     printf("SimplePluginInstance::Print\n");
00749 #endif
00750 
00751     if (printInfo == NULL)
00752         return NS_ERROR_FAILURE;
00753 
00754     if (printInfo->mode == nsPluginMode_Full) {
00755         /*
00756          * PLUGIN DEVELOPERS:
00757          *    If your plugin would like to take over
00758          *    printing completely when it is in full-screen mode,
00759          *    set printInfo->pluginPrinted to TRUE and print your
00760          *    plugin as you see fit.  If your plugin wants Netscape
00761          *    to handle printing in this case, set
00762          *    printInfo->pluginPrinted to FALSE (the default) and
00763          *    do nothing.  If you do want to handle printing
00764          *    yourself, printOne is true if the print button
00765          *    (as opposed to the print menu) was clicked.
00766          *    On the Macintosh, platformPrint is a THPrint; on
00767          *    Windows, platformPrint is a structure
00768          *    (defined in npapi.h) containing the printer name, port,
00769          *    etc.
00770          */
00771 
00772         /* Do the default*/
00773         printInfo->print.fullPrint.pluginPrinted = PR_FALSE;
00774     }
00775     else {    /* If not fullscreen, we must be embedded */
00776         /*
00777          * PLUGIN DEVELOPERS:
00778          *    If your plugin is embedded, or is full-screen
00779          *    but you returned false in pluginPrinted above, NPP_Print
00780          *    will be called with mode == nsPluginMode_Embedded.  The nsPluginWindow
00781          *    in the printInfo gives the location and dimensions of
00782          *    the embedded plugin on the printed page.  On the
00783          *    Macintosh, platformPrint is the printer port; on
00784          *    Windows, platformPrint is the handle to the printing
00785          *    device context.
00786          */
00787     }
00788     return NS_OK;
00789 }
00790 
00791 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00792  * NPP_HandleEvent:
00793  * Mac-only, but stub must be present for Windows
00794  * Delivers a platform-specific event to the instance. 
00795  * 
00796  * On the Macintosh, event is a pointer to a standard Macintosh EventRecord.
00797  * All standard event types are passed to the instance as appropriate. In general,
00798  * return TRUE if you handle the event and FALSE if you ignore the event. 
00799  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00800 
00801 NS_METHOD
00802 SimplePluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
00803 {
00804 #ifdef NS_DEBUG
00805     printf("SimplePluginInstance::HandleEvent\n");
00806 #endif
00807 
00808     *handled = (PRBool)PlatformHandleEvent(event);
00809     return NS_OK;
00810 }
00811 
00812 NS_METHOD
00813 SimplePluginInstance::GetValue(nsPluginInstanceVariable variable, void *value)
00814 {
00815 #ifdef NS_DEBUG
00816     printf("SimplePluginInstance::GetValue\n");
00817 #endif
00818 
00819     return NS_ERROR_FAILURE;
00820 }
00821 
00823 // SimplePluginStreamListener Methods
00825 
00826 SimplePluginStreamListener::SimplePluginStreamListener(SimplePluginInstance* inst,
00827                                                        const char* msgName)
00828     : fMessageName(msgName)
00829 {
00830     char msg[256];
00831     sprintf(msg, "### Creating SimplePluginStreamListener for %s\n", fMessageName);
00832 }
00833 
00834 SimplePluginStreamListener::~SimplePluginStreamListener(void)
00835 {
00836     char msg[256];
00837     sprintf(msg, "### Destroying SimplePluginStreamListener for %s\n", fMessageName);
00838 }
00839 
00840 // This macro produces a simple version of QueryInterface, AddRef and Release.
00841 // See the nsISupports.h header file for details.
00842 
00843 NS_IMPL_ISUPPORTS1(SimplePluginStreamListener, nsIPluginStreamListener)
00844 
00845 NS_METHOD
00846 SimplePluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
00847 {
00848 #ifdef NS_DEBUG
00849     printf("SimplePluginStreamListener::OnStartBinding\n");
00850 #endif
00851 
00852     char msg[256];
00853     sprintf(msg, "### Opening plugin stream for %s\n", fMessageName);
00854     return NS_OK;
00855 }
00856 
00857 NS_METHOD
00858 SimplePluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo, 
00859                                             nsIInputStream* input, 
00860                                             PRUint32 length)
00861 {
00862 #ifdef NS_DEBUG
00863     printf("SimplePluginStreamListener::OnDataAvailable\n");
00864 #endif
00865 
00866     char* buffer = new char[length];
00867     if (buffer) {
00868         PRUint32 amountRead = 0;
00869         nsresult rslt = input->Read(buffer, length, &amountRead);
00870         if (rslt == NS_OK) {
00871             char msg[256];
00872             sprintf(msg, "### Received %d bytes for %s\n", length, fMessageName);
00873         }
00874         delete buffer;
00875     }
00876     return NS_OK;
00877 }
00878 
00879 NS_METHOD
00880 SimplePluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo, 
00881                                             const char* fileName)
00882 {
00883 #ifdef NS_DEBUG
00884     printf("SimplePluginStreamListener::OnFileAvailable\n");
00885 #endif
00886 
00887     char msg[256];
00888     sprintf(msg, "### File available for %s: %s\n", fMessageName, fileName);
00889     return NS_OK;
00890 }
00891 
00892 NS_METHOD
00893 SimplePluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status )
00894 {
00895 #ifdef NS_DEBUG
00896     printf("SimplePluginStreamListener::OnStopBinding\n");
00897 #endif
00898 
00899     char msg[256];
00900     sprintf(msg, "### Closing plugin stream for %s\n", fMessageName);
00901     return NS_OK;
00902 }
00903 
00904 NS_METHOD
00905 SimplePluginStreamListener::OnNotify(const char* url, nsresult status)
00906 {
00907 #ifdef NS_DEBUG
00908     printf("SimplePluginStreamListener::OnNotify\n");
00909 #endif
00910 
00911     return NS_OK;
00912 }
00913 
00914 NS_METHOD
00915 SimplePluginStreamListener::GetStreamType(nsPluginStreamType *result)
00916 {
00917 #ifdef NS_DEBUG
00918     printf("SimplePluginStreamListener::GetStreamType\n");
00919 #endif
00920 
00921     *result = nsPluginStreamType_Normal;
00922     return NS_OK;
00923 }
00924 
00925 /*******************************************************************************
00926  * SECTION 4 - Utility Method Implementations
00927  *******************************************************************************/
00928 
00929 /*------------------------------------------------------------------------------
00930  * Platform-Specific Implemenations
00931  *------------------------------------------------------------------------------
00932  * UNIX Implementations
00933  *----------------------------------------------------------------------------*/
00934 
00935 #if defined(XP_UNIX)
00936 
00937 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00938  * PlatformNew
00939  *
00940  * Initialize any Platform-Specific instance data.
00941  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00942 
00943 void
00944 SimplePluginInstance::PlatformNew(void)
00945 {
00946     fPlatform.window = 0;
00947 }
00948 
00949 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00950  * PlatformDestroy
00951  *
00952  * Destroy any Platform-Specific instance data.
00953  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00954 
00955 nsresult
00956 SimplePluginInstance::PlatformDestroy(void)
00957 {
00958     gtk_widget_destroy(fPlatform.moz_box);
00959     fPlatform.moz_box = 0;
00960     return NS_OK;
00961 }
00962 
00963 /*+++++++++++++++++++++++++++++++++++++++++++++++++
00964  * PlatformSetWindow
00965  *
00966  * Perform platform-specific window operations
00967  +++++++++++++++++++++++++++++++++++++++++++++++++*/
00968 
00969 nsresult
00970 SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window)
00971 {
00972 #ifdef NS_DEBUG
00973     printf("SimplePluginInstance::PlatformSetWindow\n");
00974 #endif
00975 
00976     if (window == NULL || window->window == NULL)
00977         return NS_ERROR_NULL_POINTER;
00978 
00979     GdkWindow *win = gdk_window_lookup((XID)window->window);
00980 
00981     if ( fPlatform.superwin && fPlatform.superwin->bin_window == win )
00982         return NS_OK;
00983     
00984     // should we destroy fPlatform.superwin ??
00985     
00986     fPlatform.superwin = gdk_superwin_new(win, 0, 0, window->width, window->height);
00987 
00988     // a little cleanup
00989     if (fPlatform.label)
00990         gtk_widget_destroy(fPlatform.label);
00991     if (fPlatform.moz_box)
00992         gtk_widget_destroy(fPlatform.moz_box);
00993 
00994     // create a containing mozbox and a label to put in it
00995     fPlatform.moz_box = gtk_mozbox_new(fPlatform.superwin->bin_window);
00996     fPlatform.label = gtk_label_new(fText);
00997     gtk_container_add(GTK_CONTAINER(fPlatform.moz_box), fPlatform.label);
00998 
00999     // grow the label to fit the entire mozbox
01000     gtk_widget_set_usize(fPlatform.label, window->width, window->height);
01001 
01002     // connect to expose events
01003     gtk_signal_connect (GTK_OBJECT(fPlatform.label), "expose_event",
01004                         GTK_SIGNAL_FUNC(draw), this);
01005 
01006     gtk_widget_show(fPlatform.label);
01007     gtk_widget_show(fPlatform.moz_box);
01008 
01009     return NS_OK;
01010 }
01011 
01012 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01013  * PlatformHandleEvent
01014  *
01015  * Handle platform-specific events.
01016  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01017 
01018 int16
01019 SimplePluginInstance::PlatformHandleEvent(nsPluginEvent* event)
01020 {
01021     /* UNIX Plugins do not use HandleEvent */
01022     return 0;
01023 }
01024 
01025 NS_IMETHODIMP
01026 SimplePluginInstance::Repaint(void)
01027 {
01028 #ifdef DEBUG
01029     printf("SimplePluginInstance::Repaint()\n");
01030 #endif
01031     
01032     if ( !fPlatform.moz_box || !fPlatform.label )
01033         return NS_ERROR_FAILURE;
01034 
01035     // Set the label text
01036     gtk_label_set_text(GTK_LABEL(fPlatform.label), fText);
01037 
01038     // show the new label
01039     gtk_widget_show(fPlatform.label);
01040     gtk_widget_show(fPlatform.moz_box);
01041 
01042     return NS_OK;
01043 }
01044 
01045 gboolean draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
01046 {
01047     SimplePluginInstance * pthis = (SimplePluginInstance *)data;
01048 
01049     pthis->Repaint();
01050     return TRUE;
01051 }
01052 
01053 /*------------------------------------------------------------------------------
01054  * Windows Implementations
01055  *----------------------------------------------------------------------------*/
01056 
01057 #elif defined(XP_WIN)
01058 const char* gInstanceLookupString = "instance->pdata";
01059 
01060 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01061  * PlatformNew
01062  *
01063  * Initialize any Platform-Specific instance data.
01064  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01065 
01066 void
01067 SimplePluginInstance::PlatformNew(void)
01068 {
01069     fPlatform.fhWnd = NULL;
01070     fPlatform.fDefaultWindowProc = NULL;
01071 }
01072 
01073 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01074  * PlatformDestroy
01075  *
01076  * Destroy any Platform-Specific instance data.
01077  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01078 
01079 nsresult
01080 SimplePluginInstance::PlatformDestroy(void)
01081 {
01082     if( fWindow != NULL ) { /* If we have a window, clean
01083                                    * it up. */
01084         SetWindowLong( fPlatform.fhWnd, GWL_WNDPROC, (LONG)fPlatform.fDefaultWindowProc);
01085         fPlatform.fDefaultWindowProc = NULL;
01086         fPlatform.fhWnd = NULL;
01087     }
01088 
01089     return NS_OK;
01090 }
01091 
01092 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01093  * PlatformSetWindow
01094  *
01095  * Perform platform-specific window operations
01096  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01097 
01098 nsresult
01099 SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window)
01100 {
01101     if( fWindow != NULL ) /* If we already have a window, clean
01102                            * it up before trying to subclass
01103                            * the new window. */
01104     {
01105         if( (window == NULL) || ( window->window == NULL ) ) {
01106             /* There is now no window to use. get rid of the old
01107              * one and exit. */
01108             SetWindowLong( fPlatform.fhWnd, GWL_WNDPROC, (LONG)fPlatform.fDefaultWindowProc);
01109             fPlatform.fDefaultWindowProc = NULL;
01110             fPlatform.fhWnd = NULL;
01111             return NS_OK;
01112         }
01113 
01114         else if ( fPlatform.fhWnd == (HWND) window->window ) {
01115             /* The new window is the same as the old one. Exit now. */
01116             return NS_OK;
01117         }
01118         else {
01119             /* Clean up the old window, so that we can subclass the new
01120              * one later. */
01121             SetWindowLong( fPlatform.fhWnd, GWL_WNDPROC, (LONG)fPlatform.fDefaultWindowProc);
01122             fPlatform.fDefaultWindowProc = NULL;
01123             fPlatform.fhWnd = NULL;
01124         }
01125     }
01126     else if( (window == NULL) || ( window->window == NULL ) ) {
01127         /* We can just get out of here if there is no current
01128          * window and there is no new window to use. */
01129         return NS_OK;
01130     }
01131 
01132     /* At this point, we will subclass
01133      * window->window so that we can begin drawing and
01134      * receiving window messages. */
01135     fPlatform.fDefaultWindowProc =
01136         (WNDPROC)SetWindowLong( (HWND)window->window,
01137                                 GWL_WNDPROC, (LONG)SimplePluginInstance::PluginWindowProc);
01138     fPlatform.fhWnd = (HWND) window->window;
01139     SetProp(fPlatform.fhWnd, gInstanceLookupString, (HANDLE)this);
01140 
01141     InvalidateRect( fPlatform.fhWnd, NULL, TRUE );
01142     UpdateWindow( fPlatform.fhWnd );
01143     return NS_OK;
01144 }
01145 
01146 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01147  * PlatformHandleEvent
01148  *
01149  * Handle platform-specific events.
01150  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01151 
01152 PRInt16
01153 SimplePluginInstance::PlatformHandleEvent(nsPluginEvent* event)
01154 {
01155     /* Windows Plugins use the Windows event call-back mechanism
01156        for events. (See PluginWindowProc) */
01157     return 0;
01158 }
01159 
01160 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01161  * PluginWindowProc
01162  *
01163  * Handle the Windows window-event loop.
01164  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01165 
01166 LRESULT CALLBACK 
01167 SimplePluginInstance::PluginWindowProc( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
01168 {
01169     SimplePluginInstance* inst = (SimplePluginInstance*) GetProp(hWnd, gInstanceLookupString);
01170 
01171     switch( Msg ) {
01172       case WM_PAINT: {
01173           PAINTSTRUCT paintStruct;
01174           HDC hdc;
01175 
01176           hdc = BeginPaint( hWnd, &paintStruct );
01177 
01178           if(paintStruct.fErase)
01179             FillRect(hdc, &paintStruct.rcPaint, 
01180                      (HBRUSH) GetStockObject(WHITE_BRUSH)); 
01181 
01182           if(inst->fText) {
01183             RECT rcWnd;
01184             GetWindowRect(hWnd, &rcWnd);
01185             SetTextAlign(hdc, TA_CENTER);
01186             TextOut(hdc, (rcWnd.right-rcWnd.left)/2, (rcWnd.bottom-rcWnd.top)/2, inst->fText, strlen(inst->fText));
01187           }
01188 
01189           EndPaint( hWnd, &paintStruct );
01190           break;
01191       }
01192       default: {
01193           CallWindowProc(inst->fPlatform.fDefaultWindowProc, hWnd, Msg, wParam, lParam);
01194       }
01195     }
01196     return 0;
01197 }
01198 
01199 
01200 
01201 /*------------------------------------------------------------------------------
01202  * Macintosh Implementations
01203  *----------------------------------------------------------------------------*/
01204 
01205 #elif defined(XP_MAC)
01206 
01207 PRBool StartDraw(nsPluginWindow* window);
01208 void   EndDraw(nsPluginWindow* window);
01209 void   DoDraw(SimplePluginInstance* This);
01210 
01211 CGrafPort            gSavePort;
01212 CGrafPtr             gOldPort;
01213 
01214 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01215  * PlatformNew
01216  *
01217  * Initialize any Platform-Specific instance data.
01218  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01219 
01220 void
01221 SimplePluginInstance::PlatformNew(void)
01222 {
01223 }
01224 
01225 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01226  * PlatformDestroy
01227  *
01228  * Destroy any Platform-Specific instance data.
01229  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01230 
01231 nsresult
01232 SimplePluginInstance::PlatformDestroy(void)
01233 {
01234     return NS_OK;
01235 }
01236 
01237 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01238  * PlatformSetWindow
01239  *
01240  * Perform platform-specific window operations
01241  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01242 
01243 nsresult
01244 SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window)
01245 {
01246     fWindow = window;
01247     if( StartDraw( window ) ) {
01248         DoDraw(This);
01249         EndDraw( window );
01250     }
01251     return NS_OK;
01252 }
01253 
01254 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01255  * PlatformHandleEvent
01256  *
01257  * Handle platform-specific events.
01258  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01259 
01260 int16
01261 SimplePluginInstance::PlatformHandleEvent(nsPluginEvent* event)
01262 {
01263     int16 eventHandled = FALSE;
01264        
01265     EventRecord* ev = (EventRecord*) event;
01266     if (This != NULL && event != NULL)
01267     {
01268         switch (ev->what)
01269         {
01270             /*
01271              * Draw ourselves on update events
01272              */
01273           case updateEvt:
01274             if( StartDraw( fWindow ) ) {
01275                 DoDraw(This);
01276                 EndDraw( fWindow );
01277             }
01278             eventHandled = true;
01279             break;
01280           default:
01281             break;
01282         }
01283     }
01284     return eventHandled;
01285 }
01286 
01287 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01288  * StartDraw
01289  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01290 
01291 PRBool
01292 SimplePluginInstance::StartDraw(nsPluginWindow* window)
01293 {
01294     NP_Port* port;
01295     Rect clipRect;
01296     RGBColor  col;
01297        
01298     if (window == NULL)
01299         return FALSE;
01300     port = (NP_Port*) window->window;
01301     if (window->clipRect.left < window->clipRect.right)
01302     {
01303        /* Preserve the old port */
01304         GetPort((GrafPtr*)&gOldPort);
01305         SetPort((GrafPtr)port->port);
01306        /* Preserve the old drawing environment */
01307         gSavePort.portRect = port->port->portRect;
01308         gSavePort.txFont = port->port->txFont;
01309         gSavePort.txFace = port->port->txFace;
01310         gSavePort.txMode = port->port->txMode;
01311         gSavePort.rgbFgColor = port->port->rgbFgColor;
01312         gSavePort.rgbBkColor = port->port->rgbBkColor;
01313         GetClip(gSavePort.clipRgn);
01314        /* Setup our drawing environment */
01315         clipRect.top = window->clipRect.top + port->porty;
01316         clipRect.left = window->clipRect.left + port->portx;
01317         clipRect.bottom = window->clipRect.bottom + port->porty;
01318         clipRect.right = window->clipRect.right + port->portx;
01319         SetOrigin(port->portx,port->porty);
01320         ClipRect(&clipRect);
01321         clipRect.top = clipRect.left = 0;
01322         TextSize(12);
01323         TextFont(geneva);
01324         TextMode(srcCopy);
01325         col.red = col.green = col.blue = 0;
01326         RGBForeColor(&col);
01327         col.red = col.green = col.blue = 65000;
01328         RGBBackColor(&col);
01329         return TRUE;
01330     }
01331     else
01332         return FALSE;
01333 }
01334 
01335 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01336  * EndDraw
01337  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01338 
01339 void
01340 SimplePluginInstance::EndDraw(nsPluginWindow* window)
01341 {
01342     CGrafPtr myPort;
01343     NP_Port* port = (NP_Port*) window->window;
01344     SetOrigin(gSavePort.portRect.left, gSavePort.portRect.top);
01345     SetClip(gSavePort.clipRgn);
01346     GetPort((GrafPtr*)&myPort);
01347     myPort->txFont = gSavePort.txFont;
01348     myPort->txFace = gSavePort.txFace;
01349     myPort->txMode = gSavePort.txMode;
01350     RGBForeColor(&gSavePort.rgbFgColor);
01351     RGBBackColor(&gSavePort.rgbBkColor);
01352     SetPort((GrafPtr)gOldPort);
01353 }
01354 
01355 /*+++++++++++++++++++++++++++++++++++++++++++++++++
01356  * DoDraw
01357  +++++++++++++++++++++++++++++++++++++++++++++++++*/
01358 
01359 void
01360 SimplePluginInstance::DoDraw(void)
01361 {
01362     Rect drawRect;
01363     drawRect.top = 0;
01364     drawRect.left = 0;
01365     drawRect.bottom = drawRect.top + fWindow->height;
01366     drawRect.right = drawRect.left + fWindow->width;
01367     EraseRect( &drawRect );
01368     MoveTo( 2, 12 );
01369     DrawString("\pHello, World!");
01370 }
01371 
01372 
01373 
01374 /*------------------------------------------------------------------------------
01375  * Stub Implementations
01376  *----------------------------------------------------------------------------*/
01377 
01378 #else
01379 
01380 void
01381 SimplePluginInstance::PlatformNew(void)
01382 {
01383 }
01384 
01385 nsresult
01386 SimplePluginInstance::PlatformDestroy(void)
01387 {
01388     return NS_ERROR_NOT_IMPLEMENTED;
01389 }
01390 
01391 nsresult
01392 SimplePluginInstance::PlatformSetWindow(nsPluginWindow* window)
01393 {
01394     return NS_ERROR_NOT_IMPLEMENTED;
01395 }
01396 
01397 int16
01398 SimplePluginInstance::PlatformHandleEvent(nsPluginEvent* event)
01399 {
01400     int16 eventHandled = FALSE;
01401     return eventHandled;
01402 }
01403 
01404 #endif /* end Section 5 */
01405 
01406 /******************************************************************************/