コード例 #1
0
ファイル: HandleViewList.cpp プロジェクト: 63n/XmdvTool
void HandleViewList::currentItemChanged(  QTreeWidgetItem * current, QTreeWidgetItem * ) {
	// First, update the item info ListWidget.
	// If current is NULL, this will clear the item info ListWidget
	updateItemInfo(current);
	if (current) {
		// If current is not NULL, set the status of "Delete" and "AddView" buttons
		// based on the type of the current node;
		switch ( current->type() ) {
		case DatasetItemType :
			m_viewListDock->m_btDelete->setEnabled(true);
			m_viewListDock->m_btAddView->setEnabled(false);
			break;
		case PipelineItemType :
			m_viewListDock->m_btDelete->setEnabled(false);
			m_viewListDock->m_btAddView->setEnabled(true);
			break;
		case ViewItemType :
			m_viewListDock->m_btDelete->setEnabled(true);
			m_viewListDock->m_btAddView->setEnabled(false);
			activateView(current);
			break;
		}
	} else {
		// if current is NULL, disable both "Delete" and "AddView" buttons.
		m_viewListDock->m_btDelete->setEnabled(false);
		m_viewListDock->m_btAddView->setEnabled(false);
	}
}
コード例 #2
0
void SELMainLibraryWidget::emitIdGetData(QListWidgetItem * item)
{
    EntertainmentItem * eItem;
    unsigned long long id;
    unsigned long long itemType;
    
    id = findId(item);
    if (id > 0) {
        eItem = controller.retrieveItem(id, itemType);
        if (eItem != 0) {
            updateItemInfo(*eItem, itemType);
            delete eItem;
        }
    } else {
        Error::raiseError(Error::ERROR_ITEM_ID_NOT_FOUND);
    }
}
コード例 #3
0
int main(int argc, char **argv)
{
	int i, j;
	struct timeval time_interval;
	fd_set useRead;
	fd_set useExcept;
	int selRet;
	char errTxt[256];
	RsslBuffer errorText = {255, (char*)errTxt};
	RsslInProgInfo inProg = RSSL_INIT_IN_PROG_INFO;
	RsslRet	retval = 0;
	int iargs;
	RsslErrorInfo rsslErrorInfo;
	RsslBool cacheOption = RSSL_FALSE;

	RsslReactorOMMProviderRole providerRole;

	RsslBindOptions sopts = RSSL_INIT_BIND_OPTS;

	RsslCreateReactorOptions reactorOpts;

	RsslReactorDispatchOptions dispatchOpts;

	time_t nextSendTime;

	/* Initialize RSSL. The locking mode RSSL_LOCK_GLOBAL_AND_CHANNEL is required to use the RsslReactor. */
	if (rsslInitialize(RSSL_LOCK_GLOBAL_AND_CHANNEL, &rsslErrorInfo.rsslError) != RSSL_RET_SUCCESS)
	{
		printf("rsslInitialize(): failed <%s>\n",rsslErrorInfo.rsslError.text);
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	rsslClearOMMProviderRole(&providerRole);

	providerRole.base.channelEventCallback = channelEventCallback;
	providerRole.base.defaultMsgCallback = defaultMsgCallback;
	providerRole.loginMsgCallback = loginMsgCallback;
	providerRole.directoryMsgCallback = directoryMsgCallback;
	providerRole.dictionaryMsgCallback = dictionaryMsgCallback;
	providerRole.tunnelStreamListenerCallback = tunnelStreamListenerCallback;

	rsslClearCreateReactorOptions(&reactorOpts);

	if (!(pReactor = rsslCreateReactor(&reactorOpts, &rsslErrorInfo)))
	{
		printf("Reactor creation failed: %s\n", rsslErrorInfo.rsslError.text);
		cleanUpAndExit();
	}

	snprintf(portNo, 128, "%s", defaultPortNo);
	snprintf(serviceName, 128, "%s", defaultServiceName);
	setServiceId(1);
	for(iargs = 1; iargs < argc; ++iargs)
	{
		if (0 == strcmp("-p", argv[iargs]))
		{
			++iargs; if (iargs == argc) exitWithUsage();
			snprintf(portNo, 128, "%s", argv[iargs]);
		}
		else if (0 == strcmp("-s", argv[iargs]))
		{
			++iargs; if (iargs == argc) exitWithUsage();
			snprintf(serviceName, 128, "%s", argv[iargs]);
		}
		else if (0 == strcmp("-id", argv[iargs]))
		{
			long tmpId = 0;
			++iargs; if (iargs == argc) exitWithUsage();
			tmpId = atol(argv[iargs]);
			if (tmpId < 0)
			{
				printf("ServiceId must be positive.\n");
				exitWithUsage();
			}
			setServiceId(tmpId);
		}
		else if (0 == strcmp("-x", argv[iargs]))
		{
			xmlTrace = RSSL_TRUE;
			snprintf(traceOutputFile, 128, "RsslVAProvider\0");
		}
		else if (0 == strcmp("-runtime", argv[iargs]))
		{
			++iargs; if (iargs == argc) exitWithUsage();
			timeToRun = atoi(argv[iargs]);
		}
		else if (0 == strcmp("-cache", argv[iargs]))
		{
			cacheOption = RSSL_TRUE;
		}
		else
		{
			printf("Error: Unrecognized option: %s\n\n", argv[iargs]);
			exitWithUsage();
		}
	}
	printf("portNo: %s\n", portNo);
	printf("serviceName: %s\n", serviceName);
	printf("serviceId: %llu\n", getServiceId());

	/* Initialiize client session information */
	for (i = 0; i < MAX_CLIENT_SESSIONS; i++)
	{
		clearClientSessionInfo(&clientSessions[i]);
	}

	initializeCache(cacheOption);

	/* Initialize login handler */
	initLoginHandler();

	/* Initialize source directory handler */
	initDirectoryHandler();

	/* Initialize dictionary provider */
	initDictionaryProvider();

	/* Initialize market price handler */
	initItemHandler();

	/* Initialize symbol list item list */
	initSymbolListItemList();

	/* Initialize market by order items */
	initMarketByOrderItems();


	/* set service name in directory handler */
	setServiceName(serviceName);

	/* load dictionary */
	if (loadDictionary() != RSSL_RET_SUCCESS)
	{
		/* exit if dictionary cannot be loaded */
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	initializeCacheDictionary();

	/* Initialize run-time */
	initRuntime();

	FD_ZERO(&readFds);
	FD_ZERO(&exceptFds);
	
	sopts.guaranteedOutputBuffers = 500;
	sopts.serviceName = portNo;
	sopts.majorVersion = RSSL_RWF_MAJOR_VERSION;
	sopts.minorVersion = RSSL_RWF_MINOR_VERSION;
	sopts.protocolType = RSSL_RWF_PROTOCOL_TYPE;

	/* Create the server. */
	if (!(rsslSrvr = rsslBind(&sopts, &rsslErrorInfo.rsslError)))
	{
		printf("Unable to bind RSSL server: <%s>\n",rsslErrorInfo.rsslError.text);
		/* WINDOWS: wait for user to enter something before exiting  */
#ifdef _WIN32
		printf("\nPress Enter or Return key to exit application:");
		getchar();
#endif
		exit(RSSL_RET_FAILURE);
	}

	FD_SET(rsslSrvr->socketId, &readFds);
	FD_SET(pReactor->eventFd, &readFds);
	
	rsslClearReactorDispatchOptions(&dispatchOpts);
	dispatchOpts.maxMessages = MAX_CLIENT_SESSIONS;

	// initialize next send time
	nextSendTime = time(NULL) + UPDATE_INTERVAL;

	/* this is the main loop */
	while(RSSL_TRUE)
	{
		useRead = readFds;
		useExcept = exceptFds;
		time_interval.tv_sec = UPDATE_INTERVAL;
		time_interval.tv_usec = 0;

		/* Call select() to check for any messages */
		selRet = select(FD_SETSIZE,&useRead,
		    NULL,&useExcept,&time_interval);

		if (selRet > 0)
		{
			RsslRet ret;

			/* Accept connection, if one is waiting */
			if (FD_ISSET(rsslSrvr->socketId, &useRead))
			{
				RsslClientSessionInfo *pClientSessionInfo = NULL;
				RsslReactorAcceptOptions aopts;

				rsslClearReactorAcceptOptions(&aopts);

				/* find an available client session */
				for (i = 0; i < MAX_CLIENT_SESSIONS; i++)
				{
					if (!clientSessions[i].isInUse)
					{
						pClientSessionInfo = &clientSessions[i];
						pClientSessionInfo->isInUse = RSSL_TRUE;
						break;
					}
				}

				/* Reject the channel if we are out of client sessions */
				if (!pClientSessionInfo)
					aopts.rsslAcceptOptions.nakMount = RSSL_TRUE;
				else
					aopts.rsslAcceptOptions.userSpecPtr = pClientSessionInfo;


				printf("Accepting new connection...\n");
				if (rsslReactorAccept(pReactor, rsslSrvr, &aopts, (RsslReactorChannelRole*)&providerRole, &rsslErrorInfo) != RSSL_RET_SUCCESS)
				{
					printf("rsslReactorAccept() failed: %s(%s)\n", rsslErrorInfo.rsslError.text, rsslErrorInfo.errorLocation);
					cleanUpAndExit();
				}
			}

			/* Call rsslReactorDispatch().  This will handle any events that have occurred on its channels.
			 * If there are events or messages for the application to process, they will be delivered
			 * through the callback functions given by the providerRole object. 
			 * A return value greater than RSSL_RET_SUCCESS indicates there may be more to process. */
			while ((ret = rsslReactorDispatch(pReactor, &dispatchOpts, &rsslErrorInfo)) > RSSL_RET_SUCCESS)
				;

			if (ret < RSSL_RET_SUCCESS)
			{
				printf("rsslReactorDispatch() failed: %s\n", rsslErrorInfo.rsslError.text);
				cleanUpAndExit();
			}
		}
		else if (selRet < 0)
		{
#ifdef _WIN32
			if (WSAGetLastError() == WSAEINTR)
				continue;
			printf("Error: select: %d\n", WSAGetLastError());
#else
			if (errno == EINTR)
				continue;
			perror("select");
#endif
			cleanUpAndExit();
		}

		// send any updates at next send time
		if (time(NULL) >= nextSendTime)
		{
			/* Send market price updates for each connected channel */
			updateItemInfo();
			for (i = 0; i < MAX_CLIENT_SESSIONS; i++)
			{
				if (clientSessions[i].clientChannel != NULL)
				{
					if (sendItemUpdates(pReactor, clientSessions[i].clientChannel) != RSSL_RET_SUCCESS)
					{
						removeClientSessionForChannel(pReactor, clientSessions[i].clientChannel);
					}

					// send any tunnel stream messages
					for (j = 0; j < MAX_TUNNEL_STREAMS; j++)
					{
						if (clientSessions[i].simpleTunnelMsgHandler[j].tunnelStreamHandler.pTunnelStream != NULL)
						{
							handleSimpleTunnelMsgHandler(pReactor, clientSessions[i].clientChannel, &clientSessions[i].simpleTunnelMsgHandler[j]);
						}
					}
				}
			}

			nextSendTime += UPDATE_INTERVAL;
		}

		/* Handle run-time */
		handleRuntime();
	}
}
コード例 #4
0
/*** MAIN ***/
int main(int argc, char **argv)
{
	RsslErrorInfo error;
	RsslError rsslErr;
	RsslCreateReactorOptions reactorOpts;
	RsslReactorDispatchOptions dispatchOpts;
	RsslInt32 j;

	RsslReactorOMMNIProviderRole role;
	RsslDataDictionary dictionary = RSSL_INIT_DATA_DICTIONARY;
	
	char err[128];
	RsslBuffer errBuf = {128, &err[0]};
	
	int selRet;

	time_t currentTime = 0;
	RsslRet ret;

	RsslInitializeExOpts initOpts = RSSL_INIT_INITIALIZE_EX_OPTS;

	rsslInitNIChannelCommand(&chnlCommand);

	handleConfig(argc, argv, &chnlCommand);

	initializeCache(cacheCommandlineOption);
	
	initOpts.jitOpts.libcryptoName = libcryptoName;
	initOpts.jitOpts.libsslName = libsslName;
	initOpts.jitOpts.libcurlName = libcurlName;
	initOpts.rsslLocking = RSSL_LOCK_GLOBAL_AND_CHANNEL;

	/* Initialize run-time */
	initRuntime();

	rsslInitializeEx(&initOpts, &rsslErr);

	/* Setup role */
	rsslClearOMMNIProviderRole((RsslReactorOMMNIProviderRole*)&role);
	role.pLoginRequest = (RsslRDMLoginRequest*)&chnlCommand.loginRequest;
	role.loginMsgCallback = processLoginResponse;
	role.pDirectoryRefresh = &chnlCommand.directoryRefresh;
	role.base.channelEventCallback = channelEventCallback;
	role.base.defaultMsgCallback = processResponse;

	printf("Connections:\n");

	chnlCommand.pRole = (RsslReactorChannelRole*)&role;
	chnlCommand.cOpts.rsslConnectOptions.guaranteedOutputBuffers = 500;
	chnlCommand.cOpts.rsslConnectOptions.majorVersion = RSSL_RWF_MAJOR_VERSION;
	chnlCommand.cOpts.rsslConnectOptions.minorVersion = RSSL_RWF_MINOR_VERSION;
	chnlCommand.cOpts.rsslConnectOptions.userSpecPtr = (void*)&chnlCommand;

//	printf("	%s:%s:%s\n", chnlCommand.hostName, chnlCommand.port, chnlCommand.serviceName);

	printf("		MarketPriceItems:");
	for(j = 0; j < CHAN_CMD_MAX_ITEMS; ++j)
	{
		RsslNIItemInfo *pItem = &chnlCommand.marketPriceItemInfo[j];
		if (pItem->isActive)
		printf(" %.*s", (int)sizeof(pItem->Itemname), pItem->Itemname);
	}

	printf("		MarketByOrderItems:");
	for(j = 0; j < CHAN_CMD_MAX_ITEMS; ++j)
	{
		RsslNIItemInfo *pItem = &chnlCommand.marketByOrderItemInfo[j];
		if (pItem->isActive)
		printf(" %.*s", (int)sizeof(pItem->Itemname), pItem->Itemname);
	}


	printf("\n");

	printf("\n");
	
	/* Load local dictionary */
	if(rsslLoadFieldDictionary("RDMFieldDictionary", &dictionary, &errBuf) < RSSL_RET_SUCCESS)
	{
		printf("Dictionary error: %s\n", errBuf.data);
		exit(-1);
	}
	
	chnlCommand.dictionary = &dictionary;
	
	initializeCacheDictionary(&dictionary);

	rsslClearCreateReactorOptions(&reactorOpts);
	reactorOpts.dispatchDecodeMemoryBufferSize = 1024;

	setupLoginRequest(&chnlCommand, 1);

	setupDirectoryResponseMsg(&chnlCommand, -1);
	
	if (!(pReactor = rsslCreateReactor(&reactorOpts, &error)))
	{
		printf("Error: %s", error.rsslError.text);
		exit(-1);
	}
	
	

	FD_ZERO(&readFds);
	FD_ZERO(&writeFds);
	FD_ZERO(&exceptFds);

	FD_SET(pReactor->eventFd, &readFds);

	if (rsslReactorConnect(pReactor, &chnlCommand.cOpts, chnlCommand.pRole, &error) != RSSL_RET_SUCCESS)
		printf("Error rsslReactorConnect(): %s\n", error.rsslError.text);
		
	rsslClearReactorDispatchOptions(&dispatchOpts);
	//dispatchOpts.pReactorChannel = &chnlCommand.reactorChannel;

	printf("Connection started!\n");

	while ( RSSL_TRUE )
	{
		struct timeval selectTime;
		int dispatchCount = 0;
		fd_set useReadFds = readFds, useWriteFds = writeFds, useExceptFds = exceptFds;
		selectTime.tv_sec = 1; selectTime.tv_usec = 0;

		handleRuntime();

		selRet = select(FD_SETSIZE, &useReadFds, &useWriteFds, &useExceptFds, &selectTime);

		if (selRet == 0 ) /* no messages received, send updates and continue */
		{
			// Update items
			updateItemInfo(&chnlCommand);

			/* Send market price updates for each connected channel */
			if (chnlCommand.startWrite == RSSL_TRUE)
			{
				if ((chnlCommand.reactorChannel != NULL) && (chnlCommand.reactorChannel->socketId != -1))
				{
					if (sendItemUpdates(pReactor,chnlCommand.reactorChannel) != RSSL_RET_SUCCESS)
						recoverConnection(pReactor, chnlCommand.reactorChannel, &chnlCommand);
				}
			}
			else
			{
				if (cacheInfo.useCache)
					cacheItemData(&chnlCommand);
			}
		}
		else if (selRet > 0)
		{
			RsslRet ret;
			while ((ret = rsslReactorDispatch(pReactor, &dispatchOpts, &error)) > 0);

			if(ret < 0)
			{
				printf("dispatch error! %i\n %s\n %s\n", ret, error.rsslError.text, error.errorLocation);
				/* Reactor has shutdown. Clean up and exit. */
				cleanUpAndExit();
			}
		}
	
		/* get current time */
		if ((currentTime = time(NULL)) < 0)
		{
			printf("time() failed.\n");
		}

		// send login reissue if login reissue time has passed
		if (chnlCommand.canSendLoginReissue == RSSL_TRUE &&
			currentTime >= (RsslInt)chnlCommand.loginReissueTime)
		{
			RsslReactorSubmitMsgOptions submitMsgOpts;
			RsslErrorInfo rsslErrorInfo;

			rsslClearReactorSubmitMsgOptions(&submitMsgOpts);
			submitMsgOpts.pRDMMsg = (RsslRDMMsg*)chnlCommand.pRole->ommNIProviderRole.pLoginRequest;
			if ((ret = rsslReactorSubmitMsg(pReactor,chnlCommand.reactorChannel,&submitMsgOpts,&rsslErrorInfo)) != RSSL_RET_SUCCESS)
			{
				printf("Login reissue failed:  %d(%s)\n", ret, rsslErrorInfo.rsslError.text);
			}
			else
			{
				printf("Login reissue sent\n");
			}
			chnlCommand.canSendLoginReissue = RSSL_FALSE;
		}
	}
}