Merge lp:~pete-woods/indicator-network/sim-unlock-label-lp1449925 into lp:indicator-network/15.10
- sim-unlock-label-lp1449925
- Merge into trunk.15.10
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 512 |
Merged at revision: | 509 |
Proposed branch: | lp:~pete-woods/indicator-network/sim-unlock-label-lp1449925 |
Merge into: | lp:indicator-network/15.10 |
Diff against target: |
2029 lines (+682/-363) 25 files modified
CMakeLists.txt (+0/-7) debian/control (+0/-1) src/indicator/CMakeLists.txt (+0/-1) src/indicator/agent/PasswordMenu.cpp (+4/-1) src/indicator/agent/SecretAgent.cpp (+8/-7) src/indicator/agent/SecretAgent.h (+9/-4) src/indicator/agent/SecretRequest.cpp (+15/-27) src/indicator/agent/SecretRequest.h (+4/-3) src/indicator/factory.cpp (+18/-2) src/indicator/main.cpp (+8/-17) src/indicator/nmofono/manager-impl.cpp (+3/-2) src/indicator/nmofono/manager-impl.h (+6/-1) src/indicator/sim-unlock-dialog.cpp (+7/-18) src/indicator/sim-unlock-dialog.h (+2/-1) src/notify-cpp/CMakeLists.txt (+4/-1) src/notify-cpp/notification-manager.cpp (+76/-0) src/notify-cpp/notification-manager.h (+67/-0) src/notify-cpp/notification.cpp (+138/-61) src/notify-cpp/notification.h (+43/-22) src/notify-cpp/snapdecision/sim-unlock.cpp (+41/-29) src/notify-cpp/snapdecision/sim-unlock.h (+4/-3) src/qdbus-stubs/dbus-types.h (+6/-0) tests/integration/indicator-network-test-base.h (+5/-1) tests/integration/test-indicator.cpp (+210/-152) tests/unit/secret-agent/test-secret-agent.cpp (+4/-2) |
To merge this branch: | bzr merge lp:~pete-woods/indicator-network/sim-unlock-label-lp1449925 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Indicator Applet Developers | Pending | ||
Review via email: mp+266725@code.launchpad.net |
Commit message
* Fix SIM PIN unlock dialog mis-titled
* Move from libnotify to internal notify-cpp
Description of the change
* Fix SIM PIN unlock dialog mis-titled
* Move from libnotify to internal notify-cpp
- 502. By Pete Woods
-
Sync GCC5 landing
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:506
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 503. By Pete Woods
-
Add hotspot management.
Approved by: PS Jenkins bot - 504. By Pete Woods
-
Hold a wakelock when the hotspot is active. Fixes: #1458046
Approved by: PS Jenkins bot - 505. By Pete Woods
-
Simplify wifi/flight toggles
Approved by: PS Jenkins bot - 506. By Pete Woods
-
Don't show access points when hotspot is enabled Fixes: #1478160
Approved by: PS Jenkins bot - 507. By Pete Woods
-
Seed the random number generator Fixes: #1478157
- 508. By CI Train Bot Account
-
Releasing 0.5.2+15.
10.20150810. 1-0ubuntu1
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-06-22 08:25:05 +0000 | |||
3 | +++ CMakeLists.txt 2015-08-12 13:44:19 +0000 | |||
4 | @@ -60,13 +60,6 @@ | |||
5 | 60 | ) | 60 | ) |
6 | 61 | include_directories(${OFONO_INCLUDE_DIRS}) | 61 | include_directories(${OFONO_INCLUDE_DIRS}) |
7 | 62 | 62 | ||
8 | 63 | set(NOTIFY_REQUIRED_VERSION 0.7.5) | ||
9 | 64 | pkg_check_modules( | ||
10 | 65 | NOTIFY REQUIRED | ||
11 | 66 | libnotify>=${NOTIFY_REQUIRED_VERSION} | ||
12 | 67 | ) | ||
13 | 68 | include_directories(${NOTIFY_INCLUDE_DIRS}) | ||
14 | 69 | |||
15 | 70 | find_package(Qt5Core REQUIRED) | 63 | find_package(Qt5Core REQUIRED) |
16 | 71 | include_directories(${Qt5Core_INCLUDE_DIRS}) | 64 | include_directories(${Qt5Core_INCLUDE_DIRS}) |
17 | 72 | 65 | ||
18 | 73 | 66 | ||
19 | === modified file 'debian/control' | |||
20 | --- debian/control 2015-07-20 18:48:44 +0000 | |||
21 | +++ debian/control 2015-08-12 13:44:19 +0000 | |||
22 | @@ -12,7 +12,6 @@ | |||
23 | 12 | graphviz, | 12 | graphviz, |
24 | 13 | intltool, | 13 | intltool, |
25 | 14 | libglib2.0-dev, | 14 | libglib2.0-dev, |
26 | 15 | libnotify-dev, | ||
27 | 16 | #///! TODO: The next line should be removed once all dependancy on qmenumodel is removed | 15 | #///! TODO: The next line should be removed once all dependancy on qmenumodel is removed |
28 | 17 | libqmenumodel-dev, | 16 | libqmenumodel-dev, |
29 | 18 | libqofono-dev, | 17 | libqofono-dev, |
30 | 19 | 18 | ||
31 | === modified file 'src/indicator/CMakeLists.txt' | |||
32 | --- src/indicator/CMakeLists.txt 2015-07-28 08:27:11 +0000 | |||
33 | +++ src/indicator/CMakeLists.txt 2015-08-12 13:44:19 +0000 | |||
34 | @@ -101,7 +101,6 @@ | |||
35 | 101 | qpowerd | 101 | qpowerd |
36 | 102 | ${DBUSCPP_LIBRARIES} | 102 | ${DBUSCPP_LIBRARIES} |
37 | 103 | ${GLIB_LIBRARIES} | 103 | ${GLIB_LIBRARIES} |
38 | 104 | ${NOTIFY_LIBRARIES} | ||
39 | 105 | ${QOFONO_LIBRARIES} | 104 | ${QOFONO_LIBRARIES} |
40 | 106 | ) | 105 | ) |
41 | 107 | 106 | ||
42 | 108 | 107 | ||
43 | === modified file 'src/indicator/agent/PasswordMenu.cpp' | |||
44 | --- src/indicator/agent/PasswordMenu.cpp 2015-04-15 15:04:51 +0000 | |||
45 | +++ src/indicator/agent/PasswordMenu.cpp 2015-08-12 13:44:19 +0000 | |||
46 | @@ -19,9 +19,12 @@ | |||
47 | 19 | #include <agent/PasswordMenu.h> | 19 | #include <agent/PasswordMenu.h> |
48 | 20 | #include <gio/gio.h> | 20 | #include <gio/gio.h> |
49 | 21 | 21 | ||
50 | 22 | #include <iostream> | ||
51 | 22 | #include <QString> | 23 | #include <QString> |
52 | 23 | #include <QDebug> | 24 | #include <QDebug> |
53 | 24 | 25 | ||
54 | 26 | using namespace std; | ||
55 | 27 | |||
56 | 25 | namespace agent | 28 | namespace agent |
57 | 26 | { | 29 | { |
58 | 27 | namespace | 30 | namespace |
59 | @@ -51,7 +54,7 @@ | |||
60 | 51 | void passwordChanged(GVariant *variant) { | 54 | void passwordChanged(GVariant *variant) { |
61 | 52 | m_password = QString::fromUtf8(g_variant_get_string(variant, 0)); | 55 | m_password = QString::fromUtf8(g_variant_get_string(variant, 0)); |
62 | 53 | if (qEnvironmentVariableIsSet("SECRET_AGENT_DEBUG_PASSWORD")) { | 56 | if (qEnvironmentVariableIsSet("SECRET_AGENT_DEBUG_PASSWORD")) { |
64 | 54 | qDebug() << "Password received"; | 57 | cout << "Password received" << endl; |
65 | 55 | } | 58 | } |
66 | 56 | } | 59 | } |
67 | 57 | 60 | ||
68 | 58 | 61 | ||
69 | === modified file 'src/indicator/agent/SecretAgent.cpp' | |||
70 | --- src/indicator/agent/SecretAgent.cpp 2015-04-21 10:59:52 +0000 | |||
71 | +++ src/indicator/agent/SecretAgent.cpp 2015-08-12 13:44:19 +0000 | |||
72 | @@ -19,7 +19,7 @@ | |||
73 | 19 | #include <agent/SecretAgent.h> | 19 | #include <agent/SecretAgent.h> |
74 | 20 | #include <agent/SecretRequest.h> | 20 | #include <agent/SecretRequest.h> |
75 | 21 | #include <AgentManagerInterface.h> | 21 | #include <AgentManagerInterface.h> |
77 | 22 | #include <NotificationsInterface.h> | 22 | #include <notify-cpp/notification-manager.h> |
78 | 23 | #include <SecretAgentAdaptor.h> | 23 | #include <SecretAgentAdaptor.h> |
79 | 24 | 24 | ||
80 | 25 | #include <NetworkManager.h> | 25 | #include <NetworkManager.h> |
81 | @@ -34,13 +34,13 @@ | |||
82 | 34 | Q_OBJECT | 34 | Q_OBJECT |
83 | 35 | 35 | ||
84 | 36 | public: | 36 | public: |
86 | 37 | Priv(const QDBusConnection &systemConnection, | 37 | Priv(notify::NotificationManager::SPtr notificationManager, const QDBusConnection &systemConnection, |
87 | 38 | const QDBusConnection &sessionConnection) : | 38 | const QDBusConnection &sessionConnection) : |
88 | 39 | m_systemConnection(systemConnection), | 39 | m_systemConnection(systemConnection), |
89 | 40 | m_sessionConnection(sessionConnection), | 40 | m_sessionConnection(sessionConnection), |
90 | 41 | m_managerWatcher(NM_DBUS_SERVICE, m_systemConnection), | 41 | m_managerWatcher(NM_DBUS_SERVICE, m_systemConnection), |
91 | 42 | m_agentManager(NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), | 42 | m_agentManager(NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), |
93 | 43 | m_notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", m_sessionConnection), | 43 | m_notifications(notificationManager), |
94 | 44 | m_request(nullptr) { | 44 | m_request(nullptr) { |
95 | 45 | } | 45 | } |
96 | 46 | 46 | ||
97 | @@ -64,14 +64,15 @@ | |||
98 | 64 | 64 | ||
99 | 65 | OrgFreedesktopNetworkManagerAgentManagerInterface m_agentManager; | 65 | OrgFreedesktopNetworkManagerAgentManagerInterface m_agentManager; |
100 | 66 | 66 | ||
102 | 67 | OrgFreedesktopNotificationsInterface m_notifications; | 67 | notify::NotificationManager::SPtr m_notifications; |
103 | 68 | 68 | ||
104 | 69 | std::shared_ptr<SecretRequest> m_request; | 69 | std::shared_ptr<SecretRequest> m_request; |
105 | 70 | }; | 70 | }; |
106 | 71 | 71 | ||
108 | 72 | SecretAgent::SecretAgent(const QDBusConnection &systemConnection, | 72 | SecretAgent::SecretAgent(notify::NotificationManager::SPtr notificationManager, |
109 | 73 | const QDBusConnection &systemConnection, | ||
110 | 73 | const QDBusConnection &sessionConnection, QObject *parent) : | 74 | const QDBusConnection &sessionConnection, QObject *parent) : |
112 | 74 | QObject(parent), d(new Priv(systemConnection, sessionConnection)) | 75 | QObject(parent), d(new Priv(notificationManager, systemConnection, sessionConnection)) |
113 | 75 | { | 76 | { |
114 | 76 | // Memory managed by Qt | 77 | // Memory managed by Qt |
115 | 77 | new SecretAgentAdaptor(this); | 78 | new SecretAgentAdaptor(this); |
116 | @@ -182,7 +183,7 @@ | |||
117 | 182 | Q_UNUSED(connectionPath); | 183 | Q_UNUSED(connectionPath); |
118 | 183 | } | 184 | } |
119 | 184 | 185 | ||
121 | 185 | OrgFreedesktopNotificationsInterface & SecretAgent::notifications() { | 186 | notify::NotificationManager::SPtr SecretAgent::notifications() { |
122 | 186 | return d->m_notifications; | 187 | return d->m_notifications; |
123 | 187 | } | 188 | } |
124 | 188 | 189 | ||
125 | 189 | 190 | ||
126 | === modified file 'src/indicator/agent/SecretAgent.h' | |||
127 | --- src/indicator/agent/SecretAgent.h 2015-04-21 10:59:52 +0000 | |||
128 | +++ src/indicator/agent/SecretAgent.h 2015-08-12 13:44:19 +0000 | |||
129 | @@ -26,9 +26,13 @@ | |||
130 | 26 | #include <QDBusContext> | 26 | #include <QDBusContext> |
131 | 27 | #include <QMap> | 27 | #include <QMap> |
132 | 28 | 28 | ||
133 | 29 | class OrgFreedesktopNotificationsInterface; | ||
134 | 30 | class SecretAgentAdaptor; | 29 | class SecretAgentAdaptor; |
135 | 31 | 30 | ||
136 | 31 | namespace notify | ||
137 | 32 | { | ||
138 | 33 | class NotificationManager; | ||
139 | 34 | } | ||
140 | 35 | |||
141 | 32 | namespace agent | 36 | namespace agent |
142 | 33 | { | 37 | { |
143 | 34 | 38 | ||
144 | @@ -58,8 +62,9 @@ | |||
145 | 58 | static constexpr char const* KEY_MGMT_WPA_PSK = "wpa-psk"; | 62 | static constexpr char const* KEY_MGMT_WPA_PSK = "wpa-psk"; |
146 | 59 | static constexpr char const* KEY_MGMT_NONE = "none"; | 63 | static constexpr char const* KEY_MGMT_NONE = "none"; |
147 | 60 | 64 | ||
150 | 61 | explicit SecretAgent(const QDBusConnection &systemConnection, | 65 | explicit SecretAgent(std::shared_ptr<notify::NotificationManager> notificationManager, |
151 | 62 | const QDBusConnection &sessionConnection, QObject *parent = 0); | 66 | const QDBusConnection &systemConnection, |
152 | 67 | const QDBusConnection &sessionConnection, QObject *parent = 0); | ||
153 | 63 | 68 | ||
154 | 64 | virtual ~SecretAgent(); | 69 | virtual ~SecretAgent(); |
155 | 65 | 70 | ||
156 | @@ -79,7 +84,7 @@ | |||
157 | 79 | void SaveSecrets(const QVariantDictMap &connection, | 84 | void SaveSecrets(const QVariantDictMap &connection, |
158 | 80 | const QDBusObjectPath &connectionPath); | 85 | const QDBusObjectPath &connectionPath); |
159 | 81 | 86 | ||
161 | 82 | OrgFreedesktopNotificationsInterface & notifications(); | 87 | std::shared_ptr<notify::NotificationManager> notifications(); |
162 | 83 | 88 | ||
163 | 84 | protected: | 89 | protected: |
164 | 85 | class Priv; | 90 | class Priv; |
165 | 86 | 91 | ||
166 | === modified file 'src/indicator/agent/SecretRequest.cpp' | |||
167 | --- src/indicator/agent/SecretRequest.cpp 2015-04-21 10:59:52 +0000 | |||
168 | +++ src/indicator/agent/SecretRequest.cpp 2015-08-12 13:44:19 +0000 | |||
169 | @@ -20,7 +20,7 @@ | |||
170 | 20 | #include <agent/SecretAgent.h> | 20 | #include <agent/SecretAgent.h> |
171 | 21 | #include <util/localisation.h> | 21 | #include <util/localisation.h> |
172 | 22 | 22 | ||
174 | 23 | #include <NotificationsInterface.h> | 23 | #include <notify-cpp/notification-manager.h> |
175 | 24 | 24 | ||
176 | 25 | namespace agent | 25 | namespace agent |
177 | 26 | { | 26 | { |
178 | @@ -35,12 +35,6 @@ | |||
179 | 35 | settingName), m_hints(hints), m_flags(flags), m_message( | 35 | settingName), m_hints(hints), m_flags(flags), m_message( |
180 | 36 | message), m_menu() { | 36 | message), m_menu() { |
181 | 37 | 37 | ||
182 | 38 | connect(&m_secretAgent.notifications(), | ||
183 | 39 | SIGNAL(ActionInvoked(uint, const QString &)), this, | ||
184 | 40 | SLOT(actionInvoked(uint, const QString &))); | ||
185 | 41 | |||
186 | 42 | connect(&m_secretAgent.notifications(), SIGNAL(NotificationClosed(uint, uint)), this, SLOT(notificationClosed(uint, uint))); | ||
187 | 43 | |||
188 | 44 | // indicate to the notification-daemon, that we want to use snap-decisions | 38 | // indicate to the notification-daemon, that we want to use snap-decisions |
189 | 45 | QVariantMap notificationHints; | 39 | QVariantMap notificationHints; |
190 | 46 | notificationHints["x-canonical-snap-decisions"] = "true"; | 40 | notificationHints["x-canonical-snap-decisions"] = "true"; |
191 | @@ -74,29 +68,28 @@ | |||
192 | 74 | subject = _("WEP"); | 68 | subject = _("WEP"); |
193 | 75 | } | 69 | } |
194 | 76 | 70 | ||
197 | 77 | m_notificationId = m_secretAgent.notifications().Notify("indicator-network", | 71 | m_notification = m_secretAgent.notifications()->notify( |
196 | 78 | 0, "wifi-full-secure", | ||
198 | 79 | title.arg(conn[SecretAgent::CONNECTION_ID].toString()), subject, | 72 | title.arg(conn[SecretAgent::CONNECTION_ID].toString()), subject, |
199 | 73 | "wifi-full-secure", | ||
200 | 80 | QStringList() << "connect_id" << _("Connect") << "cancel_id" | 74 | QStringList() << "connect_id" << _("Connect") << "cancel_id" |
201 | 81 | << _("Cancel"), notificationHints, 0); | 75 | << _("Cancel"), notificationHints, 0); |
202 | 76 | |||
203 | 77 | connect(m_notification.get(), ¬ify::Notification::actionInvoked, this, | ||
204 | 78 | &SecretRequest::actionInvoked); | ||
205 | 79 | |||
206 | 80 | connect(m_notification.get(), ¬ify::Notification::closed, this, | ||
207 | 81 | &SecretRequest::notificationClosed); | ||
208 | 82 | |||
209 | 83 | m_notification->show(); | ||
210 | 82 | } | 84 | } |
211 | 83 | 85 | ||
212 | 84 | SecretRequest::~SecretRequest() { | 86 | SecretRequest::~SecretRequest() { |
213 | 85 | /* Close the notification if it's open */ | ||
214 | 86 | if (m_notificationId != 0) { | ||
215 | 87 | m_secretAgent.notifications().CloseNotification(m_notificationId).waitForFinished(); | ||
216 | 88 | m_notificationId = 0; | ||
217 | 89 | } | ||
218 | 90 | } | 87 | } |
219 | 91 | 88 | ||
220 | 92 | /* Called when the user submits a password */ | 89 | /* Called when the user submits a password */ |
226 | 93 | void SecretRequest::actionInvoked(uint id, const QString &actionKey) { | 90 | void SecretRequest::actionInvoked(const QString &actionKey) { |
222 | 94 | // Ignore other requests' notifications | ||
223 | 95 | if (id != m_notificationId) { | ||
224 | 96 | return; | ||
225 | 97 | } | ||
227 | 98 | 91 | ||
229 | 99 | m_notificationId = 0; | 92 | m_notification.reset(); |
230 | 100 | 93 | ||
231 | 101 | if (actionKey != "connect_id") { | 94 | if (actionKey != "connect_id") { |
232 | 102 | m_secretAgent.FinishGetSecrets(*this, true); | 95 | m_secretAgent.FinishGetSecrets(*this, true); |
233 | @@ -121,15 +114,10 @@ | |||
234 | 121 | } | 114 | } |
235 | 122 | 115 | ||
236 | 123 | /* Called when the user closes the dialog */ | 116 | /* Called when the user closes the dialog */ |
238 | 124 | void SecretRequest::notificationClosed(uint id, uint reason) { | 117 | void SecretRequest::notificationClosed(uint reason) { |
239 | 125 | Q_UNUSED(reason); | 118 | Q_UNUSED(reason); |
240 | 126 | 119 | ||
247 | 127 | // Ignore other requests' notifications | 120 | m_notification.reset(); |
242 | 128 | if (id != m_notificationId) { | ||
243 | 129 | return; | ||
244 | 130 | } | ||
245 | 131 | |||
246 | 132 | m_notificationId = 0; | ||
248 | 133 | 121 | ||
249 | 134 | m_secretAgent.FinishGetSecrets(*this, true); | 122 | m_secretAgent.FinishGetSecrets(*this, true); |
250 | 135 | } | 123 | } |
251 | 136 | 124 | ||
252 | === modified file 'src/indicator/agent/SecretRequest.h' | |||
253 | --- src/indicator/agent/SecretRequest.h 2015-04-21 10:59:52 +0000 | |||
254 | +++ src/indicator/agent/SecretRequest.h 2015-08-12 13:44:19 +0000 | |||
255 | @@ -20,6 +20,7 @@ | |||
256 | 20 | 20 | ||
257 | 21 | #include <dbus-types.h> | 21 | #include <dbus-types.h> |
258 | 22 | #include <agent/PasswordMenu.h> | 22 | #include <agent/PasswordMenu.h> |
259 | 23 | #include <notify-cpp/notification.h> | ||
260 | 23 | 24 | ||
261 | 24 | #include <QDBusMessage> | 25 | #include <QDBusMessage> |
262 | 25 | #include <QDBusObjectPath> | 26 | #include <QDBusObjectPath> |
263 | @@ -42,8 +43,8 @@ | |||
264 | 42 | virtual ~SecretRequest(); | 43 | virtual ~SecretRequest(); |
265 | 43 | 44 | ||
266 | 44 | public Q_SLOTS: | 45 | public Q_SLOTS: |
269 | 45 | void actionInvoked(uint id, const QString &actionKey); | 46 | void actionInvoked(const QString &actionKey); |
270 | 46 | void notificationClosed(uint id, uint reason); | 47 | void notificationClosed(uint reason); |
271 | 47 | 48 | ||
272 | 48 | public: | 49 | public: |
273 | 49 | const QVariantDictMap & connection() const; | 50 | const QVariantDictMap & connection() const; |
274 | @@ -51,7 +52,7 @@ | |||
275 | 51 | const QDBusMessage & message() const; | 52 | const QDBusMessage & message() const; |
276 | 52 | 53 | ||
277 | 53 | protected: | 54 | protected: |
279 | 54 | unsigned int m_notificationId; | 55 | notify::Notification::UPtr m_notification; |
280 | 55 | 56 | ||
281 | 56 | SecretAgent &m_secretAgent; | 57 | SecretAgent &m_secretAgent; |
282 | 57 | 58 | ||
283 | 58 | 59 | ||
284 | === modified file 'src/indicator/factory.cpp' | |||
285 | --- src/indicator/factory.cpp 2015-04-15 15:04:51 +0000 | |||
286 | +++ src/indicator/factory.cpp 2015-08-12 13:44:19 +0000 | |||
287 | @@ -17,9 +17,11 @@ | |||
288 | 17 | * Pete Woods <pete.woods@canonical.com> | 17 | * Pete Woods <pete.woods@canonical.com> |
289 | 18 | */ | 18 | */ |
290 | 19 | 19 | ||
291 | 20 | #include <config.h> | ||
292 | 20 | #include <factory.h> | 21 | #include <factory.h> |
293 | 21 | 22 | ||
294 | 22 | #include <nmofono/manager-impl.h> | 23 | #include <nmofono/manager-impl.h> |
295 | 24 | #include <notify-cpp/notification-manager.h> | ||
296 | 23 | 25 | ||
297 | 24 | using namespace std; | 26 | using namespace std; |
298 | 25 | 27 | ||
299 | @@ -29,6 +31,17 @@ | |||
300 | 29 | 31 | ||
301 | 30 | SessionBus::Ptr m_sessionBus; | 32 | SessionBus::Ptr m_sessionBus; |
302 | 31 | 33 | ||
303 | 34 | notify::NotificationManager::SPtr m_notificationManager; | ||
304 | 35 | |||
305 | 36 | notify::NotificationManager::SPtr singletonNotificationManager() | ||
306 | 37 | { | ||
307 | 38 | if (!m_notificationManager) | ||
308 | 39 | { | ||
309 | 40 | m_notificationManager = make_shared<notify::NotificationManager>(GETTEXT_PACKAGE); | ||
310 | 41 | } | ||
311 | 42 | return m_notificationManager; | ||
312 | 43 | } | ||
313 | 44 | |||
314 | 32 | SessionBus::Ptr singletonSessionBus() | 45 | SessionBus::Ptr singletonSessionBus() |
315 | 33 | { | 46 | { |
316 | 34 | if (!m_sessionBus) | 47 | if (!m_sessionBus) |
317 | @@ -42,7 +55,9 @@ | |||
318 | 42 | { | 55 | { |
319 | 43 | if (!m_nmofono) | 56 | if (!m_nmofono) |
320 | 44 | { | 57 | { |
322 | 45 | m_nmofono = make_shared<nmofono::ManagerImpl>(QDBusConnection::systemBus()); | 58 | m_nmofono = make_shared<nmofono::ManagerImpl>( |
323 | 59 | singletonNotificationManager(), | ||
324 | 60 | QDBusConnection::systemBus()); | ||
325 | 46 | } | 61 | } |
326 | 47 | return m_nmofono; | 62 | return m_nmofono; |
327 | 48 | } | 63 | } |
328 | @@ -117,7 +132,8 @@ | |||
329 | 117 | 132 | ||
330 | 118 | agent::SecretAgent::UPtr Factory::newSecretAgent() | 133 | agent::SecretAgent::UPtr Factory::newSecretAgent() |
331 | 119 | { | 134 | { |
333 | 120 | return make_unique<agent::SecretAgent>(QDBusConnection::systemBus(), | 135 | return make_unique<agent::SecretAgent>(d->singletonNotificationManager(), |
334 | 136 | QDBusConnection::systemBus(), | ||
335 | 121 | QDBusConnection::sessionBus()); | 137 | QDBusConnection::sessionBus()); |
336 | 122 | } | 138 | } |
337 | 123 | 139 | ||
338 | 124 | 140 | ||
339 | === modified file 'src/indicator/main.cpp' | |||
340 | --- src/indicator/main.cpp 2015-08-10 09:30:04 +0000 | |||
341 | +++ src/indicator/main.cpp 2015-08-12 13:44:19 +0000 | |||
342 | @@ -28,7 +28,6 @@ | |||
343 | 28 | #include <ctime> | 28 | #include <ctime> |
344 | 29 | 29 | ||
345 | 30 | #include <glib.h> | 30 | #include <glib.h> |
346 | 31 | #include <libnotify/notify.h> | ||
347 | 32 | 31 | ||
348 | 33 | #include <config.h> | 32 | #include <config.h> |
349 | 34 | 33 | ||
350 | @@ -53,25 +52,17 @@ | |||
351 | 53 | bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); | 52 | bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); |
352 | 54 | textdomain(GETTEXT_PACKAGE); | 53 | textdomain(GETTEXT_PACKAGE); |
353 | 55 | 54 | ||
354 | 56 | notify_init(GETTEXT_PACKAGE); | ||
355 | 57 | |||
356 | 58 | if (argc == 2 && QString("--print-address") == argv[1]) | 55 | if (argc == 2 && QString("--print-address") == argv[1]) |
357 | 59 | { | 56 | { |
358 | 60 | qDebug() << QDBusConnection::systemBus().baseService(); | 57 | qDebug() << QDBusConnection::systemBus().baseService(); |
359 | 61 | } | 58 | } |
360 | 62 | 59 | ||
375 | 63 | int result = 0; | 60 | Factory factory; |
376 | 64 | { | 61 | auto menu = factory.newMenuBuilder(); |
377 | 65 | Factory factory; | 62 | auto secretAgent = factory.newSecretAgent(); |
378 | 66 | auto menu = factory.newMenuBuilder(); | 63 | auto connectivityService = factory.newConnectivityService(); |
379 | 67 | auto secretAgent = factory.newSecretAgent(); | 64 | |
380 | 68 | auto connectivityService = factory.newConnectivityService(); | 65 | QObject::connect(connectivityService.get(), &ConnectivityService::unlockAllModems, menu.get(), &MenuBuilder::unlockAllModems); |
381 | 69 | 66 | QObject::connect(connectivityService.get(), &ConnectivityService::unlockModem, menu.get(), &MenuBuilder::unlockModem); | |
382 | 70 | QObject::connect(connectivityService.get(), &ConnectivityService::unlockAllModems, menu.get(), &MenuBuilder::unlockAllModems); | 67 | return app.exec(); |
369 | 71 | QObject::connect(connectivityService.get(), &ConnectivityService::unlockModem, menu.get(), &MenuBuilder::unlockModem); | ||
370 | 72 | result = app.exec(); | ||
371 | 73 | } | ||
372 | 74 | notify_uninit(); | ||
373 | 75 | |||
374 | 76 | return result; | ||
383 | 77 | } | 68 | } |
384 | 78 | 69 | ||
385 | === modified file 'src/indicator/nmofono/manager-impl.cpp' | |||
386 | --- src/indicator/nmofono/manager-impl.cpp 2015-08-07 08:55:50 +0000 | |||
387 | +++ src/indicator/nmofono/manager-impl.cpp 2015-08-12 13:44:19 +0000 | |||
388 | @@ -31,6 +31,7 @@ | |||
389 | 31 | #include <qofono-qt5/qofonomodem.h> | 31 | #include <qofono-qt5/qofonomodem.h> |
390 | 32 | #undef slots | 32 | #undef slots |
391 | 33 | 33 | ||
392 | 34 | #include <notify-cpp/notification-manager.h> | ||
393 | 34 | #include <notify-cpp/snapdecision/sim-unlock.h> | 35 | #include <notify-cpp/snapdecision/sim-unlock.h> |
394 | 35 | #include <sim-unlock-dialog.h> | 36 | #include <sim-unlock-dialog.h> |
395 | 36 | #include <util/qhash-sharedptr.h> | 37 | #include <util/qhash-sharedptr.h> |
396 | @@ -224,11 +225,11 @@ | |||
397 | 224 | Q_EMIT statusUpdated(d->m_status); | 225 | Q_EMIT statusUpdated(d->m_status); |
398 | 225 | } | 226 | } |
399 | 226 | 227 | ||
401 | 227 | ManagerImpl::ManagerImpl(const QDBusConnection& systemConnection) : d(new ManagerImpl::Private(*this)) | 228 | ManagerImpl::ManagerImpl(notify::NotificationManager::SPtr notificationManager, const QDBusConnection& systemConnection) : d(new ManagerImpl::Private(*this)) |
402 | 228 | { | 229 | { |
403 | 229 | d->nm = make_shared<OrgFreedesktopNetworkManagerInterface>(NM_DBUS_SERVICE, NM_DBUS_PATH, systemConnection); | 230 | d->nm = make_shared<OrgFreedesktopNetworkManagerInterface>(NM_DBUS_SERVICE, NM_DBUS_PATH, systemConnection); |
404 | 230 | 231 | ||
406 | 231 | d->m_unlockDialog = make_shared<SimUnlockDialog>(); | 232 | d->m_unlockDialog = make_shared<SimUnlockDialog>(notificationManager); |
407 | 232 | connect(d->m_unlockDialog.get(), &SimUnlockDialog::ready, d.get(), &Private::sim_unlock_ready); | 233 | connect(d->m_unlockDialog.get(), &SimUnlockDialog::ready, d.get(), &Private::sim_unlock_ready); |
408 | 233 | 234 | ||
409 | 234 | d->m_ofono = make_shared<QOfonoManager>(); | 235 | d->m_ofono = make_shared<QOfonoManager>(); |
410 | 235 | 236 | ||
411 | === modified file 'src/indicator/nmofono/manager-impl.h' | |||
412 | --- src/indicator/nmofono/manager-impl.h 2015-08-05 15:14:28 +0000 | |||
413 | +++ src/indicator/nmofono/manager-impl.h 2015-08-12 13:44:19 +0000 | |||
414 | @@ -25,6 +25,11 @@ | |||
415 | 25 | #include <QDBusObjectPath> | 25 | #include <QDBusObjectPath> |
416 | 26 | #include <QVariantMap> | 26 | #include <QVariantMap> |
417 | 27 | 27 | ||
418 | 28 | namespace notify | ||
419 | 29 | { | ||
420 | 30 | class NotificationManager; | ||
421 | 31 | } | ||
422 | 32 | |||
423 | 28 | namespace nmofono { | 33 | namespace nmofono { |
424 | 29 | class Manager; | 34 | class Manager; |
425 | 30 | 35 | ||
426 | @@ -40,7 +45,7 @@ | |||
427 | 40 | public: | 45 | public: |
428 | 41 | typedef std::shared_ptr<ManagerImpl> Ptr; | 46 | typedef std::shared_ptr<ManagerImpl> Ptr; |
429 | 42 | 47 | ||
431 | 43 | ManagerImpl(const QDBusConnection& systemBus); | 48 | ManagerImpl(std::shared_ptr<notify::NotificationManager> notificationManager, const QDBusConnection& systemBus); |
432 | 44 | 49 | ||
433 | 45 | // Public API | 50 | // Public API |
434 | 46 | void setFlightMode(bool) override; | 51 | void setFlightMode(bool) override; |
435 | 47 | 52 | ||
436 | === modified file 'src/indicator/sim-unlock-dialog.cpp' | |||
437 | --- src/indicator/sim-unlock-dialog.cpp 2015-06-18 12:30:09 +0000 | |||
438 | +++ src/indicator/sim-unlock-dialog.cpp 2015-08-12 13:44:19 +0000 | |||
439 | @@ -19,7 +19,7 @@ | |||
440 | 19 | 19 | ||
441 | 20 | #include "sim-unlock-dialog.h" | 20 | #include "sim-unlock-dialog.h" |
442 | 21 | 21 | ||
444 | 22 | #include <notify-cpp/notification.h> | 22 | #include <notify-cpp/notification-manager.h> |
445 | 23 | #include <notify-cpp/snapdecision/sim-unlock.h> | 23 | #include <notify-cpp/snapdecision/sim-unlock.h> |
446 | 24 | #include <util/localisation.h> | 24 | #include <util/localisation.h> |
447 | 25 | 25 | ||
448 | @@ -196,7 +196,7 @@ | |||
449 | 196 | m_sd->showPopup(output.str(), closed); | 196 | m_sd->showPopup(output.str(), closed); |
450 | 197 | } | 197 | } |
451 | 198 | 198 | ||
453 | 199 | Private(SimUnlockDialog& parent); | 199 | Private(SimUnlockDialog& parent, notify::NotificationManager::SPtr); |
454 | 200 | 200 | ||
455 | 201 | public Q_SLOTS: | 201 | public Q_SLOTS: |
456 | 202 | void update(); | 202 | void update(); |
457 | @@ -205,8 +205,6 @@ | |||
458 | 205 | 205 | ||
459 | 206 | void pinEntered(const QString& pin); | 206 | void pinEntered(const QString& pin); |
460 | 207 | 207 | ||
461 | 208 | void closed(); | ||
462 | 209 | |||
463 | 210 | void reset(); | 208 | void reset(); |
464 | 211 | 209 | ||
465 | 212 | void pinSuccess() | 210 | void pinSuccess() |
466 | @@ -244,13 +242,12 @@ | |||
467 | 244 | } | 242 | } |
468 | 245 | }; | 243 | }; |
469 | 246 | 244 | ||
471 | 247 | SimUnlockDialog::Private::Private(SimUnlockDialog& parent) | 245 | SimUnlockDialog::Private::Private(SimUnlockDialog& parent, notify::NotificationManager::SPtr notificationManager) |
472 | 248 | : p(parent), m_doCleanUp{true} | 246 | : p(parent), m_doCleanUp{true} |
473 | 249 | { | 247 | { |
475 | 250 | m_sd = std::make_shared<notify::snapdecision::SimUnlock>(); | 248 | m_sd = make_shared<notify::snapdecision::SimUnlock>(notificationManager); |
476 | 251 | connect(m_sd.get(), ¬ify::snapdecision::SimUnlock::cancelled, this, &Private::cancelled); | 249 | connect(m_sd.get(), ¬ify::snapdecision::SimUnlock::cancelled, this, &Private::cancelled); |
477 | 252 | connect(m_sd.get(), ¬ify::snapdecision::SimUnlock::pinEntered, this, &Private::pinEntered); | 250 | connect(m_sd.get(), ¬ify::snapdecision::SimUnlock::pinEntered, this, &Private::pinEntered); |
478 | 253 | connect(m_sd.get(), ¬ify::snapdecision::SimUnlock::closed, this, &Private::closed); | ||
479 | 254 | 251 | ||
480 | 255 | reset(); | 252 | reset(); |
481 | 256 | } | 253 | } |
482 | @@ -310,6 +307,7 @@ | |||
483 | 310 | break; | 307 | break; |
484 | 311 | } | 308 | } |
485 | 312 | 309 | ||
486 | 310 | |||
487 | 313 | m_sd->setPinMinMax(lengths[type]); | 311 | m_sd->setPinMinMax(lengths[type]); |
488 | 314 | 312 | ||
489 | 315 | std::string attempts; | 313 | std::string attempts; |
490 | @@ -386,12 +384,6 @@ | |||
491 | 386 | void | 384 | void |
492 | 387 | SimUnlockDialog::Private::cancelled() | 385 | SimUnlockDialog::Private::cancelled() |
493 | 388 | { | 386 | { |
494 | 389 | m_sd->close(); | ||
495 | 390 | } | ||
496 | 391 | |||
497 | 392 | void | ||
498 | 393 | SimUnlockDialog::Private::closed() | ||
499 | 394 | { | ||
500 | 395 | reset(); | 387 | reset(); |
501 | 396 | } | 388 | } |
502 | 397 | 389 | ||
503 | @@ -421,8 +413,8 @@ | |||
504 | 421 | m_doCleanUp = true; | 413 | m_doCleanUp = true; |
505 | 422 | } | 414 | } |
506 | 423 | 415 | ||
509 | 424 | SimUnlockDialog::SimUnlockDialog() : | 416 | SimUnlockDialog::SimUnlockDialog(notify::NotificationManager::SPtr notificationManager) : |
510 | 425 | d(new Private(*this)) | 417 | d(new Private(*this, notificationManager)) |
511 | 426 | { | 418 | { |
512 | 427 | } | 419 | } |
513 | 428 | 420 | ||
514 | @@ -475,9 +467,6 @@ | |||
515 | 475 | pukRetries = retries[wwan::Modem::PinType::puk]; | 467 | pukRetries = retries[wwan::Modem::PinType::puk]; |
516 | 476 | } | 468 | } |
517 | 477 | 469 | ||
518 | 478 | qDebug() << __PRETTY_FUNCTION__ << modem->name() << "pinRetries =" | ||
519 | 479 | << pinRetries << "pukRetries =" << pukRetries; | ||
520 | 480 | |||
521 | 481 | // remind the user | 470 | // remind the user |
522 | 482 | if (type == wwan::Modem::PinType::pin && pinRetries == 1) | 471 | if (type == wwan::Modem::PinType::pin && pinRetries == 1) |
523 | 483 | { | 472 | { |
524 | 484 | 473 | ||
525 | === modified file 'src/indicator/sim-unlock-dialog.h' | |||
526 | --- src/indicator/sim-unlock-dialog.h 2015-04-24 08:47:08 +0000 | |||
527 | +++ src/indicator/sim-unlock-dialog.h 2015-08-12 13:44:19 +0000 | |||
528 | @@ -20,6 +20,7 @@ | |||
529 | 20 | #pragma once | 20 | #pragma once |
530 | 21 | 21 | ||
531 | 22 | #include <nmofono/wwan/modem.h> | 22 | #include <nmofono/wwan/modem.h> |
532 | 23 | #include <notify-cpp/notification-manager.h> | ||
533 | 23 | 24 | ||
534 | 24 | #include <memory> | 25 | #include <memory> |
535 | 25 | #include <QObject> | 26 | #include <QObject> |
536 | @@ -42,7 +43,7 @@ | |||
537 | 42 | }; | 43 | }; |
538 | 43 | 44 | ||
539 | 44 | typedef std::shared_ptr<SimUnlockDialog> Ptr; | 45 | typedef std::shared_ptr<SimUnlockDialog> Ptr; |
541 | 45 | SimUnlockDialog(); | 46 | SimUnlockDialog(notify::NotificationManager::SPtr notificationManager); |
542 | 46 | ~SimUnlockDialog(); | 47 | ~SimUnlockDialog(); |
543 | 47 | 48 | ||
544 | 48 | void unlock(nmofono::wwan::Modem::Ptr modem); | 49 | void unlock(nmofono::wwan::Modem::Ptr modem); |
545 | 49 | 50 | ||
546 | === modified file 'src/notify-cpp/CMakeLists.txt' | |||
547 | --- src/notify-cpp/CMakeLists.txt 2015-05-12 09:07:46 +0000 | |||
548 | +++ src/notify-cpp/CMakeLists.txt 2015-08-12 13:44:19 +0000 | |||
549 | @@ -1,12 +1,15 @@ | |||
550 | 1 | include_directories("${CMAKE_SOURCE_DIR}/src/") | 1 | include_directories("${CMAKE_SOURCE_DIR}/src/") |
551 | 2 | include_directories("${CMAKE_BINARY_DIR}/src/qdbus-stubs") | ||
552 | 3 | include_directories("${CMAKE_SOURCE_DIR}/src/qdbus-stubs") | ||
553 | 2 | 4 | ||
554 | 3 | set(NOTIFY_CPP_SOURCES | 5 | set(NOTIFY_CPP_SOURCES |
555 | 4 | notification.cpp | 6 | notification.cpp |
556 | 7 | notification-manager.cpp | ||
557 | 5 | snapdecision/sim-unlock.cpp | 8 | snapdecision/sim-unlock.cpp |
558 | 6 | ) | 9 | ) |
559 | 7 | 10 | ||
560 | 8 | add_library(notify_cpp STATIC ${NOTIFY_CPP_SOURCES}) | 11 | add_library(notify_cpp STATIC ${NOTIFY_CPP_SOURCES}) |
561 | 9 | target_link_libraries( | 12 | target_link_libraries( |
562 | 10 | notify_cpp | 13 | notify_cpp |
564 | 11 | ${GLIB_LIBRARIES} | 14 | qdbus-stubs |
565 | 12 | ) | 15 | ) |
566 | 13 | 16 | ||
567 | === added file 'src/notify-cpp/notification-manager.cpp' | |||
568 | --- src/notify-cpp/notification-manager.cpp 1970-01-01 00:00:00 +0000 | |||
569 | +++ src/notify-cpp/notification-manager.cpp 2015-08-12 13:44:19 +0000 | |||
570 | @@ -0,0 +1,76 @@ | |||
571 | 1 | /* | ||
572 | 2 | * Copyright © 2015 Canonical Ltd. | ||
573 | 3 | * | ||
574 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
575 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
576 | 6 | * as published by the Free Software Foundation. | ||
577 | 7 | * | ||
578 | 8 | * This program is distributed in the hope that it will be useful, | ||
579 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
580 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
581 | 11 | * GNU Lesser General Public License for more details. | ||
582 | 12 | * | ||
583 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
584 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
585 | 15 | * | ||
586 | 16 | * Authors: | ||
587 | 17 | * Pete Woods <pete.woods@canonical.com> | ||
588 | 18 | */ | ||
589 | 19 | |||
590 | 20 | #include <notification-manager.h> | ||
591 | 21 | #include <NotificationsInterface.h> | ||
592 | 22 | #include <QDebug> | ||
593 | 23 | |||
594 | 24 | using namespace std; | ||
595 | 25 | |||
596 | 26 | namespace notify | ||
597 | 27 | { | ||
598 | 28 | |||
599 | 29 | class NotificationManager::Priv | ||
600 | 30 | { | ||
601 | 31 | public: | ||
602 | 32 | QString m_appName; | ||
603 | 33 | |||
604 | 34 | shared_ptr<OrgFreedesktopNotificationsInterface> m_notificationInterface; | ||
605 | 35 | }; | ||
606 | 36 | |||
607 | 37 | NotificationManager::NotificationManager(const QString &appName, | ||
608 | 38 | const QDBusConnection& sessionConnection) : | ||
609 | 39 | d(new Priv) | ||
610 | 40 | { | ||
611 | 41 | d->m_appName = appName; | ||
612 | 42 | d->m_notificationInterface = make_shared< | ||
613 | 43 | OrgFreedesktopNotificationsInterface>(DBusTypes::NOTIFY_DBUS_NAME, | ||
614 | 44 | DBusTypes::NOTIFY_DBUS_PATH, | ||
615 | 45 | sessionConnection); | ||
616 | 46 | |||
617 | 47 | d->m_notificationInterface->GetServerInformation(); | ||
618 | 48 | |||
619 | 49 | connect(d->m_notificationInterface.get(), | ||
620 | 50 | &OrgFreedesktopNotificationsInterface::ActionInvoked, this, | ||
621 | 51 | &NotificationManager::actionInvoked); | ||
622 | 52 | |||
623 | 53 | connect(d->m_notificationInterface.get(), | ||
624 | 54 | &OrgFreedesktopNotificationsInterface::NotificationClosed, this, | ||
625 | 55 | &NotificationManager::notificationClosed); | ||
626 | 56 | |||
627 | 57 | connect(d->m_notificationInterface.get(), | ||
628 | 58 | &OrgFreedesktopNotificationsInterface::dataChanged, this, | ||
629 | 59 | &NotificationManager::dataChanged); | ||
630 | 60 | } | ||
631 | 61 | |||
632 | 62 | NotificationManager::~NotificationManager() | ||
633 | 63 | { | ||
634 | 64 | } | ||
635 | 65 | |||
636 | 66 | Notification::UPtr | ||
637 | 67 | NotificationManager::notify(const QString &summary, const QString &body, | ||
638 | 68 | const QString &icon, const QStringList &actions, | ||
639 | 69 | const QVariantMap &hints, int expireTimeout) | ||
640 | 70 | { | ||
641 | 71 | return make_unique<Notification>(d->m_appName, summary, body, icon, actions, | ||
642 | 72 | hints, expireTimeout, | ||
643 | 73 | d->m_notificationInterface); | ||
644 | 74 | } | ||
645 | 75 | |||
646 | 76 | } | ||
647 | 0 | 77 | ||
648 | === added file 'src/notify-cpp/notification-manager.h' | |||
649 | --- src/notify-cpp/notification-manager.h 1970-01-01 00:00:00 +0000 | |||
650 | +++ src/notify-cpp/notification-manager.h 2015-08-12 13:44:19 +0000 | |||
651 | @@ -0,0 +1,67 @@ | |||
652 | 1 | /* | ||
653 | 2 | * Copyright © 2015 Canonical Ltd. | ||
654 | 3 | * | ||
655 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
656 | 5 | * under the terms of the GNU Lesser General Public License version 3, | ||
657 | 6 | * as published by the Free Software Foundation. | ||
658 | 7 | * | ||
659 | 8 | * This program is distributed in the hope that it will be useful, | ||
660 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
661 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
662 | 11 | * GNU Lesser General Public License for more details. | ||
663 | 12 | * | ||
664 | 13 | * You should have received a copy of the GNU Lesser General Public License | ||
665 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
666 | 15 | * | ||
667 | 16 | * Authors: | ||
668 | 17 | * Pete Woods <pete.woods@canonical.com> | ||
669 | 18 | */ | ||
670 | 19 | |||
671 | 20 | #pragma once | ||
672 | 21 | |||
673 | 22 | #include <memory> | ||
674 | 23 | #include <QDBusConnection> | ||
675 | 24 | #include <QObject> | ||
676 | 25 | #include <QString> | ||
677 | 26 | #include <QStringList> | ||
678 | 27 | #include <QVariantMap> | ||
679 | 28 | |||
680 | 29 | #include <notify-cpp/notification.h> | ||
681 | 30 | |||
682 | 31 | namespace notify | ||
683 | 32 | { | ||
684 | 33 | |||
685 | 34 | class NotificationManager: public QObject | ||
686 | 35 | { | ||
687 | 36 | Q_OBJECT | ||
688 | 37 | |||
689 | 38 | public: | ||
690 | 39 | typedef std::unique_ptr<NotificationManager> UPtr; | ||
691 | 40 | typedef std::shared_ptr<NotificationManager> SPtr; | ||
692 | 41 | |||
693 | 42 | NotificationManager(const QString &appName, | ||
694 | 43 | const QDBusConnection& sessionConnection = QDBusConnection::sessionBus()); | ||
695 | 44 | |||
696 | 45 | ~NotificationManager(); | ||
697 | 46 | |||
698 | 47 | Notification::UPtr notify( | ||
699 | 48 | const QString &summary, | ||
700 | 49 | const QString &body, | ||
701 | 50 | const QString &icon, | ||
702 | 51 | const QStringList &actions, | ||
703 | 52 | const QVariantMap &hints, | ||
704 | 53 | int expireTimeout = -1); | ||
705 | 54 | |||
706 | 55 | Q_SIGNALS: | ||
707 | 56 | void actionInvoked(uint id, const QString &action_key); | ||
708 | 57 | |||
709 | 58 | void notificationClosed(uint id, uint reason); | ||
710 | 59 | |||
711 | 60 | void dataChanged(uint id); | ||
712 | 61 | |||
713 | 62 | protected: | ||
714 | 63 | class Priv; | ||
715 | 64 | std::shared_ptr<Priv> d; | ||
716 | 65 | }; | ||
717 | 66 | |||
718 | 67 | } | ||
719 | 0 | 68 | ||
720 | === modified file 'src/notify-cpp/notification.cpp' | |||
721 | --- src/notify-cpp/notification.cpp 2015-05-12 09:03:23 +0000 | |||
722 | +++ src/notify-cpp/notification.cpp 2015-08-12 13:44:19 +0000 | |||
723 | @@ -18,14 +18,17 @@ | |||
724 | 18 | */ | 18 | */ |
725 | 19 | 19 | ||
726 | 20 | #include "notification.h" | 20 | #include "notification.h" |
727 | 21 | #include <NotificationsInterface.h> | ||
728 | 21 | 22 | ||
729 | 22 | #include <libnotify/notify.h> | ||
730 | 23 | #include <QDebug> | 23 | #include <QDebug> |
731 | 24 | 24 | ||
732 | 25 | using namespace notify; | 25 | using namespace notify; |
733 | 26 | using namespace std; | ||
734 | 26 | 27 | ||
736 | 27 | class notify::Notification::Private | 28 | class notify::Notification::Private: public QObject |
737 | 28 | { | 29 | { |
738 | 30 | Q_OBJECT | ||
739 | 31 | |||
740 | 29 | public: | 32 | public: |
741 | 30 | Private(Notification& parent) : | 33 | Private(Notification& parent) : |
742 | 31 | p(parent) | 34 | p(parent) |
743 | @@ -34,76 +37,135 @@ | |||
744 | 34 | 37 | ||
745 | 35 | Notification& p; | 38 | Notification& p; |
746 | 36 | 39 | ||
747 | 40 | QString m_appName; | ||
748 | 37 | QString m_summary; | 41 | QString m_summary; |
749 | 38 | QString m_body; | 42 | QString m_body; |
750 | 39 | QString m_icon; | 43 | QString m_icon; |
762 | 40 | 44 | QStringList m_actions; | |
763 | 41 | std::unique_ptr<NotifyNotification, GObjectDeleter> m_notification; | 45 | QVariantMap m_hints; |
764 | 42 | 46 | int m_expireTimeout = 0; | |
765 | 43 | static void closed_cb(NotifyNotification *, | 47 | uint m_id = 0; |
766 | 44 | gpointer user_data) | 48 | |
767 | 45 | { | 49 | shared_ptr<OrgFreedesktopNotificationsInterface> m_notificationsInterface; |
768 | 46 | Private *that = static_cast<Private *>(user_data); | 50 | |
769 | 47 | Q_EMIT that->p.closed(); | 51 | bool m_open = false; |
770 | 48 | } | 52 | bool m_dirty = false; |
771 | 49 | 53 | ||
772 | 50 | gulong disconnectId = 0; | 54 | public Q_SLOTS: |
773 | 55 | void notificationClosed(uint id, uint reason) | ||
774 | 56 | { | ||
775 | 57 | if (id == m_id) | ||
776 | 58 | { | ||
777 | 59 | m_open = false; | ||
778 | 60 | Q_EMIT p.closed(reason); | ||
779 | 61 | } | ||
780 | 62 | } | ||
781 | 63 | |||
782 | 64 | void actionInvoked(uint id, const QString& name) | ||
783 | 65 | { | ||
784 | 66 | if (id == m_id) | ||
785 | 67 | { | ||
786 | 68 | Q_EMIT p.actionInvoked(name); | ||
787 | 69 | } | ||
788 | 70 | } | ||
789 | 51 | }; | 71 | }; |
790 | 52 | 72 | ||
794 | 53 | Notification::Notification(const QString &summary, | 73 | Notification::Notification( |
795 | 54 | const QString &body, | 74 | const QString& appName, const QString &summary, const QString &body, |
796 | 55 | const QString &icon) | 75 | const QString &icon, const QStringList &actions, |
797 | 76 | const QVariantMap &hints, int expireTimeout, | ||
798 | 77 | shared_ptr<OrgFreedesktopNotificationsInterface> notificationsInterface) | ||
799 | 56 | { | 78 | { |
800 | 57 | d.reset(new Private(*this)); | 79 | d.reset(new Private(*this)); |
801 | 80 | d->m_appName = appName; | ||
802 | 58 | d->m_summary = summary; | 81 | d->m_summary = summary; |
803 | 59 | d->m_body = body; | 82 | d->m_body = body; |
804 | 60 | d->m_icon = icon; | 83 | d->m_icon = icon; |
808 | 61 | 84 | d->m_actions = actions; | |
809 | 62 | d->m_notification.reset(notify_notification_new(summary.toUtf8().constData(), body.toUtf8().constData(), icon.toUtf8().constData())); | 85 | d->m_hints = hints; |
810 | 63 | d->disconnectId = g_signal_connect(d->m_notification.get(), "closed", G_CALLBACK(Private::closed_cb), d.get()); | 86 | d->m_expireTimeout = expireTimeout; |
811 | 87 | d->m_notificationsInterface = notificationsInterface; | ||
812 | 88 | |||
813 | 89 | connect(d->m_notificationsInterface.get(), &OrgFreedesktopNotificationsInterface::NotificationClosed, d.get(), &Private::notificationClosed); | ||
814 | 90 | |||
815 | 91 | connect(d->m_notificationsInterface.get(), &OrgFreedesktopNotificationsInterface::ActionInvoked, d.get(), &Private::actionInvoked); | ||
816 | 64 | } | 92 | } |
817 | 65 | 93 | ||
818 | 66 | Notification::~Notification() | 94 | Notification::~Notification() |
819 | 67 | { | 95 | { |
829 | 68 | g_signal_handler_disconnect(d->m_notification.get(), d->disconnectId); | 96 | if (d->m_id > 0 && d->m_open) |
830 | 69 | 97 | { | |
831 | 70 | // TODO Uncomment this when the notification service is more robust | 98 | auto reply = d->m_notificationsInterface->CloseNotification(d->m_id); |
832 | 71 | // GError* error = nullptr; | 99 | reply.waitForFinished(); |
833 | 72 | // if (notify_notification_close(d->m_notification.get(), &error) == FALSE) | 100 | if (reply.isError()) |
834 | 73 | // { | 101 | { |
835 | 74 | // qWarning() << __PRETTY_FUNCTION__ << error->message; | 102 | qCritical() << __PRETTY_FUNCTION__ << reply.error().message(); |
836 | 75 | // g_error_free(error); | 103 | } |
837 | 76 | // } | 104 | } |
838 | 77 | } | 105 | } |
839 | 78 | 106 | ||
840 | 79 | QString | 107 | QString |
842 | 80 | Notification::summary() | 108 | Notification::summary() const |
843 | 81 | { | 109 | { |
844 | 82 | return d->m_summary; | 110 | return d->m_summary; |
845 | 83 | } | 111 | } |
846 | 84 | 112 | ||
847 | 85 | QString | 113 | QString |
849 | 86 | Notification::body() | 114 | Notification::body() const |
850 | 87 | { | 115 | { |
851 | 88 | return d->m_body; | 116 | return d->m_body; |
852 | 89 | } | 117 | } |
853 | 90 | 118 | ||
854 | 91 | QString | 119 | QString |
856 | 92 | Notification::icon() | 120 | Notification::icon() const |
857 | 93 | { | 121 | { |
858 | 94 | return d->m_icon; | 122 | return d->m_icon; |
859 | 95 | } | 123 | } |
860 | 96 | 124 | ||
871 | 97 | void | 125 | QStringList |
872 | 98 | Notification::setHint(const QString &key, Variant value) | 126 | Notification::actions() const |
873 | 99 | { | 127 | { |
874 | 100 | notify_notification_set_hint(d->m_notification.get(), key.toUtf8().constData(), value); | 128 | return d->m_actions; |
875 | 101 | } | 129 | } |
876 | 102 | 130 | ||
877 | 103 | void | 131 | QVariantMap |
878 | 104 | Notification::setHintString(const QString &key, const QString &value) | 132 | Notification::hints() const |
879 | 105 | { | 133 | { |
880 | 106 | notify_notification_set_hint_string(d->m_notification.get(), key.toUtf8().constData(), value.toUtf8().constData()); | 134 | return d->m_hints; |
881 | 135 | } | ||
882 | 136 | |||
883 | 137 | void | ||
884 | 138 | Notification::addHint(const QString &key, const QVariant& value) | ||
885 | 139 | { | ||
886 | 140 | d->m_hints[key] = value; | ||
887 | 141 | d->m_dirty = true; | ||
888 | 142 | Q_EMIT hintsUpdated(d->m_hints); | ||
889 | 143 | } | ||
890 | 144 | |||
891 | 145 | void | ||
892 | 146 | Notification::setHints(const QVariantMap& hints) | ||
893 | 147 | { | ||
894 | 148 | if (d->m_hints == hints) | ||
895 | 149 | { | ||
896 | 150 | return; | ||
897 | 151 | } | ||
898 | 152 | |||
899 | 153 | d->m_hints = hints; | ||
900 | 154 | d->m_dirty = true; | ||
901 | 155 | Q_EMIT hintsUpdated(d->m_hints); | ||
902 | 156 | } | ||
903 | 157 | |||
904 | 158 | void | ||
905 | 159 | Notification::setActions(const QStringList& actions) | ||
906 | 160 | { | ||
907 | 161 | if (d->m_actions == actions) | ||
908 | 162 | { | ||
909 | 163 | return; | ||
910 | 164 | } | ||
911 | 165 | |||
912 | 166 | d->m_actions = actions; | ||
913 | 167 | d->m_dirty = true; | ||
914 | 168 | Q_EMIT actionsUpdated(d->m_actions); | ||
915 | 107 | } | 169 | } |
916 | 108 | 170 | ||
917 | 109 | void | 171 | void |
918 | @@ -115,7 +177,7 @@ | |||
919 | 115 | } | 177 | } |
920 | 116 | 178 | ||
921 | 117 | d->m_summary = summary; | 179 | d->m_summary = summary; |
923 | 118 | g_object_set(d->m_notification.get(), "summary", d->m_summary.toUtf8().constData(), nullptr); | 180 | d->m_dirty = true; |
924 | 119 | Q_EMIT summaryUpdated(d->m_summary); | 181 | Q_EMIT summaryUpdated(d->m_summary); |
925 | 120 | } | 182 | } |
926 | 121 | 183 | ||
927 | @@ -128,7 +190,7 @@ | |||
928 | 128 | } | 190 | } |
929 | 129 | 191 | ||
930 | 130 | d->m_body = body; | 192 | d->m_body = body; |
932 | 131 | g_object_set(d->m_notification.get(), "body", d->m_body.toUtf8().constData(), nullptr); | 193 | d->m_dirty = true; |
933 | 132 | Q_EMIT bodyUpdated(d->m_body); | 194 | Q_EMIT bodyUpdated(d->m_body); |
934 | 133 | } | 195 | } |
935 | 134 | 196 | ||
936 | @@ -141,35 +203,50 @@ | |||
937 | 141 | } | 203 | } |
938 | 142 | 204 | ||
939 | 143 | d->m_icon = icon; | 205 | d->m_icon = icon; |
941 | 144 | g_object_set(d->m_notification.get(), "icon", d->m_icon.toUtf8().constData(), nullptr); | 206 | d->m_dirty = true; |
942 | 145 | Q_EMIT iconUpdated(d->m_icon); | 207 | Q_EMIT iconUpdated(d->m_icon); |
943 | 146 | } | 208 | } |
944 | 147 | 209 | ||
945 | 148 | void | 210 | void |
946 | 149 | Notification::update() | ||
947 | 150 | { | ||
948 | 151 | notify_notification_update(d->m_notification.get(), d->m_summary.toUtf8().constData(), | ||
949 | 152 | d->m_body.toUtf8().constData(), d->m_icon.toUtf8().constData()); | ||
950 | 153 | } | ||
951 | 154 | |||
952 | 155 | void | ||
953 | 156 | Notification::show() | 211 | Notification::show() |
954 | 157 | { | 212 | { |
960 | 158 | GError *error = nullptr; | 213 | if (d->m_dirty || !d->m_open) |
961 | 159 | notify_notification_show(d->m_notification.get(), &error); | 214 | { |
962 | 160 | if (error) { | 215 | auto reply = d->m_notificationsInterface->Notify(d->m_appName, d->m_id, |
963 | 161 | qCritical() << __PRETTY_FUNCTION__ << error->message; | 216 | d->m_icon, d->m_summary, |
964 | 162 | g_error_free(error); | 217 | d->m_body, d->m_actions, |
965 | 218 | d->m_hints, | ||
966 | 219 | d->m_expireTimeout); | ||
967 | 220 | reply.waitForFinished(); | ||
968 | 221 | if (reply.isError()) | ||
969 | 222 | { | ||
970 | 223 | qCritical() << __PRETTY_FUNCTION__ << reply.error().message(); | ||
971 | 224 | } | ||
972 | 225 | else | ||
973 | 226 | { | ||
974 | 227 | d->m_id = reply; | ||
975 | 228 | d->m_dirty = false; | ||
976 | 229 | d->m_open = true; | ||
977 | 230 | } | ||
978 | 163 | } | 231 | } |
979 | 164 | } | 232 | } |
980 | 165 | 233 | ||
981 | 166 | void | 234 | void |
982 | 167 | Notification::close() | 235 | Notification::close() |
983 | 168 | { | 236 | { |
989 | 169 | GError *error = nullptr; | 237 | if (d->m_id > 0) |
990 | 170 | notify_notification_close(d->m_notification.get(), &error); | 238 | { |
991 | 171 | if (error) { | 239 | auto reply = d->m_notificationsInterface->CloseNotification(d->m_id); |
992 | 172 | qCritical() << __PRETTY_FUNCTION__ << error->message; | 240 | reply.waitForFinished(); |
993 | 173 | g_error_free(error); | 241 | if (reply.isError()) |
994 | 242 | { | ||
995 | 243 | qCritical() << __PRETTY_FUNCTION__ << reply.error().message(); | ||
996 | 244 | } | ||
997 | 245 | else | ||
998 | 246 | { | ||
999 | 247 | d->m_open = false; | ||
1000 | 248 | } | ||
1001 | 174 | } | 249 | } |
1002 | 175 | } | 250 | } |
1003 | 251 | |||
1004 | 252 | #include "notification.moc" | ||
1005 | 176 | 253 | ||
1006 | === modified file 'src/notify-cpp/notification.h' | |||
1007 | --- src/notify-cpp/notification.h 2015-04-24 08:47:08 +0000 | |||
1008 | +++ src/notify-cpp/notification.h 2015-08-12 13:44:19 +0000 | |||
1009 | @@ -25,7 +25,12 @@ | |||
1010 | 25 | 25 | ||
1011 | 26 | #include <QObject> | 26 | #include <QObject> |
1012 | 27 | 27 | ||
1014 | 28 | namespace notify { | 28 | class OrgFreedesktopNotificationsInterface; |
1015 | 29 | |||
1016 | 30 | namespace notify | ||
1017 | 31 | { | ||
1018 | 32 | |||
1019 | 33 | class NotificationManager; | ||
1020 | 29 | 34 | ||
1021 | 30 | class Notification: public QObject | 35 | class Notification: public QObject |
1022 | 31 | { | 36 | { |
1023 | @@ -36,35 +41,38 @@ | |||
1024 | 36 | 41 | ||
1025 | 37 | public: | 42 | public: |
1026 | 38 | 43 | ||
1028 | 39 | typedef std::shared_ptr<Notification> Ptr; | 44 | typedef std::unique_ptr<Notification> UPtr; |
1029 | 45 | typedef std::shared_ptr<Notification> SPtr; | ||
1030 | 40 | 46 | ||
1031 | 41 | Notification() = delete; | ||
1032 | 42 | Notification(const QString &summary, | ||
1033 | 43 | const QString &body, | ||
1034 | 44 | const QString &icon); | ||
1035 | 45 | virtual ~Notification(); | 47 | virtual ~Notification(); |
1036 | 46 | 48 | ||
1037 | 47 | /// @todo remember show() after set(). | 49 | /// @todo remember show() after set(). |
1050 | 48 | Q_PROPERTY(QString summary READ summary NOTIFY summaryUpdated) | 50 | Q_PROPERTY(QString summary READ summary WRITE setSummary NOTIFY summaryUpdated) |
1051 | 49 | QString summary(); | 51 | QString summary() const; |
1052 | 50 | 52 | ||
1053 | 51 | /// @todo remember show() after set(). | 53 | /// @todo remember show() after set(). |
1054 | 52 | Q_PROPERTY(QString body READ body NOTIFY bodyUpdated) | 54 | Q_PROPERTY(QString body READ body WRITE setBody NOTIFY bodyUpdated) |
1055 | 53 | QString body(); | 55 | QString body() const; |
1056 | 54 | 56 | ||
1057 | 55 | /// @todo remember show() after set(). | 57 | /// @todo remember show() after set(). |
1058 | 56 | Q_PROPERTY(QString icon READ icon NOTIFY iconUpdated) | 58 | Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY iconUpdated) |
1059 | 57 | QString icon(); | 59 | QString icon() const; |
1060 | 58 | 60 | ||
1061 | 59 | void update(); | 61 | Q_PROPERTY(QStringList actions READ actions WRITE setActions NOTIFY actionsUpdated) |
1062 | 62 | QStringList actions() const; | ||
1063 | 63 | |||
1064 | 64 | Q_PROPERTY(QVariantMap hints READ hints WRITE setHints NOTIFY hintsUpdated) | ||
1065 | 65 | QVariantMap hints() const; | ||
1066 | 60 | 66 | ||
1067 | 61 | void show(); | 67 | void show(); |
1068 | 62 | void close(); | 68 | void close(); |
1069 | 63 | 69 | ||
1070 | 64 | public Q_SLOTS: | 70 | public Q_SLOTS: |
1074 | 65 | void setHint(const QString &key, Variant value); | 71 | void setActions(const QStringList& actions); |
1075 | 66 | 72 | ||
1076 | 67 | void setHintString(const QString &key, const QString &value); | 73 | void setHints(const QVariantMap& hints); |
1077 | 74 | |||
1078 | 75 | void addHint(const QString &key, const QVariant& value); | ||
1079 | 68 | 76 | ||
1080 | 69 | void setSummary(const QString& summary); | 77 | void setSummary(const QString& summary); |
1081 | 70 | 78 | ||
1082 | @@ -73,12 +81,25 @@ | |||
1083 | 73 | void setIcon(const QString& icon); | 81 | void setIcon(const QString& icon); |
1084 | 74 | 82 | ||
1085 | 75 | Q_SIGNALS: | 83 | Q_SIGNALS: |
1087 | 76 | void closed(); | 84 | void closed(uint reason); |
1088 | 85 | |||
1089 | 86 | void hintsUpdated(const QVariantMap&); | ||
1090 | 87 | |||
1091 | 88 | void actionsUpdated(const QStringList&); | ||
1092 | 77 | 89 | ||
1093 | 78 | void summaryUpdated(const QString&); | 90 | void summaryUpdated(const QString&); |
1094 | 79 | 91 | ||
1095 | 80 | void bodyUpdated(const QString&); | 92 | void bodyUpdated(const QString&); |
1096 | 81 | 93 | ||
1097 | 82 | void iconUpdated(const QString&); | 94 | void iconUpdated(const QString&); |
1098 | 95 | |||
1099 | 96 | void actionInvoked(const QString& name); | ||
1100 | 97 | |||
1101 | 98 | public: | ||
1102 | 99 | Notification(const QString& appName, | ||
1103 | 100 | const QString &summary, const QString &body, | ||
1104 | 101 | const QString &icon, const QStringList &actions, | ||
1105 | 102 | const QVariantMap &hints, int expireTimeout, | ||
1106 | 103 | std::shared_ptr<OrgFreedesktopNotificationsInterface> notificationsInterface); | ||
1107 | 83 | }; | 104 | }; |
1108 | 84 | } | 105 | } |
1109 | 85 | 106 | ||
1110 | === modified file 'src/notify-cpp/snapdecision/sim-unlock.cpp' | |||
1111 | --- src/notify-cpp/snapdecision/sim-unlock.cpp 2015-05-12 09:02:50 +0000 | |||
1112 | +++ src/notify-cpp/snapdecision/sim-unlock.cpp 2015-08-12 13:44:19 +0000 | |||
1113 | @@ -18,7 +18,6 @@ | |||
1114 | 18 | */ | 18 | */ |
1115 | 19 | 19 | ||
1116 | 20 | #include "sim-unlock.h" | 20 | #include "sim-unlock.h" |
1117 | 21 | #include <notify-cpp/notification.h> | ||
1118 | 22 | 21 | ||
1119 | 23 | #include "menumodel-cpp/menu.h" | 22 | #include "menumodel-cpp/menu.h" |
1120 | 24 | #include "menumodel-cpp/menu-exporter.h" | 23 | #include "menumodel-cpp/menu-exporter.h" |
1121 | @@ -31,6 +30,7 @@ | |||
1122 | 31 | #include <QDebug> | 30 | #include <QDebug> |
1123 | 32 | 31 | ||
1124 | 33 | using namespace notify::snapdecision; | 32 | using namespace notify::snapdecision; |
1125 | 33 | using namespace std; | ||
1126 | 34 | 34 | ||
1127 | 35 | class SimUnlock::Private: public QObject | 35 | class SimUnlock::Private: public QObject |
1128 | 36 | { | 36 | { |
1129 | @@ -39,8 +39,8 @@ | |||
1130 | 39 | public: | 39 | public: |
1131 | 40 | SimUnlock& p; | 40 | SimUnlock& p; |
1132 | 41 | 41 | ||
1135 | 42 | Notification::Ptr m_notification; | 42 | NotificationManager::SPtr m_notificationManager; |
1136 | 43 | Notification::Ptr m_pending; | 43 | Notification::UPtr m_notification; |
1137 | 44 | 44 | ||
1138 | 45 | QString m_title; | 45 | QString m_title; |
1139 | 46 | QString m_body; | 46 | QString m_body; |
1140 | @@ -48,7 +48,7 @@ | |||
1141 | 48 | 48 | ||
1142 | 49 | std::shared_ptr<SessionBus> m_sessionBus; | 49 | std::shared_ptr<SessionBus> m_sessionBus; |
1143 | 50 | 50 | ||
1145 | 51 | std::map<std::string, Variant> m_modelPaths; | 51 | QVariantMap m_modelPaths; |
1146 | 52 | 52 | ||
1147 | 53 | Action::Ptr m_notifyAction; | 53 | Action::Ptr m_notifyAction; |
1148 | 54 | Action::Ptr m_pinMinMaxAction; | 54 | Action::Ptr m_pinMinMaxAction; |
1149 | @@ -65,11 +65,6 @@ | |||
1150 | 65 | std::function<void()> m_pendingPopupClosed; | 65 | std::function<void()> m_pendingPopupClosed; |
1151 | 66 | 66 | ||
1152 | 67 | public Q_SLOTS: | 67 | public Q_SLOTS: |
1153 | 68 | void notificationClosed() | ||
1154 | 69 | { | ||
1155 | 70 | resetNotification(m_title, m_body); | ||
1156 | 71 | Q_EMIT p.closed(); | ||
1157 | 72 | } | ||
1158 | 73 | 68 | ||
1159 | 74 | void resetActionStates() | 69 | void resetActionStates() |
1160 | 75 | { | 70 | { |
1161 | @@ -90,16 +85,31 @@ | |||
1162 | 90 | } | 85 | } |
1163 | 91 | } | 86 | } |
1164 | 92 | 87 | ||
1167 | 93 | void resetNotification(const QString &title, | 88 | void resetNotification() |
1166 | 94 | const QString &body) | ||
1168 | 95 | { | 89 | { |
1174 | 96 | m_pending = m_notification; | 90 | QVariantMap hints({ |
1175 | 97 | m_notification = std::make_shared<notify::Notification>(title, body, ""); | 91 | { "x-canonical-snap-decisions", "true" }, |
1176 | 98 | m_notification->setHintString("x-canonical-snap-decisions", "true"); | 92 | { "x-canonical-snap-decisions-timeout", numeric_limits<int32_t>::max() }, |
1177 | 99 | m_notification->setHint("x-canonical-snap-decisions-timeout", TypedVariant<std::int32_t>(std::numeric_limits<std::int32_t>::max())); | 93 | { "x-canonical-private-menu-model", m_modelPaths } |
1178 | 100 | m_notification->setHint("x-canonical-private-menu-model", TypedVariant<std::map<std::string, Variant>>(m_modelPaths)); | 94 | }); |
1179 | 95 | |||
1180 | 96 | if (m_notification) | ||
1181 | 97 | { | ||
1182 | 98 | m_notification->setSummary(m_title); | ||
1183 | 99 | m_notification->setBody(m_body); | ||
1184 | 100 | m_notification->setIcon(""); | ||
1185 | 101 | m_notification->setActions(QStringList()); | ||
1186 | 102 | m_notification->setHints(hints); | ||
1187 | 103 | } | ||
1188 | 104 | else | ||
1189 | 105 | { | ||
1190 | 106 | m_notification = m_notificationManager->notify( | ||
1191 | 107 | m_title, m_body, "", QStringList(), hints); | ||
1192 | 108 | |||
1193 | 109 | connect(&p, &SimUnlock::titleUpdated, m_notification.get(), &Notification::setSummary); | ||
1194 | 110 | connect(&p, &SimUnlock::bodyUpdated, m_notification.get(), &Notification::setBody); | ||
1195 | 111 | } | ||
1196 | 101 | resetActionStates(); | 112 | resetActionStates(); |
1197 | 102 | connect(m_notification.get(), &Notification::closed, this, &Private::notificationClosed); | ||
1198 | 103 | } | 113 | } |
1199 | 104 | 114 | ||
1200 | 105 | void pinEntered(const Variant& state) | 115 | void pinEntered(const Variant& state) |
1201 | @@ -111,6 +121,7 @@ | |||
1202 | 111 | { | 121 | { |
1203 | 112 | if (!parameter.as<bool>()) | 122 | if (!parameter.as<bool>()) |
1204 | 113 | { | 123 | { |
1205 | 124 | p.close(); | ||
1206 | 114 | Q_EMIT p.cancelled(); | 125 | Q_EMIT p.cancelled(); |
1207 | 115 | } | 126 | } |
1208 | 116 | } | 127 | } |
1209 | @@ -145,11 +156,13 @@ | |||
1210 | 145 | 156 | ||
1211 | 146 | public: | 157 | public: |
1212 | 147 | Private(SimUnlock& parent, | 158 | Private(SimUnlock& parent, |
1213 | 159 | NotificationManager::SPtr notificationManager, | ||
1214 | 148 | const QString &title, | 160 | const QString &title, |
1215 | 149 | const QString &body, | 161 | const QString &body, |
1216 | 150 | std::pair<std::uint8_t, std::uint8_t> pinMinMax) | 162 | std::pair<std::uint8_t, std::uint8_t> pinMinMax) |
1217 | 151 | : p(parent) | 163 | : p(parent) |
1218 | 152 | { | 164 | { |
1219 | 165 | m_notificationManager = notificationManager; | ||
1220 | 153 | m_title = title; | 166 | m_title = title; |
1221 | 154 | m_body = body; | 167 | m_body = body; |
1222 | 155 | m_pinMinMax = pinMinMax; | 168 | m_pinMinMax = pinMinMax; |
1223 | @@ -162,12 +175,12 @@ | |||
1224 | 162 | std::string menuPath = "/com/canonical/indicator/network/unlocksim" + std::to_string(exportId); | 175 | std::string menuPath = "/com/canonical/indicator/network/unlocksim" + std::to_string(exportId); |
1225 | 163 | ++exportId; | 176 | ++exportId; |
1226 | 164 | 177 | ||
1229 | 165 | std::map<std::string, Variant> modelActions; | 178 | QVariantMap modelActions; |
1230 | 166 | modelActions["notifications"] = TypedVariant<std::string>(actionPath); | 179 | modelActions["notifications"] = QString::fromStdString(actionPath); |
1231 | 167 | 180 | ||
1235 | 168 | m_modelPaths["busName"] = TypedVariant<std::string>(m_sessionBus->address()); | 181 | m_modelPaths["busName"] = QString::fromStdString(m_sessionBus->address()); |
1236 | 169 | m_modelPaths["menuPath"] = TypedVariant<std::string>(menuPath); | 182 | m_modelPaths["menuPath"] = QString::fromStdString(menuPath); |
1237 | 170 | m_modelPaths["actions"] = TypedVariant<std::map<std::string, Variant>>(modelActions); | 183 | m_modelPaths["actions"] = modelActions; |
1238 | 171 | 184 | ||
1239 | 172 | m_menu = std::make_shared<Menu>(); | 185 | m_menu = std::make_shared<Menu>(); |
1240 | 173 | m_menuItem = std::make_shared<MenuItem>("", "notifications.simunlock"); | 186 | m_menuItem = std::make_shared<MenuItem>("", "notifications.simunlock"); |
1241 | @@ -205,19 +218,18 @@ | |||
1242 | 205 | m_menuExporter = std::make_shared<MenuExporter>(m_sessionBus, menuPath, m_menu); | 218 | m_menuExporter = std::make_shared<MenuExporter>(m_sessionBus, menuPath, m_menu); |
1243 | 206 | m_actionGroupExporter = std::make_shared<ActionGroupExporter>(m_sessionBus, m_actionGroup, actionPath); | 219 | m_actionGroupExporter = std::make_shared<ActionGroupExporter>(m_sessionBus, m_actionGroup, actionPath); |
1244 | 207 | 220 | ||
1246 | 208 | resetNotification(title, body); | 221 | resetNotification(); |
1247 | 209 | 222 | ||
1248 | 210 | connect(&p, &SimUnlock::titleUpdated, m_notification.get(), &Notification::setSummary); | ||
1249 | 211 | connect(&p, &SimUnlock::bodyUpdated, m_notification.get(), &Notification::setBody); | ||
1250 | 212 | connect(&p, &SimUnlock::pinMinMaxUpdated, this, &Private::pinMinMaxChanged); | 223 | connect(&p, &SimUnlock::pinMinMaxUpdated, this, &Private::pinMinMaxChanged); |
1251 | 213 | } | 224 | } |
1252 | 214 | }; | 225 | }; |
1253 | 215 | 226 | ||
1257 | 216 | SimUnlock::SimUnlock(const QString &title, | 227 | SimUnlock::SimUnlock(NotificationManager::SPtr notificationManager, |
1258 | 217 | const QString &body, | 228 | const QString &title, |
1259 | 218 | std::pair<std::uint8_t, std::uint8_t> pinMinMax) | 229 | const QString &body, |
1260 | 230 | std::pair<std::uint8_t, std::uint8_t> pinMinMax) | ||
1261 | 219 | { | 231 | { |
1263 | 220 | d.reset(new Private(*this, title, body, pinMinMax)); | 232 | d.reset(new Private(*this, notificationManager, title, body, pinMinMax)); |
1264 | 221 | } | 233 | } |
1265 | 222 | 234 | ||
1266 | 223 | SimUnlock::~SimUnlock() | 235 | SimUnlock::~SimUnlock() |
1267 | 224 | 236 | ||
1268 | === modified file 'src/notify-cpp/snapdecision/sim-unlock.h' | |||
1269 | --- src/notify-cpp/snapdecision/sim-unlock.h 2015-05-13 15:46:54 +0000 | |||
1270 | +++ src/notify-cpp/snapdecision/sim-unlock.h 2015-08-12 13:44:19 +0000 | |||
1271 | @@ -24,6 +24,8 @@ | |||
1272 | 24 | #include <QObject> | 24 | #include <QObject> |
1273 | 25 | #include <QString> | 25 | #include <QString> |
1274 | 26 | 26 | ||
1275 | 27 | #include <notify-cpp/notification-manager.h> | ||
1276 | 28 | |||
1277 | 27 | namespace notify { | 29 | namespace notify { |
1278 | 28 | namespace snapdecision { | 30 | namespace snapdecision { |
1279 | 29 | 31 | ||
1280 | @@ -38,7 +40,8 @@ | |||
1281 | 38 | 40 | ||
1282 | 39 | typedef std::shared_ptr<SimUnlock> Ptr; | 41 | typedef std::shared_ptr<SimUnlock> Ptr; |
1283 | 40 | 42 | ||
1285 | 41 | explicit SimUnlock(const QString &title = "", | 43 | explicit SimUnlock(NotificationManager::SPtr notificationManager, |
1286 | 44 | const QString &title = "", | ||
1287 | 42 | const QString &body = "", | 45 | const QString &body = "", |
1288 | 43 | std::pair<std::uint8_t, std::uint8_t> pinMinMax = {0, 0}); | 46 | std::pair<std::uint8_t, std::uint8_t> pinMinMax = {0, 0}); |
1289 | 44 | ~SimUnlock(); | 47 | ~SimUnlock(); |
1290 | @@ -84,8 +87,6 @@ | |||
1291 | 84 | 87 | ||
1292 | 85 | void cancelled(); | 88 | void cancelled(); |
1293 | 86 | 89 | ||
1294 | 87 | void closed(); | ||
1295 | 88 | |||
1296 | 89 | void titleUpdated(const QString&); | 90 | void titleUpdated(const QString&); |
1297 | 90 | 91 | ||
1298 | 91 | void bodyUpdated(const QString&); | 92 | void bodyUpdated(const QString&); |
1299 | 92 | 93 | ||
1300 | === modified file 'src/qdbus-stubs/dbus-types.h' | |||
1301 | --- src/qdbus-stubs/dbus-types.h 2015-08-10 16:49:01 +0000 | |||
1302 | +++ src/qdbus-stubs/dbus-types.h 2015-08-12 13:44:19 +0000 | |||
1303 | @@ -56,4 +56,10 @@ | |||
1304 | 56 | static constexpr char const* URFKILL_OBJ_PATH = "/org/freedesktop/URfkill"; | 56 | static constexpr char const* URFKILL_OBJ_PATH = "/org/freedesktop/URfkill"; |
1305 | 57 | 57 | ||
1306 | 58 | static constexpr char const* URFKILL_WIFI_OBJ_PATH = "/org/freedesktop/URfkill/WLAN"; | 58 | static constexpr char const* URFKILL_WIFI_OBJ_PATH = "/org/freedesktop/URfkill/WLAN"; |
1307 | 59 | static constexpr char const* NOTIFY_DBUS_NAME = "org.freedesktop.Notifications"; | ||
1308 | 60 | |||
1309 | 61 | static constexpr char const* NOTIFY_DBUS_INTERFACE = "org.freedesktop.Notifications"; | ||
1310 | 62 | |||
1311 | 63 | static constexpr char const* NOTIFY_DBUS_PATH = "/org/freedesktop/Notifications"; | ||
1312 | 64 | |||
1313 | 59 | } | 65 | } |
1314 | 60 | 66 | ||
1315 | === modified file 'tests/integration/indicator-network-test-base.h' | |||
1316 | --- tests/integration/indicator-network-test-base.h 2015-07-07 08:29:34 +0000 | |||
1317 | +++ tests/integration/indicator-network-test-base.h 2015-08-12 13:44:19 +0000 | |||
1318 | @@ -30,7 +30,11 @@ | |||
1319 | 30 | #include <gtest/gtest.h> | 30 | #include <gtest/gtest.h> |
1320 | 31 | 31 | ||
1321 | 32 | inline void PrintTo(const QVariant& variant, std::ostream* os) { | 32 | inline void PrintTo(const QVariant& variant, std::ostream* os) { |
1323 | 33 | *os << "QVariant(" << variant.toString().toStdString() << ")"; | 33 | QString output; |
1324 | 34 | QDebug dbg(&output); | ||
1325 | 35 | dbg << variant; | ||
1326 | 36 | |||
1327 | 37 | *os << "QVariant(" << output.toStdString() << ")"; | ||
1328 | 34 | } | 38 | } |
1329 | 35 | 39 | ||
1330 | 36 | #define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ | 40 | #define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ |
1331 | 37 | 41 | ||
1332 | === modified file 'tests/integration/test-indicator.cpp' | |||
1333 | --- tests/integration/test-indicator.cpp 2015-07-08 08:49:30 +0000 | |||
1334 | +++ tests/integration/test-indicator.cpp 2015-08-12 13:44:19 +0000 | |||
1335 | @@ -2077,12 +2077,12 @@ | |||
1336 | 2077 | // set sim locked | 2077 | // set sim locked |
1337 | 2078 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); | 2078 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); |
1338 | 2079 | 2079 | ||
1339 | 2080 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1340 | 2081 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1341 | 2082 | |||
1342 | 2080 | // start the indicator | 2083 | // start the indicator |
1343 | 2081 | ASSERT_NO_THROW(startIndicator()); | 2084 | ASSERT_NO_THROW(startIndicator()); |
1344 | 2082 | 2085 | ||
1345 | 2083 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1346 | 2084 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1347 | 2085 | |||
1348 | 2086 | // check indicator is a locked sim card and a 0-bar wifi icon. | 2086 | // check indicator is a locked sim card and a 0-bar wifi icon. |
1349 | 2087 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. | 2087 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. |
1350 | 2088 | // check that the “Unlock SIM” button has the correct action name. | 2088 | // check that the “Unlock SIM” button has the correct action name. |
1351 | @@ -2100,10 +2100,9 @@ | |||
1352 | 2100 | ).match()); | 2100 | ).match()); |
1353 | 2101 | 2101 | ||
1354 | 2102 | // check that the "GetServerInformation" method was called | 2102 | // check that the "GetServerInformation" method was called |
1355 | 2103 | // check that the "Notify" method was called twice | ||
1356 | 2104 | // check method arguments are correct | 2103 | // check method arguments are correct |
1359 | 2105 | std::string busName; | 2104 | string busName; |
1360 | 2106 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 2105 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1361 | 2107 | { | 2106 | { |
1362 | 2108 | QVariantList const& call(notificationsSpy.at(0)); | 2107 | QVariantList const& call(notificationsSpy.at(0)); |
1363 | 2109 | EXPECT_EQ("GetServerInformation", call.at(0)); | 2108 | EXPECT_EQ("GetServerInformation", call.at(0)); |
1364 | @@ -2147,45 +2146,9 @@ | |||
1365 | 2147 | ASSERT_TRUE(actions.contains("notifications")); | 2146 | ASSERT_TRUE(actions.contains("notifications")); |
1366 | 2148 | EXPECT_EQ("/com/canonical/indicator/network/unlocksim0", actions["notifications"]); | 2147 | EXPECT_EQ("/com/canonical/indicator/network/unlocksim0", actions["notifications"]); |
1367 | 2149 | } | 2148 | } |
1368 | 2150 | { | ||
1369 | 2151 | QVariantList const& call(notificationsSpy.at(2)); | ||
1370 | 2152 | EXPECT_EQ("Notify", call.at(0)); | ||
1371 | 2153 | QVariantList const& args(call.at(1).toList()); | ||
1372 | 2154 | ASSERT_EQ(8, args.size()); | ||
1373 | 2155 | EXPECT_EQ("indicator-network", args.at(0)); | ||
1374 | 2156 | EXPECT_EQ(1, args.at(1)); | ||
1375 | 2157 | EXPECT_EQ("", args.at(2)); | ||
1376 | 2158 | EXPECT_EQ("Enter SIM PIN", args.at(3)); | ||
1377 | 2159 | EXPECT_EQ("3 attempts remaining", args.at(4)); | ||
1378 | 2160 | EXPECT_EQ(QStringList(), args.at(5)); | ||
1379 | 2161 | EXPECT_EQ(-1, args.at(7)); | ||
1380 | 2162 | |||
1381 | 2163 | QVariantMap hints; | ||
1382 | 2164 | ASSERT_TRUE(qDBusArgumentToMap(args.at(6), hints)); | ||
1383 | 2165 | ASSERT_EQ(3, hints.size()); | ||
1384 | 2166 | ASSERT_TRUE(hints.contains("x-canonical-private-menu-model")); | ||
1385 | 2167 | ASSERT_TRUE(hints.contains("x-canonical-snap-decisions")); | ||
1386 | 2168 | ASSERT_TRUE(hints.contains("x-canonical-snap-decisions-timeout")); | ||
1387 | 2169 | EXPECT_EQ(true, hints["x-canonical-snap-decisions"]); | ||
1388 | 2170 | EXPECT_EQ(numeric_limits<int32_t>::max(), hints["x-canonical-snap-decisions-timeout"]); | ||
1389 | 2171 | |||
1390 | 2172 | QVariantMap menuInfo; | ||
1391 | 2173 | ASSERT_TRUE(qDBusArgumentToMap(hints["x-canonical-private-menu-model"], menuInfo)); | ||
1392 | 2174 | ASSERT_EQ(3, menuInfo.size()); | ||
1393 | 2175 | ASSERT_TRUE(menuInfo.contains("actions")); | ||
1394 | 2176 | ASSERT_TRUE(menuInfo.contains("busName")); | ||
1395 | 2177 | ASSERT_TRUE(menuInfo.contains("menuPath")); | ||
1396 | 2178 | EXPECT_EQ(busName, menuInfo["busName"].toString().toStdString()); | ||
1397 | 2179 | EXPECT_EQ("/com/canonical/indicator/network/unlocksim0", menuInfo["menuPath"]); | ||
1398 | 2180 | |||
1399 | 2181 | QVariantMap actions; | ||
1400 | 2182 | ASSERT_TRUE(qDBusArgumentToMap(menuInfo["actions"], actions)); | ||
1401 | 2183 | ASSERT_EQ(1, actions.size()); | ||
1402 | 2184 | ASSERT_TRUE(actions.contains("notifications")); | ||
1403 | 2185 | EXPECT_EQ("/com/canonical/indicator/network/unlocksim0", actions["notifications"]); | ||
1404 | 2186 | } | ||
1405 | 2187 | notificationsSpy.clear(); | 2149 | notificationsSpy.clear(); |
1406 | 2188 | 2150 | ||
1407 | 2151 | ASSERT_FALSE(busName.empty()); | ||
1408 | 2189 | // check contents of x-canonical-private-menu-model | 2152 | // check contents of x-canonical-private-menu-model |
1409 | 2190 | EXPECT_MATCHRESULT(mh::MenuMatcher(unlockSimParameters(busName, 0)) | 2153 | EXPECT_MATCHRESULT(mh::MenuMatcher(unlockSimParameters(busName, 0)) |
1410 | 2191 | .item(mh::MenuItemMatcher() | 2154 | .item(mh::MenuItemMatcher() |
1411 | @@ -2205,12 +2168,12 @@ | |||
1412 | 2205 | // set sim locked | 2168 | // set sim locked |
1413 | 2206 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); | 2169 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); |
1414 | 2207 | 2170 | ||
1415 | 2171 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1416 | 2172 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1417 | 2173 | |||
1418 | 2208 | // start the indicator | 2174 | // start the indicator |
1419 | 2209 | ASSERT_NO_THROW(startIndicator()); | 2175 | ASSERT_NO_THROW(startIndicator()); |
1420 | 2210 | 2176 | ||
1421 | 2211 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1422 | 2212 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1423 | 2213 | |||
1424 | 2214 | // check indicator is a locked sim card and a 0-bar wifi icon. | 2177 | // check indicator is a locked sim card and a 0-bar wifi icon. |
1425 | 2215 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. | 2178 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. |
1426 | 2216 | // check that the “Unlock SIM” button has the correct action name. | 2179 | // check that the “Unlock SIM” button has the correct action name. |
1427 | @@ -2228,15 +2191,13 @@ | |||
1428 | 2228 | ).match()); | 2191 | ).match()); |
1429 | 2229 | 2192 | ||
1430 | 2230 | // check that the "GetServerInformation" method was called | 2193 | // check that the "GetServerInformation" method was called |
1431 | 2231 | // check that the "Notify" method was called twice | ||
1432 | 2232 | // check method arguments are correct | 2194 | // check method arguments are correct |
1433 | 2233 | std::string busName; | 2195 | std::string busName; |
1435 | 2234 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 2196 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1436 | 2235 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); | 2197 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); |
1437 | 2236 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); | 2198 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); |
1438 | 2237 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); | ||
1439 | 2238 | { | 2199 | { |
1441 | 2239 | QVariantList const& call(notificationsSpy.at(2)); | 2200 | QVariantList const& call(notificationsSpy.at(1)); |
1442 | 2240 | QVariantList const& args(call.at(1).toList()); | 2201 | QVariantList const& args(call.at(1).toList()); |
1443 | 2241 | QVariantMap hints; | 2202 | QVariantMap hints; |
1444 | 2242 | QVariantMap menuInfo; | 2203 | QVariantMap menuInfo; |
1445 | @@ -2284,11 +2245,10 @@ | |||
1446 | 2284 | ) | 2245 | ) |
1447 | 2285 | ).match()); | 2246 | ).match()); |
1448 | 2286 | 2247 | ||
1454 | 2287 | // check that the "Notify" method was called twice | 2248 | // check that the "Notify" method was called |
1455 | 2288 | // check method arguments are correct (new notification index should be 2) | 2249 | // check method arguments are correct (we re-use the same notification and reopen it) |
1456 | 2289 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2250 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1457 | 2290 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 0}); | 2251 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}); |
1453 | 2291 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 2}); | ||
1458 | 2292 | notificationsSpy.clear(); | 2252 | notificationsSpy.clear(); |
1459 | 2293 | 2253 | ||
1460 | 2294 | // cancel the notification again | 2254 | // cancel the notification again |
1461 | @@ -2302,15 +2262,144 @@ | |||
1462 | 2302 | .activate(shared_ptr<GVariant>(g_variant_new_boolean(false), &mh::gvariant_deleter)) | 2262 | .activate(shared_ptr<GVariant>(g_variant_new_boolean(false), &mh::gvariant_deleter)) |
1463 | 2303 | ).match()); | 2263 | ).match()); |
1464 | 2304 | 2264 | ||
1474 | 2305 | // check that the "NotificationClosed" signal was emitted (new notification index should be 2) | 2265 | // check that the "NotificationClosed" signal was emitted (new notification index should be 1) |
1475 | 2306 | WAIT_FOR_SIGNALS(notificationClosedSpy, 1); | 2266 | WAIT_FOR_SIGNALS(notificationClosedSpy, 1); |
1476 | 2307 | EXPECT_EQ(notificationClosedSpy.first(), QVariantList() << QVariant(2) << QVariant(1)); | 2267 | EXPECT_EQ(notificationClosedSpy.first(), QVariantList() << QVariant(1) << QVariant(1)); |
1477 | 2308 | notificationClosedSpy.clear(); | 2268 | notificationClosedSpy.clear(); |
1478 | 2309 | 2269 | ||
1479 | 2310 | // check that the "CloseNotification" method was called | 2270 | // check that the "CloseNotification" method was called |
1480 | 2311 | // check method arguments are correct (new notification index should be 2) | 2271 | // check method arguments are correct (still using the same notification: 1) |
1481 | 2312 | WAIT_FOR_SIGNALS(notificationsSpy, 1); | 2272 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1482 | 2313 | CHECK_METHOD_CALL(notificationsSpy, 0, "CloseNotification", {0, "2"}); | 2273 | CHECK_METHOD_CALL(notificationsSpy, 0, "CloseNotification", {0, "1"}); |
1483 | 2274 | notificationsSpy.clear(); | ||
1484 | 2275 | } | ||
1485 | 2276 | |||
1486 | 2277 | TEST_F(TestIndicator, UnlockSIM_CancelFirstUnlockSecond) | ||
1487 | 2278 | { | ||
1488 | 2279 | // set flight mode off, wifi off, and cell data off, and sim in | ||
1489 | 2280 | setGlobalConnectedState(NM_STATE_DISCONNECTED); | ||
1490 | 2281 | |||
1491 | 2282 | // set sim locked | ||
1492 | 2283 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); | ||
1493 | 2284 | |||
1494 | 2285 | // Create a second locked modem | ||
1495 | 2286 | auto secondModem = createModem("ril_1"); | ||
1496 | 2287 | setSimManagerProperty(secondModem, "PinRequired", "pin"); | ||
1497 | 2288 | |||
1498 | 2289 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1499 | 2290 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1500 | 2291 | |||
1501 | 2292 | QSignalSpy secondModemMockInterfaceSpy(&modemMockInterface(secondModem), | ||
1502 | 2293 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1503 | 2294 | |||
1504 | 2295 | // start the indicator | ||
1505 | 2296 | ASSERT_NO_THROW(startIndicator()); | ||
1506 | 2297 | |||
1507 | 2298 | // check indicator is a locked sim card and a 0-bar wifi icon. | ||
1508 | 2299 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. | ||
1509 | 2300 | // check that the “Unlock SIM” button has the correct action name. | ||
1510 | 2301 | // unlock first SIM | ||
1511 | 2302 | EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters()) | ||
1512 | 2303 | .item(mh::MenuItemMatcher() | ||
1513 | 2304 | .mode(mh::MenuItemMatcher::Mode::starts_with) | ||
1514 | 2305 | .item(flightModeSwitch()) | ||
1515 | 2306 | .item(mh::MenuItemMatcher() | ||
1516 | 2307 | .item(modemInfo("SIM 1", "SIM Locked", "simcard-locked", true) | ||
1517 | 2308 | .pass_through_activate("x-canonical-modem-locked-action") | ||
1518 | 2309 | ) | ||
1519 | 2310 | .item(modemInfo("SIM 2", "SIM Locked", "simcard-locked", true)) | ||
1520 | 2311 | .item(cellularSettings()) | ||
1521 | 2312 | ) | ||
1522 | 2313 | ).match()); | ||
1523 | 2314 | |||
1524 | 2315 | // check that the "GetServerInformation" method was called | ||
1525 | 2316 | // check method arguments are correct | ||
1526 | 2317 | std::string busName; | ||
1527 | 2318 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | ||
1528 | 2319 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); | ||
1529 | 2320 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM 1 PIN"}, {4, "3 attempts remaining"}); | ||
1530 | 2321 | { | ||
1531 | 2322 | QVariantList const& call(notificationsSpy.at(1)); | ||
1532 | 2323 | QVariantList const& args(call.at(1).toList()); | ||
1533 | 2324 | QVariantMap hints; | ||
1534 | 2325 | QVariantMap menuInfo; | ||
1535 | 2326 | ASSERT_TRUE(qDBusArgumentToMap(args.at(6), hints)); | ||
1536 | 2327 | ASSERT_TRUE(qDBusArgumentToMap(hints["x-canonical-private-menu-model"], menuInfo)); | ||
1537 | 2328 | busName = menuInfo["busName"].toString().toStdString(); | ||
1538 | 2329 | } | ||
1539 | 2330 | notificationsSpy.clear(); | ||
1540 | 2331 | |||
1541 | 2332 | // cancel the notification | ||
1542 | 2333 | QSignalSpy notificationClosedSpy(&dbusMock.notificationDaemonInterface(), | ||
1543 | 2334 | SIGNAL(NotificationClosed(uint, uint))); | ||
1544 | 2335 | |||
1545 | 2336 | EXPECT_MATCHRESULT(mh::MenuMatcher(unlockSimParameters(busName, 0)) | ||
1546 | 2337 | .item(mh::MenuItemMatcher() | ||
1547 | 2338 | .action("notifications.simunlock") | ||
1548 | 2339 | .string_attribute("x-canonical-type", "com.canonical.snapdecision.pinlock") | ||
1549 | 2340 | .string_attribute("x-canonical-pin-min-max", "notifications.pinMinMax") | ||
1550 | 2341 | .string_attribute("x-canonical-pin-popup", "notifications.popup") | ||
1551 | 2342 | .string_attribute("x-canonical-pin-error", "notifications.error") | ||
1552 | 2343 | .activate(shared_ptr<GVariant>(g_variant_new_boolean(false), &mh::gvariant_deleter)) | ||
1553 | 2344 | ).match()); | ||
1554 | 2345 | |||
1555 | 2346 | // check that the "NotificationClosed" signal was emitted | ||
1556 | 2347 | WAIT_FOR_SIGNALS(notificationClosedSpy, 1); | ||
1557 | 2348 | EXPECT_EQ(notificationClosedSpy.first(), QVariantList() << QVariant(1) << QVariant(1)); | ||
1558 | 2349 | notificationClosedSpy.clear(); | ||
1559 | 2350 | |||
1560 | 2351 | // check that the "CloseNotification" method was called | ||
1561 | 2352 | // check method arguments are correct | ||
1562 | 2353 | WAIT_FOR_SIGNALS(notificationsSpy, 1); | ||
1563 | 2354 | CHECK_METHOD_CALL(notificationsSpy, 0, "CloseNotification", {0, "1"}); | ||
1564 | 2355 | notificationsSpy.clear(); | ||
1565 | 2356 | |||
1566 | 2357 | // Activate the second SIM unlock | ||
1567 | 2358 | EXPECT_MATCHRESULT(mh::MenuMatcher(phoneParameters()) | ||
1568 | 2359 | .item(mh::MenuItemMatcher() | ||
1569 | 2360 | .mode(mh::MenuItemMatcher::Mode::starts_with) | ||
1570 | 2361 | .item(flightModeSwitch()) | ||
1571 | 2362 | .item(mh::MenuItemMatcher() | ||
1572 | 2363 | .item(modemInfo("SIM 1", "SIM Locked", "simcard-locked", true)) | ||
1573 | 2364 | .item(modemInfo("SIM 2", "SIM Locked", "simcard-locked", true) | ||
1574 | 2365 | .pass_through_activate("x-canonical-modem-locked-action") | ||
1575 | 2366 | ) | ||
1576 | 2367 | .item(cellularSettings()) | ||
1577 | 2368 | ) | ||
1578 | 2369 | ).match()); | ||
1579 | 2370 | |||
1580 | 2371 | // check that the "Notify" method was called | ||
1581 | 2372 | // check method arguments are correct (we re-use the same notification and reopen it) | ||
1582 | 2373 | WAIT_FOR_SIGNALS(notificationsSpy, 1); | ||
1583 | 2374 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}); | ||
1584 | 2375 | notificationsSpy.clear(); | ||
1585 | 2376 | |||
1586 | 2377 | secondModemMockInterfaceSpy.clear(); | ||
1587 | 2378 | |||
1588 | 2379 | // enter the PIN | ||
1589 | 2380 | EXPECT_MATCHRESULT(mh::MenuMatcher(unlockSimParameters(busName, 0)) | ||
1590 | 2381 | .item(mh::MenuItemMatcher() | ||
1591 | 2382 | .action("notifications.simunlock") | ||
1592 | 2383 | .string_attribute("x-canonical-type", "com.canonical.snapdecision.pinlock") | ||
1593 | 2384 | .string_attribute("x-canonical-pin-min-max", "notifications.pinMinMax") | ||
1594 | 2385 | .string_attribute("x-canonical-pin-popup", "notifications.popup") | ||
1595 | 2386 | .string_attribute("x-canonical-pin-error", "notifications.error") | ||
1596 | 2387 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("1234"), &mh::gvariant_deleter)) | ||
1597 | 2388 | ).match()); | ||
1598 | 2389 | |||
1599 | 2390 | // Check the PIN was sent to Ofono | ||
1600 | 2391 | WAIT_FOR_SIGNALS(secondModemMockInterfaceSpy, 1); | ||
1601 | 2392 | CHECK_METHOD_CALL(secondModemMockInterfaceSpy, 0, "EnterPin", {0, "pin"}, {1, "1234"}); | ||
1602 | 2393 | |||
1603 | 2394 | // check that the "NotificationClosed" signal was emitted (new notification index should be 1) | ||
1604 | 2395 | WAIT_FOR_SIGNALS(notificationClosedSpy, 1); | ||
1605 | 2396 | EXPECT_EQ(notificationClosedSpy.first(), QVariantList() << QVariant(1) << QVariant(1)); | ||
1606 | 2397 | notificationClosedSpy.clear(); | ||
1607 | 2398 | |||
1608 | 2399 | // check that the "CloseNotification" method was called | ||
1609 | 2400 | // check method arguments are correct (still using the same notification: 1) | ||
1610 | 2401 | WAIT_FOR_SIGNALS(notificationsSpy, 1); | ||
1611 | 2402 | CHECK_METHOD_CALL(notificationsSpy, 0, "CloseNotification", {0, "1"}); | ||
1612 | 2314 | notificationsSpy.clear(); | 2403 | notificationsSpy.clear(); |
1613 | 2315 | } | 2404 | } |
1614 | 2316 | 2405 | ||
1615 | @@ -2322,12 +2411,12 @@ | |||
1616 | 2322 | // set sim locked | 2411 | // set sim locked |
1617 | 2323 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); | 2412 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); |
1618 | 2324 | 2413 | ||
1619 | 2414 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1620 | 2415 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1621 | 2416 | |||
1622 | 2325 | // start the indicator | 2417 | // start the indicator |
1623 | 2326 | ASSERT_NO_THROW(startIndicator()); | 2418 | ASSERT_NO_THROW(startIndicator()); |
1624 | 2327 | 2419 | ||
1625 | 2328 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1626 | 2329 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1627 | 2330 | |||
1628 | 2331 | // check indicator is a locked sim card and a 0-bar wifi icon. | 2420 | // check indicator is a locked sim card and a 0-bar wifi icon. |
1629 | 2332 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. | 2421 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. |
1630 | 2333 | // check that the “Unlock SIM” button has the correct action name. | 2422 | // check that the “Unlock SIM” button has the correct action name. |
1631 | @@ -2348,12 +2437,11 @@ | |||
1632 | 2348 | // check that the "Notify" method was called twice | 2437 | // check that the "Notify" method was called twice |
1633 | 2349 | // check method arguments are correct | 2438 | // check method arguments are correct |
1634 | 2350 | std::string busName; | 2439 | std::string busName; |
1636 | 2351 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 2440 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1637 | 2352 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); | 2441 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); |
1638 | 2353 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); | 2442 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); |
1639 | 2354 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); | ||
1640 | 2355 | { | 2443 | { |
1642 | 2356 | QVariantList const& call(notificationsSpy.at(2)); | 2444 | QVariantList const& call(notificationsSpy.at(1)); |
1643 | 2357 | QVariantList const& args(call.at(1).toList()); | 2445 | QVariantList const& args(call.at(1).toList()); |
1644 | 2358 | QVariantMap hints; | 2446 | QVariantMap hints; |
1645 | 2359 | QVariantMap menuInfo; | 2447 | QVariantMap menuInfo; |
1646 | @@ -2406,12 +2494,12 @@ | |||
1647 | 2406 | // set sim locked | 2494 | // set sim locked |
1648 | 2407 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); | 2495 | setSimManagerProperty(firstModem(), "PinRequired", "pin"); |
1649 | 2408 | 2496 | ||
1650 | 2497 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1651 | 2498 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1652 | 2499 | |||
1653 | 2409 | // start the indicator | 2500 | // start the indicator |
1654 | 2410 | ASSERT_NO_THROW(startIndicator()); | 2501 | ASSERT_NO_THROW(startIndicator()); |
1655 | 2411 | 2502 | ||
1656 | 2412 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1657 | 2413 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1658 | 2414 | |||
1659 | 2415 | // check indicator is a locked sim card and a 0-bar wifi icon. | 2503 | // check indicator is a locked sim card and a 0-bar wifi icon. |
1660 | 2416 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. | 2504 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. |
1661 | 2417 | // check that the “Unlock SIM” button has the correct action name. | 2505 | // check that the “Unlock SIM” button has the correct action name. |
1662 | @@ -2432,12 +2520,11 @@ | |||
1663 | 2432 | // check that the "Notify" method was called twice | 2520 | // check that the "Notify" method was called twice |
1664 | 2433 | // check method arguments are correct | 2521 | // check method arguments are correct |
1665 | 2434 | std::string busName; | 2522 | std::string busName; |
1667 | 2435 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 2523 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1668 | 2436 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); | 2524 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); |
1669 | 2437 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); | 2525 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); |
1670 | 2438 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "3 attempts remaining"}); | ||
1671 | 2439 | { | 2526 | { |
1673 | 2440 | QVariantList const& call(notificationsSpy.at(2)); | 2527 | QVariantList const& call(notificationsSpy.at(1)); |
1674 | 2441 | QVariantList const& args(call.at(1).toList()); | 2528 | QVariantList const& args(call.at(1).toList()); |
1675 | 2442 | QVariantMap hints; | 2529 | QVariantMap hints; |
1676 | 2443 | QVariantMap menuInfo; | 2530 | QVariantMap menuInfo; |
1677 | @@ -2464,13 +2551,11 @@ | |||
1678 | 2464 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); | 2551 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); |
1679 | 2465 | modemSpy.clear(); | 2552 | modemSpy.clear(); |
1680 | 2466 | 2553 | ||
1682 | 2467 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2554 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1683 | 2468 | // check method arguments are correct (notification index should still be 1) | 2555 | // check method arguments are correct (notification index should still be 1) |
1685 | 2469 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2556 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1686 | 2470 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "2 attempts remaining"}); | 2557 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "2 attempts remaining"}); |
1687 | 2471 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "2 attempts remaining"}); | 2558 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "2 attempts remaining"}); |
1688 | 2472 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "2 attempts remaining"}); | ||
1689 | 2473 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "2 attempts remaining"}); | ||
1690 | 2474 | notificationsSpy.clear(); | 2559 | notificationsSpy.clear(); |
1691 | 2475 | 2560 | ||
1692 | 2476 | // check that the notification is displaying the appropriate error message | 2561 | // check that the notification is displaying the appropriate error message |
1693 | @@ -2498,13 +2583,11 @@ | |||
1694 | 2498 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); | 2583 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); |
1695 | 2499 | modemSpy.clear(); | 2584 | modemSpy.clear(); |
1696 | 2500 | 2585 | ||
1698 | 2501 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2586 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1699 | 2502 | // check method arguments are correct (notification index should still be 1) | 2587 | // check method arguments are correct (notification index should still be 1) |
1701 | 2503 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2588 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1702 | 2504 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "1 attempt remaining"}); | 2589 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "1 attempt remaining"}); |
1703 | 2505 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "1 attempt remaining"}); | 2590 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "1 attempt remaining"}); |
1704 | 2506 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "1 attempt remaining"}); | ||
1705 | 2507 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "1 attempt remaining"}); | ||
1706 | 2508 | notificationsSpy.clear(); | 2591 | notificationsSpy.clear(); |
1707 | 2509 | 2592 | ||
1708 | 2510 | // check that the error message and last attempt popup are displayed | 2593 | // check that the error message and last attempt popup are displayed |
1709 | @@ -2537,13 +2620,11 @@ | |||
1710 | 2537 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); | 2620 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); |
1711 | 2538 | modemSpy.clear(); | 2621 | modemSpy.clear(); |
1712 | 2539 | 2622 | ||
1714 | 2540 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2623 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1715 | 2541 | // check method arguments are correct (notification index should still be 1) | 2624 | // check method arguments are correct (notification index should still be 1) |
1717 | 2542 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2625 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1718 | 2543 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "0 attempts remaining"}); | 2626 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "0 attempts remaining"}); |
1719 | 2544 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "0 attempts remaining"}); | 2627 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "0 attempts remaining"}); |
1720 | 2545 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "0 attempts remaining"}); | ||
1721 | 2546 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter SIM PIN"}, {4, "0 attempts remaining"}); | ||
1722 | 2547 | notificationsSpy.clear(); | 2628 | notificationsSpy.clear(); |
1723 | 2548 | 2629 | ||
1724 | 2549 | // set sim blocked | 2630 | // set sim blocked |
1725 | @@ -2553,11 +2634,10 @@ | |||
1726 | 2553 | WAIT_FOR_SIGNALS(modemSpy, 1); | 2634 | WAIT_FOR_SIGNALS(modemSpy, 1); |
1727 | 2554 | modemSpy.clear(); | 2635 | modemSpy.clear(); |
1728 | 2555 | 2636 | ||
1730 | 2556 | // check that the "Notify" method was called twice | 2637 | // check that the "Notify" method was called |
1731 | 2557 | // check method arguments are correct (notification index should still be 1) | 2638 | // check method arguments are correct (notification index should still be 1) |
1733 | 2558 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2639 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1734 | 2559 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter PUK code"}, {4, "10 attempts remaining"}); | 2640 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter PUK code"}, {4, "10 attempts remaining"}); |
1735 | 2560 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter PUK code"}, {4, "10 attempts remaining"}); | ||
1736 | 2561 | notificationsSpy.clear(); | 2641 | notificationsSpy.clear(); |
1737 | 2562 | 2642 | ||
1738 | 2563 | // check that the error message and last attempt popup are displayed | 2643 | // check that the error message and last attempt popup are displayed |
1739 | @@ -2585,11 +2665,10 @@ | |||
1740 | 2585 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("87654321"), &mh::gvariant_deleter)) | 2665 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("87654321"), &mh::gvariant_deleter)) |
1741 | 2586 | ).match()); | 2666 | ).match()); |
1742 | 2587 | 2667 | ||
1744 | 2588 | // check that the "Notify" method was called twice | 2668 | // check that the "Notify" method was called |
1745 | 2589 | // check method arguments are correct (notification index should still be 1) | 2669 | // check method arguments are correct (notification index should still be 1) |
1747 | 2590 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2670 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1748 | 2591 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM PIN"}, {4, "Create new PIN"}); | 2671 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM PIN"}, {4, "Create new PIN"}); |
1749 | 2592 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter new SIM PIN"}, {4, "Create new PIN"}); | ||
1750 | 2593 | notificationsSpy.clear(); | 2672 | notificationsSpy.clear(); |
1751 | 2594 | 2673 | ||
1752 | 2595 | // enter new pin | 2674 | // enter new pin |
1753 | @@ -2598,11 +2677,10 @@ | |||
1754 | 2598 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) | 2677 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) |
1755 | 2599 | ).match()); | 2678 | ).match()); |
1756 | 2600 | 2679 | ||
1758 | 2601 | // check that the "Notify" method was called twice | 2680 | // check that the "Notify" method was called |
1759 | 2602 | // check method arguments are correct (notification index should still be 1) | 2681 | // check method arguments are correct (notification index should still be 1) |
1761 | 2603 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2682 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1762 | 2604 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | 2683 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); |
1763 | 2605 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | ||
1764 | 2606 | notificationsSpy.clear(); | 2684 | notificationsSpy.clear(); |
1765 | 2607 | 2685 | ||
1766 | 2608 | // enter new pin again | 2686 | // enter new pin again |
1767 | @@ -2617,13 +2695,11 @@ | |||
1768 | 2617 | CHECK_METHOD_CALL(modemSpy, 0, "ResetPin", {0, "puk"}, {1, "87654321"}, {2, "4321"}); | 2695 | CHECK_METHOD_CALL(modemSpy, 0, "ResetPin", {0, "puk"}, {1, "87654321"}, {2, "4321"}); |
1769 | 2618 | modemSpy.clear(); | 2696 | modemSpy.clear(); |
1770 | 2619 | 2697 | ||
1772 | 2620 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2698 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1773 | 2621 | // check method arguments are correct (notification index should still be 1) | 2699 | // check method arguments are correct (notification index should still be 1) |
1775 | 2622 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2700 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1776 | 2623 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | 2701 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); |
1780 | 2624 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | 2702 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter PUK code"}, {4, "9 attempts remaining"}); |
1778 | 2625 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter PUK code"}, {4, "9 attempts remaining"}); | ||
1779 | 2626 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter PUK code"}, {4, "9 attempts remaining"}); | ||
1781 | 2627 | notificationsSpy.clear(); | 2703 | notificationsSpy.clear(); |
1782 | 2628 | 2704 | ||
1783 | 2629 | // check that the notification is displaying the appropriate error message | 2705 | // check that the notification is displaying the appropriate error message |
1784 | @@ -2649,10 +2725,9 @@ | |||
1785 | 2649 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("12345678"), &mh::gvariant_deleter)) | 2725 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("12345678"), &mh::gvariant_deleter)) |
1786 | 2650 | ).match()); | 2726 | ).match()); |
1787 | 2651 | 2727 | ||
1790 | 2652 | // check that the "Notify" method was called twice | 2728 | // check that the "Notify" method was called |
1791 | 2653 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2729 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1792 | 2654 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM PIN"}, {4, "Create new PIN"}); | 2730 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM PIN"}, {4, "Create new PIN"}); |
1793 | 2655 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter new SIM PIN"}, {4, "Create new PIN"}); | ||
1794 | 2656 | notificationsSpy.clear(); | 2731 | notificationsSpy.clear(); |
1795 | 2657 | 2732 | ||
1796 | 2658 | // enter new pin | 2733 | // enter new pin |
1797 | @@ -2661,10 +2736,9 @@ | |||
1798 | 2661 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) | 2736 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) |
1799 | 2662 | ).match()); | 2737 | ).match()); |
1800 | 2663 | 2738 | ||
1803 | 2664 | // check that the "Notify" method was called twice | 2739 | // check that the "Notify" method was called |
1804 | 2665 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2740 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1805 | 2666 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | 2741 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); |
1806 | 2667 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | ||
1807 | 2668 | notificationsSpy.clear(); | 2742 | notificationsSpy.clear(); |
1808 | 2669 | 2743 | ||
1809 | 2670 | // enter new pin again | 2744 | // enter new pin again |
1810 | @@ -2687,10 +2761,9 @@ | |||
1811 | 2687 | // check that the "Notify" method was called twice when retries changes | 2761 | // check that the "Notify" method was called twice when retries changes |
1812 | 2688 | // check that the "CloseNotification" method was called | 2762 | // check that the "CloseNotification" method was called |
1813 | 2689 | // check method arguments are correct | 2763 | // check method arguments are correct |
1815 | 2690 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 2764 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1816 | 2691 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | 2765 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); |
1819 | 2692 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM PIN"}, {4, "Create new PIN"}); | 2766 | CHECK_METHOD_CALL(notificationsSpy, 1, "CloseNotification", {0, "1"}); |
1818 | 2693 | CHECK_METHOD_CALL(notificationsSpy, 2, "CloseNotification", {0, "1"}); | ||
1820 | 2694 | notificationsSpy.clear(); | 2767 | notificationsSpy.clear(); |
1821 | 2695 | } | 2768 | } |
1822 | 2696 | 2769 | ||
1823 | @@ -2703,12 +2776,12 @@ | |||
1824 | 2703 | auto secondModem = createModem("ril_1"); | 2776 | auto secondModem = createModem("ril_1"); |
1825 | 2704 | setSimManagerProperty(secondModem, "PinRequired", "pin"); | 2777 | setSimManagerProperty(secondModem, "PinRequired", "pin"); |
1826 | 2705 | 2778 | ||
1827 | 2779 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1828 | 2780 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1829 | 2781 | |||
1830 | 2706 | // start the indicator | 2782 | // start the indicator |
1831 | 2707 | ASSERT_NO_THROW(startIndicator()); | 2783 | ASSERT_NO_THROW(startIndicator()); |
1832 | 2708 | 2784 | ||
1833 | 2709 | QSignalSpy notificationsSpy(¬ificationsMockInterface(), | ||
1834 | 2710 | SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
1835 | 2711 | |||
1836 | 2712 | // check indicator is a locked sim card and a 0-bar wifi icon. | 2785 | // check indicator is a locked sim card and a 0-bar wifi icon. |
1837 | 2713 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. | 2786 | // check sim status shows “SIM Locked”, with locked sim card icon and a “Unlock SIM” button beneath. |
1838 | 2714 | // check that the “Unlock SIM” button has the correct action name. | 2787 | // check that the “Unlock SIM” button has the correct action name. |
1839 | @@ -2730,12 +2803,11 @@ | |||
1840 | 2730 | // check that the "Notify" method was called twice | 2803 | // check that the "Notify" method was called twice |
1841 | 2731 | // check method arguments are correct | 2804 | // check method arguments are correct |
1842 | 2732 | std::string busName; | 2805 | std::string busName; |
1844 | 2733 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 2806 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1845 | 2734 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); | 2807 | CHECK_METHOD_CALL(notificationsSpy, 0, "GetServerInformation", /* no_args */); |
1846 | 2735 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM 2 PIN"}, {4, "3 attempts remaining"}); | 2808 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 0}, {3, "Enter SIM 2 PIN"}, {4, "3 attempts remaining"}); |
1847 | 2736 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "3 attempts remaining"}); | ||
1848 | 2737 | { | 2809 | { |
1850 | 2738 | QVariantList const& call(notificationsSpy.at(2)); | 2810 | QVariantList const& call(notificationsSpy.at(1)); |
1851 | 2739 | QVariantList const& args(call.at(1).toList()); | 2811 | QVariantList const& args(call.at(1).toList()); |
1852 | 2740 | QVariantMap hints; | 2812 | QVariantMap hints; |
1853 | 2741 | QVariantMap menuInfo; | 2813 | QVariantMap menuInfo; |
1854 | @@ -2762,13 +2834,11 @@ | |||
1855 | 2762 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); | 2834 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); |
1856 | 2763 | modemSpy.clear(); | 2835 | modemSpy.clear(); |
1857 | 2764 | 2836 | ||
1859 | 2765 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2837 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1860 | 2766 | // check method arguments are correct (notification index should still be 1) | 2838 | // check method arguments are correct (notification index should still be 1) |
1862 | 2767 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2839 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1863 | 2768 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "2 attempts remaining"}); | 2840 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "2 attempts remaining"}); |
1864 | 2769 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "2 attempts remaining"}); | 2841 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "2 attempts remaining"}); |
1865 | 2770 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "2 attempts remaining"}); | ||
1866 | 2771 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "2 attempts remaining"}); | ||
1867 | 2772 | notificationsSpy.clear(); | 2842 | notificationsSpy.clear(); |
1868 | 2773 | 2843 | ||
1869 | 2774 | // check that the notification is displaying the appropriate error message | 2844 | // check that the notification is displaying the appropriate error message |
1870 | @@ -2796,13 +2866,11 @@ | |||
1871 | 2796 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); | 2866 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); |
1872 | 2797 | modemSpy.clear(); | 2867 | modemSpy.clear(); |
1873 | 2798 | 2868 | ||
1875 | 2799 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2869 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1876 | 2800 | // check method arguments are correct (notification index should still be 1) | 2870 | // check method arguments are correct (notification index should still be 1) |
1878 | 2801 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2871 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1879 | 2802 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "1 attempt remaining"}); | 2872 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "1 attempt remaining"}); |
1880 | 2803 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "1 attempt remaining"}); | 2873 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "1 attempt remaining"}); |
1881 | 2804 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "1 attempt remaining"}); | ||
1882 | 2805 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "1 attempt remaining"}); | ||
1883 | 2806 | notificationsSpy.clear(); | 2874 | notificationsSpy.clear(); |
1884 | 2807 | 2875 | ||
1885 | 2808 | // check that the error message and last attempt popup are displayed | 2876 | // check that the error message and last attempt popup are displayed |
1886 | @@ -2835,13 +2903,11 @@ | |||
1887 | 2835 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); | 2903 | CHECK_METHOD_CALL(modemSpy, 0, "EnterPin", {0, "pin"}, {1, "4321"}); |
1888 | 2836 | modemSpy.clear(); | 2904 | modemSpy.clear(); |
1889 | 2837 | 2905 | ||
1891 | 2838 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2906 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1892 | 2839 | // check method arguments are correct (notification index should still be 1) | 2907 | // check method arguments are correct (notification index should still be 1) |
1894 | 2840 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2908 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1895 | 2841 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "0 attempts remaining"}); | 2909 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "0 attempts remaining"}); |
1896 | 2842 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "0 attempts remaining"}); | 2910 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "0 attempts remaining"}); |
1897 | 2843 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "0 attempts remaining"}); | ||
1898 | 2844 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter SIM 2 PIN"}, {4, "0 attempts remaining"}); | ||
1899 | 2845 | notificationsSpy.clear(); | 2911 | notificationsSpy.clear(); |
1900 | 2846 | 2912 | ||
1901 | 2847 | // set sim blocked | 2913 | // set sim blocked |
1902 | @@ -2851,11 +2917,10 @@ | |||
1903 | 2851 | WAIT_FOR_SIGNALS(modemSpy, 1); | 2917 | WAIT_FOR_SIGNALS(modemSpy, 1); |
1904 | 2852 | modemSpy.clear(); | 2918 | modemSpy.clear(); |
1905 | 2853 | 2919 | ||
1907 | 2854 | // check that the "Notify" method was called twice | 2920 | // check that the "Notify" method was called |
1908 | 2855 | // check method arguments are correct (notification index should still be 1) | 2921 | // check method arguments are correct (notification index should still be 1) |
1910 | 2856 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2922 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1911 | 2857 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter PUK code for SIM 2"}, {4, "10 attempts remaining"}); | 2923 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter PUK code for SIM 2"}, {4, "10 attempts remaining"}); |
1912 | 2858 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter PUK code for SIM 2"}, {4, "10 attempts remaining"}); | ||
1913 | 2859 | notificationsSpy.clear(); | 2924 | notificationsSpy.clear(); |
1914 | 2860 | 2925 | ||
1915 | 2861 | // check that the error message and last attempt popup are displayed | 2926 | // check that the error message and last attempt popup are displayed |
1916 | @@ -2883,11 +2948,10 @@ | |||
1917 | 2883 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("87654321"), &mh::gvariant_deleter)) | 2948 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("87654321"), &mh::gvariant_deleter)) |
1918 | 2884 | ).match()); | 2949 | ).match()); |
1919 | 2885 | 2950 | ||
1921 | 2886 | // check that the "Notify" method was called twice | 2951 | // check that the "Notify" method was called |
1922 | 2887 | // check method arguments are correct (notification index should still be 1) | 2952 | // check method arguments are correct (notification index should still be 1) |
1924 | 2888 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2953 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1925 | 2889 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM 2 PIN"}, {4, "Create new PIN"}); | 2954 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM 2 PIN"}, {4, "Create new PIN"}); |
1926 | 2890 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter new SIM 2 PIN"}, {4, "Create new PIN"}); | ||
1927 | 2891 | notificationsSpy.clear(); | 2955 | notificationsSpy.clear(); |
1928 | 2892 | 2956 | ||
1929 | 2893 | // enter new pin | 2957 | // enter new pin |
1930 | @@ -2896,11 +2960,10 @@ | |||
1931 | 2896 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) | 2960 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) |
1932 | 2897 | ).match()); | 2961 | ).match()); |
1933 | 2898 | 2962 | ||
1935 | 2899 | // check that the "Notify" method was called twice | 2963 | // check that the "Notify" method was called |
1936 | 2900 | // check method arguments are correct (notification index should still be 1) | 2964 | // check method arguments are correct (notification index should still be 1) |
1938 | 2901 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 2965 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1939 | 2902 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | 2966 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); |
1940 | 2903 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | ||
1941 | 2904 | notificationsSpy.clear(); | 2967 | notificationsSpy.clear(); |
1942 | 2905 | 2968 | ||
1943 | 2906 | // enter new pin again | 2969 | // enter new pin again |
1944 | @@ -2915,13 +2978,11 @@ | |||
1945 | 2915 | CHECK_METHOD_CALL(modemSpy, 0, "ResetPin", {0, "puk"}, {1, "87654321"}, {2, "4321"}); | 2978 | CHECK_METHOD_CALL(modemSpy, 0, "ResetPin", {0, "puk"}, {1, "87654321"}, {2, "4321"}); |
1946 | 2916 | modemSpy.clear(); | 2979 | modemSpy.clear(); |
1947 | 2917 | 2980 | ||
1949 | 2918 | // check that the "Notify" method was called twice when retries changes, then twice again for incorrect pin | 2981 | // check that the "Notify" method was called when retries changes, then again for incorrect pin |
1950 | 2919 | // check method arguments are correct (notification index should still be 1) | 2982 | // check method arguments are correct (notification index should still be 1) |
1952 | 2920 | WAIT_FOR_SIGNALS(notificationsSpy, 4); | 2983 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1953 | 2921 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | 2984 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); |
1957 | 2922 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | 2985 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter PUK code for SIM 2"}, {4, "9 attempts remaining"}); |
1955 | 2923 | CHECK_METHOD_CALL(notificationsSpy, 2, "Notify", {1, 1}, {3, "Enter PUK code for SIM 2"}, {4, "9 attempts remaining"}); | ||
1956 | 2924 | CHECK_METHOD_CALL(notificationsSpy, 3, "Notify", {1, 1}, {3, "Enter PUK code for SIM 2"}, {4, "9 attempts remaining"}); | ||
1958 | 2925 | notificationsSpy.clear(); | 2986 | notificationsSpy.clear(); |
1959 | 2926 | 2987 | ||
1960 | 2927 | // check that the notification is displaying the appropriate error message | 2988 | // check that the notification is displaying the appropriate error message |
1961 | @@ -2947,10 +3008,9 @@ | |||
1962 | 2947 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("12345678"), &mh::gvariant_deleter)) | 3008 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("12345678"), &mh::gvariant_deleter)) |
1963 | 2948 | ).match()); | 3009 | ).match()); |
1964 | 2949 | 3010 | ||
1967 | 2950 | // check that the "Notify" method was called twice | 3011 | // check that the "Notify" method was called |
1968 | 2951 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 3012 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1969 | 2952 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM 2 PIN"}, {4, "Create new PIN"}); | 3013 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Enter new SIM 2 PIN"}, {4, "Create new PIN"}); |
1970 | 2953 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Enter new SIM 2 PIN"}, {4, "Create new PIN"}); | ||
1971 | 2954 | notificationsSpy.clear(); | 3014 | notificationsSpy.clear(); |
1972 | 2955 | 3015 | ||
1973 | 2956 | // enter new pin | 3016 | // enter new pin |
1974 | @@ -2959,10 +3019,9 @@ | |||
1975 | 2959 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) | 3019 | .set_action_state(shared_ptr<GVariant>(g_variant_new_string("4321"), &mh::gvariant_deleter)) |
1976 | 2960 | ).match()); | 3020 | ).match()); |
1977 | 2961 | 3021 | ||
1980 | 2962 | // check that the "Notify" method was called twice | 3022 | // check that the "Notify" method was called |
1981 | 2963 | WAIT_FOR_SIGNALS(notificationsSpy, 2); | 3023 | WAIT_FOR_SIGNALS(notificationsSpy, 1); |
1982 | 2964 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | 3024 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); |
1983 | 2965 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | ||
1984 | 2966 | notificationsSpy.clear(); | 3025 | notificationsSpy.clear(); |
1985 | 2967 | 3026 | ||
1986 | 2968 | // enter new pin again | 3027 | // enter new pin again |
1987 | @@ -2985,10 +3044,9 @@ | |||
1988 | 2985 | // check that the "Notify" method was called twice when retries changes | 3044 | // check that the "Notify" method was called twice when retries changes |
1989 | 2986 | // check that the "CloseNotification" method was called | 3045 | // check that the "CloseNotification" method was called |
1990 | 2987 | // check method arguments are correct | 3046 | // check method arguments are correct |
1992 | 2988 | WAIT_FOR_SIGNALS(notificationsSpy, 3); | 3047 | WAIT_FOR_SIGNALS(notificationsSpy, 2); |
1993 | 2989 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | 3048 | CHECK_METHOD_CALL(notificationsSpy, 0, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); |
1996 | 2990 | CHECK_METHOD_CALL(notificationsSpy, 1, "Notify", {1, 1}, {3, "Confirm new SIM 2 PIN"}, {4, "Create new PIN"}); | 3049 | CHECK_METHOD_CALL(notificationsSpy, 1, "CloseNotification", {0, "1"}); |
1995 | 2991 | CHECK_METHOD_CALL(notificationsSpy, 2, "CloseNotification", {0, "1"}); | ||
1997 | 2992 | notificationsSpy.clear(); | 3050 | notificationsSpy.clear(); |
1998 | 2993 | } | 3051 | } |
1999 | 2994 | 3052 | ||
2000 | 2995 | 3053 | ||
2001 | === modified file 'tests/unit/secret-agent/test-secret-agent.cpp' | |||
2002 | --- tests/unit/secret-agent/test-secret-agent.cpp 2015-04-23 12:04:27 +0000 | |||
2003 | +++ tests/unit/secret-agent/test-secret-agent.cpp 2015-08-12 13:44:19 +0000 | |||
2004 | @@ -50,7 +50,8 @@ | |||
2005 | 50 | QProcessEnvironment env(QProcessEnvironment::systemEnvironment()); | 50 | QProcessEnvironment env(QProcessEnvironment::systemEnvironment()); |
2006 | 51 | env.insert("SECRET_AGENT_DEBUG_PASSWORD", "1"); | 51 | env.insert("SECRET_AGENT_DEBUG_PASSWORD", "1"); |
2007 | 52 | secretAgent.setProcessEnvironment(env); | 52 | secretAgent.setProcessEnvironment(env); |
2009 | 53 | secretAgent.setProcessChannelMode(QProcess::MergedChannels); | 53 | secretAgent.setReadChannel(QProcess::StandardOutput); |
2010 | 54 | secretAgent.setProcessChannelMode(QProcess::ForwardedErrorChannel); | ||
2011 | 54 | secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address"); | 55 | secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address"); |
2012 | 55 | secretAgent.waitForStarted(); | 56 | secretAgent.waitForStarted(); |
2013 | 56 | secretAgent.waitForReadyRead(); | 57 | secretAgent.waitForReadyRead(); |
2014 | @@ -260,13 +261,14 @@ | |||
2015 | 260 | /* Tests that if we request secrets and then cancel the request | 261 | /* Tests that if we request secrets and then cancel the request |
2016 | 261 | that we close the notification */ | 262 | that we close the notification */ |
2017 | 262 | TEST_F(TestSecretAgent, CancelGetSecrets) { | 263 | TEST_F(TestSecretAgent, CancelGetSecrets) { |
2018 | 264 | QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
2019 | 265 | |||
2020 | 263 | agentInterface->GetSecrets( | 266 | agentInterface->GetSecrets( |
2021 | 264 | connection(SecretAgent::KEY_MGMT_WPA_PSK), | 267 | connection(SecretAgent::KEY_MGMT_WPA_PSK), |
2022 | 265 | QDBusObjectPath("/connection/foo"), | 268 | QDBusObjectPath("/connection/foo"), |
2023 | 266 | SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), | 269 | SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), |
2024 | 267 | 5); | 270 | 5); |
2025 | 268 | 271 | ||
2026 | 269 | QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); | ||
2027 | 270 | notificationSpy.wait(); | 272 | notificationSpy.wait(); |
2028 | 271 | 273 | ||
2029 | 272 | ASSERT_EQ(1, notificationSpy.size()); | 274 | ASSERT_EQ(1, notificationSpy.size()); |
PASSED: Continuous integration, rev:505 jenkins. qa.ubuntu. com/job/ indicator- network- ci/379/ jenkins. qa.ubuntu. com/job/ indicator- network- wily-amd64- ci/31 jenkins. qa.ubuntu. com/job/ indicator- network- wily-armhf- ci/31 jenkins. qa.ubuntu. com/job/ indicator- network- wily-armhf- ci/31/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- network- ci/379/ rebuild
http://