bool PowerDocsExtHelper::GetPreviousVersion(const DOCSObjects::IVersionPtr pVersion,DOCSObjects::IVersionPtr& pPrevVersion)
{
	
	if(pVersion == NULL)
		return false;
	
	pPrevVersion = NULL;

	_bstr_t bstrLabel;
	bstrLabel= pVersion->GetVersionLabel();
	CStdString sLabel = bstrLabel;
	long lVersion = _ttol(sLabel.c_str());
	if(lVersion == 1)
		return false;

	DOCSObjects::IProfilePtr pProfile = pVersion->GetProfile();
	
	if(pProfile == NULL)
		return false;
	
	DOCSObjects::IVersionsPtr pVersions;
	
	HRESULT hr = pProfile->get_Versions(&pVersions);
	
	if(SUCCEEDED(hr))
	{
		TCHAR tmp[5];
		_variant_t varIndex = _ltot(lVersion-1, tmp, 10); //Previous version
		pPrevVersion =  pVersions->GetItem(varIndex);
		return true;
	}
	return false;
}
void VideoRegionsConfigDialog::updateUI()
{
  StringVector *videoClasses = m_config->getVideoClassNames();
  std::vector<Rect> *videoRects = m_config->getVideoRects();
  StringStorage textAreaData;
  TCHAR endLine[3] = {13, 10, 0};
  {
    AutoLock al(m_config);
    textAreaData.setString(_T(""));
    for (size_t i = 0; i < videoClasses->size(); i++) {
      textAreaData.appendString(videoClasses->at(i).getString());
      textAreaData.appendString(&endLine[0]);
    }
    TCHAR buffer[32];
    _ltot(m_config->getVideoRecognitionInterval(), &buffer[0], 10);
    m_videoRecognitionInterval.setText(buffer);
  }
  m_videoClasses.setText(textAreaData.getString());

  {
    AutoLock al(m_config);
    textAreaData.setString(_T(""));
    for (size_t i = 0; i < videoRects->size(); i++) {
      Rect r = videoRects->at(i);
      StringStorage s;
      RectSerializer::toString(&r, &s);
      textAreaData.appendString(s.getString());
      textAreaData.appendString(&endLine[0]);
    }
  }
  m_videoRects.setText(textAreaData.getString());
}
void UTBStr::ltot(long value, TCHAR * dest, size_t size, int radix)
{
#if _MSC_VER >= 1400
	_ltot_s(value, dest, size, radix);
#else
	UNREFERENCED_PARAMETER(size);
	_ltot(value, dest, radix);
#endif
}
Beispiel #4
0
void CGroupPrice::GetGroupPrice(const _QuoteUpdateParams& Params)
{
	_SetDbKey(Params);

	long nResult = _GetOptions(Params);
	if(DBA_ERR_NO_ERROR == nResult)
	{
		if(m_bIsGotOptions && !m_bIsGotError)
		{
			DBA_RECORD_3 rec;
			ZeroMemory(&rec, sizeof(rec));
			PublicLastQuote(Params, rec);
		}
		else if(!m_bIsGotOptions && !m_bIsGotError) 
		{
			CErrorResponse* pError = new CErrorResponse();
			pError->m_enRequestType = enRequestLastQuote;
			const_cast<_QuoteUpdateParams&>(Params).CopyTo(pError->m_vtRequest);			
			pError->m_bstrDescription = L"Couldn't get options prices for underlying. Unknown symbol.";
			pError->m_Error = enNoDataAvailableForSymbol;
			CResponseBasePtr pErrorPtr = CResponseBasePtr((CResponseBase*)pError);
			PublicResponse(pErrorPtr);
		}
	}
	else
	{
		CErrorResponse* pError = new CErrorResponse();
		pError->m_enRequestType = enRequestLastQuote;
		const_cast<_QuoteUpdateParams&>(Params).CopyTo(pError->m_vtRequest);			
		if(nResult == DBA_ERR_KEY_NOT_FOUND)
		{
			pError->m_bstrDescription = L"Couldn't get options prices for underlying. Unknown symbol.";
			pError->m_Error = enNoDataAvailableForSymbol;
		}
		else if(nResult == DBA_TERMINATED)
		{
			pError->m_bstrDescription = L"Operation canceled by user.";
			pError->m_Error = enInternalError;
		}
		else
		{
			_bstr_t bs =  "Couldn't get options prices for underlying. Error: ";
			bs += EtGetMessage(DBA_ERROR,nResult);
			TCHAR buffer[0x100] = {0};				
			_ltot(nResult,buffer,10);
			bs += " (";
			bs += buffer;
			bs += ")";
			pError->m_bstrDescription = bs;
			pError->m_Error = enProviderInternalError;
		}
		CResponseBasePtr pErrorPtr = CResponseBasePtr((CResponseBase*)pError);
		PublicResponse(pErrorPtr);
	}
	m_vtRequest.Clear();
}
Beispiel #5
0
	//////////////////////////////////////////////////////////////////////
	//
	// Returns a string registry key value, empty when failure
	//
	bool GetRegValue(HKEY root, LPCTSTR keyPath, LPCTSTR keyName, string& val, short prodId)
	{
		long retCode;
		HKEY hKeyResult;
		DWORD  dwType;
		DWORD  buffSize=0;

#if defined(WIN64)||defined(NCWOW64)
		
		retCode = RegOpenKeyEx(root, keyPath, 0, KEY_READ|KEY_WOW64_64KEY, &hKeyResult);
#else
		retCode = RegOpenKeyEx(root, keyPath, 0, KEY_READ, &hKeyResult);
#endif
		
		
		if (retCode != ERROR_SUCCESS)
		{
			return false;
		}

		retCode = RegQueryValueEx(hKeyResult, keyName, NULL, &dwType, NULL, &buffSize);
		if ((retCode != ERROR_SUCCESS))
		{
			RegCloseKey(hKeyResult);
			return false;
		}

		if (dwType == REG_DWORD)
		{
			DWORD regData;
			retCode = RegQueryValueEx(hKeyResult, keyName, NULL, &dwType, (LPBYTE) &regData, &buffSize);
			RegCloseKey(hKeyResult);
			if (retCode == ERROR_SUCCESS)
			{
				TCHAR data[10];
				_ltot(regData, data, 10);
				val = data;
			}
		}
		else
		{
			if(buffSize != 0)
			{
				TCHAR *pRegData = new TCHAR[buffSize];
				retCode = RegQueryValueEx(hKeyResult, keyName, NULL, &dwType,(LPBYTE)pRegData, &buffSize);
				RegCloseKey(hKeyResult);
				if (retCode == ERROR_SUCCESS)
				{
					val = pRegData;
				}
				delete [] pRegData;
			}
		}
		return true;
	}
CStdString  CPowerDocsDocInfo::AsDocID()
{
 	std::tstring sDocID = _T("PowerDOCS://");
	
	sDocID += m_sLibrary;
 	sDocID += _T("/");
	
	TCHAR szDocNum[ 10 ]; _ltot( m_nDocNum, szDocNum, 10 );
	sDocID += szDocNum;
 	sDocID += _T("/");
	sDocID += m_sVerLabel;
	
	return sDocID;
}
Beispiel #7
0
int CMsnProto::MSN_ChatInit(WPARAM wParam, LPARAM)
{
	ThreadData *info = (ThreadData*)wParam;
	MyInterlockedIncrement(&sttChatID);
	_ltot(sttChatID, info->mChatID, 10);

	TCHAR szName[512];
	mir_sntprintf(szName, SIZEOF(szName), _T("%s %s%s"), 
		m_tszUserName, TranslateT("Chat #"), info->mChatID);

	GCSESSION gcw = {0};
	gcw.cbSize = sizeof(GCSESSION);
	gcw.dwFlags = GC_TCHAR;
	gcw.iType = GCW_CHATROOM;
	gcw.pszModule = m_szModuleName;
	gcw.ptszName = szName;
	gcw.ptszID = info->mChatID;
	CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);

	GCDEST gcd = { m_szModuleName, { NULL }, GC_EVENT_ADDGROUP };
	gcd.ptszID = info->mChatID;
	GCEVENT gce = {0};
	gce.cbSize = sizeof(GCEVENT);
	gce.dwFlags = GC_TCHAR;
	gce.pDest = &gcd;
	gce.ptszStatus = TranslateT("Me");
	CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);

	gcd.iType = GC_EVENT_JOIN;
	gce.ptszUID = mir_a2t(MyOptions.szEmail);
	gce.ptszNick = GetContactNameT(NULL);
	gce.time = 0;
	gce.bIsMe = TRUE;
	CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);

	gcd.iType = GC_EVENT_ADDGROUP;
	gce.ptszStatus = TranslateT("Others");
	CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);

	gcd.iType = GC_EVENT_CONTROL;
	CallServiceSync(MS_GC_EVENT, SESSION_INITDONE, (LPARAM)&gce);
	CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
	CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, (LPARAM)&gce);

	mir_free((TCHAR*)gce.ptszUID);
	return 0;
}
void CIcqProto::GetAvatarFileName(int dwUin, const char *szUid, TCHAR *pszDest, int cbLen)
{
	TCHAR szPath[MAX_PATH * 2];
	mir_sntprintf(szPath, MAX_PATH * 2, _T("%s\\%S\\"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);

	FOLDERSGETDATA fgd = {0};
	fgd.cbSize = sizeof(FOLDERSGETDATA);
	fgd.nMaxPathSize = MAX_PATH * 2;
	fgd.szPathT = szPath;
	fgd.flags = FF_TCHAR;

	// fill the destination
	lstrcpyn(pszDest, szPath, cbLen - 1);
	int tPathLen = strlennull(pszDest);

	// make sure the avatar cache directory exists
	CreateDirectoryTreeT(szPath);

	if (dwUin != 0)
	{
		_ltot(dwUin, pszDest + tPathLen, 10);
	}
	else if (szUid)
	{
		TCHAR* p = mir_a2t(szUid);
		_tcscpy(pszDest + tPathLen, p);
		mir_free( p );
	}
	else
	{
		TCHAR szBuf[MAX_PATH];

		if (CallService(MS_DB_GETPROFILENAMET, MAX_PATH, (LPARAM)szBuf))
			_tcscpy(pszDest + tPathLen, _T("avatar"));
		else
		{
			TCHAR *szLastDot = _tcsrchr(szBuf, '.');
			if (szLastDot) szLastDot[0] = '\0';

			_tcscpy(pszDest + tPathLen, szBuf);
			_tcscat(pszDest + tPathLen, _T("_avt"));
		}
	}
}
Beispiel #9
0
BOOL CxDlgIceProfile::OnInitDialog() 
{
	CString csTempo,csTitle;
	CDialog::OnInitDialog();

	if (m_pStructProfileInfo->bAlter)
	{	//"Alter Ice Profile %s on %s"
		csTitle.Format(IDS_ICE_ALTER_PROFILE_TITLE,
		(LPCTSTR)m_pStructProfileInfo->ProfileName, 
		(LPCTSTR)m_csVnodeName);
		m_ctrledName.EnableWindow(FALSE);
		PushHelpId (HELPID_ALTER_IDD_ICE_PROFILE);
	}
	else
	{
		GetWindowText(csTempo);
		csTitle.Format(csTempo,m_csVnodeName);
		PushHelpId (HELPID_IDD_ICE_PROFILE);
	}
	SetWindowText(csTitle);
	FillDatabasesUsers();
	m_bAdmin			=	m_pStructProfileInfo->bAdminPriv; 
	m_bSecurityAdmin	=	m_pStructProfileInfo->bSecurityPriv;
	m_bUnitManager		=	m_pStructProfileInfo->bUnitMgrPriv;
	m_bMonitoring		=	m_pStructProfileInfo->bMonitorPriv;
	m_lTimeout			=	m_pStructProfileInfo->ltimeoutms;
	m_csName			=	m_pStructProfileInfo->ProfileName;
	m_csDefUser			=	m_pStructProfileInfo->DefDBUsr.UserAlias;
	UpdateData(FALSE);
	char buffer[20];
	_ltot(LONG_MAX,buffer,10);
	m_ctrledTimeOut.LimitText(lstrlen(buffer));
	m_ctrledName.LimitText(sizeof(m_pStructProfileInfo->ProfileName)-1);

	EnableDisableOK ();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #10
0
void CKeyEditDlg::OnButtonRead() 
{
	SRdkitKeyData	keydata;
	BYTE			bBuffer[KEY_DATA_SIZE];
	CString			strCaption,str;

	keydata.dwSize = sizeof(keydata);
	keydata.dwDataOffset = 0;
	keydata.dwDataSize = KEY_DATA_SIZE;
	keydata.pDataPtr = bBuffer;
		
	if(!GetPassword(keydata.pdwCustomerPassword))
	{
		strCaption.LoadString(IDS_ERROR);
		str.LoadString(IDS_ERROR_INVALID_PASSWORD);
		MessageBox(str, strCaption, MB_OK|MB_ICONSTOP);
		return;
	}
	
	if(!RdkitReadKeyData(&keydata))
	{
		DWORD dwError = GetLastError();

		strCaption.LoadString(IDS_ERROR);
		str.Format(IDS_ERROR_CANT_READ_KEY_DATA, ERROR_MESSAGE(dwError));
		MessageBox(str, strCaption, MB_OK|MB_ICONSTOP);
		return;
	}

	TCHAR szTemp[8];

	for(int i=0; i<KEY_DATA_SIZE; i++)
	{
		m_listKeyData.SetItemText(i, 0, _tcsupr(_ltot(bBuffer[i],szTemp,16)));
		m_listKeyData.SetItemData(i, false);
	}
}
Beispiel #11
0
JNIEXPORT jstring SIGAR_JNI(win32_RegistryKey_RegQueryStringValue)
(JNIEnv *env, jclass, jlong hkey, jstring name)
{
    jstring strResult;
    DWORD   dwType;
    LPBYTE  lpValue;
    DWORD   cbValue;
    jsize len = env->GetStringLength(name);
    LPTSTR lpValueName = (LPTSTR)env->GetStringChars(name, NULL);
    LPTSTR copy;
    LONG    lErr;
    /* required under IBM/WebSphere 4.0 for certain keys */
    if (lpValueName[len] != '\0') {
        copy = _wcsdup(lpValueName);
        copy[len] = '\0';
    }
    else {
        copy = lpValueName;
    }

    lErr = RegQueryValueEx((HKEY)hkey, 
                           copy, NULL, 
                           (LPDWORD)&dwType, NULL, &cbValue);
    if(lErr == ERROR_SUCCESS)
    {
        lpValue = (LPBYTE)HeapAlloc(GetProcessHeap(), 
                                    HEAP_ZERO_MEMORY, cbValue);

        if(RegQueryValueEx((HKEY)hkey, copy, NULL, NULL, 
                           lpValue, &cbValue) == ERROR_SUCCESS)
        {
            switch(dwType) {
            case REG_DWORD:
                TCHAR   szBuf[20];
                _ltot(*(LPDWORD)lpValue, szBuf, 10);
                strResult = env->NewString((const jchar *)szBuf, 
                                           lstrlen(szBuf));
                break;
            case REG_SZ:
            case REG_EXPAND_SZ: {
                DWORD len;
                LPTSTR dest = NULL;
                len = ExpandEnvironmentStrings((LPCTSTR)lpValue, dest, 0);
                dest = (LPTSTR)malloc(len * sizeof(TCHAR));
                ExpandEnvironmentStrings((LPCTSTR)lpValue, dest, len);
                strResult = env->NewString((const jchar *)dest, len);
                free(dest);
                break;
            }
            default:
                lErr = ERROR_SUCCESS - 1; // Make an error
            }
        }

        HeapFree(GetProcessHeap(), 0, lpValue);
    }

    env->ReleaseStringChars(name, (const jchar *)lpValueName);
    if (copy != lpValueName) {
        free(copy);
    }
    
    if(lErr == ERROR_SUCCESS)
        return strResult;
    else
    {
        jclass cls = env->FindClass(WIN32_PACKAGE "Win32Exception");
        env->ThrowNew(cls, "");
        return NULL;
    }
}
void CHyperFeedStructureProviderEx::OnRequest(CRequestBasePtr pRequest)
{
	switch(pRequest->m_enType)
	{
	case _enRequestStock:
		{
			CStockRequest* pStockRequest = static_cast<CStockRequest*>(pRequest.get());
			if(pStockRequest)
				GetStockResultsEx(pStockRequest->m_recParams);
		}
		break;
	case _enRequestOption:
		{
			COptionRequest* pOptionRequest = static_cast<COptionRequest*>(pRequest.get());
			if(pOptionRequest)
			{
				pOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				if(!IsCanceled())
					LoadOptionFundamentalInfo(pOptionRequest->m_recParams->UnderlyingSymbol);
				if(!IsCanceled())
					GetOptions(pOptionRequest->m_recParams->UnderlyingSymbol);
			}
		}
		break;
	case _enRequestFuture:
		{
			CFutureRequest* pFutureRequest = static_cast<CFutureRequest*>(pRequest.get());
			if(pFutureRequest)
				GetFutureResultsBySymbol(pFutureRequest->m_recParams, true);
		}
		break;
	case _enRequestFutures:
		{
			CFuturesRequest* pFuturesRequest = static_cast<CFuturesRequest*>(pRequest.get());
			if(pFuturesRequest)
				GetFutureResultsByRootSymbol(pFuturesRequest->m_recParams, true);
		}
		break;
	case _enRequestFuturesOption:
		{
			EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Requst Futures Options Start"));
			CFuturesOptionRequestPtr pFuturesOptionRequest = boost::shared_dynamic_cast<CFuturesOptionRequest>(pRequest);
			if(pFuturesOptionRequest)
			{
				EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("pFuturesOptionRequest"));
				pFuturesOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetFutureInfo Call"));
				long nResult = GetFutureInfo(pFuturesOptionRequest->m_recParams, false);
				if(nResult == DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetFutureInfo Call - No Error"));
					QuoteUpdateParams Params;
					Params.Symbol = ::SysAllocString(pFuturesOptionRequest->m_recParams->FutureSymbol);
					Params.Type = enFUT;
					Params.Exchange = NULL;

					CQuoteRequestPtr pQuoteRequest = CQuoteRequestPtr(new CQuoteRequest(_enRequestFuturesOption, &Params));
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice for: Symbol - %s"), CW2T(Params.Symbol) );
					nResult = GetPrice(boost::shared_static_cast<CRequestBase>(pQuoteRequest), false);

					::SysFreeString(Params.Symbol);

					if(nResult == DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got Price for: %s"), CW2T(Params.Symbol));
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Requesting future options for: %s"), CW2T(Params.Symbol));
						GetFutureOptionsResults(m_clCurrentFuture, false);
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got future options for: %s"), CW2T(Params.Symbol));

					}
					else
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice FAILED for: %s"),CW2T(Params.Symbol));
						/* Lets try to get with 'G' symbol */

						//Params.Exchange = ::SysAllocString(L"G");
						CComBSTR cbsTmp(pFuturesOptionRequest->m_recParams->FutureSymbol);
						cbsTmp.Append(L"G");
						Params.Symbol = cbsTmp.Detach();


						CQuoteRequestPtr pQuoteRequest = CQuoteRequestPtr(new CQuoteRequest(_enRequestFuturesOption, &Params));
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice for: Symbol - %s"), CW2T(Params.Symbol) );
						nResult = GetPrice(boost::shared_dynamic_cast<CRequestBase>(pQuoteRequest), false);
						//::SysFreeString(Params.Symbol);
						//::SysFreeString(Params.Exchange );

						if(nResult == DBA_ERR_NO_ERROR) 
						{
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got Price for: %s"), CW2T(Params.Symbol));
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Requesting future options for: %s"), CW2T(Params.Symbol));
							GetFutureOptionsResults(m_clCurrentFuture, false);
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Got future options for: %s"), CW2T(Params.Symbol));
						}
						else
						{
							EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetPrice FAILED for: %s"),CW2T(Params.Symbol));

						}
						/* ---Lets try to get with 'G' symbol */
					}

				}
				else
				{
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("GetFutureInfo Call - Failed"));
				}

				if(nResult != DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Request future options - got error"));

					if(nResult == DBA_TERMINATED)
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Operation was canceled by user"));
						PublicGetFutureOptionError(enInternalError, _bstr_t(L"Operation was canceled by user"));
					}
					if(nResult == DBA_ERR_KEY_NOT_FOUND)
					{
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T("Couldn't get future options for future. Unknown symbol"));
						PublicGetFutureOptionError(enNoDataAvailableForSymbol, _bstr_t(L"Couldn't get future options for future. Unknown symbol"));
					}
					else
					{
						_bstr_t bs =  "Couldn't get options for future. Error: ";
						bs += EtGetMessage(DBA_ERROR,nResult);
						TCHAR buffer[0x100] = {0};				
						_ltot(nResult,buffer,10);
						bs += " (";
						bs += buffer;
						bs += ")";
						EgStd::CEgTracingClass::TraceStatic(enlogSubs, __FUNCTION__ , _T(buffer));
						PublicGetFutureOptionError(enProviderInternalError, bs);
					}
				}
			}
		}
		break;
	}
}
DWORD CDatabaseManager::OnCreateGlobalDBObject(DWORD size, void *params)
{
	DBCREATEPARAMS *db;
	CHashString memType(_T("Memory"));
	IArchive *MemArchive;
	StdString str;
	TCHAR strNum[50];
	int memsize;
	VERIFY_MESSAGE_SIZE(size, sizeof(DBCREATEPARAMS));

	db = (DBCREATEPARAMS*)params;

	// begin name
	str = _T("GlobalDatabase");

	// append number to each name
	_ltot(m_iGlobalCount, strNum, 10);
	str = str + strNum;
	
	// increment global count
	++m_iGlobalCount;

	// get name, parent and type
	CHashString name(str.c_str());
	static CHashString typeName(_T("CDatabase"));
	
	// create object
	CDatabase *pDatabase = dynamic_cast<CDatabase *>(
		m_ToolBox->CreateComponent(&typeName, 3, &name, NULL, false));

	// add object to object factory by hand since we need a pointer to the database object
	OFACTORYADDPARAMS aotf;
	aotf.component = pDatabase;
	aotf.name = &name;
	static DWORD msgHash_AddObjectToFactory = CHashString(_T("AddObjectToFactory")).GetUniqueID();
	m_ToolBox->SendMessage(msgHash_AddObjectToFactory, sizeof(aotf), &aotf );

	// get size of name
	memsize = _tcslen(db->fileName)+1;

	// create memory chunk
	char* memBuffer = new char[memsize];

	// create archive
	CREATEARCHIVE ca;
	ca.mode =  STREAM_MODE_READ | STREAM_MODE_WRITE;
	ca.streamData = memBuffer;
	ca.streamSize = memsize;
	ca.streamType = &memType;
	static DWORD msgHash_CreateArchive = CHashString(_T("CreateArchive")).GetUniqueID();
	if (m_ToolBox->SendMessage(msgHash_CreateArchive, sizeof(CREATEARCHIVE), &ca) != MSG_HANDLED)
	{
		StdString error;
		error = _T(__FILE__ " OnCreateGlobalDBObject(): cannot create archive\n");
		EngineGetToolBox()->Log( LOGWARNING, error );
		if( memBuffer != NULL )
		{
			delete [] memBuffer;
		}
		memBuffer = NULL;
		return MSG_ERROR;
	}

	// write name to archive 
	MemArchive = ca.archive;
	MemArchive->Write(db->fileName);

	// serialize database object
	pDatabase->Serialize(*MemArchive);
	// init database object
	pDatabase->Init();

	// close the archive
	MemArchive->Close();
	// clean up
	if( memBuffer != NULL )
	{
		delete [] memBuffer;
	}
	memBuffer = NULL;
	
	*static_cast<IDatabase**>(db->dbObj) = pDatabase;

	return MSG_HANDLED_STOP;
}
void CHyperFeedStructureProviderEx::OnRequest(CRequestBasePtr pRequest)
{
	switch(pRequest->m_enType)
	{
	case _enRequestStock:
		{
			CStockRequest* pStockRequest = dynamic_cast<CStockRequest*>(pRequest.get());
			if(pStockRequest)
				GetStockResultsEx(pStockRequest->m_recParams);
		}
		break;
	case _enRequestOption:
		{
			COptionRequest* pOptionRequest = dynamic_cast<COptionRequest*>(pRequest.get());
			if(pOptionRequest)
			{
				pOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				if(!IsCanceled())
					LoadOptionFundamentalInfo(pOptionRequest->m_recParams->UnderlyingSymbol);
				if(!IsCanceled())
					GetOptions(pOptionRequest->m_recParams->UnderlyingSymbol);
			}
		}
		break;
	case _enRequestFuture:
		{
			CFutureRequest* pFutureRequest = dynamic_cast<CFutureRequest*>(pRequest.get());
			if(pFutureRequest)
				GetFutureResultsBySymbol(pFutureRequest->m_recParams, true);
		}
		break;
	case _enRequestFutures:
		{
			CFuturesRequest* pFuturesRequest = dynamic_cast<CFuturesRequest*>(pRequest.get());
			if(pFuturesRequest)
				GetFutureResultsByRootSymbol(pFuturesRequest->m_recParams, true);
		}
		break;
	case _enRequestFuturesOption:
		{
			CFuturesOptionRequest* pFuturesOptionRequest = dynamic_cast<CFuturesOptionRequest*>(pRequest.get());
			if(pFuturesOptionRequest)
			{
				pFuturesOptionRequest->m_recParams.CopyTo(m_vtCurrentRequest);
				long nResult = GetFutureInfo(pFuturesOptionRequest->m_recParams, true);
				if(nResult == DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					m_clCurrentFuture.m_dFutureClosePrice = GetClosePrice(pFuturesOptionRequest->m_recParams->FutureSymbol, enFUT);

					if(m_clCurrentFuture.m_dFutureClosePrice > BAD_DOUBLE_VALUE) // Sharky: try to resolve FT_CQ00001489
					{
						GetFutureOptionsResults(m_clCurrentFuture, true);
					}
					else
					{
						PublicGetFutureOptionError(enNoDataAvailableForSymbol, _bstr_t(L"Couldn't get future options for future. No close price for future."));
					}
				}
				
				if(nResult != DBA_ERR_NO_ERROR) // Sharky: try to resolve FT_CQ00001489
				{
					if(nResult == DBA_TERMINATED)
					{
						PublicGetFutureOptionError(enInternalError, _bstr_t(L"Operation was canceled by user"));
					}
					if(nResult == DBA_ERR_KEY_NOT_FOUND)
					{
						PublicGetFutureOptionError(enNoDataAvailableForSymbol, _bstr_t(L"Couldn't get future options for future. Unknown symbol"));
					}
					else
					{
						_bstr_t bs =  "Couldn't get options for future. Error: ";
						bs += EtGetMessage(DBA_ERROR,nResult);
						TCHAR buffer[0x100] = {0};				
						_ltot(nResult,buffer,10);
						bs += " (";
						bs += buffer;
						bs += ")";
						PublicGetFutureOptionError(enProviderInternalError, bs);
					}
				}
			}
		}
		break;
	}
}
Beispiel #15
0
// weather options
INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
{
	TCHAR str[512];

	switch (msg) {
	case WM_INITDIALOG:
		opt_startup = TRUE;
		TranslateDialogDefault(hdlg);
		// load settings
		_ltot(opt.UpdateTime, str, 10);
		SetDlgItemText(hdlg, IDC_UPDATETIME, str);
		SetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign);

		SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETRANGE32, 0, 999);
		SendDlgItemMessage(hdlg, IDC_AVATARSPIN, UDM_SETPOS, 0, opt.AvatarSize);
		SendDlgItemMessage(hdlg, IDC_AVATARSIZE, EM_LIMITTEXT, 3, 0);

		CheckDlgButton(hdlg, IDC_STARTUPUPD, opt.StartupUpdate ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_UPDATE, opt.AutoUpdate ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_PROTOCOND, !opt.NoProtoCondition ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_UPDCONDCHG, opt.UpdateOnlyConditionChanged ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_REMOVEOLD, opt.RemoveOldData ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_MAKEI, opt.MakeItalic ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_DISCONDICON, opt.DisCondIcon ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_DONOTAPPUNITS, opt.DoNotAppendUnit ? BST_CHECKED : BST_UNCHECKED);
		CheckDlgButton(hdlg, IDC_NOFRAC, opt.NoFrac ? BST_CHECKED : BST_UNCHECKED);

		// load units
		switch (opt.tUnit) {	// temperature
		case 1: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T1); break;
		case 2: CheckRadioButton(hdlg, IDC_T1, IDC_T2, IDC_T2); break;
		}
		switch (opt.wUnit) {	// wind
		case 1: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W1); break;
		case 2: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W2); break;
		case 3: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W3); break;
		case 4: CheckRadioButton(hdlg, IDC_W1, IDC_W4, IDC_W4); break;
		}
		switch (opt.vUnit) {	// visibility
		case 1: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V1); break;
		case 2: CheckRadioButton(hdlg, IDC_V1, IDC_V2, IDC_V2); break;
		}
		switch (opt.pUnit) {	// pressure
		case 1: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P1); break;
		case 2: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P2); break;
		case 3: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P3); break;
		case 4: CheckRadioButton(hdlg, IDC_P1, IDC_P4, IDC_P4); break;
		}
		switch (opt.dUnit) {	// pressure
		case 1: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D1); break;
		case 2: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D2); break;
		case 3: CheckRadioButton(hdlg, IDC_D1, IDC_D3, IDC_D3); break;
		}

		switch (opt.eUnit) {	// elev
		case 1: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E1); break;
		case 2: CheckRadioButton(hdlg, IDC_E1, IDC_E2, IDC_E2); break;
		}

		opt_startup = FALSE;
		return 0;

	case WM_COMMAND:
		if (HIWORD(wparam) == BN_CLICKED && GetFocus() == (HWND)lparam)
			if (!opt_startup)	SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
		if (!((LOWORD(wparam) == IDC_UPDATE || LOWORD(wparam) == IDC_DEGREE) &&
			(HIWORD(wparam) != EN_CHANGE || (HWND)lparam != GetFocus())))
			if (!opt_startup)	SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
		return 0;

	case WM_NOTIFY:
		switch (((LPNMHDR)lparam)->code) {
		case PSN_APPLY:
			// change the status for weather protocol
			if (IsDlgButtonChecked(hdlg, IDC_PROTOCOND) && opt.DefStn != NULL) {
				old_status = status;
				status = db_get_w(opt.DefStn, WEATHERPROTONAME, "StatusIcon", NOSTATUSDATA);
				ProtoBroadcastAck(WEATHERPROTONAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, status);
			}

			// get update time and remove the old timer
			GetDlgItemText(hdlg, IDC_UPDATETIME, str, _countof(str));
			opt.UpdateTime = (WORD)_ttoi(str);
			if (opt.UpdateTime < 1)	opt.UpdateTime = 1;
			KillTimer(NULL, timerId);
			timerId = SetTimer(NULL, 0, opt.UpdateTime * 60000, (TIMERPROC)timerProc);

			// other general options
			GetDlgItemText(hdlg, IDC_DEGREE, opt.DegreeSign, _countof(opt.DegreeSign));
			opt.StartupUpdate = IsDlgButtonChecked(hdlg, IDC_STARTUPUPD);
			opt.AutoUpdate = IsDlgButtonChecked(hdlg, IDC_UPDATE);
			opt.NoProtoCondition = BST_UNCHECKED == IsDlgButtonChecked(hdlg, IDC_PROTOCOND);
			opt.DisCondIcon = IsDlgButtonChecked(hdlg, IDC_DISCONDICON);
			opt.UpdateOnlyConditionChanged = (BYTE)IsDlgButtonChecked(hdlg, IDC_UPDCONDCHG);
			opt.RemoveOldData = IsDlgButtonChecked(hdlg, IDC_REMOVEOLD);
			opt.MakeItalic = IsDlgButtonChecked(hdlg, IDC_MAKEI);
			opt.AvatarSize = GetDlgItemInt(hdlg, IDC_AVATARSIZE, NULL, FALSE);
			opt.DoNotAppendUnit = IsDlgButtonChecked(hdlg, IDC_DONOTAPPUNITS);
			opt.NoFrac = IsDlgButtonChecked(hdlg, IDC_NOFRAC);
			UpdateMenu(opt.AutoUpdate);

			// save the units
			if (IsDlgButtonChecked(hdlg, IDC_T1)) opt.tUnit = 1;
			if (IsDlgButtonChecked(hdlg, IDC_T2)) opt.tUnit = 2;
			if (IsDlgButtonChecked(hdlg, IDC_W1)) opt.wUnit = 1;
			if (IsDlgButtonChecked(hdlg, IDC_W2)) opt.wUnit = 2;
			if (IsDlgButtonChecked(hdlg, IDC_W3)) opt.wUnit = 3;
			if (IsDlgButtonChecked(hdlg, IDC_W4)) opt.wUnit = 4;
			if (IsDlgButtonChecked(hdlg, IDC_V1)) opt.vUnit = 1;
			if (IsDlgButtonChecked(hdlg, IDC_V2)) opt.vUnit = 2;
			if (IsDlgButtonChecked(hdlg, IDC_P1)) opt.pUnit = 1;
			if (IsDlgButtonChecked(hdlg, IDC_P2)) opt.pUnit = 2;
			if (IsDlgButtonChecked(hdlg, IDC_P3)) opt.pUnit = 3;
			if (IsDlgButtonChecked(hdlg, IDC_P4)) opt.pUnit = 4;
			if (IsDlgButtonChecked(hdlg, IDC_D1)) opt.dUnit = 1;
			if (IsDlgButtonChecked(hdlg, IDC_D2)) opt.dUnit = 2;
			if (IsDlgButtonChecked(hdlg, IDC_D3)) opt.dUnit = 3;
			if (IsDlgButtonChecked(hdlg, IDC_E1)) opt.eUnit = 1;
			if (IsDlgButtonChecked(hdlg, IDC_E2)) opt.eUnit = 2;

			// save the new weather options
			SaveOptions();

			RedrawFrame(0, 0);

			return 1;
		}
		break;
	}
	return 0;
}
Beispiel #16
0
bool CVideoExchange::Dehydrate(void)
{
    if (m_pDocument)
        m_pDocument.Release();
    MSXML::IXMLDOMElementPtr pRoot;
    MSXML::IXMLDOMElementPtr pElem;
    TCHAR chBuffer[255];

    HRESULT hr = m_pDocument.CreateInstance(L"MSXML.FreeThreadedDOMDocument");
    ASSERT(ERROR_SUCCESS == hr);

    pElem = m_pDocument->createElement(L"CARDVIDEO");
    pRoot = m_pDocument->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"BITRATE");
    pElem->text = (LPCTSTR)m_sBitRate;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"FILENAME");
    pElem->text = (LPCTSTR)m_sFileName;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"MPEGFORMAT");
    pElem->text = (LPCTSTR)m_sMPEGFormat;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"CARDID");
    pElem->text = (LPCTSTR)m_sCardId;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"ROOMID");
    pElem->text = _ltot(m_nRoomId,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"TIMESTART");
    pElem->text = (LPCTSTR)m_odtStart.Format(_T("%m-%d-%Y %H:%M:%S"));
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"TIMESTOP");
    pElem->text = (LPCTSTR)m_odtStop.Format(_T("%m-%d-%Y %H:%M:%S"));
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"DURATION");
    pElem->text = _ltot(m_nDuration,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"VIDEOSTORAGESERVERID");
    pElem->text = _ltot(m_nVideoStorageServerId,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"STREAMINGENCODERID");
    pElem->text = _ltot(m_nStreamingEncoderId,chBuffer,10);
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"SESSIONID");
    pElem->text = (LPCTSTR)m_sSessionId;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"SESSIONNAME");
    pElem->text = (LPCTSTR)m_sSessionName;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"DISPLAYNAME");
    pElem->text = (LPCTSTR)m_sDisplayName;
    pRoot->appendChild(pElem);
    pElem.Release();

    pElem = m_pDocument->createElement(L"FILETITLE");
    pElem->text = (LPCTSTR)m_sFileTitle;
    pRoot->appendChild(pElem);
    pElem.Release();
    return false;
}
Beispiel #17
0
static MCONTACT ImportContact(MCONTACT hSrc)
{
    MCONTACT hDst;
    TCHAR id[ 40 ], *pszUniqueID;
    char  szProto[100];

    // Check what protocol this contact belongs to
    if (myGetS(hSrc, "Protocol", "p", szProto)) {
        AddMessage(LPGENT("Skipping contact with no protocol"));
        return NULL;
    }

    if (!IsProtocolLoaded(szProto)) {
        AddMessage(LPGENT("Skipping contact, %S not installed."), szProto);
        return NULL;
    }

    // Skip protocols with no unique id setting (some non IM protocols return NULL)
    char* pszUniqueSetting = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
    if (!pszUniqueSetting || (INT_PTR)pszUniqueSetting == CALLSERVICE_NOTFOUND) {
        AddMessage(LPGENT("Skipping non-IM contact (%S)"), szProto);
        return NULL;
    }

    DBVARIANT dbv;
    if (myGet(hSrc, szProto, pszUniqueSetting, &dbv)) {
        AddMessage(LPGENT("Skipping %S contact, ID not found"), szProto);
        return NULL;
    }

    // Does the contact already exist?
    switch (dbv.type) {
    case DBVT_DWORD:
        pszUniqueID = _ltot(dbv.dVal, id, 10);
        hDst = HContactFromNumericID(szProto, pszUniqueSetting, dbv.dVal);
        break;

    case DBVT_ASCIIZ:
        pszUniqueID = NEWTSTR_ALLOCA(_A2T(dbv.pszVal));
        hDst = HContactFromID(szProto, pszUniqueSetting, pszUniqueID);
        break;

    case DBVT_WCHAR:
        pszUniqueID = NEWTSTR_ALLOCA(dbv.ptszVal);
        hDst = HContactFromID(szProto, pszUniqueSetting, pszUniqueID);
        break;
    }

    if (hDst != INVALID_CONTACT_ID) {
        AddMessage(LPGENT("Skipping duplicate %S contact %s"), szProto, pszUniqueID);
        srcDb->FreeVariant(&dbv);
        return NULL;
    }

    TCHAR *tszGroup = myGetWs(hSrc, "CList", "Group"), *tszNick = myGetWs(hSrc, "CList", "MyHandle");
    if (tszNick == NULL)
        tszNick = myGetWs(hSrc, szProto, "Nick");

    hDst = AddContact(hdlgProgress, szProto, pszUniqueSetting, &dbv, pszUniqueID, tszNick, tszGroup);
    mir_free(tszGroup), mir_free(tszNick);

    if (hDst != INVALID_CONTACT_ID) {
        // Hidden?
        if (!myGet(hSrc, "CList", "Hidden", &dbv)) {
            mySet(hDst, "CList", "Hidden", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Ignore settings
        if (!myGet(hSrc, "Ignore", "Mask1", &dbv)) {
            mySet(hDst, "Ignore", "Mask1", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Apparent mode
        if (!myGet(hSrc, szProto, "ApparentMode", &dbv)) {
            mySet(hDst, szProto, "ApparentMode", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Nick
        if (!myGet(hSrc, szProto, "Nick", &dbv)) {
            mySet(hDst, szProto, "Nick", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Myhandle
        if (!myGet(hSrc, szProto, "MyHandle", &dbv)) {
            mySet(hDst, szProto, "MyHandle", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // First name
        if (!myGet(hSrc, szProto, "FirstName", &dbv)) {
            mySet(hDst, szProto, "FirstName", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // Last name
        if (!myGet(hSrc, szProto, "LastName", &dbv)) {
            mySet(hDst, szProto, "LastName", &dbv);
            srcDb->FreeVariant(&dbv);
        }

        // About
        if (!myGet(hSrc, szProto, "About", &dbv)) {
            mySet(hDst, szProto, "About", &dbv);
            srcDb->FreeVariant(&dbv);
        }
    }
    else AddMessage(LPGENT("Unknown error while adding %S contact %s"), szProto, pszUniqueID);

    return hDst;
}
Beispiel #18
0
BOOL AFXAPI AfxOleRegisterControlClass(HINSTANCE hInstance,
	REFCLSID clsid, LPCTSTR pszProgID, UINT idTypeName, UINT idBitmap,
	int nRegFlags, DWORD dwMiscStatus, REFGUID tlid, WORD wVerMajor,
	WORD wVerMinor)
{
	USES_CONVERSION;

	BOOL bSuccess = FALSE;

	// Format class ID as a string
	OLECHAR szClassID[GUID_CCH];
	int cchGuid = ::StringFromGUID2(clsid, szClassID, GUID_CCH);
	LPCTSTR lpszClassID = OLE2CT(szClassID);

	ASSERT(cchGuid == GUID_CCH);    // Did StringFromGUID2 work?
	if (cchGuid != GUID_CCH)
		return FALSE;

	// Format typelib guid as a string
	OLECHAR szTypeLibID[GUID_CCH];
	cchGuid = ::StringFromGUID2(tlid, szTypeLibID, GUID_CCH);

	ASSERT(cchGuid == GUID_CCH);    // Did StringFromGUID2 work?
	if (cchGuid != GUID_CCH)
		return FALSE;

	CString strPathName;
	AfxGetModuleShortFileName(hInstance, strPathName);

	CString strTypeName;
	if (!strTypeName.LoadString(idTypeName))
	{
		ASSERT(FALSE);  // Name string not present in resources
		strTypeName = lpszClassID; // Use Class ID instead
	}

	TCHAR szBitmapID[_MAX_PATH];
	_itot(idBitmap, szBitmapID, 10);

	TCHAR szMiscStatus[_MAX_PATH];
	_ltot(dwMiscStatus, szMiscStatus, 10);

	// Format version string as "major.minor"
	TCHAR szVersion[_MAX_PATH];
	wsprintf(szVersion, _T("%d.%d"), wVerMajor, wVerMinor);

	// Attempt to open registry keys.
	HKEY hkeyClassID = NULL;
	HKEY hkeyProgID = NULL;

	TCHAR szScratch[_MAX_PATH];
	wsprintf(szScratch, _T("CLSID\\%s"), lpszClassID);
	if (::RegCreateKey(HKEY_CLASSES_ROOT, szScratch, &hkeyClassID) !=
		ERROR_SUCCESS)
		goto Error;
	if (::RegCreateKey(HKEY_CLASSES_ROOT, pszProgID, &hkeyProgID) !=
		ERROR_SUCCESS)
		goto Error;

	ASSERT(hkeyClassID != NULL);
	ASSERT(hkeyProgID != NULL);

	LPCTSTR rglpszSymbols[7];
	rglpszSymbols[0] = strTypeName;
	rglpszSymbols[1] = lpszClassID;
	bSuccess = AfxOleRegisterHelper(_afxCtrlProgID, rglpszSymbols, 2,
		TRUE, hkeyProgID);

	if (!bSuccess)
		goto Error;

	rglpszSymbols[1] = pszProgID;
	rglpszSymbols[2] = strPathName;
	rglpszSymbols[3] = szBitmapID;
	rglpszSymbols[4] = szMiscStatus;
	rglpszSymbols[5] = OLE2CT(szTypeLibID);
	rglpszSymbols[6] = szVersion;
	bSuccess = AfxOleRegisterHelper(_afxCtrlClassID, rglpszSymbols, 7,
		TRUE, hkeyClassID);

	if (!bSuccess)
		goto Error;

	if (nRegFlags & afxRegInsertable)
	{
		bSuccess =
			(::RegSetValue(hkeyProgID, _T("Insertable"), REG_SZ, _T(""), 0) ==
				ERROR_SUCCESS) &&
			(::RegSetValue(hkeyClassID, _T("Insertable"), REG_SZ, _T(""), 0) ==
				ERROR_SUCCESS);
	}

	if (nRegFlags & afxRegApartmentThreading)
	{
		HKEY hkeyInprocServer32;
		bSuccess = (::RegOpenKey(hkeyClassID, INPROCSERVER,
			&hkeyInprocServer32) == ERROR_SUCCESS);
		if (!bSuccess)
			goto Error;
		ASSERT(hkeyInprocServer32 != NULL);
		static TCHAR szApartment[] = _T("Apartment");
		bSuccess = (::RegSetValueEx(hkeyInprocServer32, _T("ThreadingModel"), 0,
			REG_SZ, (const BYTE*)szApartment, (lstrlen(szApartment)+1) * sizeof(TCHAR)) ==
			ERROR_SUCCESS);
		::RegCloseKey(hkeyInprocServer32);
	}

Error:
	if (hkeyProgID != NULL)
		::RegCloseKey(hkeyProgID);

	if (hkeyClassID != NULL)
		::RegCloseKey(hkeyClassID);

	return bSuccess;
}
Beispiel #19
0
void CGroupPrice::SubscribeGroup(const _QuoteUpdateParams& Params, GroupRequestType enRequest)
{
	_SetDbKey(Params);
	m_NeedToUnsubscribe.clear();
	long nResult = _GetOptions(Params, enRequest);
	if(DBA_ERR_NO_ERROR == nResult || DBA_TERMINATED == nResult)
	{
		if(m_bIsGotOptions && !m_bIsGotError)
		{
			if(enGroupRequestSubscribe != enRequest && enGroupRequestAllNotify != enRequest)
			{
				CDBARecordPtr pRec = CDBARecordPtr(new DBA_RECORD_3);
				ZeroMemory(pRec.get(), sizeof(DBA_RECORD_3));
				PublicLastQuote(&Params, pRec);
			}
			else if(enGroupRequestAllNotify == enRequest)
			{
				CResponseBasePtr pResponse = 
					boost::shared_static_cast<CResponseBase>(CSubscribedResponsePtr(new CSubscribedResponse(Params)));
				PublicResponse(pResponse);
			}
		}
		else if(!m_bIsGotOptions && !m_bIsGotError) 
		{
			CErrorResponsePtr pError = CErrorResponsePtr(new CErrorResponse());
			if(pError)
			{
				pError->m_enRequestType = enSubscribeQuote;
				const_cast<_QuoteUpdateParams&>(Params).CopyTo(pError->m_vtRequest);			
				pError->m_bstrDescription = L"Couldn't subscribe underlings options. Unknown symbol.";
				pError->m_Error = enNoDataAvailableForSymbol;

				PublicResponse(boost::shared_static_cast<CResponseBase>(pError));
			}
		}
		if(!m_NeedToUnsubscribe.empty())
		{
			boost::shared_ptr<CVectorKeys> pKeys = boost::shared_ptr<CVectorKeys>(new CVectorKeys());
			pKeys->insert(pKeys->end(), m_NeedToUnsubscribe.begin(), m_NeedToUnsubscribe.end());
			m_UnsubscribeStrategy.PushData(pKeys);
			m_NeedToUnsubscribe.clear();
		}

	}
	else
	{
		CErrorResponsePtr pError = CErrorResponsePtr(new CErrorResponse());
		if(pError)
		{
			pError->m_enRequestType = enSubscribeQuote;
			const_cast<_QuoteUpdateParams&>(Params).CopyTo(pError->m_vtRequest);			
			if(nResult == DBA_ERR_KEY_NOT_FOUND)
			{
				pError->m_bstrDescription = L"Unable to subscribe underlings options.";
				pError->m_Error = enNoDataAvailableForSymbol;
			}
			else if(nResult == DBA_ERR_INTEREST)
			{
				pError->m_bstrDescription = L"HyperFeed server subscription list is full";
				pError->m_Error = enProviderInternalError;
			}
			else if(nResult == DBA_TERMINATED)
			{
				pError->m_bstrDescription = L"Operation canceled by user.";
				pError->m_Error = enInternalError;
			}
			else
			{
				_bstr_t bs =  "Unable to subscribe underlings options. Error: ";
				bs += EtGetMessage(DBA_ERROR,nResult);
				TCHAR buffer[0x100] = {0};				
				_ltot(nResult,buffer,10);
				bs += " (";
				bs += buffer;
				bs += ")";
				pError->m_bstrDescription = bs;
				pError->m_Error = enProviderInternalError;
			}
			PublicResponse(boost::shared_static_cast<CResponseBase>(pError));
			EgLib::CEgLibTraceManager::Trace(LogError, __FUNCTION__ , _T("[%s]\t %s"), m_strUserName.c_str(), (LPCSTR)pError->m_bstrDescription);

		}
	}
	m_vtRequest.Clear();
}
void BinValToStrSimle(
    const BINVAL_TYP*    pVal,
    FC_CString*          pStr          //c-like value string
)
{
    TCHAR buffer[256];

    switch(pVal->typ) 
    {
    case BL_BOOL:
        buffer[0] = pVal->aBOOL ? _T('1') : _T('0');
        buffer[1] = 0;
    break;
    case BL_BYTE:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ltot(pVal->aBYTE & 0xff, buffer+2, 16);
    break;
    case BL_WORD:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ltot(pVal->aWORD & 0xffff, buffer+2, 16);
    break;
    case BL_UINT:
        _ultot(pVal->aWORD & 0xffff, buffer, 10);
    break;
    case BL_INT:
        _ltot(pVal->aINT, buffer, 10);
    break;
    case BL_DWORD:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ltot(pVal->aDWORD, buffer+2, 16);
    break;
    case BL_UDINT:
        _ultot(pVal->aDWORD, buffer, 10);
    break;
    case BL_DINT: 
        _ltot(pVal->aDINT, buffer, 10);
    break;
    case BL_LWORD:
        buffer[0] = '0';
        buffer[1] = 'x';
        _ui64tot(pVal->aLWORD, buffer+2, 16);
    break;
    case BL_LINT:
        _ui64tot(pVal->aLINT, buffer, 10);
    break;
    case BL_REAL:
        if(pVal->aREAL != 0.0)
            _stprintf(buffer, _T("%.8e"), (double)pVal->aREAL);                  
        else
            _tcscpy(buffer, _T("0"));
    break;
    case BL_LREAL:    
        if(pVal->aLREAL != 0.0)
            _stprintf(buffer, _T("%.17e"), pVal->aLREAL);
        else
            _tcscpy(buffer, _T("0"));
    break;
    case BL_TOD:
        _ltot(pVal->aTOD, buffer, 10);
    break;
    case  BL_DATE:
        _ltot(pVal->aDATE, buffer, 10);
    break;
    case  BL_TIME:
        _ui64tot(pVal->aTIME, buffer, 10);
    break;
    case  BL_DT:
        _ui64tot(pVal->aDT, buffer, 10);
    break;
    case BL_STRING:
    case BL_WSTRING:
        pStr->load(pVal->pszStr); //HACK
        return;
    break;
    default:
        assert(!"data type not supported");
        pStr->load(_T("<data type not supported>"));
        return;
    }

    pStr->load(buffer);
}
Beispiel #21
0
DWORD CQHState::OnGetSchema( DWORD size, void *params )
{
	VERIFY_MESSAGE_SIZE(size, sizeof(GETSCHEMAPARAMS));
	GETSCHEMAPARAMS *getSchemaParams = (GETSCHEMAPARAMS*)params;
	IXMLArchive *archive = getSchemaParams->ar;
	if( archive != NULL )
	{
		archive->StartClass( GetComponentType()->GetString() );
		archive->Write( m_Name.GetString(), _T("Name") );
		archive->Write( 5 );

		archive->StartClass(_T("hidden") );
		archive->Write( _T("float"), _T("Type") );
		archive->EndClass();

		if( m_bAbstract )
		{
			archive->StartClass( _T("static") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("State Name"), _T("Name") );
			archive->EndClass();

			archive->StartClass( _T("static") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("Entry Event"), _T("Name") );
			archive->EndClass();

			archive->StartClass( _T("static") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("Update Event"), _T("Name") );
			archive->EndClass();

			archive->StartClass( _T("static") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("Exit Event"), _T("Name") );
			archive->EndClass();
		}
		else
		{
			TCHAR szComboNum[] = _T("ComboItem_XXXX");
			LPTSTR szNum = szComboNum + sizeof(szComboNum) / sizeof(*szComboNum) - 4;


			archive->StartClass( _T("edit") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("State Name"), _T("Name") );
			archive->Write( false, _T("Key") );
			archive->EndClass();

			archive->StartClass( _T("combo") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("Entry Event"), _T("Name") );
			archive->Write( false, _T("Key") );
			archive->Write( _T(""), _T("DefSelect") );

			OBJECTLIST eventList;
			GenerateAvailableEventsList( &eventList );
			int eventListCount = eventList.size() + 1;
			OBJECTLIST::iterator eventListIterator = eventList.begin();
			archive->Write( eventListCount, _T("Count") );
			int comboItemCounter = 0;
			_ltot( ++comboItemCounter, szNum, 10 );
			archive->Write( _T(""), szComboNum );
			for(; eventListIterator != eventList.end(); eventListIterator++ )
			{
				_ltot( ++comboItemCounter, szNum, 10 );
				CQHStateMachineEvent *iteratedEvent = (CQHStateMachineEvent*)(*eventListIterator);
				archive->Write( iteratedEvent->GetEventName()->GetString(), szComboNum );
			}
			archive->EndClass();

			archive->StartClass( _T("combo") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("Update Event"), _T("Name") );
			archive->Write( false, _T("Key") );
			archive->Write( _T(""), _T("DefSelect") );

			eventListIterator = eventList.begin();
			archive->Write( eventListCount, _T("Count") );
			comboItemCounter = 0;
			_ltot( ++comboItemCounter, szNum, 10 );
			archive->Write( _T(""), szComboNum );
			for(; eventListIterator != eventList.end(); eventListIterator++ )
			{
				_ltot( ++comboItemCounter, szNum, 10 );
				CQHStateMachineEvent *iteratedEvent = (CQHStateMachineEvent*)(*eventListIterator);
				archive->Write( iteratedEvent->GetEventName()->GetString(), szComboNum );
			}
			archive->EndClass();

			archive->StartClass( _T("combo") );
			archive->Write( _T("string"), _T("Type") );
			archive->Write( _T("Exit Event"), _T("Name") );
			archive->Write( false, _T("Key") );
			archive->Write( _T(""), _T("DefSelect") );

			eventListIterator = eventList.begin();
			archive->Write( eventListCount, _T("Count") );
			comboItemCounter = 0;
			_ltot( ++comboItemCounter, szNum, 10 );
			archive->Write( _T(""), szComboNum );
			for(; eventListIterator != eventList.end(); eventListIterator++ )
			{
				_ltot( ++comboItemCounter, szNum, 10 );
				CQHStateMachineEvent *iteratedEvent = (CQHStateMachineEvent*)(*eventListIterator);
				archive->Write( iteratedEvent->GetEventName()->GetString(), szComboNum );
			}
			archive->EndClass();
		}

		archive->EndClass();
	}
	else
	{
		m_ToolBox->Log( LOGERROR, _T("Attempt to get CQHState schema. No archive specified.\n" ) );
	}

	return MSG_HANDLED_STOP;
}
Beispiel #22
0
void CGUIPage::Serialize(IArchive &ar)
{
	CGUIManager *manager;
	static CHashString managerName(_T("CGUIManager"));
	IObject *Object;
	StdString pageName;
	StdString guiName;
	StdString guiType;
	StdString type;
	int iNumGuiElements;
	OBJECTLIST::iterator olIter;

	if(ar.IsReading())
	{
		CHashString versionName;
		static DWORD msgHash_GetFileVersion = CHashString(_T("GetFileVersion")).GetUniqueID();
		DWORD retval = EngineGetToolBox()->SendMessage(msgHash_GetFileVersion, sizeof(IHashString), &versionName);

		static DWORD Vers2_0a = CHashString(_T("2.0a")).GetUniqueID();
		static DWORD Vers2_0b = CHashString(_T("2.0b")).GetUniqueID();
		static DWORD Vers2_0c = CHashString(_T("2.0c")).GetUniqueID();

		int verNum = 0;
		
		if (versionName.GetUniqueID() == Vers2_0a)
		{
			verNum = 3;
		}
		else if (versionName.GetUniqueID() == Vers2_0b)
		{
			verNum = 4;
		}
		else if (versionName.GetUniqueID() == Vers2_0c)
		{
			verNum = 5;
		}
		else 
		{
			m_ToolBox->Log(LOGERROR, _T("Bad GUI file version!"));
			assert(0);
			return;
		}

		float loadVersion = 0.0f;

		if (verNum >= 4)
		{
			ar.Read(loadVersion);
			if (loadVersion == 0.0f)
			{
				// initial serialize from editor; set to save version (up to date schema)
				loadVersion = m_fSaveVersion;
			}
		}

		ar.Read(iNumGuiElements);
		while(iNumGuiElements != 0)
		{
			ar.Read(guiName);
			ar.Read(guiType);

			CHashString szhGuiName(guiName.c_str());
			CHashString szhGuiType(guiType.c_str());

			// ask gui manager for the object to add
			manager = dynamic_cast<CGUIManager*>(EngineGetToolBox()->GetComponent( &managerName ));
			if (!manager)
			{
				EngineGetToolBox()->SetErrorValue(ERR_NULL_POINTER);
				EngineGetToolBox()->Log(LOGERROR, _T("could not cast IComponent from EngineToolBox to CGUIManager\n")); 
				return;
			}
			Object = manager->GetObject(&szhGuiName, &szhGuiType);
			if(Object == NULL)
			{
				CREATEOBJECTPARAMS cop;
				INITOBJECTPARAMS iop;
				cop.name = &szhGuiName;
				cop.typeName = &szhGuiType;
				cop.parentName = GetName();
				iop.name = &szhGuiName;

				static DWORD msgHash_CreateObject = CHashString(_T("CreateObject")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_CreateObject, sizeof(CREATEOBJECTPARAMS), &cop, NULL, NULL);
				static DWORD msgHash_InitObject = CHashString(_T("InitObject")).GetUniqueID();
				m_ToolBox->SendMessage(msgHash_InitObject, sizeof(INITOBJECTPARAMS), &cop, NULL, NULL);
				Object = manager->GetObject(&szhGuiName, &szhGuiType);
			}
			m_ObjectList.push_back(Object);
			iNumGuiElements--;
		}

	}
	else //ar.IsWritting()
	{
		TCHAR strNum[50];
		int count = 1;
		StdString itemName;
		StdString itemType;

		//pageName = GetName()->GetString();
		//type = GetComponentType()->GetString();
		iNumGuiElements = m_ObjectList.size();

		ar.Write(m_fSaveVersion, _T("Version"));

		// start the page class
		//ar.StartClass(type); // <CGUIPage
		// write the page's name
		//ar.Write( pageName, _T("Name") );
		// write the number of gui elements 
		ar.Write( iNumGuiElements, _T("NumGuiElements") );
		
		for(olIter = m_ObjectList.begin(); olIter != m_ObjectList.end();
			olIter++)
		{

			_ltot(count, strNum, 10);
			itemName = StdString(_T("GuiName")) + strNum;
			itemType = StdString(_T("GuiType")) + strNum;

			guiName = (*olIter)->GetName()->GetString();
			ar.Write( guiName, itemName );
			guiType = (*olIter)->GetComponentType()->GetString();
			ar.Write( guiType, itemType );
			count++;
		}
		//ar.EndClass(); // </CGUIPage>
	}
}
Beispiel #23
0
UINT ShowMessageBox (UINT Id, UINT Button, UINT Help, ...) {

    CString temp;
    TCHAR *pszstring, 
    *pszpaste, 
    *pszcut, 
    *pszdone,
    *pszconvert;
    TCHAR chread;
    va_list params;
    int x;

    pszconvert = new TCHAR[255];    	
    va_start(params, Help);
    LoadString (temp, Id);
    pszstring = temp.GetBuffer(512);
    _tcscpy(pszstring,pszstring);
    temp.ReleaseBuffer();
    // Look and see - is there a need to insert chars (95% of the time, there won't)
    if (!_tcsstr(pszstring, _T("%"))) {
	delete pszconvert;
	return AfxMessageBox(pszstring, Button, Help);
    }   

    x = _tcscspn(pszstring, _T("%"));
    pszdone = new TCHAR[512];
    pszcut = new TCHAR[512];
    pszpaste = new TCHAR[512];
    _tcscpy(pszcut, &pszstring[x+2]);
    _tcsncpy(pszpaste, pszstring, x);
    pszpaste[x] = _T('\0');
    chread = pszstring[x+1];

    for ( ; ; ) {

	switch (chread) { 
	case	_T('i') :
	case	_T('d') :
	{ 	    
	    int anint = va_arg(params, int);
	    _itot( anint, pszconvert, 10);
	    break;
	}
	case	_T('u') :
	{	
	    UINT anuint = va_arg(params, UINT);
	    _itot( anuint, pszconvert, 10);
	    break;
	}

	case	_T('x') :
	case	_T('X') :   
	{
	    int ahex = va_arg(params, int);
	    _itot( ahex, pszconvert, 16);
	    break;
	}
	case	_T('g') :
	case	_T('f') :
	case	_T('e') :   
	{
	    double adbl = va_arg(params, double);
            _stprintf(pszconvert, _T("%g"), adbl);
	    break;
	}
	case	_T('s') :	
	{
	    TCHAR *pStr = va_arg(params, TCHAR*);
	    ASSERT(_tcslen(pStr) <= 255);
	    _tcscpy(pszconvert, pStr);
	    break;
	}
	case	_T('l') :	
	{
	    chread = pszdone[x+2];
	    switch(chread) {
	    case	_T('x')	:
	    {
		long int alhex = va_arg(params, long int);
		_ltot(alhex, pszconvert, 16);
		_tcscpy(pszcut, &pszcut[1]);
		break;
	    }
	    case 	_T('d')	:
		default 	:
		{
		    long int along = va_arg(params, long int);
		    _ltot( along, pszconvert, 10);
		    // For the L, there will be one character after it,
		    //   so move ahead another letter
		    _tcscpy(pszcut, &pszcut[1]);
		    break;
		}
	    }
	    break;
	}

	case	_T('c') :	
	{
	    int letter = va_arg(params, int);
	    pszconvert[0] = (TCHAR)letter;
	    pszconvert[1] = '\0'; 
	    break;
	}
	case 	_T('a')	:
	{
	    CString zeta;
	    TCHAR* lsc;
	    UINT ls = va_arg(params, UINT);
	    LoadString (zeta, ls);
	    lsc = zeta.GetBuffer(255);
	    _tcscpy(pszconvert, lsc);
	    zeta.ReleaseBuffer();
	    break;
	}
	case	_T('o')	:
	{
	    CString get = va_arg(params, CString);
	    TCHAR* ex = get.GetBuffer(255);
	    _tcscpy(pszconvert,ex);
	    get.ReleaseBuffer();
	    break;
	}
	    default 	:
	    {	
		_tcscpy(pszconvert, _T(" Could not load message. Invalid %type in string table entry. "));
		delete pszdone;
		pszdone = new TCHAR[_tcslen(pszpaste)+_tcslen(pszcut)+_tcslen(pszconvert)+5];
		_tcscpy(pszdone, pszpaste);
		_tcscat(pszdone, pszconvert);
		_tcscat(pszdone, pszcut);
		AfxMessageBox(pszdone, Button, Help);
		delete pszcut;
		delete pszpaste;
		delete pszconvert;
		delete pszdone;
		ASSERT(FALSE);
		return 0;
	    }		
	} // case

	delete pszdone;
	pszdone = new TCHAR[_tcslen(pszpaste)+_tcslen(pszcut)+_tcslen(pszconvert)+5];
	_tcscpy(pszdone, pszpaste);
	_tcscat(pszdone, pszconvert);
	_tcscat(pszdone, pszcut);
	// Now pszdone holds the entire message.
	// Check to see if there are more insertions to be made or not
	
	if (!_tcsstr(pszdone, _T("%")))	{
	    UINT rt_type = AfxMessageBox(pszdone, Button, Help);
	    delete pszcut;
	    delete pszpaste;
	    delete pszconvert;
	    delete pszdone;
	    return rt_type;
	} // if

	// there are more insertions to make, prepare the strings to use.
	x = _tcscspn(pszdone, _T("%"));
	_tcscpy(pszcut, &pszdone[x+2]);
	_tcsncpy(pszpaste, pszdone, x); 
	pszpaste[x] = _T('\0');
	chread = pszdone[x+1];
	
    } // for
    ASSERT(FALSE);		
    return 0;

} // ShowMessageBox
Beispiel #24
0
void CGroupPrice::SubscribeGroup(const _QuoteUpdateParams& Params, GroupRequestType enRequest)
{
	_SetDbKey(Params);
	
	long nResult = _GetOptions(Params, enRequest);
	if(DBA_ERR_NO_ERROR == nResult)
	{
		if(m_bIsGotOptions && !m_bIsGotError)
		{
			if(enGroupRequestSubscribe != enRequest && enGroupRequestAllNotify != enRequest)
			{
				DBA_RECORD_3 rec;
				ZeroMemory(&rec, sizeof(rec));
				PublicLastQuote(Params, rec);
			}
			else if(enGroupRequestAllNotify == enRequest)
			{
				CResponseBasePtr pResponse = 
					boost::shared_dynamic_cast<CResponseBase>(CSubscribedResponsePtr(new CSubscribedResponse(Params)));
				PublicResponse(pResponse);
			}
		}
		else if(!m_bIsGotOptions && !m_bIsGotError) 
		{
			CErrorResponsePtr pError = CErrorResponsePtr(new CErrorResponse());
			if(pError)
			{
				pError->m_enRequestType = enSubscribeQuote;
				const_cast<_QuoteUpdateParams&>(Params).CopyTo(pError->m_vtRequest);			
				pError->m_bstrDescription = L"Couldn't subscribe underlyings options. Unknown symbol.";
				pError->m_Error = enNoDataAvailableForSymbol;

				PublicResponse(boost::shared_dynamic_cast<CResponseBase>(pError));
			}
		}
	}
	else
	{
		CErrorResponsePtr pError = CErrorResponsePtr(new CErrorResponse());
		if(pError)
		{
			pError->m_enRequestType = enSubscribeQuote;
			const_cast<_QuoteUpdateParams&>(Params).CopyTo(pError->m_vtRequest);			
			if(nResult == DBA_ERR_KEY_NOT_FOUND)
			{
				pError->m_bstrDescription = L"Couldn't subscribe underlyings options.";
				pError->m_Error = enNoDataAvailableForSymbol;
			}
			else if(nResult == DBA_ERR_INTEREST)
			{
				pError->m_bstrDescription = L"HyperFeed server subscription list is full";
				pError->m_Error = enProviderInternalError;
			}
			else if(nResult == DBA_TERMINATED)
			{
				pError->m_bstrDescription = L"Operation canceled by user.";
				pError->m_Error = enInternalError;
			}
			else
			{
				_bstr_t bs =  "Couldn't underlyings options. Error: ";
				bs += EtGetMessage(DBA_ERROR,nResult);
				TCHAR buffer[0x100] = {0};				
				_ltot(nResult,buffer,10);
				bs += " (";
				bs += buffer;
				bs += ")";
				pError->m_bstrDescription = bs;
				pError->m_Error = enProviderInternalError;
			}
			PublicResponse(boost::shared_dynamic_cast<CResponseBase>(pError));
		}
	}
	m_vtRequest.Clear();
}
int COptDownloadPackage::downloadInfoFile()
{
	CConfig				*pAgentConfig = getAgentConfig();
	CComProvider		*pProvider = getComServerProvider();
	CServerConfig		*pServerConfig = pProvider->newConfig();
	CConnexionAbstract	*pConnexion = NULL;
	TCHAR				szDummy[_MAX_PATH + 1];

	ASSERT(pAgentConfig);
	ASSERT(pProvider);
	ASSERT(pServerConfig);

	// Create provider connection object using default Provider configuration
	if ((pConnexion = pProvider->newConnexion(pServerConfig)) == NULL)
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Failed creating connection for Communication Provider <%s>"), pAgentConfig->getCommunicationProvider());
		pProvider->deleteConfig(pServerConfig);
		return FALSE;
	}
	// Download metadata info file
	m_pLogger->log(LOG_PRIORITY_DEBUG, _T("DOWNLOAD => Metadata file <info> for package <%s> is located at <%s>"), m_csId, getRemoteMetadataURL());
	if (!pConnexion->getFile(getRemoteMetadataURL(), getLocalMetadataFilename()))
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Failed to download Metadata file <%s> to <%s>"), getRemoteMetadataURL(), getLocalMetadataFilename());
		pProvider->deleteConnexion(pConnexion);
		pProvider->deleteConfig(pServerConfig);
		return FALSE;
	}
	m_pLogger->log(LOG_PRIORITY_DEBUG, _T("DOWNLOAD => Unloading communication provider"));
	// Use provider to delete connexion and server config
	pProvider->deleteConnexion(pConnexion);
	pProvider->deleteConfig(pServerConfig);

	// Open metadata file to add fragment location
	CString csBuffer;
	CMarkup xml;
	if (!xml.LoadFile(getLocalMetadataFilename()))
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Cannot read or parse Metadata file <%s>"), getLocalMetadataFilename());
		return FALSE;
	}
	// Add fragment location to meta data
	xml.FindFirstElem(_T("DOWNLOAD"));
	xml.SetAttrib(_T("LOC"), m_csRemotePackLoc);
	// Add package schedule to meta data
	xml.SetAttrib(_T("SCHEDULE"), m_csSchedule);
	// Add post execution command to meta data
	xml.SetAttrib(_T("POSTCMD"), m_csPostCmd);
	// Write meta data file
	if (!xml.SaveFile(getLocalMetadataFilename()))
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Can't update Metadata file <%s>"), getLocalMetadataFilename());
		return FALSE;
	}
	// Compute digest on meta data and add it to Registry
	if (!fileDigest(getLocalMetadataFilename(), csBuffer))
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Can't register package <%s> into Registry"), m_csId);
		DeleteFile(getLocalMetadataFilename());
		return FALSE;
	}
	if (!regAddPackageDigest(m_csId, csBuffer))
	{
		m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Can't register package <%s> into Registry"), m_csId);
		DeleteFile(getLocalMetadataFilename());
		return FALSE;
	}
	// Now create a timestamp 
	csBuffer.Format(_T("%s\\%s\\%s"), getDownloadFolder(), m_csId, OCS_DOWNLOAD_TIMESTAMP);
	if (!fileExists(csBuffer))
	{
		_ltot(time(NULL), szDummy, 10);
		if (!WriteTextToFile(szDummy, csBuffer))
			m_pLogger->log(LOG_PRIORITY_ERROR, _T("DOWNLOAD => Can't create timestamp file <%s>"), csBuffer);
	}
	else
		m_pLogger->log(LOG_PRIORITY_DEBUG, _T("DOWNLOAD => Timestamp file <%s> already exists"), csBuffer);
	m_pLogger->log(LOG_PRIORITY_DEBUG, _T("DOWNLOAD => Retrieve info file...OK (pack %s)"), m_csId);
	return TRUE;
}
Beispiel #26
0
//+----------------------------------------------------------------------
//
//  Function:   NumberToNumeral( n, achBuffer[NUMCONV_STRLEN] )
//
//              Convert a long value to a numeric string.
//
//  Returns:    A string in achBuffer.
//
//-----------------------------------------------------------------------
void NumberToNumeral(LONG n, TCHAR achBuffer[NUMCONV_STRLEN])
{
    _ltot(n, achBuffer, 10);
    _tcscat(achBuffer, _T("."));
}
Beispiel #27
0
long CGroupPrice::_OptionsProc(ULONG ulFunction, DBA_KEY *pDbaKey, DBA_OPTIONS_FILTER_RECORD *pDbaRec, DWORD dwStatus) 
{
	if (ulFunction == DBA_TERMINATE_STREAM_FUNCTION || m_bTerminate)
	{
		SetEvent(m_hTerminateGroupOption);
		return TRUE;
	}

	if (dwStatus == DBA_ERR_NO_ERROR)
	{
#ifdef __PERFMON
		if(m_spGlobalPerfCounter!=NULL)
			m_spGlobalPerfCounter->AddGroupRequestResponce();
		if(m_pPerfMon)
			m_pPerfMon->AddGroupRequestResponce();
#endif // __PERFMON


		if(_IsOurOptionExchange(pDbaKey->exchangeCode[0]))
		{
			_QuoteUpdateParams Params;
			ParamFromKey(*pDbaKey, enOPT, Params);

			CHahedKeyStringPtr pHashedKey = CHahedKeyStringPtr(new CHahedKeyString(pDbaKey));


			if(enGroupRequestLastQuote != m_enRequestType)
				EgLib::CEgLibTraceManager::Trace(LogSubsExt, __FUNCTION__, _T("[%s]\t Group Option Subscribe %s"), m_strUserName.c_str(), pHashedKey->GetKeyString().c_str()); 
			else
				EgLib::CEgLibTraceManager::Trace(LogSubsExt, __FUNCTION__, _T("[%s]\t Group Option Get %s"), m_strUserName.c_str(), pHashedKey->GetKeyString().c_str()); 

			//StoreClosePrice(pHashedKey, );
			//EgLib::CEgLibTraceManager::Trace(LogCustom, __FUNCTION__, _T("[%s]\t Group Option Close Price Set %s"), m_strUserName.c_str(), pHashedKey->GetKeyString().c_str()); 

			m_bIsGotOptions = true;

			if(enGroupRequestLastQuote != m_enRequestType)
			{
				if(m_bsUndSymbol.length())
				{
					CAutoLock lk(m_csGroupSubscript);
					m_mapGroupSubscript[m_bsUndSymbol].insert(pHashedKey);
				}

				CSubscriptionInfoPtr pSubscription = AddSubscription(pHashedKey, enOPT);
				pSubscription->SetClosePrice(pDbaRec->priceRec.dbaRec.close.price);

				if(enGroupRequestAllNotify == m_enRequestType)
				{
					CSubscribedResponsePtr pResponse = CSubscribedResponsePtr(new CSubscribedResponse(Params));
					PublicResponse(boost::shared_dynamic_cast<CResponseBase>(pResponse));
				}
				CDBARecordPtr pRecData =  CDBARecordPtr(new DBA_RECORD_3);
				memcpy(pRecData.get(), &pDbaRec->priceRec.dbaRec, sizeof(DBA_RECORD_3));

				pSubscription->AssignData(pRecData);
				PostIntoRealtimeMessageProcessor(pSubscription);

				pRecData = pSubscription->GetData();
				PublicLastQuote(&Params, pRecData);
			}
			
			if(enGroupRequestSubscribe != m_enRequestType && enGroupRequestAllNotify != m_enRequestType)
			{
				CDBARecordPtr pRec = CDBARecordPtr(new DBA_RECORD_3);
				if(pRec!=NULL)
				{
					memcpy(pRec.get(), &pDbaRec->priceRec.dbaRec, sizeof(DBA_RECORD_3));
					PublicLastQuote(&Params, pRec);
				}
			}
		}
		else
		{
			if(enGroupRequestLastQuote != m_enRequestType)
				m_NeedToUnsubscribe.push_back(CHahedKeyStringPtr(new CHahedKeyString(pDbaKey)));
		}
		return FALSE;
	}
	else 
	{
		CErrorResponsePtr 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"Unable to subscribe underlying 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 =  "Unable to get underlying 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;
			}
			EgLib::CEgLibTraceManager::Trace(LogError, __FUNCTION__ , _T("[%s]\t %s"), m_strUserName.c_str(), (LPCSTR)pError->m_bstrDescription);

		}
		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 = boost::shared_dynamic_cast<CResponseBase>(pError);
		PublicResponse(pErrorPtr);
		m_bIsGotError = true;
		EgLib::CEgLibTraceManager::Trace(LogError, __FUNCTION__ , _T("[%s]\t %s"), m_strUserName.c_str(), (LPCSTR)pError->m_bstrDescription);

	}

	return FALSE;
}
Beispiel #28
0
// copied and modified from NewStatusNotify
INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) 
{
	int ID;
	TCHAR str[512];
	HMENU hMenu, hMenu1;
	RECT pos;
	HWND button;
	MCONTACT hContact;

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hdlg);
		SaveOptions();

		// click actions
		hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
		hMenu1 = GetSubMenu(hMenu, 0);
		GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
		SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
		GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
		SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
		DestroyMenu(hMenu);

		// other options
		CheckDlgButton(hdlg, IDC_E, opt.UsePopup);
		CheckDlgButton(hdlg, IDC_POP2, opt.AlertPopup);
		CheckDlgButton(hdlg, IDC_POP1, opt.UpdatePopup);
		CheckDlgButton(hdlg, IDC_CH, opt.PopupOnChange);
		CheckDlgButton(hdlg, IDC_W, opt.ShowWarnings);
		SetDlgItemText(hdlg,IDC_PText, opt.pText);
		SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
		// setting popup delay option
		_ltot(opt.pDelay, str, 10);
		SetDlgItemText(hdlg,IDC_DELAY, str);
		if (opt.pDelay == -1)
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
		else if (opt.pDelay == 0)
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
		else
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
		//Colours. First step is configuring the colours.
		SendDlgItemMessage(hdlg,IDC_BGCOLOUR,CPM_SETCOLOUR,0,opt.BGColour);
		SendDlgItemMessage(hdlg,IDC_TEXTCOLOUR,CPM_SETCOLOUR,0,opt.TextColour);
		//Second step is disabling them if we want to use default Windows ones.
		CheckDlgButton(hdlg, IDC_USEWINCOLORS,opt.UseWinColors?BST_CHECKED:BST_UNCHECKED);
		EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !opt.UseWinColors);
		EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !opt.UseWinColors);

		// buttons
		SendMessage(GetDlgItem(hdlg,IDC_PREVIEW), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_PDEF), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_LeftClick), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_RightClick), BUTTONSETASFLATBTN, TRUE, 0);
		SendMessage(GetDlgItem(hdlg,IDC_VAR3), BUTTONSETASFLATBTN, TRUE, 0);
		return TRUE;

	case WM_COMMAND:
		// enable the "apply" button 
		if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
		if ( !((LOWORD(wParam) == IDC_UPDATE || LOWORD(wParam) == IDC_DEGREE) && 
			(HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())))
			SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
		//These are simple clicks: we don't save, but we tell the Options Page to enable the "Apply" button.
		switch(LOWORD(wParam)) {
		case IDC_BGCOLOUR: //Fall through
		case IDC_TEXTCOLOUR:
			// select new colors
			if (HIWORD(wParam) == CPN_COLOURCHANGED)
				SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_USEWINCOLORS:
			// use window color - enable/disable color selection controls
			EnableWindow(GetDlgItem(hdlg, IDC_BGCOLOUR), !(opt.UseWinColors));
			EnableWindow(GetDlgItem(hdlg, IDC_TEXTCOLOUR), !(opt.UseWinColors));
			SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_E:
		case IDC_CH:
			SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
			break;

		case IDC_RightClick:
			// right click action selection menu
			button = GetDlgItem(hdlg, IDC_RightClick);
			GetWindowRect(button, &pos); 

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			TranslateMenu(hMenu1);
			SelectMenuItem(hMenu1, opt.RightClickAction);
			ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
			if (ID)   opt.RightClickAction = ID;
			DestroyMenu(hMenu);

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			GetMenuString(hMenu1, opt.RightClickAction, str, sizeof(str), MF_BYCOMMAND);
			SetDlgItemText(hdlg, IDC_RightClick, TranslateTS(str));
			DestroyMenu(hMenu);
			break;

		case IDC_LeftClick:
			// left click action selection menu
			button = GetDlgItem(hdlg, IDC_LeftClick);
			GetWindowRect(button, &pos); 

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			TranslateMenu(hMenu1);
			SelectMenuItem(hMenu1, opt.LeftClickAction);
			ID = TrackPopupMenu(hMenu1, TPM_LEFTBUTTON|TPM_RETURNCMD, pos.left, pos.bottom, 0, hdlg, NULL);
			if (ID)   opt.LeftClickAction = ID;
			DestroyMenu(hMenu);

			hMenu  = LoadMenu(hInst, MAKEINTRESOURCE(IDR_PMENU));
			hMenu1 = GetSubMenu(hMenu, 0);
			GetMenuString(hMenu1, opt.LeftClickAction, str, sizeof(str), MF_BYCOMMAND);
			SetDlgItemText(hdlg, IDC_LeftClick, TranslateTS(str));
			DestroyMenu(hMenu);
			break;

		case IDC_PD1:
			// Popup delay setting from Popup plugin
			SetDlgItemText(hdlg, IDC_DELAY, _T("0"));
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
			break;

		case IDC_PD2:
			// Popup delay = permanent
			SetDlgItemText(hdlg, IDC_DELAY, _T("-1"));
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
			break;

		case IDC_DELAY:
			// if text is edited
			CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
			break;

		case IDC_PDEF:
			// set the default value for popup texts
			SetTextDefault("Pp");
			SetDlgItemText(hdlg,IDC_PText, opt.pText);
			SetDlgItemText(hdlg,IDC_PTitle, opt.pTitle);
			wfree(&opt.pText);
			wfree(&opt.pTitle);
			break;

		case IDC_VAR3:
			// display variable list
			_tcscpy(str, _T("                                                            \n"));		// to make the message box wider
			_tcscat(str, TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temperature\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set"));
			_tcscat(str, _T("\n"));
			_tcscat(str, TranslateT("%[..]\tcustom variables"));
			MessageBox(NULL, str, TranslateT("Variable List"), MB_OK|MB_ICONASTERISK|MB_TOPMOST);
			break;

		case IDC_PREVIEW:
			// popup preview
			hContact = opt.DefStn;
			ReadPopupOpt(hdlg);	// read new options to memory
			WeatherPopup((WPARAM)opt.DefStn, (BOOL)TRUE);	// display popup using new opt
			DestroyOptions();
			LoadOptions();		// restore old option in memory
			opt.DefStn = hContact;
			break;
		}
		break;
	
	case WM_NOTIFY: //Here we have pressed either the OK or the APPLY button.
		switch (((LPNMHDR)lParam)->code) {
			case PSN_APPLY: {
				ReadPopupOpt(hdlg);

				// save the options, and update main menu
				SaveOptions();
				UpdatePopupMenu(opt.UsePopup);
				return TRUE;
			}
		}
		break;
	}
	return FALSE;
}
Beispiel #29
0
TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact)
{
#define MAXSIZE 1024
	static TCHAR sztemp[MAXSIZE + 1];
	TCHAR szdbsetting[128];
	TCHAR *charPtr;
	int isetting = 0;
	DWORD dwsetting = 0;
	struct in_addr ia;
	DBVARIANT dbv;

	sztemp[0] = '\0';

	SYSTEMTIME st;
	if (!isSeen(hcontact, &st)) {
		mir_tstrcat(sztemp, TranslateT("<never seen>"));
		return sztemp;
	}

	CONTACTINFO ci = { sizeof(CONTACTINFO) };
	ci.hContact = hcontact;
	ci.szProto = hcontact ? GetContactProto(hcontact) : courProtoName;

	TCHAR *d = sztemp;
	for (TCHAR *p = szstring; *p; p++) {
		if (d >= sztemp + MAXSIZE)
			break;

		if (*p != '%' && *p != '#') {
			*d++ = *p;
			continue;
		}

		bool wantempty = *p == '#';
		switch (*++p) {
		case 'Y':
			if (!st.wYear) goto LBL_noData;
			d += _stprintf(d, _T("%04i"), st.wYear); //!!!!!!!!!!!!
			break;

		case 'y':
			if (!st.wYear) goto LBL_noData;
			d += _stprintf(d, _T("%02i"), st.wYear % 100); //!!!!!!!!!!!!
			break;

		case 'm':
			if (!(isetting = st.wMonth)) goto LBL_noData;
		LBL_2DigNum:
			d += _stprintf(d, _T("%02i"), isetting); //!!!!!!!!!!!!
			break;

		case 'd':
			if (isetting = st.wDay) goto LBL_2DigNum;
			else goto LBL_noData;

		case 'W':
			isetting = st.wDayOfWeek;
			if (isetting == -1) {
			LBL_noData:
				charPtr = wantempty ? _T("") : TranslateT("<unknown>");
				goto LBL_charPtr;
			}
			charPtr = TranslateTS(weekdays[isetting]);
		LBL_charPtr:
			d += mir_sntprintf(d, MAXSIZE - (d - sztemp), _T("%s"), charPtr);
			break;

		case 'w':
			isetting = st.wDayOfWeek;
			if (isetting == -1) goto LBL_noData;
			charPtr = TranslateTS(wdays_short[isetting]);
			goto LBL_charPtr;

		case 'E':
			if (!(isetting = st.wMonth)) goto LBL_noData;
			charPtr = TranslateTS(monthnames[isetting - 1]);
			goto LBL_charPtr;

		case 'e':
			if (!(isetting = st.wMonth)) goto LBL_noData;
			charPtr = TranslateTS(mnames_short[isetting - 1]);
			goto LBL_charPtr;

		case 'H':
			if ((isetting = st.wHour) == -1) goto LBL_noData;
			goto LBL_2DigNum;

		case 'h':
			if ((isetting = st.wHour) == -1) goto LBL_noData;
			if (!isetting) isetting = 12;
			isetting = isetting - ((isetting > 12) ? 12 : 0);
			goto LBL_2DigNum;

		case 'p':
			if ((isetting = st.wHour) == -1) goto LBL_noData;
			charPtr = (isetting >= 12) ? _T("PM") : _T("AM");
			goto LBL_charPtr;

		case 'M':
			if ((isetting = st.wMinute) == -1) goto LBL_noData;
			goto LBL_2DigNum;

		case 'S':
			if ((isetting = st.wHour) == -1) goto LBL_noData;
			goto LBL_2DigNum;

		case 'n':
			charPtr = hcontact ? (TCHAR*)pcli->pfnGetContactDisplayName(hcontact, 0) : (wantempty ? _T("") : _T("---"));
			goto LBL_charPtr;

		case 'N':
			ci.dwFlag = CNF_NICK | CNF_TCHAR;
			if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
				charPtr = ci.pszVal;
				goto LBL_charPtr;
			}
			goto LBL_noData;

		case 'G':
			if (!db_get_ts(hcontact, "CList", "Group", &dbv)) {
				_tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting));
				db_free(&dbv);
				charPtr = szdbsetting;
				goto LBL_charPtr;
			}
			break;

		case 'u':
			ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
			if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
				switch (ci.type) {
				case CNFT_BYTE:
					_ltot(ci.bVal, szdbsetting, 10);
					break;
				case CNFT_WORD:
					_ltot(ci.wVal, szdbsetting, 10);
					break;
				case CNFT_DWORD:
					_ltot(ci.dVal, szdbsetting, 10);
					break;
				case CNFT_ASCIIZ:
					_tcsncpy(szdbsetting, ci.pszVal, _countof(szdbsetting));
					break;
				}
			}
			else goto LBL_noData;
			charPtr = szdbsetting;
			goto LBL_charPtr;

		case 's':
			if (isetting = db_get_w(hcontact, S_MOD, hcontact ? "StatusTriger" : courProtoName, 0)) {
				_tcsncpy(szdbsetting, pcli->pfnGetStatusModeDescription(isetting | 0x8000, 0), _countof(szdbsetting));
				if (!(isetting & 0x8000)) {
					mir_tstrncat(szdbsetting, _T("/"), _countof(szdbsetting) - mir_tstrlen(szdbsetting));
					mir_tstrncat(szdbsetting, TranslateT("Idle"), _countof(szdbsetting) - mir_tstrlen(szdbsetting));
				}
				charPtr = szdbsetting;
				goto LBL_charPtr;
			}
			goto LBL_noData;

		case 'T':
			if (db_get_ts(hcontact, "CList", "StatusMsg", &dbv))
				goto LBL_noData;

			d += mir_sntprintf(d, MAXSIZE - (d - sztemp), _T("%s"), dbv.ptszVal);
			db_free(&dbv);
			break;

		case 'o':
			if (isetting = db_get_w(hcontact, S_MOD, hcontact ? "OldStatus" : courProtoName, 0)) {
				_tcsncpy(szdbsetting, pcli->pfnGetStatusModeDescription(isetting, 0), _countof(szdbsetting));
				if (includeIdle && hcontact && db_get_b(hcontact, S_MOD, "OldIdle", 0)) {
					mir_tstrncat(szdbsetting, _T("/"), _countof(szdbsetting) - mir_tstrlen(szdbsetting));
					mir_tstrncat(szdbsetting, TranslateT("Idle"), _countof(szdbsetting) - mir_tstrlen(szdbsetting));
				}
				charPtr = szdbsetting;
				goto LBL_charPtr;
			}
			goto LBL_noData;

		case 'i':
		case 'r':
			if (isJabber(ci.szProto)) {
				if (db_get_ts(hcontact, ci.szProto, *p == 'i' ? "Resource" : "System", &dbv))
					goto LBL_noData;

				_tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting));
				db_free(&dbv);
				charPtr = szdbsetting;
			}
			else {
				dwsetting = db_get_dw(hcontact, ci.szProto, *p == 'i' ? "IP" : "RealIP", 0);
				if (!dwsetting)
					goto LBL_noData;

				ia.S_un.S_addr = htonl(dwsetting);
				_tcsncpy(szdbsetting, _A2T(inet_ntoa(ia)), _countof(szdbsetting));
				charPtr = szdbsetting;
			}
			goto LBL_charPtr;

		case 'P':
			_tcsncpy(szdbsetting, ci.szProto ? _A2T(ci.szProto) : (wantempty ? _T("") : _T("ProtoUnknown")), _countof(szdbsetting));
			charPtr = szdbsetting;
			goto LBL_charPtr;

		case 'b':
			charPtr = _T("\x0D\x0A");
			goto LBL_charPtr;

		case 'C': // Get Client Info
			if (!db_get_ts(hcontact, ci.szProto, "MirVer", &dbv)) {
				_tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting));
				db_free(&dbv);
			}
			else goto LBL_noData;
			charPtr = szdbsetting;
			goto LBL_charPtr;

		case 't':
			charPtr = _T("\t");
			goto LBL_charPtr;

		case 'A':
		{
			PROTOACCOUNT *pa = Proto_GetAccount(ci.szProto);
			if (!pa) goto LBL_noData;
			_tcsncpy(szdbsetting, pa->tszAccountName, _countof(szdbsetting));
			charPtr = szdbsetting;
			goto LBL_charPtr;
		}


		default:
			*d++ = p[-1];
			*d++ = *p;
		}
	}

	*d = 0;
	return sztemp;
}
Beispiel #30
0
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;
}