Example #1
0
void
quit (int signal)
{
  std::cout << "Stopping service." << std::endl;

  if (initialized)
    iaxc_shutdown ();
  if (reg_id)
    iaxc_unregister (reg_id);

  exit (exitcode);
}
void IaxNetworkRegistration::registrationEvent( int eventType )
{
    // Process an IAX registration event.
    if ( eventType == IAXC_REGISTRATION_REPLY_ACK ||
         eventType == 65535 ) { // IAX_EVENT_NULL, which means already reg'd.
        // Registration is now valid.
        qLog(VoIP) << "IAX registration set to Home";
        updateRegistrationState( QTelephony::RegistrationHome );
        if ( pendingSetCurrentOperator ) {
            emit setCurrentOperatorResult( QTelephony::OK );
            pendingSetCurrentOperator = false;
        }
    } else if ( eventType == IAXC_REGISTRATION_REPLY_REJ ) {
        // Registration authentication failed.
        qLog(VoIP) << "IAX registration set to Denied";
        updateRegistrationState( QTelephony::RegistrationDenied );
        if ( pendingSetCurrentOperator ) {
            emit setCurrentOperatorResult( QTelephony::NetworkNotAllowed );
            pendingSetCurrentOperator = false;
        }
        if ( registrationId != -1 ) {
            iaxc_unregister( registrationId );
            registrationId = -1;
        }
    } else {
        // Registration has failed for some other reason (timeout probably).
        qLog(VoIP) << "IAX registration set to None, event type" << eventType;
        updateRegistrationState( QTelephony::RegistrationNone );
        if ( pendingSetCurrentOperator ) {
            emit setCurrentOperatorResult( QTelephony::Error );
            pendingSetCurrentOperator = false;
        }
        if ( registrationId != -1 ) {
            iaxc_unregister( registrationId );
            registrationId = -1;
        }
    }
}
void IaxNetworkRegistration::deregisterFromServer()
{
    qLog(VoIP) << "IaxNetworkRegistration::deregisterFromServer()";
    callUriValue = QString();
    if ( registrationId != -1 ) {
        iaxc_unregister( registrationId );
        registrationId = -1;

        // Handle any pending events or timeouts caused by the unregistration.
        service->serviceIaxClient();
    }
    qLog(VoIP) << "IAX registration set to None";
    updateRegistrationState( QTelephony::RegistrationNone );
    if ( pendingSetCurrentOperator ) {
        emit setCurrentOperatorResult( QTelephony::OK );
        pendingSetCurrentOperator = false;
    }
}