NOT PART OF BUILD. Cleanup event sink and fire named DOM events, add dispatch tear off to scriptable peer

This commit is contained in:
locka%iol.ie 2002-10-03 21:59:34 +00:00
Родитель ebe472a055
Коммит 81bca70132
6 изменённых файлов: 172 добавлений и 826 удалений

Просмотреть файл

@ -295,6 +295,7 @@ NPError NewControl(const char *pluginType,
if (pSink)
{
pSink->AddRef();
pSink->mPlugin = pData;
CComPtr<IUnknown> control;
pSite->GetControlUnknown(&control);
pSink->SubscribeToEvents(control);

Просмотреть файл

@ -39,6 +39,9 @@ REQUIRES = \
plugin \
string \
dom \
content \
widget \
gfx \
$(NULL)
XPIFILE = mozactivex.xpi
@ -179,6 +182,7 @@ EXTRA_DSO_LDOPTS = \
$(DIST)/lib/$(LIB_PREFIX)string_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)string_obsolete_s.$(LIB_SUFFIX) \
$(DIST)/lib/$(LIB_PREFIX)xpcomglue.$(LIB_SUFFIX) \
$(MOZ_COMPONENT_LIBS) \
$(NSPR_LIBS) \
$(NULL)

Просмотреть файл

@ -1,570 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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/
*
* 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.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Adam Lock <adamlock@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "stdafx.h"
#include "XPCMediaPlayer.h"
#include "nsString.h"
//#############################################################################
// IMPORTANT!!!!!
// I am using Windows Media Player to test how the plugin copes with arbitrary
// scriptability interfaces and to exercise the IHTMLDocument2 and IWebBrowser
// interfaces that many controls expect.
// THIS CODE ISN'T GOING STAY SO DON'T RELY ON IT!!!
//#############################################################################
const IID IID_IWMPCore =
{ 0xD84CCA99, 0xCCE2, 0x11d2, { 0x9E, 0xCC, 0x00, 0x00, 0xF8, 0x08, 0x59, 0x81 } };
/* Header file */
class nsWMPControls :
public nsIWMPControls,
public nsIClassInfoImpl<nsWMPControls>
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWMPCONTROLS
nsWMPScriptablePeer *mOwner;
HRESULT GetIWMPControls(IWMPControls **pc);
nsWMPControls(nsWMPScriptablePeer *pOwner);
virtual ~nsWMPControls();
/* additional members */
};
/* Header file */
class nsWMPSettings :
public nsIWMPSettings,
public nsIClassInfoImpl<nsWMPControls>
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWMPSETTINGS
nsWMPScriptablePeer *mOwner;
HRESULT GetIWMPSettings(IWMPSettings **ps);
nsWMPSettings(nsWMPScriptablePeer *pOwner);
virtual ~nsWMPSettings();
/* additional members */
};
nsWMPScriptablePeer::nsWMPScriptablePeer()
{
NS_INIT_ISUPPORTS();
mControls = new nsWMPControls(this);
mControls->AddRef();
mSettings = new nsWMPSettings(this);
mSettings->AddRef();
}
nsWMPScriptablePeer::~nsWMPScriptablePeer()
{
mSettings->Release();
mControls->Release();
}
NS_IMPL_ADDREF_INHERITED(nsWMPScriptablePeer, nsScriptablePeer)
NS_IMPL_RELEASE_INHERITED(nsWMPScriptablePeer, nsScriptablePeer)
NS_INTERFACE_MAP_BEGIN(nsWMPScriptablePeer)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIWMPCore, nsIWMPPlayer2)
NS_INTERFACE_MAP_ENTRY(nsIWMPPlayer2)
NS_INTERFACE_MAP_END_INHERITING(nsScriptablePeer)
HRESULT
nsWMPScriptablePeer::GetIWMPCore(IWMPCore **pwmpc)
{
*pwmpc = NULL;
CComPtr<IDispatch> disp;
HRESULT hr = GetIDispatch(&disp);
if (FAILED(hr)) return hr;
return disp->QueryInterface(IID_IWMPCore, (void **) pwmpc);
}
///////////////////////////////////////////////////////////////////////////////
// nsIWMPCore
/* attribute AString URL; */
NS_IMETHODIMP nsWMPScriptablePeer::GetURL(nsAString & aURL)
{
CComPtr<IWMPCore> wmpc;
HRESULT hr = GetIWMPCore(&wmpc);
if (FAILED(hr)) return hr;
CComBSTR bstrURL;
hr = wmpc->get_URL(&bstrURL);
if (SUCCEEDED(hr))
{
aURL.Assign(bstrURL.m_str);
}
return HR2NS(hr);
}
NS_IMETHODIMP nsWMPScriptablePeer::SetURL(const nsAString & aURL)
{
CComPtr<IWMPCore> wmpc;
HRESULT hr = GetIWMPCore(&wmpc);
if (FAILED(hr)) return hr;
nsAutoString url(aURL);
CComBSTR bstrURL(url.get());
hr = wmpc->put_URL(bstrURL);
// DEBUG
nsAutoString urlTest;
GetURL(urlTest);
nsAutoString urlBaseTest;
mSettings->GetBaseURL(urlBaseTest);
return HR2NS(hr);
}
/* readonly attribute nsIWMPControls controls; */
NS_IMETHODIMP nsWMPScriptablePeer::GetControls(nsIWMPControls * *aControls)
{
return mControls->QueryInterface(NS_GET_IID(nsIWMPControls), (void **) aControls);
}
/* readonly attribute nsIWMPSettings settings; */
NS_IMETHODIMP nsWMPScriptablePeer::GetSettings(nsIWMPSettings * *aSettings)
{
return mSettings->QueryInterface(NS_GET_IID(nsIWMPSettings), (void **) aSettings);
}
///////////////////////////////////////////////////////////////////////////////
// nsIWMPPlayer2
/* attribute boolean stretchToFit; */
NS_IMETHODIMP nsWMPScriptablePeer::GetStretchToFit(PRBool *aStretchToFit)
{
CComPtr<IWMPCore> wmpc;
HRESULT hr = GetIWMPCore(&wmpc);
if (FAILED(hr)) return hr;
CComQIPtr<IWMPPlayer2> wmpp2 = wmpc;
VARIANT_BOOL bStretchToFit = VARIANT_FALSE;
if (wmpp2)
wmpp2->get_stretchToFit(&bStretchToFit);
*aStretchToFit = (bStretchToFit == VARIANT_TRUE) ? PR_TRUE : PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsWMPScriptablePeer::SetStretchToFit(PRBool aStretchToFit)
{
CComPtr<IWMPCore> wmpc;
HRESULT hr = GetIWMPCore(&wmpc);
if (FAILED(hr)) return hr;
CComQIPtr<IWMPPlayer2> wmpp2 = wmpc;
if (wmpp2)
wmpp2->put_stretchToFit(aStretchToFit ? VARIANT_TRUE : VARIANT_FALSE);
return NS_OK;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Some sanity saving macros to remove some drudgery of this work.
#define IMPL_COMMON(iface) \
CComPtr<iface> i; \
HRESULT hr = Get ## iface (&i); \
if (FAILED(hr)) return mOwner->HR2NS(hr);
#define IMPL_GETPROP_BOOL_NAMED(iface, propname, item, retval) \
IMPL_COMMON(iface) \
VARIANT_BOOL bValue = VARIANT_FALSE; \
nsAutoString strItem(item); \
CComBSTR bstrItem(strItem.get()); \
hr = i->get_ ## propname(bstrItem, &bValue); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
*(retval) = (bValue == VARIANT_TRUE) ? PR_TRUE : PR_FALSE; \
return NS_OK;
#define IMPL_SETPROP_BOOL_NAMED(iface, propname, item, retval) \
IMPL_COMMON(iface) \
VARIANT_BOOL bValue = VARIANT_FALSE; \
nsAutoString strItem(item); \
CComBSTR bstrItem(strItem.get()); \
hr = i->put_ ## propname(bstrItem, bValue); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
return NS_OK;
#define IMPL_GETPROP_BOOL(iface, propname, retval) \
IMPL_COMMON(iface) \
VARIANT_BOOL bValue = VARIANT_FALSE; \
hr = i->get_ ## propname(&bValue); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
*(retval) = (bValue == VARIANT_TRUE) ? PR_TRUE : PR_FALSE; \
return NS_OK;
#define IMPL_SETPROP_BOOL(iface, propname, value) \
IMPL_COMMON(iface) \
hr = i->put_ ## propname((value) ? VARIANT_TRUE : VARIANT_FALSE); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
return NS_OK;
#define IMPL_GETPROP_NUM(iface, propname, nstype, oletype, retval) \
IMPL_COMMON(iface) \
oletype nValue = 0; \
hr = i->get_ ## propname(&nValue); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
*(retval) = (nstype) nValue; \
return NS_OK;
#define IMPL_SETPROP_NUM(iface, propname, nstype, oletype, value) \
IMPL_COMMON(iface) \
hr = i->put_ ## propname((oletype)(value)); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
return NS_OK;
#define IMPL_GETPROP_DOUBLE(iface, propname, retval) \
IMPL_GETPROP_NUM(iface, propname, double, double, retval)
#define IMPL_SETPROP_DOUBLE(iface, propname, retval) \
IMPL_SETPROP_NUM(iface, propname, double, double, retval)
#define IMPL_GETPROP_LONG(iface, propname, retval) \
IMPL_GETPROP_NUM(iface, propname, PRInt32, long, retval)
#define IMPL_SETPROP_LONG(iface, propname, retval) \
IMPL_SETPROP_NUM(iface, propname, PRInt32, long, retval)
#define IMPL_GETPROP_BSTR(iface, propname, retval) \
IMPL_COMMON(iface) \
CComBSTR bstrVal; \
hr = i->get_ ## propname(&bstrVal); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
retval.Assign(bstrVal.m_str); \
return NS_OK;
#define IMPL_SETPROP_BSTR(iface, propname, value) \
IMPL_COMMON(iface) \
nsAutoString val(value); \
CComBSTR bstrVal(val.get()); \
hr = i->put_ ## propname (bstrVal); \
if (FAILED(hr)) return mOwner->HR2NS(hr); \
return NS_OK;
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/* Implementation file */
NS_IMPL_ISUPPORTS2(nsWMPControls, nsIWMPControls, nsIClassInfo)
nsWMPControls::nsWMPControls(nsWMPScriptablePeer *pOwner) :
mOwner(pOwner)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
}
nsWMPControls::~nsWMPControls()
{
/* destructor code */
}
HRESULT
nsWMPControls::GetIWMPControls(IWMPControls **pc)
{
*pc = NULL;
CComPtr<IWMPCore> wmpc;
HRESULT hr = mOwner->GetIWMPCore(&wmpc);
if (FAILED(hr)) return hr;
return wmpc->get_controls(pc);
}
///////////////////////////////////////////////////////////////////////////////
// nsIWMPControls
/* boolean isAvailable (in AString item); */
NS_IMETHODIMP nsWMPControls::IsAvailable(const nsAString &aItem, PRBool *_retval)
{
IMPL_GETPROP_BOOL_NAMED(IWMPControls, isAvailable, aItem, _retval);
}
/* void play (); */
NS_IMETHODIMP nsWMPControls::Play()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->play());
}
/* void stop (); */
NS_IMETHODIMP nsWMPControls::Stop()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->stop());
}
/* void pause (); */
NS_IMETHODIMP nsWMPControls::Pause()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->pause());
}
/* void fastForward (); */
NS_IMETHODIMP nsWMPControls::FastForward()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->fastForward());
}
/* void fastReverse (); */
NS_IMETHODIMP nsWMPControls::FastReverse()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->fastReverse());
}
/* attribute double currentPosition; */
NS_IMETHODIMP nsWMPControls::GetCurrentPosition(double *aCurrentPosition)
{
IMPL_GETPROP_DOUBLE(IWMPControls, currentPosition, aCurrentPosition);
}
NS_IMETHODIMP nsWMPControls::SetCurrentPosition(double aCurrentPosition)
{
IMPL_SETPROP_DOUBLE(IWMPControls, currentPosition, aCurrentPosition);
}
/* readonly attribute AString currentPositionString; */
NS_IMETHODIMP nsWMPControls::GetCurrentPositionString(nsAString &aCurrentPositionString)
{
IMPL_GETPROP_BSTR(IWMPControls, currentPositionString, aCurrentPositionString);
}
/* void next (); */
NS_IMETHODIMP nsWMPControls::Next()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->next());
}
/* void previous (); */
NS_IMETHODIMP nsWMPControls::Previous()
{
IMPL_COMMON(IWMPControls);
return mOwner->HR2NS(i->previous());
}
/* attribute nsIWMPMedia currentItem; */
NS_IMETHODIMP nsWMPControls::GetCurrentItem(nsIWMPMedia * *aCurrentItem)
{
IMPL_COMMON(IWMPControls);
// TODO
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsWMPControls::SetCurrentItem(nsIWMPMedia * aCurrentItem)
{
IMPL_COMMON(IWMPControls);
// TODO
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute long currentMarker; */
NS_IMETHODIMP nsWMPControls::GetCurrentMarker(PRInt32 *aCurrentMarker)
{
IMPL_GETPROP_LONG(IWMPControls, currentMarker, aCurrentMarker);
}
NS_IMETHODIMP nsWMPControls::SetCurrentMarker(PRInt32 aCurrentMarker)
{
IMPL_SETPROP_LONG(IWMPControls, currentMarker, aCurrentMarker);
}
/* void playItem (in nsIWMPMedia aItem); */
NS_IMETHODIMP nsWMPControls::PlayItem(nsIWMPMedia *aItem)
{
IMPL_COMMON(IWMPControls);
// TODO
return NS_ERROR_NOT_IMPLEMENTED;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/* Implementation file */
NS_IMPL_ISUPPORTS2(nsWMPSettings, nsIWMPSettings, nsIClassInfo)
nsWMPSettings::nsWMPSettings(nsWMPScriptablePeer *pOwner) :
mOwner(pOwner)
{
NS_INIT_ISUPPORTS();
/* member initializers and constructor code */
}
nsWMPSettings::~nsWMPSettings()
{
/* destructor code */
}
HRESULT
nsWMPSettings::GetIWMPSettings(IWMPSettings **ps)
{
*ps = NULL;
CComPtr<IWMPCore> wmpc;
HRESULT hr = mOwner->GetIWMPCore(&wmpc);
if (FAILED(hr)) return hr;
return wmpc->get_settings(ps);
}
///////////////////////////////////////////////////////////////////////////////
// nsIWMPControls
/* boolean isAvailable (in AString aItem); */
NS_IMETHODIMP nsWMPSettings::IsAvailable(const nsAString & aItem, PRBool *_retval)
{
IMPL_GETPROP_BOOL_NAMED(IWMPSettings, isAvailable, aItem, _retval);
}
/* attribute boolean autoStart; */
NS_IMETHODIMP nsWMPSettings::GetAutoStart(PRBool *aAutoStart)
{
IMPL_GETPROP_BOOL(IWMPSettings, autoStart, aAutoStart);
}
NS_IMETHODIMP nsWMPSettings::SetAutoStart(PRBool aAutoStart)
{
IMPL_SETPROP_BOOL(IWMPSettings, autoStart, aAutoStart);
}
/* attribute AString baseURL; */
NS_IMETHODIMP nsWMPSettings::GetBaseURL(nsAString & aBaseURL)
{
IMPL_GETPROP_BSTR(IWMPSettings, baseURL, aBaseURL);
}
NS_IMETHODIMP nsWMPSettings::SetBaseURL(const nsAString & aBaseURL)
{
IMPL_SETPROP_BSTR(IWMPSettings, baseURL, aBaseURL);
}
/* attribute AString defaultFrame; */
NS_IMETHODIMP nsWMPSettings::GetDefaultFrame(nsAString & aDefaultFrame)
{
IMPL_GETPROP_BSTR(IWMPSettings, defaultFrame, aDefaultFrame);
}
NS_IMETHODIMP nsWMPSettings::SetDefaultFrame(const nsAString & aDefaultFrame)
{
IMPL_SETPROP_BSTR(IWMPSettings, defaultFrame, aDefaultFrame);
}
/* attribute boolean invokeURLs; */
NS_IMETHODIMP nsWMPSettings::GetInvokeURLs(PRBool *aInvokeURLs)
{
IMPL_GETPROP_BOOL(IWMPSettings, invokeURLs, aInvokeURLs);
}
NS_IMETHODIMP nsWMPSettings::SetInvokeURLs(PRBool aInvokeURLs)
{
IMPL_SETPROP_BOOL(IWMPSettings, invokeURLs, aInvokeURLs);
}
/* attribute boolean mute; */
NS_IMETHODIMP nsWMPSettings::GetMute(PRBool *aMute)
{
IMPL_GETPROP_BOOL(IWMPSettings, mute, aMute);
}
NS_IMETHODIMP nsWMPSettings::SetMute(PRBool aMute)
{
IMPL_SETPROP_BOOL(IWMPSettings, mute, aMute);
}
/* attribute long playCount; */
NS_IMETHODIMP nsWMPSettings::GetPlayCount(PRInt32 *aPlayCount)
{
IMPL_GETPROP_LONG(IWMPSettings, playCount, aPlayCount);
}
NS_IMETHODIMP nsWMPSettings::SetPlayCount(PRInt32 aPlayCount)
{
IMPL_SETPROP_LONG(IWMPSettings, playCount, aPlayCount);
}
/* attribute double rate; */
NS_IMETHODIMP nsWMPSettings::GetRate(double *aRate)
{
IMPL_GETPROP_DOUBLE(IWMPSettings, rate, aRate);
}
NS_IMETHODIMP nsWMPSettings::SetRate(double aRate)
{
IMPL_SETPROP_DOUBLE(IWMPSettings, rate, aRate);
}
/* attribute long balance; */
NS_IMETHODIMP nsWMPSettings::GetBalance(PRInt32 *aBalance)
{
IMPL_GETPROP_LONG(IWMPSettings, balance, aBalance);
}
NS_IMETHODIMP nsWMPSettings::SetBalance(PRInt32 aBalance)
{
IMPL_SETPROP_LONG(IWMPSettings, balance, aBalance);
}
/* attribute long volume; */
NS_IMETHODIMP nsWMPSettings::GetVolume(PRInt32 *aVolume)
{
IMPL_GETPROP_LONG(IWMPSettings, volume, aVolume);
}
NS_IMETHODIMP nsWMPSettings::SetVolume(PRInt32 aVolume)
{
IMPL_SETPROP_LONG(IWMPSettings, volume, aVolume);
}
/* boolean getMode (in AString aMode); */
NS_IMETHODIMP nsWMPSettings::GetMode(const nsAString & aMode, PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void setMode (in AString aMode, in boolean aValue); */
NS_IMETHODIMP nsWMPSettings::SetMode(const nsAString & aMode, PRBool aValue)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* attribute boolean enableErrorDialogs; */
NS_IMETHODIMP nsWMPSettings::GetEnableErrorDialogs(PRBool *aEnableErrorDialogs)
{
IMPL_GETPROP_BOOL(IWMPSettings, enableErrorDialogs, aEnableErrorDialogs);
}
NS_IMETHODIMP nsWMPSettings::SetEnableErrorDialogs(PRBool aEnableErrorDialogs)
{
IMPL_SETPROP_BOOL(IWMPSettings, enableErrorDialogs, aEnableErrorDialogs);
}

Просмотреть файл

@ -48,6 +48,12 @@
#include "nsIVariant.h"
#include "nsMemory.h"
#include "nsIAtom.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventReceiver.h"
#include "nsIEventListenerManager.h"
#include "nsGUIEvent.h"
#include "LegacyPlugin.h"
#include "XPConnect.h"
@ -62,14 +68,17 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
///////////////////////////////////////////////////////////////////////////////
// nsScriptablePeer
nsScriptablePeer::nsScriptablePeer()
nsScriptablePeer::nsScriptablePeer() :
mTearOff(new nsScriptablePeerTearOff(this))
{
NS_INIT_ISUPPORTS();
NS_ASSERTION(mTearOff, "can't create tearoff");
xpc_AddRef();
}
nsScriptablePeer::~nsScriptablePeer()
{
delete mTearOff;
xpc_Release();
}
@ -569,11 +578,11 @@ nsScriptablePeer::SetProperty(const char *propertyName, nsIVariant *propertyValu
HRESULT
nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
FUNCDESC *pFuncDesc = NULL;
HRESULT hr = S_OK;
CComBSTR bstrName;
// Must search compare each member to the dispid...
// Must search and compare each member to the dispid...
if (m_spEventSinkTypeInfo)
{
HRESULT hr = S_OK;
@ -582,28 +591,34 @@ nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wF
if (pAttr)
{
int i;
for (i=0; i < pAttr->cFuncs;i++)
for (i = 0; i < pAttr->cFuncs;i++)
{
hr = m_spEventSinkTypeInfo->GetFuncDesc(i, &pFuncDesc);
if (FAILED(hr))
return hr;
if (pFuncDesc->memid == dispIdMember)
{
UINT cNames = 0;
m_spEventSinkTypeInfo->GetNames(dispIdMember, &bstrName, 1, &cNames);
break;
}
m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
pFuncDesc = NULL;
}
m_spEventSinkTypeInfo->ReleaseTypeAttr(pAttr);
}
}
if (!pFuncDesc)
{
// Return
return S_OK;
}
#ifdef DEBUG
// Dump out some info to look at
ATLTRACE(_T("Invoke(%d)\n"), (int) dispIdMember);
if (pFuncDesc)
{
UINT cNames = 0;
CComBSTR bstrName;
HRESULT hr = m_spEventSinkTypeInfo->GetNames(dispIdMember, &bstrName, 1, &cNames);
// Dump out some info to look at
ATLTRACE(_T("Invoke(%d)\n"), (int) dispIdMember);
ATLTRACE(_T(" "));
@ -665,19 +680,132 @@ nsEventSink::InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wF
}
#endif
// TODO fire an outgoing event with the types in the correct format
if (pFuncDesc)
nsCOMPtr<nsIDOMElement> element;
NPN_GetValue(mPlugin->pPluginInstance, NPNVDOMElement, (void *) &element);
if (element)
{
m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
// TODO Turn VARIANT args into js objects
nsCOMPtr<nsIDOMEventReceiver> eventReceiver = do_QueryInterface(element);
if (eventReceiver)
{
// Get the event manager
nsCOMPtr<nsIEventListenerManager> eventManager;
eventReceiver->GetListenerManager(getter_AddRefs(eventManager));
if (eventManager)
{
nsAutoString keyName(bstrName.m_str);
nsStringKey key(keyName);
nsEvent event;
event.message = NS_USER_DEFINED_EVENT;
event.userType = &key;
// Fire the event!
nsCOMPtr<nsIDOMEvent> domEvent;
nsEventStatus eventStatus;
nsresult rv = eventManager->HandleEvent(nsnull, &event, getter_AddRefs(domEvent),
eventReceiver, NS_EVENT_FLAG_INIT, &eventStatus);
}
}
// TODO Turn js objects back into VARIANTS specifying VT_BYREF
// TODO Turn js return code into VARIANT
// TODO handle js exception and fill in exception info
}
if (pExcepInfo)
{
pExcepInfo->wCode = 0;
}
m_spEventSinkTypeInfo->ReleaseFuncDesc(pFuncDesc);
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// nsScriptablePeerTearOff
nsScriptablePeerTearOff::nsScriptablePeerTearOff(nsScriptablePeer *pOwner) :
mOwner(pOwner)
{
NS_ASSERTION(mOwner, "no owner");
}
HRESULT STDMETHODCALLTYPE nsScriptablePeerTearOff::QueryInterface(REFIID riid, void **ppvObject)
{
if (::IsEqualIID(riid, _uuidof(IDispatch)))
{
*ppvObject = dynamic_cast<IDispatch *>(this);
mOwner->AddRef();
return NS_OK;
}
nsID iid;
memcpy(&iid, &riid, sizeof(nsID));
return mOwner->QueryInterface(iid, ppvObject);
}
ULONG STDMETHODCALLTYPE nsScriptablePeerTearOff::AddRef()
{
return mOwner->AddRef();
}
ULONG STDMETHODCALLTYPE nsScriptablePeerTearOff::Release()
{
return mOwner->Release();
}
// IDispatch
HRESULT STDMETHODCALLTYPE nsScriptablePeerTearOff::GetTypeInfoCount(UINT __RPC_FAR *pctinfo)
{
CComPtr<IDispatch> disp;
if (FAILED(mOwner->GetIDispatch(&disp)))
{
return E_UNEXPECTED;
}
return disp->GetTypeInfoCount(pctinfo);
}
HRESULT STDMETHODCALLTYPE nsScriptablePeerTearOff::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo)
{
CComPtr<IDispatch> disp;
if (FAILED(mOwner->GetIDispatch(&disp)))
{
return E_UNEXPECTED;
}
return disp->GetTypeInfo(iTInfo, lcid, ppTInfo);
}
HRESULT STDMETHODCALLTYPE nsScriptablePeerTearOff::GetIDsOfNames(REFIID riid, LPOLESTR __RPC_FAR *rgszNames, UINT cNames, LCID lcid, DISPID __RPC_FAR *rgDispId)
{
CComPtr<IDispatch> disp;
if (FAILED(mOwner->GetIDispatch(&disp)))
{
return E_UNEXPECTED;
}
return disp->GetIDsOfNames(riid, rgszNames, cNames, lcid, rgDispId);
}
HRESULT STDMETHODCALLTYPE nsScriptablePeerTearOff::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr)
{
CComPtr<IDispatch> disp;
if (FAILED(mOwner->GetIDispatch(&disp)))
{
return E_UNEXPECTED;
}
return disp->Invoke(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Some public methods
static PRUint32 gInstances = 0;
void xpc_AddRef()
@ -718,7 +846,6 @@ CLSID xpc_GetCLSIDForType(const char *mimeType)
USES_CONVERSION;
TCHAR szGUID[64];
ULONG nCount = 64;
LONG lRes;
GUID guidValue = GUID_NULL;
if (keyMimeType.QueryValue(_T("CLSID"), szGUID, &nCount) == ERROR_SUCCESS &&

Просмотреть файл

@ -75,16 +75,20 @@ template <class T> class nsIClassInfoImpl : public nsIClassInfo
{ return NS_ERROR_NOT_IMPLEMENTED; }
};
class nsScriptablePeerTearOff;
class nsScriptablePeer :
public nsIClassInfoImpl<nsScriptablePeer>,
public nsIMozAxPlugin
{
friend nsScriptablePeerTearOff;
protected:
virtual ~nsScriptablePeer();
public:
nsScriptablePeer();
nsScriptablePeerTearOff *mTearOff;
PluginInstanceData* mPlugin;
NS_DECL_ISUPPORTS
@ -98,9 +102,30 @@ protected:
NS_IMETHOD InternalInvoke(const char *aMethod, unsigned int aNumArgs, nsIVariant *aArgs[]);
};
class nsScriptablePeerTearOff :
public IDispatch
{
public:
nsScriptablePeerTearOff(nsScriptablePeer *pOwner);
nsScriptablePeer *mOwner;
// IUnknown
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release( void);
// IDispatch
virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount(UINT __RPC_FAR *pctinfo);
virtual HRESULT STDMETHODCALLTYPE GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID riid, LPOLESTR __RPC_FAR *rgszNames, UINT cNames, LCID lcid, DISPID __RPC_FAR *rgDispId);
virtual HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS __RPC_FAR *pDispParams, VARIANT __RPC_FAR *pVarResult, EXCEPINFO __RPC_FAR *pExcepInfo, UINT __RPC_FAR *puArgErr);
};
class nsEventSink : public CControlEventSink
{
public:
PluginInstanceData* mPlugin;
virtual HRESULT InternalInvoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr);
};

Просмотреть файл

@ -1,241 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is Netscape
* Communications, Inc. Portions created by Netscape are
* Copyright (C) 1999, Mozilla. All Rights Reserved.
*
* Contributor(s):
* Adam Lock <adamlock@netscape.com>
*/
#include "nsISupports.idl"
#include "nsIMozAxPlugin.idl"
[scriptable, uuid(94D55E95-3FAC-11d3-B155-00C04F79FAA6)]
interface nsIWMPMedia : nsISupports
{
/** Determines if the supplied object is the same as the this one */
boolean isIdentical(in nsIWMPMedia aIn);
/** Returns the media URL */
readonly attribute AString sourceURL;
/** Returns or sets the name of the media */
attribute AString name;
/** Returns the original width of the source images */
readonly attribute long width;
/** Returns the original height of the source images */
readonly attribute long height;
/** Returns the number of markers in the file */
readonly attribute long markerCount;
/** Returns the time of a marker */
double markerTime(in long aMarkerNum);
/** Returns the name of a marker */
AString markerName(in long aMarkerNum);
/** Returns duration of current media */
readonly attribute double duration;
/** Returns duration of current media as a string */
readonly attribute AString durationString;
/** Returns the count of the attributes associated with this media */
readonly attribute long attributeCount;
/** Returns the name of the attribute whose index has been specified */
AString getAttributeName(in long aIndex);
/** Returns the value of specified attribute for this media */
AString getItemInfo(in AString aItemName);
/** Sets the value of specified attribute for this media */
void setItemInfo(in AString aItemName, in AString aValue);
/** Gets an item info by atom */
AString getItemInfoByAtom(in long aAtom);
/*
[
id( DISPID_WMPMEDIA_ISMEMBEROF ), helpstring( "Is the media a member of the given playlist" ) ]
HRESULT isMemberOf( [in] IWMPPlaylist* pPlaylist, [out, retval] VARIANT_BOOL* pvarfIsMemberOf );
*/
/** Is the attribute read only */
boolean isReadOnlyItem(in AString aItemName);
};
[scriptable, uuid(74C09E02-F828-11d2-A74B-00A0C905F36E)]
interface nsIWMPControls : nsISupports
{
/** Returns whether or not the specified media functionality is available */
boolean isAvailable(in AString aItem);
/** Begins playing media */
void play();
/** Stops play of media */
void stop();
/** Pauses play of media */
void pause();
/** Fast play of media in forward direction */
void fastForward();
/** Fast play of media in reverse direction */
void fastReverse();
/** Returns or sets the current position in media */
attribute double currentPosition;
/** Returns the current position in media as a string */
readonly attribute AString currentPositionString;
/** Sets the current item to the next item in the playlist */
void next();
/** Sets the current item to the previous item in the playlist */
void previous();
/** Returns/Sets the play item */
attribute nsIWMPMedia currentItem;
/** Returns or sets the current marker */
attribute long currentMarker;
/** Sets the current item and plays it */
void playItem(in nsIWMPMedia aItem);
};
[scriptable, uuid(9104D1AB-80C9-4fed-ABF0-2E6417A6DF14)]
interface nsIWMPSettings : nsISupports
{
/** Returns whether or not the specified media functionality is available */
boolean isAvailable(in AString aItem);
/** Returns or sets whether media should automatically begin playing */
attribute boolean autoStart;
/** Returns or sets the base URL used for relative path resolution */
attribute AString baseURL;
/** Returns or sets the frame location that changes when a URL flip occurs */
attribute AString defaultFrame;
/** Returns or sets whether URL events should spawn a browser */
attribute boolean invokeURLs;
/** Returns or sets whether audio should be muted */
attribute boolean mute;
/** Returns or sets how many times media should play */
attribute long playCount;
/** Returns or sets current playback rate*/
attribute double rate;
/** Returns or sets current audio balance */
attribute long balance;
/** Returns or sets current audio volume */
attribute long volume;
/** Returns the mode of the playlist */
boolean getMode(in AString aMode);
/** Sets the mode of the playlist */
void setMode(in AString aMode, in boolean aValue);
/** Returns or sets whether error dialogs are shown by default when embedded */
attribute boolean enableErrorDialogs;
};
[scriptable, uuid(D84CCA99-CCE2-11d2-9ECC-0000F8085981)]
interface nsIWMPCore : nsISupports
{
/** Returns or sets the URL */
attribute AString URL;
// openState
// playState
/** Returns the control handler */
readonly attribute nsIWMPControls controls;
/** Returns the settings handler */
readonly attribute nsIWMPSettings settings;
// currentMedia
// mediaCollection
// playlistCollection
// versionInfo
// launchURL
// network
// currentPlaylist
// cdromCollection
// closedCaption
/*
readonly attribute isOnline;
[ id(DISPID_WMPCORE_ISONLINE), propget, helpstring( "Returns whether the machine is online." ) ]
HRESULT isOnline( [out, retval] VARIANT_BOOL *pfOnline );
readonly attribute IWMPError error;
[ id(DISPID_WMPCORE_ERROR), propget, helpstring("Returns the error object")]
HRESULT error([out, retval] IWMPError **ppError);
readonly attribute AString status;
[ id(DISPID_WMPCORE_STATUS), propget, helpstring("Returns status string")]
HRESULT status([out, retval] BSTR *pbstrStatus);
*/
};
[scriptable, uuid(0E6B01D1-D407-4c85-BF5F-1C01F6150280)]
interface nsIWMPPlayer2 : nsIWMPCore
{
/*
[ id(DISPID_WMPOCX_ENABLED), propget, helpstring("Returns a boolen value specifying whether or not the control is enabled")]
HRESULT enabled([out, retval] VARIANT_BOOL *pbEnabled);
[ id(DISPID_WMPOCX_ENABLED), propput, helpstring("Sets a boolean value specifying whether or not the control is enabled")]
HRESULT enabled([in] VARIANT_BOOL bEnabled);
[ id(DISPID_WMPOCX_FULLSCREEN), propget, helpstring("Returns a boolean value specifying whether or not the control is in full screen mode")]
HRESULT fullScreen([out, retval] VARIANT_BOOL *pbFullScreen);
[ id(DISPID_WMPOCX_FULLSCREEN), propput, helpstring("Sets a boolean value specifying whether or not the control is in full screen mode")]
HRESULT fullScreen(VARIANT_BOOL bFullScreen);
[ id(DISPID_WMPOCX_ENABLECONTEXTMENU), propget, helpstring("Returns a boolean value specifying whether or not the context menu is enabled on the control")]
HRESULT enableContextMenu([out, retval] VARIANT_BOOL *pbEnableContextMenu);
[ id(DISPID_WMPOCX_ENABLECONTEXTMENU), propput, helpstring("Sets a boolean value specifying whether or not the context menu is enabled on the control")]
HRESULT enableContextMenu(VARIANT_BOOL bEnableContextMenu);
[ id(DISPID_WMPOCX_UIMODE), propput, helpstring("Specifies the ui mode to select")]
HRESULT uiMode([in] BSTR bstrMode);
[ id(DISPID_WMPOCX_UIMODE), propget, helpstring("Returns the currently selected ui mode")]
HRESULT uiMode([out, retval] BSTR *pbstrMode);
[ id(DISPID_WMPOCX2_STRETCHTOFIT), propget, helpstring("Returns a boolen value specifying whether or not video is stretched")]
HRESULT stretchToFit([out, retval] VARIANT_BOOL *pbEnabled);
[ id(DISPID_WMPOCX2_STRETCHTOFIT), propput, helpstring("Sets a boolean value specifying whether or not video is stretched")]
HRESULT stretchToFit([in] VARIANT_BOOL bEnabled);
[ id(DISPID_WMPOCX2_WINDOWLESSVIDEO), propget, helpstring("Returns a boolen value specifying whether or not video is windowless")]
HRESULT windowlessVideo([out, retval] VARIANT_BOOL *pbEnabled);
[ id(DISPID_WMPOCX2_WINDOWLESSVIDEO), propput, helpstring("Sets a boolean value specifying whether or not video is windowless")]
HRESULT windowlessVideo([in] VARIANT_BOOL bEnabled);
*/
/** Returns or sets whether or not video is stretched */
attribute boolean stretchToFit;
};