Beispiel #1
0
QString RingControl::findRingTone()
{
    QString ringTone;
    if(DialerControl::instance()->hasIncomingCall()) {
        QPhoneCall call = DialerControl::instance()->incomingCall();
        QString numberOrName = call.number();
        QContact cnt;
        QContactModel *m = ServerContactModel::instance();
        if (!call.contact().isNull()) {
            cnt = m->contact(call.contact());
        } else if (!numberOrName.isEmpty()) {
            cnt = m->matchPhoneNumber(numberOrName);
        }

        if (!cnt.uid().isNull()) {
            numberOrName = cnt.label();

            // video ringtone
            ringTone = cnt.customField( "videotone" );
            if ( !ringTone.isEmpty() ) {
                d->videoTone = true;
            } else { // normal ringtone
                ringTone = cnt.customField( "tone" );
                d->videoTone = false;
            }

            if ( ringTone.isEmpty() ) {
                // check if the contacts category has a ringtone
                QList<QString> catList = cnt.categories();
                if ( catList.count() ) {
                    QCategoryManager catManager;
                    ringTone = catManager.ringTone( catList.at( 0 ) );
                }
                d->videoTone = false;
            }
        }
    }

    return ringTone;
}
Beispiel #2
0
void DialerControl::callStateChanged( const QPhoneCall& call )
{
    // Set value space appropriately
    // XXX Optimize for redundancy!
    if(hasIncomingCall()) {
        QPhoneCall icall = incomingCall();
        QString number = icall.number();
        QString name;
        QUniqueId contact = icall.contact();
        QContactModel *m = ServerContactModel::instance();
        if(!contact.isNull()) {
            QContact cnt = m->contact(contact);
            if (!cnt.uid().isNull())
                name = cnt.label();
        } else if(!number.isEmpty()) {
            QContact cnt = m->matchPhoneNumber(number);
            if (!cnt.uid().isNull())
                name = cnt.label();
        } else {
            number = tr("Unknown", "Unknown caller");
        }
        phoneValueSpace.setAttribute("Incoming/Number", QVariant(number.trimmed()));
        phoneValueSpace.setAttribute("Incoming/Name", QVariant(name));

        if(!aaTid && mProfiles->activeProfile().autoAnswer())
            aaTid = startTimer(auto_answer_gap);
    } else {
        if(aaTid)
            killTimer(aaTid);
        phoneValueSpace.removeAttribute("Incoming");
    }

    // emit useful signals
    if( call.state() == QPhoneCall::Connected )
    {
        emit callConnected( call );
        // update cached call info.
        updateCachedCall( call );
    }
    else if( call.state() == QPhoneCall::Hold )
    {
        emit callPutOnHold( call );
    }
    else if( call.dialing() )
    {
        emit callDialing( call );
    }
    else if( call.incoming() )
    {
        // Turn off screen saver so the incoming call will be visible.
        QtopiaPowerManager::setActive(false);

        emit callIncoming( call );
    }
    else if ( call.dropped()  )
    {
        emit callDropped( call );
    }
    doActiveCalls();

    // Disable screen saver if in a call
    if (hasIncomingCall() || hasActiveCalls() || hasCallsOnHold())
        QtopiaApplication::setPowerConstraint(QtopiaApplication::DisableLightOff);
    else
        QtopiaApplication::setPowerConstraint(QtopiaApplication::Enable);

    emit stateChanged();
}