1998-08-01 05:46:47 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
|
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
|
|
* http://www.mozilla.org/NPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* NPL.
|
|
|
|
*
|
|
|
|
* The Initial Developer of this code under the NPL is Netscape
|
|
|
|
* Communications Corporation. Portions created by Netscape are
|
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
|
|
* Reserved.
|
|
|
|
*/
|
|
|
|
|
1998-08-05 04:21:36 +00:00
|
|
|
#include "nscore.h"
|
1998-08-01 05:46:47 +00:00
|
|
|
#include "nsPluginInstancePeer.h"
|
1998-08-05 04:21:36 +00:00
|
|
|
#include "nsIPluginInstance.h"
|
1998-09-15 03:48:58 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "prmem.h"
|
1999-04-12 03:12:48 +00:00
|
|
|
#include "prthread.h"
|
1998-09-15 03:48:58 +00:00
|
|
|
#include "plstr.h"
|
1999-01-04 23:43:41 +00:00
|
|
|
#include "prprf.h"
|
1999-03-05 22:53:56 +00:00
|
|
|
#include "nsIFileStream.h"
|
|
|
|
#include "nsFileSpec.h"
|
|
|
|
#include "nsCOMPtr.h"
|
1998-08-01 05:46:47 +00:00
|
|
|
|
1999-04-07 05:20:54 +00:00
|
|
|
#if defined(OJI)
|
1999-03-24 05:40:02 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIScriptContextOwner.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
|
|
|
#include "nsIScriptObjectOwner.h"
|
1999-03-24 07:16:41 +00:00
|
|
|
#endif
|
1999-03-24 05:40:02 +00:00
|
|
|
|
1999-01-25 09:00:42 +00:00
|
|
|
#ifdef XP_PC
|
|
|
|
#include "windows.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#endif
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
nsPluginInstancePeerImpl::nsPluginInstancePeerImpl()
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
1998-08-05 04:21:36 +00:00
|
|
|
mInstance = nsnull;
|
1998-09-15 03:48:58 +00:00
|
|
|
mOwner = nsnull;
|
|
|
|
mMIMEType = nsnull;
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl()
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-08-05 04:21:36 +00:00
|
|
|
mInstance = nsnull;
|
1998-09-15 03:48:58 +00:00
|
|
|
mOwner = nsnull;
|
|
|
|
|
|
|
|
if (nsnull != mMIMEType)
|
|
|
|
{
|
|
|
|
PR_Free((void *)mMIMEType);
|
|
|
|
mMIMEType = nsnull;
|
|
|
|
}
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIPluginTagInfoIID, NS_IPLUGINTAGINFO_IID);
|
1998-09-27 22:24:54 +00:00
|
|
|
static NS_DEFINE_IID(kIPluginTagInfo2IID, NS_IPLUGINTAGINFO2_IID);
|
|
|
|
static NS_DEFINE_IID(kIJVMPluginTagInfoIID, NS_IJVMPLUGINTAGINFO_IID);
|
1998-08-01 05:46:47 +00:00
|
|
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
1999-05-27 23:20:09 +00:00
|
|
|
static NS_DEFINE_IID(kIWindowlessPluginInstancePeerIID, NS_IWINDOWLESSPLUGININSTANCEPEER_IID);//~~~
|
1998-08-01 05:46:47 +00:00
|
|
|
|
1999-01-04 23:43:41 +00:00
|
|
|
NS_IMPL_ADDREF(nsPluginInstancePeerImpl);
|
|
|
|
NS_IMPL_RELEASE(nsPluginInstancePeerImpl);
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** instance)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
|
|
|
if (instance == NULL)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
1999-03-25 03:31:37 +00:00
|
|
|
if (iid.Equals(nsIPluginInstancePeer::GetIID()) || iid.Equals(nsIPluginInstancePeer2::GetIID()))
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1999-03-25 03:31:37 +00:00
|
|
|
*instance = (void *)(nsIPluginInstancePeer2*)this;
|
1998-08-01 05:46:47 +00:00
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-27 23:20:09 +00:00
|
|
|
if (iid.Equals(kIWindowlessPluginInstancePeerIID))//~~~
|
|
|
|
{
|
|
|
|
*instance = (void *)(nsIWindowlessPluginInstancePeer*)this;
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-01 05:46:47 +00:00
|
|
|
if (iid.Equals(kIPluginTagInfoIID))
|
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
*instance = (void *)(nsIPluginTagInfo *)this;
|
1998-08-01 05:46:47 +00:00
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-09-27 22:24:54 +00:00
|
|
|
if (iid.Equals(kIPluginTagInfo2IID))
|
|
|
|
{
|
|
|
|
*instance = (void *)(nsIPluginTagInfo2 *)this;
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iid.Equals(kIJVMPluginTagInfoIID))
|
|
|
|
{
|
|
|
|
*instance = (void *)(nsIJVMPluginTagInfo *)this;
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-08-01 05:46:47 +00:00
|
|
|
if (iid.Equals(kISupportsIID))
|
|
|
|
{
|
|
|
|
*instance = (void *)(nsISupports *)(nsIPluginTagInfo *)this;
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
printf("instance peer getvalue %d called\n", variable);
|
1998-08-05 04:21:36 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMIMEType(nsMIMEType *result)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
if (nsnull == mMIMEType)
|
|
|
|
*result = "";
|
|
|
|
else
|
|
|
|
*result = mMIMEType;
|
|
|
|
|
1998-08-01 05:46:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMode(nsPluginMode *result)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
if (nsnull != mOwner)
|
|
|
|
return mOwner->GetMode(result);
|
|
|
|
else
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
1999-01-04 23:43:41 +00:00
|
|
|
// nsPluginStreamToFile
|
|
|
|
// --------------------
|
|
|
|
// Used to handle NPN_NewStream() - writes the stream as received by the plugin
|
|
|
|
// to a file and at completion (NPN_DestroyStream), tells the browser to load it into
|
|
|
|
// a plugin-specified target
|
|
|
|
|
|
|
|
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
|
|
|
|
|
|
|
class nsPluginStreamToFile : public nsIOutputStream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner);
|
1999-03-23 03:18:12 +00:00
|
|
|
virtual ~nsPluginStreamToFile();
|
1999-01-04 23:43:41 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIOutputStream interface
|
|
|
|
|
|
|
|
NS_IMETHOD
|
1999-03-05 22:53:56 +00:00
|
|
|
Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
|
1999-01-04 23:43:41 +00:00
|
|
|
|
1999-04-22 07:31:03 +00:00
|
|
|
NS_IMETHOD Flush() {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-01-04 23:43:41 +00:00
|
|
|
// nsIBaseStream interface
|
|
|
|
|
|
|
|
NS_IMETHOD
|
|
|
|
Close(void);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
char* mTarget;
|
1999-03-05 22:53:56 +00:00
|
|
|
nsFileURL mFileURL;
|
|
|
|
nsFileSpec mFileSpec;
|
|
|
|
nsCOMPtr<nsIFileOutputStream> mFileThing;
|
1999-01-04 23:43:41 +00:00
|
|
|
nsIPluginInstanceOwner* mOwner;
|
|
|
|
};
|
|
|
|
|
1999-03-11 22:48:58 +00:00
|
|
|
NS_IMPL_ADDREF(nsPluginStreamToFile);
|
|
|
|
NS_IMPL_RELEASE(nsPluginStreamToFile);
|
|
|
|
|
1999-01-04 23:43:41 +00:00
|
|
|
nsPluginStreamToFile::nsPluginStreamToFile(const char* target, nsIPluginInstanceOwner* owner)
|
1999-03-05 22:53:56 +00:00
|
|
|
: mTarget(PL_strdup(target))
|
|
|
|
, mFileURL(nsnull)
|
|
|
|
, mOwner(owner)
|
1999-01-04 23:43:41 +00:00
|
|
|
{
|
1999-03-11 22:48:58 +00:00
|
|
|
NS_INIT_REFCNT();
|
|
|
|
|
1999-01-04 23:43:41 +00:00
|
|
|
// open the file and prepare it for writing
|
|
|
|
char buf[400], tpath[300];
|
|
|
|
#ifdef XP_PC
|
|
|
|
::GetTempPath(sizeof(tpath), tpath);
|
|
|
|
PRInt32 len = PL_strlen(tpath);
|
|
|
|
|
1999-03-05 22:53:56 +00:00
|
|
|
if ((len > 0) && (tpath[len-1] != '\\'))
|
1999-01-04 23:43:41 +00:00
|
|
|
{
|
|
|
|
tpath[len] = '\\';
|
|
|
|
tpath[len+1] = 0;
|
|
|
|
}
|
1999-06-29 11:36:21 +00:00
|
|
|
#elif defined (XP_UNIX) || defined (XP_BEOS)
|
1999-01-04 23:43:41 +00:00
|
|
|
PL_strcpy(tpath, "/tmp/");
|
|
|
|
#else
|
|
|
|
tpath[0] = 0;
|
|
|
|
#endif // XP_PC
|
|
|
|
|
|
|
|
PR_snprintf(buf, sizeof(buf), "%s%08X.html", tpath, this);
|
|
|
|
|
|
|
|
|
1999-03-05 22:53:56 +00:00
|
|
|
// Create and validate the file spec object. (When we have a constructor for the temp
|
|
|
|
// directory, we should use this instead of the per-platform hack above).
|
1999-03-11 22:48:58 +00:00
|
|
|
mFileSpec = PL_strdup(buf);
|
1999-03-05 22:53:56 +00:00
|
|
|
if (mFileSpec.Error())
|
1999-01-04 23:43:41 +00:00
|
|
|
return;
|
|
|
|
|
1999-03-05 22:53:56 +00:00
|
|
|
// create the file
|
|
|
|
nsISupports* ourStream;
|
|
|
|
if (NS_FAILED(NS_NewTypicalOutputFileStream(&ourStream, mFileSpec)))
|
|
|
|
return;
|
|
|
|
mFileThing = do_QueryInterface(ourStream);
|
|
|
|
NS_RELEASE(ourStream);
|
|
|
|
|
|
|
|
mFileThing->Close();
|
1999-01-04 23:43:41 +00:00
|
|
|
|
1999-03-05 22:53:56 +00:00
|
|
|
// construct the URL we'll use later in calls to GetURL()
|
|
|
|
mFileURL = mFileSpec;
|
1999-01-04 23:43:41 +00:00
|
|
|
|
1999-03-13 06:39:17 +00:00
|
|
|
printf("File URL = %s\n", mFileURL.GetAsString());
|
1999-01-04 23:43:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPluginStreamToFile::~nsPluginStreamToFile()
|
|
|
|
{
|
1999-03-05 22:53:56 +00:00
|
|
|
if (nsnull != mTarget)
|
1999-01-04 23:43:41 +00:00
|
|
|
PL_strfree(mTarget);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult nsPluginStreamToFile::QueryInterface(const nsIID& aIID,
|
|
|
|
void** aInstancePtrResult)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
|
|
|
|
|
|
|
if (nsnull == aInstancePtrResult)
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
|
|
|
if (aIID.Equals(kIOutputStreamIID))
|
|
|
|
{
|
|
|
|
*aInstancePtrResult = (void *)((nsIOutputStream *)this);
|
|
|
|
AddRef();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-03-05 22:53:56 +00:00
|
|
|
nsPluginStreamToFile::Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount)
|
1999-01-04 23:43:41 +00:00
|
|
|
{
|
|
|
|
// write the data to the file and update the target
|
1999-03-06 00:07:06 +00:00
|
|
|
nsCOMPtr<nsIFile> thing;
|
|
|
|
thing = do_QueryInterface(mFileThing);
|
|
|
|
thing->Open(mFileSpec, (PR_RDWR|PR_APPEND), 0700);
|
1999-03-05 22:53:56 +00:00
|
|
|
PRUint32 actualCount;
|
|
|
|
mFileThing->Write(aBuf, aCount, &actualCount);
|
|
|
|
mFileThing->Close();
|
1999-03-13 06:39:17 +00:00
|
|
|
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
|
1999-01-04 23:43:41 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsPluginStreamToFile::Close(void)
|
|
|
|
{
|
1999-03-13 06:39:17 +00:00
|
|
|
mOwner->GetURL(mFileURL.GetAsString(), mTarget, nsnull);
|
1999-01-04 23:43:41 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
// end of nsPluginStreamToFile
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::NewStream(nsMIMEType type, const char* target, nsIOutputStream* *result)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1999-01-04 23:43:41 +00:00
|
|
|
nsresult rv;
|
|
|
|
nsPluginStreamToFile* stream = new nsPluginStreamToFile(target, mOwner);
|
1999-07-30 23:51:53 +00:00
|
|
|
if(stream == nsnull)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
1999-01-04 23:43:41 +00:00
|
|
|
|
|
|
|
rv = stream->QueryInterface(kIOutputStreamIID, (void **)result);
|
|
|
|
|
|
|
|
return rv;
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::ShowStatus(const char* message)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-27 22:24:54 +00:00
|
|
|
if (nsnull != mOwner)
|
|
|
|
return mOwner->ShowStatus(message);
|
|
|
|
else
|
|
|
|
return NS_ERROR_FAILURE;
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttributes(PRUint16& n, const char*const*& names, const char*const*& values)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
if (nsnull != mOwner)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
nsIPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetAttributes(n, names, values);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-15 03:48:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
n = 0;
|
|
|
|
names = nsnull;
|
|
|
|
values = nsnull;
|
1998-09-27 22:24:54 +00:00
|
|
|
|
1998-09-15 03:48:58 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1998-08-01 05:46:47 +00:00
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAttribute(const char* name, const char* *result)
|
1998-08-01 05:46:47 +00:00
|
|
|
{
|
1998-09-15 03:48:58 +00:00
|
|
|
if (nsnull != mOwner)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
nsIPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetAttribute(name, result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = "";
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagType(nsPluginTagType *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetTagType(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = nsPluginTagType_Unknown;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetTagText(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetTagText(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
1998-09-15 03:48:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = "";
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameters(PRUint16& n, const char*const*& names, const char*const*& values)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetParameters(n, names, values);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
n = 0;
|
|
|
|
names = nsnull;
|
|
|
|
values = nsnull;
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetParameter(const char* name, const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetParameter(name, result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = "";
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-03 02:51:39 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentBase(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetDocumentBase(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = "";
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetDocumentEncoding(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetDocumentEncoding(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = "";
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetAlignment(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetAlignment(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = "";
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetWidth(PRUint32 *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetWidth(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetHeight(PRUint32 *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetHeight(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderVertSpace(PRUint32 *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetBorderVertSpace(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetBorderHorizSpace(PRUint32 *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetBorderHorizSpace(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetUniqueID(PRUint32 *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIPluginTagInfo2 *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIPluginTagInfo2IID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetUniqueID(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetCode(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIJVMPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetCode(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetCodeBase(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIJVMPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetCodeBase(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetArchive(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIJVMPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetArchive(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetName(const char* *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIJVMPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetName(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMayScript(PRBool *result)
|
1998-09-27 22:24:54 +00:00
|
|
|
{
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
{
|
|
|
|
nsIJVMPluginTagInfo *tinfo;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = mOwner->QueryInterface(kIJVMPluginTagInfoIID, (void **)&tinfo);
|
|
|
|
|
|
|
|
if (NS_OK == rv)
|
|
|
|
{
|
|
|
|
rv = tinfo->GetMayScript(result);
|
|
|
|
NS_RELEASE(tinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*result = 0;
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::SetWindowSize(PRUint32 width, PRUint32 height)
|
1998-09-15 03:48:58 +00:00
|
|
|
{
|
|
|
|
printf("instance peer setwindowsize called\n");
|
1998-08-05 04:21:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-03-24 05:40:02 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSWindow(JSObject* *outJSWindow)
|
|
|
|
{
|
|
|
|
*outJSWindow = NULL;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
1999-04-07 05:20:54 +00:00
|
|
|
#if defined(OJI)
|
1999-03-24 05:40:02 +00:00
|
|
|
nsIDocument* document = nsnull;
|
|
|
|
if (mOwner->GetDocument(&document) == NS_OK) {
|
|
|
|
nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner();
|
|
|
|
if (nsnull != contextOwner) {
|
|
|
|
nsIScriptGlobalObject *global = nsnull;
|
|
|
|
contextOwner->GetScriptGlobalObject(&global);
|
|
|
|
nsIScriptContext* context = nsnull;
|
|
|
|
contextOwner->GetScriptContext(&context);
|
|
|
|
if (nsnull != global && nsnull != context) {
|
|
|
|
static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID);
|
|
|
|
nsIScriptObjectOwner* window = nsnull;
|
|
|
|
if (global->QueryInterface(kIScriptObjectOwnerIID, (void **)&window) == NS_OK) {
|
|
|
|
rv = window->GetScriptObject(context, (void**)outJSWindow);
|
|
|
|
NS_RELEASE(window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_IF_RELEASE(global);
|
|
|
|
NS_IF_RELEASE(context);
|
|
|
|
NS_RELEASE(contextOwner);
|
|
|
|
}
|
|
|
|
NS_RELEASE(document);
|
|
|
|
}
|
1999-03-24 07:16:41 +00:00
|
|
|
#endif
|
1999-03-24 05:40:02 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-08-05 04:21:36 +00:00
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSThread(PRUint32 *outThreadID)
|
|
|
|
{
|
|
|
|
*outThreadID = mThreadID;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-05-08 16:33:40 +00:00
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
|
|
|
|
{
|
|
|
|
*outContext = NULL;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
#if defined(OJI)
|
|
|
|
nsIDocument* document = nsnull;
|
|
|
|
if (mOwner->GetDocument(&document) == NS_OK) {
|
|
|
|
nsIScriptContextOwner* contextOwner = document->GetScriptContextOwner();
|
|
|
|
if (nsnull != contextOwner) {
|
|
|
|
nsIScriptContext* context = nsnull;
|
|
|
|
if (contextOwner->GetScriptContext(&context) == NS_OK) {
|
|
|
|
*outContext = (JSContext*) context->GetNativeContext();
|
|
|
|
NS_RELEASE(context);
|
|
|
|
rv = NS_OK;
|
|
|
|
}
|
|
|
|
NS_RELEASE(contextOwner);
|
|
|
|
}
|
|
|
|
NS_RELEASE(document);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
|
1998-09-15 03:48:58 +00:00
|
|
|
const nsMIMEType aMIMEType)
|
1998-08-05 04:21:36 +00:00
|
|
|
{
|
1999-01-25 09:00:42 +00:00
|
|
|
//don't add a ref to prevent circular references... MMP
|
1998-09-15 03:48:58 +00:00
|
|
|
mOwner = aOwner;
|
|
|
|
|
|
|
|
aOwner->GetInstance(mInstance);
|
|
|
|
//release this one too... MMP
|
|
|
|
NS_IF_RELEASE(mInstance);
|
|
|
|
|
|
|
|
if (nsnull != aMIMEType)
|
|
|
|
{
|
|
|
|
mMIMEType = (nsMIMEType)PR_Malloc(PL_strlen(aMIMEType) + 1);
|
|
|
|
|
|
|
|
if (nsnull != mMIMEType)
|
|
|
|
PL_strcpy((char *)mMIMEType, aMIMEType);
|
|
|
|
}
|
1999-04-12 03:12:48 +00:00
|
|
|
|
|
|
|
// record the thread we were created in.
|
|
|
|
mThreadID = PRUint32(PR_GetCurrentThread());
|
1998-08-05 04:21:36 +00:00
|
|
|
|
1998-08-01 05:46:47 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-15 03:48:58 +00:00
|
|
|
|
1999-05-07 22:06:47 +00:00
|
|
|
nsresult nsPluginInstancePeerImpl::SetOwner(nsIPluginInstanceOwner *aOwner)
|
|
|
|
{
|
|
|
|
// do not add refs to these objects to prevent circular references
|
|
|
|
mOwner = aOwner;
|
|
|
|
aOwner->GetInstance(mInstance);
|
|
|
|
NS_IF_RELEASE(mInstance);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-04-12 03:12:48 +00:00
|
|
|
nsresult nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner *&aOwner)
|
1998-09-15 03:48:58 +00:00
|
|
|
{
|
|
|
|
aOwner = mOwner;
|
|
|
|
NS_IF_ADDREF(mOwner);
|
|
|
|
|
|
|
|
if (nsnull != mOwner)
|
|
|
|
return NS_OK;
|
|
|
|
else
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-01-04 23:43:41 +00:00
|
|
|
|
1999-01-25 09:00:42 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRect(nsPluginRect *invalidRect)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRegion(nsPluginRegion invalidRegion)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsPluginInstancePeerImpl::ForceRedraw(void)
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-06-04 22:32:27 +00:00
|
|
|
/*void
|
|
|
|
nsPluginInstancePeerImpl::SetStopped()
|
|
|
|
{
|
|
|
|
mStopped = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPluginInstancePeerImpl::SetStarted()
|
|
|
|
{
|
|
|
|
mStopped = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsPluginInstancePeerImpl::IsStopped(PRBool *result)
|
|
|
|
{
|
|
|
|
*result = mStopped;
|
|
|
|
}*/
|