Exemplo n.º 1
0
HRESULT	CISEMMManager::OnEvent(const EventNumberEnum EventNumber, _bstr_t Description)
{
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[2];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;
	
	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[1] = EventNumber;
			pvars[0] = (BSTR)Description;
			DISPPARAMS disp = { pvars, NULL, 2, 0 };
			hr = pDispatch->Invoke(0x9, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;
	return varResult.scode;
}
Exemplo n.º 2
0
HRESULT CISEMMManager::OnQuoteTickWorse(const CComVariant& varParams, 
		long lTickWorseLevel, _bstr_t bsReason)
{
		CComVariant varResult;
		int nConnectionIndex;
		CComVariant* pvars = new CComVariant[3];
		int nConnections = m_vec.GetSize();
		
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
			Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				VariantClear(&varResult);
				pvars[2] = varParams;
				pvars[1] = lTickWorseLevel;
				pvars[0] = (BSTR)bsReason;
				DISPPARAMS disp = { pvars, NULL, 3, 0 };
				pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
			}
		}
		delete[] pvars;
		return varResult.scode;
}
Exemplo n.º 3
0
HRESULT CISEMMManager::OnTrade(const CComVariant& varParams)
{
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[1];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;
	
	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[0] = varParams;
			DISPPARAMS disp = { pvars, NULL, 1, 0 };
			hr = pDispatch->Invoke(0x8, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;
	return varResult.scode;
}
void CMyTrackPriceInfoWithNotify::Subscribed(CComVariant &varParams)
{
	ATLTRACE(_T("CMyTrackPriceInfoWithNotify::OnSubscribed\n"));
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[1];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;

	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[0] = varParams;
			DISPPARAMS disp = { pvars, NULL, 1, 0 };
			hr = pDispatch->Invoke(0x4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

}
Exemplo n.º 5
0
//-----------------------------------------------------------------------------------------------//
HRESULT CTrackDataStructureProvider::OnError(ErrorNumberEnum enumError, _bstr_t bstrDescription, 
									RequestsTypeEnum enumRequest, CComVariant &varRequest)
{
	ATLTRACE(_T("CMyTrackStructureProvider::OnError\n"));

	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[4];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;
	
	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[3] = enumError;
			pvars[2] = (BSTR)bstrDescription;
			pvars[1] = enumRequest;
			pvars[0] = varRequest;
			DISPPARAMS disp = { pvars, NULL, 4, 0 };
			hr = pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;
	return varResult.scode;
}
Exemplo n.º 6
0
//-----------------------------------------------------------------------------------------------//
HRESULT CTrackDataStructureProvider::OnOption(CComVariant &varParams, CComVariant &varResults, CComVariant &varIsLastOption)
{
	ATLTRACE(_T("CMyTrackStructureProvider::OnOption\n"));
	HRESULT  hr = S_OK ;
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[3];
	int nConnections = m_vec.GetSize();
	
	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[2] = varParams;
			pvars[1] = varResults;
			pvars[0] = varIsLastOption;
			DISPPARAMS disp = { pvars, NULL, 3, 0 };
			hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;
	return varResult.scode;
}
Exemplo n.º 7
0
Atom MSIDispatchConsumer::getAtomProperty(Atom name) const {
    AXTam *axcore = (AXTam *)core();
    IDispatch *disp = (IDispatch *)getDispatch();
    if (!axcore->isString(name))
        axcore->toplevel->throwTypeError(kCheckTypeFailedError);
    DISPID id;

    OLECHAR *olename = (OLECHAR *)axcore->atomToString(name)->c_str();
    HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id);
    if (hr == DISP_E_UNKNOWNNAME) {
        // not a name this object has - do we need to see if its builtin?
        // If we call ScriptObject::getAtomProperty() with an unknown name,
        // it throws an exception, where we just want undefinedAtom.
        // XXX - but we must call the base for now to resolve 'Object' etc
        //return ScriptObject::getAtomProperty(name);
        return undefinedAtom;
    }
    if (FAILED(hr))
        axcore->throwCOMConsumerError(hr);
    EXCEPINFO ei;
    DISPPARAMS params = {NULL, NULL, 0, 0};
    CComVariant ret;
    hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_PROPERTYGET, &params, &ret, &ei, NULL);
    if (FAILED(hr))
        axcore->throwCOMConsumerError(hr, &ei);
    return axcore->toAtom(ret);
}
Exemplo n.º 8
0
HRESULT CISEMMManager::OnQuotesSent(const CComVariant& varParams, ErrorNumberEnum Error, bstr_t bsOrderID)
{
		CComVariant varResult;
		int nConnectionIndex;
		CComVariant* pvars = new CComVariant[3];
		int nConnections = m_vec.GetSize();
		
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
			Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				VariantClear(&varResult);
				pvars[2] = varParams;
				pvars[1] = Error;
				pvars[0] = (BSTR)bsOrderID;
				DISPPARAMS disp = { pvars, NULL, 3, 0 };
				HRESULT hr = pDispatch->Invoke(0x4, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
			}
		}
		delete[] pvars;
		return varResult.scode;
}
Exemplo n.º 9
0
/*
 * Get the location of a fighter.
 */
bool CComPlugin::getFighterLocation(const int party, const int idx, int &x, int &y)
{
    if (!m_plugin) return false;

    const MEMBERID member = m_members[MEMBER_GETFIGHTERLOCATION];
    if (member == DISPID_UNKNOWN) return false;

    // Arguments in *reverse* order.
    CComVariant vars[4], ret;
    vars[3] = party;
    vars[2] = idx;

    vars[1].vt = VT_I4 | VT_BYREF;
    vars[1].plVal = (long *)&x;

    vars[0].vt = VT_I4 | VT_BYREF;
    vars[0].plVal = (long *)&y;

    DISPPARAMS params = {vars, NULL, 4, 0};

    HRESULT hr = m_plugin->Invoke(
                     member,
                     IID_NULL,
                     LOCALE_USER_DEFAULT,
                     DISPATCH_METHOD,
                     &params,
                     &ret,
                     NULL,
                     NULL
                 );

    return (ret.boolVal == VARIANT_TRUE);
}
Exemplo n.º 10
0
HRESULT CHyperFeedPriceProvider::OnLastQuote(const CComVariant &varParams,const CComVariant &varResults)
{
	ATLTRACE(_T("CHyperFeedPriceProvider::OnLastQuote\n"));
		CComVariant varResult;
		int nConnectionIndex;
		CComVariant* pvars = new CComVariant[2];
		int nConnections = m_vec.GetSize();
		HRESULT hr = S_OK;
		
		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
			Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				VariantClear(&varResult);
				pvars[1] = varParams;
				pvars[0] = varResults;
				DISPPARAMS disp = { pvars, NULL, 2, 0 };
				hr = pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
			}
		}
		delete[] pvars;

		if(FAILED(hr)) return hr;
		return varResult.scode;
}
Exemplo n.º 11
0
		VARIANT ObjectInstance::Execute(const wstring methodName, DISPPARAMS inputParameters)
		{
			if (this->objectHandle == NULL)
			{
				throw new RuntimeHostException("ObjectHandle is no longer valid");
			}

			VARIANT v;
			DISPID	dispid;
			LPOLESTR szMethodName = _bstr_t(methodName.data());
			VARIANT result;
			EXCEPINFO pExcepInfo;
			unsigned int puArgErr = 0;
			
			// Initialze the variants
			VariantInit(&v);
			VariantInit(&result);
					
			HRESULT hr = this->objectHandle->Unwrap(&v);
			if (!SUCCEEDED(hr))
			{
				throw new RuntimeHostException("Unable to retrieve method information");
			}

			// The .NET Component should expose IDispatch
			IDispatch* pdispatch = v.pdispVal;				

			// Retrieve the DISPID
			hr = pdispatch->GetIDsOfNames(
								IID_NULL,
								&szMethodName,
								1,
								LOCALE_SYSTEM_DEFAULT,
								&dispid);
			if (!SUCCEEDED(hr))
			{
				throw new RuntimeHostException("Unable to retrieve method information");
			}

			// Invoke the method on the IDispatch Interface
			hr = pdispatch->Invoke(
							dispid,
							IID_NULL,
							LOCALE_SYSTEM_DEFAULT,
							DISPATCH_METHOD,
							&inputParameters,
							&result,
							&pExcepInfo,
							&puArgErr);

			if (!SUCCEEDED(hr))
			{
				throw new RuntimeHostException("Error on method execution");
			}

			return result;
		}
Exemplo n.º 12
0
// Prints the WORD document if everything goes fine
// otherwise error is returned
int CAutoWord::PrintDocument(char *strFilePath)
{
	// Open the document
	VARIANT varRetVal;
	EXCEPINFO excepInfo; 	// this variable contains exception info if any Invoke call fails
	VARIANTARG varg;
	varg.vt = VT_BSTR;
	varg.bstrVal = _bstr_t(strFilePath); // this is the MS-word document filename, must be changed to a valid filename that exists on disk
	DISPPARAMS dpOpen = { &varg, NULL, 1, 0 };
	DISPID dispOpenID;
	LPOLESTR szOpenDoc = L"Open";
	HRESULT hr = m_pDocuments->GetIDsOfNames(IID_NULL, &szOpenDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispOpenID);
	hr = m_pDocuments->Invoke(dispOpenID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpOpen, &varRetVal, &excepInfo, NULL);
	if (FAILED(hr))
	{
		OutputDebugString("Error opening the document\n");
		Destroy();
		return -1;
	}
	
	IDispatch* pDocument = varRetVal.pdispVal;

	// Call PrintOut method of the opened Document 
	DISPPARAMS dpPrint = { NULL, NULL, 0, 0 };
	DISPID dispPrintID;
	LPOLESTR szPrintDoc = L"PrintOut";
	hr = pDocument->GetIDsOfNames(IID_NULL, &szPrintDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispPrintID);
	hr = pDocument->Invoke(dispPrintID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpPrint, &varRetVal, NULL, NULL);
	if (FAILED(hr))
	{
		OutputDebugString("The document could not be printed\n");
		Destroy();
		return -1;
	}

	// Close the document now.
	DISPPARAMS dpClose = { NULL, NULL, 0, 0 };
	DISPID dispCloseID;
	LPOLESTR szCloseDoc = L"Close";
	hr = pDocument->GetIDsOfNames(IID_NULL, &szCloseDoc, 1, LOCALE_SYSTEM_DEFAULT, &dispCloseID);
	hr = pDocument->Invoke(dispCloseID, IID_NULL, LOCALE_SYSTEM_DEFAULT, DISPATCH_METHOD, &dpClose, &varRetVal, &excepInfo, NULL);
	
	return 0;
}
void HostTimerDispatcher::invoke(UINT timerId)
{
	IDispatch* pDisp = NULL;
	if (!m_timerDispatchMap.query(timerId, pDisp) || !pDisp)
		return;

	VARIANTARG args[1];
	args[0].vt = VT_I4;
	args[0].lVal = timerId;
	DISPPARAMS dispParams = {args, NULL, _countof(args), 0};
	pDisp->Invoke(DISPID_VALUE, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &dispParams, NULL, NULL, NULL);
}
Exemplo n.º 14
0
HRESULT CISEStdPriceProvider::OnQuoteUpdate(const CComVariant &varParams,const  CComVariant &varResults)
{
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[2];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;
		
    CComVariant _varResults;

    _ISEQuoteUpdateResult ResultSrc(varResults);
    _QuoteUpdateResult ResultDest;
	ResultDest.Init();

	ResultDest->UpdateDateTime = 0;
	ResultDest->SeqNum = 0;
	ResultDest->BidPrice = ResultSrc->BidPrice;
	ResultDest->AskPrice = ResultSrc->AskPrice;
	ResultDest->BidSize = ResultSrc->BidSize;
	ResultDest->AskSize = ResultSrc->AskSize;
	ResultDest->Currency = SysAllocString(ResultSrc->Currency);
	ResultDest->LotSize = 0;
	ResultDest->LastPrice = ResultSrc->LastPrice;
	ResultDest->OpenInterest = 0;
	ResultDest->Volume = 0;
	ResultDest->Exchange = 0;

    ResultDest.CopyTo(_varResults);

	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[1] = varParams;
			pvars[0] = _varResults;
			DISPPARAMS disp = { pvars, NULL, 2, 0 };
			hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;

	return varResult.scode;
}
Exemplo n.º 15
0
HRESULT __stdcall ScriptHost::Run(WCHAR *procname, DISPPARAMS *args, VARIANT *results)
{
    assert(procname != nullptr);

    if (procname == nullptr)
        return E_POINTER;

	IDispatch *disp = nullptr;
	_activeScript->GetScriptDispatch(nullptr, &disp);
	DISPID dispid = 0;
	disp->GetIDsOfNames(IID_NULL, &procname, 1, LOCALE_SYSTEM_DEFAULT, &dispid);
	EXCEPINFO info;
	UINT argErr;
	args->rgdispidNamedArgs = &dispid;
	HRESULT hr = disp->Invoke(dispid, IID_NULL, NULL, DISPATCH_METHOD, args, results, &info, &argErr);
	return hr;
}
Exemplo n.º 16
0
HRESULT CISEStdStructureProvider::OnStock(const CComVariant &varParams,const CComVariant &varResults, const CComVariant &varIsLastStock)
{
	CComVariant varResult;
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[2];
	int nConnections = m_vec.GetSize();
	HRESULT hr = S_OK;

    CComVariant _varResults;

    _ISEStockResults ResultSrc(varResults);
    _StockResults ResultDest;
	ResultDest.Init();

    ResultDest->StockType = ResultSrc->StockType;
    ResultDest->DivFreq = 0;
    ResultDest->DivLastDate = 0;
    ResultDest->DivAmount = 0;
    ResultDest->Currency = SysAllocString(ResultSrc->Currency);
    ResultDest->Description = SysAllocString(ResultSrc->Description);
    ResultDest->LotSize = ResultSrc->LotSize;
    ResultDest->Exchange = SysAllocString(ResultSrc->Exchange);

    ResultDest.CopyTo(_varResults);

	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			VariantClear(&varResult);
			pvars[1] = varParams;
			pvars[0] = _varResults;
			DISPPARAMS disp = { pvars, NULL, 2, 0 };
			hr = pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
		}
	}
	delete[] pvars;

	if(FAILED(hr)) return hr;
	return varResult.scode;
}
Exemplo n.º 17
0
/*
 * Terminate the plugin.
 */
void CComPlugin::terminate()
{
    if (!m_plugin) return;

    const MEMBERID member = m_members[MEMBER_TERMINATE];
    if (member == DISPID_UNKNOWN) return;

    DISPPARAMS params = {NULL, NULL, 0, 0};

    m_plugin->Invoke(
        member,
        IID_NULL,
        LOCALE_USER_DEFAULT,
        DISPATCH_METHOD,
        &params,
        NULL,
        NULL,
        NULL
    );
}
Exemplo n.º 18
0
void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS *pDispParams)
{
    map<DWORD,LPUNKNOWN>::iterator end = _connections.end();
    map<DWORD,LPUNKNOWN>::iterator iter = _connections.begin();

    while( iter != end )
    {
        LPUNKNOWN pUnk = iter->second;
        if( NULL != pUnk )
        {
            IDispatch *pDisp;
            if( SUCCEEDED(pUnk->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp)) )
            {
                pDisp->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, pDispParams, NULL, NULL, NULL);
                pDisp->Release();
            }
        }
        ++iter;
    }
};
Exemplo n.º 19
0
void CEasyPDFCtrl::GetURL()
{
	USES_CONVERSION;  

	IOleContainer* pContainer = NULL;
	IHTMLDocument* pDoc = NULL;
	m_pClientSite->GetContainer( &pContainer );
	if ( pContainer != NULL )
	pContainer->QueryInterface( IID_IHTMLDocument, (void**)&pDoc );

	HRESULT hresult;
	OLECHAR FAR* szMember = T2W(_T("Initilize"));

	DISPID dispid;
	DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};

	IDispatch * pdisp = NULL;
	pDoc->get_Script(&pdisp);
	hresult = pdisp->GetIDsOfNames(IID_NULL,&szMember,1, LOCALE_SYSTEM_DEFAULT,&dispid);
	hresult = pdisp->Invoke(dispid,IID_NULL,LOCALE_USER_DEFAULT,DISPATCH_METHOD,&dispparamsNoArgs, NULL, NULL, NULL);
	pContainer->Release();
}
Exemplo n.º 20
0
VOID CDrawMenu::Fire_MenuClick(int Item, BSTR ID)
{
	int nConnectionIndex;
	CComVariant* pvars = new CComVariant[2];
	int nConnections = m_vec.GetSize();
	
	for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
	{
		Lock();
		CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
		Unlock();
		IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
		if (pDispatch != NULL)
		{
			pvars[0] = ID;
			pvars[1] = Item;
			DISPPARAMS disp = { pvars, NULL, 2, 0 };
			pDispatch->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);
		}
	}
	delete[] pvars;
}
Exemplo n.º 21
0
/*
 * Open a menu.
 */
int CComPlugin::menu(const int request)
{
    if (!m_plugin) return 0;

    const MEMBERID member = m_members[MEMBER_MENU];
    if (member == DISPID_UNKNOWN) return 0;

    CComVariant vars[] = {request}, ret;
    DISPPARAMS params = {vars, NULL, 1, 0};

    HRESULT hr = m_plugin->Invoke(
                     member,
                     IID_NULL,
                     LOCALE_USER_DEFAULT,
                     DISPATCH_METHOD,
                     &params,
                     &ret,
                     NULL,
                     NULL
                 );

    return ret.intVal;
}
Exemplo n.º 22
0
// ScriptObject::setMultinameProperty checks if our traits have 'needsHashtable' -
// but we don't.  Its possible 'needsHashtable' is misnamed and means more like 'isDynamic'
// so we should revisit this...
void MSIDispatchConsumer::setMultinameProperty(Multiname* name, Atom value)
{
    // its possible we should just call setStringProperty(), which calls
    // setAtomProperty(), and we should add our impl there - but let's see
    // if we can get away without that for now...
    DISPID id;
    AXTam *axcore = (AXTam *)core();
    OLECHAR *olename = (OLECHAR *)name->getName()->c_str();
    IDispatch *disp = (IDispatch *)getDispatch();
    HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id);
    // ScriptObject::setMultinameProperty just throws an exception, so
    // no point trying it...
    if (FAILED(hr))
        axcore->throwCOMConsumerError(hr);
    // Now create args for the call.
    EXCEPINFO ei;
    CComVariant arg;
    axcore->atomToVARIANT(value, &arg);
    DISPPARAMS params = {&arg, NULL, 1, 0};
    hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_PROPERTYPUT, &params, NULL, &ei, NULL);
    if (FAILED(hr))
        axcore->throwCOMConsumerError(hr, &ei);
}
Exemplo n.º 23
0
/*
 * Query to check whether we support a function.
 */
bool CComPlugin::query(const STRING function)
{
    if (!m_plugin) return false;

    const MEMBERID member = m_members[MEMBER_QUERY];
    if (member == DISPID_UNKNOWN) return false;

    CComVariant vars[] = {function.c_str()}, ret;
    DISPPARAMS params = {vars, NULL, 1, 0};

    m_plugin->Invoke(
        member,
        IID_NULL,
        LOCALE_USER_DEFAULT,
        DISPATCH_METHOD,
        &params,
        &ret,
        NULL,
        NULL
    );

    return (ret.boolVal == VARIANT_TRUE);
}
Exemplo n.º 24
0
/*
 * Check whether we are a certain type of plugin.
 */
bool CComPlugin::plugType(const int request)
{
    if (!m_plugin) return false;

    const MEMBERID member = m_members[MEMBER_TYPE];
    if (member == DISPID_UNKNOWN) return false;

    CComVariant vars[] = {request}, ret;
    DISPPARAMS params = {vars, NULL, 1, 0};

    HRESULT hr = m_plugin->Invoke(
                     member,
                     IID_NULL,
                     LOCALE_USER_DEFAULT,
                     DISPATCH_METHOD,
                     &params,
                     &ret,
                     NULL,
                     NULL
                 );

    return (ret.boolVal == VARIANT_TRUE);
}
Exemplo n.º 25
0
HRESULT CHyperFeedPriceInfoWithNotify::OnQuoteUpdate(const CComVariant &varParams, const CComVariant &varResults)
{
	ATLTRACE(_T("CHyperFeedPriceInfoWithNotify::OnQuoteUpdate\n"));
	CComVariant varResult;
	HRESULT hr = S_OK;
	
	try
	{
		int nConnectionIndex;
		CComVariant* pvars = new CComVariant[2];
		int nConnections = m_vec.GetSize();
		

		for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
		{
			Lock();
			CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
			Unlock();
			IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
			if (pDispatch != NULL)
			{
				VariantClear(&varResult);
				pvars[1] = varParams;
				pvars[0] = varResults;
				DISPPARAMS disp = { pvars, NULL, 2, 0 };
				hr = pDispatch->Invoke(0x2, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
			}
		}
		delete[] pvars;
	}
	_CATCH_COM_EXCEPTION_RETURN_COM( L"OnQuoteUpdate Failed")
	_CATCH_UNHANDLED_EXCEPTION_RETURN_COM;

	if(FAILED(hr)) return hr;
	return varResult.scode;
	
	}
Exemplo n.º 26
0
/*
 * Execute an RPGCode function.
 */
bool CComPlugin::execute(const STRING line, int &retValDt, STRING &retValLit, double &retValNum, const short usingReturn)
{
    if (!m_plugin) return false;

    const MEMBERID member = m_members[MEMBER_EXECUTE];
    if (member == DISPID_UNKNOWN) return false;

    // Arguments in *reverse* order.
    CComVariant vars[5], ret;
    vars[4] = line.c_str();
    vars[3].vt = VT_I4 | VT_BYREF;
    vars[3].plVal = (long *)&retValDt;
    vars[2].vt = VT_BSTR | VT_BYREF;
    BSTR bstr = SysAllocString(L"");
    vars[2].pbstrVal = &bstr;
    vars[1].vt = VT_R8 | VT_BYREF;
    vars[1].pdblVal = &retValNum;
    vars[0] = bool(usingReturn);

    DISPPARAMS params = {vars, NULL, 5, 0};

    HRESULT hr = m_plugin->Invoke(
                     member,
                     IID_NULL,
                     LOCALE_USER_DEFAULT,
                     DISPATCH_METHOD,
                     &params,
                     &ret,
                     NULL,
                     NULL
                 );

    retValLit = getString(bstr);
    SysFreeString(bstr);

    return (ret.boolVal == VARIANT_TRUE);
}
// Strategy: only says that is validated if we can really confirm it
bool WindowsLPIAction::_isWindowsXPValidated()
{
	CLSID lcsid;
	IDispatch* disp;
	VARIANT dispRes;
	EXCEPINFO *pExcepInfo = NULL;
	unsigned int *puArgErr = NULL;
	bool bRslt;	

	CoInitialize(NULL);
	
	if (!SUCCEEDED(CLSIDFromString(L"{17492023-C23A-453E-A040-C7C580BBF700}", &lcsid)))
	{
		g_log.Log(L"WindowsLPIAction::IsWindowsValidated. CLSIDFromString failed, passed: 0");
		return false;
	}
	 
    if (!SUCCEEDED(CoCreateInstance(lcsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IDispatch), (void**)&disp)))
	{
		g_log.Log(L"WindowsLPIAction::IsWindowsValidated. CreateInstance failed, passed: 0");
		return false;
	}

	DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};

	HRESULT hr = disp->Invoke(FUNCTION_ID, IID_NULL,
                               LOCALE_SYSTEM_DEFAULT, 
                               DISPATCH_METHOD,
                               &dispparamsNoArgs, &dispRes,
                               pExcepInfo, puArgErr);

	disp->Release();

	bRslt = wcscmp(dispRes.bstrVal, L"0") == 0;
	g_log.Log(L"WindowsLPIAction::IsWindowsValidated. Result: '%s', passed %u", dispRes.bstrVal,  (wchar_t *)bRslt);
	return bRslt;
}
Exemplo n.º 28
0
Atom MSIDispatchConsumer::callProperty(avmplus::Multiname *name, int argc, avmplus::Atom *argv)
{
    // Not sure how to best handle this re 'builtin' names, such as toString()
    // XXX - need a map of DISPIDs to speed things up, and/or optimizations
    // using the typelib.
    DISPID id;
    AXTam *axcore = (AXTam *)core();
    IDispatch *disp = (IDispatch *)getDispatch();
    OLECHAR *olename = (OLECHAR *)name->getName()->c_str();
    HRESULT hr = disp->GetIDsOfNames(IID_NULL, &olename, 1, 0, &id);
    if (hr == DISP_E_UNKNOWNNAME) {
        // not a name this object has - see if its builtin.
        return ScriptObject::callProperty(name, argc, argv);
    }
    if (FAILED(hr))
        axcore->throwCOMConsumerError(hr);
    // Now create args for the call.
    EXCEPINFO ei;
    CComVariant *pArgs = new CComVariant[argc];
    //memset(pArgs, 0, sizeof(VARIANT) * argc);
    // Take care to not early exit without cleaning up variants
    int i;
    for (i=0; i<argc; i++) {
        //VariantInit(pArgs+i);
        axcore->atomToVARIANT(argv[i+1], pArgs+i);
    }
    DISPPARAMS params = {pArgs, NULL, argc, 0};
    CComVariant ret;
    hr = disp->Invoke(id, IID_NULL, 0, DISPATCH_METHOD, &params, &ret, &ei, NULL);
    //for (i=0;i<argc;i++)
    //	VariantClear(pArg+i);
    delete [] pArgs;
    if (FAILED(hr))
        axcore->throwCOMConsumerError(hr, &ei);
    return axcore->toAtom(ret);
}
Exemplo n.º 29
0
/*
 * Start a fight.
 */
int CComPlugin::fight(const int enemyCount, const int skillLevel, const STRING background, const bool canRun)
{
    if (!m_plugin) return 0;

    const MEMBERID member = m_members[MEMBER_FIGHT];
    if (member == DISPID_UNKNOWN) return 0;

    // Arguments in *reverse* order.
    CComVariant vars[] = {int(canRun), background.c_str(), skillLevel, enemyCount}, ret;
    DISPPARAMS params = {vars, NULL, 4, 0};

    HRESULT hr = m_plugin->Invoke(
                     member,
                     IID_NULL,
                     LOCALE_USER_DEFAULT,
                     DISPATCH_METHOD,
                     &params,
                     &ret,
                     NULL,
                     NULL
                 );

    return ret.intVal;
}
Exemplo n.º 30
0
/*
 * Send a fight message.
 */
int CComPlugin::fightInform(const int sourcePartyIndex, const int sourceFighterIndex, const int targetPartyIndex, const int targetFighterIndex, const int sourceHpLost, const int sourceSmpLost, const int targetHpLost, const int targetSmpLost, const STRING strMessage, const int attackCode)
{
    if (!m_plugin) return 0;

    const MEMBERID member = m_members[MEMBER_FIGHTINFORM];
    if (member == DISPID_UNKNOWN) return 0;

    // Arguments in *reverse* order.
    CComVariant vars[] = {attackCode, strMessage.c_str(), targetSmpLost, targetHpLost, sourceSmpLost, sourceHpLost, targetFighterIndex, targetPartyIndex, sourceFighterIndex, sourcePartyIndex}, ret;
    DISPPARAMS params = {vars, NULL, 10, 0};

    HRESULT hr = m_plugin->Invoke(
                     member,
                     IID_NULL,
                     LOCALE_USER_DEFAULT,
                     DISPATCH_METHOD,
                     &params,
                     &ret,
                     NULL,
                     NULL
                 );

    return ret.intVal;
}