From 7e93511cca79f3855d7aa61124b0ec48fda73adb Mon Sep 17 00:00:00 2001 From: "michaelp%netscape.com" Date: Sun, 2 Aug 1998 03:20:22 +0000 Subject: [PATCH] additional plugins work. --- modules/plugin/base/src/Makefile | 1 + modules/plugin/base/src/makefile.win | 1 + modules/plugin/base/src/nsIPluginHost.h | 3 +- modules/plugin/base/src/nsPluginHostImpl.cpp | 41 +++++++++ modules/plugin/base/src/nsPluginHostImpl.h | 8 ++ .../plugin/base/src/nsPluginStreamPeer.cpp | 90 +++++++++++++++++++ modules/plugin/base/src/nsPluginStreamPeer.h | 54 +++++++++++ modules/plugin/nglsrc/Makefile | 1 + modules/plugin/nglsrc/makefile.win | 1 + modules/plugin/nglsrc/nsIPluginHost.h | 3 +- modules/plugin/nglsrc/nsPluginHostImpl.cpp | 41 +++++++++ modules/plugin/nglsrc/nsPluginHostImpl.h | 8 ++ modules/plugin/nglsrc/nsPluginStreamPeer.cpp | 90 +++++++++++++++++++ modules/plugin/nglsrc/nsPluginStreamPeer.h | 54 +++++++++++ 14 files changed, 394 insertions(+), 2 deletions(-) create mode 100644 modules/plugin/base/src/nsPluginStreamPeer.cpp create mode 100644 modules/plugin/base/src/nsPluginStreamPeer.h create mode 100644 modules/plugin/nglsrc/nsPluginStreamPeer.cpp create mode 100644 modules/plugin/nglsrc/nsPluginStreamPeer.h diff --git a/modules/plugin/base/src/Makefile b/modules/plugin/base/src/Makefile index 8a986c0018b5..2ee5ad906fe6 100644 --- a/modules/plugin/base/src/Makefile +++ b/modules/plugin/base/src/Makefile @@ -34,6 +34,7 @@ CPPSRCS = \ ns4xPluginInstance.cpp \ ns4xPluginStream.cpp \ nsPluginInstancePeer.cpp \ + nsPluginStreamPeer.cpp \ $(NULL) REQUIRES = raptor plugin java xpcom diff --git a/modules/plugin/base/src/makefile.win b/modules/plugin/base/src/makefile.win index 46de9b2cb6e8..6de3c26fbf1c 100644 --- a/modules/plugin/base/src/makefile.win +++ b/modules/plugin/base/src/makefile.win @@ -38,6 +38,7 @@ OBJS = \ .\$(OBJDIR)\ns4xPluginInstance.obj \ .\$(OBJDIR)\ns4xPluginStream.obj \ .\$(OBJDIR)\nsPluginInstancePeer.obj \ + .\$(OBJDIR)\nsPluginStreamPeer.obj \ $(NULL) LINCS= \ diff --git a/modules/plugin/base/src/nsIPluginHost.h b/modules/plugin/base/src/nsIPluginHost.h index b86d5d977217..7b503f27adf6 100644 --- a/modules/plugin/base/src/nsIPluginHost.h +++ b/modules/plugin/base/src/nsIPluginHost.h @@ -21,12 +21,13 @@ #include "xp_core.h" #include "nsplugindefs.h" +#include "nsIFactory.h" #define NS_IPLUGINHOST_IID \ { 0x264c0640, 0x1c31, 0x11d2, \ { 0xa8, 0x2e, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } } -struct nsIPluginHost : public nsISupports +struct nsIPluginHost : public nsIFactory { public: diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index ad0c26490879..53b068e43fa2 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -23,6 +23,7 @@ #include "ns4xPlugin.h" #include "nsMalloc.h" //this is evil... #include "nsPluginInstancePeer.h" +#include "nsPluginStreamPeer.h" #ifdef XP_PC #include "windows.h" @@ -108,7 +109,9 @@ nsPluginTag :: ~nsPluginTag() static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID); +static NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); static NS_DEFINE_IID(kIMallocIID, NS_IMALLOC_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); nsPluginHostImpl :: nsPluginHostImpl() @@ -158,6 +161,13 @@ nsresult nsPluginHostImpl :: QueryInterface(const nsIID& aIID, return NS_OK; } + if (aIID.Equals(kIFactoryIID)) + { + *aInstancePtrResult = (void *)((nsIFactory *)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIMallocIID)) { *aInstancePtrResult = mMalloc; @@ -630,3 +640,34 @@ printf("unable to find plugin to handle %s\n", aMimeType); return NS_ERROR_FAILURE; } } + +nsresult nsPluginHostImpl :: CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) + return NS_ERROR_NULL_POINTER; + + nsISupports *inst = nsnull; + + if (aIID.Equals(kIPluginStreamPeerIID)) + inst = (nsISupports *)(nsIPluginStreamPeer *)new nsPluginStreamPeer(); + + if (inst == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + // We didn't get the right interface, so clean up + delete inst; + } + + return res; +} + +nsresult nsPluginHostImpl :: LockFactory(PRBool aLock) +{ + // Not implemented in simplest case. + return NS_OK; +} diff --git a/modules/plugin/base/src/nsPluginHostImpl.h b/modules/plugin/base/src/nsPluginHostImpl.h index 07168081f75a..ee14d3a33f4e 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.h +++ b/modules/plugin/base/src/nsPluginHostImpl.h @@ -109,6 +109,14 @@ public: NS_IMETHOD InstantiatePlugin(char *aMimeType, nsIPluginInstance ** aPluginInst); + //nsIFactory interface + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + private: char *mPluginPath; nsPluginTag *mPlugins; diff --git a/modules/plugin/base/src/nsPluginStreamPeer.cpp b/modules/plugin/base/src/nsPluginStreamPeer.cpp new file mode 100644 index 000000000000..222fcc4cefe8 --- /dev/null +++ b/modules/plugin/base/src/nsPluginStreamPeer.cpp @@ -0,0 +1,90 @@ +/* -*- 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. + */ + +#include "nsPluginStreamPeer.h" + +nsPluginStreamPeer :: nsPluginStreamPeer() +{ +} + +nsPluginStreamPeer :: ~nsPluginStreamPeer() +{ +} + +NS_IMPL_ADDREF(nsPluginStreamPeer); +NS_IMPL_RELEASE(nsPluginStreamPeer); + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); +//static NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); + +NS_IMETHODIMP nsPluginStreamPeer :: QueryInterface(const nsIID& iid, void** instance) +{ + if (instance == NULL) + return NS_ERROR_NULL_POINTER; + + if (iid.Equals(kIPluginStreamPeerIID)) + { + *instance = (void *)(nsIPluginStreamPeer *)this; + AddRef(); + return NS_OK; + } + else if (iid.Equals(kISupportsIID)) + { + *instance = (void *)(nsISupports *)this; + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetURL(const char* *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetEnd(PRUint32 *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetLastModified(PRUint32 *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetNotifyData(void* *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetReason(nsPluginReason *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetMIMEType(nsMIMEType *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: Initialize(void) +{ + return NS_OK; +} diff --git a/modules/plugin/base/src/nsPluginStreamPeer.h b/modules/plugin/base/src/nsPluginStreamPeer.h new file mode 100644 index 000000000000..c2c90788ebdb --- /dev/null +++ b/modules/plugin/base/src/nsPluginStreamPeer.h @@ -0,0 +1,54 @@ +/* -*- 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. + */ + +#ifndef nsPluginStreamPeer_h___ +#define nsPluginStreamPeer_h___ + +#include "nsIPluginStreamPeer.h" + +class nsPluginStreamPeer : public nsIPluginStreamPeer +{ +public: + nsPluginStreamPeer(); + ~nsPluginStreamPeer(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD + GetURL(const char* *result); + + NS_IMETHOD + GetEnd(PRUint32 *result); + + NS_IMETHOD + GetLastModified(PRUint32 *result); + + NS_IMETHOD + GetNotifyData(void* *result); + + NS_IMETHOD + GetReason(nsPluginReason *result); + + NS_IMETHOD + GetMIMEType(nsMIMEType *result); + + NS_IMETHOD + Initialize(void); +}; + +#endif diff --git a/modules/plugin/nglsrc/Makefile b/modules/plugin/nglsrc/Makefile index 8a986c0018b5..2ee5ad906fe6 100644 --- a/modules/plugin/nglsrc/Makefile +++ b/modules/plugin/nglsrc/Makefile @@ -34,6 +34,7 @@ CPPSRCS = \ ns4xPluginInstance.cpp \ ns4xPluginStream.cpp \ nsPluginInstancePeer.cpp \ + nsPluginStreamPeer.cpp \ $(NULL) REQUIRES = raptor plugin java xpcom diff --git a/modules/plugin/nglsrc/makefile.win b/modules/plugin/nglsrc/makefile.win index 46de9b2cb6e8..6de3c26fbf1c 100644 --- a/modules/plugin/nglsrc/makefile.win +++ b/modules/plugin/nglsrc/makefile.win @@ -38,6 +38,7 @@ OBJS = \ .\$(OBJDIR)\ns4xPluginInstance.obj \ .\$(OBJDIR)\ns4xPluginStream.obj \ .\$(OBJDIR)\nsPluginInstancePeer.obj \ + .\$(OBJDIR)\nsPluginStreamPeer.obj \ $(NULL) LINCS= \ diff --git a/modules/plugin/nglsrc/nsIPluginHost.h b/modules/plugin/nglsrc/nsIPluginHost.h index b86d5d977217..7b503f27adf6 100644 --- a/modules/plugin/nglsrc/nsIPluginHost.h +++ b/modules/plugin/nglsrc/nsIPluginHost.h @@ -21,12 +21,13 @@ #include "xp_core.h" #include "nsplugindefs.h" +#include "nsIFactory.h" #define NS_IPLUGINHOST_IID \ { 0x264c0640, 0x1c31, 0x11d2, \ { 0xa8, 0x2e, 0x00, 0x40, 0x95, 0x9a, 0x28, 0xc9 } } -struct nsIPluginHost : public nsISupports +struct nsIPluginHost : public nsIFactory { public: diff --git a/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/modules/plugin/nglsrc/nsPluginHostImpl.cpp index ad0c26490879..53b068e43fa2 100644 --- a/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -23,6 +23,7 @@ #include "ns4xPlugin.h" #include "nsMalloc.h" //this is evil... #include "nsPluginInstancePeer.h" +#include "nsPluginStreamPeer.h" #ifdef XP_PC #include "windows.h" @@ -108,7 +109,9 @@ nsPluginTag :: ~nsPluginTag() static NS_DEFINE_IID(kIPluginManagerIID, NS_IPLUGINMANAGER_IID); static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID); +static NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); static NS_DEFINE_IID(kIMallocIID, NS_IMALLOC_IID); +static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); nsPluginHostImpl :: nsPluginHostImpl() @@ -158,6 +161,13 @@ nsresult nsPluginHostImpl :: QueryInterface(const nsIID& aIID, return NS_OK; } + if (aIID.Equals(kIFactoryIID)) + { + *aInstancePtrResult = (void *)((nsIFactory *)this); + AddRef(); + return NS_OK; + } + if (aIID.Equals(kIMallocIID)) { *aInstancePtrResult = mMalloc; @@ -630,3 +640,34 @@ printf("unable to find plugin to handle %s\n", aMimeType); return NS_ERROR_FAILURE; } } + +nsresult nsPluginHostImpl :: CreateInstance(nsISupports *aOuter, + const nsIID &aIID, + void **aResult) +{ + if (aResult == NULL) + return NS_ERROR_NULL_POINTER; + + nsISupports *inst = nsnull; + + if (aIID.Equals(kIPluginStreamPeerIID)) + inst = (nsISupports *)(nsIPluginStreamPeer *)new nsPluginStreamPeer(); + + if (inst == NULL) + return NS_ERROR_OUT_OF_MEMORY; + + nsresult res = inst->QueryInterface(aIID, aResult); + + if (res != NS_OK) { + // We didn't get the right interface, so clean up + delete inst; + } + + return res; +} + +nsresult nsPluginHostImpl :: LockFactory(PRBool aLock) +{ + // Not implemented in simplest case. + return NS_OK; +} diff --git a/modules/plugin/nglsrc/nsPluginHostImpl.h b/modules/plugin/nglsrc/nsPluginHostImpl.h index 07168081f75a..ee14d3a33f4e 100644 --- a/modules/plugin/nglsrc/nsPluginHostImpl.h +++ b/modules/plugin/nglsrc/nsPluginHostImpl.h @@ -109,6 +109,14 @@ public: NS_IMETHOD InstantiatePlugin(char *aMimeType, nsIPluginInstance ** aPluginInst); + //nsIFactory interface + + NS_IMETHOD CreateInstance(nsISupports *aOuter, + REFNSIID aIID, + void **aResult); + + NS_IMETHOD LockFactory(PRBool aLock); + private: char *mPluginPath; nsPluginTag *mPlugins; diff --git a/modules/plugin/nglsrc/nsPluginStreamPeer.cpp b/modules/plugin/nglsrc/nsPluginStreamPeer.cpp new file mode 100644 index 000000000000..222fcc4cefe8 --- /dev/null +++ b/modules/plugin/nglsrc/nsPluginStreamPeer.cpp @@ -0,0 +1,90 @@ +/* -*- 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. + */ + +#include "nsPluginStreamPeer.h" + +nsPluginStreamPeer :: nsPluginStreamPeer() +{ +} + +nsPluginStreamPeer :: ~nsPluginStreamPeer() +{ +} + +NS_IMPL_ADDREF(nsPluginStreamPeer); +NS_IMPL_RELEASE(nsPluginStreamPeer); + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIPluginStreamPeerIID, NS_IPLUGINSTREAMPEER_IID); +//static NS_DEFINE_IID(kISeekablePluginStreamPeerIID, NS_ISEEKABLEPLUGINSTREAMPEER_IID); + +NS_IMETHODIMP nsPluginStreamPeer :: QueryInterface(const nsIID& iid, void** instance) +{ + if (instance == NULL) + return NS_ERROR_NULL_POINTER; + + if (iid.Equals(kIPluginStreamPeerIID)) + { + *instance = (void *)(nsIPluginStreamPeer *)this; + AddRef(); + return NS_OK; + } + else if (iid.Equals(kISupportsIID)) + { + *instance = (void *)(nsISupports *)this; + AddRef(); + return NS_OK; + } + + return NS_NOINTERFACE; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetURL(const char* *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetEnd(PRUint32 *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetLastModified(PRUint32 *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetNotifyData(void* *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetReason(nsPluginReason *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: GetMIMEType(nsMIMEType *result) +{ + return NS_OK; +} + +NS_IMETHODIMP nsPluginStreamPeer :: Initialize(void) +{ + return NS_OK; +} diff --git a/modules/plugin/nglsrc/nsPluginStreamPeer.h b/modules/plugin/nglsrc/nsPluginStreamPeer.h new file mode 100644 index 000000000000..c2c90788ebdb --- /dev/null +++ b/modules/plugin/nglsrc/nsPluginStreamPeer.h @@ -0,0 +1,54 @@ +/* -*- 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. + */ + +#ifndef nsPluginStreamPeer_h___ +#define nsPluginStreamPeer_h___ + +#include "nsIPluginStreamPeer.h" + +class nsPluginStreamPeer : public nsIPluginStreamPeer +{ +public: + nsPluginStreamPeer(); + ~nsPluginStreamPeer(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD + GetURL(const char* *result); + + NS_IMETHOD + GetEnd(PRUint32 *result); + + NS_IMETHOD + GetLastModified(PRUint32 *result); + + NS_IMETHOD + GetNotifyData(void* *result); + + NS_IMETHOD + GetReason(nsPluginReason *result); + + NS_IMETHOD + GetMIMEType(nsMIMEType *result); + + NS_IMETHOD + Initialize(void); +}; + +#endif