Merge lp:~tiagosh/history-service/fix-1417353 into lp:history-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 187
Merged at revision: 188
Proposed branch: lp:~tiagosh/history-service/fix-1417353
Merge into: lp:history-service
Diff against target: 93 lines (+43/-0)
4 files modified
Ubuntu/History/historyeventmodel.cpp (+27/-0)
Ubuntu/History/historyeventmodel.h (+1/-0)
Ubuntu/History/historymodel.h (+8/-0)
src/textevent.cpp (+7/-0)
To merge this branch: bzr merge lp:~tiagosh/history-service/fix-1417353
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+249125@code.launchpad.net

Commit message

- Add support for writing events from qml.
- Iterate over attachments when qdbus_cast fails.

Description of the change

- Add support for writing events from qml.
- Iterate over attachments when qdbus_cast fails.

--Checklist--
Are there any related MPs required for this MP to build/function as expected? Please list.
No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed UI labels, did you update the pot file?
N/A

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve

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-16 13:48:37 +0000
3+++ Ubuntu/History/historyeventmodel.cpp 2015-02-09 20:48:02 +0000
4@@ -223,6 +223,33 @@
5 return History::Manager::instance()->removeEvents(events);
6 }
7
8+bool HistoryEventModel::writeEvents(const QVariantList &eventsProperties)
9+{
10+ History::Events events;
11+ Q_FOREACH(const QVariant &entry, eventsProperties) {
12+ QVariantMap eventProperties = entry.toMap();
13+ History::Event event;
14+ switch (eventProperties[History::FieldType].toInt()) {
15+ case History::EventTypeText:
16+ event = History::TextEvent::fromProperties(eventProperties);
17+ break;
18+ case History::EventTypeVoice:
19+ event = History::VoiceEvent::fromProperties(eventProperties);
20+ break;
21+ }
22+
23+ if (!event.isNull()) {
24+ events << event;
25+ }
26+ }
27+
28+ if (events.isEmpty()) {
29+ return false;
30+ }
31+
32+ return History::Manager::instance()->writeEvents(events);
33+}
34+
35 bool HistoryEventModel::removeEventAttachment(const QString &accountId, const QString &threadId, const QString &eventId, int eventType, const QString &attachmentId)
36 {
37 History::TextEvent textEvent;
38
39=== modified file 'Ubuntu/History/historyeventmodel.h'
40--- Ubuntu/History/historyeventmodel.h 2015-01-16 13:48:37 +0000
41+++ Ubuntu/History/historyeventmodel.h 2015-02-09 20:48:02 +0000
42@@ -62,6 +62,7 @@
43 virtual QHash<int, QByteArray> roleNames() const;
44
45 Q_INVOKABLE bool removeEvents(const QVariantList &eventsProperties);
46+ Q_INVOKABLE bool writeEvents(const QVariantList &eventsProperties);
47 Q_INVOKABLE bool markEventAsRead(const QString &accountId, const QString &threadId, const QString &eventId, int eventType);
48 Q_INVOKABLE bool removeEventAttachment(const QString &accountId, const QString &threadId, const QString &eventId, int eventType, const QString &attachmentId);
49
50
51=== modified file 'Ubuntu/History/historymodel.h'
52--- Ubuntu/History/historymodel.h 2014-09-24 20:10:24 +0000
53+++ Ubuntu/History/historymodel.h 2015-02-09 20:48:02 +0000
54@@ -43,6 +43,7 @@
55 Q_ENUMS(MessageType)
56 Q_ENUMS(MatchFlag)
57 Q_ENUMS(MessageStatus)
58+ Q_ENUMS(AttachmentFlag)
59 Q_ENUMS(Role)
60
61 public:
62@@ -76,6 +77,13 @@
63 MessageStatusPending = History::MessageStatusPending // pending attachment download
64 };
65
66+ enum AttachmentFlag
67+ {
68+ AttachmentDownloaded = History::AttachmentDownloaded,
69+ AttachmentPending = History::AttachmentPending,
70+ AttachmentError = History::AttachmentError
71+ };
72+
73 enum Role {
74 AccountIdRole = Qt::UserRole,
75 ThreadIdRole,
76
77=== modified file 'src/textevent.cpp'
78--- src/textevent.cpp 2014-09-23 12:30:29 +0000
79+++ src/textevent.cpp 2015-02-09 20:48:02 +0000
80@@ -184,6 +184,13 @@
81
82 // read the attachments
83 QList<QVariantMap> attachmentProperties = qdbus_cast<QList<QVariantMap> >(properties[FieldAttachments]);
84+ // dbus_cast fails if the map was generated by a qml app, so we demarshal it by hand
85+ if (attachmentProperties.isEmpty()) {
86+ QVariantList attachmentList = properties[FieldAttachments].toList();
87+ Q_FOREACH(const QVariant &attachmentMap, attachmentList) {
88+ attachmentProperties << attachmentMap.toMap();
89+ }
90+ }
91 TextEventAttachments attachments;
92 Q_FOREACH(const QVariantMap &map, attachmentProperties) {
93 TextEventAttachment attachment = TextEventAttachment::fromProperties(map);

Subscribers

People subscribed via source and target branches