bool Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
                                                unsigned options,
                                                OpalConnection::StringOptions * stroptions)
{
  PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection");

  if (!forward_uri.empty () && manager.get_unconditional_forward ())
    connection.ForwardCall (forward_uri);
  else if (manager.GetCallCount () > 1) { 

    if (!forward_uri.empty () && manager.get_forward_on_busy ())
      connection.ForwardCall (forward_uri);
    else {
      connection.ClearCall (OpalConnection::EndedByLocalBusy);
    }
  }
  else {

    Opal::Call *call = dynamic_cast<Opal::Call *> (&connection.GetCall ());
    if (call) {

      if (!forward_uri.empty () && manager.get_forward_on_no_answer ()) 
        call->set_no_answer_forward (manager.get_reject_delay (), forward_uri);
      else
        call->set_reject_delay (manager.get_reject_delay ());
    }

    return SIPEndPoint::OnIncomingConnection (connection, options, stroptions);
  }

  return false;
}
Beispiel #2
0
bool
Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
					   unsigned options,
					   OpalConnection::StringOptions * stroptions)
{
  bool busy = false;
  PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection");

  if (!SIPEndPoint::OnIncomingConnection (connection, options, stroptions))
    return false;

  for (PSafePtr<OpalConnection> conn(connectionsActive, PSafeReference); conn != NULL; ++conn) {
    if (conn->GetCall().GetToken() != connection.GetCall().GetToken() && !conn->IsReleased ())
      busy = true;
  }

  if (!forward_uri.empty () && manager.get_unconditional_forward ())
    connection.ForwardCall (forward_uri);
  else if (busy) {

    if (!forward_uri.empty () && manager.get_forward_on_busy ())
      connection.ForwardCall (forward_uri);
    else {
      connection.ClearCall (OpalConnection::EndedByLocalBusy);
    }
  }
  else {

    Opal::Call *call = dynamic_cast<Opal::Call *> (&connection.GetCall ());
    if (call) {

      if (!forward_uri.empty () && manager.get_forward_on_no_answer ())
        call->set_no_answer_forward (manager.get_reject_delay (), forward_uri);
      else // Pending
        call->set_reject_delay (manager.get_reject_delay ());
    }
  }

  return true;
}
Beispiel #3
0
bool
Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
                                           unsigned options,
                                           OpalConnection::StringOptions *stroptions)
{
  PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection");

  if (!SIPEndPoint::OnIncomingConnection (connection, options, stroptions))
    return false;

  /* Unconditional call forward? */
  if (!unconditionalForwardParty.IsEmpty ()) {
    PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection forwarded to " << busyForwardParty << " (Unconditional)");
    connection.ForwardCall (unconditionalForwardParty);
    return false;
  }

  /* Busy call forward? */
  for (PSafePtr<OpalConnection> conn(connectionsActive, PSafeReference); conn != NULL; ++conn) {
    if (conn->GetCall().GetToken() != connection.GetCall().GetToken() && !conn->IsReleased ()) {
      if (!busyForwardParty.IsEmpty ()) {
        PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection forwarded to " << busyForwardParty << " (busy)");
        connection.ForwardCall (busyForwardParty);
      }
      else {
        PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection rejected (busy)");
        connection.ClearCall (OpalConnection::EndedByLocalBusy);
      }
      return false;
    }
  }

  /* No Answer Call Forward or Reject */
  Opal::Call *call = dynamic_cast<Opal::Call *> (&connection.GetCall ());
  if (call)
    call->set_forward_target (noAnswerForwardParty);

  return true;
}