Early out parsing if we're only processing incoming OR outgoing.
authorJamie Thompson <jamie@.(none)>
Thu, 25 Aug 2011 02:01:39 +0000 (03:01 +0100)
committerJamie Thompson <jamie@.(none)>
Thu, 25 Aug 2011 02:01:39 +0000 (03:01 +0100)
EventParsers/CSVSymbianEventLogParser.cpp
EventParsers/VMGEntities/VMessage.cpp

index f5bf558..43142f1 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdexcept>
 
 using namespace EventParsers;
 #include <stdexcept>
 
 using namespace EventParsers;
+using EventTypes::PhoneCall;
 
 class SortByValueDesc
 {
 
 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"));
                                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);
                                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<EventTypes::iEvent> 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<EventTypes::iEvent> newEvent(new EventTypes::PhoneCall(
-                                       CurrentSettings(),
-                                       direction,
-                                       eTime,
-                                       number,
-                                       duration));
-                               fileEvents.append(EventTypes::EventFromFile(newEvent, recordNumber));
                        }
                }
 
                        }
                }
 
index 75ace8f..443070e 100644 (file)
@@ -89,6 +89,14 @@ bool VMessage::Read(const QString &initialLine, QTextStream &stream, EventTypes:
                {
                        QString box = lineData.mid(lineData.indexOf(":") + 1);
                        bool isOutgoing(box == "SENT");
                {
                        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;
                        if (isOutgoing == false && box != "INBOX")
                        {
                                qDebug() << "Unexpected box: " << box;