{
}
-void VBody::Write(QTextStream &stream, const EventTypes::SMS &event)
+void VBody::Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup)
{
stream << "BEGIN:" << getTagName() << endl;
~VBody();
virtual bool Read(const QString &initialLine, QTextStream &stream, EventTypes::SMS &event);
- virtual void Write(QTextStream &stream, const EventTypes::SMS &event);
+ virtual void Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup);
protected:
virtual const char *getTagName() const { return "VBODY"; }
{
}
-void VCalendar::Write(QTextStream &stream, const EventTypes::SMS &event)
+void VCalendar::Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup)
{
//stream << "BEGIN:" << getTagName() << "\n";
~VCalendar ();
virtual bool Read(const QString &initialLine, QTextStream &stream, EventTypes::SMS &event);
- virtual void Write(QTextStream &stream, const EventTypes::SMS &event);
+ virtual void Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup);
protected:
virtual const char *getTagName() const { return "VCALENDAR"; }
#include "Attachment.h"
#include "Factory.h"
#include "EventTypes/SMS.h"
+#include "NumberToNameLookup.h"
#include "VBody.h"
#include "VEnvelope.h"
#include "VMessage.h"
{
}
-void VCard::Write(QTextStream &stream, const EventTypes::SMS &event)
+void VCard::Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup)
{
stream << "BEGIN:" << getTagName() << "\n";
stream << "VERSION:" << m_Version << "\n";
- //stream << "N:" << (m_Target == VCARD_LOCAL ? "" : event.Name()) << "\n";
+ stream << "N:";
+ if (m_Target != VCARD_LOCAL)
+ {
+ qDebug() << event.Tel();
+ qDebug() << numberToNameLookup.ContactDetails().count();
+ if(numberToNameLookup.ContactDetails().contains(event.Tel()))
+ stream << numberToNameLookup.ContactDetails().value(event.Tel()).second;
+ }
+ stream << "\n";
stream << "TEL:" << (m_Target == VCARD_LOCAL ? "" : event.Tel()) << "\n";
stream << "END:" << getTagName() << "\n";
~VCard();
virtual bool Read(const QString &initialLine, QTextStream &stream, EventTypes::SMS &event);
- virtual void Write(QTextStream &stream, const EventTypes::SMS &event);
+ virtual void Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup);
protected:
virtual const char *getTagName() const { return "VCARD"; }
m_ContentWriters.empty();
}
-void VEnvelope::Write(QTextStream &stream, const EventTypes::SMS &event)
+void VEnvelope::Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup)
{
stream << "BEGIN:" << getTagName() << "\n";
foreach(iWriter *contentWriter, m_ContentWriters)
- contentWriter->Write(stream, event);
+ contentWriter->Write(stream, event, numberToNameLookup);
stream << "END:" << getTagName() << "\n";
}
~VEnvelope();
virtual bool Read(const QString & initialLine, QTextStream & stream, EventTypes::SMS & event);
- virtual void Write(QTextStream & stream, const EventTypes::SMS & event);
+ virtual void Write(QTextStream & stream, const EventTypes::SMS & event, const NumberToNameLookup &numberToNameLookup);
QList<iWriter*> & getContentWriters() { return m_ContentWriters; }
return true;
}
-void VMessage::Write(QTextStream &stream, const EventTypes::SMS &event)
+void VMessage::Write(QTextStream &stream, const EventTypes::SMS &event, const NumberToNameLookup &numberToNameLookup)
{
stream << "BEGIN:VMSG\n";
stream << "VERSION:" << m_Version << "\n";
// Add in the empty vcard for outgoing messages
if(event.Destination() == EventTypes::SMS::SENT)
{
- VCard(CurrentSettings(), this, 2.1, VCard::VCARD_LOCAL).Write(stream, event);
+ VCard(CurrentSettings(), this, 2.1, VCard::VCARD_LOCAL).Write(stream, event, numberToNameLookup);
msgEnvelope.getContentWriters().append(new VCard(CurrentSettings(), &msgEnvelope, 2.1, VCard::VCARD_REMOTE));
}
else
{
- VCard(CurrentSettings(), this, 2.1, VCard::VCARD_REMOTE).Write(stream, event);
+ VCard(CurrentSettings(), this, 2.1, VCard::VCARD_REMOTE).Write(stream, event, numberToNameLookup);
msgEnvelope.getContentWriters().append(new VBody(CurrentSettings(), &msgEnvelope));
}
- msgEnvelope.Write(stream, event);
+ msgEnvelope.Write(stream, event, numberToNameLookup);
stream << "END:VMSG\n";
}
~VMessage();
virtual bool Read(const QString & initialLine, QTextStream& stream, EventTypes::SMS & event);
- virtual void Write(QTextStream & stream, const EventTypes::SMS & event);
+ virtual void Write(QTextStream & stream, const EventTypes::SMS & event, const NumberToNameLookup &numberToNameLookup);
protected:
virtual const char * getTagName() const { return "VMSG"; }
#define EVENTPARSERS_VMGEntities_IWRITER_H
namespace EventTypes { class SMS; }
+class NumberToNameLookup;
class QTextStream;
{
public:
virtual ~iWriter() {};
- virtual void Write(QTextStream& stream, const EventTypes::SMS& event) = 0;
+ virtual void Write(QTextStream& stream, const EventTypes::SMS& event, const NumberToNameLookup &numberToNameLookup) = 0;
};
}
}
using namespace EventProcessors;
+Writer::Writer(Settings &settings, const NumberToNameLookup &numberToNamelookup)
+ : m_Settings(settings), m_NumberToNameLookup(numberToNameLookup)
+{
+}
+
void Writer::Process(EventTypes::iEvent &event)
{
- event.Export(CurrentSettings().Directory());
+ event.Export(CurrentSettings().Directory(), NumberToNameLookup());
}
void Writer::EmitEventProcessed(int eventsProcessed, int totalEvents)
#include "iEventProcessor.h"
+class NumberToNameLookup;
class Settings;
#include <QObject>
Q_OBJECT
public:
- Writer(Settings &settings)
- : m_Settings(settings)
- {}
+ Writer(Settings &settings, const NumberToNameLookup &numberToNamelookup);
- const Settings & CurrentSettings() { return m_Settings; }
+ const Settings & CurrentSettings() const { return m_Settings; }
+ const NumberToNameLookup & NumberToNameLookup() const { return m_NumberToNameLookup; }
virtual void Process(EventTypes::iEvent &event);
virtual void EmitEventProcessed(int eventsProcessed, int totalEvents);
private:
const Settings & m_Settings;
+ const NumberToNameLookup &numberToNameLookup;
signals:
void EventProcessed(int current, int total);
return event;
}
-void PhoneCall::Export(const QString &baseDirectory) const
+void PhoneCall::Export(const QString &baseDirectory, const NumberToNameLookup &numberToNameLookup) const
{
// // Build the path and ensure it exists...
// QString eventFilename(baseDirectory);
virtual AttachmentCollection & Attachments() { return m_Attachments; }
public:
- virtual void Export(const QString &baseDirectory) const;
+ virtual void Export(const QString &baseDirectory, const NumberToNameLookup &numberToNameLookup) const;
PhoneCall(const Settings &settings, const RTComElEvent& event, const QList<RTComElAttachment*> attachments = QList<RTComElAttachment*>());
virtual RTComElEvent * toRTComEvent(const NumberToNameLookup &numberToNameLookup) const;
return event;
}
-void SMS::Export(const QString &baseDirectory) const
+void SMS::Export(const QString &baseDirectory, const NumberToNameLookup &numberToNameLookup) const
{
// Build the path and ensure it exists...
QString eventFilename(baseDirectory);
stream.setCodec("UTF-16LE");
EventParsers::VMGEntities::VMessage writer(CurrentSettings(), NULL, 1.1);
- writer.Write(stream, *this);
+ writer.Write(stream, *this, numberToNameLookup);
//stream << "Test";
//stream.setCodec(oldCodec);
stream.flush();
virtual AttachmentCollection & Attachments() { return m_Attachments; }
public:
- virtual void Export(const QString &baseDirectory) const;
+ virtual void Export(const QString &baseDirectory, const NumberToNameLookup &numberToNameLookup) const;
SMS(const Settings &settings, const RTComElEvent& event, const QList<RTComElAttachment*> attachments = QList<RTComElAttachment*>());
virtual RTComElEvent * toRTComEvent(const NumberToNameLookup &numberToNameLookup) const;
namespace DBBackends { class iDBBackend; }
class AttachmentCollection;
+class NumberToNameLookup;
class QDateTime;
class QString;
virtual const DBBackends::iDBBackend &DB() const =0;
- virtual void Export(const QString &baseDirectory) const =0;
+ virtual void Export(const QString &baseDirectory, const NumberToNameLookup &numberToNameLookup) const =0;
virtual const QDateTime Timestamp() const =0;
virtual const AttachmentCollection & Attachments() const =0;
QDir().rmpath(CurrentSettings().Directory());
DBBackends::AllBackends allBackends(CurrentSettings());
- EventProcessors::Writer eventWriter(CurrentSettings());
+ NumberToNameLookup lookup; // Prepare the telephone-address book ID lookup.
+ EventProcessors::Writer eventWriter(CurrentSettings(), lookup);
QObject::connect(&eventWriter, SIGNAL(EventProcessed(int,int)), this, SIGNAL(EventProcessed(int,int)));
allBackends.Process(eventWriter);
}