X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=EventTypes%2FSMS.cpp;fp=EventTypes%2FSMS.cpp;h=c067fe6144eaac39d9fe86cc5ef180667a225a54;hb=43c287cf53b85a8a347ae12ce8d938b256357ce3;hp=e147c8d9af353c5b568d6c3d3406eb8a4824d8d3;hpb=1672d85141d3ee1ac7f2996c122f3f9ed974b702;p=qwerkisync diff --git a/EventTypes/SMS.cpp b/EventTypes/SMS.cpp index e147c8d..c067fe6 100644 --- a/EventTypes/SMS.cpp +++ b/EventTypes/SMS.cpp @@ -24,16 +24,10 @@ #include "NumberToNameLookup.h" #include "Settings.h" -#include -#include -#include -#include #include #include #include -#include - #include #include @@ -127,36 +121,96 @@ RTComElEvent * SMS::toRTComEvent(const NumberToNameLookup &numberToNameLookup) c return event; } -void SMS::Export(const QString &baseDirectory, const NumberToNameLookup &numberToNameLookup) const +void SMS::WriteCSVSymbian(QTextStream &stream, const ColumnIndicesByIndexHash &headerIndices, const QChar delimiter, const NumberToNameLookup &numberToNameLookup, SymbianEventLogStrings &strings) const { - // Build the path and ensure it exists... - QString eventFilename(baseDirectory); - eventFilename += Destination() == EventTypes::SMS::SENT ? "/Sent/" : "/Inbox/"; - eventFilename += QString::number(Timestamp().toUTC().date().year()) + "/"; - QDir().mkpath(eventFilename); - - // ...then build the filename and open it. - eventFilename += QString::number(Timestamp().toUTC().toTime_t()) + ".vmg"; - QFile data(eventFilename); - if (data.open(QFile::WriteOnly | QFile::Truncate)) + // 0|05/09/2007 11:25:12 am|1|||||||3|8|0|0||||Unrecognized|| + for(uint columnIndex(0); columnIndex < headerIndices.count(); ++columnIndex) { - 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:@.MA=sip:@" + stream << "Unrecognised"; + } + else + { + // Don't print anything. Makes it obvious which fields we've + // generated. + } + + if(columnIndex < headerIndices.count() - 1) + stream << delimiter; } + + stream << endl; +} + +const QString SMS::PathForVMG() const +{ + QString eventPath("/sms"); + eventPath += Destination() == EventTypes::SMS::SENT ? "/Sent/" : "/Inbox/"; + eventPath += QString::number(Timestamp().toUTC().date().year()) + "/"; + + return eventPath; +} + +void SMS::WriteVMG(QTextStream &stream, const NumberToNameLookup &numberToNameLookup) const +{ + EventParsers::VMGEntities::VMessage writer(CurrentSettings(), NULL, 1.1); + writer.Write(stream, *this, numberToNameLookup); + stream.flush(); } QDebug operator<<(QDebug dbg, SMS& event)