Esempio n. 1
0
void CmdExtended::helpImpl(DebuggerClient *client, const char *name) {
  const char *cmd = "{cmd} {arg1} {arg2} ...";
  const char *help = "invoke specified command";
  client->helpCmds((string(name) + " " + cmd).c_str(), help,
                   (string(name) + cmd).c_str(), help,
                   NULL);

  const ExtendedCommandMap &cmds = getCommandMap();
  if (!cmds.empty()) {
    client->help("");
    client->help("where {cmd} can be:");
    client->help("");
    vector<string> vcmds;
    for (ExtendedCommandMap::const_iterator iter = cmds.begin();
         iter != cmds.end(); ++iter) {
      vcmds.push_back(iter->first);
    }
    for (unsigned int i = 0; i < vcmds.size(); i++) {
      client->help("\t%s", format_unique_prefix
                   (vcmds[i], i ? vcmds[i-1] : "",
                    i < vcmds.size() - 1 ? vcmds[i+1] : "").c_str());
    }
    client->help("");
    client->help("Type '%s [h]elp|? {cmd} to read their usages.", name);
  }
}
Esempio n. 2
0
void CmdExtended::list(DebuggerClient *client) {
  if (client->argCount() == 0) {
    const ExtendedCommandMap &cmds = getCommandMap();
    for (ExtendedCommandMap::const_iterator iter = cmds.begin();
         iter != cmds.end(); ++iter) {
      client->addCompletion(iter->first.c_str());
    }
  } else {
    ExtendedCommandMap matches = match(client, 1);
    if (matches.size() == 1) {
      invokeList(client, matches.begin()->second);
    }
  }
}
Esempio n. 3
0
ExtendedCommandMap CmdExtended::match(DebuggerClient *client, int argIndex) {
  ExtendedCommandMap matches;
  const ExtendedCommandMap &cmds = getCommandMap();
  for (ExtendedCommandMap::const_iterator iter = cmds.begin();
       iter != cmds.end(); ++iter) {
    if (client->arg(argIndex, iter->first.c_str())) {
      matches[iter->first] = iter->second;
    }
  }
  if (matches.empty()) {
    client->error("Cannot find the specified user command: %s",
                  client->argValue(argIndex).c_str());
  }
  return matches;
}
Esempio n. 4
0
/**
 * @brief slot: show preference dialog
 * @return
 *      void
 */
void DLDConfigureOB::showPreferences ()
{
	QDialog * preferenceDialog = new QDialog;
	preferences.setupUi (preferenceDialog);

	// fill with defaults: (from settings)
	QString logFile = settings->value("logFile", "").toString ();
	preferences.flashBasepathEdit->setText (settings->value("FlashBasepath", "ttyUSB").toString ());
	preferences.openBeaconBasepathEdit->setText (settings->value("OpenBeaconBasepath", "ttyACM").toString ());
	preferences.refreshSpin->setValue (settings->value("DeviceRefreshRate", 5).toInt ());
	preferences.logFileEdit->setText (logFile);
	preferences.sam7PathEdit->setText (settings->value("sam7Path", "/usr/local/bin/sam7").toString ());
	preferences.showTagPacketsCheck->setChecked (showRX);

	// fill command table
	QStringList		tableHeader;
	tableHeader << tr ("Command") << tr ("Command description");
	preferences.commandTable->setColumnCount(2);
	preferences.commandTable->setHorizontalHeaderLabels (tableHeader);
	preferences.commandTable->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
	preferences.commandTable->setShowGrid(true);

	QMap<QString, QString> cmdMap = getCommandMap ();
	QMapIterator<QString, QString> i (cmdMap);
	while (i.hasNext())
	{
		i.next();
		QTableWidgetItem * cmdNameItem = new QTableWidgetItem(i.key());
		QTableWidgetItem * cmdDescItem = new QTableWidgetItem(i.value());
		preferences.commandTable->insertRow(0);
		preferences.commandTable->setItem(0, 0, cmdNameItem);
		preferences.commandTable->setItem(0, 1, cmdDescItem);
	}

	// connect buttons:
	connect(preferences.addButton,		SIGNAL(clicked ()), this, SLOT(insertCommandTableRow ()));
	connect(preferences.deleteButton,	SIGNAL(clicked ()), this, SLOT(deleteCommandTableRow ()));
	connect(preferences.logFileButton,	SIGNAL(clicked ()), this, SLOT(selectLogFile ()));
	connect(preferences.sam7PathButton,	SIGNAL(clicked ()), this, SLOT(selectSam7File ()));
	connect(preferences.defaultCommandsButton,SIGNAL(clicked ()), this, SLOT(fillDefaultCommands ()));

	// connect entry checks
	connect(preferences.flashBasepathEdit,	SIGNAL(editingFinished ()), this, SLOT(checkFilled ()));
	connect(preferences.openBeaconBasepathEdit,SIGNAL(editingFinished ()), this, SLOT(checkFilled ()));

	if (preferenceDialog->exec () == QDialog::Accepted)
	{
		int refreshRate = preferences.refreshSpin->value ();
		settings->setValue("FlashBasepath", preferences.flashBasepathEdit->text ());
		settings->setValue("OpenBeaconBasepath", preferences.openBeaconBasepathEdit->text ());
		settings->setValue("DeviceRefreshRate", refreshRate);
		settings->setValue("showRX", showRX);
		showRX = preferences.showTagPacketsCheck->isChecked();
		settings->setValue("sam7Path", preferences.sam7PathEdit->text ());

		QString newLogFile = preferences.logFileEdit->text();
		if (logFile != newLogFile)
		{
			emit logFileChanged (newLogFile);
			settings->setValue("logFile", newLogFile);
			log->infoLog (QString("Logpath changed to: %1").arg(newLogFile));
		}

		QMap<QString, QString> newCmdMap;
		log->debugLog ("Current command list:");
		for (int row = 0; row < preferences.commandTable->rowCount(); row++)
		{
			QTableWidgetItem *cmdNameItem = preferences.commandTable->item(row, 0);
			QTableWidgetItem *cmdDescItem = preferences.commandTable->item(row, 1);
			if (cmdNameItem && cmdDescItem)
			{
				newCmdMap.insert (cmdNameItem->text(), cmdDescItem->text());
				log->debugLog (QString ("Name: %1\tDesc: %2").arg(cmdNameItem->text()).arg(cmdDescItem->text()));
			}
		}
		writeCommandMap (newCmdMap);
		refreshDevices ();
		refreshTimer->setInterval (refreshRate * 1000);
	}
}