Merge lp:~phablet-team/telephony-service/initialize_chatentry into lp:telephony-service/staging

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 1254
Merged at revision: 1253
Proposed branch: lp:~phablet-team/telephony-service/initialize_chatentry
Merge into: lp:telephony-service/staging
Diff against target: 72 lines (+13/-3)
3 files modified
Ubuntu/Telephony/participantsmodel.cpp (+4/-2)
handler/texthandler.cpp (+8/-1)
handler/texthandler.h (+1/-0)
To merge this branch: bzr merge lp:~phablet-team/telephony-service/initialize_chatentry
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+321292@code.launchpad.net

Commit message

- Initialize pointer to avoid crashes.
- Connect new accounts in case messaging-app is already active

Description of the change

- Initialize pointer to avoid crashes.
- Connect new accounts in case messaging-app is already active

To post a comment you must log in.
1254. By Tiago Salem Herrmann

Connect new accounts in case messaging-app is already active

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Ubuntu/Telephony/participantsmodel.cpp'
2--- Ubuntu/Telephony/participantsmodel.cpp 2017-03-22 16:45:33 +0000
3+++ Ubuntu/Telephony/participantsmodel.cpp 2017-03-29 14:03:35 +0000
4@@ -27,7 +27,7 @@
5 Q_DECLARE_METATYPE(Participant)
6
7 ParticipantsModel::ParticipantsModel(QObject *parent) :
8- QAbstractListModel(parent), mWaitingForQml(false), mCanFetchMore(true)
9+ QAbstractListModel(parent), mWaitingForQml(false), mCanFetchMore(true), mChatEntry(NULL)
10 {
11 qRegisterMetaType<Participant>();
12 mRoles[AliasRole] = "alias";
13@@ -220,7 +220,9 @@
14 if (!entry) {
15 return;
16 }
17- previousChatEntry->disconnect(this);
18+ if (previousChatEntry) {
19+ previousChatEntry->disconnect(this);
20+ }
21 connect(mChatEntry, SIGNAL(participantAdded(Participant *)), SLOT(addParticipant(Participant *)));
22 connect(mChatEntry, SIGNAL(participantRemoved(Participant *)), SLOT(removeParticipant(Participant *)));
23 Q_FOREACH(Participant *participant, mChatEntry->allParticipants()) {
24
25=== modified file 'handler/texthandler.cpp'
26--- handler/texthandler.cpp 2017-03-03 17:51:57 +0000
27+++ handler/texthandler.cpp 2017-03-29 14:03:35 +0000
28@@ -35,17 +35,23 @@
29
30 TextHandler::TextHandler(QObject *parent)
31 : QObject(parent)
32- , mMessagingAppMonitor("com.canonical.MessagingApp", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration)
33+ , mMessagingAppMonitor("com.canonical.MessagingApp", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration), mMessagingAppRegistered(false)
34 {
35 qDBusRegisterMetaType<AttachmentStruct>();
36 qDBusRegisterMetaType<AttachmentList>();
37 qRegisterMetaType<PendingMessage>();
38 connect(&mMessagingAppMonitor, SIGNAL(serviceRegistered(const QString&)), SLOT(onMessagingAppOpen()));
39 connect(&mMessagingAppMonitor, SIGNAL(serviceUnregistered(const QString&)), SLOT(onMessagingAppClosed()));
40+ connect(TelepathyHelper::instance(), &TelepathyHelper::accountAdded, [=](AccountEntry *account) {
41+ if (mMessagingAppRegistered && !account->active() && account->protocolInfo()->leaveRoomsOnClose()) {
42+ account->reconnect();
43+ }
44+ });
45 }
46
47 void TextHandler::onMessagingAppOpen()
48 {
49+ mMessagingAppRegistered = true;
50 Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {
51 if (!account->active() && account->protocolInfo()->leaveRoomsOnClose()) {
52 account->reconnect();
53@@ -55,6 +61,7 @@
54
55 void TextHandler::onMessagingAppClosed()
56 {
57+ mMessagingAppRegistered = false;
58 Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {
59 if (account->protocolInfo()->leaveRoomsOnClose()) {
60 account->requestDisconnect();
61
62=== modified file 'handler/texthandler.h'
63--- handler/texthandler.h 2017-03-03 17:51:57 +0000
64+++ handler/texthandler.h 2017-03-29 14:03:35 +0000
65@@ -65,6 +65,7 @@
66 explicit TextHandler(QObject *parent = 0);
67 QList<Tp::TextChannelPtr> mChannels;
68 QDBusServiceWatcher mMessagingAppMonitor;
69+ bool mMessagingAppRegistered;
70 };
71
72 #endif // TEXTHANDLER_H

Subscribers

People subscribed via source and target branches

to all changes: