const string EvtKey::getAsString() const { string event = "key"; // Add the action if( m_action == kDown ) event += ":down"; else if( m_action == kUp ) event += ":up"; else msg_Warn( getIntf(), "Unknown action type" ); // Add the key char *keyName = KeyToString( m_key ); if( keyName ) { event += (string)":" + keyName; free( keyName ); } else msg_Warn( getIntf(), "Unknown key: %d", m_key ); // Add the modifier addModifier( event ); return event; }
void CProfile::SaveKeyBind(LPCTSTR appName, LPCTSTR comName, int type, int key) { CString subKey = CString(MAKEINTRESOURCE(IDS_REGSUBKEY_DATA)) + _T("\\") + appName + _T("\\") + comName; CString s = KeyToString(type, key); if (!s.IsEmpty()) subKey = subKey + _T("\\") + s; HKEY hKey = NULL; if (RegCreateKeyEx(HKEY_CURRENT_USER, subKey, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, NULL) == ERROR_SUCCESS) RegCloseKey(hKey); }
void CGroupPrice::UnsubscribeGroup(const CComVariant& params) { if(V_VT(¶ms) == VT_ERROR) { UnsubscribeAll(); } else { _QuoteUpdateParams Params(params); if(V_VT(&m_vtRequest) != VT_ERROR) { _QuoteUpdateParams param2(m_vtRequest); _bstr_t bsSymbol1(Params->Symbol) ; _bstr_t bsSymbol2(param2->Symbol) ; if(bsSymbol1 == bsSymbol2 && Params->Type == param2->Type) { _CancelOptions(); } } _SetDbKey(Params); char szSymbol[MAX_LENGTH + 1]; ZeroMemory(szSymbol,sizeof(szSymbol)); KeyToString(&m_dbaKey.dbaKey, szSymbol, MAX_LENGTH); m_csSubscript.Lock(); for(tickerset::const_iterator iter = m_mapGroupSubscript[szSymbol].begin(); iter != m_mapGroupSubscript[szSymbol].end(); iter++) { ZeroMemory(&m_dbaKey.dbaKey, sizeof(DBA_KEY)); ::StringToKey(const_cast<char*>((*iter).c_str()), &m_dbaKey.dbaKey); m_mapSubscript.erase(*iter); DecInterest(); } m_mapGroupSubscript.erase(szSymbol); m_csSubscript.Unlock(); } m_vtRequest.Clear(); }
long CGroupPrice::_OptionsProc(ULONG ulFunction, DBA_KEY *pDbaKey, DBA_OPTIONS_FILTER_RECORD *pDbaRec, DWORD dwStatus) { if (ulFunction == DBA_TERMINATE_STREAM_FUNCTION || m_bTerminate) return FALSE; if (dwStatus == DBA_ERR_NO_ERROR) { _QuoteUpdateParams Params; ParamFromKey(*pDbaKey, Params); if(_IsOurOptionExchange(pDbaKey->exchangeCode[0])) { char symbol[MAX_LENGTH + 1]; ZeroMemory(&symbol, sizeof(symbol)); KeyToString(pDbaKey, symbol, MAX_LENGTH); m_csClosePrice.Lock(); m_mapClosePrices[symbol] = pDbaRec->priceRec.dbaRec.close.price; m_csClosePrice.Unlock(); m_bIsGotOptions = true; if(enGroupRequestLastQuote != m_enRequestType) { m_csSubscript.Lock(); m_mapGroupSubscript[m_szUndSymbol].insert(symbol); m_mapSubscript.insert(subscriptionmap::value_type(symbol, enOPT)); m_csSubscript.Unlock(); if(enGroupRequestAllNotify == m_enRequestType) { CSubscribedResponsePtr pResponse = CSubscribedResponsePtr(new CSubscribedResponse(Params)); PublicResponse(boost::shared_dynamic_cast<CResponseBase>(pResponse)); } PublicQuoteUpdate(Params, pDbaRec->priceRec.dbaRec); } if(enGroupRequestSubscribe != m_enRequestType && enGroupRequestAllNotify != m_enRequestType) { PublicLastQuote(Params, pDbaRec->priceRec.dbaRec); } } else { memcpy(&m_dbaKey.dbaKey, pDbaKey, sizeof(DBA_KEY)); DecInterest(); } if(Params->Symbol) { SysFreeString(Params->Symbol); Params->Symbol = NULL; } if(Params->Exchange) { SysFreeString(Params->Exchange); Params->Exchange = NULL; } return FALSE; } else { CErrorResponse* pError = new CErrorResponse(); pError->m_vtRequest = m_vtRequest; if(enGroupRequestLastQuote != m_enRequestType) { pError->m_enRequestType = enSubscribeQuote; if(dwStatus == DBA_ERR_KEY_NOT_FOUND) { pError->m_bstrDescription = L"Couldn't subscribe underlyings options."; pError->m_Error = enNoDataAvailableForSymbol; } else if(dwStatus == DBA_ERR_INTEREST) { pError->m_bstrDescription = L"HyperFeed server subscription list is full"; pError->m_Error = enProviderInternalError; } else { _bstr_t bs = "Could not underlyings options. Error: "; bs += EtGetMessage(DBA_ERROR,dwStatus); TCHAR buffer[0x100] = {0}; _ltot(dwStatus,buffer,10); bs += " ("; bs += buffer; bs += ")"; pError->m_bstrDescription = bs; pError->m_Error = enProviderInternalError; } } else { pError->m_enRequestType = enRequestLastQuote; if(dwStatus == DBA_ERR_KEY_NOT_FOUND) { pError->m_bstrDescription = L"Couldn't get options prices for underlying. Unknown symbol."; pError->m_Error = enNoDataAvailableForSymbol; } else { _bstr_t bs = "Couldn't get options prices for underlying. Error: "; bs += EtGetMessage(DBA_ERROR,dwStatus); TCHAR buffer[0x100] = {0}; _ltot(dwStatus,buffer,10); bs += " ("; bs += buffer; bs += ")"; pError->m_bstrDescription = bs; pError->m_Error = enProviderInternalError; } } CResponseBasePtr pErrorPtr = CResponseBasePtr((CResponseBase*)pError); PublicResponse(pErrorPtr); m_bIsGotError = true; } return FALSE; }
long CGroupPrice::_GetOptions(const _QuoteUpdateParams& Params, GroupRequestType enRequest) { EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("CGroupPrice::_GetOptions Enter %s"), _T(m_dbaKey.dbaKey.symbol) ); long nStatus = 0; try { ATLTRACE(_T("_GetOptions Enter\n")); _CancelOptions(); char szSymbol[MAX_LENGTH + 1]; ZeroMemory(szSymbol,sizeof(szSymbol)); KeyToString(&m_dbaKey.dbaKey, szSymbol, MAX_LENGTH); m_szUndSymbol = szSymbol; m_bIsGotOptions = false; m_bIsGotError = false; m_bTerminate = false; m_enRequestType = enRequest; const_cast<_QuoteUpdateParams&>(Params).CopyTo(m_vtRequest); int nRecLen = sizeof(OPTIONS_FILTER); int nKeyLen = sizeof(DBA_KEY); m_optionsFilter.flags.mask = 0; if (m_bComposites) m_optionsFilter.flags.mask += DBA_OFM_COMPOSITES; if (m_bRegionals) m_optionsFilter.flags.mask += DBA_OFM_REGIONALS; m_optionsFilter.flags.mask += DBA_OFM_CALLS; m_optionsFilter.flags.mask += DBA_OFM_PUTS; m_optionsFilter.months = -1; m_optionsFilter.count = -1; m_optionsFilter.nRecLen = sizeof(DBA_OPTIONS_FILTER_RECORD); bool bSubscribe = (m_enRequestType != enGroupRequestLastQuote); long nFunc = bSubscribe ? DBA_GET_OPTIONS | DBAX_INTEREST : DBA_GET_OPTIONS; nStatus = dba(&m_blk, nFunc, &m_dbaKey.dbaKey, &nKeyLen, &m_optionsFilter, &nRecLen, 0); if (nStatus == DBA_ERR_NO_ERROR) { EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("CGroupPrice::_GetOptions dba returns NO_ERROR")); EgLib::WaitWithEvents(1, &m_optionsFilter.hThread); if(m_bTerminate) { EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("CGroupPrice::_GetOptions nStatus = DBA_TERMINATED")); nStatus = DBA_TERMINATED; } } if(m_optionsFilter.hThread) { //::CloseHandle(m_optionsFilter.hThread); m_optionsFilter.hThread = 0; } ATLTRACE(_T("_GetOptions Exit\n")); } _CATCH_UNHANDLED_EXCEPTION; EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("CGroupPrice::_GetOptions Exit %s"), _T(m_dbaKey.dbaKey.symbol) ); return nStatus; }