Merge lp:~boiko/history-service/rtm-store_remote_participant_id into lp:history-service/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
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 mRoles[TextReadSubjectRole] = "textSubject";
6 mRoles[CallMissedRole] = "callMissed";
7 mRoles[CallDurationRole] = "callDuration";
8+ mRoles[RemoteParticipantRole] = "remoteParticipant";
9 }
10
11 int HistoryEventModel::rowCount(const QModelIndex &parent) const
12@@ -153,6 +154,11 @@
13 result = voiceEvent.duration();
14 }
15 break;
16+ case RemoteParticipantRole:
17+ if (!voiceEvent.isNull()) {
18+ result = voiceEvent.remoteParticipant();
19+ }
20+ break;
21 }
22
23 return result;
24
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 TextMessageAttachmentsRole,
30 CallMissedRole,
31 CallDurationRole,
32+ RemoteParticipantRole,
33 LastEventRole
34 };
35
36
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 event[History::FieldNewEvent] = missed; // only mark as a new (unseen) event if it is a missed call
42 event[History::FieldMissed] = missed;
43 event[History::FieldDuration] = duration;
44+ // FIXME: check what to do when there are more than just one remote participant
45+ event[History::FieldRemoteParticipant] = participants[0];
46 writeEvents(QList<QVariantMap>() << event);
47 }
48
49
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+ALTER TABLE voice_events ADD COLUMN remoteParticipant varchar(255);
55+UPDATE voice_events SET remoteParticipant=(SELECT participantId FROM thread_participants
56+ WHERE thread_participants.accountId = voice_events.accountId
57+ AND thread_participants.threadId = voice_events.threadId
58+ AND thread_participants.type = 1
59+ LIMIT 1);
60
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 History::EventWriteResult result;
66 if (existingEvent.isEmpty()) {
67 // create new
68- query.prepare("INSERT INTO voice_events (accountId, threadId, eventId, senderId, timestamp, newEvent, duration, missed) "
69- "VALUES (:accountId, :threadId, :eventId, :senderId, :timestamp, :newEvent, :duration, :missed)");
70+ query.prepare("INSERT INTO voice_events (accountId, threadId, eventId, senderId, timestamp, newEvent, duration, missed, remoteParticipant) "
71+ "VALUES (:accountId, :threadId, :eventId, :senderId, :timestamp, :newEvent, :duration, :missed, :remoteParticipant)");
72 result = History::EventWriteCreated;
73 } else {
74 // update existing event
75 query.prepare("UPDATE voice_events SET senderId=:senderId, timestamp=:timestamp, newEvent=:newEvent, duration=:duration, "
76- "missed=:missed WHERE accountId=:accountId AND threadId=:threadId AND eventId=:eventId");
77+ "missed=:missed, remoteParticipant=:remoteParticipant "
78+ "WHERE accountId=:accountId AND threadId=:threadId AND eventId=:eventId");
79
80 result = History::EventWriteModified;
81 }
82@@ -400,6 +401,7 @@
83 query.bindValue(":newEvent", event[History::FieldNewEvent]);
84 query.bindValue(":duration", event[History::FieldDuration]);
85 query.bindValue(":missed", event[History::FieldMissed]);
86+ query.bindValue(":remoteParticipant", event[History::FieldRemoteParticipant]);
87
88 if (!query.exec()) {
89 qCritical() << "Failed to save the voice event: Error:" << query.lastError() << query.lastQuery();
90@@ -484,7 +486,7 @@
91 break;
92 case History::EventTypeVoice:
93 table = "voice_events";
94- extraFields << "voice_events.duration" << "voice_events.missed";
95+ extraFields << "voice_events.duration" << "voice_events.missed" << "voice_events.remoteParticipant";
96 break;
97 }
98
99@@ -557,6 +559,7 @@
100 case History::EventTypeVoice:
101 thread[History::FieldMissed] = query.value(10);
102 thread[History::FieldDuration] = query.value(9);
103+ thread[History::FieldRemoteParticipant] = query.value(11);
104 break;
105 }
106 threads << thread;
107@@ -585,7 +588,7 @@
108 case History::EventTypeVoice:
109 participantsField = participantsField.arg("voice_events", QString::number(type));
110 queryText = QString("SELECT accountId, threadId, eventId, senderId, timestamp, newEvent, %1, "
111- "duration, missed FROM voice_events %2 %3").arg(participantsField, modifiedCondition, order);
112+ "duration, missed, remoteParticipant FROM voice_events %2 %3").arg(participantsField, modifiedCondition, order);
113 break;
114 }
115
116@@ -649,6 +652,7 @@
117 case History::EventTypeVoice:
118 event[History::FieldDuration] = query.value(7).toInt();
119 event[History::FieldMissed] = query.value(8);
120+ event[History::FieldRemoteParticipant] = query.value(9);
121 break;
122 }
123
124
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 QTest::addColumn<bool>("newEvent");
130 QTest::addColumn<bool>("missed");
131 QTest::addColumn<QTime>("duration");
132+ QTest::addColumn<QString>("remoteParticipant");
133+ QTest::addColumn<QStringList>("participants");
134
135 QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId"
136 << "testSenderId" << QDateTime::currentDateTime().addDays(-10)
137- << true << true << QTime(0, 0, 0);
138+ << true << true << QTime(0, 0, 0) << QString("remoteParticipant")
139+ << (QStringList() << "testSenderId");
140 QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2"
141 << "testSenderId2" << QDateTime::currentDateTime().addDays(-5)
142- << false << true << QTime(0, 0, 0);
143+ << false << true << QTime(0, 0, 0) << QString("remoteParticipant2")
144+ << (QStringList() << "testSenderId2");
145 QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId"
146 << "testSenderId" << QDateTime::currentDateTime().addDays(-10)
147- << false << false << QTime(1, 2, 3);
148+ << false << false << QTime(1, 2, 3) << QString("remoteParticipant")
149+ << (QStringList() << "testSenderId");
150 }
151
152 void VoiceEventTest::testCreateNewEvent()
153@@ -68,8 +73,10 @@
154 QFETCH(bool, newEvent);
155 QFETCH(bool, missed);
156 QFETCH(QTime, duration);
157+ QFETCH(QString, remoteParticipant);
158+ QFETCH(QStringList, participants);
159 History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent,
160- missed, duration);
161+ missed, duration, remoteParticipant, participants);
162
163 // check that the values are properly set
164 QCOMPARE(event.accountId(), accountId);
165@@ -80,12 +87,14 @@
166 QCOMPARE(event.newEvent(), newEvent);
167 QCOMPARE(event.missed(), missed);
168 QCOMPARE(event.duration(), duration);
169+ QCOMPARE(event.remoteParticipant(), remoteParticipant);
170+ QCOMPARE(event.participants(), participants);
171 }
172
173 void VoiceEventTest::testCastToEventAndBack()
174 {
175 History::VoiceEvent voiceEvent("oneAccountId", "oneThreadId", "oneEventId", "oneSender", QDateTime::currentDateTime(),
176- true, true, QTime(1,2,3));
177+ true, true, QTime(1,2,3), "remoteParticipant", QStringList() << "oneParticipant");
178
179 // test the copy constructor
180 History::Event historyEvent(voiceEvent);
181@@ -112,16 +121,17 @@
182 QTest::addColumn<bool>("newEvent");
183 QTest::addColumn<bool>("missed");
184 QTest::addColumn<QTime>("duration");
185+ QTest::addColumn<QStringList>("participants");
186
187 QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId"
188 << "testSenderId" << QDateTime::currentDateTime().addDays(-10)
189- << true << true << QTime(0, 0, 0);
190+ << true << true << QTime(0, 0, 0) << (QStringList() << "testParticipant");
191 QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2"
192 << "testSenderId2" << QDateTime::currentDateTime().addDays(-5)
193- << false << true << QTime(0, 0, 0);
194+ << false << true << QTime(0, 0, 0) << (QStringList() << "testParticipant2");
195 QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId"
196 << "testSenderId" << QDateTime::currentDateTime().addDays(-10)
197- << false << false << QTime(1, 2, 3);
198+ << false << false << QTime(1, 2, 3) << (QStringList() << "testParticipant");
199 }
200
201 void VoiceEventTest::testFromProperties()
202@@ -134,6 +144,7 @@
203 QFETCH(bool, newEvent);
204 QFETCH(bool, missed);
205 QFETCH(QTime, duration);
206+ QFETCH(QStringList, participants);
207
208 QVariantMap properties;
209 properties[History::FieldAccountId] = accountId;
210@@ -144,6 +155,7 @@
211 properties[History::FieldNewEvent] = newEvent;
212 properties[History::FieldMissed] = missed;
213 properties[History::FieldDuration] = QTime(0,0,0,0).secsTo(duration);
214+ properties[History::FieldParticipants] = participants;
215
216 History::VoiceEvent voiceEvent = History::VoiceEvent::fromProperties(properties);
217 QCOMPARE(voiceEvent.accountId(), accountId);
218@@ -154,6 +166,7 @@
219 QCOMPARE(voiceEvent.newEvent(), newEvent);
220 QCOMPARE(voiceEvent.missed(), missed);
221 QCOMPARE(voiceEvent.duration(), duration);
222+ QCOMPARE(voiceEvent.participants(), participants);
223 }
224
225 void VoiceEventTest::testFromNullProperties()
226@@ -174,16 +187,21 @@
227 QTest::addColumn<bool>("newEvent");
228 QTest::addColumn<bool>("missed");
229 QTest::addColumn<QTime>("duration");
230+ QTest::addColumn<QString>("remoteParticipant");
231+ QTest::addColumn<QStringList>("participants");
232
233 QTest::newRow("unread missed call") << "testAccountId" << "testThreadId" << "testEventId"
234 << "testSenderId" << QDateTime::currentDateTime().addDays(-10)
235- << true << true << QTime(0, 0, 0);
236+ << true << true << QTime(0, 0, 0) << QString("remoteParticipant")
237+ << (QStringList() << "testParticipant");
238 QTest::newRow("missed call") << "testAccountId2" << "testThreadId2" << "testEventId2"
239 << "testSenderId2" << QDateTime::currentDateTime().addDays(-5)
240- << false << true << QTime(0, 0, 0);
241+ << false << true << QTime(0, 0, 0) << QString("remoteParticipant2")
242+ << (QStringList() << "testParticipant2");
243 QTest::newRow("not missed call") << "testAccountId" << "testThreadId" << "testEventId"
244 << "testSenderId" << QDateTime::currentDateTime().addDays(-10)
245- << false << false << QTime(1, 2, 3);
246+ << false << false << QTime(1, 2, 3) << QString("remoteParticipant3")
247+ << (QStringList() << "testParticipant3");
248 }
249
250 void VoiceEventTest::testProperties()
251@@ -196,8 +214,10 @@
252 QFETCH(bool, newEvent);
253 QFETCH(bool, missed);
254 QFETCH(QTime, duration);
255+ QFETCH(QString, remoteParticipant);
256+ QFETCH(QStringList, participants);
257 History::VoiceEvent event(accountId, threadId, eventId, senderId, timestamp, newEvent,
258- missed, duration);
259+ missed, duration, remoteParticipant, participants);
260
261 // check that the values are properly set
262 QVariantMap properties = event.properties();
263@@ -209,6 +229,8 @@
264 QCOMPARE(properties[History::FieldNewEvent].toBool(), newEvent);
265 QCOMPARE(properties[History::FieldMissed].toBool(), missed);
266 QCOMPARE(QTime(0,0).addSecs(properties[History::FieldDuration].toInt()), duration);
267+ QCOMPARE(properties[History::FieldRemoteParticipant].toString(), remoteParticipant);
268+ QCOMPARE(properties[History::FieldParticipants].toStringList(), participants);
269 }
270
271 QTEST_MAIN(VoiceEventTest)
272
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 // voice event fields
278 static const char* FieldMissed = "missed";
279 static const char* FieldDuration = "duration";
280+static const char* FieldRemoteParticipant = "remoteParticipant";
281
282 // sort stuff
283 static const char* FieldSortField = "sortField";
284
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 const QDateTime &theTimestamp,
290 bool theNewEvent,
291 bool theMissed,
292- const QTime &theDuration, const QStringList &theParticipants)
293+ const QTime &theDuration,
294+ const QString &theRemoteParticipant,
295+ const QStringList &theParticipants)
296 : EventPrivate(theAccountId, theThreadId, theEventId, theSender, theTimestamp, theNewEvent, theParticipants),
297- missed(theMissed), duration(theDuration)
298+ missed(theMissed), duration(theDuration), remoteParticipant(theRemoteParticipant)
299 {
300 }
301
302@@ -59,6 +61,7 @@
303
304 map[FieldMissed] = missed;
305 map[FieldDuration] = QTime(0,0,0,0).secsTo(duration);
306+ map[FieldRemoteParticipant] = remoteParticipant;
307
308 return map;
309 }
310@@ -81,8 +84,10 @@
311 const QDateTime &timestamp,
312 bool newEvent,
313 bool missed,
314- const QTime &duration, const QStringList &participants)
315- : Event(*new VoiceEventPrivate(accountId, threadId, eventId, sender, timestamp, newEvent, missed, duration, participants))
316+ const QTime &duration,
317+ const QString &remoteParticipant,
318+ const QStringList &participants)
319+ : Event(*new VoiceEventPrivate(accountId, threadId, eventId, sender, timestamp, newEvent, missed, duration, remoteParticipant, participants))
320 {
321 }
322
323@@ -102,6 +107,12 @@
324 return d->duration;
325 }
326
327+QString VoiceEvent::remoteParticipant() const
328+{
329+ Q_D(const VoiceEvent);
330+ return d->remoteParticipant;
331+}
332+
333 Event VoiceEvent::fromProperties(const QVariantMap &properties)
334 {
335 Event event;
336@@ -117,8 +128,9 @@
337 QStringList participants = properties[FieldParticipants].toStringList();
338 bool missed = properties[FieldMissed].toBool();
339 QTime duration = QTime(0,0,0).addSecs(properties[FieldDuration].toInt());
340+ QString remoteParticipant = properties[FieldRemoteParticipant].toString();
341 event = VoiceEvent(accountId, threadId, eventId, senderId, timestamp, newEvent,
342- missed, duration, participants);
343+ missed, duration, remoteParticipant, participants);
344 return event;
345 }
346
347
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 bool newEvent,
353 bool missed,
354 const QTime &duration = QTime(),
355+ const QString &remoteParticipant = QString::null,
356 const QStringList &participants = QStringList());
357 ~VoiceEvent();
358
359@@ -55,6 +56,12 @@
360 bool missed() const;
361 QTime duration() const;
362
363+ /***
364+ * Returns the ID of the remote participant.
365+ * On incoming calls that's the same as the sender() property
366+ */
367+ QString remoteParticipant() const;
368+
369 static Event fromProperties(const QVariantMap &properties);
370 };
371
372
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 bool theNewEvent,
378 bool theMissed,
379 const QTime &theDuration,
380+ const QString &theRemoteParticipant,
381 const QStringList &theParticipants);
382 ~VoiceEventPrivate();
383 bool missed;
384 QTime duration;
385+ QString remoteParticipant;
386
387 EventType type() const;
388 QVariantMap properties() const;

Subscribers

People subscribed via source and target branches