static void parse_command(char *str)
{
  char *p;
  char *cmd;

  p = str + strlen(str);
  while ( (p > str) && (*(--p) < ' ') )
    *p = '\0';

  cmd = parse_command_arg(&str);
  if ( *cmd == '\0' )
    return;

  if ( strcmp(cmd, "window") == 0 ) {
    frame_geometry_t g = FRAME_GEOMETRY_NULL;

    if ( *str != '\0' ) {
      if ( _capture_interface.set_window ) {
	frame_geometry_parse(str, &g);
	_capture_interface.set_window(capture, &g);
      }
    }
    else {
      if ( _capture_interface.get_window ) {
	_capture_interface.get_window(capture, &g);
	callback_window(&g);
      }
    }
  }
  else if ( strcmp(cmd, "period") == 0 ) {   // period
    long delay = 0;

    if ( *str != '\0' ) {
      if ( _capture_interface.set_period )
	delay = _capture_interface.set_period(capture, strtol(str, NULL, 0));
    }
    else {
      if ( _capture_interface.set_period )
	delay = _capture_interface.get_period(capture);
    }

    callback_period(delay);
  }
  else if ( strcmp(cmd, "refresh") == 0 ) {
    if ( _capture_interface.refresh )
      _capture_interface.refresh(capture);
  }
  else if ( strncmp(cmd, "action_", 7) == 0 ) {
    parse_command_action(cmd, str);
  }
  else if ( strcmp(cmd, "attr") == 0 ) {
    char *key = parse_command_arg(&str);
    capture_attr_t *attrs = NULL;
    int nmemb = 0;

    if ( *key != '\0' ) {
      char *value = parse_command_arg(&str);

      if ( *value != '\0' ) {
	if ( _capture_interface.attr_set )
	  _capture_interface.attr_set(capture, key, value);
      }
      else {
	if ( _capture_interface.attr_get )
	  attrs = _capture_interface.attr_get(capture, key, &nmemb);
      }
    }
    else {
      if ( _capture_interface.attr_get )
	attrs = _capture_interface.attr_get(capture, NULL, &nmemb);
    }

    if ( attrs != NULL ) {
      callback_attr(attrs, nmemb);
    }
  }
  else if ( strcmp(cmd, "show_status") == 0 ) {
    if ( _capture_interface.show_status ) {
      _capture_interface.show_status(capture, str);
    }
  }
  else if ( strcmp(cmd, "exit") == 0 ) {
    exit(0);
  }
  else {
    eprintf("Unknown command '%s'\n", cmd);
  }
}
Exemple #2
0
QString obout( QObject *w) {
  QString attr; // return value

  QString wname = w->objectName();
  QString wtype = w->metaObject()->className();
  //qDebug() << wname << wtype;

  if (OUTXML) {
    //printf("<%s>\n", wname.replace(' ','_').toAscii().data());
    jxout += "<" + wname.replace(' ','_') + " >\n";
    return wname;
  }

  QString outname;
/* eliminate cruft */
  if (wname.startsWith("qt_")) {
  } else if (wname.isNull()) {
    if (wtype == "QWidget") {
    } else if (wtype == "QSplitterHandle") {
    } else if (wtype == "QTextControl") {
    } else if (wtype == "QVBoxLayout") {
    } else if (wtype == "QAction") {
    }

  } else if (wname == "VSplitter") {
    outname = wname;
    attr = " ";
  } else if (wname == "HSplitter") {
    outname = wname;
    attr = " ";
  } else if (wname == "MenuBar") {
    outname = wname;
    attr = " ";
  } else if (wname == "MenuItem") {
    outname = wname;
    attr = " ";
  } else if (wname == "Navigator") {
    outname = wname;
    attr = " ";
  } else if (wname == "Widget") {
    outname = wname;
    attr = " ";
  } else if (wname == "OpenGLContext") {
    outname = wname;
    attr = " ";
  } else if (wtype == "QMenu") {
    outname = "MenuItem";
    attr = "label: "; attr.append('"'); attr.append(wname); attr.append('"');
  } else if (wtype == "QAction") {
    outname = "MenuItem";
    attr = "label: "; attr.append('"'); attr.append(wname); attr.append('"');
    QString check = check_attr((QAction *)w);
    if (!check.isNull()) attr.append(","+check);
  } else if (wtype == "JXAction") {
    outname = "MenuItem";
    attr = "label: "; attr.append('"'); attr.append(wname); attr.append('"');
    QString cback = callback_attr((JXAction *)w);
    if (!cback.isNull()) attr.append(","+cback);
    QString check = check_attr((QAction *)w);
    if (!check.isNull()) attr.append(","+check);
  } else {
    attr = " ";
  }

  if (!outname.isNull()) {
    //printf("(%s [\n", outname.toAscii().data());
    jxout += "( " + outname + " [\n";
  }
  return attr;

}