Beispiel #1
0
         bool XMLRPC::setCommand(t_int const _command)
         {
            reset();
#if BTG_EXTERNALIZATION_DEBUG
            BTG_NOTICE(logWrapper(), "XMLRPC::setCommand() " << _command << " :" <<getCommandName(_command));
#endif // BTG_EXTERNALIZATION_DEBUG
            XMLRPC_RequestSetMethodName(xmlrpc_request, getCommandName(_command).c_str());
            return addByte(_command);
         }
Beispiel #2
0
bool MgCmdManagerImpl::switchCommand(const MgMotion* sender)
{
    const char* name;
    
    for (int i = 0; *(name = getCommandName(i)); i++) {
        if (_cmdname == name) {
            name = getCommandName(i + 1);
            name = *name ? name : getCommandName(0);
            return setCommand(sender, name, NULL);
        }
    }
    return setCommand(sender, getCommandName(0), NULL);
}
//! \brief Sends a command to the TBDML device over the Out Bulk Endpoint
//!
//! Since the EP transfer is unidirectional, data returned by the
//! device must be read in a separate transfer - this includes any status
//! from extended command execution.
//!
//! @param count = # of bytes to Tx (N)
//!
//! @param data                                 \n
//!    OUT                                      \n
//!    =======================================  \n
//!    data[0]      = reserved                  \n
//!    data[1]      = command byte              \n
//!    data[2..N-1] = parameters                \n
//!                                             \n
//!    IN                                       \n
//!    ======================================== \n
//!    data[0]      = error code (=rc)
//!
//! @return
//!   BDM_RC_OK        => USB transfer OK \n
//!   BDM_RC_USB_ERROR => USB transfer Failed
//!
USBDM_ErrorCode bdm_usb_send_epOut(unsigned int count, const unsigned char *data) {
    int rc;
    int transferCount;

    if (usbDeviceHandle==NULL) {
        print("bdm_usb_send_epOut(): device not open\n");
        return BDM_RC_DEVICE_NOT_OPEN;
    }

#ifdef LOG_LOW_LEVEL
    print("============================\n");
    if (data[0] == 0) { // Zero as first byte indicates split USBDM command
        print("bdm_usb_send_epOut() - USB EP0ut send (SPLIT, size=%d):\n", count);
    }
    else {
        print("bdm_usb_send_epOut() - USB EP0ut send (%s, size=%d):\n", getCommandName(data[1]), count);
        if (data[1] == CMD_USBDM_DEBUG)
            print("bdm_usb_send_epOut() - Debug cmd = %s\n", getDebugCommandName(data[2]));
    }
    printDump(data, count);
#endif // LOG_LOW_LEVEL

    rc = libusb_bulk_transfer(usbDeviceHandle,
                              EP_OUT,                  // Endpoint & direction
                              (unsigned char *)data,   // ptr to Tx data
                              count,                   // number of bytes to Tx
                              &transferCount,          // number of bytes actually Tx
                              timeoutValue             // timeout
                             );
    if (rc != LIBUSB_SUCCESS) {
        print("bdm_usb_send_epOut() - Transfer failed (USB error = %s, timeout=%d)\n", libusb_strerror((libusb_error)rc), timeoutValue);
        return BDM_RC_USB_ERROR;
    }
    return BDM_RC_OK;
}
	ShellCommand * createShellCommand(char * commandLine){

		int i;
		ShellCommand * command = allocateMemory(getGlobalHeap() , sizeof(ShellCommand));

		//parseamos el commandLine y creamos la matriz de symbolos
		parseSequence(commandLine);

		//seteamos la cantidad de argumentos
		command->argsCount = getArgumentsCount();
		
		//ponemos en 0 todos los caracteres del comando
		memset(command->commandName , '\0' , CMD_MAX_LEN);
		//ponemos en 0 todos los caracteres de todos los argumentos
		for(i=0 ; i<CMD_MAX_ARG ; i++)
			memset(command->args[i] , '\0' , CMD_MAX_LEN);

		//seteamos el comando
		strcpy(command->commandName , getCommandName());
		//seteamos todos los argumentos
		for( i=0 ; i<getArgumentsCount() ; i++){
			strcpy(command->args[i] , getArgument(i));
		}

		return command;	
	}
//! \brief Sends a message of 5 bytes to the USBDM device over EP0.
//!
//!  An immediate response is expected
//!
//! @param data - Entry \n
//!    data[0]    = N, the number of bytes to receive from the device \n
//!    data[1]    = Command byte \n
//!    data[2..5] = parameter(s) for OSBDM command \n
//! @note data must be an array of at least 5 bytes even if there are no parameters!
//!
//! @param data - Exit \n
//!    data[0]      = cmd response from OSBDM\n
//!    data[1..N-1] = data response from the device (cleared on error)\n
//!
//! @return \n
//!    == BDM_RC_OK (0)     => Success, OK response from device\n
//!    == BDM_RC_USB_ERROR  => USB failure \n
//!    == else              => Error code from Device
//!
USBDM_ErrorCode bdm_usb_recv_ep0(unsigned char *data, unsigned *actualRxSize) {
    unsigned char size = data[0];   // Transfer size is the first byte
    unsigned char cmd  = data[1];   // OSBDM/TBDML Command byte
    int rc;
    int retry = 5;

    *actualRxSize = 0;

    if (usbDeviceHandle == NULL) {
        print("bdm_usb_recv_ep0() - ERROR : Device handle NULL!\n");
        data[0] = BDM_RC_DEVICE_NOT_OPEN;
        return BDM_RC_DEVICE_NOT_OPEN;
    }

#ifdef LOG_LOW_LEVEL
    print("============================\n");
    print("bdm_usb_recv_ep0(%s, size=%d) - \n", getCommandName(cmd), size);
    if (data[1] == CMD_USBDM_DEBUG)
        print("bdm_usb_recv_ep0() - Debug cmd = %s\n", getDebugCommandName(data[2]));
    printDump(data, 6);
#endif // LOG_LOW_LEVEL

    do {
        rc = libusb_control_transfer(usbDeviceHandle,
                                     LIBUSB_REQUEST_TYPE_VENDOR|EP_CONTROL_IN,      // bmRequestType
                                     cmd,                                           // bRequest
                                     data[2]+(data[3]<<8),                          // wValue
                                     data[4]+(data[5]<<8),                          // wIndex
                                     (unsigned char*)data,                          // ptr to data buffer (for Rx)
                                     size,                                          // wLength = size of transfer
                                     5*timeoutValue                                 // timeout
                                    );
        if (rc < 0) {
            print("bdm_usb_recv_ep0(size=%d) - Transfer error (USB error = %s) - retry %d \n", size, libusb_strerror((libusb_error)rc), retry);
            milliSleep(100); // So we don't monopolise the USB
        }
    } while ((rc < 0) && (--retry>0));

    if (rc < 0) {
        print("bdm_usb_recv_ep0() - Transfer failed (USB error = %s)\n", libusb_strerror((libusb_error)rc));
        data[0] = BDM_RC_USB_ERROR;
        *actualRxSize = 0;
    }
    else {
        *actualRxSize = (unsigned) rc;
    }
    if ((data[0] != BDM_RC_OK) && (data[0] != cmd)) { // Error at BDM?
        print("bdm_usb_recv_ep0() - Cmd Failed (%s):\n", getErrorName(data[0]));
        printDump(data,*actualRxSize);
        memset(&data[1], 0x00, size-1);
        return (USBDM_ErrorCode)data[0];
    }
#ifdef LOG_LOW_LEVEL
    print("bdm_usb_recv_ep0(size = %d, recvd = %d):\n", size, rc);
    printDump(data,rc);
#endif // LOG_LOW_LEVEL

    return(BDM_RC_OK);
}
Beispiel #6
0
	int Program::run(int argc, char **argv)
	{
		setLocale();
#ifdef WIN32
		auto command_line = po::split_winmain(ucsToUtf8(wstring(GetCommandLine())));
		command_line.erase(command_line.begin());
#else
		vector<string> command_line;
		command_line.resize(argc - 1);
		for (int i = 1; i < argc; i++) {
			command_line[i - 1] = argv[i];
		}
#endif
		auto command_name = getCommandName(command_line);
		if (!command_name.first) return EXIT_FAILURE;

		if (command_name.first && command_name.second == ""){
			printHelp();
			return EXIT_FAILURE;
		}
		auto command = findCommand(command_name.second.c_str());
		if (!command){
			cerr << program_name << ": " << "unknown command '" << command_name.second << "'" << "\n";
			printHelp();
			return EXIT_FAILURE;
		}

		try{
			po::options_description all_options, global_options, options, hidden_options;
			po::positional_options_description positional_options;
			string command_confirm;
			addGlobalOptions(global_options);
			hidden_options.add_options()
				("command",  po::value<string>(&command_confirm), "")
			;
			positional_options.add("command", 1);
			command->addOptions(options, hidden_options);
			command->addPositionalOptions(positional_options);
			all_options.add(global_options).add(options).add(hidden_options);
			auto parsed = po::command_line_parser(command_line).options(all_options).positional(positional_options).run();
			po::variables_map vm;
			po::store(parsed, vm);
			po::notify(vm);
			if (vm.count("help")) {
				printHelp(*command);
				return EXIT_SUCCESS;
			}
			if (!command->checkOptions(vm)){
				printHelp(*command);
				return EXIT_FAILURE;
			}
			return command->run();
		}catch(const exception &e){
			cerr << program_name << ": " << e.what() << "\n";
			return EXIT_FAILURE;
		}
	}
Beispiel #7
0
bool AtrmMotors :: isExecute(const char* cmdName, const int argc, char * const argv[], AStream *stream)
{
	char szName[MAX_TERMINAL_BUFFER];
	getCommandName(szName);
	if (strCompare(cmdName, szName))
	{
		execute(argc, argv, stream);
		return true;
	}
	return false;
}
					// some common serialization work
					void serializeBase(json::Object& json_init_root) const
					{
						// command name
						json_init_root["COMMAND_NAME"]  =json::String(getCommandName());
						

						json_init_root["RESULT_MESSAGE"] = json::String(result_message);
						json_init_root["RESULT_CODE"] = json::Number(result_code);
						json_init_root["MT_MESSAGE"] = json::String(mt_result_message);
						json_init_root["MT_CODE"] = json::Number(mt_result_code);
						json_init_root["MT_INSTANCE_NAME"] = json::String(mt_instance_name_m);
						//json_init_root["MT_INSTANCE_UID"] = json::String(mt_instance_uid_m.toString());
					}
Beispiel #9
0
/*
 * Dump the contents of a packet to stdout.
 */
static void dumpPacket(const unsigned char* packetBuf, const char* srcName,
    const char* dstName)
{
    const unsigned char* buf = packetBuf;
    char prefix[3];
    u4 length, id;
    u1 flags, cmdSet=0, cmd=0;
    JdwpError error = ERR_NONE;
    bool reply;
    int dataLen;

    length = get4BE(buf+0);
    id = get4BE(buf+4);
    flags = get1(buf+8);
    if ((flags & kJDWPFlagReply) != 0) {
        reply = true;
        error = static_cast<JdwpError>(get2BE(buf+9));
    } else {
        reply = false;
        cmdSet = get1(buf+9);
        cmd = get1(buf+10);
    }

    buf += kJDWPHeaderLen;
    dataLen = length - (buf - packetBuf);

    if (!reply) {
        prefix[0] = srcName[0];
        prefix[1] = '>';
    } else {
        prefix[0] = dstName[0];
        prefix[1] = '<';
    }
    prefix[2] = '\0';

    int min, sec;
    getCurrentTime(&min, &sec);

    if (!reply) {
        printf("%s REQUEST dataLen=%-5u id=0x%08x flags=0x%02x cmd=%d/%d [%02d:%02d]\n",
            prefix, dataLen, id, flags, cmdSet, cmd, min, sec);
        printf("%s   --> %s\n", prefix, getCommandName(cmdSet, cmd));
    } else {
        printf("%s REPLY   dataLen=%-5u id=0x%08x flags=0x%02x err=%d (%s) [%02d:%02d]\n",
            prefix, dataLen, id, flags, error, dvmJdwpErrorStr(error), min,sec);
    }
    if (dataLen > 0)
        printHexDump2(buf, dataLen, prefix);
    printf("%s ----------\n", prefix);
}
//! \brief Executes an USB transaction.
//! This consists of a transmission of a command and reception of the response
//!
//! @param txSize = size of transmitted packet
//!
//! @param rxSize = maximum size of received packet
//!
//! @param data   = IN/OUT buffer for data                           \n
//!    Transmission                                                  \n
//!    ===================================                           \n
//!    data[0]    = reserved for USB layer                           \n
//!    data[1]    = command                                          \n
//!    data[2..N] = data                                             \n
//!                                                                  \n
//!    Reception                                                     \n
//!    ============================================================= \n
//!    data[0]    = response code (error code - see \ref USBDM_ErrorCode) \n
//!    data[1..N] = command response
//!
//! @param timeout      = timeout in ms
//! @param actualRxSize = number of bytes actually received (may be NULL if not required)
//!
//! @return                                                          \n
//!    == BDM_RC_OK (0)     => Success, OK response from device      \n
//!    == BDM_RC_USB_ERROR  => USB failure                           \n
//!    == else              => Error code from BDM
//!
USBDM_ErrorCode bdm_usb_transaction( unsigned int   txSize,
                                     unsigned int   rxSize,
                                     unsigned char *data,
                                     unsigned int   timeout,
                                     unsigned int  *actualRxSize) {
    USBDM_ErrorCode rc;
    unsigned tempRxSize;
    uint8_t command = data[1];

    if (usbDeviceHandle==NULL) {
        print("bdm_usb_transaction(): device not open\n");
        return BDM_RC_DEVICE_NOT_OPEN;
    }
    timeoutValue = timeout;

    if (bdmState.useOnlyEp0) {
        rc = bdmJB16_usb_transaction( txSize, rxSize, data, &tempRxSize);
    }
    else {
        rc = bdmJMxx_usb_transaction( txSize, rxSize, data, &tempRxSize);
    }
    if (actualRxSize != NULL) {
        // Variable size data expected
        *actualRxSize = tempRxSize;
    }
    else if ((rc == 0) && (tempRxSize != rxSize)) {
        // Expect exact data size
        print("bdm_usb_transaction() - cmd = %s, Expected %d; received %d\n",
              getCommandName(command), rxSize, tempRxSize);
        rc = BDM_RC_UNEXPECTED_RESPONSE;
    }
    if (rc != BDM_RC_OK) {
        print("bdm_usb_transaction() - Failed, cmd = %s, rc = %s\n",
              getCommandName(command), getErrorName(rc));
    }
    return rc;
}
Beispiel #11
0
int Monitor::setTarget(char *cmd_line) {
    if (p_args != NULL) free(p_args);
    p_full = NULL;
    
    p_args = Monitor::parseArgs((char *)cmd_line);
    if (p_args == NULL) return(1);
    
    if (p_args != NULL && p_args[0] != NULL) {
        p_full = (char *)malloc(strlen((char *)p_args[0]) + 1);
        memset(p_full, 0x00, strlen((char *)p_args[0]) + 1);
        strcpy(p_full, p_args[0]);
        p_args[0] = getCommandName(p_args[0]);
    }
    if (p_args[0] == NULL) return(1);
    return(0);
}
Beispiel #12
0
void Shell::start() {
  std::string commandWithArgs;
  out << PROMPT;
  while(std::getline(in, commandWithArgs, '\n')) {
    if (!commandWithArgs.empty() && !isSpaces(commandWithArgs)) {
      ShellCommand* cmd = commands[getCommandName(commandWithArgs)];
      if (cmd == NULL) {
        out << "command not found" << std::endl;
      } else {
        cmd->run(commandWithArgs);
        if (cmd->getName() == "quit") {
          break;
        }
      }
    }
    out << PROMPT;
  }
}
//*****************************************************************************
//!
//! \brief Sends a message+data to the USBDM device over EP0
//!
//! No response is expected from device.
//!
//! Since the EP0 transfer is unidirectional in this case, data returned by the
//! device must be read in a separate transfer - this includes any status.
//!
//! @param data \n
//!    data[0]    = N, the number of bytes to send (excluding this byte)\n
//!    data[1]    = Command byte \n
//!    data[2..N] = parameter(s) for command \n
//!
//! @return \n
//!    == BDM_RC_OK (0)     => Success\n
//!    == BDM_RC_USB_ERROR  => USB failure
//!
USBDM_ErrorCode bdm_usb_send_ep0( const unsigned char * data ) {
    unsigned char setupPkt[] = {0,0,0,0,0,0,0};
    unsigned char size       = data[0];   // Size is the first byte
    int rc;
    unsigned index;

    if (usbDeviceHandle == NULL) {
        print("bdm_usb_send_ep0() - Device handle NULL!\n");
        return BDM_RC_DEVICE_NOT_OPEN;
    }
#ifdef LOG_LOW_LEVEL
    print("============================\n");
    print("bdm_usb_send_ep0() - USB EP0 send (%s, size=%d):\n", getCommandName(data[1]), size);
    if (data[1] == CMD_USBDM_DEBUG)
        print("bdm_usb_send_ep0() - Debug cmd = %s\n", getDebugCommandName(data[2]));
    printDump(data, size+1);
#endif // LOG_LOW_LEVEL

    // Copy data in case <5 bytes to avoid possible illegal de-referencing
    for(index=0; index<(sizeof(setupPkt)/sizeof(setupPkt[0])); index++) {
        if (index > size)
            break;
        setupPkt[index] = data[index];
    }
    rc=libusb_control_transfer(usbDeviceHandle,
                               LIBUSB_REQUEST_TYPE_VENDOR|EP_CONTROL_OUT,      // requestType=Vendor
                               setupPkt[1],                                    // request
                               setupPkt[2]+(setupPkt[3]<<8),                   // value
                               setupPkt[4]+(setupPkt[5]<<8),                   // index
                               (unsigned char *)((size>5)?data+6:setupPkt),    // data bytes
                               (size>5)?(size-5):0,                            // size (# of data bytes)
                               timeoutValue);                                  // how long to wait for reply
    if (rc < 0) {
        print("bdm_usb_send_ep0() - USB EP0 send: Send failed (USB error = %d)\n", rc);
        return(BDM_RC_USB_ERROR);
    }
    return(BDM_RC_OK);
}
		void Fst2CheckCommand::buildArguments(Stringlist& arguments) const
		{
			arguments.clear();
			arguments.push_back(getCommandName());

			arguments.push_back(m_inputPath.string());
			arguments.push_back("--input_encoding");
			arguments.push_back(m_inputEncoding);
			if (!m_outputPath.empty()) {
				arguments.push_back("-o");
				arguments.push_back(m_outputPath.string());
				arguments.push_back("--output_encoding");
				arguments.push_back(m_outputEncoding);
			}
			if (m_showStatistics)
				arguments.push_back("-s");
			arguments.push_back(m_loopCheck ? "-y" : "-n");
			if (m_appendOutputMode)
				arguments.push_back("--append");
			if (m_sentenceCheck)
				arguments.push_back("-t");
			if (!m_emptyGraphWarnings)
				arguments.push_back("-e");
		}
Beispiel #15
0
void V3DocViewWin::showMainMenu()
{
    lvRect fullRc = _wm->getScreen()->getRect();
    CRFullScreenMenu * menu_win = new CRFullScreenMenu(
            _wm, 0, lString16(_("Main Menu")), 8, fullRc );
/*
VIEWER_MENU_GOTOFIRSTPAGE=Go to first page
VIEWER_MENU_GOTOENDPAGE=Go to last page
VIEWER_MENU_GOTOPAGE=Go to page...
VIEWER_MENU_GOTOINDEX=Go to index
VIEWER_MENU_5ABOUT=About...
VIEWER_MENU_4ABOUT=About...
*/
    menu_win->setSkinName(lString16(L"#main"));
	CRGUIAcceleratorTableRef menuItems = _wm->getAccTables().get(lString16("mainMenuItems"));
	if ( !menuItems.isNull() && menuItems->length()>1 ) {
		// get menu from file
		for ( unsigned i=0; i<menuItems->length(); i++ ) {
			const CRGUIAccelerator * acc = menuItems->get( i );
			int cmd = acc->commandId;
			int param = acc->commandParam;
			const char * name = getCommandName( cmd, param );
			int key = 0;
			int keyFlags = 0;
			lString8 label( name );
			if ( _acceleratorTable->findCommandKey( cmd, param, key, keyFlags ) ) {
				const char * keyname = getKeyName( key, keyFlags );
				if ( keyname && keyname[0] )
					label << "\t" << keyname;
			}
			menu_win->addItem( new CRMenuItem( menu_win, cmd,
				label.c_str(),
				LVImageSourceRef(),
				LVFontRef() ) );
		}
	} else {
		// default menu
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_ABOUT,
					_("About"),
					LVImageSourceRef(),
					LVFontRef() ) );
	#if 0
		menu_win->addItem( new CRMenuItem( menu_win, DCMD_BEGIN,
					_wm->translateString("VIEWER_MENU_GOTOFIRSTPAGE", "Go to first page"),
					LVImageSourceRef(),
					LVFontRef() ) );
	#endif
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_GO_PAGE,
					_("Go to page"),
					LVImageSourceRef(),
					LVFontRef() ) );
	#if 0
		menu_win->addItem( new CRMenuItem( menu_win, DCMD_END,
					_wm->translateString("VIEWER_MENU_GOTOENDPAGE", "Go to last page"),
					LVImageSourceRef(),
					LVFontRef() ) );
	#endif

		menu_win->addItem( new CRMenuItem( menu_win, MCMD_RECENT_BOOK_LIST,
					_("Open recent book"),
					LVImageSourceRef(),
					LVFontRef() ) );

	#ifdef WITH_DICT
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_DICT,
					_("Dictionary"),
					LVImageSourceRef(),
					LVFontRef() ) );
	#endif
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_CITE,
					_("Cite"),
					LVImageSourceRef(),
					LVFontRef() ) );
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_BOOKMARK_LIST,
					_("Bookmarks"),
					LVImageSourceRef(),
					LVFontRef() ) );
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_SEARCH,
					_("Search"),
					LVImageSourceRef(),
					LVFontRef() ) );
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_SETTINGS,
					_("Settings"),
					LVImageSourceRef(),
					LVFontRef() ) );
		if ( !_helpFile.empty() )
			menu_win->addItem( new CRMenuItem( menu_win, MCMD_HELP,
					_("Help"),
					LVImageSourceRef(),
					LVFontRef() ) );
		menu_win->addItem( new CRMenuItem( menu_win, MCMD_HELP_KEYS,
					_("Keyboard layout"),
					LVImageSourceRef(),
					LVFontRef() ) );
	}

    menu_win->setAccelerators( getMenuAccelerators() );

    lString16 s(_("$1 - choose command\n$2, $3 - close"));
    s.replaceParam(1, menu_win->getItemNumberKeysName());
    s.replaceParam(2, menu_win->getCommandKeyName(MCMD_OK) );
    s.replaceParam(3, menu_win->getCommandKeyName(MCMD_CANCEL) );
    menu_win->setStatusText( s );
    menu_win->setFullscreen( true );

    menu_win->reconfigure(0);
    _wm->activateWindow( menu_win );
}
Beispiel #16
0
/// returns true if command is processed
bool V3DocViewWin::onCommand( int command, int params )
{
    CRLog::info("V3DocViewWin::onCommand(%d [%s], %d)", command, getCommandName(command, params), params );
    switch ( command ) {
    case MCMD_QUIT:
        getWindowManager()->closeAllWindows();
        return true;
    case MCMD_MAIN_MENU:
        showMainMenu();
        return true;
    case MCMD_SETTINGS_FONTSIZE:
        showFontSizeMenu();
        return true;
#if CR_INTERNAL_PAGE_ORIENTATION==1
    case MCMD_SETTINGS_ORIENTATION:
        showOrientationMenu();
        return true;
#endif
    case MCMD_SETTINGS:
        showSettingsMenu();
        return true;
    case MCMD_RECENT_BOOK_LIST:
        showRecentBooksMenu();
        return true;
    case MCMD_OPEN_RECENT_BOOK:
        _docview->swapToCache();
        _docview->getDocument()->updateMap();
        openRecentBook( params );
        return true;
    case MCMD_SWITCH_TO_RECENT_BOOK:
        _docview->swapToCache();
        _docview->getDocument()->updateMap();
        openRecentBook( 1 );
        return true;
    case MCMD_ABOUT:
        showAboutDialog();
        return true;
    case MCMD_CITE:
        activate_cite( _wm, this);
        return true;
    case MCMD_GO_PAGE_APPLY:
        _docview->doCommand( DCMD_GO_PAGE, params-1 );
        return true;
    case MCMD_GO_PERCENT_APPLY:
        _docview->doCommand( DCMD_GO_POS, params * _docview->GetFullHeight() / 100 );
        return true;
    case MCMD_SETTINGS_APPLY:
#if CR_INTERNAL_PAGE_ORIENTATION==1
    case mm_Orientation:
#endif
    case mm_FontSize:
        applySettings();
        saveSettings( lString16() );
        _wm->getSkin()->gc();
        return true;
    case DCMD_SAVE_HISTORY:
        saveHistory( lString16() );
        saveSettings( lString16() );
        return true;
    case DCMD_SAVE_TO_CACHE:
        _docview->swapToCache();
        _docview->getDocument()->updateMap();
        return true;
    case MCMD_BOOKMARK_LIST:
        showBookmarksMenu(false);
        return true;
    case MCMD_BOOKMARK_LIST_GO_MODE:
        showBookmarksMenu(true);
        return true;
    case DCMD_ZOOM_IN:
    case DCMD_ZOOM_OUT:
        showWaitIcon();
		CRViewDialog::onCommand( command, params );
        _props->setInt( PROP_FONT_SIZE, _docview->getFontSize() );
        saveSettings( lString16() );
        return true;
    case MCMD_HELP:
        showHelpDialog();
        return true;
    case DCMD_BOOKMARK_SAVE_N:
        _docview->doCommand( DCMD_BOOKMARK_SAVE_N, params );
        if ( _props->getBoolDef( PROP_AUTOSAVE_BOOKMARKS, true ) )
            saveHistory( lString16() );
        return true;
    default:
        // do nothing
        ;
    }
    return CRViewDialog::onCommand( command, params );
}
Beispiel #17
0
bool MgCmdManagerImpl::setCommand(const MgMotion* sender,
                                  const char* name, MgStorage* s)
{
    if (!name) {
        return cancel(sender);
    }
    if (strcmp(name, "@draw") == 0) {   // 将 @draw 换成上一次绘图命令名
        name = _drawcmd.empty() ? "splines" : _drawcmd.c_str();
    }
    else if (strcmp(name, "@last") == 0) {
        name = getCommandName();
    }

    MgCommand* cmd = findCommand(name);
    if (!cmd) {
        cmd = sender->view->getCmdSubject()->createCommand(sender, name);
        if (cmd) {
            _cmds[name] = cmd;
            LOGD("createCommand %d: %s", (int)_cmds.size(), name);
        }
    }
    
    if (strcmp(name, "erase") == 0 && _cmdname == "select") {   // 在选择命令中点橡皮擦
        MgSelection *sel = getSelection();
        if (sel && sel->deleteSelection(sender)) {      // 直接删除选中的图形
            return false;                               // 不切换到橡皮擦命令
        }
    }
    
    cancel(sender);
    
    bool ret = false;
    std::string oldname(_cmdname);
    
    if (cmd) {
        _cmdname = cmd->getName();
        
        ret = cmd->initialize(sender, s);
        if (!ret) {
            _cmdname = oldname;
        }
        else if (cmd->isDrawingCommand()) {
            _drawcmd = _cmdname;
        }
    }
    else if (strcmp(name, "erasewnd") == 0) {
        eraseWnd(sender);
    }
    else if (!name[0]) {
        _cmdname = "";
    }
    
    if (MgBaseShape::minTol().equalPoint() < 1e-5) {
        MgBaseShape::minTol().setEqualPoint(sender->view->xform()->displayToModel(1.f, true));
    }
    if (oldname != _cmdname) {
        sender->view->commandChanged();
    }
    sender->view->redraw(false);
    
    return ret;
}
Beispiel #18
0
void ClangDocCommentVisitor::visitBlockCommandComment(
    const BlockCommandComment *C) {
  CurrentCI.Name = getCommandName(C->getCommandID());
  for (unsigned I = 0, E = C->getNumArgs(); I < E; ++I)
    CurrentCI.Args.push_back(C->getArgText(I));
}
Beispiel #19
0
void ImapSession::processData() {
    lock_guard<mutex> lock(sessionLock_);

    string data = socket_->readAll();
    incomingData_.append(data);

    bool flag = true;
    while(flag) {
        size_t crlfPos = incomingData_.find(CRLF);

        // Checking for valid line
        if (crlfPos == string::npos)
            break;

        /* Getting line and parse her. Here we only do rough parsing,
         * detailed parsing goes in process<command> methods.*/
        string line = incomingData_.substr(0, crlfPos);
        string *tag, *commandName;


        tag = getCommandTag(line);
        commandName = getCommandName(line);

        if (!tag || !commandName) {
            ImapCommand com {line, ""};
            rejectBad(&com, "Missing command");

            incomingData_.erase(0, crlfPos + 2); // deleting wrong line from buffer
            if (tag) delete tag;
            if (commandName) delete commandName;
            continue;
        }

        ImapCommand *command = new ImapCommand();
        command->tag = *tag;
        command->name = *commandName;

        stringToUpper(command->name);

        IMAP_LOG_LVL(DEBUG, "Received command: {" << command->tag << "," << command->name << "}");

        int commandEnd;

        if (parserFunctions.count(command->name)) {
            CommandParserFunction func =  parserFunctions.at(command->name);
            commandEnd = (this->*func)(command);
            if (commandEnd >= 0) {
                incomingData_.erase(0, commandEnd + 1);
            } else {
                /* Incomplete command. break */
                flag = false;
            }
        } else {
            rejectUnknownCommand(command);
            incomingData_.erase(0, crlfPos + 2); // deleting wrong line from buffer
        }

        writeAnswers();

        if (tag) delete tag;
        if (commandName) delete commandName;

        if (state_ == ImapSessionState::EXIT) {
            break;
        }
    }
}
Beispiel #20
0
void ClangDocCommentVisitor::visitVerbatimBlockComment(
    const VerbatimBlockComment *C) {
  CurrentCI.Name = getCommandName(C->getCommandID());
  CurrentCI.CloseName = C->getCloseName();
}