Merge lp:~boiko/telephony-service/history_messaging_menu into lp:telephony-service

Proposed by Gustavo Pichorim Boiko
Status: Work in progress
Proposed branch: lp:~boiko/telephony-service/history_messaging_menu
Merge into: lp:telephony-service
Diff against target: 609 lines (+307/-130)
9 files modified
CMakeLists.txt (+1/-0)
indicator/CMakeLists.txt (+4/-1)
indicator/historyloader.cpp (+207/-0)
indicator/historyloader.h (+57/-0)
indicator/main.cpp (+12/-5)
indicator/messagingmenu.h (+1/-0)
indicator/notifications.cpp (+17/-99)
indicator/notifications.h (+7/-23)
libtelephonyservice/chatmanager.h (+1/-2)
To merge this branch: bzr merge lp:~boiko/telephony-service/history_messaging_menu
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+193976@code.launchpad.net

Commit message

Use the history service to populate the messaging menu.

Description of the change

Use the history service to populate the messaging menu.

To post a comment you must log in.
760. By Gustavo Pichorim Boiko

Merge latest changes from trunk.

Unmerged revisions

760. By Gustavo Pichorim Boiko

Merge latest changes from trunk.

759. By Gustavo Pichorim Boiko

Start implementing the messaging menu populating using the history service.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-10-09 21:59:42 +0000
+++ CMakeLists.txt 2013-12-11 13:06:39 +0000
@@ -61,6 +61,7 @@
61pkg_check_modules(MESSAGING_MENU REQUIRED messaging-menu)61pkg_check_modules(MESSAGING_MENU REQUIRED messaging-menu)
62pkg_check_modules(GSETTINGS REQUIRED gsettings-qt)62pkg_check_modules(GSETTINGS REQUIRED gsettings-qt)
63pkg_check_modules(UserMetrics REQUIRED libusermetricsinput-1)63pkg_check_modules(UserMetrics REQUIRED libusermetricsinput-1)
64pkg_check_modules(HISTORY REQUIRED history-service)
6465
65add_definitions(-DQT_NO_KEYWORDS)66add_definitions(-DQT_NO_KEYWORDS)
6667
6768
=== modified file 'indicator/CMakeLists.txt'
--- indicator/CMakeLists.txt 2013-09-25 21:18:46 +0000
+++ indicator/CMakeLists.txt 2013-12-11 13:06:39 +0000
@@ -1,9 +1,10 @@
11
2set(qt_SRCS2set(qt_SRCS
3 callchannelobserver.cpp3 callchannelobserver.cpp
4 historyloader.cpp
4 messagingmenu.cpp5 messagingmenu.cpp
5 metrics.cpp6 metrics.cpp
6 textchannelobserver.cpp7 notifications.cpp
7 voicemailindicator.cpp8 voicemailindicator.cpp
8 )9 )
910
@@ -17,6 +18,7 @@
17 ${CMAKE_SOURCE_DIR}/libtelephonyservice18 ${CMAKE_SOURCE_DIR}/libtelephonyservice
18 ${CMAKE_CURRENT_BINARY_DIR}19 ${CMAKE_CURRENT_BINARY_DIR}
19 ${UserMetrics_INCLUDE_DIRS}20 ${UserMetrics_INCLUDE_DIRS}
21 ${HISTORY_INCLUDE_DIRS}
20 )22 )
2123
22link_directories(${MESSAGING_MENU_LIBRARY_DIRS})24link_directories(${MESSAGING_MENU_LIBRARY_DIRS})
@@ -30,6 +32,7 @@
30 ${MESSAGING_MENU_LIBRARIES}32 ${MESSAGING_MENU_LIBRARIES}
31 ${GSETTINGS_LIBRARIES}33 ${GSETTINGS_LIBRARIES}
32 ${UserMetrics_LIBRARIES}34 ${UserMetrics_LIBRARIES}
35 ${HISTORY_LIBRARIES}
33 telephonyservice36 telephonyservice
34 )37 )
3538
3639
=== added file 'indicator/historyloader.cpp'
--- indicator/historyloader.cpp 1970-01-01 00:00:00 +0000
+++ indicator/historyloader.cpp 2013-12-11 13:06:39 +0000
@@ -0,0 +1,207 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
6 *
7 * This file is part of telephony-service.
8 *
9 * telephony-service is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * telephony-service is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "historyloader.h"
23#include "messagingmenu.h"
24#include "metrics.h"
25#include "notifications.h"
26#include <History/EventView>
27#include <History/IntersectionFilter>
28#include <History/Manager>
29#include <History/TextEvent>
30#include <History/VoiceEvent>
31
32HistoryLoader::HistoryLoader(QObject *parent) :
33 QObject(parent)
34{
35 loadMessages();
36 loadCalls();
37}
38
39HistoryLoader *HistoryLoader::instance()
40{
41 static HistoryLoader *self = new HistoryLoader();
42 return self;
43}
44
45void HistoryLoader::loadMessages()
46{
47 if (!mTextEventView.isNull()) {
48 mTextEventView->deleteLater();
49 }
50
51 if (!mSentTextEventView.isNull()) {
52 mSentTextEventView->deleteLater();
53 }
54
55 History::IntersectionFilter filter;
56 // FIXME: maybe we should not hardcode the accountId?
57 filter.append(History::Filter(History::FieldAccountId, "ofono/ofono/account0"));
58 filter.append(History::Filter(History::FieldNewEvent, true));
59
60 mTextEventView = History::Manager::instance()->queryEvents(History::EventTypeText, History::Sort(), filter);
61 connect(mTextEventView.data(),
62 SIGNAL(eventsAdded(History::Events)),
63 SLOT(onTextEventsAdded(History::Events)));
64 connect(mTextEventView.data(),
65 SIGNAL(eventsModified(History::Events)),
66 SLOT(onTextEventsModified(History::Events)));
67 connect(mTextEventView.data(),
68 SIGNAL(eventsRemoved(History::Events)),
69 SLOT(onTextEventsRemoved(History::Events)));
70 connect(mTextEventView.data(),
71 SIGNAL(invalidated()),
72 SLOT(loadMessages()));
73
74 History::Events events = mTextEventView->nextPage();
75 while (!events.isEmpty()) {
76 // add the events to the messaging menu
77 Q_FOREACH(const History::Event &event, events) {
78 History::TextEvent textEvent(event);
79
80 // add the message to the messaging menu (use hex format to avoid invalid characters)
81 QByteArray token(textEvent.eventId().toUtf8());
82 MessagingMenu::instance()->addMessage(textEvent.senderId(), token.toHex(), textEvent.timestamp(), textEvent.message());
83 }
84 events = mTextEventView->nextPage();
85 }
86
87 // create a view just to get signals of sent messages
88 filter.clear();
89 filter.append(History::Filter(History::FieldAccountId, "ofono/ofono/account0"));
90 filter.append(History::Filter(History::FieldSenderId, "self"));
91 mSentTextEventView = History::Manager::instance()->queryEvents(History::EventTypeText, History::Sort(), filter);
92 connect(mSentTextEventView.data(),
93 SIGNAL(eventsAdded(History::Events)),
94 SLOT(onTextEventsSent(History::Events)));
95 connect(mSentTextEventView.data(),
96 SIGNAL(invalidated()),
97 SLOT(loadMessages()));
98}
99
100void HistoryLoader::loadCalls()
101{
102 if (!mVoiceEventView.isNull()) {
103 mVoiceEventView->deleteLater();
104 }
105
106 History::IntersectionFilter filter;
107 // FIXME: maybe we should not hardcode the accountId?
108 filter.append(History::Filter(History::FieldAccountId, "ofono/ofono/account0"));
109 filter.append(History::Filter(History::FieldNewEvent, true));
110 filter.append(History::Filter(History::FieldMissed, true));
111 mVoiceEventView = History::Manager::instance()->queryEvents(History::EventTypeVoice, History::Sort(), filter);
112 connect(mVoiceEventView.data(),
113 SIGNAL(eventsAdded(History::Events)),
114 SLOT(onVoiceEventsAdded(History::Events)));
115 connect(mVoiceEventView.data(),
116 SIGNAL(invalidated()),
117 SLOT(loadCalls()));
118
119 History::Events events = mVoiceEventView->nextPage();
120 while (!events.isEmpty()) {
121 Q_FOREACH(const History::Event &event, events) {
122 History::VoiceEvent voiceEvent(event);
123 MessagingMenu::instance()->addCall(voiceEvent.senderId(), voiceEvent.timestamp());
124 }
125 }
126}
127
128void HistoryLoader::onTextEventsAdded(const History::Events &events)
129{
130 Q_FOREACH(const History::Event &event, events) {
131 History::TextEvent textEvent(event);
132
133 // add the message to the messaging menu (use hex format to avoid invalid characters)
134 QByteArray token(textEvent.eventId().toUtf8());
135 MessagingMenu::instance()->addMessage(textEvent.senderId(), token.toHex(), textEvent.timestamp(), textEvent.message());
136
137 // and show the notify OSD notification
138 Notifications::instance()->showNotificationForMessage(textEvent.senderId(), textEvent.message());
139
140 // update the metrics
141 Metrics::instance()->increment(Metrics::ReceivedMessages);
142 }
143}
144
145void HistoryLoader::onTextEventsSent(const History::Events &events)
146{
147 // just increase the metrics
148 Metrics::instance()->increment(Metrics::SentMessages, events.count());
149}
150
151void HistoryLoader::onTextEventsModified(const History::Events &events)
152{
153 Q_FOREACH(const History::Event &event, events) {
154 // we only support removing events from the menu
155 if (!event.newEvent()) {
156 MessagingMenu::instance()->removeMessage(event.eventId());
157 }
158 }
159}
160
161void HistoryLoader::onTextEventsRemoved(const History::Events &events)
162{
163 Q_FOREACH(const History::Event &event, events) {
164 // we only support removing events from the menu
165 MessagingMenu::instance()->removeMessage(event.eventId());
166 }
167}
168
169void HistoryLoader::onVoiceEventsAdded(const History::Events &events)
170{
171 Q_FOREACH(const History::Event &event, events) {
172 History::VoiceEvent voiceEvent(event);
173 if (voiceEvent.missed()) {
174 MessagingMenu::instance()->addCall(voiceEvent.senderId(), voiceEvent.timestamp());
175 } else {
176 Metrics::instance()->increment(Metrics::CallDurations, QTime(0,0,0).secsTo(voiceEvent.duration()));
177 }
178
179 if (voiceEvent.senderId() != "self") {
180 Metrics::instance()->increment(Metrics::IncomingCalls);
181 } else {
182 Metrics::instance()->increment(Metrics::OutgoingCalls);
183 }
184 }
185}
186
187void HistoryLoader::onMessageRead(const QString &phoneNumber, const QString &messageId)
188{
189 History::Thread thread = History::Manager::instance()->threadForParticipants("ofono/ofono/account0",
190 History::EventTypeText,
191 QStringList() << phoneNumber,
192 History::MatchPhoneNumber);
193 if (thread.isNull()) {
194 return;
195 }
196
197 History::TextEvent event = History::Manager::instance()->getSingleEvent(History::EventTypeText,
198 "ofono/ofono/account0",
199 thread.threadId(),
200 messageId);
201 if (event.isNull() || !event.newEvent()) {
202 return;
203 }
204
205 event.setNewEvent(false);
206 History::Manager::instance()->writeEvents(History::Events() << event);
207}
0208
=== added file 'indicator/historyloader.h'
--- indicator/historyloader.h 1970-01-01 00:00:00 +0000
+++ indicator/historyloader.h 2013-12-11 13:06:39 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * Authors:
5 * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com>
6 *
7 * This file is part of telephony-service.
8 *
9 * telephony-service is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 3.
12 *
13 * telephony-service is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef HISTORYLOADER_H
23#define HISTORYLOADER_H
24
25#include <QObject>
26#include <History/Types>
27#include <History/Event>
28
29class HistoryLoader : public QObject
30{
31 Q_OBJECT
32public:
33 static HistoryLoader *instance();
34
35public Q_SLOTS:
36 void loadMessages();
37 void loadCalls();
38
39private Q_SLOTS:
40 void onTextEventsAdded(const History::Events &events);
41 void onTextEventsSent(const History::Events &events);
42 void onTextEventsModified(const History::Events &events);
43 void onTextEventsRemoved(const History::Events &events);
44 void onVoiceEventsAdded(const History::Events &events);
45 void onMessageRead(const QString &phoneNumber, const QString &messageId);
46
47private:
48 explicit HistoryLoader(QObject *parent = 0);
49
50 History::EventViewPtr mTextEventView;
51 History::EventViewPtr mSentTextEventView;
52 History::EventViewPtr mVoiceEventView;
53
54
55};
56
57#endif // HISTORYLOADER_H
058
=== modified file 'indicator/main.cpp'
--- indicator/main.cpp 2013-09-25 21:18:46 +0000
+++ indicator/main.cpp 2013-12-11 13:06:39 +0000
@@ -23,10 +23,12 @@
23#include <libnotify/notify.h>23#include <libnotify/notify.h>
2424
25#include "applicationutils.h"25#include "applicationutils.h"
26#include "chatmanager.h"
26#include "callchannelobserver.h"27#include "callchannelobserver.h"
28#include "historyloader.h"
27#include "metrics.h"29#include "metrics.h"
28#include "telepathyhelper.h"30#include "telepathyhelper.h"
29#include "textchannelobserver.h"31#include "messagingmenu.h"
30#include "voicemailindicator.h"32#include "voicemailindicator.h"
31#include <QCoreApplication>33#include <QCoreApplication>
32#include <TelepathyQt/ClientRegistrar>34#include <TelepathyQt/ClientRegistrar>
@@ -60,9 +62,6 @@
6062
61 // Connect the textObserver and the callObserver to the channel observer in TelepathyHelper63 // Connect the textObserver and the callObserver to the channel observer in TelepathyHelper
62 CallChannelObserver *callObserver = new CallChannelObserver();64 CallChannelObserver *callObserver = new CallChannelObserver();
63 TextChannelObserver *textObserver = new TextChannelObserver();
64 QObject::connect(TelepathyHelper::instance()->channelObserver(), SIGNAL(textChannelAvailable(Tp::TextChannelPtr)),
65 textObserver, SLOT(onTextChannelAvailable(Tp::TextChannelPtr)));
66 QObject::connect(TelepathyHelper::instance()->channelObserver(), SIGNAL(callChannelAvailable(Tp::CallChannelPtr)),65 QObject::connect(TelepathyHelper::instance()->channelObserver(), SIGNAL(callChannelAvailable(Tp::CallChannelPtr)),
67 callObserver, SLOT(onCallChannelAvailable(Tp::CallChannelPtr)));66 callObserver, SLOT(onCallChannelAvailable(Tp::CallChannelPtr)));
6867
@@ -70,8 +69,16 @@
70 VoiceMailIndicator voiceMailIndicator;69 VoiceMailIndicator voiceMailIndicator;
71 Q_UNUSED(voiceMailIndicator);70 Q_UNUSED(voiceMailIndicator);
7271
73 // instanciate the metrics helper72 // instanciate the singletons
73 HistoryLoader::instance();
74 Metrics::instance();74 Metrics::instance();
7575
76 // forward the replies from messaging menu to the chat manager
77 QObject::connect(MessagingMenu::instance(), SIGNAL(replyReceived(QString,QString)),
78 ChatManager::instance(), SLOT(sendMessage(QString,QString)));
79
80 // just to make sure, ack the message on the telepathy level
81 QObject::connect(MessagingMenu::instance(), SIGNAL(messageRead(QString,QString)),
82 ChatManager::instance(), SLOT(acknowledgeMessage(QString,QString)));
76 return app.exec();83 return app.exec();
77}84}
7885
=== modified file 'indicator/messagingmenu.h'
--- indicator/messagingmenu.h 2013-10-11 21:08:18 +0000
+++ indicator/messagingmenu.h 2013-12-11 13:06:39 +0000
@@ -25,6 +25,7 @@
25#include <QObject>25#include <QObject>
26#include <QMap>26#include <QMap>
27#include <QDBusInterface>27#include <QDBusInterface>
28#include <QUrl>
28#include <messaging-menu.h>29#include <messaging-menu.h>
2930
30class Call31class Call
3132
=== renamed file 'indicator/textchannelobserver.cpp' => 'indicator/notifications.cpp'
--- indicator/textchannelobserver.cpp 2013-10-07 19:20:02 +0000
+++ indicator/notifications.cpp 2013-12-11 13:06:39 +0000
@@ -21,16 +21,10 @@
2121
22#include <libnotify/notify.h>22#include <libnotify/notify.h>
23#include "applicationutils.h"23#include "applicationutils.h"
24#include "textchannelobserver.h"24#include "notifications.h"
25#include "messagingmenu.h"
26#include "metrics.h"
27#include "chatmanager.h"
28#include "config.h"25#include "config.h"
29#include "contactutils.h"26#include "contactutils.h"
30#include "ringtone.h"27#include "ringtone.h"
31#include <TelepathyQt/AvatarData>
32#include <TelepathyQt/TextChannel>
33#include <TelepathyQt/ReceivedMessage>
34#include <QContactAvatar>28#include <QContactAvatar>
35#include <QContactFetchRequest>29#include <QContactFetchRequest>
36#include <QContactPhoneNumber>30#include <QContactPhoneNumber>
@@ -69,31 +63,25 @@
69 }63 }
70}64}
7165
72TextChannelObserver::TextChannelObserver(QObject *parent) :66Notifications::Notifications(QObject *parent) :
73 QObject(parent)67 QObject(parent)
74{68{
75 connect(MessagingMenu::instance(),69}
76 SIGNAL(replyReceived(QString,QString)),70
77 SLOT(onReplyReceived(QString,QString)));71Notifications *Notifications::instance()
78 connect(MessagingMenu::instance(),72{
79 SIGNAL(messageRead(QString,QString)),73 static Notifications *self = new Notifications();
80 SLOT(onMessageRead(QString,QString)));74 return self;
81}75}
8276
83void TextChannelObserver::showNotificationForMessage(const Tp::ReceivedMessage &message)77void Notifications::showNotificationForMessage(const QString &sender, const QString &message)
84{78{
85 Tp::ContactPtr contact = message.sender();
86
87 // try to match the contact info79 // try to match the contact info
88 QContactFetchRequest *request = new QContactFetchRequest(this);80 QContactFetchRequest *request = new QContactFetchRequest(this);
89 request->setFilter(QContactPhoneNumber::match(contact->id()));81 request->setFilter(QContactPhoneNumber::match(sender));
90
91 // add the message to the messaging menu (use hex format to avoid invalid characters)
92 QByteArray token(message.messageToken().toUtf8());
93 MessagingMenu::instance()->addMessage(contact->id(), token.toHex(), message.received(), message.text());
9482
95 // place the notify-notification item only after the contact fetch request is finished, as we can´t simply update83 // place the notify-notification item only after the contact fetch request is finished, as we can´t simply update
96 QObject::connect(request, &QContactAbstractRequest::stateChanged, [request, message, contact]() {84 QObject::connect(request, &QContactAbstractRequest::stateChanged, [request, message, sender]() {
97 // only process the results after the finished state is reached85 // only process the results after the finished state is reached
98 if (request->state() != QContactAbstractRequest::FinishedState) {86 if (request->state() != QContactAbstractRequest::FinishedState) {
99 return;87 return;
@@ -108,7 +96,7 @@
108 avatar = contact.detail<QContactAvatar>().imageUrl().toEncoded();96 avatar = contact.detail<QContactAvatar>().imageUrl().toEncoded();
109 }97 }
11098
111 QString title = QString::fromUtf8(C::gettext("SMS from %1")).arg(displayLabel.isEmpty() ? contact->alias() : displayLabel);99 QString title = QString::fromUtf8(C::gettext("SMS from %1")).arg(displayLabel.isEmpty() ? sender : displayLabel);
112100
113 if (avatar.isEmpty()) {101 if (avatar.isEmpty()) {
114 avatar = QUrl(telephonyServiceDir() + "assets/avatar-default@18.png").toEncoded();102 avatar = QUrl(telephonyServiceDir() + "assets/avatar-default@18.png").toEncoded();
@@ -117,12 +105,12 @@
117 qDebug() << title << avatar;105 qDebug() << title << avatar;
118 // show the notification106 // show the notification
119 NotifyNotification *notification = notify_notification_new(title.toStdString().c_str(),107 NotifyNotification *notification = notify_notification_new(title.toStdString().c_str(),
120 message.text().toStdString().c_str(),108 message.toStdString().c_str(),
121 avatar.toStdString().c_str());109 avatar.toStdString().c_str());
122110
123 // add the callback action111 // add the callback action
124 NotificationData *data = new NotificationData();112 NotificationData *data = new NotificationData();
125 data->phoneNumber = contact->id();113 data->phoneNumber = sender;
126 notify_notification_add_action (notification,114 notify_notification_add_action (notification,
127 "notification_action",115 "notification_action",
128 C::gettext("View message"),116 C::gettext("View message"),
@@ -146,73 +134,3 @@
146 request->setManager(ContactUtils::sharedManager());134 request->setManager(ContactUtils::sharedManager());
147 request->start();135 request->start();
148}136}
149
150Tp::TextChannelPtr TextChannelObserver::channelFromPath(const QString &path)
151{
152 Q_FOREACH(Tp::TextChannelPtr channel, mChannels) {
153 if (channel->objectPath() == path) {
154 return channel;
155 }
156 }
157
158 return Tp::TextChannelPtr(0);
159}
160
161void TextChannelObserver::onTextChannelAvailable(Tp::TextChannelPtr textChannel)
162{
163 connect(textChannel.data(),
164 SIGNAL(invalidated(Tp::DBusProxy*,const QString&, const QString&)),
165 SLOT(onTextChannelInvalidated()));
166 connect(textChannel.data(),
167 SIGNAL(messageReceived(const Tp::ReceivedMessage&)),
168 SLOT(onMessageReceived(const Tp::ReceivedMessage&)));
169 connect(textChannel.data(),
170 SIGNAL(pendingMessageRemoved(const Tp::ReceivedMessage&)),
171 SLOT(onPendingMessageRemoved(const Tp::ReceivedMessage&)));
172 connect(textChannel.data(),
173 SIGNAL(messageSent(Tp::Message,Tp::MessageSendingFlags,QString)),
174 SLOT(onMessageSent(Tp::Message,Tp::MessageSendingFlags,QString)));
175
176 mChannels.append(textChannel);
177
178 // notify all the messages from the channel
179 Q_FOREACH(Tp::ReceivedMessage message, textChannel->messageQueue()) {
180 onMessageReceived(message);
181 }
182}
183
184void TextChannelObserver::onTextChannelInvalidated()
185{
186 Tp::TextChannelPtr textChannel(qobject_cast<Tp::TextChannel*>(sender()));
187 mChannels.removeAll(textChannel);
188}
189
190void TextChannelObserver::onMessageReceived(const Tp::ReceivedMessage &message)
191{
192 // do not place notification items for scrollback messages
193 if (!message.isScrollback() && !message.isDeliveryReport() && !message.isRescued()) {
194 showNotificationForMessage(message);
195 Metrics::instance()->increment(Metrics::ReceivedMessages);
196 }
197}
198
199void TextChannelObserver::onPendingMessageRemoved(const Tp::ReceivedMessage &message)
200{
201 MessagingMenu::instance()->removeMessage(message.messageToken());
202}
203
204void TextChannelObserver::onReplyReceived(const QString &phoneNumber, const QString &reply)
205{
206 ChatManager::instance()->sendMessage(phoneNumber, reply);
207}
208
209void TextChannelObserver::onMessageRead(const QString &phoneNumber, const QString &encodedMessageId)
210{
211 QString messageId(QByteArray::fromHex(encodedMessageId.toUtf8()));
212 ChatManager::instance()->acknowledgeMessage(phoneNumber, messageId);
213}
214
215void TextChannelObserver::onMessageSent(Tp::Message, Tp::MessageSendingFlags, QString)
216{
217 Metrics::instance()->increment(Metrics::SentMessages);
218}
219137
=== renamed file 'indicator/textchannelobserver.h' => 'indicator/notifications.h'
--- indicator/textchannelobserver.h 2013-09-25 21:18:46 +0000
+++ indicator/notifications.h 2013-12-11 13:06:39 +0000
@@ -19,36 +19,20 @@
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */20 */
2121
22#ifndef TEXTCHANNELOBSERVER_H22#ifndef NOTIFICATIONS_H
23#define TEXTCHANNELOBSERVER_H23#define NOTIFICATIONS_H
2424
25#include <QObject>25#include <QObject>
26#include <TelepathyQt/TextChannel>
27#include <TelepathyQt/ReceivedMessage>
2826
29class TextChannelObserver : public QObject27class Notifications : public QObject
30{28{
31 Q_OBJECT29 Q_OBJECT
32public:30public:
33 explicit TextChannelObserver(QObject *parent = 0);31 static Notifications *instance();
3432 void showNotificationForMessage(const QString &sender, const QString &message);
35public Q_SLOTS:
36 void onTextChannelAvailable(Tp::TextChannelPtr textChannel);
37
38protected:
39 void showNotificationForMessage(const Tp::ReceivedMessage &message);
40 Tp::TextChannelPtr channelFromPath(const QString &path);
41
42protected Q_SLOTS:
43 void onTextChannelInvalidated();
44 void onMessageReceived(const Tp::ReceivedMessage &message);
45 void onPendingMessageRemoved(const Tp::ReceivedMessage &message);
46 void onReplyReceived(const QString &phoneNumber, const QString &reply);
47 void onMessageRead(const QString &phoneNumber, const QString &encodedMessageId);
48 void onMessageSent(Tp::Message, Tp::MessageSendingFlags, QString);
4933
50private:34private:
51 QList<Tp::TextChannelPtr> mChannels;35 explicit Notifications(QObject *parent = 0);
52};36};
5337
54#endif // TEXTCHANNELOBSERVER_H38#endif // NOTIFICATIONS_H
5539
=== modified file 'libtelephonyservice/chatmanager.h'
--- libtelephonyservice/chatmanager.h 2013-07-18 17:02:10 +0000
+++ libtelephonyservice/chatmanager.h 2013-12-11 13:06:39 +0000
@@ -34,8 +34,6 @@
34public:34public:
35 static ChatManager *instance();35 static ChatManager *instance();
3636
37 Q_INVOKABLE void sendMessage(const QString &phoneNumber, const QString &message);
38
39 int unreadMessagesCount() const;37 int unreadMessagesCount() const;
40 int unreadMessages(const QString &phoneNumber);38 int unreadMessages(const QString &phoneNumber);
4139
@@ -51,6 +49,7 @@
51 void onMessageSent(const Tp::Message &sentMessage, const Tp::MessageSendingFlags flags, const QString &message);49 void onMessageSent(const Tp::Message &sentMessage, const Tp::MessageSendingFlags flags, const QString &message);
5250
53 void acknowledgeMessage(const QString &phoneNumber, const QString &messageId);51 void acknowledgeMessage(const QString &phoneNumber, const QString &messageId);
52 void sendMessage(const QString &phoneNumber, const QString &message);
5453
55protected:54protected:
56 Tp::TextChannelPtr existingChat(const QString &phoneNumber);55 Tp::TextChannelPtr existingChat(const QString &phoneNumber);

Subscribers

People subscribed via source and target branches