TimeoutCommand::TimeoutCommand(Command *command, WebPageManager *manager, QObject *parent) : Command(parent) {
    m_command = command;
    m_manager = manager;
    m_timer = new QTimer(this);
    m_timer->setSingleShot(true);
    connect(m_timer, SIGNAL(timeout()), this, SLOT(commandTimeout()));
    connect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
}
void PageLoadingCommand::commandFinished(Response *response) {
    disconnect(m_page, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
    m_command->deleteLater();
    if (m_pageLoadingFromCommand)
        m_pendingResponse = response;
    else
        emit finished(response);
}
PageLoadingCommand::PageLoadingCommand(Command *command, WebPageManager *manager, QObject *parent) : Command(parent) {
  m_manager = manager;
  m_command = command;
  m_pageLoadingFromCommand = false;
  m_pageSuccess = true;
  m_pendingResponse = NULL;
  connect(m_manager, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
  connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
}
void Connection::startCommand() {
  m_commandWaiting = false;
  if (m_pageSuccess) {
    m_runningCommand = m_queuedCommand;
    m_queuedCommand = NULL;
    connect(m_page, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
    connect(m_runningCommand,
            SIGNAL(finished(Response *)),
            this,
            SLOT(finishCommand(Response *)));
    m_runningCommand->start();
  } else {
void Connection::startCommand() {
  m_commandWaiting = false;
  if (m_pageSuccess) {
    m_command = m_commandFactory->createCommand(m_commandName.toAscii().constData());
    if (m_command) {
      connect(m_page, SIGNAL(loadStarted()), this, SLOT(pageLoadingFromCommand()));
      connect(m_command,
              SIGNAL(finished(Response *)),
              this,
              SLOT(finishCommand(Response *)));
      m_command->start(m_arguments);
    } else {
      QString failure = QString("[WebKitServer] Unknown command: ") +  m_commandName + "\n";
      writeResponse(new Response(false, failure));
    }
    m_commandName = QString();
  } else {