- QTextStream stream(&data);
-
- QTextCodec *oldCodec = stream.codec();
- stream.setAutoDetectUnicode(false);
- stream.setCodec("UTF-16LE");
-
- EventParsers::VMGEntities::VMessage writer(CurrentSettings(), NULL, 1.1);
- writer.Write(stream, *this, numberToNameLookup);
-//stream << "Test";
- //stream.setCodec(oldCodec);
- stream.flush();
- data.close();
-
- utimbuf fileTimes;
- fileTimes.modtime = Timestamp().toUTC().toTime_t();
- utime(eventFilename.toAscii(), &fileTimes);
+ const QString &heading(headerIndices.value(columnIndex));
+ if("etype" == heading.toLower())
+ {
+ stream << "3"; // SMSes are type '3'
+ }
+ else if("etime" == heading.toLower())
+ {
+ stream << Timestamp().toUTC().toString("dd/MM/yyyy h:mm:ss ap");
+ }
+ else if("remote" == heading.toLower())
+ {
+ stream << numberToNameLookup.ContactDetails().value(Tel()).second;
+ }
+ else if("direction" == heading.toLower())
+ {
+ if(Settings::OUTGOING == Destination())
+ {
+ if(!strings.contains("Outgoing"))
+ strings.insert("Outgoing", strings.count());
+ stream << strings.value("Outgoing");
+ }
+ else if (Settings::INCOMING == Destination())
+ {
+ if(!strings.contains("Incoming"))
+ strings.insert("Incoming", strings.count());
+ stream << strings.value("Incoming");
+ }
+ }
+ else if("duration" == heading.toLower())
+ {
+ stream << "0"; // SMSes are always 0
+ }
+ else if("dtype" == heading.toLower())
+ {
+ stream << "-1"; // -1 seems to match KLogDurationNone
+ }
+ else if("status" == heading.toLower())
+ {
+ stream << "0"; // Always '0' for phone calls.
+ }
+ else if("subject" == heading.toLower())
+ {
+ // Subject seems to be ignored - this makes sense, but I
+ // suspect that non-zero values are a bug that I can't duplicate...
+ stream << "0";
+ }
+ else if("number" == heading.toLower())
+ {
+ stream << Tel();
+ }
+ else if("data" == heading.toLower())
+ {
+ // Event-specfic data - but not supported by DBU-SCV tool
+ // Hex editing the DBU suggests there is SIP account info in here...
+ // ...along the lines of:
+ // "VOIP.URL=sip:<remote#>@<remote domain>.MA=sip:<my#>@<my domain>"
+ stream << "Unrecognised";
+ }
+ else
+ {
+ // Don't print anything. Makes it obvious which fields we've
+ // generated.
+ }
+
+ if(columnIndex < headerIndices.count() - 1)
+ stream << delimiter;