Early out parsing if we're only processing incoming OR outgoing.
[qwerkisync] / EventParsers / VMGEntities / VMessage.cpp
index b798462..443070e 100644 (file)
@@ -21,9 +21,9 @@
 #include "EventTypes/SMS.h"
 #include "Factory.h"
 #include "Settings.h"
+#include "VBody.h"
 #include "VCard.h"
 #include "VEnvelope.h"
-#include "VBody.h"
 
 #include <QDateTime>
 #include <QTextStream>
@@ -50,7 +50,7 @@ VMessage::~VMessage()
 {
 }
 
-bool VMessage::Read(const QString & initialLine, QTextStream & stream, EventTypes::SMS & event)
+bool VMessage::Read(const QString &initialLine, QTextStream &stream, EventTypes::SMS &event)
 {
        if(getParent() != NULL)
        {
@@ -89,6 +89,14 @@ bool VMessage::Read(const QString & initialLine, QTextStream & stream, EventType
                {
                        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;