Merge lp:~boiko/history-service/rtm-store_remote_participant_id into lp:history-service/rtm-14.09
- rtm-store_remote_participant_id
- Merge into rtm-14.09
Proposed by
Gustavo Pichorim Boiko
Status: | Merged |
---|---|
Approved by: | Bill Filler |
Approved revision: | 175 |
Merged at revision: | 175 |
Proposed branch: | lp:~boiko/history-service/rtm-store_remote_participant_id |
Merge into: | lp:history-service/rtm-14.09 |
Diff against target: |
388 lines (+85/-22) 10 files modified
Ubuntu/History/historyeventmodel.cpp (+6/-0) Ubuntu/History/historyeventmodel.h (+1/-0) daemon/historydaemon.cpp (+2/-0) plugins/sqlite/schema/v11.sql (+6/-0) plugins/sqlite/sqlitehistoryplugin.cpp (+9/-5) src/tests/VoiceEventTest.cpp (+34/-12) src/types.h (+1/-0) src/voiceevent.cpp (+17/-5) src/voiceevent.h (+7/-0) src/voiceevent_p.h (+2/-0) |
To merge this branch: | bzr merge lp:~boiko/history-service/rtm-store_remote_participant_id |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+249226@code.launchpad.net |
Commit message
Store the number that was used to call a given voice event.
Description of the change
Store the number that was used to call a given voice event.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Ubuntu/History/historyeventmodel.cpp' | |||
2 | --- Ubuntu/History/historyeventmodel.cpp 2015-01-09 11:59:27 +0000 | |||
3 | +++ Ubuntu/History/historyeventmodel.cpp 2015-02-10 17:31:22 +0000 | |||
4 | @@ -45,6 +45,7 @@ | |||
5 | 45 | mRoles[TextReadSubjectRole] = "textSubject"; | 45 | mRoles[TextReadSubjectRole] = "textSubject"; |
6 | 46 | mRoles[CallMissedRole] = "callMissed"; | 46 | mRoles[CallMissedRole] = "callMissed"; |
7 | 47 | mRoles[CallDurationRole] = "callDuration"; | 47 | mRoles[CallDurationRole] = "callDuration"; |
8 | 48 | mRoles[RemoteParticipantRole] = "remoteParticipant"; | ||
9 | 48 | } | 49 | } |
10 | 49 | 50 | ||
11 | 50 | int HistoryEventModel::rowCount(const QModelIndex &parent) const | 51 | int HistoryEventModel::rowCount(const QModelIndex &parent) const |
12 | @@ -153,6 +154,11 @@ | |||
13 | 153 | result = voiceEvent.duration(); | 154 | result = voiceEvent.duration(); |
14 | 154 | } | 155 | } |
15 | 155 | break; | 156 | break; |
16 | 157 | case RemoteParticipantRole: | ||
17 | 158 | if (!voiceEvent.isNull()) { | ||
18 | 159 | result = voiceEvent.remoteParticipant(); | ||
19 | 160 | } | ||
20 | 161 | break; | ||
21 | 156 | } | 162 | } |
22 | 157 | 163 | ||
23 | 158 | return result; | 164 | return result; |
24 | 159 | 165 | ||
25 | === modified file 'Ubuntu/History/historyeventmodel.h' | |||
26 | --- Ubuntu/History/historyeventmodel.h 2015-01-09 11:59:27 +0000 | |||
27 | +++ Ubuntu/History/historyeventmodel.h 2015-02-10 17:31:22 +0000 | |||
28 | @@ -46,6 +46,7 @@ | |||
29 | 46 | TextMessageAttachmentsRole, | 46 | TextMessageAttachmentsRole, |
30 | 47 | CallMissedRole, | 47 | CallMissedRole, |
31 | 48 | CallDurationRole, | 48 | CallDurationRole, |
32 | 49 | RemoteParticipantRole, | ||
33 | 49 | LastEventRole | 50 | LastEventRole |
34 | 50 | }; | 51 | }; |
35 | 51 | 52 | ||
36 | 52 | 53 | ||
37 | === modified file 'daemon/historydaemon.cpp' | |||
38 | --- daemon/historydaemon.cpp 2014-09-23 12:30:29 +0000 | |||
39 | +++ daemon/historydaemon.cpp 2015-02-10 17:31:22 +0000 | |||
40 | @@ -363,6 +363,8 @@ | |||
41 | 363 | event[History::FieldNewEvent] = missed; // only mark as a new (unseen) event if it is a missed call | 363 | event[History::FieldNewEvent] = missed; // only mark as a new (unseen) event if it is a missed call |
42 | 364 | event[History::FieldMissed] = missed; | 364 | event[History::FieldMissed] = missed; |
43 | 365 | event[History::FieldDuration] = duration; | 365 | event[History::FieldDuration] = duration; |
44 | 366 | // FIXME: check what to do when there are more than just one remote participant | ||
45 | 367 | event[History::FieldRemoteParticipant] = participants[0]; | ||
46 | 366 | writeEvents(QList<QVariantMap>() << event); | 368 | writeEvents(QList<QVariantMap>() << event); |
47 | 367 | } | 369 | } |
48 | 368 | 370 | ||
49 | 369 | 371 | ||
50 | === added file 'plugins/sqlite/schema/v11.sql' | |||
51 | --- plugins/sqlite/schema/v11.sql 1970-01-01 00:00:00 +0000 | |||
52 | +++ plugins/sqlite/schema/v11.sql 2015-02-10 17:31:22 +0000 | |||
53 | @@ -0,0 +1,6 @@ | |||
54 | 1 | ALTER TABLE voice_events ADD COLUMN remoteParticipant varchar(255); | ||
55 | 2 | UPDATE voice_events SET remoteParticipant=(SELECT participantId FROM thread_participants | ||
56 | 3 | WHERE thread_participants.accountId = voice_events.accountId | ||
57 | 4 | AND thread_participants.threadId = voice_events.threadId | ||
58 | 5 | AND thread_participants.type = 1 | ||
59 | 6 | LIMIT 1); | ||
60 | 0 | 7 | ||
61 | === modified file 'plugins/sqlite/sqlitehistoryplugin.cpp' | |||
62 | --- plugins/sqlite/sqlitehistoryplugin.cpp 2015-01-28 23:15:01 +0000 | |||
63 | +++ plugins/sqlite/sqlitehistoryplugin.cpp 2015-02-10 17:31:22 +0000 | |||
64 | @@ -381,13 +381,14 @@ | |||
65 | 381 | History::EventWriteResult result; | 381 | History::EventWriteResult result; |
66 | 382 | if (existingEvent.isEmpty()) { | 382 | if (existingEvent.isEmpty()) { |
67 | 383 | // create new | 383 | // create new |
70 | 384 | query.prepare("INSERT INTO voice_events (accountId, threadId, eventId, senderId, timestamp, newEvent, duration, missed) " | 384 | query.prepare("INSERT INTO voice_events (accountId, threadId, eventId, senderId, timestamp, newEvent, duration, missed, remoteParticipant) " |
71 | 385 | "VALUES (:accountId, :threadId, :eventId, :senderId, :timestamp, :newEvent, :duration, :missed)"); | 385 | "VALUES (:accountId, :threadId, :eventId, :senderId, :timestamp, :newEvent, :duration, :missed, :remoteParticipant)"); |
72 | 386 | result = History::EventWriteCreated; | 386 | result = History::EventWriteCreated; |
73 | 387 | } else { | 387 | } else { |
74 | 388 | // update existing event | 388 | // update existing event |
75 | 389 | query.prepare("UPDATE voice_events SET senderId=:senderId, timestamp=:timestamp, newEvent=:newEvent, duration=:duration, " | 389 | query.prepare("UPDATE voice_events SET senderId=:senderId, timestamp=:timestamp, newEvent=:newEvent, duration=:duration, " |
77 | 390 | "missed=:missed WHERE accountId=:accountId AND threadId=:threadId AND eventId=:eventId"); | 390 | "missed=:missed, remoteParticipant=:remoteParticipant " |
78 | 391 | "WHERE accountId=:accountId AND threadId=:threadId AND eventId=:eventId"); | ||
79 | 391 | 392 | ||
80 | 392 | result = History::EventWriteModified; | 393 | result = History::EventWriteModified; |
81 | 393 | } | 394 | } |
82 | @@ -400,6 +401,7 @@ | |||
83 | 400 | query.bindValue(":newEvent", event[History::FieldNewEvent]); | 401 | query.bindValue(":newEvent", event[History::FieldNewEvent]); |
84 | 401 | query.bindValue(":duration", event[History::FieldDuration]); | 402 | query.bindValue(":duration", event[History::FieldDuration]); |
85 | 402 | query.bindValue(":missed", event[History::FieldMissed]); | 403 | query.bindValue(":missed", event[History::FieldMissed]); |
86 | 404 | query.bindValue(":remoteParticipant", event[History::FieldRemoteParticipant]); | ||
87 | 403 | 405 | ||
88 | 404 | if (!query.exec()) { | 406 | if (!query.exec()) { |
89 | 405 | qCritical() << "Failed to save the voice event: Error:" << query.lastError() << query.lastQuery(); | 407 | qCritical() << "Failed to save the voice event: Error:" << query.lastError() << query.lastQuery(); |
90 | @@ -484,7 +486,7 @@ | |||
91 | 484 | break; | 486 | break; |
92 | 485 | case History::EventTypeVoice: | 487 | case History::EventTypeVoice: |
93 | 486 | table = "voice_events"; | 488 | table = "voice_events"; |
95 | 487 | extraFields << "voice_events.duration" << "voice_events.missed"; | 489 | extraFields << "voice_events.duration" << "voice_events.missed" << "voice_events.remoteParticipant"; |
96 | 488 | break; | 490 | break; |
97 | 489 | } | 491 | } |
98 | 490 | 492 | ||
99 | @@ -557,6 +559,7 @@ | |||
100 | 557 | case History::EventTypeVoice: | 559 | case History::EventTypeVoice: |
101 | 558 | thread[History::FieldMissed] = query.value(10); | 560 | thread[History::FieldMissed] = query.value(10); |
102 | 559 | thread[History::FieldDuration] = query.value(9); | 561 | thread[History::FieldDuration] = query.value(9); |
103 | 562 | thread[History::FieldRemoteParticipant] = query.value(11); | ||
104 | 560 | break; | 563 | break; |
105 | 561 | } | 564 | } |
106 | 562 | threads << thread; | 565 | threads << thread; |
107 | @@ -585,7 +588,7 @@ | |||
108 | 585 | case History::EventTypeVoice: | 588 | case History::EventTypeVoice: |
109 | 586 | participantsField = participantsField.arg("voice_events", QString::number(type)); | 589 | participantsField = participantsField.arg("voice_events", QString::number(type)); |
110 | 587 | queryText = QString("SELECT accountId, threadId, eventId, senderId, timestamp, newEvent, %1, " | 590 | queryText = QString("SELECT accountId, threadId, eventId, senderId, timestamp, newEvent, %1, " |
112 | 588 | "duration, missed FROM voice_events %2 %3").arg(participantsField, modifiedCondition, order); | 591 | "duration, missed, remoteParticipant FROM voice_events %2 %3").arg(participantsField, modifiedCondition, order); |
113 | 589 | break; | 592 | break; |
114 | 590 | } | 593 | } |
115 | 591 | 594 | ||
116 | @@ -649,6 +652,7 @@ | |||
117 | 649 | case History::EventTypeVoice: | 652 | case History::EventTypeVoice: |
118 | 650 | event[History::FieldDuration] = query.value(7).toInt(); | 653 | event[History::FieldDuration] = query.value(7).toInt(); |
119 | 651 | event[History::FieldMissed] = query.value(8); | 654 | event[History::FieldMissed] = query.value(8); |
120 | 655 | event[History::FieldRemoteParticipant] = query.value(9); | ||
121 | 652 | break; | 656 | break; |
122 | 653 | } | 657 | } |
123 | 654 | 658 | ||
124 | 655 | 659 | ||
125 | === modified file 'src/tests/VoiceEventTest.cpp' | |||
126 | --- src/tests/VoiceEventTest.cpp 2014-09-25 18:27:15 +0000 | |||
127 | +++ src/tests/VoiceEventTest.cpp 2015-02-10 17:31:22 +0000 | |||
128 | @@ -46,16 +46,21 @@ | |||
129 | 46 | QTest::addColumn<bool>("newEvent"); | 46 | QTest::addColumn<bool>("newEvent"); |
130 | 47 | QTest::addColumn<bool>("missed"); | 47 | QTest::addColumn<bool>("missed"); |
131 | 48 | QTest::addColumn<QTime>("duration"); | 48 | QTest::addColumn<QTime>("duration"); |
132 | 49 | QTest::addColumn<QString>("remoteParticipant"); | ||
133 | 50 | QTest::addColumn<QStringList>("participants"); | ||
134 | 49 | 51 | ||
135 | 50 | QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId" | 52 | QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId" |
136 | 51 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) | 53 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) |
138 | 52 | << true << true << QTime(0, 0, 0); | 54 | << true << true << QTime(0, 0, 0) << QString("remoteParticipant") |
139 | 55 | << (QStringList() << "testSenderId"); | ||
140 | 53 | QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2" | 56 | QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2" |
141 | 54 | << "testSenderId2" << QDateTime::currentDateTime().addDays(-5) | 57 | << "testSenderId2" << QDateTime::currentDateTime().addDays(-5) |
143 | 55 | << false << true << QTime(0, 0, 0); | 58 | << false << true << QTime(0, 0, 0) << QString("remoteParticipant2") |
144 | 59 | << (QStringList() << "testSenderId2"); | ||
145 | 56 | QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId" | 60 | QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId" |
146 | 57 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) | 61 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) |
148 | 58 | << false << false << QTime(1, 2, 3); | 62 | << false << false << QTime(1, 2, 3) << QString("remoteParticipant") |
149 | 63 | << (QStringList() << "testSenderId"); | ||
150 | 59 | } | 64 | } |
151 | 60 | 65 | ||
152 | 61 | void VoiceEventTest::testCreateNewEvent() | 66 | void VoiceEventTest::testCreateNewEvent() |
153 | @@ -68,8 +73,10 @@ | |||
154 | 68 | QFETCH(bool, newEvent); | 73 | QFETCH(bool, newEvent); |
155 | 69 | QFETCH(bool, missed); | 74 | QFETCH(bool, missed); |
156 | 70 | QFETCH(QTime, duration); | 75 | QFETCH(QTime, duration); |
157 | 76 | QFETCH(QString, remoteParticipant); | ||
158 | 77 | QFETCH(QStringList, participants); | ||
159 | 71 | History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent, | 78 | History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent, |
161 | 72 | missed, duration); | 79 | missed, duration, remoteParticipant, participants); |
162 | 73 | 80 | ||
163 | 74 | // check that the values are properly set | 81 | // check that the values are properly set |
164 | 75 | QCOMPARE(event.accountId(), accountId); | 82 | QCOMPARE(event.accountId(), accountId); |
165 | @@ -80,12 +87,14 @@ | |||
166 | 80 | QCOMPARE(event.newEvent(), newEvent); | 87 | QCOMPARE(event.newEvent(), newEvent); |
167 | 81 | QCOMPARE(event.missed(), missed); | 88 | QCOMPARE(event.missed(), missed); |
168 | 82 | QCOMPARE(event.duration(), duration); | 89 | QCOMPARE(event.duration(), duration); |
169 | 90 | QCOMPARE(event.remoteParticipant(), remoteParticipant); | ||
170 | 91 | QCOMPARE(event.participants(), participants); | ||
171 | 83 | } | 92 | } |
172 | 84 | 93 | ||
173 | 85 | void VoiceEventTest::testCastToEventAndBack() | 94 | void VoiceEventTest::testCastToEventAndBack() |
174 | 86 | { | 95 | { |
175 | 87 | History::VoiceEvent voiceEvent("oneAccountId", "oneThreadId", "oneEventId", "oneSender", QDateTime::currentDateTime(), | 96 | History::VoiceEvent voiceEvent("oneAccountId", "oneThreadId", "oneEventId", "oneSender", QDateTime::currentDateTime(), |
177 | 88 | true, true, QTime(1,2,3)); | 97 | true, true, QTime(1,2,3), "remoteParticipant", QStringList() << "oneParticipant"); |
178 | 89 | 98 | ||
179 | 90 | // test the copy constructor | 99 | // test the copy constructor |
180 | 91 | History::Event historyEvent(voiceEvent); | 100 | History::Event historyEvent(voiceEvent); |
181 | @@ -112,16 +121,17 @@ | |||
182 | 112 | QTest::addColumn<bool>("newEvent"); | 121 | QTest::addColumn<bool>("newEvent"); |
183 | 113 | QTest::addColumn<bool>("missed"); | 122 | QTest::addColumn<bool>("missed"); |
184 | 114 | QTest::addColumn<QTime>("duration"); | 123 | QTest::addColumn<QTime>("duration"); |
185 | 124 | QTest::addColumn<QStringList>("participants"); | ||
186 | 115 | 125 | ||
187 | 116 | QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId" | 126 | QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId" |
188 | 117 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) | 127 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) |
190 | 118 | << true << true << QTime(0, 0, 0); | 128 | << true << true << QTime(0, 0, 0) << (QStringList() << "testParticipant"); |
191 | 119 | QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2" | 129 | QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2" |
192 | 120 | << "testSenderId2" << QDateTime::currentDateTime().addDays(-5) | 130 | << "testSenderId2" << QDateTime::currentDateTime().addDays(-5) |
194 | 121 | << false << true << QTime(0, 0, 0); | 131 | << false << true << QTime(0, 0, 0) << (QStringList() << "testParticipant2"); |
195 | 122 | QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId" | 132 | QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId" |
196 | 123 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) | 133 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) |
198 | 124 | << false << false << QTime(1, 2, 3); | 134 | << false << false << QTime(1, 2, 3) << (QStringList() << "testParticipant"); |
199 | 125 | } | 135 | } |
200 | 126 | 136 | ||
201 | 127 | void VoiceEventTest::testFromProperties() | 137 | void VoiceEventTest::testFromProperties() |
202 | @@ -134,6 +144,7 @@ | |||
203 | 134 | QFETCH(bool, newEvent); | 144 | QFETCH(bool, newEvent); |
204 | 135 | QFETCH(bool, missed); | 145 | QFETCH(bool, missed); |
205 | 136 | QFETCH(QTime, duration); | 146 | QFETCH(QTime, duration); |
206 | 147 | QFETCH(QStringList, participants); | ||
207 | 137 | 148 | ||
208 | 138 | QVariantMap properties; | 149 | QVariantMap properties; |
209 | 139 | properties[History::FieldAccountId] = accountId; | 150 | properties[History::FieldAccountId] = accountId; |
210 | @@ -144,6 +155,7 @@ | |||
211 | 144 | properties[History::FieldNewEvent] = newEvent; | 155 | properties[History::FieldNewEvent] = newEvent; |
212 | 145 | properties[History::FieldMissed] = missed; | 156 | properties[History::FieldMissed] = missed; |
213 | 146 | properties[History::FieldDuration] = QTime(0,0,0,0).secsTo(duration); | 157 | properties[History::FieldDuration] = QTime(0,0,0,0).secsTo(duration); |
214 | 158 | properties[History::FieldParticipants] = participants; | ||
215 | 147 | 159 | ||
216 | 148 | History::VoiceEvent voiceEvent = History::VoiceEvent::fromProperties(properties); | 160 | History::VoiceEvent voiceEvent = History::VoiceEvent::fromProperties(properties); |
217 | 149 | QCOMPARE(voiceEvent.accountId(), accountId); | 161 | QCOMPARE(voiceEvent.accountId(), accountId); |
218 | @@ -154,6 +166,7 @@ | |||
219 | 154 | QCOMPARE(voiceEvent.newEvent(), newEvent); | 166 | QCOMPARE(voiceEvent.newEvent(), newEvent); |
220 | 155 | QCOMPARE(voiceEvent.missed(), missed); | 167 | QCOMPARE(voiceEvent.missed(), missed); |
221 | 156 | QCOMPARE(voiceEvent.duration(), duration); | 168 | QCOMPARE(voiceEvent.duration(), duration); |
222 | 169 | QCOMPARE(voiceEvent.participants(), participants); | ||
223 | 157 | } | 170 | } |
224 | 158 | 171 | ||
225 | 159 | void VoiceEventTest::testFromNullProperties() | 172 | void VoiceEventTest::testFromNullProperties() |
226 | @@ -174,16 +187,21 @@ | |||
227 | 174 | QTest::addColumn<bool>("newEvent"); | 187 | QTest::addColumn<bool>("newEvent"); |
228 | 175 | QTest::addColumn<bool>("missed"); | 188 | QTest::addColumn<bool>("missed"); |
229 | 176 | QTest::addColumn<QTime>("duration"); | 189 | QTest::addColumn<QTime>("duration"); |
230 | 190 | QTest::addColumn<QString>("remoteParticipant"); | ||
231 | 191 | QTest::addColumn<QStringList>("participants"); | ||
232 | 177 | 192 | ||
233 | 178 | QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId" | 193 | QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId" |
234 | 179 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) | 194 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) |
236 | 180 | << true << true << QTime(0, 0, 0); | 195 | << true << true << QTime(0, 0, 0) << QString("remoteParticipant") |
237 | 196 | << (QStringList() << "testParticipant"); | ||
238 | 181 | QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2" | 197 | QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2" |
239 | 182 | << "testSenderId2" << QDateTime::currentDateTime().addDays(-5) | 198 | << "testSenderId2" << QDateTime::currentDateTime().addDays(-5) |
241 | 183 | << false << true << QTime(0, 0, 0); | 199 | << false << true << QTime(0, 0, 0) << QString("remoteParticipant2") |
242 | 200 | << (QStringList() << "testParticipant2"); | ||
243 | 184 | QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId" | 201 | QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId" |
244 | 185 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) | 202 | << "testSenderId" << QDateTime::currentDateTime().addDays(-10) |
246 | 186 | << false << false << QTime(1, 2, 3); | 203 | << false << false << QTime(1, 2, 3) << QString("remoteParticipant3") |
247 | 204 | << (QStringList() << "testParticipant3"); | ||
248 | 187 | } | 205 | } |
249 | 188 | 206 | ||
250 | 189 | void VoiceEventTest::testProperties() | 207 | void VoiceEventTest::testProperties() |
251 | @@ -196,8 +214,10 @@ | |||
252 | 196 | QFETCH(bool, newEvent); | 214 | QFETCH(bool, newEvent); |
253 | 197 | QFETCH(bool, missed); | 215 | QFETCH(bool, missed); |
254 | 198 | QFETCH(QTime, duration); | 216 | QFETCH(QTime, duration); |
255 | 217 | QFETCH(QString, remoteParticipant); | ||
256 | 218 | QFETCH(QStringList, participants); | ||
257 | 199 | History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent, | 219 | History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent, |
259 | 200 | missed, duration); | 220 | missed, duration, remoteParticipant, participants); |
260 | 201 | 221 | ||
261 | 202 | // check that the values are properly set | 222 | // check that the values are properly set |
262 | 203 | QVariantMap properties = event.properties(); | 223 | QVariantMap properties = event.properties(); |
263 | @@ -209,6 +229,8 @@ | |||
264 | 209 | QCOMPARE(properties[History::FieldNewEvent].toBool(), newEvent); | 229 | QCOMPARE(properties[History::FieldNewEvent].toBool(), newEvent); |
265 | 210 | QCOMPARE(properties[History::FieldMissed].toBool(), missed); | 230 | QCOMPARE(properties[History::FieldMissed].toBool(), missed); |
266 | 211 | QCOMPARE(QTime(0,0).addSecs(properties[History::FieldDuration].toInt()), duration); | 231 | QCOMPARE(QTime(0,0).addSecs(properties[History::FieldDuration].toInt()), duration); |
267 | 232 | QCOMPARE(properties[History::FieldRemoteParticipant].toString(), remoteParticipant); | ||
268 | 233 | QCOMPARE(properties[History::FieldParticipants].toStringList(), participants); | ||
269 | 212 | } | 234 | } |
270 | 213 | 235 | ||
271 | 214 | QTEST_MAIN(VoiceEventTest) | 236 | QTEST_MAIN(VoiceEventTest) |
272 | 215 | 237 | ||
273 | === modified file 'src/types.h' | |||
274 | --- src/types.h 2014-09-22 13:27:29 +0000 | |||
275 | +++ src/types.h 2015-02-10 17:31:22 +0000 | |||
276 | @@ -132,6 +132,7 @@ | |||
277 | 132 | // voice event fields | 132 | // voice event fields |
278 | 133 | static const char* FieldMissed = "missed"; | 133 | static const char* FieldMissed = "missed"; |
279 | 134 | static const char* FieldDuration = "duration"; | 134 | static const char* FieldDuration = "duration"; |
280 | 135 | static const char* FieldRemoteParticipant = "remoteParticipant"; | ||
281 | 135 | 136 | ||
282 | 136 | // sort stuff | 137 | // sort stuff |
283 | 137 | static const char* FieldSortField = "sortField"; | 138 | static const char* FieldSortField = "sortField"; |
284 | 138 | 139 | ||
285 | === modified file 'src/voiceevent.cpp' | |||
286 | --- src/voiceevent.cpp 2013-10-08 21:06:20 +0000 | |||
287 | +++ src/voiceevent.cpp 2015-02-10 17:31:22 +0000 | |||
288 | @@ -38,9 +38,11 @@ | |||
289 | 38 | const QDateTime &theTimestamp, | 38 | const QDateTime &theTimestamp, |
290 | 39 | bool theNewEvent, | 39 | bool theNewEvent, |
291 | 40 | bool theMissed, | 40 | bool theMissed, |
293 | 41 | const QTime &theDuration, const QStringList &theParticipants) | 41 | const QTime &theDuration, |
294 | 42 | const QString &theRemoteParticipant, | ||
295 | 43 | const QStringList &theParticipants) | ||
296 | 42 | : EventPrivate(theAccountId, theThreadId, theEventId, theSender, theTimestamp, theNewEvent, theParticipants), | 44 | : EventPrivate(theAccountId, theThreadId, theEventId, theSender, theTimestamp, theNewEvent, theParticipants), |
298 | 43 | missed(theMissed), duration(theDuration) | 45 | missed(theMissed), duration(theDuration), remoteParticipant(theRemoteParticipant) |
299 | 44 | { | 46 | { |
300 | 45 | } | 47 | } |
301 | 46 | 48 | ||
302 | @@ -59,6 +61,7 @@ | |||
303 | 59 | 61 | ||
304 | 60 | map[FieldMissed] = missed; | 62 | map[FieldMissed] = missed; |
305 | 61 | map[FieldDuration] = QTime(0,0,0,0).secsTo(duration); | 63 | map[FieldDuration] = QTime(0,0,0,0).secsTo(duration); |
306 | 64 | map[FieldRemoteParticipant] = remoteParticipant; | ||
307 | 62 | 65 | ||
308 | 63 | return map; | 66 | return map; |
309 | 64 | } | 67 | } |
310 | @@ -81,8 +84,10 @@ | |||
311 | 81 | const QDateTime ×tamp, | 84 | const QDateTime ×tamp, |
312 | 82 | bool newEvent, | 85 | bool newEvent, |
313 | 83 | bool missed, | 86 | bool missed, |
316 | 84 | const QTime &duration, const QStringList &participants) | 87 | const QTime &duration, |
317 | 85 | : Event(*new VoiceEventPrivate(accountId, threadId, eventId, sender, timestamp, newEvent, missed, duration, participants)) | 88 | const QString &remoteParticipant, |
318 | 89 | const QStringList &participants) | ||
319 | 90 | : Event(*new VoiceEventPrivate(accountId, threadId, eventId, sender, timestamp, newEvent, missed, duration, remoteParticipant, participants)) | ||
320 | 86 | { | 91 | { |
321 | 87 | } | 92 | } |
322 | 88 | 93 | ||
323 | @@ -102,6 +107,12 @@ | |||
324 | 102 | return d->duration; | 107 | return d->duration; |
325 | 103 | } | 108 | } |
326 | 104 | 109 | ||
327 | 110 | QString VoiceEvent::remoteParticipant() const | ||
328 | 111 | { | ||
329 | 112 | Q_D(const VoiceEvent); | ||
330 | 113 | return d->remoteParticipant; | ||
331 | 114 | } | ||
332 | 115 | |||
333 | 105 | Event VoiceEvent::fromProperties(const QVariantMap &properties) | 116 | Event VoiceEvent::fromProperties(const QVariantMap &properties) |
334 | 106 | { | 117 | { |
335 | 107 | Event event; | 118 | Event event; |
336 | @@ -117,8 +128,9 @@ | |||
337 | 117 | QStringList participants = properties[FieldParticipants].toStringList(); | 128 | QStringList participants = properties[FieldParticipants].toStringList(); |
338 | 118 | bool missed = properties[FieldMissed].toBool(); | 129 | bool missed = properties[FieldMissed].toBool(); |
339 | 119 | QTime duration = QTime(0,0,0).addSecs(properties[FieldDuration].toInt()); | 130 | QTime duration = QTime(0,0,0).addSecs(properties[FieldDuration].toInt()); |
340 | 131 | QString remoteParticipant = properties[FieldRemoteParticipant].toString(); | ||
341 | 120 | event = VoiceEvent(accountId, threadId, eventId, senderId, timestamp, newEvent, | 132 | event = VoiceEvent(accountId, threadId, eventId, senderId, timestamp, newEvent, |
343 | 121 | missed, duration, participants); | 133 | missed, duration, remoteParticipant, participants); |
344 | 122 | return event; | 134 | return event; |
345 | 123 | } | 135 | } |
346 | 124 | 136 | ||
347 | 125 | 137 | ||
348 | === modified file 'src/voiceevent.h' | |||
349 | --- src/voiceevent.h 2013-09-26 21:06:50 +0000 | |||
350 | +++ src/voiceevent.h 2015-02-10 17:31:22 +0000 | |||
351 | @@ -45,6 +45,7 @@ | |||
352 | 45 | bool newEvent, | 45 | bool newEvent, |
353 | 46 | bool missed, | 46 | bool missed, |
354 | 47 | const QTime &duration = QTime(), | 47 | const QTime &duration = QTime(), |
355 | 48 | const QString &remoteParticipant = QString::null, | ||
356 | 48 | const QStringList &participants = QStringList()); | 49 | const QStringList &participants = QStringList()); |
357 | 49 | ~VoiceEvent(); | 50 | ~VoiceEvent(); |
358 | 50 | 51 | ||
359 | @@ -55,6 +56,12 @@ | |||
360 | 55 | bool missed() const; | 56 | bool missed() const; |
361 | 56 | QTime duration() const; | 57 | QTime duration() const; |
362 | 57 | 58 | ||
363 | 59 | /*** | ||
364 | 60 | * Returns the ID of the remote participant. | ||
365 | 61 | * On incoming calls that's the same as the sender() property | ||
366 | 62 | */ | ||
367 | 63 | QString remoteParticipant() const; | ||
368 | 64 | |||
369 | 58 | static Event fromProperties(const QVariantMap &properties); | 65 | static Event fromProperties(const QVariantMap &properties); |
370 | 59 | }; | 66 | }; |
371 | 60 | 67 | ||
372 | 61 | 68 | ||
373 | === modified file 'src/voiceevent_p.h' | |||
374 | --- src/voiceevent_p.h 2013-09-26 21:06:50 +0000 | |||
375 | +++ src/voiceevent_p.h 2015-02-10 17:31:22 +0000 | |||
376 | @@ -39,10 +39,12 @@ | |||
377 | 39 | bool theNewEvent, | 39 | bool theNewEvent, |
378 | 40 | bool theMissed, | 40 | bool theMissed, |
379 | 41 | const QTime &theDuration, | 41 | const QTime &theDuration, |
380 | 42 | const QString &theRemoteParticipant, | ||
381 | 42 | const QStringList &theParticipants); | 43 | const QStringList &theParticipants); |
382 | 43 | ~VoiceEventPrivate(); | 44 | ~VoiceEventPrivate(); |
383 | 44 | bool missed; | 45 | bool missed; |
384 | 45 | QTime duration; | 46 | QTime duration; |
385 | 47 | QString remoteParticipant; | ||
386 | 46 | 48 | ||
387 | 47 | EventType type() const; | 49 | EventType type() const; |
388 | 48 | QVariantMap properties() const; | 50 | QVariantMap properties() const; |