コード例 #1
0
ファイル: vendor_neo.cpp プロジェクト: Camelek/qtmoko
void NeoCallProvider::clcc(bool, const QAtResult & result)
{
    QModemCall *ic = incomingCall();
    bool icMissing = true;

    int count = 0;

    // Find the current state of the call in the AT+CLCC results.
    QAtResultParser parser(result);
    while (parser.next("+CLCC:")) {
        uint id = parser.readNumeric();
        parser.readNumeric();   // dir
        uint state = parser.readNumeric();
        uint mode = parser.readNumeric();
        parser.readNumeric();   // mpty
        QString number = QAtUtils::decodeNumber(parser);
        QString callType = resolveCallMode(mode);
        //qDebug() << "=============== CLCC id=" << id << ", state =" << state <<
        //    ", mode=" << mode << ", number=" << number << "callType=" << callType;

        if (state == 4) {       // incoming
            if (ic && ic->number() == number) {
                icMissing = false;  // still ringing
            } else {            // new incoming call
                QModemCallProvider::ringing(number, callType, id);
                announceCall();
                clccTimer.start(CLCC_POLL_INTERVAL);
                return;
            }
        }
        count++;
    }

    // We still have call in incoming state
    if (ic) {
        if (icMissing) {
            qLog(Modem) << "Reporting missed call.";    // but it's missing in CLCC list
            ic->setState(QPhoneCall::Missed);   // make the call missed
            return;
        }
        clccTimer.start(CLCC_POLL_INTERVAL);    // continue with polling
        return;
    }
    // We still have some connected calls
    if (count > 0) {
        clccTimer.start(CLCC_POLL_INTERVAL);    // continue with polling
        return;
    }

    qLog(Modem) << "No more calls left";

    QList < QPhoneCallImpl * >list = calls();
    QList < QPhoneCallImpl * >::ConstIterator it;
    for (it = list.begin(); it != list.end(); ++it) {
        (*it)->setState(QPhoneCall::HangupRemote);
    }
}