Added missed call property to phone calls.
[qwerkisync] / EventTypes / PhoneCall.cpp
index bfed790..df8387a 100644 (file)
@@ -61,12 +61,12 @@ PhoneCall::~PhoneCall()
 PhoneCall::PhoneCall(const Settings &settings, const RTComElEvent &event, const QList<RTComElAttachment*> attachments) :
        m_Settings(settings)
 {
-       setDestination(event.fld_outgoing ? OUTGOING : INCOMING);
-       setTimestamp(QDateTime::fromTime_t(event.fld_start_time).toUTC());
-       setDurationInSeconds(QDateTime::fromTime_t(event.fld_start_time).toUTC().secsTo(QDateTime::fromTime_t(event.fld_end_time).toUTC()));
-       setTel(event.fld_remote_uid);
+       Destination(event.fld_outgoing ? Settings::OUTGOING : Settings::INCOMING);
+       Timestamp(QDateTime::fromTime_t(event.fld_start_time).toUTC());
+       DurationInSeconds(QDateTime::fromTime_t(event.fld_start_time).toUTC().secsTo(QDateTime::fromTime_t(event.fld_end_time).toUTC()));
+       Tel(event.fld_remote_uid);
        if(Tel().indexOf("0") == 0)
-               setTel(QString(Tel()).replace(QRegExp("^0"), "+44"));
+               Tel(QString(Tel()).replace(QRegExp("^0"), "+44"));
 
        if(attachments.count() > 0)
                foreach(RTComElAttachment *attachment, attachments)
@@ -75,12 +75,12 @@ PhoneCall::PhoneCall(const Settings &settings, const RTComElEvent &event, const
        qDebug() << "Created new Phone Call from RtCom:\n" << *this;
 }
 
-PhoneCall::PhoneCall(const Settings &settings, const eDestination destination, const QDateTime &timestamp, const QString &tel, int durationInSeconds, const AttachmentCollection &attachments) :
+PhoneCall::PhoneCall(const Settings &settings, const Settings::eDirection destination, const QDateTime &timestamp, const QString &tel, const int durationInSeconds, const bool isMissedCall, const AttachmentCollection &attachments) :
        m_Settings(settings), m_Destination(destination), m_Timestamp(timestamp), m_Tel(tel),
-       m_DurationInSeconds(durationInSeconds), m_Attachments(attachments)
+       m_DurationInSeconds(durationInSeconds), m_IsMissedCall(isMissedCall), m_Attachments(attachments)
 {
        if(Tel().indexOf("0") == 0)
-               setTel(QString(Tel()).replace(QRegExp("^0"), "+44"));
+               Tel(QString(Tel()).replace(QRegExp("^0"), "+44"));
 
        // TODO: Copy attachments.
 //     if(attachments.count() > 0)
@@ -123,13 +123,15 @@ RTComElEvent * PhoneCall::toRTComEvent(const NumberToNameLookup &numberToNameLoo
        RTCOM_EL_EVENT_SET_FIELD (event, service, g_strdup("RTCOM_EL_SERVICE_CALL"));
        if(voiceMailList.contains(Tel()))
                RTCOM_EL_EVENT_SET_FIELD (event, event_type, g_strdup("RTCOM_EL_EVENTTYPE_CALL_VOICEMAIL"));
+       else if(IsMissedCall())
+               RTCOM_EL_EVENT_SET_FIELD (event, event_type, g_strdup("RTCOM_EL_EVENTTYPE_CALL_MISSED"));
        else
                RTCOM_EL_EVENT_SET_FIELD (event, event_type, g_strdup("RTCOM_EL_EVENTTYPE_CALL"));
        RTCOM_EL_EVENT_SET_FIELD (event, start_time, Timestamp().toUTC().toTime_t());
        RTCOM_EL_EVENT_SET_FIELD (event, end_time, Timestamp().addSecs(DurationInSeconds()).toUTC().toTime_t());
        RTCOM_EL_EVENT_SET_FIELD (event, storage_time, Timestamp().addSecs(DurationInSeconds()).toUTC().toTime_t());
        //RTCOM_EL_EVENT_SET_FIELD (event, is_read, 0);
-       RTCOM_EL_EVENT_SET_FIELD (event, outgoing, Destination() == PhoneCall::OUTGOING ? 1 : 0);
+       RTCOM_EL_EVENT_SET_FIELD (event, outgoing, Destination() == Settings::OUTGOING ? 1 : 0);
        //if(local_uid) // Voicemail local_uid transform needed here
        RTCOM_EL_EVENT_SET_FIELD (event, local_uid, g_strdup("ring/tel/ring"));
        //RTCOM_EL_EVENT_SET_FIELD (&event, local_name, g_strdup("<SelfHandle>"));
@@ -141,7 +143,7 @@ RTComElEvent * PhoneCall::toRTComEvent(const NumberToNameLookup &numberToNameLoo
        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);
@@ -175,7 +177,8 @@ void PhoneCall::Export(const QString &baseDirectory) const
 
 QDebug operator<<(QDebug dbg, PhoneCall& event)
 {
-       dbg.nospace() << "\tDirection:\t\t" << (event.Destination() == PhoneCall::OUTGOING ? "Made" : "Recieved") << "\n";
+       dbg.nospace() << "\tHash:\t\t" << event.HashCode() << "\n";
+       dbg.nospace() << "\tDirection:\t\t" << (event.Destination() == Settings::OUTGOING ? "Made" : "Recieved") << "\n";
        dbg.nospace() << "\tTimestamp:\t" << event.Timestamp().toUTC() << "\n";
        dbg.nospace() << "\tDuration:\t\t" << event.DurationInSeconds() << " seconds\n";
        dbg.nospace() << "\tRemote-Tel:\t" << event.Tel() << "\n";