зеркало из https://github.com/mozilla/pjs.git
First impl of ActiveX control site plugin
This commit is contained in:
Родитель
e8326bc55f
Коммит
90f357a52c
|
@ -0,0 +1,180 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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 "stdafx.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_IID(kIPluginIID, NS_IPLUGIN_IID);
|
||||
|
||||
static CActiveXPlugin *gpFactory = NULL;
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
|
||||
{
|
||||
if (aClass.Equals(kIPluginIID))
|
||||
{
|
||||
if (gpFactory)
|
||||
{
|
||||
gpFactory->AddRef();
|
||||
*aFactory = (nsIFactory *) gpFactory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
CActiveXPlugin *pFactory = new CActiveXPlugin();
|
||||
if (pFactory == NULL)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
pFactory->AddRef();
|
||||
gpFactory = pFactory;
|
||||
*aFactory = pFactory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
extern "C" NS_EXPORT PRBool NSCanUnload(void)
|
||||
{
|
||||
return (_Module.GetLockCount() == 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CActiveXPlugin::CActiveXPlugin()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
|
||||
CActiveXPlugin::~CActiveXPlugin()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports implementation
|
||||
|
||||
|
||||
NS_IMPL_ADDREF(CActiveXPlugin)
|
||||
NS_IMPL_RELEASE(CActiveXPlugin)
|
||||
|
||||
nsresult CActiveXPlugin::QueryInterface(const nsIID& aIID, void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtrResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aInstancePtrResult = (void*) ((nsIPlugin*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIFactoryIID))
|
||||
{
|
||||
*aInstancePtrResult = (void*) ((nsIPlugin*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIPluginIID))
|
||||
{
|
||||
*aInstancePtrResult = (void*) ((nsIPlugin*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIFactory overrides
|
||||
|
||||
NS_IMETHODIMP CActiveXPlugin::CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
CActiveXPluginInstance *pInst = new CActiveXPluginInstance();
|
||||
if (pInst == NULL)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
pInst->AddRef();
|
||||
*aResult = pInst;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CActiveXPlugin::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock)
|
||||
{
|
||||
_Module.Lock();
|
||||
}
|
||||
else
|
||||
{
|
||||
_Module.Unlock();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIPlugin overrides
|
||||
|
||||
static char *gpszMime = "application/x-activex-plugin:smp:Mozilla ActiveX Control Plug-in";
|
||||
static char *gpszPluginName = "Mozilla ActiveX Control Plug-in";
|
||||
static char *gpszPluginDesc = "Hosts ActiveX controls";
|
||||
|
||||
|
||||
NS_IMETHODIMP CActiveXPlugin::Initialize(nsISupports* browserInterfaces)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP CActiveXPlugin::Shutdown(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP CActiveXPlugin::GetMIMEDescription(const char* *resultingDesc)
|
||||
{
|
||||
*resultingDesc = gpszMime;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP CActiveXPlugin::GetValue(nsPluginVariable variable, void *value)
|
||||
{
|
||||
nsresult err = NS_OK;
|
||||
if (variable == nsPluginVariable_NameString)
|
||||
{
|
||||
*((char **)value) = gpszPluginName;
|
||||
}
|
||||
else if (variable == nsPluginVariable_DescriptionString)
|
||||
{
|
||||
*((char **)value) = gpszPluginDesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = NS_ERROR_FAILURE;
|
||||
}
|
||||
return err;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef ACTIVEXPLUGIN_H
|
||||
#define ACTIVEXPLUGIN_H
|
||||
|
||||
class CActiveXPlugin : public nsIPlugin
|
||||
{
|
||||
protected:
|
||||
virtual ~CActiveXPlugin();
|
||||
|
||||
public:
|
||||
CActiveXPlugin();
|
||||
|
||||
// nsISupports overrides
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory overrides
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
// nsIPlugin overrides
|
||||
NS_IMETHOD Initialize(nsISupports* browserInterfaces);
|
||||
NS_IMETHOD Shutdown(void);
|
||||
NS_IMETHOD GetMIMEDescription(const char* *resultingDesc);
|
||||
NS_IMETHOD GetValue(nsPluginVariable variable, void *value);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,146 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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 "stdafx.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIPluginInstanceIID, NS_IPLUGININSTANCE_IID);
|
||||
static NS_DEFINE_IID(kIEventHandlerIID, NS_IEVENTHANDLER_IID);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CActiveXPluginInstance::CActiveXPluginInstance()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mControlSite = NULL;
|
||||
}
|
||||
|
||||
|
||||
CActiveXPluginInstance::~CActiveXPluginInstance()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports implementation
|
||||
|
||||
NS_IMPL_ADDREF(CActiveXPluginInstance)
|
||||
NS_IMPL_RELEASE(CActiveXPluginInstance)
|
||||
|
||||
nsresult CActiveXPluginInstance::QueryInterface(const nsIID& aIID, void** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null pointer");
|
||||
if (nsnull == aInstancePtrResult)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aInstancePtrResult = NULL;
|
||||
|
||||
if (aIID.Equals(kISupportsIID))
|
||||
{
|
||||
*aInstancePtrResult = (void*) ((nsIPluginInstance*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIPluginInstanceIID))
|
||||
{
|
||||
*aInstancePtrResult = (void*) ((nsIPluginInstance*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (aIID.Equals(kIEventHandlerIID))
|
||||
{
|
||||
*aInstancePtrResult = (void*) ((nsIPluginInstance*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIEventHandler overrides
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::HandleEvent(nsPluginEvent* event, PRBool* handled)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// nsIPluginInstance overrides
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::Initialize(nsIPluginInstancePeer* peer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::GetPeer(nsIPluginInstancePeer* *resultingPeer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::Start(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::Stop(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::Destroy(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::SetWindow(nsPluginWindow* window)
|
||||
{
|
||||
if (window)
|
||||
{
|
||||
mPluginWindow = *window;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHODIMP CActiveXPluginInstance::NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::Print(nsPluginPrint* platformPrint)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHODIMP CActiveXPluginInstance::URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP CActiveXPluginInstance::GetValue(nsPluginInstanceVariable variable, void *value)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#ifndef ACTIVEXPLUGININSTANCE_H
|
||||
#define ACTIVEXPLUGININSTANCE_H
|
||||
|
||||
class CActiveXPluginInstance : public nsIPluginInstance
|
||||
{
|
||||
protected:
|
||||
virtual ~CActiveXPluginInstance();
|
||||
|
||||
CControlSite *mControlSite;
|
||||
nsPluginWindow mPluginWindow;
|
||||
|
||||
public:
|
||||
CActiveXPluginInstance();
|
||||
|
||||
// nsISupports overrides
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIEventHandler overrides
|
||||
NS_IMETHOD HandleEvent(nsPluginEvent* event, PRBool* handled);
|
||||
|
||||
// nsIPluginInstance overrides
|
||||
NS_IMETHOD Initialize(nsIPluginInstancePeer* peer);
|
||||
NS_IMETHOD GetPeer(nsIPluginInstancePeer* *resultingPeer);
|
||||
NS_IMETHOD Start(void);
|
||||
NS_IMETHOD Stop(void);
|
||||
NS_IMETHOD Destroy(void);
|
||||
NS_IMETHOD SetWindow(nsPluginWindow* window);
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHOD NewStream(nsIPluginStreamPeer* peer, nsIPluginStream* *result);
|
||||
#endif
|
||||
NS_IMETHOD Print(nsPluginPrint* platformPrint);
|
||||
#ifndef NEW_PLUGIN_STREAM_API
|
||||
NS_IMETHOD URLNotify(const char* url, const char* target, nsPluginReason reason, void* notifyData);
|
||||
#endif
|
||||
NS_IMETHOD GetValue(nsPluginInstanceVariable variable, void *value);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче