bool MovieController::process(MsgPacket* request, MsgPacket* response) {
    switch(request->getMsgID()) {
        case ROBOTV_RECORDINGS_DISKSIZE:
            return processGetDiskSpace(request, response);

        case ROBOTV_RECORDINGS_GETLIST:
            return processGetList(request, response);

        case ROBOTV_RECORDINGS_RENAME:
            return processRename(request, response);

        case ROBOTV_RECORDINGS_DELETE:
            return processDelete(request, response);

        case ROBOTV_RECORDINGS_SETPLAYCOUNT:
            return processSetPlayCount(request, response);

        case ROBOTV_RECORDINGS_SETPOSITION:
            return processSetPosition(request, response);

        case ROBOTV_RECORDINGS_SETURLS:
            return processSetUrls(request, response);

        case ROBOTV_RECORDINGS_GETPOSITION:
            return processGetPosition(request, response);

        case ROBOTV_RECORDINGS_GETMARKS:
            return processGetMarks(request, response);

        case ROBOTV_RECORDINGS_SEARCH:
            return processSearch(request, response);
    }

    return false;
}
示例#2
0
int main(int argc, char *argv[]) {

	programName = "firechain";
	c7c88e52_ensureUserIsRoot();

	if (argc == 1) {
		c7c88e52_printUsage(USAGE_MSG);
		exit(EXIT_FAILURE);
	} else if (f6215943_isEqual("help", argv[1])) {
		printHelp(argc, argv);
		exit(EXIT_SUCCESS);
	}

	FirewallParams firewallParams;
	CmdLineParam cmdLineParm;

	d7ad7024_initCmdLineParam(&cmdLineParm, argc, argv, USAGE_MSG);
	processCmdLine(&cmdLineParm, &firewallParams);

	if (firewallParams.action == ADD) {
		processAdd(&firewallParams);
	} else if (firewallParams.action == DELETE) {
		processDelete(&firewallParams);
	} else if (firewallParams.action == VIEW) {
		for (int i=0; i < firewallParams.ruleList.length; i++) {
			puts(firewallParams.ruleList.values[i]);
		}
	}

	b196167f_destroyAllElements(&firewallParams.ruleList);

	// Exit with success
	exit(EXIT_SUCCESS);
}
/**
 * FUNCTION NAME: checkMessages
 *
 * DESCRIPTION: This function is the message handler of this node.
 * 				This function does the following:
 * 				1) Pops messages from the queue
 * 				2) Handles the messages according to message types
 */
void MP2Node::checkMessages() {
	/*
	 * Implement this. Parts of it are already implemented
	 */
	char * data;
	int size;

	/*
	 * Declare your local variables here
	 */

	// dequeue all messages and handle them
	while ( !memberNode->mp2q.empty() ) {
		/*
		 * Pop a message from the queue
		 */
		data = (char *)memberNode->mp2q.front().elt;
		size = memberNode->mp2q.front().size;
		memberNode->mp2q.pop();

		string message(data, data + size);

		/*
		 * Handle the message types here
		 */

        cout << "Got message = " <<  message << endl;

        Message incoming_msg(message); //convert the message in string form to Message type

        //check for message type and call their handlers accordingly.
        switch(incoming_msg.type) {
            case CREATE     : {processCreate(incoming_msg); break;}
            case READ       : {processRead(incoming_msg); break;}
            case REPLY      : {processNodesReply(incoming_msg); break;}
            case READREPLY  : {processReadReply(incoming_msg);break;}
            case DELETE     : {processDelete(incoming_msg); break;}
            case UPDATE     : {processUpdate(incoming_msg); break;}
            default         : {}
        }
	}

    // At the end check the acks or nacks that this node may have received from the reply messages from the nodes to
    // whom this node may sent the client CRUD message
    checkReplyMessages();

	/*
	 * This function should also ensure all READ and UPDATE operation
	 * get QUORUM replies
	 */
}
示例#4
0
void patternWindow::constructActions() {

  backHistoryAction_ =
    new QAction(QIcon(":leftArrow.png"),
                tr("Undo"), this);
  backHistoryAction_->setShortcut(QKeySequence("Ctrl+z"));
  backHistoryAction_->setEnabled(false);
  connect(backHistoryAction_, SIGNAL(triggered()),
          this, SLOT(backHistoryActionSlot()));

  forwardHistoryAction_ =
    new QAction(QIcon(":rightArrow.png"),
                tr("Redo"), this);
  forwardHistoryAction_->setShortcut(QKeySequence("Ctrl+y"));
  forwardHistoryAction_->setEnabled(false);
  connect(forwardHistoryAction_, SIGNAL(triggered()),
          this, SLOT(forwardHistoryActionSlot()));

  switchAction_ = 
    new QAction(QIcon(":switchImages.png"), 
                tr("Switch between pattern and square images"), this);
  connect(switchAction_, SIGNAL(triggered()),
          this, SLOT(switchActionSlot()));

  gridAction_ = 
    new QAction(QIcon(":grid.png"), tr("Turn grid on/off"), this);
  gridAction_->setCheckable(true);
  gridAction_->setChecked(true);
  imageLabel_->setGridOn(true);
  connect(gridAction_, SIGNAL(triggered(bool )),
          this, SLOT(processGridChange(bool )));

  deleteImageAction_ = new QAction(tr("Delete image"), this);
  connect(deleteImageAction_, SIGNAL(triggered()),
          this, SLOT(processDelete()));

  gridColorAction_ = new QAction(tr("Change grid color"), this);
  connect(gridColorAction_, SIGNAL(triggered()),
          this, SLOT(processGridColorChange()));

  connect(originalSizeAction(), SIGNAL(triggered()),
          this, SLOT(originalSize()));

  setPdfViewerAction_ = new QAction(tr("Set pdf viewer"), this);
  connect(setPdfViewerAction_, SIGNAL(triggered()),
          this, SLOT(updatePdfViewerOptions()));
}
示例#5
0
void MarkerVisualizer::processMessage( const std_msgs::VisualizationMarker& message )
{
  switch ( message.action )
  {
  case MarkerActions::Add:
    processAdd( message );
    break;

  case MarkerActions::Modify:
    processModify( message );
    break;

  case MarkerActions::Delete:
    processDelete( message );
    break;

  default:
    printf( "Unknown marker action: %d\n", message.action );
  }
}
示例#6
0
void MarkerDisplay::processMessage( const visualization_msgs::Marker::ConstPtr& message )
{
  if (!validateFloats(*message))
  {
    setMarkerStatus(MarkerID(message->ns, message->id), StatusProperty::Error, "Contains invalid floating point values (nans or infs)");
    return;
  }

  switch ( message->action )
  {
  case visualization_msgs::Marker::ADD:
    processAdd( message );
    break;

  case visualization_msgs::Marker::DELETE:
    processDelete( message );
    break;

  default:
    ROS_ERROR( "Unknown marker action: %d\n", message->action );
  }
}
//////////////////////////////////////////////////////
// Member "text" is used to communicate with the above processXxx methods;
// the resulting string is returned to caller in parameter "fixed_data",
// not in "text" ("text" not used elsewhere).
// (Member "command" and the "pos/len" members -- same for them.)
//////////////////////////////////////////////////////
InputStmt::Option InputStmt::fix_string(const char * in_data,
					char * fixed_data,
					size_t data_maxlen)
{
  command = new char[data_maxlen + 1];
  command_pos = 0;
  text_pos = 0;

  text = fixed_data;
  text_maxlen = strlen(in_data);
#pragma nowarn(1506)   // warning elimination 
  str_pad(text, data_maxlen, ' ');
#pragma warn(1506)  // warning elimination 
#pragma nowarn(1506)   // warning elimination 
  str_cpy_all(text, in_data, strlen(in_data));
#pragma warn(1506)  // warning elimination 

  char c;
  Option option;

  cout << ">>" << in_data << endl;
  cout << "..";

#pragma nowarn(1506)   // warning elimination
  if (cin.peek() != '\n')
     cin.get(command, data_maxlen, '\n');
  else
     command[0] = '\0';
#pragma warn(1506)  // warning elimination
 
  if (cin.eof())
    {
      // Abort the "FC", not the whole SQLCI session
      CLEAR_STDIN_EOF;
      option = ABORT_O;
    }
  else
    {
      // consume the eol ('\n')
      cin.get(c);
      option = EMPTY_O;
    }

  while ((option != DONE_O) && (option != ABORT_O))
    {
      option = nextOption();

      switch (option)
	{
	case INSERT_O:
	  processInsert();
	  break;

	case REPLACE_O:
	  processReplace();
	  break;

	case EXPLICIT_REPLACE_O:
	  processReplace();
	  text_pos++;
	  break;

	case DELETE_O:
	  processDelete();
	  break;

	case ADVANCE_O:
	  text_pos += 1;
	  break;

	case END_O:
	  text_pos += 2;
	  break;

	case ABORT_O:
	  strncpy(text, in_data, strlen(in_data));
	  break;

	case DONE_O:
	  text[text_maxlen] = 0;
	  break;

	case AGAIN_O:
	  text[text_maxlen] = 0;
	  cout << ">>" << text << endl;
	  text[text_maxlen] = ' ';

	  cout << "..";
#pragma nowarn(1506)   // warning elimination 
          if (cin.peek() != '\n')
             cin.get(command, data_maxlen, '\n');
          else
             command[0] = '\0';
#pragma warn(1506)  // warning elimination 
	  if (cin.eof())
	    {
	      CLEAR_STDIN_EOF;
	      option = ABORT_O;
	    }
	  else
	    {
	      // consume the eol ('\n')
	      cin.get(c);
	      command_pos = 0;
	      text_pos = 0;
	    }
	  break;

	default:
	  break;

	}
    }

  delete [] command;
  command = 0;
  // delete text;    // text points to fixed_data, memory owned by caller!
  text = 0;

  return option;
}	// fix_string()
示例#8
0
/**
 * Processes all the POP3 commands such as
 * USER, PASS, LIST, RETR, DELE, NOOP, RSET, STAT
 */
int processPOPCommands(int sockfd, char *msg) {
	char *clientMsg = NULL;
	clientMsg = (char *)malloc(sizeof(char *) * 1024);
	if (clientMsg == NULL) {
		perror("ERROR: Cannot allocate memory");
		return(-1);
	}
	if (strncasecmp(msg, POP_SSL_STARTTLS, strlen(POP_SSL_STARTTLS)) == 0) { //EHLO
		if (setupSSLCommunication(sockfd)) {
			writeClient(sockfd, "OK Begin TLS negotiation now", TRUE);
		}
	}
	else if (strncasecmp(msg, POP_USER, strlen(POP_USER)) == 0) { //USER
		if (checkPOPStates(iPOP_USER)) {
			if (processUser(msg)== -1) {
				strcpy(clientMsg,"User name required");
				writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
			}
			else
				writeClient(sockfd, POP_OK, TRUE);
		}
		else {
			strcpy(clientMsg,"Invalid State");
			writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
		}
	}
	else if (strncasecmp(msg, POP_PASS, strlen(POP_PASS)) == 0) { //PASS
		if (checkPOPStates(iPOP_PASS)) {
			if (processPassword(msg) == -1) {
				strcpy(clientMsg,"Password required");
				writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
			}
			else {
				struct userdata *user;
				if (fetch_user_data(username, password, &user)) { //VALID USER

					//GET MESSAGE LISTING FOR THE USER
					getListMessages(username);

					writeClient(sockfd, POP_OK, TRUE);
					free(user);
				}
				else {
					strcpy(clientMsg,"Invalid User");
					writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
				}
			}
		}
		else {
			strcpy(clientMsg,"Invalid State");
			writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
		}
	}
	else if (strncasecmp(msg, POP_LIST, strlen(POP_LIST)) == 0) { //LIST
		if (checkPOPStates(iPOP_LIST))
			processList(sockfd, msg);
		else {
			strcpy(clientMsg,"Invalid State");
			writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
		}
	}
	else if (strncasecmp(msg, POP_RETR, strlen(POP_RETR)) == 0) { //RETR
		if (checkPOPStates(iPOP_RETR)) {
			if (processRetr(sockfd, msg) == -1) {
				strcpy(clientMsg,"Invalid Syntax");
				writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
			}
		}
		else {
			strcpy(clientMsg,"Invalid State");
			writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
		}
	}
	else if (strncasecmp(msg, POP_DELE, strlen(POP_DELE)) == 0) { //DELE
		if (checkPOPStates(iPOP_DELE)) {
			if (processDelete(sockfd, msg)== -1) {
				strcpy(clientMsg,"Invalid Syntax");
				writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
			}
		}
		else {
			strcpy(clientMsg,"Invalid State");
			writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
		}
	}
	else if (strncasecmp(msg, POP_RSET, strlen(POP_RSET)) == 0) { //RSET
//		if (checkStates(iPOP_RSET))
//			processRset(sockfd, msg);
//		else
//			writeClient(sockfd, POP_RESP_503, TRUE);
	}
	else if (strncasecmp(msg, POP_NOOP, strlen(POP_NOOP)) == 0) { //NOOP
		if (checkPOPStates(iPOP_NOOP))
			writeClient(sockfd, POP_OK, TRUE);
		else
			writeClient(sockfd, POP_ERR, TRUE);
	}
	else if (strncasecmp(msg, POP_STAT, strlen(POP_STAT)) == 0) { //STAT
		if (checkPOPStates(iPOP_STAT)) {
			processStat(sockfd, msg);
		}
		else {
			strcpy(clientMsg,"Invalid State");
			writeClient(sockfd, getMessage(TRUE, &clientMsg), TRUE);
		}
	}
	else {
		strcpy(clientMsg,"Invalid State");
		writeClient(sockfd,getMessage(TRUE, &clientMsg), TRUE);
	}
	free(clientMsg);
	return(0);
}
示例#9
0
bool PRINT_SCP_EMULATOR_CLASS::processCommandDataset(DCM_COMMAND_CLASS *command_ptr, DCM_DATASET_CLASS *dataset_ptr)

//  DESCRIPTION     : Process the Print command (and dataset).
//  PRECONDITIONS   :
//  POSTCONDITIONS  :
//  EXCEPTIONS      : 
//  NOTES           :
//<<===========================================================================
{
	bool result;

	// handle individual commands
	switch(command_ptr->getCommandId())
	{
	case DIMSE_CMD_NACTION_RQ:
		// process the ACTION command
		result = processAction(command_ptr->getEncodePresentationContextId());
		break;
	case DIMSE_CMD_NCREATE_RQ:
	    if ((sopClassUidM == FILM_SESSION_SOP_CLASS_UID) ||
		    (dataset_ptr))
		{
			// process the CREATE command
            // - Basic Film Session may not define a dataset - but that is OK
			result = processCreate(command_ptr->getEncodePresentationContextId(), dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_NCREATE_RSP,
				command_ptr->getEncodePresentationContextId(),
				status);
		}
		break;
	case DIMSE_CMD_NDELETE_RQ:
		// process the DELETE command
		result = processDelete(command_ptr->getEncodePresentationContextId());
		break;
	case DIMSE_CMD_NEVENTREPORT_RSP:
		// nothing to do here
		result = true;
		break;
	case DIMSE_CMD_NGET_RQ:
		// process the GET command
		result = processGet(command_ptr);
		break;
	case DIMSE_CMD_NSET_RQ:
		if (dataset_ptr)
		{
			// process the SET dataset
			result = processSet(command_ptr->getEncodePresentationContextId(), dataset_ptr);
		}
		else
		{
			// missing dataset
			UINT16 status = DCM_STATUS_PROCESSING_FAILURE;
			result = sendResponse(DIMSE_CMD_NSET_RSP,
				command_ptr->getEncodePresentationContextId(), 
				status);
		}
		break;
	default:
		{
			// unknown command
			UINT16 status = DCM_STATUS_UNRECOGNIZED_OPERATION;
			result = sendResponse(command_ptr->getCommandId(),
				command_ptr->getEncodePresentationContextId(), 
				status);
		}
		break;
	}

	// return result
	return result;
}