/**
   * Constructor.
   *
   * @param eventSource source of the mouse and key events which will be translated into scripting
   *     language commands. Such a typical source is e.g. the VNC viewer panel.
   */
  public RecordingModule(
      MainFrame frame, Component eventSource, ScriptManager scriptManager, UserConfiguration cfg) {
    this.cfg = cfg;
    this.scriptManager = scriptManager;
    readOnly = cfg.getBoolean("rfb.readOnly").booleanValue();

    fb = (DesktopViewer) eventSource;
    fb.removeMouseListener(fb);
    eventSource.addMouseListener(this);
    fb.addMouseListener(fb);
    eventSource.addMouseMotionListener(this);
    eventSource.addMouseWheelListener(this);
    eventSource.addKeyListener(this);

    client = scriptManager.getClient();
    if (client != null) {
      client.addServerListener(this);
    }

    //        scriptManager.addMouseInputListener(this);
    //        scriptManager.addKeyListener(this);

    // Number of archived events
    //        events.setSize(EVENT_VECTOR_SIZE);

    // Populate the reversed keycode->keyname Map
    Map t = Utils.getKeyCodeTable();
    Iterator e = t.keySet().iterator();
    Object o;
    while (e.hasNext()) {
      o = e.next();
      keyCodes.put(t.get(o), o);
    }
    cfg.addConfigurationListener(this);
    scriptManager.addScriptListener(this);
    configurationChanged(null);
  }