Merge lp:~tiagosh/telephony-service/refactor-ussd into lp:telephony-service
- refactor-ussd
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Gustavo Pichorim Boiko | ||||
Approved revision: | 1060 | ||||
Merged at revision: | 1065 | ||||
Proposed branch: | lp:~tiagosh/telephony-service/refactor-ussd | ||||
Merge into: | lp:telephony-service | ||||
Diff against target: |
768 lines (+235/-211) 10 files modified
Ubuntu/Telephony/components.cpp (+1/-1) indicator/ussdindicator.cpp (+49/-14) indicator/ussdindicator.h (+7/-1) libtelephonyservice/ofonoaccountentry.cpp (+7/-0) libtelephonyservice/ofonoaccountentry.h (+4/-0) libtelephonyservice/telepathyhelper.cpp (+31/-0) libtelephonyservice/telepathyhelper.h (+7/-1) libtelephonyservice/ussdmanager.cpp (+82/-175) libtelephonyservice/ussdmanager.h (+15/-19) tests/libtelephonyservice/TelepathyHelperTest.cpp (+32/-0) |
||||
To merge this branch: | bzr merge lp:~tiagosh/telephony-service/refactor-ussd | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gustavo Pichorim Boiko (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email:
|
Commit message
Add an USSDManager instance to each OfonoAccountEntry.
Description of the change
Add an USSDManager instance to each OfonoAccountEntry.
--Checklist--
Are there any related MPs required for this MP to build/function as expected? Please list.
No
Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes
Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes
Did you successfully run all tests found in your component's Test Plan (https:/
Yes
If you changed the UI, was the change specified/approved by design?
N/A
If you changed UI labels, did you update the pot file?
N/A
If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1058. By Tiago Salem Herrmann
-
merge trunk
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1058
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Pichorim Boiko (boiko) wrote : | # |
Code looks good, just a couple diff comments.
- 1059. By Tiago Salem Herrmann
-
add more checks for null pointers
- 1060. By Tiago Salem Herrmann
-
merge trunk
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Gustavo Pichorim Boiko (boiko) wrote : | # |
Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes
Did CI run pass? If not, please explain why.
No, but not related to the changes.
Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes
Code looks good and works as expected!
Preview Diff
1 | === modified file 'Ubuntu/Telephony/components.cpp' |
2 | --- Ubuntu/Telephony/components.cpp 2014-08-25 14:49:53 +0000 |
3 | +++ Ubuntu/Telephony/components.cpp 2015-04-22 13:43:13 +0000 |
4 | @@ -54,7 +54,6 @@ |
5 | mRootContext->setContextProperty("telepathyHelper", TelepathyHelper::instance()); |
6 | mRootContext->setContextProperty("chatManager", ChatManager::instance()); |
7 | mRootContext->setContextProperty("callManager", CallManager::instance()); |
8 | - mRootContext->setContextProperty("ussdManager", USSDManager::instance()); |
9 | mRootContext->setContextProperty("greeter", GreeterContacts::instance()); |
10 | |
11 | } |
12 | @@ -66,6 +65,7 @@ |
13 | qmlRegisterUncreatableType<CallEntry>(uri, 0, 1, "CallEntry", "Objects of this type are created in CallManager and made available to QML for usage"); |
14 | qmlRegisterUncreatableType<AudioOutput>(uri, 0, 1, "AudioOutput", "Objects of this type are created in CallEntry and made available to QML for usage"); |
15 | qmlRegisterUncreatableType<AccountEntry>(uri, 0, 1, "AccountEntry", "Objects of this type are created in TelepathyHelper and made available to QML"); |
16 | + qmlRegisterUncreatableType<USSDManager>(uri, 0, 1, "USSDManager", "Objects of this type are created in AccountEntry and made available to QML"); |
17 | qmlRegisterType<ContactWatcher>(uri, 0, 1, "ContactWatcher"); |
18 | qmlRegisterType<PhoneUtils>(uri, 0, 1, "PhoneUtils"); |
19 | } |
20 | |
21 | === modified file 'indicator/ussdindicator.cpp' |
22 | --- indicator/ussdindicator.cpp 2014-03-31 19:37:40 +0000 |
23 | +++ indicator/ussdindicator.cpp 2015-04-22 13:43:13 +0000 |
24 | @@ -27,6 +27,8 @@ |
25 | #include <libnotify/notify.h> |
26 | #include "ringtone.h" |
27 | #include "ussdindicator.h" |
28 | +#include "ofonoaccountentry.h" |
29 | +#include "telepathyhelper.h" |
30 | |
31 | USSDIndicator::USSDIndicator(QObject *parent) |
32 | : QObject(parent), |
33 | @@ -35,35 +37,63 @@ |
34 | m_notifications("org.freedesktop.Notifications", |
35 | "/org/freedesktop/Notifications", QDBusConnection::sessionBus()) |
36 | { |
37 | - connect(USSDManager::instance(), SIGNAL(notificationReceived(const QString &)), SLOT(onNotificationReceived(const QString &))); |
38 | - connect(USSDManager::instance(), SIGNAL(requestReceived(const QString &)), SLOT(onRequestReceived(const QString &))); |
39 | - connect(USSDManager::instance(), SIGNAL(initiateUSSDComplete(const QString &)), SLOT(onInitiateUSSDComplete(const QString &))); |
40 | - connect(USSDManager::instance(), SIGNAL(respondComplete(bool, const QString &)), SLOT(onRespondComplete(bool, const QString &))); |
41 | - connect(USSDManager::instance(), SIGNAL(stateChanged(const QString &)), SLOT(onStateChanged(const QString &))); |
42 | - |
43 | + setupAccounts(); |
44 | + connect(TelepathyHelper::instance(), SIGNAL(accountsChanged()), this, SLOT(setupAccounts())); |
45 | connect(&m_notifications, SIGNAL(ActionInvoked(uint, const QString &)), this, SLOT(actionInvoked(uint, const QString &))); |
46 | connect(&m_notifications, SIGNAL(NotificationClosed(uint, uint)), this, SLOT(notificationClosed(uint, uint))); |
47 | } |
48 | |
49 | +void USSDIndicator::setupAccounts() |
50 | +{ |
51 | + Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) { |
52 | + OfonoAccountEntry *ofonoAccount = qobject_cast<OfonoAccountEntry*>(account); |
53 | + if (!ofonoAccount) { |
54 | + continue; |
55 | + } |
56 | + |
57 | + connect(ofonoAccount->ussdManager(), SIGNAL(notificationReceived(const QString &)), SLOT(onNotificationReceived(const QString &)), Qt::UniqueConnection); |
58 | + connect(ofonoAccount->ussdManager(), SIGNAL(requestReceived(const QString &)), SLOT(onRequestReceived(const QString &)), Qt::UniqueConnection); |
59 | + connect(ofonoAccount->ussdManager(), SIGNAL(initiateUSSDComplete(const QString &)), SLOT(onInitiateUSSDComplete(const QString &)), Qt::UniqueConnection); |
60 | + connect(ofonoAccount->ussdManager(), SIGNAL(respondComplete(bool, const QString &)), SLOT(onRespondComplete(bool, const QString &)), Qt::UniqueConnection); |
61 | + connect(ofonoAccount->ussdManager(), SIGNAL(stateChanged(const QString &)), SLOT(onStateChanged(const QString &)), Qt::UniqueConnection); |
62 | + } |
63 | +} |
64 | + |
65 | void USSDIndicator::onNotificationReceived(const QString &message) |
66 | { |
67 | - showUSSDNotification(message, false); |
68 | + USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
69 | + if (!ussdManager) { |
70 | + return; |
71 | + } |
72 | + showUSSDNotification(message, false, ussdManager); |
73 | } |
74 | |
75 | void USSDIndicator::onRequestReceived(const QString &message) |
76 | { |
77 | - showUSSDNotification(message, true); |
78 | + USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
79 | + if (!ussdManager) { |
80 | + return; |
81 | + } |
82 | + showUSSDNotification(message, true, ussdManager); |
83 | } |
84 | |
85 | void USSDIndicator::onInitiateUSSDComplete(const QString &ussdResp) |
86 | { |
87 | - showUSSDNotification(ussdResp, (USSDManager::instance()->state() == "user-response")); |
88 | + USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
89 | + if (!ussdManager) { |
90 | + return; |
91 | + } |
92 | + showUSSDNotification(ussdResp, (ussdManager->state() == "user-response"), ussdManager); |
93 | } |
94 | |
95 | void USSDIndicator::onRespondComplete(bool success, const QString &ussdResp) |
96 | { |
97 | + USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
98 | + if (!ussdManager) { |
99 | + return; |
100 | + } |
101 | if (success) { |
102 | - showUSSDNotification(ussdResp, (USSDManager::instance()->state() == "user-response")); |
103 | + showUSSDNotification(ussdResp, (ussdManager->state() == "user-response"), ussdManager); |
104 | } |
105 | } |
106 | |
107 | @@ -72,7 +102,7 @@ |
108 | // TODO: check if we should close notifications when the state is idle |
109 | } |
110 | |
111 | -void USSDIndicator::showUSSDNotification(const QString &message, bool replyRequired) |
112 | +void USSDIndicator::showUSSDNotification(const QString &message, bool replyRequired, USSDManager *ussdManager) |
113 | { |
114 | USSDMenu *menu = replyRequired ? &m_menuRequest : &m_menuNotification; |
115 | QString actionId = "ok_id"; |
116 | @@ -102,7 +132,7 @@ |
117 | "", message, |
118 | QStringList() << actionId << actionLabel << "cancel_id" |
119 | << C::gettext("Cancel"), notificationHints, 0); |
120 | - |
121 | + mUSSDRequests[m_notificationId] = ussdManager; |
122 | |
123 | Ringtone::instance()->playIncomingMessageSound(); |
124 | } |
125 | @@ -113,12 +143,17 @@ |
126 | return; |
127 | } |
128 | |
129 | + USSDManager *ussdManager = mUSSDRequests.take(id); |
130 | + if (!ussdManager) { |
131 | + return; |
132 | + } |
133 | + |
134 | m_notificationId = 0; |
135 | |
136 | if (actionKey == "reply_id") { |
137 | - USSDManager::instance()->respond(m_menuRequest.response(), USSDManager::instance()->activeAccountId()); |
138 | + ussdManager->respond(m_menuRequest.response()); |
139 | } else if (actionKey == "cancel_id") { |
140 | - USSDManager::instance()->cancel(USSDManager::instance()->activeAccountId()); |
141 | + ussdManager->cancel(); |
142 | } |
143 | m_menuRequest.clearResponse(); |
144 | } |
145 | |
146 | === modified file 'indicator/ussdindicator.h' |
147 | --- indicator/ussdindicator.h 2014-03-31 19:37:40 +0000 |
148 | +++ indicator/ussdindicator.h 2015-04-22 13:43:13 +0000 |
149 | @@ -27,13 +27,14 @@ |
150 | #include "indicator/NotificationsInterface.h" |
151 | #include "ussdmanager.h" |
152 | #include "ussdmenu.h" |
153 | +#include "ofonoaccountentry.h" |
154 | |
155 | class USSDIndicator : public QObject |
156 | { |
157 | Q_OBJECT |
158 | public: |
159 | explicit USSDIndicator(QObject *parent = 0); |
160 | - void showUSSDNotification(const QString &message, bool replyRequired); |
161 | + void showUSSDNotification(const QString &message, bool replyRequired, USSDManager *ussdManager); |
162 | |
163 | public Q_SLOTS: |
164 | void onNotificationReceived(const QString &message); |
165 | @@ -43,12 +44,17 @@ |
166 | void onStateChanged(const QString &state); |
167 | void actionInvoked(uint id, const QString &actionKey); |
168 | void notificationClosed(uint id, uint reason); |
169 | +private Q_SLOTS: |
170 | + void setupAccounts(); |
171 | + |
172 | private: |
173 | unsigned int m_notificationId; |
174 | USSDMenu m_menuRequest; |
175 | USSDMenu m_menuNotification; |
176 | QString mPendingMessage; |
177 | org::freedesktop::Notifications m_notifications; |
178 | + QMap<int, USSDManager*> mUSSDRequests; |
179 | + QList<OfonoAccountEntry*> mAccounts; |
180 | }; |
181 | |
182 | #endif // USSDINDICATOR_H |
183 | |
184 | === modified file 'libtelephonyservice/ofonoaccountentry.cpp' |
185 | --- libtelephonyservice/ofonoaccountentry.cpp 2015-03-17 18:26:32 +0000 |
186 | +++ libtelephonyservice/ofonoaccountentry.cpp 2015-04-22 13:43:13 +0000 |
187 | @@ -37,6 +37,13 @@ |
188 | connect(this, |
189 | SIGNAL(statusMessageChanged()), |
190 | SIGNAL(emergencyCallsAvailableChanged())); |
191 | + |
192 | + mUssdManager = new USSDManager(this, this); |
193 | +} |
194 | + |
195 | +USSDManager *OfonoAccountEntry::ussdManager() const |
196 | +{ |
197 | + return mUssdManager; |
198 | } |
199 | |
200 | QStringList OfonoAccountEntry::emergencyNumbers() const |
201 | |
202 | === modified file 'libtelephonyservice/ofonoaccountentry.h' |
203 | --- libtelephonyservice/ofonoaccountentry.h 2015-03-17 18:21:59 +0000 |
204 | +++ libtelephonyservice/ofonoaccountentry.h 2015-04-22 13:43:13 +0000 |
205 | @@ -23,6 +23,7 @@ |
206 | #define OFONOACCOUNTENTRY_H |
207 | |
208 | #include "accountentry.h" |
209 | +#include "ussdmanager.h" |
210 | |
211 | class OfonoAccountEntry : public AccountEntry |
212 | { |
213 | @@ -35,6 +36,7 @@ |
214 | Q_PROPERTY(bool emergencyCallsAvailable READ emergencyCallsAvailable NOTIFY emergencyCallsAvailableChanged) |
215 | Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged) |
216 | Q_PROPERTY(QString serial READ serial NOTIFY serialChanged) |
217 | + Q_PROPERTY(USSDManager* ussdManager READ ussdManager CONSTANT) |
218 | friend class AccountEntryFactory; |
219 | |
220 | public: |
221 | @@ -46,6 +48,7 @@ |
222 | bool emergencyCallsAvailable() const; |
223 | bool simLocked() const; |
224 | QString serial() const; |
225 | + USSDManager *ussdManager() const; |
226 | |
227 | // reimplemented from AccountEntry |
228 | virtual AccountEntry::AccountType type() const; |
229 | @@ -81,6 +84,7 @@ |
230 | uint mVoicemailCount; |
231 | bool mVoicemailIndicator; |
232 | QString mSerial; |
233 | + USSDManager *mUssdManager; |
234 | }; |
235 | |
236 | #endif // OFONOACCOUNTENTRY_H |
237 | |
238 | === modified file 'libtelephonyservice/telepathyhelper.cpp' |
239 | --- libtelephonyservice/telepathyhelper.cpp 2015-03-26 21:52:43 +0000 |
240 | +++ libtelephonyservice/telepathyhelper.cpp 2015-04-22 13:43:13 +0000 |
241 | @@ -162,6 +162,22 @@ |
242 | return activeAccountList; |
243 | } |
244 | |
245 | +QList<AccountEntry*> TelepathyHelper::phoneAccounts() const |
246 | +{ |
247 | + QList<AccountEntry*> accountList; |
248 | + Q_FOREACH(AccountEntry *account, mAccounts) { |
249 | + if (account->type() == AccountEntry::PhoneAccount) { |
250 | + accountList << account; |
251 | + } |
252 | + } |
253 | + return accountList; |
254 | +} |
255 | + |
256 | +QQmlListProperty<AccountEntry> TelepathyHelper::qmlPhoneAccounts() |
257 | +{ |
258 | + return QQmlListProperty<AccountEntry>(this, 0, phoneAccountsCount, phoneAccountAt); |
259 | +} |
260 | + |
261 | QQmlListProperty<AccountEntry> TelepathyHelper::qmlAccounts() |
262 | { |
263 | return QQmlListProperty<AccountEntry>(this, 0, accountsCount, accountAt); |
264 | @@ -357,12 +373,24 @@ |
265 | return spec; |
266 | } |
267 | |
268 | +int TelepathyHelper::phoneAccountsCount(QQmlListProperty<AccountEntry> *p) |
269 | +{ |
270 | + Q_UNUSED(p) |
271 | + return TelepathyHelper::instance()->phoneAccounts().count(); |
272 | +} |
273 | + |
274 | int TelepathyHelper::accountsCount(QQmlListProperty<AccountEntry> *p) |
275 | { |
276 | Q_UNUSED(p) |
277 | return TelepathyHelper::instance()->accounts().count(); |
278 | } |
279 | |
280 | +AccountEntry *TelepathyHelper::phoneAccountAt(QQmlListProperty<AccountEntry> *p, int index) |
281 | +{ |
282 | + Q_UNUSED(p) |
283 | + return TelepathyHelper::instance()->phoneAccounts()[index]; |
284 | +} |
285 | + |
286 | AccountEntry *TelepathyHelper::accountAt(QQmlListProperty<AccountEntry> *p, int index) |
287 | { |
288 | Q_UNUSED(p) |
289 | @@ -391,6 +419,7 @@ |
290 | |
291 | Q_EMIT accountIdsChanged(); |
292 | Q_EMIT accountsChanged(); |
293 | + Q_EMIT phoneAccountsChanged(); |
294 | Q_EMIT activeAccountsChanged(); |
295 | onSettingsChanged("defaultSimForMessages"); |
296 | onSettingsChanged("defaultSimForCalls"); |
297 | @@ -418,6 +447,7 @@ |
298 | |
299 | Q_EMIT accountIdsChanged(); |
300 | Q_EMIT accountsChanged(); |
301 | + Q_EMIT phoneAccountsChanged(); |
302 | Q_EMIT activeAccountsChanged(); |
303 | onSettingsChanged("defaultSimForMessages"); |
304 | onSettingsChanged("defaultSimForCalls"); |
305 | @@ -452,6 +482,7 @@ |
306 | |
307 | Q_EMIT accountIdsChanged(); |
308 | Q_EMIT accountsChanged(); |
309 | + Q_EMIT phoneAccountsChanged(); |
310 | Q_EMIT activeAccountsChanged(); |
311 | onSettingsChanged("defaultSimForMessages"); |
312 | onSettingsChanged("defaultSimForCalls"); |
313 | |
314 | === modified file 'libtelephonyservice/telepathyhelper.h' |
315 | --- libtelephonyservice/telepathyhelper.h 2015-03-23 18:17:51 +0000 |
316 | +++ libtelephonyservice/telepathyhelper.h 2015-04-22 13:43:13 +0000 |
317 | @@ -48,6 +48,7 @@ |
318 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) |
319 | Q_PROPERTY(QStringList accountIds READ accountIds NOTIFY accountIdsChanged) |
320 | Q_PROPERTY(QQmlListProperty<AccountEntry> accounts READ qmlAccounts NOTIFY accountsChanged) |
321 | + Q_PROPERTY(QQmlListProperty<AccountEntry> phoneAccounts READ qmlPhoneAccounts NOTIFY phoneAccountsChanged) |
322 | Q_PROPERTY(QQmlListProperty<AccountEntry> activeAccounts READ qmlActiveAccounts NOTIFY activeAccountsChanged) |
323 | Q_PROPERTY(AccountEntry *defaultMessagingAccount READ defaultMessagingAccount NOTIFY defaultMessagingAccountChanged) |
324 | Q_PROPERTY(AccountEntry *defaultCallAccount READ defaultCallAccount NOTIFY defaultCallAccountChanged) |
325 | @@ -65,8 +66,10 @@ |
326 | |
327 | static TelepathyHelper *instance(); |
328 | QList<AccountEntry*> accounts() const; |
329 | + QList<AccountEntry*> phoneAccounts() const; |
330 | QList<AccountEntry*> activeAccounts() const; |
331 | QQmlListProperty<AccountEntry> qmlAccounts(); |
332 | + QQmlListProperty<AccountEntry> qmlPhoneAccounts(); |
333 | QQmlListProperty<AccountEntry> qmlActiveAccounts(); |
334 | ChannelObserver *channelObserver() const; |
335 | QDBusInterface *handlerInterface() const; |
336 | @@ -97,7 +100,9 @@ |
337 | static AccountEntry *accountAt(QQmlListProperty<AccountEntry> *p, int index); |
338 | static int activeAccountsCount(QQmlListProperty<AccountEntry> *p); |
339 | static AccountEntry *activeAccountAt(QQmlListProperty<AccountEntry> *p, int index); |
340 | - |
341 | + static int phoneAccountsCount(QQmlListProperty<AccountEntry> *p); |
342 | + static AccountEntry *phoneAccountAt(QQmlListProperty<AccountEntry> *p, int index); |
343 | + |
344 | Q_SIGNALS: |
345 | void channelObserverCreated(ChannelObserver *observer); |
346 | void channelObserverUnregistered(); |
347 | @@ -105,6 +110,7 @@ |
348 | void connectedChanged(); |
349 | void accountIdsChanged(); |
350 | void accountsChanged(); |
351 | + void phoneAccountsChanged(); |
352 | void activeAccountsChanged(); |
353 | void setupReady(); |
354 | void defaultMessagingAccountChanged(); |
355 | |
356 | === modified file 'libtelephonyservice/ussdmanager.cpp' |
357 | --- libtelephonyservice/ussdmanager.cpp 2015-02-03 17:30:41 +0000 |
358 | +++ libtelephonyservice/ussdmanager.cpp 2015-04-22 13:43:13 +0000 |
359 | @@ -1,5 +1,5 @@ |
360 | /* |
361 | - * Copyright (C) 2012 Canonical, Ltd. |
362 | + * Copyright (C) 2012-2015 Canonical, Ltd. |
363 | * |
364 | * Authors: |
365 | * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
366 | @@ -30,198 +30,105 @@ |
367 | typedef QMap<QString, QVariant> dbusQMap; |
368 | Q_DECLARE_METATYPE(dbusQMap) |
369 | |
370 | -USSDManager *USSDManager::instance() |
371 | -{ |
372 | - static USSDManager *self = new USSDManager(); |
373 | - return self; |
374 | -} |
375 | - |
376 | -USSDManager::USSDManager(QObject *parent) |
377 | -: QObject(parent) |
378 | -{ |
379 | - connect(TelepathyHelper::instance(), SIGNAL(accountsChanged()), SLOT(onAccountsChanged())); |
380 | - onAccountsChanged(); |
381 | -} |
382 | - |
383 | -Tp::ConnectionPtr USSDManager::connectionForAccountId(const QString &accountId) |
384 | -{ |
385 | - AccountEntry *accountEntry; |
386 | - if (accountId.isNull()) { |
387 | - accountEntry = TelepathyHelper::instance()->accounts()[0]; |
388 | - } else { |
389 | - accountEntry = TelepathyHelper::instance()->accountForId(accountId); |
390 | - } |
391 | - |
392 | - return accountEntry->account()->connection(); |
393 | -} |
394 | - |
395 | -void USSDManager::initiate(const QString &command, const QString &accountId) |
396 | -{ |
397 | - Tp::ConnectionPtr conn = connectionForAccountId(accountId); |
398 | - QString busName = conn->busName(); |
399 | - QString objectPath = conn->objectPath(); |
400 | - QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
401 | +USSDManager::USSDManager(AccountEntry *account, QObject *parent) |
402 | +: QObject(parent), |
403 | + mState("idle"), |
404 | + mAccount(account) |
405 | +{ |
406 | + connect(mAccount, SIGNAL(connectedChanged()), this, SLOT(onConnectionChanged())); |
407 | + onConnectionChanged(); |
408 | +} |
409 | + |
410 | +void USSDManager::initiate(const QString &command) |
411 | +{ |
412 | + QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
413 | ussdIface.asyncCall("Initiate", command); |
414 | } |
415 | |
416 | -void USSDManager::respond(const QString &reply, const QString &accountId) |
417 | +void USSDManager::respond(const QString &reply) |
418 | { |
419 | - Tp::ConnectionPtr conn = connectionForAccountId(accountId); |
420 | - QString busName = conn->busName(); |
421 | - QString objectPath = conn->objectPath(); |
422 | - QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
423 | + QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
424 | ussdIface.asyncCall("Respond", reply); |
425 | } |
426 | |
427 | -void USSDManager::cancel(const QString &accountId) |
428 | +void USSDManager::cancel() |
429 | { |
430 | - Tp::ConnectionPtr conn = connectionForAccountId(accountId); |
431 | - QString busName = conn->busName(); |
432 | - QString objectPath = conn->objectPath(); |
433 | - QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
434 | + QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
435 | ussdIface.asyncCall("Cancel"); |
436 | } |
437 | |
438 | -void USSDManager::disconnectAllSignals(const Tp::ConnectionPtr& conn) |
439 | -{ |
440 | - if (conn.isNull()) { |
441 | - return; |
442 | - } |
443 | - |
444 | - QString busName = conn->busName(); |
445 | - QString objectPath = conn->objectPath(); |
446 | - |
447 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); |
448 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); |
449 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); |
450 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); |
451 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); |
452 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); |
453 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); |
454 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); |
455 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); |
456 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); |
457 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); |
458 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); |
459 | - QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); |
460 | -} |
461 | - |
462 | -void USSDManager::connectAllSignals(const Tp::ConnectionPtr& conn) |
463 | -{ |
464 | - if (conn.isNull()) { |
465 | - return; |
466 | - } |
467 | - |
468 | - QString busName = conn->busName(); |
469 | - QString objectPath = conn->objectPath(); |
470 | - |
471 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); |
472 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); |
473 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); |
474 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); |
475 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); |
476 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); |
477 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); |
478 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); |
479 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); |
480 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); |
481 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); |
482 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); |
483 | - QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); |
484 | -} |
485 | - |
486 | -void USSDManager::accountConnectedChanged() |
487 | -{ |
488 | - AccountEntry *accountEntry = qobject_cast<AccountEntry*>(sender()); |
489 | - if (!accountEntry) { |
490 | - return; |
491 | - } |
492 | - Tp::ConnectionPtr conn(accountEntry->account()->connection()); |
493 | - disconnectAllSignals(conn); |
494 | - |
495 | - if (accountEntry->connected()) { |
496 | - QString busName = conn->busName(); |
497 | - QString objectPath = conn->objectPath(); |
498 | - |
499 | - connectAllSignals(conn); |
500 | - |
501 | - QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
502 | - mStates[accountEntry->accountId()] = ussdIface.property("State").toString(); |
503 | - } |
504 | -} |
505 | - |
506 | -void USSDManager::onAccountsChanged() |
507 | -{ |
508 | - Q_FOREACH (AccountEntry *accountEntry, TelepathyHelper::instance()->accounts()) { |
509 | - QObject::disconnect(accountEntry, SIGNAL(connectedChanged()), this, SLOT(accountConnectedChanged())); |
510 | - QObject::connect(accountEntry, SIGNAL(connectedChanged()), this, SLOT(accountConnectedChanged())); |
511 | - |
512 | - // disconnect all and reconnect only the online accounts |
513 | - Tp::ConnectionPtr conn(accountEntry->account()->connection()); |
514 | - disconnectAllSignals(conn); |
515 | - mStates.remove(accountEntry->accountId()); |
516 | - |
517 | - if (accountEntry->connected()) { |
518 | - QString busName = conn->busName(); |
519 | - QString objectPath = conn->objectPath(); |
520 | - |
521 | - connectAllSignals(conn); |
522 | - |
523 | - QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
524 | - mStates[accountEntry->accountId()] = ussdIface.property("State").toString(); |
525 | - } |
526 | - } |
527 | - Q_EMIT stateChanged(state()); |
528 | +void USSDManager::connectAllSignals() |
529 | +{ |
530 | + if (mBusName.isEmpty() || mObjectPath.isEmpty()) { |
531 | + return; |
532 | + } |
533 | + |
534 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); |
535 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); |
536 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); |
537 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); |
538 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); |
539 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); |
540 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); |
541 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); |
542 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); |
543 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); |
544 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); |
545 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); |
546 | + QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); |
547 | +} |
548 | + |
549 | +void USSDManager::disconnectAllSignals() |
550 | +{ |
551 | + if (mBusName.isEmpty() || mObjectPath.isEmpty()) { |
552 | + return; |
553 | + } |
554 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); |
555 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); |
556 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); |
557 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); |
558 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); |
559 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); |
560 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); |
561 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); |
562 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); |
563 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); |
564 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); |
565 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); |
566 | + QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); |
567 | +} |
568 | + |
569 | +void USSDManager::onConnectionChanged() |
570 | +{ |
571 | + disconnectAllSignals(); |
572 | + |
573 | + if (mAccount->account()->connection().isNull()) { |
574 | + qDebug() << "USSDManager: Failed to connect signals"; |
575 | + return; |
576 | + } |
577 | + |
578 | + mBusName = mAccount->account()->connection()->busName(); |
579 | + mObjectPath = mAccount->account()->connection()->objectPath(); |
580 | + |
581 | + QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
582 | + mState = ussdIface.property("State").toString(); |
583 | + |
584 | + connectAllSignals(); |
585 | +} |
586 | + |
587 | +void USSDManager::onStateChanged(const QString &state) |
588 | +{ |
589 | + mState = state; |
590 | + Q_EMIT stateChanged(mState); |
591 | Q_EMIT activeChanged(); |
592 | - Q_EMIT activeAccountIdChanged(); |
593 | -} |
594 | - |
595 | -void USSDManager::onStateChanged(const QString &) |
596 | -{ |
597 | - Q_FOREACH (AccountEntry *accountEntry, TelepathyHelper::instance()->accounts()) { |
598 | - Tp::ConnectionPtr conn(accountEntry->account()->connection()); |
599 | - if (accountEntry->connected()) { |
600 | - QString busName = conn->busName(); |
601 | - QString objectPath = conn->objectPath(); |
602 | - QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
603 | - mStates[accountEntry->accountId()] = ussdIface.property("State").toString(); |
604 | - } |
605 | - } |
606 | - Q_EMIT stateChanged(state()); |
607 | } |
608 | |
609 | bool USSDManager::active() const |
610 | { |
611 | - QMap<QString, QString>::const_iterator i = mStates.constBegin(); |
612 | - while (i != mStates.constEnd()) { |
613 | - if (i.value() != "idle") { |
614 | - return true; |
615 | - } |
616 | - ++i; |
617 | - } |
618 | - return false; |
619 | -} |
620 | - |
621 | -QString USSDManager::activeAccountId() const |
622 | -{ |
623 | - QMap<QString, QString>::const_iterator i = mStates.constBegin(); |
624 | - while (i != mStates.constEnd()) { |
625 | - if (i.value() != "idle") { |
626 | - return i.key(); |
627 | - } |
628 | - ++i; |
629 | - } |
630 | - return QString::null; |
631 | + return mState != "idle"; |
632 | } |
633 | |
634 | QString USSDManager::state() const |
635 | { |
636 | - QMap<QString, QString>::const_iterator i = mStates.constBegin(); |
637 | - while (i != mStates.constEnd()) { |
638 | - if (i.value() != "idle") { |
639 | - return i.value(); |
640 | - } |
641 | - ++i; |
642 | - } |
643 | - return "idle"; |
644 | + return mState; |
645 | } |
646 | |
647 | === modified file 'libtelephonyservice/ussdmanager.h' |
648 | --- libtelephonyservice/ussdmanager.h 2015-02-03 17:30:41 +0000 |
649 | +++ libtelephonyservice/ussdmanager.h 2015-04-22 13:43:13 +0000 |
650 | @@ -28,6 +28,7 @@ |
651 | #include <TelepathyQt/Connection> |
652 | |
653 | class TelepathyHelper; |
654 | +class AccountEntry; |
655 | |
656 | class USSDManager : public QObject |
657 | { |
658 | @@ -35,30 +36,23 @@ |
659 | Q_PROPERTY(bool active |
660 | READ active |
661 | NOTIFY activeChanged) |
662 | - Q_PROPERTY(QString activeAccountId |
663 | - READ activeAccountId |
664 | - NOTIFY activeAccountIdChanged) |
665 | Q_PROPERTY(QString state |
666 | READ state |
667 | NOTIFY stateChanged) |
668 | public: |
669 | - static USSDManager *instance(); |
670 | - Q_INVOKABLE void initiate(const QString &command, const QString &accountId = QString::null); |
671 | - Q_INVOKABLE void respond(const QString &reply, const QString &accountId = QString::null); |
672 | - Q_INVOKABLE void cancel(const QString &accountId = QString::null); |
673 | + explicit USSDManager(AccountEntry *account, QObject *parent = 0); |
674 | + Q_INVOKABLE void initiate(const QString &command); |
675 | + Q_INVOKABLE void respond(const QString &reply); |
676 | + Q_INVOKABLE void cancel(); |
677 | |
678 | bool active() const; |
679 | - QString activeAccountId() const; |
680 | QString state() const; |
681 | |
682 | public Q_SLOTS: |
683 | - void onAccountsChanged(); |
684 | void onStateChanged(const QString &state); |
685 | - void accountConnectedChanged(); |
686 | |
687 | Q_SIGNALS: |
688 | void activeChanged(); |
689 | - void activeAccountIdChanged(); |
690 | void stateChanged(const QString &state); |
691 | |
692 | void notificationReceived(const QString &message); |
693 | @@ -75,15 +69,17 @@ |
694 | void connectedLineRestrictionComplete(const QString &ssOp, const QString &status); |
695 | void initiateFailed(); |
696 | |
697 | +private Q_SLOTS: |
698 | + void onConnectionChanged(); |
699 | + |
700 | private: |
701 | - explicit USSDManager(QObject *parent = 0); |
702 | - |
703 | - Tp::ConnectionPtr connectionForAccountId(const QString &accountId = QString::null); |
704 | - |
705 | - void disconnectAllSignals(const Tp::ConnectionPtr& conn); |
706 | - void connectAllSignals(const Tp::ConnectionPtr& conn); |
707 | - |
708 | - QMap<QString, QString> mStates; |
709 | + void connectAllSignals(); |
710 | + void disconnectAllSignals(); |
711 | + |
712 | + QString mState; |
713 | + QString mBusName; |
714 | + QString mObjectPath; |
715 | + AccountEntry *mAccount; |
716 | }; |
717 | |
718 | #endif // USSDMANAGER_H |
719 | |
720 | === modified file 'tests/libtelephonyservice/TelepathyHelperTest.cpp' |
721 | --- tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-04-16 02:51:08 +0000 |
722 | +++ tests/libtelephonyservice/TelepathyHelperTest.cpp 2015-04-22 13:43:13 +0000 |
723 | @@ -37,6 +37,7 @@ |
724 | void cleanup(); |
725 | void testConnected(); |
726 | void testAccounts(); |
727 | + void testPhoneAccounts(); |
728 | void testAccountSorting(); |
729 | void testAccountIds(); |
730 | void testActiveAccounts(); |
731 | @@ -147,6 +148,37 @@ |
732 | QCOMPARE(TelepathyHelper::instance()->accounts()[1]->accountId(), second->accountId()); |
733 | } |
734 | |
735 | +void TelepathyHelperTest::testPhoneAccounts() |
736 | +{ |
737 | + QCOMPARE(TelepathyHelper::instance()->phoneAccounts().count(), 1); |
738 | + AccountEntry *phoneAccount = TelepathyHelper::instance()->phoneAccounts()[0]; |
739 | + QVERIFY(phoneAccount->accountId() == mPhoneTpAccount->uniqueIdentifier()); |
740 | + |
741 | + // now check that new phone accounts are captured |
742 | + QSignalSpy phoneAccountsChangedSpy(TelepathyHelper::instance(), SIGNAL(phoneAccountsChanged())); |
743 | + Tp::AccountPtr newAccount = addAccount("mock", "ofono", "extra"); |
744 | + QVERIFY(!newAccount.isNull()); |
745 | + |
746 | + QTRY_COMPARE(phoneAccountsChangedSpy.count(), 1); |
747 | + QCOMPARE(TelepathyHelper::instance()->phoneAccounts().count(), 2); |
748 | + |
749 | + bool accountFound = false; |
750 | + Q_FOREACH(AccountEntry *entry, TelepathyHelper::instance()->phoneAccounts()) { |
751 | + if (entry->accountId() == newAccount->uniqueIdentifier()) { |
752 | + accountFound = true; |
753 | + break; |
754 | + } |
755 | + } |
756 | + QVERIFY(accountFound); |
757 | + |
758 | + // now remove the extra phone account and make sure it is properly removed |
759 | + phoneAccountsChangedSpy.clear(); |
760 | + QVERIFY(removeAccount(newAccount)); |
761 | + QTRY_COMPARE(phoneAccountsChangedSpy.count(), 1); |
762 | + QCOMPARE(TelepathyHelper::instance()->phoneAccounts().count(), 1); |
763 | + QCOMPARE(TelepathyHelper::instance()->phoneAccounts()[0]->accountId(), phoneAccount->accountId()); |
764 | +} |
765 | + |
766 | void TelepathyHelperTest::testAccountSorting() |
767 | { |
768 | // create two accounts with modem-objpath parameters and make sure they are listed first |
FAILED: Continuous integration, rev:1057 jenkins. qa.ubuntu. com/job/ telephony- service- ci/421/ jenkins. qa.ubuntu. com/job/ telephony- service- vivid-amd64- ci/89/console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/89 jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/89/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ telephony- service- vivid-i386- ci/89/console
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/telephony- service- ci/421/ rebuild
http://