Merge lp:~tiagosh/telephony-service/fix-1453004 into lp:telephony-service/rtm-15.04

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 1095
Merged at revision: 1095
Proposed branch: lp:~tiagosh/telephony-service/fix-1453004
Merge into: lp:telephony-service/rtm-15.04
Diff against target: 189 lines (+98/-6)
5 files modified
approver/approver.cpp (+3/-0)
cmake/modules/GenerateTest.cmake (+1/-0)
indicator/ussdindicator.cpp (+13/-6)
tests/common/CMakeLists.txt (+3/-0)
tests/common/NotificationsMock.cpp (+78/-0)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/fix-1453004
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+263702@code.launchpad.net

Commit message

- Do not let USSD and incoming call snap decisions timeout.
- Initialize m_notificationId with -1, as 0 is a valid id.
- Do not call CloseNotification() when notificationClosed() is received to avoid loop.

Description of the change

- Do not let USSD and incoming call snap decisions timeout.
- Initialize m_notificationId with -1, as 0 is a valid id.
- Do not call CloseNotification() when notificationClosed() is received to avoid loop.

--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/<package-name>) 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?
N/A

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.
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, on a previously submitted MP against trunk.

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'approver/approver.cpp'
2--- approver/approver.cpp 2015-06-10 21:05:50 +0000
3+++ approver/approver.cpp 2015-07-02 17:43:59 +0000
4@@ -477,6 +477,9 @@
5 notify_notification_set_hint_string(notification,
6 "x-canonical-secondary-icon",
7 "incoming-call");
8+ notify_notification_set_hint_int32(notification,
9+ "x-canonical-snap-decisions-timeout",
10+ -1);
11
12 QString acceptTitle = hasCalls ? C::gettext("Hold + Answer") :
13 C::gettext("Accept");
14
15=== modified file 'cmake/modules/GenerateTest.cmake'
16--- cmake/modules/GenerateTest.cmake 2015-06-02 20:39:25 +0000
17+++ cmake/modules/GenerateTest.cmake 2015-07-02 17:43:59 +0000
18@@ -110,6 +110,7 @@
19 cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
20
21 set(TASKS --task gnome-keyring-daemon -p -r -p -d --task-name gnome-keyring --ignore-return
22+ --task ${CMAKE_BINARY_DIR}/tests/common/NotificationsMock --task-name notifications --ignore-return
23 --task /usr/lib/dconf/dconf-service --task-name dconf-service --ignore-return
24 --task dconf -p write -p /org/gnome/empathy/use-conn -p false --task-name dconf-write --wait-for ca.desrt.dconf --ignore-return
25 --task /usr/lib/telepathy/mission-control-5 --task-name mission-control --wait-for ca.desrt.dconf --ignore-return
26
27=== modified file 'indicator/ussdindicator.cpp'
28--- indicator/ussdindicator.cpp 2015-04-28 19:18:55 +0000
29+++ indicator/ussdindicator.cpp 2015-07-02 17:43:59 +0000
30@@ -32,6 +32,7 @@
31
32 USSDIndicator::USSDIndicator(QObject *parent)
33 : QObject(parent),
34+ m_notificationId(-1),
35 m_menuRequest(true),
36 m_menuNotification(false),
37 m_notifications("org.freedesktop.Notifications",
38@@ -99,7 +100,13 @@
39
40 void USSDIndicator::onStateChanged(const QString &state)
41 {
42- // TODO: check if we should close notifications when the state is idle
43+ if (m_notificationId == -1) {
44+ return;
45+ }
46+
47+ if (state == "idle") {
48+ m_notifications.CloseNotification(m_notificationId);
49+ }
50 }
51
52 void USSDIndicator::showUSSDNotification(const QString &message, bool replyRequired, USSDManager *ussdManager)
53@@ -116,6 +123,7 @@
54 QVariantMap notificationHints;
55 notificationHints["x-canonical-snap-decisions"] = "true";
56 notificationHints["x-canonical-private-button-tint"] = "true";
57+ notificationHints["x-canonical-snap-decisions-timeout"] = -1;
58
59 QVariantMap menuModelActions;
60 menuModelActions["notifications"] = menu->actionPath();
61@@ -148,7 +156,7 @@
62 return;
63 }
64
65- m_notificationId = 0;
66+ m_notificationId = -1;
67
68 if (actionKey == "reply_id") {
69 ussdManager->respond(m_menuRequest.response());
70@@ -162,19 +170,18 @@
71 if (id != m_notificationId) {
72 return;
73 }
74- m_notifications.CloseNotification(m_notificationId);
75- m_notificationId = 0;
76+ m_notificationId = -1;
77 }
78
79 void USSDIndicator::clear()
80 {
81- if (m_notificationId != 0) {
82+ if (m_notificationId != -1) {
83 USSDManager *ussdManager = mUSSDRequests.take(m_notificationId);
84 if (ussdManager) {
85 ussdManager->cancel();
86 }
87
88 m_notifications.CloseNotification(m_notificationId);
89- m_notificationId = 0;
90+ m_notificationId = -1;
91 }
92 }
93
94=== modified file 'tests/common/CMakeLists.txt'
95--- tests/common/CMakeLists.txt 2015-06-05 18:42:14 +0000
96+++ tests/common/CMakeLists.txt 2015-07-02 17:43:59 +0000
97@@ -5,6 +5,9 @@
98
99 configure_file(dbus-session.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-session.conf)
100
101+add_executable(NotificationsMock NotificationsMock.cpp)
102+qt5_use_modules(NotificationsMock Core DBus)
103+
104 qt5_add_dbus_interface(mockcontroller_SRCS mock/MockConnection.xml MockConnectionInterface)
105 add_library(mockcontroller STATIC mockcontroller.cpp mockcontroller.h ${mockcontroller_SRCS})
106 qt5_use_modules(mockcontroller Core DBus)
107
108=== added file 'tests/common/NotificationsMock.cpp'
109--- tests/common/NotificationsMock.cpp 1970-01-01 00:00:00 +0000
110+++ tests/common/NotificationsMock.cpp 2015-07-02 17:43:59 +0000
111@@ -0,0 +1,78 @@
112+/*
113+ * Copyright (C) 2015 Canonical, Ltd.
114+ *
115+ * This file is part of telephony-service.
116+ *
117+ * telephony-service is free software; you can redistribute it and/or modify
118+ * it under the terms of the GNU General Public License as published by
119+ * the Free Software Foundation; version 3.
120+ *
121+ * telephony-service is distributed in the hope that it will be useful,
122+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
123+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
124+ * GNU General Public License for more details.
125+ *
126+ * You should have received a copy of the GNU General Public License
127+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
128+ */
129+
130+#include <QObject>
131+#include <QCoreApplication>
132+#include <QDBusConnection>
133+#include <QDBusMessage>
134+#include <QDBusObjectPath>
135+#include <QDebug>
136+
137+#define NOTIFICATIONS_DBUS_SERVICE_NAME "org.freedesktop.Notifications"
138+#define NOTIFICATIONS_DBUS_OBJ_PATH "/org/freedesktop/Notifications"
139+
140+class NotificationsMock : public QObject
141+{
142+ Q_OBJECT
143+ Q_CLASSINFO("D-Bus Interface", NOTIFICATIONS_DBUS_SERVICE_NAME)
144+
145+public:
146+ Q_SCRIPTABLE void Notify(QString app_name, uint replaces_id, QString app_icon, QString summary, QString body, QStringList actions, QVariantMap hints, int expire_timeout);
147+ Q_SCRIPTABLE void CloseNotification(uint id);
148+
149+ // Mock specific method
150+ Q_SCRIPTABLE void MockInvokeAction(uint id, QString action_key);
151+
152+Q_SIGNALS:
153+ Q_SCRIPTABLE void NotificationClosed(uint id, uint reason);
154+ Q_SCRIPTABLE void ActionInvoked(uint id, QString action_key);
155+
156+ // Mock specific signal
157+ Q_SCRIPTABLE void MockNotificationReceived(QString app_name, uint replaces_id, QString app_icon, QString summary, QString body, QStringList actions, QVariantMap hints, int expire_timeout);
158+};
159+
160+void NotificationsMock::Notify(QString app_name, uint replaces_id, QString app_icon, QString summary, QString body, QStringList actions, QVariantMap hints, int expire_timeout)
161+{
162+ Q_EMIT MockNotificationReceived(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout);
163+}
164+
165+void NotificationsMock::MockInvokeAction(uint id, QString action_key)
166+{
167+ Q_EMIT ActionInvoked(id, action_key);
168+ Q_EMIT NotificationClosed(id, 2); // 2 is dismissed by user
169+}
170+
171+void NotificationsMock::CloseNotification(uint id)
172+{
173+ Q_EMIT NotificationClosed(id, 3); // 3 is closed by a CloseNotification() call
174+}
175+
176+int main(int argc, char **argv)
177+{
178+ QCoreApplication a(argc, argv);
179+
180+ QDBusConnection connection = QDBusConnection::sessionBus();
181+
182+ NotificationsMock notifications;
183+ connection.registerObject(NOTIFICATIONS_DBUS_OBJ_PATH, &notifications, QDBusConnection::ExportScriptableContents);
184+ connection.registerService(NOTIFICATIONS_DBUS_SERVICE_NAME);
185+
186+ return a.exec();
187+}
188+
189+#include "NotificationsMock.moc"

Subscribers

People subscribed via source and target branches