1999-07-07 20:18:27 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-07-07 20:18:27 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-07-07 20:18:27 +00:00
|
|
|
*
|
1999-11-06 03:43:54 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-07-07 20:18:27 +00:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 03:43:54 +00:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-07-07 20:18:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ns4xPluginInstance.h"
|
|
|
|
#include "nsIPluginStreamListener.h"
|
2000-09-14 06:13:56 +00:00
|
|
|
#include "nsPluginHostImpl.h"
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
#include "prlog.h"
|
|
|
|
#include "prmem.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
2000-05-13 04:41:56 +00:00
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
2000-10-13 01:10:21 +00:00
|
|
|
#include <gdk/gdk.h>
|
|
|
|
#include <gdk/gdkx.h>
|
2000-04-22 20:50:22 +00:00
|
|
|
#include "gtkxtbin.h"
|
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-09-14 06:13:56 +00:00
|
|
|
#include "nsPluginSafety.h"
|
|
|
|
#include "nsIPref.h" // needed for NS_TRY_SAFE_CALL_*
|
|
|
|
|
|
|
|
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); // needed for NS_TRY_SAFE_CALL_*
|
|
|
|
static NS_DEFINE_IID(kCPluginManagerCID, NS_PLUGINMANAGER_CID);
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
class ns4xPluginStreamListener : public nsIPluginStreamListener {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
NS_DECL_ISUPPORTS
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// from nsIPluginStreamListener:
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
NS_IMETHOD OnStartBinding(nsIPluginStreamInfo* pluginInfo);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
NS_IMETHOD OnDataAvailable(nsIPluginStreamInfo* pluginInfo, nsIInputStream* input,
|
|
|
|
PRUint32 length);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
NS_IMETHOD OnFileAvailable( nsIPluginStreamInfo* pluginInfo, const char* fileName);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
NS_IMETHOD OnStopBinding(nsIPluginStreamInfo* pluginInfo, nsresult status);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
NS_IMETHOD GetStreamType(nsPluginStreamType *result);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// ns4xPluginStreamListener specific methods:
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
ns4xPluginStreamListener(nsIPluginInstance* inst, void* notifyData);
|
|
|
|
virtual ~ns4xPluginStreamListener(void);
|
2000-10-27 22:05:07 +00:00
|
|
|
PRBool IsStarted(void);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
void* mNotifyData;
|
|
|
|
ns4xPluginInstance* mInst;
|
|
|
|
NPStream mNPStream;
|
|
|
|
PRUint32 mPosition;
|
|
|
|
nsPluginStreamType mStreamType;
|
1999-07-07 20:18:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
1999-07-07 20:18:27 +00:00
|
|
|
// ns4xPluginStreamListener Methods
|
2000-04-22 20:50:22 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
ns4xPluginStreamListener::ns4xPluginStreamListener(nsIPluginInstance* inst,
|
|
|
|
void* notifyData)
|
1999-07-07 20:18:27 +00:00
|
|
|
: mNotifyData(notifyData)
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
mInst = (ns4xPluginInstance*) inst;
|
|
|
|
mPosition = 0;
|
|
|
|
|
|
|
|
// Initialize the 4.x interface structure
|
|
|
|
memset(&mNPStream, 0, sizeof(mNPStream));
|
|
|
|
|
|
|
|
NS_IF_ADDREF(mInst);
|
|
|
|
}
|
|
|
|
|
|
|
|
ns4xPluginStreamListener::~ns4xPluginStreamListener(void)
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mInst);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(ns4xPluginStreamListener, kIPluginStreamListenerIID);
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ns4xPluginStreamListener::OnStartBinding(nsIPluginStreamInfo* pluginInfo)
|
|
|
|
{
|
2001-03-02 00:29:33 +00:00
|
|
|
if(!mInst)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
NPP npp;
|
|
|
|
const NPPluginFuncs *callbacks = nsnull;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
mInst->GetCallbacks(&callbacks);
|
|
|
|
mInst->GetNPP(&npp);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-25 00:28:53 +00:00
|
|
|
if(!callbacks || !npp->pdata || !mInst->IsStarted())
|
2001-03-02 00:29:33 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2000-09-14 06:13:56 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
PRBool seekable;
|
|
|
|
nsMIMEType contentType;
|
|
|
|
PRUint16 streamType = NP_NORMAL;
|
|
|
|
NPError error;
|
2000-12-11 22:54:54 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
mNPStream.ndata = (void*) this;
|
|
|
|
pluginInfo->GetURL(&mNPStream.url);
|
|
|
|
mNPStream.notifyData = mNotifyData;
|
2001-02-13 21:48:26 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
pluginInfo->GetLength((PRUint32*)&(mNPStream.end));
|
|
|
|
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
|
|
|
pluginInfo->IsSeekable(&seekable);
|
|
|
|
pluginInfo->GetContentType(&contentType);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
PRLibrary* lib = mInst->fLibrary;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
// if we don't know the end of the stream, use 0 instead of -1. bug 59571
|
|
|
|
if (mNPStream.end == -1)
|
|
|
|
mNPStream.end = 0;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewStreamProc(callbacks->newstream,
|
|
|
|
npp,
|
|
|
|
(char *)contentType,
|
|
|
|
&mNPStream,
|
|
|
|
seekable,
|
|
|
|
&streamType), lib);
|
|
|
|
if(error != NPERR_NO_ERROR)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
// translate the old 4x style stream type to the new one
|
|
|
|
switch(streamType)
|
|
|
|
{
|
|
|
|
case NP_NORMAL:
|
|
|
|
mStreamType = nsPluginStreamType_Normal;
|
|
|
|
break;
|
|
|
|
case NP_ASFILEONLY:
|
|
|
|
mStreamType = nsPluginStreamType_AsFileOnly;
|
|
|
|
break;
|
|
|
|
case NP_ASFILE:
|
|
|
|
mStreamType = nsPluginStreamType_AsFile;
|
|
|
|
break;
|
|
|
|
case NP_SEEK:
|
|
|
|
mStreamType = nsPluginStreamType_Seek;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ns4xPluginStreamListener::OnDataAvailable(nsIPluginStreamInfo* pluginInfo,
|
2000-09-29 00:46:18 +00:00
|
|
|
nsIInputStream* input,
|
1999-07-07 20:18:27 +00:00
|
|
|
PRUint32 length)
|
|
|
|
{
|
2001-04-28 02:24:29 +00:00
|
|
|
if (!mInst || !mInst->IsStarted())
|
2001-03-02 00:29:33 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
const NPPluginFuncs *callbacks = nsnull;
|
|
|
|
NPP npp;
|
|
|
|
|
|
|
|
mInst->GetCallbacks(&callbacks);
|
|
|
|
mInst->GetNPP(&npp);
|
|
|
|
|
|
|
|
if(!callbacks || !npp->pdata)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2000-09-29 00:46:18 +00:00
|
|
|
PRUint32 numtowrite = 0;
|
|
|
|
PRUint32 amountRead = 0;
|
|
|
|
PRInt32 writeCount = 0;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-09-29 00:46:18 +00:00
|
|
|
pluginInfo->GetURL(&mNPStream.url);
|
|
|
|
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
if (callbacks->write == nsnull || length == 0)
|
2000-09-29 00:46:18 +00:00
|
|
|
return NS_OK; // XXX ?
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
// Get the data from the input stream
|
2000-09-29 00:46:18 +00:00
|
|
|
char* buffer = (char*) PR_Malloc(length);
|
2001-03-17 00:38:23 +00:00
|
|
|
if (!buffer)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
nsresult rv = input->Read(buffer, length, &amountRead);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
goto error;
|
2000-09-29 00:46:18 +00:00
|
|
|
|
|
|
|
// amountRead tells us how many bytes were put in the buffer
|
|
|
|
// WriteReady returns to us how many bytes the plugin is
|
|
|
|
// ready to handle - we have to keep calling WriteReady and
|
|
|
|
// Write until the buffer is empty
|
|
|
|
while (amountRead > 0)
|
|
|
|
{
|
|
|
|
if (callbacks->writeready != NULL)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2001-03-02 00:29:33 +00:00
|
|
|
PRLibrary* lib = nsnull;
|
|
|
|
PRBool started = PR_FALSE;
|
2001-04-28 02:24:29 +00:00
|
|
|
lib = mInst->fLibrary;
|
2001-03-02 00:29:33 +00:00
|
|
|
|
2001-04-28 02:24:29 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(numtowrite, CallNPP_WriteReadyProc(callbacks->writeready,
|
2001-03-02 00:29:33 +00:00
|
|
|
npp,
|
|
|
|
&mNPStream), lib);
|
2000-09-14 06:13:56 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
// if WriteReady returned 0, the plugin is not ready to handle
|
2000-09-29 00:46:18 +00:00
|
|
|
// the data, return FAILURE for now
|
2001-03-17 00:38:23 +00:00
|
|
|
if (numtowrite <= 0) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
goto error;
|
|
|
|
}
|
2000-09-29 00:46:18 +00:00
|
|
|
|
|
|
|
if (numtowrite > amountRead)
|
|
|
|
numtowrite = amountRead;
|
|
|
|
}
|
|
|
|
else
|
2001-03-02 00:29:33 +00:00
|
|
|
{
|
2000-09-29 00:46:18 +00:00
|
|
|
// if WriteReady is not supported by the plugin,
|
|
|
|
// just write the whole buffer
|
|
|
|
numtowrite = length;
|
2001-03-02 00:29:33 +00:00
|
|
|
}
|
2000-09-29 00:46:18 +00:00
|
|
|
|
2001-03-17 00:38:23 +00:00
|
|
|
if (numtowrite > 0)
|
2000-09-29 00:46:18 +00:00
|
|
|
{
|
2001-03-02 00:29:33 +00:00
|
|
|
PRLibrary* lib = mInst->fLibrary;
|
2000-09-29 00:46:18 +00:00
|
|
|
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(writeCount, CallNPP_WriteProc(callbacks->write,
|
2001-03-02 00:29:33 +00:00
|
|
|
npp,
|
|
|
|
&mNPStream,
|
|
|
|
mPosition,
|
|
|
|
numtowrite,
|
|
|
|
(void *)buffer), lib);
|
2001-03-17 00:38:23 +00:00
|
|
|
if (writeCount < 0) {
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
goto error;
|
|
|
|
}
|
2001-03-02 00:29:33 +00:00
|
|
|
|
2000-09-29 00:46:18 +00:00
|
|
|
amountRead -= numtowrite;
|
|
|
|
mPosition += numtowrite;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
2000-09-29 00:46:18 +00:00
|
|
|
}
|
|
|
|
|
2001-03-17 00:38:23 +00:00
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (buffer)
|
|
|
|
PR_Free(buffer);
|
|
|
|
return rv;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-04-22 20:50:22 +00:00
|
|
|
ns4xPluginStreamListener::OnFileAvailable(nsIPluginStreamInfo* pluginInfo,
|
|
|
|
const char* fileName)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2001-04-28 02:24:29 +00:00
|
|
|
if(!mInst || !mInst->IsStarted())
|
2001-03-02 00:29:33 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
NPP npp;
|
|
|
|
const NPPluginFuncs *callbacks = nsnull;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
mInst->GetCallbacks(&callbacks);
|
|
|
|
mInst->GetNPP(&npp);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
if(!callbacks || !npp->pdata)
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
pluginInfo->GetURL(&mNPStream.url);
|
2000-09-14 06:13:56 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
if (callbacks->asfile == NULL)
|
1999-07-07 20:18:27 +00:00
|
|
|
return NS_OK;
|
2001-03-02 00:29:33 +00:00
|
|
|
|
|
|
|
PRLibrary* lib = nsnull;
|
2001-04-28 02:24:29 +00:00
|
|
|
lib = mInst->fLibrary;
|
2001-03-02 00:29:33 +00:00
|
|
|
|
2001-04-28 02:24:29 +00:00
|
|
|
NS_TRY_SAFE_CALL_VOID(CallNPP_StreamAsFileProc(callbacks->asfile,
|
2001-03-02 00:29:33 +00:00
|
|
|
npp,
|
|
|
|
&mNPStream,
|
|
|
|
fileName), lib);
|
|
|
|
|
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-04-22 20:50:22 +00:00
|
|
|
ns4xPluginStreamListener::OnStopBinding(nsIPluginStreamInfo* pluginInfo,
|
|
|
|
nsresult status)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2001-04-28 02:24:29 +00:00
|
|
|
if(!mInst || !mInst->IsStarted())
|
2001-03-02 00:29:33 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
NPP npp;
|
|
|
|
const NPPluginFuncs *callbacks = nsnull;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
mInst->GetCallbacks(&callbacks);
|
|
|
|
mInst->GetNPP(&npp);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
if(!callbacks || !npp->pdata)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
NPError error;
|
|
|
|
|
|
|
|
pluginInfo->GetURL(&mNPStream.url);
|
|
|
|
pluginInfo->GetLastModified((PRUint32*)&(mNPStream.lastmodified));
|
|
|
|
|
|
|
|
if (callbacks->destroystream != NULL)
|
|
|
|
{
|
|
|
|
// XXX need to convert status to NPReason
|
2000-12-11 23:00:45 +00:00
|
|
|
PRLibrary* lib = nsnull;
|
2001-04-28 02:24:29 +00:00
|
|
|
lib = mInst->fLibrary;
|
2000-09-14 06:13:56 +00:00
|
|
|
|
2001-04-28 02:24:29 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyStreamProc(callbacks->destroystream,
|
2001-03-02 00:29:33 +00:00
|
|
|
npp,
|
|
|
|
&mNPStream,
|
|
|
|
NPRES_DONE), lib);
|
|
|
|
if(error != NPERR_NO_ERROR)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
// check to see if we have a call back
|
|
|
|
if (callbacks->urlnotify != NULL && mNotifyData != nsnull)
|
|
|
|
{
|
|
|
|
PRLibrary* lib = nsnull;
|
|
|
|
lib = mInst->fLibrary;
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
NS_TRY_SAFE_CALL_VOID(CallNPP_URLNotifyProc(callbacks->urlnotify,
|
|
|
|
npp,
|
|
|
|
mNPStream.url,
|
|
|
|
nsPluginReason_Done,
|
|
|
|
mNotifyData), lib);
|
|
|
|
}
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
ns4xPluginStreamListener::GetStreamType(nsPluginStreamType *result)
|
|
|
|
{
|
|
|
|
*result = mStreamType;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-09-14 06:13:56 +00:00
|
|
|
ns4xPluginInstance :: ns4xPluginInstance(NPPluginFuncs* callbacks, PRLibrary* aLibrary)
|
1999-07-07 20:18:27 +00:00
|
|
|
: fCallbacks(callbacks)
|
|
|
|
{
|
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
|
|
|
NS_ASSERTION(fCallbacks != NULL, "null callbacks");
|
|
|
|
|
|
|
|
// Initialize the NPP structure.
|
|
|
|
|
|
|
|
fNPP.pdata = NULL;
|
|
|
|
fNPP.ndata = this;
|
|
|
|
|
2000-09-14 06:13:56 +00:00
|
|
|
fLibrary = aLibrary;
|
1999-07-07 20:18:27 +00:00
|
|
|
mWindowless = PR_FALSE;
|
|
|
|
mTransparent = PR_FALSE;
|
|
|
|
mStarted = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ns4xPluginInstance :: ~ns4xPluginInstance(void)
|
|
|
|
{
|
2000-07-11 21:44:39 +00:00
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("ns4xPluginInstance::~ns4xPluginInstance()\n");
|
2000-07-11 21:44:39 +00:00
|
|
|
#endif
|
|
|
|
#if defined(MOZ_WIDGET_GTK)
|
|
|
|
if (mXtBin)
|
|
|
|
gtk_widget_destroy(mXtBin);
|
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2000-10-27 22:05:07 +00:00
|
|
|
PRBool
|
|
|
|
ns4xPluginInstance :: IsStarted(void)
|
|
|
|
{
|
|
|
|
return mStarted;
|
|
|
|
}
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
NS_IMPL_ISUPPORTS2(ns4xPluginInstance, nsIPluginInstance, nsIScriptablePlugin)
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
|
|
|
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
NS_IMETHODIMP ns4xPluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2000-05-13 04:41:56 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2000-07-11 21:44:39 +00:00
|
|
|
mXtBin = nsnull;
|
2000-04-22 21:47:01 +00:00
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
return InitializePlugin(peer);
|
|
|
|
}
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
NS_IMETHODIMP ns4xPluginInstance::GetPeer(nsIPluginInstancePeer* *resultingPeer)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2000-07-11 21:44:39 +00:00
|
|
|
*resultingPeer = mPeer;
|
|
|
|
NS_IF_ADDREF(*resultingPeer);
|
2000-04-22 20:50:22 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::Start(void)
|
|
|
|
{
|
2000-04-22 20:50:22 +00:00
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Inside ns4xPluginInstance::Start(void)...\n");
|
2000-04-22 20:50:22 +00:00
|
|
|
#endif
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
if(mStarted)
|
|
|
|
return NS_OK;
|
|
|
|
else
|
2000-07-11 21:44:39 +00:00
|
|
|
return InitializePlugin(mPeer);
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::Stop(void)
|
|
|
|
{
|
2001-02-02 23:48:17 +00:00
|
|
|
if (fNPP.pdata == nsnull)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
NPError error;
|
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("ns4xPluginInstance::Stop()\n");
|
2000-07-11 21:44:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
|
|
|
if (mXtBin)
|
|
|
|
gtk_widget_destroy(mXtBin);
|
|
|
|
#endif
|
|
|
|
|
2001-02-02 23:48:17 +00:00
|
|
|
if(!mStarted)
|
|
|
|
return NS_OK;
|
2000-07-11 21:44:39 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
if (fCallbacks->destroy == NULL)
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_ERROR_FAILURE; // XXX right error?
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
NPSavedData *sdata;
|
|
|
|
|
2000-09-14 06:13:56 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_DestroyProc(fCallbacks->destroy, &fNPP, &sdata), fLibrary);
|
2000-09-29 00:46:18 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
mStarted = PR_FALSE;
|
|
|
|
if(error != NPERR_NO_ERROR)
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1999-07-07 20:18:27 +00:00
|
|
|
else
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ns4xPluginInstance::InitializePlugin(nsIPluginInstancePeer* peer)
|
|
|
|
{
|
|
|
|
PRUint16 count = 0;
|
|
|
|
const char* const* names = nsnull;
|
|
|
|
const char* const* values = nsnull;
|
2000-04-22 20:50:22 +00:00
|
|
|
nsresult rv;
|
|
|
|
NPError error;
|
2000-07-11 21:44:39 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
NS_ASSERTION(peer != NULL, "null peer");
|
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
mPeer = peer;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
nsCOMPtr<nsIPluginTagInfo> taginfo = do_QueryInterface(mPeer, &rv);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
if (NS_SUCCEEDED(rv))
|
1999-07-07 20:18:27 +00:00
|
|
|
taginfo->GetAttributes(count, names, values);
|
|
|
|
|
2001-03-02 00:29:33 +00:00
|
|
|
if (fCallbacks->newp == nsnull)
|
2000-07-11 21:44:39 +00:00
|
|
|
return NS_ERROR_FAILURE; // XXX right error?
|
2000-04-22 20:50:22 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
// XXX Note that the NPPluginType_* enums were crafted to be
|
|
|
|
// backward compatible...
|
2000-04-22 20:50:22 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
nsPluginMode mode;
|
|
|
|
nsMIMEType mimetype;
|
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
mPeer->GetMode(&mode);
|
|
|
|
mPeer->GetMIMEType(&mimetype);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-09-14 06:13:56 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_NewProc(fCallbacks->newp,
|
|
|
|
(char *)mimetype,
|
|
|
|
&fNPP,
|
|
|
|
(PRUint16)mode,
|
|
|
|
count,
|
|
|
|
(char**)names,
|
|
|
|
(char**)values,
|
|
|
|
NULL), fLibrary);
|
2000-04-22 20:50:22 +00:00
|
|
|
|
|
|
|
if(error != NPERR_NO_ERROR)
|
|
|
|
rv = NS_ERROR_FAILURE;
|
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
mStarted = PR_TRUE;
|
2000-04-22 20:50:22 +00:00
|
|
|
|
1999-07-07 20:18:27 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::Destroy(void)
|
|
|
|
{
|
|
|
|
// destruction is handled in the Stop call
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
|
|
|
|
{
|
2001-03-02 00:29:33 +00:00
|
|
|
if (fNPP.pdata == nsnull)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2000-05-13 04:41:56 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2000-04-22 20:50:22 +00:00
|
|
|
NPSetWindowCallbackStruct *ws;
|
2000-04-22 21:47:01 +00:00
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
// XXX 4.x plugins don't want a SetWindow(NULL).
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Inside ns4xPluginInstance::SetWindow(%p)...\n", window);
|
2000-04-22 20:50:22 +00:00
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
if (!window || !mStarted)
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
NPError error;
|
|
|
|
|
2000-05-13 04:41:56 +00:00
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2000-04-22 20:50:22 +00:00
|
|
|
// Allocate and fill out the ws_info data
|
|
|
|
if (!window->ws_info) {
|
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("About to create new ws_info...\n");
|
2000-04-22 20:50:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// allocate a new NPSetWindowCallbackStruct structure at ws_info
|
|
|
|
window->ws_info = (NPSetWindowCallbackStruct *)PR_MALLOC(sizeof(NPSetWindowCallbackStruct));
|
2000-07-11 21:44:39 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
if (!window->ws_info)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
ws = (NPSetWindowCallbackStruct *)window->ws_info;
|
|
|
|
|
2000-10-13 01:10:21 +00:00
|
|
|
GdkWindow *win = gdk_window_lookup((XID)window->window);
|
|
|
|
if (win)
|
2000-07-11 21:44:39 +00:00
|
|
|
{
|
2000-10-28 22:17:53 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
printf("About to create new xtbin of %i X %i from %p...\n",
|
2000-10-13 01:10:21 +00:00
|
|
|
window->width, window->height, win);
|
2000-10-28 22:17:53 +00:00
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
#if 1
|
|
|
|
// if we destroyed the plugin when we left the page, we could remove this
|
|
|
|
// code (i believe) the problem here is that the window gets destroyed when
|
|
|
|
// its parent, etc does by changing a page the plugin instance is being
|
|
|
|
// held on to, so when we return to the page, we have a mXtBin, but it is
|
|
|
|
// in a not-so-good state.
|
|
|
|
// --
|
|
|
|
// this is lame. we shouldn't be destroying this everytime, but I can't find
|
|
|
|
// a good way to tell if we need to destroy/recreate the xtbin or not
|
|
|
|
// what if the plugin wants to change the window and not just resize it??
|
|
|
|
// (pav)
|
|
|
|
|
|
|
|
if (mXtBin) {
|
|
|
|
gtk_widget_destroy(mXtBin);
|
|
|
|
mXtBin = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (!mXtBin) {
|
2000-10-13 01:10:21 +00:00
|
|
|
mXtBin = gtk_xtbin_new(win, 0);
|
2000-07-11 21:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_set_usize(mXtBin, window->width, window->height);
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2000-07-11 21:44:39 +00:00
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("About to show xtbin(%p)...\n", mXtBin); fflush(NULL);
|
2000-07-11 21:44:39 +00:00
|
|
|
#endif
|
|
|
|
gtk_widget_show(mXtBin);
|
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("completed gtk_widget_show(%p)\n", mXtBin); fflush(NULL);
|
2000-07-11 21:44:39 +00:00
|
|
|
#endif
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
// fill in window info structure
|
|
|
|
ws->type = 0; // OK, that was a guess!!
|
2000-07-11 21:44:39 +00:00
|
|
|
ws->depth = gdk_rgb_get_visual()->depth;
|
|
|
|
ws->display = GTK_XTBIN(mXtBin)->xtdisplay;
|
2000-04-22 20:50:22 +00:00
|
|
|
ws->visual = GDK_VISUAL_XVISUAL(gdk_rgb_get_visual());
|
2000-10-13 01:10:21 +00:00
|
|
|
ws->colormap = GDK_COLORMAP_XCOLORMAP(gdk_window_get_colormap(win));
|
2000-04-22 20:50:22 +00:00
|
|
|
|
|
|
|
XFlush(ws->display);
|
|
|
|
} // !window->ws_info
|
|
|
|
|
|
|
|
// And now point the NPWindow structures window
|
|
|
|
// to the actual X window
|
2000-07-11 21:44:39 +00:00
|
|
|
window->window = (nsPluginPort *)GTK_XTBIN(mXtBin)->xtwindow;
|
2000-05-13 04:41:56 +00:00
|
|
|
#endif // MOZ_WIDGET_GTK
|
2000-04-22 20:50:22 +00:00
|
|
|
|
|
|
|
if (fCallbacks->setwindow) {
|
|
|
|
// XXX Turns out that NPPluginWindow and NPWindow are structurally
|
|
|
|
// identical (on purpose!), so there's no need to make a copy.
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("About to call CallNPP_SetWindowProc()...\n");
|
2000-04-22 20:50:22 +00:00
|
|
|
fflush(NULL);
|
|
|
|
#endif
|
|
|
|
|
2000-09-14 06:13:56 +00:00
|
|
|
NS_TRY_SAFE_CALL_RETURN(error, CallNPP_SetWindowProc(fCallbacks->setwindow,
|
2000-04-22 20:50:22 +00:00
|
|
|
&fNPP,
|
2000-09-14 06:13:56 +00:00
|
|
|
(NPWindow*) window), fLibrary);
|
2000-09-29 00:46:18 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
|
|
|
|
// XXX In the old code, we'd just ignore any errors coming
|
|
|
|
// back from the plugin's SetWindow(). Is this the correct
|
|
|
|
// behavior?!?
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("Falling out of ns4xPluginInstance::SetWindow()...\n");
|
2000-04-22 20:50:22 +00:00
|
|
|
#endif
|
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* NOTE: the caller must free the stream listener */
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::NewStream(nsIPluginStreamListener** listener)
|
|
|
|
{
|
2000-04-22 20:50:22 +00:00
|
|
|
ns4xPluginStreamListener* stream = new ns4xPluginStreamListener(this,
|
|
|
|
nsnull);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
if(stream == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
1999-10-24 04:41:17 +00:00
|
|
|
NS_ADDREF(stream); // Stabilize
|
|
|
|
|
|
|
|
nsresult res = stream->QueryInterface(kIPluginStreamListenerIID, (void**)listener);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
// Destabilize and avoid leaks.
|
|
|
|
// Avoid calling delete <interface pointer>
|
|
|
|
NS_RELEASE(stream);
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ns4xPluginInstance::NewNotifyStream(nsIPluginStreamListener** listener, void* notifyData)
|
|
|
|
{
|
2000-04-22 20:50:22 +00:00
|
|
|
*listener = new ns4xPluginStreamListener(this, notifyData);
|
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::Print(nsPluginPrint* platformPrint)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
|
|
|
|
{
|
2001-03-12 02:07:15 +00:00
|
|
|
if(!mStarted)
|
|
|
|
return NS_OK;
|
|
|
|
|
2001-03-22 01:37:36 +00:00
|
|
|
if (fNPP.pdata == nsnull || event == nsnull)
|
2001-02-02 23:48:17 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
PRInt16 res = 0;
|
|
|
|
|
|
|
|
if (fCallbacks->event)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
|
|
|
#ifdef XP_MAC
|
2000-04-22 20:50:22 +00:00
|
|
|
res = CallNPP_HandleEventProc(fCallbacks->event,
|
|
|
|
&fNPP,
|
|
|
|
(void*) event->event);
|
1999-07-07 20:18:27 +00:00
|
|
|
#endif
|
|
|
|
|
2000-11-14 00:40:58 +00:00
|
|
|
#if defined(XP_WIN) || defined(XP_OS2)
|
2000-04-22 20:50:22 +00:00
|
|
|
NPEvent npEvent;
|
|
|
|
npEvent.event = event->event;
|
|
|
|
npEvent.wParam = event->wParam;
|
|
|
|
npEvent.lParam = event->lParam;
|
2000-09-14 06:13:56 +00:00
|
|
|
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(res, CallNPP_HandleEventProc(fCallbacks->event,
|
2000-04-22 20:50:22 +00:00
|
|
|
&fNPP,
|
2000-09-14 06:13:56 +00:00
|
|
|
(void*)&npEvent), fLibrary);
|
1999-07-07 20:18:27 +00:00
|
|
|
#endif
|
2000-04-22 20:50:22 +00:00
|
|
|
|
|
|
|
*handled = res;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2000-04-22 20:50:22 +00:00
|
|
|
NS_IMETHODIMP ns4xPluginInstance :: GetValue(nsPluginInstanceVariable variable,
|
|
|
|
void *value)
|
1999-07-07 20:18:27 +00:00
|
|
|
{
|
2001-04-03 22:49:38 +00:00
|
|
|
if(!mStarted)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsresult res = NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
|
|
|
switch (variable)
|
|
|
|
{
|
|
|
|
case nsPluginInstanceVariable_WindowlessBool:
|
|
|
|
*(PRBool *)value = mWindowless;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case nsPluginInstanceVariable_TransparentBool:
|
|
|
|
*(PRBool *)value = mTransparent;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2001-04-03 22:49:38 +00:00
|
|
|
if(fCallbacks->getvalue)
|
|
|
|
{
|
|
|
|
NS_TRY_SAFE_CALL_RETURN(res,
|
|
|
|
CallNPP_GetValueProc(fCallbacks->getvalue,
|
|
|
|
&fNPP,
|
|
|
|
(NPPVariable)variable,
|
|
|
|
value),
|
|
|
|
fLibrary);
|
|
|
|
}
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
return res;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ns4xPluginInstance::GetNPP(NPP* aNPP)
|
|
|
|
{
|
2001-04-03 22:49:38 +00:00
|
|
|
if(aNPP != nsnull)
|
|
|
|
*aNPP = &fNPP;
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ns4xPluginInstance::GetCallbacks(const NPPluginFuncs ** aCallbacks)
|
|
|
|
{
|
2001-04-03 22:49:38 +00:00
|
|
|
if(aCallbacks != nsnull)
|
|
|
|
*aCallbacks = fCallbacks;
|
|
|
|
else
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-07-07 20:18:27 +00:00
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
return NS_OK;
|
1999-07-07 20:18:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ns4xPluginInstance :: SetWindowless(PRBool aWindowless)
|
|
|
|
{
|
|
|
|
mWindowless = aWindowless;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult ns4xPluginInstance :: SetTransparent(PRBool aTransparent)
|
|
|
|
{
|
|
|
|
mTransparent = aTransparent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
/* readonly attribute nsQIResult scriptablePeer; */
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance :: GetScriptablePeer(void * *aScriptablePeer)
|
|
|
|
{
|
|
|
|
if (!aScriptablePeer)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
*aScriptablePeer = nsnull;
|
|
|
|
return GetValue(nsPluginInstanceVariable_ScriptableInstance, aScriptablePeer);
|
|
|
|
}
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
/* readonly attribute nsIIDPtr scriptableInterface; */
|
|
|
|
NS_IMETHODIMP ns4xPluginInstance :: GetScriptableInterface(nsIID * *aScriptableInterface)
|
|
|
|
{
|
|
|
|
if (!aScriptableInterface)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2000-04-22 20:50:22 +00:00
|
|
|
|
2001-04-03 22:49:38 +00:00
|
|
|
*aScriptableInterface = nsnull;
|
|
|
|
return GetValue(nsPluginInstanceVariable_ScriptableIID, (void*)aScriptableInterface);
|
|
|
|
}
|