示例#1
0
/*! \internal */
QPhoneCall DialerControl::createCall( const QString& callType )
{
    QPhoneCall c = mCallManager->create(callType);
    c.connectStateChanged( this, SLOT(callStateChanged(QPhoneCall)) );
    c.connectPendingTonesChanged( this, SIGNAL(pendingTonesChanged(QPhoneCall)) );
    c.connectRequestFailed( this, SIGNAL(requestFailed(QPhoneCall,QPhoneCall::Request)) );
    return c;
}
示例#2
0
void DialerControl::newCall( const QPhoneCall& call )
{
    QPhoneCall c = call;
    c.connectStateChanged( this, SLOT(callStateChanged(QPhoneCall)) );
    c.connectPendingTonesChanged( this, SIGNAL(pendingTonesChanged(QPhoneCall)) );
    emit callCreated( c );
    doActiveCalls();
    callStateChanged( call ); //force an update
}
示例#3
0
/*! \internal */
void DialerControl::updateCachedCall( const QPhoneCall &call )
{
    QSettings setting( "Trolltech", "qpe" );
    setting.beginGroup( "CallControl" );
    setting.beginGroup( call.identifier() );
    setting.setValue( "CallType", call.dialed() ? QCallListItem::Dialed : QCallListItem::Received );
    setting.setValue( "EndTime", QDateTime::currentDateTime() );
    setting.endGroup();
    setting.endGroup();
    setting.sync();
    ::sync();
}
示例#4
0
/*!
  Accepts an incoming call.  Has no effect if there is no incoming call.
*/
void DialerControl::accept()
{
    QList<QPhoneCall> incomingCalls = findCalls( QPhoneCall::Incoming );
    if( incomingCalls.count() )
    {
        QPhoneCall incoming = incomingCalls.first();
        if ( incoming.incoming() ) {
            //put active calls on hold
            if ( incoming.callType() == "Voice" ) {   // No tr
                // GSM calls will be put on hold automatically by the accept().
                // Other call types need to be put on hold explicitly.
                if( hasActiveCalls() ) {
                    if ( activeCalls().first().callType() == "Voice" ) {  // No tr
                        incoming.accept();
                    } else {
                        hold();
                        incoming.accept();
                    }
                } else {
                    incoming.accept();
                }
            } else {
                if( hasActiveCalls() )
                    hold();
                incoming.accept();
                incoming.activate();
            }
        }
    }
}
示例#5
0
/*! \internal */
void DialerControl::removeCachedCall( const QPhoneCall &call )
{
    QSettings setting( "Trolltech", "qpe" );
    setting.beginGroup( "CallControl" );
    setting.remove( call.identifier() );
    setting.sync();
    ::sync();
}
示例#6
0
文件: dialup.cpp 项目: Fale/qtmoko
void DialupImpl::phoneCallStateChanged( const QPhoneCall& call)
{
    if ( (int)call.state()  >= (int) QPhoneCall::HangupLocal  && !pppdProcessBlocked ) {
        //if the call hangs up/aborts w/o being stopped manually by the user we need to cleanup 
        //in order to prevent that pppdProcessBlocked blocks the interface forever
        if ( tidStateUpdate ) {
            killTimer( tidStateUpdate );
            tidStateUpdate = 0;
            state = Initialize;
            logIndex = 0;
        }
        pppIface = QString();
        netSpace->setAttribute( "NetDevice", QString() );
        ifaceStatus = QtopiaNetworkInterface::Down;
        status();
    }
    qLog(Network) << "Call state: " << call.state();
}
示例#7
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;
}
示例#8
0
/*!
  Dials a \a number if there are no currently active calls. If a
  \a contact is specified, it is used as the contact to display and
  insert into the call history. Before calling this function,
  you should check that there are no incoming calls, or active calls.
  If \a sendcallerid is true, then send the caller's identifier as part
  of the dial sequence.

  If \a callType is "Voice" a GSM call will be dialed.  If \a callType is
  "VoIP" a VoIP call will be dialed.
*/
void DialerControl::dial( const QString &number, bool sendcallerid, const QString& callType, const QUniqueId &contact )
{

    QUniqueId matchedContact;
    if (contact.isNull() && !number.isEmpty())
        matchedContact = ServerContactModel::instance()->matchPhoneNumber(number).uid();
    else
        matchedContact = contact;

    if ( isDialing() ) {
        //qWarning("BUG! Attempt to dial while there is already a dialing call");
    }
    if( !hasActiveCalls() && !isDialing() )
    {
        // Collect up the dial options.
        QDialOptions dialopts;
        dialopts.setNumber( number );
        if ( sendcallerid )
            dialopts.setCallerId( QDialOptions::SendCallerId );
        else
            dialopts.setCallerId( QDialOptions::DefaultCallerId );
        dialopts.setContact( matchedContact );

        // Allow other parts of the server (e.g. GsmKeyActions) to
        // modify the dial options to account for supplementary services.
        bool handledAlready = false;
        emit modifyDial( dialopts, handledAlready );
        if ( handledAlready )
            return;

        // Call the specified number.
        QPhoneCall call = createCall(callType);
        phoneValueSpace.setAttribute( "LastDialedCall", QVariant(number) );
        call.dial( dialopts );

        // cache call here to preserve the information even if the battery run out.
        cacheCall( call );
    }
}
示例#9
0
/*!
  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 );
}
示例#10
0
/*! \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();
}
示例#11
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();
}
示例#12
0
/*!
    \internal
    Checks if the request to connect the \a call was successful.
*/
void DialerControl::checkConnectedState( const QPhoneCall &call )
{
    if ( call.state() == QPhoneCall::Connected )
        emit callControlSucceeded();
    call.disconnectStateChanged( this, SLOT(checkConnectedState(QPhoneCall)) );
}
示例#13
0
/*!
    Activate a specific call with the modem identifier \a id.
    This will typically only work with GSM calls that set the
    QPhoneCall::modemIdentifier() value.  It is used to implement
    the GSM \c{2x SEND} key sequence where \c{x} is the identifier.
*/
void DialerControl::activateCall( int id )
{
    QPhoneCall call = callManager().fromModemIdentifier(id);
    if ( !call.isNull() )
        call.activate(QPhoneCall::CallOnly);
}
示例#14
0
/*!
    End a specific call with the modem identifier \a id.
    This will typically only work with GSM calls that set the
    QPhoneCall::modemIdentifier() value.  It is used to implement
    the GSM \c{1x SEND} key sequence where \c{x} is the identifier.
*/
void DialerControl::endCall(int id)
{
    QPhoneCall call = callManager().fromModemIdentifier(id);
    if ( !call.isNull() )
        call.hangup(QPhoneCall::CallOnly);
}