From: Jamie Thompson Date: Thu, 25 Aug 2011 02:01:39 +0000 (+0100) Subject: Early out parsing if we're only processing incoming OR outgoing. X-Git-Url: http://git.maemo.org/git/?p=qwerkisync;a=commitdiff_plain;h=f3569fd45504745ccde6944c0dc25c17c0b92dd5;ds=sidebyside Early out parsing if we're only processing incoming OR outgoing. --- diff --git a/EventParsers/CSVSymbianEventLogParser.cpp b/EventParsers/CSVSymbianEventLogParser.cpp index f5bf558..43142f1 100644 --- a/EventParsers/CSVSymbianEventLogParser.cpp +++ b/EventParsers/CSVSymbianEventLogParser.cpp @@ -29,6 +29,7 @@ #include using namespace EventParsers; +using EventTypes::PhoneCall; class SortByValueDesc { @@ -176,26 +177,37 @@ EventTypes::EventFromFileList CSVSymbianEventLogParser::ParseFile(QFile &eventFi qDebug() << "Parsing event from line #" << lineNumber << ". Values: " << lineValues; QDateTime eTime(QDateTime::fromString(lineValues.at(m_HeadingIndices.value("etime")), "dd/MM/yyyy h:mm:ss ap")); - int duration(lineValues.at(m_HeadingIndices.value("duration")).toInt(&bOK)); - if(!bOK) Settings::eDirection direction(lineValues.at(m_HeadingIndices.value("direction")) == "0" ? Settings::INCOMING : Settings::OUTGOING); + + // We only care about the requested directions... + if(CurrentSettings().ShouldProcess(direction, EventTypes::EVENT_TYPE_CALL)) { - qDebug() << QString("Unable to parse '%1' as a duration. Skipping record.") - .arg(lineValues.at(m_HeadingIndices.value("duration"))); - continue; + int duration(lineValues.at(m_HeadingIndices.value("duration")).toInt(&bOK)); + if(!bOK) + { + qDebug() << QString("Unable to parse '%1' as a duration. Skipping record.") + .arg(lineValues.at(m_HeadingIndices.value("duration"))); + continue; + } + QString number(ExtractString(lineValues.at(m_HeadingIndices.value("number")))); + // TODO: Not currently used...but almost certainly contains SIP call data + QString data(ExtractString(lineValues.at(m_HeadingIndices.value("data")))); + + if(number.trimmed().length() == 0) + { + qDebug() << "Empty tel!"; + } + + QSharedPointer newEvent(new PhoneCall( + CurrentSettings(), + direction, + eTime, + number, + duration)); + fileEvents.append(EventTypes::EventFromFile(newEvent, recordNumber)); } - QString number(ExtractString(lineValues.at(m_HeadingIndices.value("number")))); - QString data(ExtractString(lineValues.at(m_HeadingIndices.value("data")))); - - QSharedPointer newEvent(new EventTypes::PhoneCall( - CurrentSettings(), - direction, - eTime, - number, - duration)); - fileEvents.append(EventTypes::EventFromFile(newEvent, recordNumber)); } } diff --git a/EventParsers/VMGEntities/VMessage.cpp b/EventParsers/VMGEntities/VMessage.cpp index 75ace8f..443070e 100644 --- a/EventParsers/VMGEntities/VMessage.cpp +++ b/EventParsers/VMGEntities/VMessage.cpp @@ -89,6 +89,14 @@ bool VMessage::Read(const QString &initialLine, QTextStream &stream, EventTypes: { QString box = lineData.mid(lineData.indexOf(":") + 1); bool isOutgoing(box == "SENT"); + + // Early out once we know we're not processing this type of message + if((!isOutgoing && !CurrentSettings().ShouldProcess(Settings::INCOMING, EventTypes::EVENT_TYPE_SMS)) + || isOutgoing && !CurrentSettings().ShouldProcess(Settings::OUTGOING, EventTypes::EVENT_TYPE_SMS)) + { + return false; + } + if (isOutgoing == false && box != "INBOX") { qDebug() << "Unexpected box: " << box;