New xpcom liveconnect apis

git-svn-id: svn://10.0.0.236/trunk@10280 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sudu%netscape.com
1998-09-17 18:13:55 +00:00
parent d59e07a06e
commit e1bee63656
16 changed files with 337 additions and 28 deletions

View File

@@ -26,7 +26,7 @@ CPPSRCS = nsplugin.cpp npglue.cpp
EXPORTS = nppg.h npglue.h nppriv.h
REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom raptor netcnvts plugin plugimpl oji ojiimpl
REQUIRES = lay layer js style applet nspr dbm img util java pref xpcom raptor netcnvts plugin plugimpl oji ojiimpl caps
ifeq ($(subst /,_,$(shell uname -s)),OS2)
CPPSRCS = npwplat.cpp
@@ -39,6 +39,7 @@ ifeq ($(subst /,_,$(shell uname -s)),OS2)
INCLUDES += -I$(DEPTH)/cmd/os2fe/nfc/include -I$(DEPTH)/cmd/os2fe -I$(DEPTH)/cmd/winfe
endif
INCLUDES += -I.
INCLUDES += -I. -I$(DIST)/include/private
$(LIBRARY): $(OBJS)

View File

@@ -47,5 +47,8 @@ INCLUDES += -I$(DEPTH)/cmd/os2fe/nfc/include -I$(DEPTH)/cmd/os2fe -I$(DEPTH)/cmd
endif
INCLUDES += -I$(srcdir)/.
# XXX Add -I$(DIST)/include/private to the above line. Replace DIST to something else in
# autoconf world.
# cyeh asked me to put in this note as we could not figure out a equivalent right now.
$(LIBRARY): $(OBJS)

View File

@@ -29,6 +29,7 @@ EXPORTS = \
LIBRARY_NAME = plug
LINCS = -I$(DIST)\include \
-I$(DIST)\include\private \
-I$(PUBLIC)\plugin \
-I$(PUBLIC)\java \
-I$(PUBLIC)\pref \
@@ -38,7 +39,8 @@ LINCS = -I$(DIST)\include \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\oji \
-I$(PUBLIC)\ojiimpl
-I$(PUBLIC)\ojiimpl \
-I$(PUBLIC)\caps
OBJS = .\$(OBJDIR)\npassoc.obj \
.\$(OBJDIR)\nsplugin.obj \

View File

@@ -32,6 +32,7 @@
#ifdef OJI
#include "jni.h"
#include "jvmmgr.h"
#include "nsCaps.h"
#endif
#ifdef ANTHRAX
@@ -3996,6 +3997,12 @@ NPL_Init()
* available.
*/
NPL_RegisterDefaultConverters();
/*
** Initialize caps manager so that factory for nsCCapsManager gets registered.
** Since nsICapsManager is aggregated with nsIPluginManager, we need to initialize
** caps well upfront. =-= sudu.
*/
nsCapsInitialize();
/* call the platform specific FE code to enumerate and register plugins */
FE_RegisterPlugins();

View File

@@ -381,6 +381,10 @@ protected:
virtual ~nsPluginManager(void);
// aggregated interfaces:
nsIJVMManager* GetJVMMgr(const nsIID& aIID);
nsICapsManager* GetCapsManager(const nsIID& aIID);
nsILiveconnect* GetLiveconnect(const nsIID& aIID);
nsISupports* fJVMMgr;
nsISupports* fMalloc;
nsISupports* fFileUtils;
@@ -389,6 +393,8 @@ protected:
void* fOldCursor;
nsHashtable* fAllocatedMenuIDs;
nsISupports* fCapsManager;
nsISupports* fLiveconnect;
};
extern nsPluginManager* thePluginManager;

View File

@@ -43,8 +43,14 @@
#include <TArray.h>
#endif
#include "prthread.h"
#include "pprthred.h"
#include "prtypes.h"
#include "nsHashtable.h"
#include "nsMalloc.h"
#include "nsICapsManager.h"
#include "nsCCapsManager.h"
#include "nsILiveconnect.h"
#include "intl_csi.h"
@@ -100,7 +106,7 @@ nsresult fromNPError[] = {
nsPluginManager* thePluginManager = NULL;
nsPluginManager::nsPluginManager(nsISupports* outer)
: fJVMMgr(NULL), fMalloc(NULL), fFileUtils(NULL), fAllocatedMenuIDs(NULL)
: fJVMMgr(NULL), fMalloc(NULL), fAllocatedMenuIDs(NULL), fCapsManager(NULL), fLiveconnect(NULL)
{
NS_INIT_AGGREGATED(outer);
}
@@ -120,6 +126,16 @@ nsPluginManager::~nsPluginManager(void)
fFileUtils = NULL;
}
if (fCapsManager) {
fCapsManager->Release();
fCapsManager = NULL;
}
if (fLiveconnect) {
fCapsManager->Release();
fCapsManager = NULL;
}
#ifdef XP_MAC
if (fAllocatedMenuIDs != NULL) {
// Fix me, delete all the elements before deleting the table.
@@ -140,6 +156,7 @@ nsPluginManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInstanceP
return NS_ERROR_OUT_OF_MEMORY;
mgr->AddRef();
*aInstancePtr = mgr->GetInner();
*aInstancePtr = (outer != NULL)? (void *)mgr->GetInner(): (void *)mgr;
return NS_OK;
}
@@ -216,6 +233,17 @@ nsPluginManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr
(void**)&fJVMMgr);
if (fJVMMgr && fJVMMgr->QueryInterface(aIID, aInstancePtr) == NS_OK)
return NS_OK;
nsICapsManager* pNSICapsManager = GetCapsManager(aIID);
if (pNSICapsManager) {
*aInstancePtr = (void*) ((nsISupports*)pNSICapsManager);
return NS_OK;
}
nsILiveconnect* pNSILiveconnect = GetLiveconnect(aIID);
if (pNSILiveconnect) {
*aInstancePtr = (void*) ((nsISupports*)pNSILiveconnect);
return NS_OK;
}
#endif
if (fMalloc == NULL)
nsMalloc::Create((nsIPluginManager*)this, kISupportsIID,
@@ -232,6 +260,86 @@ nsPluginManager::AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr
return NS_NOINTERFACE;
}
nsICapsManager*
nsPluginManager::GetCapsManager(const nsIID& aIID)
{
nsICapsManager* result = NULL;
nsresult err = NS_OK;
PRThread *threadAttached = NULL;
#ifdef OJI
if (fCapsManager == NULL) {
if ( PR_GetCurrentThread() == NULL )
{
threadAttached = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL);
}
NS_DEFINE_CID(kCCapsManagerCID, NS_CCAPSMANAGER_CID);
nsresult err = NS_OK;
err = nsRepository::CreateInstance(kCCapsManagerCID,
(nsIPluginManager*)this, /* outer */
kISupportsIID,
(void **)&fCapsManager);
NS_DEFINE_IID(kICapsManagerIID, NS_ICAPSMANAGER_IID);
if ( (err == NS_OK)
&& (fCapsManager != NULL)
&& (err = (fCapsManager->QueryInterface(kICapsManagerIID, (void**)&result)) == NS_OK)
)
{
((nsCCapsManager*)result)->SetSystemPrivilegeManager();
result->Release();
}
}
if ( (err == NS_OK)
&&(fCapsManager->QueryInterface(aIID, (void**)&result) != NS_OK)
)
{
result = NULL;
}
if (threadAttached != NULL )
{
PR_DetachThread();
}
#endif
return result;
}
nsILiveconnect*
nsPluginManager::GetLiveconnect(const nsIID& aIID)
{
nsILiveconnect* result = NULL;
PRThread *threadAttached = NULL;
#ifdef OJI
nsresult err = NS_OK;
if (fLiveconnect == NULL) {
if ( PR_GetCurrentThread() == NULL )
{
threadAttached = PR_AttachThread(PR_USER_THREAD, PR_PRIORITY_NORMAL, NULL);
}
NS_DEFINE_CID(kCLiveconnectCID, NS_CLIVECONNECT_CID);
nsresult err = NS_OK;
err = nsRepository::CreateInstance(kCLiveconnectCID,
(nsIPluginManager*)this, /* outer */
kISupportsIID,
(void **)&fLiveconnect);
}
if ( (err == NS_OK)
&&(fLiveconnect->QueryInterface(aIID, (void**)&result) != NS_OK)
)
{
result = NULL;
}
if (threadAttached != NULL )
{
PR_DetachThread();
}
#endif
return result;
}
NS_METHOD
nsPluginManager::BeginWaitCursor(void)
{