void IaxNetworkRegistration::registerToServer() { qLog(VoIP) << "IaxNetworkRegistration::registerToServer()"; if ( registrationState() == QTelephony::RegistrationHome ) { if ( pendingSetCurrentOperator ) { emit setCurrentOperatorResult( QTelephony::OK ); pendingSetCurrentOperator = false; } } else if ( registrationId == -1 ) { // We are now searching for a server to register to. qLog(VoIP) << "IAX registration set to Searching"; updateRegistrationState( QTelephony::RegistrationSearching ); // Read the registration settings to use from Asterisk.conf. QSettings config( "Trolltech", "Asterisk" ); config.beginGroup( "Registration" ); QString userid = config.value( "UserId" ).toString(); QString password = config.value( "Password" ).toString(); QString server = config.value( "Server" ).toString(); int port = config.value( "Port", -1 ).toInt(); if ( password.startsWith( ":" ) ) { // The password has been base64-encoded. password = QString::fromUtf8 ( QByteArray::fromBase64( password.mid(1).toLatin1() ) ); } config.endGroup(); // Registration // If no server, then assume that we cannot register at all. if ( server.isEmpty() ) { qLog(VoIP) << "IAX registration set to None - no server configured"; updateRegistrationState( QTelephony::RegistrationNone ); if ( pendingSetCurrentOperator ) { emit setCurrentOperatorResult( QTelephony::Error ); pendingSetCurrentOperator = false; } return; } // Record the call URI for later. TODO: how to encode special chars? if ( password.isEmpty() ) callUriValue = userid + "@" + server; else callUriValue = userid + ":" + password + "@" + server; // Start the registration process. TODO: async host lookup. if ( port != -1 && port != 0 ) server += ":" + QString::number( port ); registrationId = iaxc_register( userid.toUtf8().data(), password.toUtf8().data(), server.toUtf8().data() ); // Handle any pending events or timeouts caused by the registration. service->serviceIaxClient(); } }
AtPhoneIndicators::AtPhoneIndicators( QObject *parent ) : AtIndicators( parent ) { d = new AtPhoneIndicatorsPrivate(); d->signalQuality = new QValueSpaceItem ( "/Hardware/Accessories/QSignalSource/modem/SignalStrength", this ); connect( d->signalQuality, SIGNAL(contentsChanged()), this, SLOT(updateSignalQuality()) ); d->batteryCharge = new QValueSpaceItem( "/Hardware/Accessories/QPowerSource/modem", this ); connect( d->batteryCharge, SIGNAL(contentsChanged()), this, SLOT(updateBatteryCharge()) ); #ifdef QTOPIA_CELL d->smsMemoryFull = new QValueSpaceItem ( "/Telephony/Status/SMSMemoryFull", this ); connect( d->smsMemoryFull, SIGNAL(contentsChanged()), this, SLOT(updateSmsMemoryFull()) ); #endif d->battchg = addIndicator( "battchg", 5, 0 ); d->signal = addIndicator( "signal", 5, 0 ); d->service = addIndicator( "service", 1, 0 ); d->message = addIndicator( "message", 1, 0 ); d->call = addIndicator( "call", 1, 0 ); d->roam = addIndicator( "roam", 1, 0 ); d->smsfull = addIndicator( "smsfull", 1, 0 ); d->callsetup = addIndicator( "callsetup", 3, 0 ); d->callhold = addIndicator( "callheld", 2, 0 ); d->netReg = new QNetworkRegistration( "modem", this ); if ( !d->netReg->available() ) { // May be a VoIP-only phone, so use the default network reg object. delete d->netReg; d->netReg = new QNetworkRegistration( QString(), this ); } connect( d->netReg, SIGNAL(registrationStateChanged()), this, SLOT(updateRegistrationState()) ); #ifdef QTOPIA_CELL d->smsReader = new QSMSReader( QString(), this ); connect( d->smsReader, SIGNAL(unreadCountChanged()), this, SLOT(unreadCountChanged()) ); #endif updateRegistrationState(); updateSignalQuality(); updateBatteryCharge(); }
void PstnNetworkRegistration::initDone() { updateInitialized( true ); updateRegistrationState( QTelephony::RegistrationHome ); updateCurrentOperator( QTelephony::OperatorModeAutomatic, "0Telephone", "Telephone", "GSM" ); // No tr }
QNetworkRegistrationDummy::QNetworkRegistrationDummy ( const QString& service, QObject *parent ) : QNetworkRegistrationServer( service, parent ) { QTimer::singleShot( 500, this, SLOT(searching()) ); QTimer::singleShot( 5000, this, SLOT(home()) ); QTimer::singleShot( 200, this, SLOT(initDone()) ); updateRegistrationState( QTelephony::RegistrationNone ); }
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; } }
void QNetworkRegistrationDummy::home() { updateRegistrationState( QTelephony::RegistrationHome ); updateCurrentOperator( QTelephony::OperatorModeAutomatic, "0Qtopia", "Qtopia", "GSM" ); // No tr }
void QNetworkRegistrationDummy::searching() { updateRegistrationState( QTelephony::RegistrationSearching ); }