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
=== modified file 'Ubuntu/Telephony/participantsmodel.cpp'
--- Ubuntu/Telephony/participantsmodel.cpp 2017-03-22 16:45:33 +0000
+++ Ubuntu/Telephony/participantsmodel.cpp 2017-03-29 14:03:35 +0000
@@ -27,7 +27,7 @@
27Q_DECLARE_METATYPE(Participant)27Q_DECLARE_METATYPE(Participant)
2828
29ParticipantsModel::ParticipantsModel(QObject *parent) :29ParticipantsModel::ParticipantsModel(QObject *parent) :
30 QAbstractListModel(parent), mWaitingForQml(false), mCanFetchMore(true)30 QAbstractListModel(parent), mWaitingForQml(false), mCanFetchMore(true), mChatEntry(NULL)
31{31{
32 qRegisterMetaType<Participant>();32 qRegisterMetaType<Participant>();
33 mRoles[AliasRole] = "alias";33 mRoles[AliasRole] = "alias";
@@ -220,7 +220,9 @@
220 if (!entry) {220 if (!entry) {
221 return;221 return;
222 }222 }
223 previousChatEntry->disconnect(this);223 if (previousChatEntry) {
224 previousChatEntry->disconnect(this);
225 }
224 connect(mChatEntry, SIGNAL(participantAdded(Participant *)), SLOT(addParticipant(Participant *)));226 connect(mChatEntry, SIGNAL(participantAdded(Participant *)), SLOT(addParticipant(Participant *)));
225 connect(mChatEntry, SIGNAL(participantRemoved(Participant *)), SLOT(removeParticipant(Participant *)));227 connect(mChatEntry, SIGNAL(participantRemoved(Participant *)), SLOT(removeParticipant(Participant *)));
226 Q_FOREACH(Participant *participant, mChatEntry->allParticipants()) {228 Q_FOREACH(Participant *participant, mChatEntry->allParticipants()) {
227229
=== modified file 'handler/texthandler.cpp'
--- handler/texthandler.cpp 2017-03-03 17:51:57 +0000
+++ handler/texthandler.cpp 2017-03-29 14:03:35 +0000
@@ -35,17 +35,23 @@
3535
36TextHandler::TextHandler(QObject *parent)36TextHandler::TextHandler(QObject *parent)
37: QObject(parent)37: QObject(parent)
38 , mMessagingAppMonitor("com.canonical.MessagingApp", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration)38 , mMessagingAppMonitor("com.canonical.MessagingApp", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration), mMessagingAppRegistered(false)
39{39{
40 qDBusRegisterMetaType<AttachmentStruct>();40 qDBusRegisterMetaType<AttachmentStruct>();
41 qDBusRegisterMetaType<AttachmentList>();41 qDBusRegisterMetaType<AttachmentList>();
42 qRegisterMetaType<PendingMessage>();42 qRegisterMetaType<PendingMessage>();
43 connect(&mMessagingAppMonitor, SIGNAL(serviceRegistered(const QString&)), SLOT(onMessagingAppOpen()));43 connect(&mMessagingAppMonitor, SIGNAL(serviceRegistered(const QString&)), SLOT(onMessagingAppOpen()));
44 connect(&mMessagingAppMonitor, SIGNAL(serviceUnregistered(const QString&)), SLOT(onMessagingAppClosed()));44 connect(&mMessagingAppMonitor, SIGNAL(serviceUnregistered(const QString&)), SLOT(onMessagingAppClosed()));
45 connect(TelepathyHelper::instance(), &TelepathyHelper::accountAdded, [=](AccountEntry *account) {
46 if (mMessagingAppRegistered && !account->active() && account->protocolInfo()->leaveRoomsOnClose()) {
47 account->reconnect();
48 }
49 });
45}50}
4651
47void TextHandler::onMessagingAppOpen()52void TextHandler::onMessagingAppOpen()
48{53{
54 mMessagingAppRegistered = true;
49 Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {55 Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {
50 if (!account->active() && account->protocolInfo()->leaveRoomsOnClose()) {56 if (!account->active() && account->protocolInfo()->leaveRoomsOnClose()) {
51 account->reconnect();57 account->reconnect();
@@ -55,6 +61,7 @@
5561
56void TextHandler::onMessagingAppClosed()62void TextHandler::onMessagingAppClosed()
57{63{
64 mMessagingAppRegistered = false;
58 Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {65 Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {
59 if (account->protocolInfo()->leaveRoomsOnClose()) {66 if (account->protocolInfo()->leaveRoomsOnClose()) {
60 account->requestDisconnect();67 account->requestDisconnect();
6168
=== modified file 'handler/texthandler.h'
--- handler/texthandler.h 2017-03-03 17:51:57 +0000
+++ handler/texthandler.h 2017-03-29 14:03:35 +0000
@@ -65,6 +65,7 @@
65 explicit TextHandler(QObject *parent = 0);65 explicit TextHandler(QObject *parent = 0);
66 QList<Tp::TextChannelPtr> mChannels;66 QList<Tp::TextChannelPtr> mChannels;
67 QDBusServiceWatcher mMessagingAppMonitor;67 QDBusServiceWatcher mMessagingAppMonitor;
68 bool mMessagingAppRegistered;
68};69};
6970
70#endif // TEXTHANDLER_H71#endif // TEXTHANDLER_H

Subscribers

People subscribed via source and target branches

to all changes: