Merge lp:~tiagosh/telephony-service/fallback-default-account into lp:telephony-service

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 935
Merged at revision: 932
Proposed branch: lp:~tiagosh/telephony-service/fallback-default-account
Merge into: lp:telephony-service
Diff against target: 152 lines (+72/-6)
4 files modified
handler/texthandler.cpp (+3/-0)
indicator/textchannelobserver.cpp (+47/-0)
libtelephonyservice/callmanager.cpp (+14/-4)
libtelephonyservice/chatmanager.cpp (+8/-2)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/fallback-default-account
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+234382@code.launchpad.net

Commit message

- Fix crash on the desktop
- Use default account for messaging as a fallback
- Display a dialog asking the user to choose a sim card when sending a message from messaging-menu and no default sim card is defined.

Description of the change

- Fix crash on the desktop
- Use default account for messaging as a fallback
- Display a dialog asking the user to choose a sim card when sending a message from messaging-menu and no default sim card is defined.

--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/telephony-service) 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?
will be done later to avoid conflicts

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.
935. By Tiago Salem Herrmann

add fixme

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 'handler/texthandler.cpp'
2--- handler/texthandler.cpp 2014-07-28 21:05:28 +0000
3+++ handler/texthandler.cpp 2014-09-11 20:58:09 +0000
4@@ -254,6 +254,9 @@
5 void TextHandler::onTextChannelAvailable(Tp::TextChannelPtr channel)
6 {
7 AccountEntry *account = TelepathyHelper::instance()->accountForConnection(channel->connection());
8+ if (!account) {
9+ return;
10+ }
11 QString accountId = account->accountId();
12 mChannels.append(channel);
13
14
15=== modified file 'indicator/textchannelobserver.cpp'
16--- indicator/textchannelobserver.cpp 2014-07-07 22:01:09 +0000
17+++ indicator/textchannelobserver.cpp 2014-09-11 20:58:09 +0000
18@@ -30,6 +30,7 @@
19 #include "ringtone.h"
20 #include "telepathyhelper.h"
21 #include "phoneutils.h"
22+#include "accountentry.h"
23 #include <TelepathyQt/AvatarData>
24 #include <TelepathyQt/TextChannel>
25 #include <TelepathyQt/ReceivedMessage>
26@@ -62,6 +63,20 @@
27
28 void notification_closed(NotifyNotification *notification, QMap<NotifyNotification*, NotificationData*> *map);
29
30+void sim_selection_action(NotifyNotification* notification, char *action, gpointer data)
31+{
32+ GError *error = NULL;
33+ QString accountId = action;
34+ qDebug() << accountId << data;
35+ NotificationData *notificationData = (NotificationData*) data;
36+ if (notificationData != NULL) {
37+ ChatManager::instance()->sendMessage(QStringList() << notificationData->phoneNumber, notificationData->text, accountId);
38+ }
39+
40+ notify_notification_close(notification, &error);
41+ g_object_unref(notification);
42+}
43+
44 void flash_notification_action(NotifyNotification* notification, char *action, gpointer data)
45 {
46 GError *error = NULL;
47@@ -379,6 +394,38 @@
48
49 void TextChannelObserver::onReplyReceived(const QString &phoneNumber, const QString &reply)
50 {
51+ // FIXME - we need to find a better way to deal with dual sim in the messaging-menu
52+ if (!TelepathyHelper::instance()->defaultMessagingAccount() && TelepathyHelper::instance()->accounts().size() > 1) {
53+ NotifyNotification *notification = notify_notification_new(C::gettext("Please, select a SIM card:"),
54+ reply.toStdString().c_str(),
55+ "");
56+ NotificationData *data = new NotificationData();
57+ data->phoneNumber = phoneNumber;
58+ data->text = reply;
59+ mNotifications.insert(notification, data);
60+
61+ Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) {
62+ notify_notification_add_action (notification,
63+ account->accountId().toStdString().c_str(),
64+ account->displayName().toStdString().c_str(),
65+ sim_selection_action,
66+ data,
67+ NULL);
68+ }
69+ g_signal_connect(notification, "closed", G_CALLBACK(notification_closed), &mNotifications);
70+
71+ notify_notification_set_hint_string(notification,
72+ "x-canonical-snap-decisions",
73+ "true");
74+
75+ GError *error = NULL;
76+ if (!notify_notification_show(notification, &error)) {
77+ qWarning() << "Failed to show message notification:" << error->message;
78+ g_error_free (error);
79+ }
80+ return;
81+ }
82+
83 ChatManager::instance()->sendMessage(QStringList() << phoneNumber, reply);
84 }
85
86
87=== modified file 'libtelephonyservice/callmanager.cpp'
88--- libtelephonyservice/callmanager.cpp 2014-08-07 12:18:15 +0000
89+++ libtelephonyservice/callmanager.cpp 2014-09-11 20:58:09 +0000
90@@ -24,6 +24,7 @@
91 #include "callentry.h"
92 #include "telepathyhelper.h"
93 #include "greetercontacts.h"
94+#include "accountentry.h"
95
96 #include <TelepathyQt/ContactManager>
97 #include <TelepathyQt/PendingContacts>
98@@ -165,13 +166,22 @@
99
100 void CallManager::startCall(const QString &phoneNumber, const QString &accountId)
101 {
102- QString account = accountId;
103- if (account.isNull()) {
104- account = TelepathyHelper::instance()->accountIds()[0];
105+ AccountEntry *account;
106+ if (accountId.isNull()) {
107+ account = TelepathyHelper::instance()->defaultCallAccount();
108+ if (!account) {
109+ account = TelepathyHelper::instance()->accounts()[0];
110+ }
111+ } else {
112+ account = TelepathyHelper::instance()->accountForId(accountId);
113+ }
114+
115+ if (!account) {
116+ return;
117 }
118
119 QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();
120- phoneAppHandler->call("StartCall", phoneNumber, account);
121+ phoneAppHandler->call("StartCall", phoneNumber, account->accountId());
122 }
123
124 void CallManager::onCallIndicatorVisibleChanged(bool visible)
125
126=== modified file 'libtelephonyservice/chatmanager.cpp'
127--- libtelephonyservice/chatmanager.cpp 2014-07-28 21:05:28 +0000
128+++ libtelephonyservice/chatmanager.cpp 2014-09-11 20:58:09 +0000
129@@ -75,7 +75,10 @@
130 AttachmentList newAttachments;
131 AccountEntry *account;
132 if (accountId.isNull()) {
133- account = TelepathyHelper::instance()->accounts()[0];
134+ account = TelepathyHelper::instance()->defaultMessagingAccount();
135+ if (!account) {
136+ account = TelepathyHelper::instance()->accounts()[0];
137+ }
138 } else {
139 account = TelepathyHelper::instance()->accountForId(accountId);
140 }
141@@ -113,7 +116,10 @@
142 {
143 AccountEntry *account;
144 if (accountId.isNull()) {
145- account = TelepathyHelper::instance()->accounts()[0];
146+ account = TelepathyHelper::instance()->defaultMessagingAccount();
147+ if (!account) {
148+ account = TelepathyHelper::instance()->accounts()[0];
149+ }
150 } else {
151 account = TelepathyHelper::instance()->accountForId(accountId);
152 }

Subscribers

People subscribed via source and target branches