void Session::Registered(const Response &response)
  {
    if(Stopped()) {
      return;
    }

    if(response.Successful() && response.GetData().toBool()) {
      qDebug() << GetPrivateIdentity().GetLocalId() << "registered and waiting to go.";
      return;
    }

    if(!_register_event.Stopped()) {
      qDebug() << "Almost started two registration attempts simultaneously!";
      return;
    }

    int delay = 5000;
    if(response.GetErrorType() == Response::Other) {
      delay = 60000;
    }
    qDebug() << "Unable to register due to" << response.GetError() <<
      "Trying again later.";

    Dissent::Utils::TimerCallback *cb =
      new Dissent::Utils::TimerMethod<Session, int>(this, &Session::Register, 0);
    _register_event = Dissent::Utils::Timer::GetInstance().QueueCallback(cb, delay);
  }
  void Session::Challenged(const Response &response)
  {
    if(Stopped()) {
      return;
    }

    if(response.Successful()) {
      QPair<bool, QVariant> auth = _auth->ProcessChallenge(response.GetData());
      if(auth.first) {
        qDebug() << "Sending challenge response";
        SendChallenge(false, auth.second);
        return;
      }

      qDebug() << "Received an invalid challenge, retrying.";
    }

    if(!_register_event.Stopped()) {
      qDebug() << "Almost started two registration attempts simultaneously!";
      return;
    }

    int delay = 5000;
    if(response.GetErrorType() == Response::Other) {
      delay = 60000;
    }
    qDebug() << "Unable to register due to" << response.GetError() <<
      "Trying again later.";

    Dissent::Utils::TimerCallback *cb =
      new Dissent::Utils::TimerMethod<Session, int>(this, &Session::Register, 0);
    _register_event = Dissent::Utils::Timer::GetInstance().QueueCallback(cb, delay);
  }