コード例 #1
0
ファイル: ringcontrol.cpp プロジェクト: Artox/qtmoko
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;
}
コード例 #2
0
ファイル: dialercontrol.cpp プロジェクト: muromec/qtopia-ezx
/*! \internal */
void DialerControl::cacheCall( const QPhoneCall &call )
{
    // cache call info to perserve data when battery runs out
    QSettings setting( "Trolltech", "qpe" );
    setting.beginGroup( "CallControl" );
    setting.beginGroup( call.identifier() );
    setting.setValue( "CallType", call.dialing() ? QCallListItem::Dialed : QCallListItem::Missed );
    setting.setValue( "FullNumber", call.fullNumber() );
    setting.setValue( "StartTime", call.startTime() );
    setting.setValue( "EndTime", QDateTime() );
    setting.setValue( "Contact", call.contact().toString() );
    setting.setValue( "ServiceType", call.callType() );
    setting.endGroup();
    setting.endGroup();
    setting.sync();
    // make sure the data is written to disk
    ::sync();
}
コード例 #3
0
ファイル: dialercontrol.cpp プロジェクト: muromec/qtopia-ezx
/*!
  Record the \a call in the call list.
 */
void DialerControl::recordCall( const QPhoneCall &call )
{
    QCallListItem::CallType ct;
    if( call.dialed() )
        ct = QCallListItem::Dialed;
    else if( call.hasBeenConnected() || call.state() == QPhoneCall::HangupLocal )
        ct = QCallListItem::Received;
    else {
        ct = QCallListItem::Missed;
        // increase missed call count
        missedCall( call );
    }

    // QPhoneCall::connectTime() in case call has been connected
    // QPhoneCall::startTime() in other cases
    QDateTime startTime = call.hasBeenConnected() ? call.connectTime() : call.startTime();

    QCallListItem listItem( ct, call.fullNumber(),
            startTime, call.endTime(), call.contact(), call.callType() );
    mCallList.record( listItem );

    removeCachedCall( call );
}
コード例 #4
0
ファイル: dialercontrol.cpp プロジェクト: muromec/qtopia-ezx
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();
}