Exemplo n.º 1
0
 QSharedPointer<Node> Node::CreateClientServer(const PrivateIdentity &ident,
     const Group &group, const QList<Address> &local,
     const QList<Address> &remote, const QSharedPointer<ISink> &sink,
     SessionFactory::SessionType session, AuthFactory::AuthType auth,
     const QSharedPointer<KeyShare> &keys)
 {
   QSharedPointer<GroupHolder> gh(new GroupHolder(group));
   QSharedPointer<ClientServer::Overlay> overlay(new ClientServer::Overlay(
         ident.GetLocalId(), local, remote, QList<Connections::Id>(), ident.GetSuperPeer()));
   QObject::connect(gh.data(), SIGNAL(GroupUpdated()),
       overlay.data(), SLOT(GroupUpdated()));
   QSharedPointer<Network> network(new CSNetwork(overlay));
   return QSharedPointer<Node>(new Node(ident, gh, overlay,
         network, sink, session, auth, keys));
 }
void P23::MetaTrader4::Manager::ClrWrapper::ExtendedPumpingNotify(int code, int type, void *data, void *param)
{
	switch (code)
	{
		case PUMP_START_PUMPING:
			PumpingStarted(this, nullptr);
			break;
		case PUMP_STOP_PUMPING:
			PumpingStopped(this, nullptr);
			break;
		case PUMP_UPDATE_BIDASK:
			BidAskUpdated(this, nullptr);
			break;
		case PUMP_UPDATE_SYMBOLS:
			if (data != NULL)
			{
				ConSymbol *conSymbol = (ConSymbol*)data;
				P23::MetaTrader4::Manager::Contracts::Configuration::Symbol^ symbolConfiguration = P23::MetaTrader4::Manager::ClrWrapper::Convert(conSymbol);
				SymbolUpdated(this, symbolConfiguration);
			}
			break;
		case PUMP_UPDATE_GROUPS:
			if (data != NULL)
			{
				ConGroup *conGroup = (ConGroup*)data;
				P23::MetaTrader4::Manager::Contracts::Configuration::Group^ groupConfiguration = P23::MetaTrader4::Manager::ClrWrapper::Convert(conGroup);
				GroupUpdated(this, groupConfiguration);
			}
			break;
		case PUMP_UPDATE_USERS:
			if (data != NULL)
			{
				UserRecord *user = (UserRecord*)data;
				P23::MetaTrader4::Manager::Contracts::UserRecord^ userRecord = P23::MetaTrader4::Manager::ClrWrapper::Convert(user);
				UserUpdated(this, userRecord);
			}
			break;
		case PUMP_UPDATE_ONLINE:
			if (data != NULL)
			{
				int onlineLogin = (int)data;
				OnlineUpdated(this, onlineLogin);
			}
			break;
		case PUMP_UPDATE_TRADES:
			if (data != NULL)
			{
				TradeRecord *trade = (TradeRecord*)data;
				P23::MetaTrader4::Manager::Contracts::TradeRecord^ tradeRecordStruct = P23::MetaTrader4::Manager::ClrWrapper::Convert(trade);

				switch (type)
				{
					case TRANS_ADD:
						TradeAdded(this, tradeRecordStruct);
						break;
					case TRANS_DELETE:
						TradeClosed(this, tradeRecordStruct);
						break;
					case TRANS_UPDATE:
						if (trade->login == 0) 
							TradeDeleted(this, tradeRecordStruct);
						else
							TradeUpdated(this, tradeRecordStruct);
						break;
				}
			}
			break;
		case PUMP_UPDATE_REQUESTS:
			if (data != NULL)
			{
				RequestInfo *requestInfo = (RequestInfo*)data;
				P23::MetaTrader4::Manager::Contracts::RequestInfo^ ri = P23::MetaTrader4::Manager::ClrWrapper::Convert(requestInfo);
				RequestInfoUpdated(this, ri);
			}
			break;
		case PUMP_UPDATE_NEWS:
			if (data != NULL)
			{
				NewsTopic *newsTopic = (NewsTopic *)data;
				P23::MetaTrader4::Manager::Contracts::NewsTopic^ nt = P23::MetaTrader4::Manager::ClrWrapper::Convert(newsTopic);
				NewsTopicUpdated(this, nt);
			}
			break;
		case PUMP_UPDATE_NEWS_NEW:
			if (data != NULL)
			{
				NewsTopicNew *newsTopic = (NewsTopicNew*)data;
				P23::MetaTrader4::Manager::Contracts::NewsTopicNew^ nt = P23::MetaTrader4::Manager::ClrWrapper::Convert(newsTopic);
				NewNewsTopicUpdated(this, nt);
			}
			break;
		case PUMP_UPDATE_MAIL:
			if (data != NULL)
			{
				MailBox *mailBox = (MailBox*)data;
				P23::MetaTrader4::Manager::Contracts::MailBox^ mb = P23::MetaTrader4::Manager::ClrWrapper::Convert(mailBox);
				MailBoxUpdated(this, mb);
			}
			break;
		default: 
			break;
	}
}