Merge lp:~tiagosh/telephony-service/fix-1517654 into lp:telephony-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Bill Filler
Approved revision: 1149
Merged at revision: 1153
Proposed branch: lp:~tiagosh/telephony-service/fix-1517654
Merge into: lp:telephony-service
Diff against target: 45 lines (+35/-0)
1 file modified
indicator/textchannelobserver.cpp (+35/-0)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/fix-1517654
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+279330@code.launchpad.net

Commit message

Fill notifications with attachments info when no text is received.

Description of the change

Fill notifications with attachments info when no text is received.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'indicator/textchannelobserver.cpp'
2--- indicator/textchannelobserver.cpp 2015-11-19 12:59:24 +0000
3+++ indicator/textchannelobserver.cpp 2015-12-02 18:32:21 +0000
4@@ -404,6 +404,41 @@
5 }
6 }
7
8+ // if messageText is empty, search for attachments
9+ if (messageText.isEmpty()) {
10+ int imageCount = 0;
11+ int videoCount = 0;
12+ int contactCount = 0;
13+ int audioCount = 0;
14+ int attachmentCount = 0;
15+ Q_FOREACH(const Tp::MessagePart &part, messageParts) {
16+ QString contentType = part["content-type"].variant().toString();
17+ if (contentType.startsWith("image/")) {
18+ imageCount++;
19+ } else if (contentType.startsWith("video/")) {
20+ videoCount++;
21+ } else if (contentType.startsWith("audio/")) {
22+ audioCount++;
23+ } else if (contentType.startsWith("text/vcard") ||
24+ contentType.startsWith("text/x-vcard")) {
25+ contactCount++;
26+ }
27+ }
28+ attachmentCount = imageCount + videoCount + contactCount;
29+
30+ if (imageCount > 0 && attachmentCount == imageCount) {
31+ messageText = QString::fromUtf8(C::ngettext("Attachment: %1 image", "Attachments: %1 images", imageCount)).arg(imageCount);
32+ } else if (videoCount > 0 && attachmentCount == videoCount) {
33+ messageText = QString::fromUtf8(C::ngettext("Attachment: %1 video", "Attachments: %1 videos", videoCount)).arg(videoCount);
34+ } else if (contactCount > 0 && attachmentCount == contactCount) {
35+ messageText = QString::fromUtf8(C::ngettext("Attachment: %1 contact", "Attachments: %1 contacts", contactCount)).arg(contactCount);
36+ } else if (audioCount > 0 && attachmentCount == audioCount) {
37+ messageText = QString::fromUtf8(C::ngettext("Attachment: %1 audio clip", "Attachments: %1 audio clips", audioCount)).arg(audioCount);
38+ } else if (attachmentCount > 0) {
39+ messageText = QString::fromUtf8(C::ngettext("Attachment: %1 file", "Attachments: %1 files", attachmentCount)).arg(attachmentCount);
40+ }
41+ }
42+
43 // WORKAROUND: powerd can't decide when to wake up the screen on incoming mms's
44 // (or other telepathy accounts) as the download of the attachments is made by
45 // another daemon, so we wake up the screen here.

Subscribers

People subscribed via source and target branches