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: mp+256937@code.launchpad.net |
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
PS Jenkins bot (ps-jenkins) wrote : | # |
- 1058. By Tiago Salem Herrmann
-
merge trunk
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://
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
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 | 54 | mRootContext->setContextProperty("telepathyHelper", TelepathyHelper::instance()); | 54 | mRootContext->setContextProperty("telepathyHelper", TelepathyHelper::instance()); |
6 | 55 | mRootContext->setContextProperty("chatManager", ChatManager::instance()); | 55 | mRootContext->setContextProperty("chatManager", ChatManager::instance()); |
7 | 56 | mRootContext->setContextProperty("callManager", CallManager::instance()); | 56 | mRootContext->setContextProperty("callManager", CallManager::instance()); |
8 | 57 | mRootContext->setContextProperty("ussdManager", USSDManager::instance()); | ||
9 | 58 | mRootContext->setContextProperty("greeter", GreeterContacts::instance()); | 57 | mRootContext->setContextProperty("greeter", GreeterContacts::instance()); |
10 | 59 | 58 | ||
11 | 60 | } | 59 | } |
12 | @@ -66,6 +65,7 @@ | |||
13 | 66 | qmlRegisterUncreatableType<CallEntry>(uri, 0, 1, "CallEntry", "Objects of this type are created in CallManager and made available to QML for usage"); | 65 | qmlRegisterUncreatableType<CallEntry>(uri, 0, 1, "CallEntry", "Objects of this type are created in CallManager and made available to QML for usage"); |
14 | 67 | qmlRegisterUncreatableType<AudioOutput>(uri, 0, 1, "AudioOutput", "Objects of this type are created in CallEntry and made available to QML for usage"); | 66 | qmlRegisterUncreatableType<AudioOutput>(uri, 0, 1, "AudioOutput", "Objects of this type are created in CallEntry and made available to QML for usage"); |
15 | 68 | qmlRegisterUncreatableType<AccountEntry>(uri, 0, 1, "AccountEntry", "Objects of this type are created in TelepathyHelper and made available to QML"); | 67 | qmlRegisterUncreatableType<AccountEntry>(uri, 0, 1, "AccountEntry", "Objects of this type are created in TelepathyHelper and made available to QML"); |
16 | 68 | qmlRegisterUncreatableType<USSDManager>(uri, 0, 1, "USSDManager", "Objects of this type are created in AccountEntry and made available to QML"); | ||
17 | 69 | qmlRegisterType<ContactWatcher>(uri, 0, 1, "ContactWatcher"); | 69 | qmlRegisterType<ContactWatcher>(uri, 0, 1, "ContactWatcher"); |
18 | 70 | qmlRegisterType<PhoneUtils>(uri, 0, 1, "PhoneUtils"); | 70 | qmlRegisterType<PhoneUtils>(uri, 0, 1, "PhoneUtils"); |
19 | 71 | } | 71 | } |
20 | 72 | 72 | ||
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 | 27 | #include <libnotify/notify.h> | 27 | #include <libnotify/notify.h> |
26 | 28 | #include "ringtone.h" | 28 | #include "ringtone.h" |
27 | 29 | #include "ussdindicator.h" | 29 | #include "ussdindicator.h" |
28 | 30 | #include "ofonoaccountentry.h" | ||
29 | 31 | #include "telepathyhelper.h" | ||
30 | 30 | 32 | ||
31 | 31 | USSDIndicator::USSDIndicator(QObject *parent) | 33 | USSDIndicator::USSDIndicator(QObject *parent) |
32 | 32 | : QObject(parent), | 34 | : QObject(parent), |
33 | @@ -35,35 +37,63 @@ | |||
34 | 35 | m_notifications("org.freedesktop.Notifications", | 37 | m_notifications("org.freedesktop.Notifications", |
35 | 36 | "/org/freedesktop/Notifications", QDBusConnection::sessionBus()) | 38 | "/org/freedesktop/Notifications", QDBusConnection::sessionBus()) |
36 | 37 | { | 39 | { |
43 | 38 | connect(USSDManager::instance(), SIGNAL(notificationReceived(const QString &)), SLOT(onNotificationReceived(const QString &))); | 40 | setupAccounts(); |
44 | 39 | connect(USSDManager::instance(), SIGNAL(requestReceived(const QString &)), SLOT(onRequestReceived(const QString &))); | 41 | connect(TelepathyHelper::instance(), SIGNAL(accountsChanged()), this, SLOT(setupAccounts())); |
39 | 40 | connect(USSDManager::instance(), SIGNAL(initiateUSSDComplete(const QString &)), SLOT(onInitiateUSSDComplete(const QString &))); | ||
40 | 41 | connect(USSDManager::instance(), SIGNAL(respondComplete(bool, const QString &)), SLOT(onRespondComplete(bool, const QString &))); | ||
41 | 42 | connect(USSDManager::instance(), SIGNAL(stateChanged(const QString &)), SLOT(onStateChanged(const QString &))); | ||
42 | 43 | |||
45 | 44 | connect(&m_notifications, SIGNAL(ActionInvoked(uint, const QString &)), this, SLOT(actionInvoked(uint, const QString &))); | 42 | connect(&m_notifications, SIGNAL(ActionInvoked(uint, const QString &)), this, SLOT(actionInvoked(uint, const QString &))); |
46 | 45 | connect(&m_notifications, SIGNAL(NotificationClosed(uint, uint)), this, SLOT(notificationClosed(uint, uint))); | 43 | connect(&m_notifications, SIGNAL(NotificationClosed(uint, uint)), this, SLOT(notificationClosed(uint, uint))); |
47 | 46 | } | 44 | } |
48 | 47 | 45 | ||
49 | 46 | void USSDIndicator::setupAccounts() | ||
50 | 47 | { | ||
51 | 48 | Q_FOREACH(AccountEntry *account, TelepathyHelper::instance()->accounts()) { | ||
52 | 49 | OfonoAccountEntry *ofonoAccount = qobject_cast<OfonoAccountEntry*>(account); | ||
53 | 50 | if (!ofonoAccount) { | ||
54 | 51 | continue; | ||
55 | 52 | } | ||
56 | 53 | |||
57 | 54 | connect(ofonoAccount->ussdManager(), SIGNAL(notificationReceived(const QString &)), SLOT(onNotificationReceived(const QString &)), Qt::UniqueConnection); | ||
58 | 55 | connect(ofonoAccount->ussdManager(), SIGNAL(requestReceived(const QString &)), SLOT(onRequestReceived(const QString &)), Qt::UniqueConnection); | ||
59 | 56 | connect(ofonoAccount->ussdManager(), SIGNAL(initiateUSSDComplete(const QString &)), SLOT(onInitiateUSSDComplete(const QString &)), Qt::UniqueConnection); | ||
60 | 57 | connect(ofonoAccount->ussdManager(), SIGNAL(respondComplete(bool, const QString &)), SLOT(onRespondComplete(bool, const QString &)), Qt::UniqueConnection); | ||
61 | 58 | connect(ofonoAccount->ussdManager(), SIGNAL(stateChanged(const QString &)), SLOT(onStateChanged(const QString &)), Qt::UniqueConnection); | ||
62 | 59 | } | ||
63 | 60 | } | ||
64 | 61 | |||
65 | 48 | void USSDIndicator::onNotificationReceived(const QString &message) | 62 | void USSDIndicator::onNotificationReceived(const QString &message) |
66 | 49 | { | 63 | { |
68 | 50 | showUSSDNotification(message, false); | 64 | USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
69 | 65 | if (!ussdManager) { | ||
70 | 66 | return; | ||
71 | 67 | } | ||
72 | 68 | showUSSDNotification(message, false, ussdManager); | ||
73 | 51 | } | 69 | } |
74 | 52 | 70 | ||
75 | 53 | void USSDIndicator::onRequestReceived(const QString &message) | 71 | void USSDIndicator::onRequestReceived(const QString &message) |
76 | 54 | { | 72 | { |
78 | 55 | showUSSDNotification(message, true); | 73 | USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
79 | 74 | if (!ussdManager) { | ||
80 | 75 | return; | ||
81 | 76 | } | ||
82 | 77 | showUSSDNotification(message, true, ussdManager); | ||
83 | 56 | } | 78 | } |
84 | 57 | 79 | ||
85 | 58 | void USSDIndicator::onInitiateUSSDComplete(const QString &ussdResp) | 80 | void USSDIndicator::onInitiateUSSDComplete(const QString &ussdResp) |
86 | 59 | { | 81 | { |
88 | 60 | showUSSDNotification(ussdResp, (USSDManager::instance()->state() == "user-response")); | 82 | USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); |
89 | 83 | if (!ussdManager) { | ||
90 | 84 | return; | ||
91 | 85 | } | ||
92 | 86 | showUSSDNotification(ussdResp, (ussdManager->state() == "user-response"), ussdManager); | ||
93 | 61 | } | 87 | } |
94 | 62 | 88 | ||
95 | 63 | void USSDIndicator::onRespondComplete(bool success, const QString &ussdResp) | 89 | void USSDIndicator::onRespondComplete(bool success, const QString &ussdResp) |
96 | 64 | { | 90 | { |
97 | 91 | USSDManager *ussdManager = qobject_cast<USSDManager*>(sender()); | ||
98 | 92 | if (!ussdManager) { | ||
99 | 93 | return; | ||
100 | 94 | } | ||
101 | 65 | if (success) { | 95 | if (success) { |
103 | 66 | showUSSDNotification(ussdResp, (USSDManager::instance()->state() == "user-response")); | 96 | showUSSDNotification(ussdResp, (ussdManager->state() == "user-response"), ussdManager); |
104 | 67 | } | 97 | } |
105 | 68 | } | 98 | } |
106 | 69 | 99 | ||
107 | @@ -72,7 +102,7 @@ | |||
108 | 72 | // TODO: check if we should close notifications when the state is idle | 102 | // TODO: check if we should close notifications when the state is idle |
109 | 73 | } | 103 | } |
110 | 74 | 104 | ||
112 | 75 | void USSDIndicator::showUSSDNotification(const QString &message, bool replyRequired) | 105 | void USSDIndicator::showUSSDNotification(const QString &message, bool replyRequired, USSDManager *ussdManager) |
113 | 76 | { | 106 | { |
114 | 77 | USSDMenu *menu = replyRequired ? &m_menuRequest : &m_menuNotification; | 107 | USSDMenu *menu = replyRequired ? &m_menuRequest : &m_menuNotification; |
115 | 78 | QString actionId = "ok_id"; | 108 | QString actionId = "ok_id"; |
116 | @@ -102,7 +132,7 @@ | |||
117 | 102 | "", message, | 132 | "", message, |
118 | 103 | QStringList() << actionId << actionLabel << "cancel_id" | 133 | QStringList() << actionId << actionLabel << "cancel_id" |
119 | 104 | << C::gettext("Cancel"), notificationHints, 0); | 134 | << C::gettext("Cancel"), notificationHints, 0); |
121 | 105 | 135 | mUSSDRequests[m_notificationId] = ussdManager; | |
122 | 106 | 136 | ||
123 | 107 | Ringtone::instance()->playIncomingMessageSound(); | 137 | Ringtone::instance()->playIncomingMessageSound(); |
124 | 108 | } | 138 | } |
125 | @@ -113,12 +143,17 @@ | |||
126 | 113 | return; | 143 | return; |
127 | 114 | } | 144 | } |
128 | 115 | 145 | ||
129 | 146 | USSDManager *ussdManager = mUSSDRequests.take(id); | ||
130 | 147 | if (!ussdManager) { | ||
131 | 148 | return; | ||
132 | 149 | } | ||
133 | 150 | |||
134 | 116 | m_notificationId = 0; | 151 | m_notificationId = 0; |
135 | 117 | 152 | ||
136 | 118 | if (actionKey == "reply_id") { | 153 | if (actionKey == "reply_id") { |
138 | 119 | USSDManager::instance()->respond(m_menuRequest.response(), USSDManager::instance()->activeAccountId()); | 154 | ussdManager->respond(m_menuRequest.response()); |
139 | 120 | } else if (actionKey == "cancel_id") { | 155 | } else if (actionKey == "cancel_id") { |
141 | 121 | USSDManager::instance()->cancel(USSDManager::instance()->activeAccountId()); | 156 | ussdManager->cancel(); |
142 | 122 | } | 157 | } |
143 | 123 | m_menuRequest.clearResponse(); | 158 | m_menuRequest.clearResponse(); |
144 | 124 | } | 159 | } |
145 | 125 | 160 | ||
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 | 27 | #include "indicator/NotificationsInterface.h" | 27 | #include "indicator/NotificationsInterface.h" |
151 | 28 | #include "ussdmanager.h" | 28 | #include "ussdmanager.h" |
152 | 29 | #include "ussdmenu.h" | 29 | #include "ussdmenu.h" |
153 | 30 | #include "ofonoaccountentry.h" | ||
154 | 30 | 31 | ||
155 | 31 | class USSDIndicator : public QObject | 32 | class USSDIndicator : public QObject |
156 | 32 | { | 33 | { |
157 | 33 | Q_OBJECT | 34 | Q_OBJECT |
158 | 34 | public: | 35 | public: |
159 | 35 | explicit USSDIndicator(QObject *parent = 0); | 36 | explicit USSDIndicator(QObject *parent = 0); |
161 | 36 | void showUSSDNotification(const QString &message, bool replyRequired); | 37 | void showUSSDNotification(const QString &message, bool replyRequired, USSDManager *ussdManager); |
162 | 37 | 38 | ||
163 | 38 | public Q_SLOTS: | 39 | public Q_SLOTS: |
164 | 39 | void onNotificationReceived(const QString &message); | 40 | void onNotificationReceived(const QString &message); |
165 | @@ -43,12 +44,17 @@ | |||
166 | 43 | void onStateChanged(const QString &state); | 44 | void onStateChanged(const QString &state); |
167 | 44 | void actionInvoked(uint id, const QString &actionKey); | 45 | void actionInvoked(uint id, const QString &actionKey); |
168 | 45 | void notificationClosed(uint id, uint reason); | 46 | void notificationClosed(uint id, uint reason); |
169 | 47 | private Q_SLOTS: | ||
170 | 48 | void setupAccounts(); | ||
171 | 49 | |||
172 | 46 | private: | 50 | private: |
173 | 47 | unsigned int m_notificationId; | 51 | unsigned int m_notificationId; |
174 | 48 | USSDMenu m_menuRequest; | 52 | USSDMenu m_menuRequest; |
175 | 49 | USSDMenu m_menuNotification; | 53 | USSDMenu m_menuNotification; |
176 | 50 | QString mPendingMessage; | 54 | QString mPendingMessage; |
177 | 51 | org::freedesktop::Notifications m_notifications; | 55 | org::freedesktop::Notifications m_notifications; |
178 | 56 | QMap<int, USSDManager*> mUSSDRequests; | ||
179 | 57 | QList<OfonoAccountEntry*> mAccounts; | ||
180 | 52 | }; | 58 | }; |
181 | 53 | 59 | ||
182 | 54 | #endif // USSDINDICATOR_H | 60 | #endif // USSDINDICATOR_H |
183 | 55 | 61 | ||
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 | 37 | connect(this, | 37 | connect(this, |
189 | 38 | SIGNAL(statusMessageChanged()), | 38 | SIGNAL(statusMessageChanged()), |
190 | 39 | SIGNAL(emergencyCallsAvailableChanged())); | 39 | SIGNAL(emergencyCallsAvailableChanged())); |
191 | 40 | |||
192 | 41 | mUssdManager = new USSDManager(this, this); | ||
193 | 42 | } | ||
194 | 43 | |||
195 | 44 | USSDManager *OfonoAccountEntry::ussdManager() const | ||
196 | 45 | { | ||
197 | 46 | return mUssdManager; | ||
198 | 40 | } | 47 | } |
199 | 41 | 48 | ||
200 | 42 | QStringList OfonoAccountEntry::emergencyNumbers() const | 49 | QStringList OfonoAccountEntry::emergencyNumbers() const |
201 | 43 | 50 | ||
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 | 23 | #define OFONOACCOUNTENTRY_H | 23 | #define OFONOACCOUNTENTRY_H |
207 | 24 | 24 | ||
208 | 25 | #include "accountentry.h" | 25 | #include "accountentry.h" |
209 | 26 | #include "ussdmanager.h" | ||
210 | 26 | 27 | ||
211 | 27 | class OfonoAccountEntry : public AccountEntry | 28 | class OfonoAccountEntry : public AccountEntry |
212 | 28 | { | 29 | { |
213 | @@ -35,6 +36,7 @@ | |||
214 | 35 | Q_PROPERTY(bool emergencyCallsAvailable READ emergencyCallsAvailable NOTIFY emergencyCallsAvailableChanged) | 36 | Q_PROPERTY(bool emergencyCallsAvailable READ emergencyCallsAvailable NOTIFY emergencyCallsAvailableChanged) |
215 | 36 | Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged) | 37 | Q_PROPERTY(bool simLocked READ simLocked NOTIFY simLockedChanged) |
216 | 37 | Q_PROPERTY(QString serial READ serial NOTIFY serialChanged) | 38 | Q_PROPERTY(QString serial READ serial NOTIFY serialChanged) |
217 | 39 | Q_PROPERTY(USSDManager* ussdManager READ ussdManager CONSTANT) | ||
218 | 38 | friend class AccountEntryFactory; | 40 | friend class AccountEntryFactory; |
219 | 39 | 41 | ||
220 | 40 | public: | 42 | public: |
221 | @@ -46,6 +48,7 @@ | |||
222 | 46 | bool emergencyCallsAvailable() const; | 48 | bool emergencyCallsAvailable() const; |
223 | 47 | bool simLocked() const; | 49 | bool simLocked() const; |
224 | 48 | QString serial() const; | 50 | QString serial() const; |
225 | 51 | USSDManager *ussdManager() const; | ||
226 | 49 | 52 | ||
227 | 50 | // reimplemented from AccountEntry | 53 | // reimplemented from AccountEntry |
228 | 51 | virtual AccountEntry::AccountType type() const; | 54 | virtual AccountEntry::AccountType type() const; |
229 | @@ -81,6 +84,7 @@ | |||
230 | 81 | uint mVoicemailCount; | 84 | uint mVoicemailCount; |
231 | 82 | bool mVoicemailIndicator; | 85 | bool mVoicemailIndicator; |
232 | 83 | QString mSerial; | 86 | QString mSerial; |
233 | 87 | USSDManager *mUssdManager; | ||
234 | 84 | }; | 88 | }; |
235 | 85 | 89 | ||
236 | 86 | #endif // OFONOACCOUNTENTRY_H | 90 | #endif // OFONOACCOUNTENTRY_H |
237 | 87 | 91 | ||
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 | 162 | return activeAccountList; | 162 | return activeAccountList; |
243 | 163 | } | 163 | } |
244 | 164 | 164 | ||
245 | 165 | QList<AccountEntry*> TelepathyHelper::phoneAccounts() const | ||
246 | 166 | { | ||
247 | 167 | QList<AccountEntry*> accountList; | ||
248 | 168 | Q_FOREACH(AccountEntry *account, mAccounts) { | ||
249 | 169 | if (account->type() == AccountEntry::PhoneAccount) { | ||
250 | 170 | accountList << account; | ||
251 | 171 | } | ||
252 | 172 | } | ||
253 | 173 | return accountList; | ||
254 | 174 | } | ||
255 | 175 | |||
256 | 176 | QQmlListProperty<AccountEntry> TelepathyHelper::qmlPhoneAccounts() | ||
257 | 177 | { | ||
258 | 178 | return QQmlListProperty<AccountEntry>(this, 0, phoneAccountsCount, phoneAccountAt); | ||
259 | 179 | } | ||
260 | 180 | |||
261 | 165 | QQmlListProperty<AccountEntry> TelepathyHelper::qmlAccounts() | 181 | QQmlListProperty<AccountEntry> TelepathyHelper::qmlAccounts() |
262 | 166 | { | 182 | { |
263 | 167 | return QQmlListProperty<AccountEntry>(this, 0, accountsCount, accountAt); | 183 | return QQmlListProperty<AccountEntry>(this, 0, accountsCount, accountAt); |
264 | @@ -357,12 +373,24 @@ | |||
265 | 357 | return spec; | 373 | return spec; |
266 | 358 | } | 374 | } |
267 | 359 | 375 | ||
268 | 376 | int TelepathyHelper::phoneAccountsCount(QQmlListProperty<AccountEntry> *p) | ||
269 | 377 | { | ||
270 | 378 | Q_UNUSED(p) | ||
271 | 379 | return TelepathyHelper::instance()->phoneAccounts().count(); | ||
272 | 380 | } | ||
273 | 381 | |||
274 | 360 | int TelepathyHelper::accountsCount(QQmlListProperty<AccountEntry> *p) | 382 | int TelepathyHelper::accountsCount(QQmlListProperty<AccountEntry> *p) |
275 | 361 | { | 383 | { |
276 | 362 | Q_UNUSED(p) | 384 | Q_UNUSED(p) |
277 | 363 | return TelepathyHelper::instance()->accounts().count(); | 385 | return TelepathyHelper::instance()->accounts().count(); |
278 | 364 | } | 386 | } |
279 | 365 | 387 | ||
280 | 388 | AccountEntry *TelepathyHelper::phoneAccountAt(QQmlListProperty<AccountEntry> *p, int index) | ||
281 | 389 | { | ||
282 | 390 | Q_UNUSED(p) | ||
283 | 391 | return TelepathyHelper::instance()->phoneAccounts()[index]; | ||
284 | 392 | } | ||
285 | 393 | |||
286 | 366 | AccountEntry *TelepathyHelper::accountAt(QQmlListProperty<AccountEntry> *p, int index) | 394 | AccountEntry *TelepathyHelper::accountAt(QQmlListProperty<AccountEntry> *p, int index) |
287 | 367 | { | 395 | { |
288 | 368 | Q_UNUSED(p) | 396 | Q_UNUSED(p) |
289 | @@ -391,6 +419,7 @@ | |||
290 | 391 | 419 | ||
291 | 392 | Q_EMIT accountIdsChanged(); | 420 | Q_EMIT accountIdsChanged(); |
292 | 393 | Q_EMIT accountsChanged(); | 421 | Q_EMIT accountsChanged(); |
293 | 422 | Q_EMIT phoneAccountsChanged(); | ||
294 | 394 | Q_EMIT activeAccountsChanged(); | 423 | Q_EMIT activeAccountsChanged(); |
295 | 395 | onSettingsChanged("defaultSimForMessages"); | 424 | onSettingsChanged("defaultSimForMessages"); |
296 | 396 | onSettingsChanged("defaultSimForCalls"); | 425 | onSettingsChanged("defaultSimForCalls"); |
297 | @@ -418,6 +447,7 @@ | |||
298 | 418 | 447 | ||
299 | 419 | Q_EMIT accountIdsChanged(); | 448 | Q_EMIT accountIdsChanged(); |
300 | 420 | Q_EMIT accountsChanged(); | 449 | Q_EMIT accountsChanged(); |
301 | 450 | Q_EMIT phoneAccountsChanged(); | ||
302 | 421 | Q_EMIT activeAccountsChanged(); | 451 | Q_EMIT activeAccountsChanged(); |
303 | 422 | onSettingsChanged("defaultSimForMessages"); | 452 | onSettingsChanged("defaultSimForMessages"); |
304 | 423 | onSettingsChanged("defaultSimForCalls"); | 453 | onSettingsChanged("defaultSimForCalls"); |
305 | @@ -452,6 +482,7 @@ | |||
306 | 452 | 482 | ||
307 | 453 | Q_EMIT accountIdsChanged(); | 483 | Q_EMIT accountIdsChanged(); |
308 | 454 | Q_EMIT accountsChanged(); | 484 | Q_EMIT accountsChanged(); |
309 | 485 | Q_EMIT phoneAccountsChanged(); | ||
310 | 455 | Q_EMIT activeAccountsChanged(); | 486 | Q_EMIT activeAccountsChanged(); |
311 | 456 | onSettingsChanged("defaultSimForMessages"); | 487 | onSettingsChanged("defaultSimForMessages"); |
312 | 457 | onSettingsChanged("defaultSimForCalls"); | 488 | onSettingsChanged("defaultSimForCalls"); |
313 | 458 | 489 | ||
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 | 48 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) | 48 | Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged) |
319 | 49 | Q_PROPERTY(QStringList accountIds READ accountIds NOTIFY accountIdsChanged) | 49 | Q_PROPERTY(QStringList accountIds READ accountIds NOTIFY accountIdsChanged) |
320 | 50 | Q_PROPERTY(QQmlListProperty<AccountEntry> accounts READ qmlAccounts NOTIFY accountsChanged) | 50 | Q_PROPERTY(QQmlListProperty<AccountEntry> accounts READ qmlAccounts NOTIFY accountsChanged) |
321 | 51 | Q_PROPERTY(QQmlListProperty<AccountEntry> phoneAccounts READ qmlPhoneAccounts NOTIFY phoneAccountsChanged) | ||
322 | 51 | Q_PROPERTY(QQmlListProperty<AccountEntry> activeAccounts READ qmlActiveAccounts NOTIFY activeAccountsChanged) | 52 | Q_PROPERTY(QQmlListProperty<AccountEntry> activeAccounts READ qmlActiveAccounts NOTIFY activeAccountsChanged) |
323 | 52 | Q_PROPERTY(AccountEntry *defaultMessagingAccount READ defaultMessagingAccount NOTIFY defaultMessagingAccountChanged) | 53 | Q_PROPERTY(AccountEntry *defaultMessagingAccount READ defaultMessagingAccount NOTIFY defaultMessagingAccountChanged) |
324 | 53 | Q_PROPERTY(AccountEntry *defaultCallAccount READ defaultCallAccount NOTIFY defaultCallAccountChanged) | 54 | Q_PROPERTY(AccountEntry *defaultCallAccount READ defaultCallAccount NOTIFY defaultCallAccountChanged) |
325 | @@ -65,8 +66,10 @@ | |||
326 | 65 | 66 | ||
327 | 66 | static TelepathyHelper *instance(); | 67 | static TelepathyHelper *instance(); |
328 | 67 | QList<AccountEntry*> accounts() const; | 68 | QList<AccountEntry*> accounts() const; |
329 | 69 | QList<AccountEntry*> phoneAccounts() const; | ||
330 | 68 | QList<AccountEntry*> activeAccounts() const; | 70 | QList<AccountEntry*> activeAccounts() const; |
331 | 69 | QQmlListProperty<AccountEntry> qmlAccounts(); | 71 | QQmlListProperty<AccountEntry> qmlAccounts(); |
332 | 72 | QQmlListProperty<AccountEntry> qmlPhoneAccounts(); | ||
333 | 70 | QQmlListProperty<AccountEntry> qmlActiveAccounts(); | 73 | QQmlListProperty<AccountEntry> qmlActiveAccounts(); |
334 | 71 | ChannelObserver *channelObserver() const; | 74 | ChannelObserver *channelObserver() const; |
335 | 72 | QDBusInterface *handlerInterface() const; | 75 | QDBusInterface *handlerInterface() const; |
336 | @@ -97,7 +100,9 @@ | |||
337 | 97 | static AccountEntry *accountAt(QQmlListProperty<AccountEntry> *p, int index); | 100 | static AccountEntry *accountAt(QQmlListProperty<AccountEntry> *p, int index); |
338 | 98 | static int activeAccountsCount(QQmlListProperty<AccountEntry> *p); | 101 | static int activeAccountsCount(QQmlListProperty<AccountEntry> *p); |
339 | 99 | static AccountEntry *activeAccountAt(QQmlListProperty<AccountEntry> *p, int index); | 102 | static AccountEntry *activeAccountAt(QQmlListProperty<AccountEntry> *p, int index); |
341 | 100 | 103 | static int phoneAccountsCount(QQmlListProperty<AccountEntry> *p); | |
342 | 104 | static AccountEntry *phoneAccountAt(QQmlListProperty<AccountEntry> *p, int index); | ||
343 | 105 | |||
344 | 101 | Q_SIGNALS: | 106 | Q_SIGNALS: |
345 | 102 | void channelObserverCreated(ChannelObserver *observer); | 107 | void channelObserverCreated(ChannelObserver *observer); |
346 | 103 | void channelObserverUnregistered(); | 108 | void channelObserverUnregistered(); |
347 | @@ -105,6 +110,7 @@ | |||
348 | 105 | void connectedChanged(); | 110 | void connectedChanged(); |
349 | 106 | void accountIdsChanged(); | 111 | void accountIdsChanged(); |
350 | 107 | void accountsChanged(); | 112 | void accountsChanged(); |
351 | 113 | void phoneAccountsChanged(); | ||
352 | 108 | void activeAccountsChanged(); | 114 | void activeAccountsChanged(); |
353 | 109 | void setupReady(); | 115 | void setupReady(); |
354 | 110 | void defaultMessagingAccountChanged(); | 116 | void defaultMessagingAccountChanged(); |
355 | 111 | 117 | ||
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 | 1 | /* | 1 | /* |
362 | 2 | * Copyright (C) 2012 Canonical, Ltd. | 2 | * Copyright (C) 2012-2015 Canonical, Ltd. |
363 | 3 | * | 3 | * |
364 | 4 | * Authors: | 4 | * Authors: |
365 | 5 | * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> | 5 | * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
366 | @@ -30,198 +30,105 @@ | |||
367 | 30 | typedef QMap<QString, QVariant> dbusQMap; | 30 | typedef QMap<QString, QVariant> dbusQMap; |
368 | 31 | Q_DECLARE_METATYPE(dbusQMap) | 31 | Q_DECLARE_METATYPE(dbusQMap) |
369 | 32 | 32 | ||
401 | 33 | USSDManager *USSDManager::instance() | 33 | USSDManager::USSDManager(AccountEntry *account, QObject *parent) |
402 | 34 | { | 34 | : QObject(parent), |
403 | 35 | static USSDManager *self = new USSDManager(); | 35 | mState("idle"), |
404 | 36 | return self; | 36 | mAccount(account) |
405 | 37 | } | 37 | { |
406 | 38 | 38 | connect(mAccount, SIGNAL(connectedChanged()), this, SLOT(onConnectionChanged())); | |
407 | 39 | USSDManager::USSDManager(QObject *parent) | 39 | onConnectionChanged(); |
408 | 40 | : QObject(parent) | 40 | } |
409 | 41 | { | 41 | |
410 | 42 | connect(TelepathyHelper::instance(), SIGNAL(accountsChanged()), SLOT(onAccountsChanged())); | 42 | void USSDManager::initiate(const QString &command) |
411 | 43 | onAccountsChanged(); | 43 | { |
412 | 44 | } | 44 | QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
382 | 45 | |||
383 | 46 | Tp::ConnectionPtr USSDManager::connectionForAccountId(const QString &accountId) | ||
384 | 47 | { | ||
385 | 48 | AccountEntry *accountEntry; | ||
386 | 49 | if (accountId.isNull()) { | ||
387 | 50 | accountEntry = TelepathyHelper::instance()->accounts()[0]; | ||
388 | 51 | } else { | ||
389 | 52 | accountEntry = TelepathyHelper::instance()->accountForId(accountId); | ||
390 | 53 | } | ||
391 | 54 | |||
392 | 55 | return accountEntry->account()->connection(); | ||
393 | 56 | } | ||
394 | 57 | |||
395 | 58 | void USSDManager::initiate(const QString &command, const QString &accountId) | ||
396 | 59 | { | ||
397 | 60 | Tp::ConnectionPtr conn = connectionForAccountId(accountId); | ||
398 | 61 | QString busName = conn->busName(); | ||
399 | 62 | QString objectPath = conn->objectPath(); | ||
400 | 63 | QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); | ||
413 | 64 | ussdIface.asyncCall("Initiate", command); | 45 | ussdIface.asyncCall("Initiate", command); |
414 | 65 | } | 46 | } |
415 | 66 | 47 | ||
417 | 67 | void USSDManager::respond(const QString &reply, const QString &accountId) | 48 | void USSDManager::respond(const QString &reply) |
418 | 68 | { | 49 | { |
423 | 69 | Tp::ConnectionPtr conn = connectionForAccountId(accountId); | 50 | QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
420 | 70 | QString busName = conn->busName(); | ||
421 | 71 | QString objectPath = conn->objectPath(); | ||
422 | 72 | QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); | ||
424 | 73 | ussdIface.asyncCall("Respond", reply); | 51 | ussdIface.asyncCall("Respond", reply); |
425 | 74 | } | 52 | } |
426 | 75 | 53 | ||
428 | 76 | void USSDManager::cancel(const QString &accountId) | 54 | void USSDManager::cancel() |
429 | 77 | { | 55 | { |
434 | 78 | Tp::ConnectionPtr conn = connectionForAccountId(accountId); | 56 | QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
431 | 79 | QString busName = conn->busName(); | ||
432 | 80 | QString objectPath = conn->objectPath(); | ||
433 | 81 | QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); | ||
435 | 82 | ussdIface.asyncCall("Cancel"); | 57 | ussdIface.asyncCall("Cancel"); |
436 | 83 | } | 58 | } |
437 | 84 | 59 | ||
528 | 85 | void USSDManager::disconnectAllSignals(const Tp::ConnectionPtr& conn) | 60 | void USSDManager::connectAllSignals() |
529 | 86 | { | 61 | { |
530 | 87 | if (conn.isNull()) { | 62 | if (mBusName.isEmpty() || mObjectPath.isEmpty()) { |
531 | 88 | return; | 63 | return; |
532 | 89 | } | 64 | } |
533 | 90 | 65 | ||
534 | 91 | QString busName = conn->busName(); | 66 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); |
535 | 92 | QString objectPath = conn->objectPath(); | 67 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); |
536 | 93 | 68 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); | |
537 | 94 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); | 69 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); |
538 | 95 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); | 70 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); |
539 | 96 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); | 71 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); |
540 | 97 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); | 72 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); |
541 | 98 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); | 73 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); |
542 | 99 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); | 74 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); |
543 | 100 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); | 75 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); |
544 | 101 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); | 76 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); |
545 | 102 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); | 77 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); |
546 | 103 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); | 78 | QDBusConnection::sessionBus().connect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); |
547 | 104 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); | 79 | } |
548 | 105 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); | 80 | |
549 | 106 | QDBusConnection::sessionBus().disconnect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); | 81 | void USSDManager::disconnectAllSignals() |
550 | 107 | } | 82 | { |
551 | 108 | 83 | if (mBusName.isEmpty() || mObjectPath.isEmpty()) { | |
552 | 109 | void USSDManager::connectAllSignals(const Tp::ConnectionPtr& conn) | 84 | return; |
553 | 110 | { | 85 | } |
554 | 111 | if (conn.isNull()) { | 86 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); |
555 | 112 | return; | 87 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); |
556 | 113 | } | 88 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); |
557 | 114 | 89 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); | |
558 | 115 | QString busName = conn->busName(); | 90 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); |
559 | 116 | QString objectPath = conn->objectPath(); | 91 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); |
560 | 117 | 92 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); | |
561 | 118 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "StateChanged", this, SLOT(onStateChanged(QString))); | 93 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); |
562 | 119 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RequestReceived", this, SIGNAL(requestReceived(QString))); | 94 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); |
563 | 120 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "NotificationReceived", this, SIGNAL(notificationReceived(QString))); | 95 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); |
564 | 121 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateUSSDComplete", this, SIGNAL(initiateUSSDComplete(QString))); | 96 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); |
565 | 122 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "RespondComplete", this, SIGNAL(respondComplete(bool, QString))); | 97 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); |
566 | 123 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "BarringComplete", this, SIGNAL(barringComplete(QString, QString, QVariantMap))); | 98 | QDBusConnection::sessionBus().disconnect(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); |
567 | 124 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ForwardingComplete", this, SIGNAL(forwardingComplete(QString, QString, QVariantMap))); | 99 | } |
568 | 125 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "WaitingComplete", this, SIGNAL(waitingComplete(QString, QVariantMap))); | 100 | |
569 | 126 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLinePresentationComplete", this, SIGNAL(callingLinePresentationComplete(QString, QString))); | 101 | void USSDManager::onConnectionChanged() |
570 | 127 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "CallingLineRestrictionComplete", this, SIGNAL(callingLineRestrictionComplete(QString, QString))); | 102 | { |
571 | 128 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLineRestrictionComplete", this, SIGNAL(connectedLineRestrictionComplete(QString, QString))); | 103 | disconnectAllSignals(); |
572 | 129 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "ConnectedLinePresentationComplete", this, SIGNAL(connectedLinePresentationComplete(QString, QString))); | 104 | |
573 | 130 | QDBusConnection::sessionBus().connect(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE, "InitiateFailed", this, SIGNAL(initiateFailed())); | 105 | if (mAccount->account()->connection().isNull()) { |
574 | 131 | } | 106 | qDebug() << "USSDManager: Failed to connect signals"; |
575 | 132 | 107 | return; | |
576 | 133 | void USSDManager::accountConnectedChanged() | 108 | } |
577 | 134 | { | 109 | |
578 | 135 | AccountEntry *accountEntry = qobject_cast<AccountEntry*>(sender()); | 110 | mBusName = mAccount->account()->connection()->busName(); |
579 | 136 | if (!accountEntry) { | 111 | mObjectPath = mAccount->account()->connection()->objectPath(); |
580 | 137 | return; | 112 | |
581 | 138 | } | 113 | QDBusInterface ussdIface(mBusName, mObjectPath, CANONICAL_TELEPHONY_USSD_IFACE); |
582 | 139 | Tp::ConnectionPtr conn(accountEntry->account()->connection()); | 114 | mState = ussdIface.property("State").toString(); |
583 | 140 | disconnectAllSignals(conn); | 115 | |
584 | 141 | 116 | connectAllSignals(); | |
585 | 142 | if (accountEntry->connected()) { | 117 | } |
586 | 143 | QString busName = conn->busName(); | 118 | |
587 | 144 | QString objectPath = conn->objectPath(); | 119 | void USSDManager::onStateChanged(const QString &state) |
588 | 145 | 120 | { | |
589 | 146 | connectAllSignals(conn); | 121 | mState = state; |
590 | 147 | 122 | Q_EMIT stateChanged(mState); | |
501 | 148 | QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); | ||
502 | 149 | mStates[accountEntry->accountId()] = ussdIface.property("State").toString(); | ||
503 | 150 | } | ||
504 | 151 | } | ||
505 | 152 | |||
506 | 153 | void USSDManager::onAccountsChanged() | ||
507 | 154 | { | ||
508 | 155 | Q_FOREACH (AccountEntry *accountEntry, TelepathyHelper::instance()->accounts()) { | ||
509 | 156 | QObject::disconnect(accountEntry, SIGNAL(connectedChanged()), this, SLOT(accountConnectedChanged())); | ||
510 | 157 | QObject::connect(accountEntry, SIGNAL(connectedChanged()), this, SLOT(accountConnectedChanged())); | ||
511 | 158 | |||
512 | 159 | // disconnect all and reconnect only the online accounts | ||
513 | 160 | Tp::ConnectionPtr conn(accountEntry->account()->connection()); | ||
514 | 161 | disconnectAllSignals(conn); | ||
515 | 162 | mStates.remove(accountEntry->accountId()); | ||
516 | 163 | |||
517 | 164 | if (accountEntry->connected()) { | ||
518 | 165 | QString busName = conn->busName(); | ||
519 | 166 | QString objectPath = conn->objectPath(); | ||
520 | 167 | |||
521 | 168 | connectAllSignals(conn); | ||
522 | 169 | |||
523 | 170 | QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); | ||
524 | 171 | mStates[accountEntry->accountId()] = ussdIface.property("State").toString(); | ||
525 | 172 | } | ||
526 | 173 | } | ||
527 | 174 | Q_EMIT stateChanged(state()); | ||
591 | 175 | Q_EMIT activeChanged(); | 123 | Q_EMIT activeChanged(); |
592 | 176 | Q_EMIT activeAccountIdChanged(); | ||
593 | 177 | } | ||
594 | 178 | |||
595 | 179 | void USSDManager::onStateChanged(const QString &) | ||
596 | 180 | { | ||
597 | 181 | Q_FOREACH (AccountEntry *accountEntry, TelepathyHelper::instance()->accounts()) { | ||
598 | 182 | Tp::ConnectionPtr conn(accountEntry->account()->connection()); | ||
599 | 183 | if (accountEntry->connected()) { | ||
600 | 184 | QString busName = conn->busName(); | ||
601 | 185 | QString objectPath = conn->objectPath(); | ||
602 | 186 | QDBusInterface ussdIface(busName, objectPath, CANONICAL_TELEPHONY_USSD_IFACE); | ||
603 | 187 | mStates[accountEntry->accountId()] = ussdIface.property("State").toString(); | ||
604 | 188 | } | ||
605 | 189 | } | ||
606 | 190 | Q_EMIT stateChanged(state()); | ||
607 | 191 | } | 124 | } |
608 | 192 | 125 | ||
609 | 193 | bool USSDManager::active() const | 126 | bool USSDManager::active() const |
610 | 194 | { | 127 | { |
631 | 195 | QMap<QString, QString>::const_iterator i = mStates.constBegin(); | 128 | return mState != "idle"; |
612 | 196 | while (i != mStates.constEnd()) { | ||
613 | 197 | if (i.value() != "idle") { | ||
614 | 198 | return true; | ||
615 | 199 | } | ||
616 | 200 | ++i; | ||
617 | 201 | } | ||
618 | 202 | return false; | ||
619 | 203 | } | ||
620 | 204 | |||
621 | 205 | QString USSDManager::activeAccountId() const | ||
622 | 206 | { | ||
623 | 207 | QMap<QString, QString>::const_iterator i = mStates.constBegin(); | ||
624 | 208 | while (i != mStates.constEnd()) { | ||
625 | 209 | if (i.value() != "idle") { | ||
626 | 210 | return i.key(); | ||
627 | 211 | } | ||
628 | 212 | ++i; | ||
629 | 213 | } | ||
630 | 214 | return QString::null; | ||
632 | 215 | } | 129 | } |
633 | 216 | 130 | ||
634 | 217 | QString USSDManager::state() const | 131 | QString USSDManager::state() const |
635 | 218 | { | 132 | { |
644 | 219 | QMap<QString, QString>::const_iterator i = mStates.constBegin(); | 133 | return mState; |
637 | 220 | while (i != mStates.constEnd()) { | ||
638 | 221 | if (i.value() != "idle") { | ||
639 | 222 | return i.value(); | ||
640 | 223 | } | ||
641 | 224 | ++i; | ||
642 | 225 | } | ||
643 | 226 | return "idle"; | ||
645 | 227 | } | 134 | } |
646 | 228 | 135 | ||
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 | 28 | #include <TelepathyQt/Connection> | 28 | #include <TelepathyQt/Connection> |
652 | 29 | 29 | ||
653 | 30 | class TelepathyHelper; | 30 | class TelepathyHelper; |
654 | 31 | class AccountEntry; | ||
655 | 31 | 32 | ||
656 | 32 | class USSDManager : public QObject | 33 | class USSDManager : public QObject |
657 | 33 | { | 34 | { |
658 | @@ -35,30 +36,23 @@ | |||
659 | 35 | Q_PROPERTY(bool active | 36 | Q_PROPERTY(bool active |
660 | 36 | READ active | 37 | READ active |
661 | 37 | NOTIFY activeChanged) | 38 | NOTIFY activeChanged) |
662 | 38 | Q_PROPERTY(QString activeAccountId | ||
663 | 39 | READ activeAccountId | ||
664 | 40 | NOTIFY activeAccountIdChanged) | ||
665 | 41 | Q_PROPERTY(QString state | 39 | Q_PROPERTY(QString state |
666 | 42 | READ state | 40 | READ state |
667 | 43 | NOTIFY stateChanged) | 41 | NOTIFY stateChanged) |
668 | 44 | public: | 42 | public: |
673 | 45 | static USSDManager *instance(); | 43 | explicit USSDManager(AccountEntry *account, QObject *parent = 0); |
674 | 46 | Q_INVOKABLE void initiate(const QString &command, const QString &accountId = QString::null); | 44 | Q_INVOKABLE void initiate(const QString &command); |
675 | 47 | Q_INVOKABLE void respond(const QString &reply, const QString &accountId = QString::null); | 45 | Q_INVOKABLE void respond(const QString &reply); |
676 | 48 | Q_INVOKABLE void cancel(const QString &accountId = QString::null); | 46 | Q_INVOKABLE void cancel(); |
677 | 49 | 47 | ||
678 | 50 | bool active() const; | 48 | bool active() const; |
679 | 51 | QString activeAccountId() const; | ||
680 | 52 | QString state() const; | 49 | QString state() const; |
681 | 53 | 50 | ||
682 | 54 | public Q_SLOTS: | 51 | public Q_SLOTS: |
683 | 55 | void onAccountsChanged(); | ||
684 | 56 | void onStateChanged(const QString &state); | 52 | void onStateChanged(const QString &state); |
685 | 57 | void accountConnectedChanged(); | ||
686 | 58 | 53 | ||
687 | 59 | Q_SIGNALS: | 54 | Q_SIGNALS: |
688 | 60 | void activeChanged(); | 55 | void activeChanged(); |
689 | 61 | void activeAccountIdChanged(); | ||
690 | 62 | void stateChanged(const QString &state); | 56 | void stateChanged(const QString &state); |
691 | 63 | 57 | ||
692 | 64 | void notificationReceived(const QString &message); | 58 | void notificationReceived(const QString &message); |
693 | @@ -75,15 +69,17 @@ | |||
694 | 75 | void connectedLineRestrictionComplete(const QString &ssOp, const QString &status); | 69 | void connectedLineRestrictionComplete(const QString &ssOp, const QString &status); |
695 | 76 | void initiateFailed(); | 70 | void initiateFailed(); |
696 | 77 | 71 | ||
697 | 72 | private Q_SLOTS: | ||
698 | 73 | void onConnectionChanged(); | ||
699 | 74 | |||
700 | 78 | private: | 75 | private: |
709 | 79 | explicit USSDManager(QObject *parent = 0); | 76 | void connectAllSignals(); |
710 | 80 | 77 | void disconnectAllSignals(); | |
711 | 81 | Tp::ConnectionPtr connectionForAccountId(const QString &accountId = QString::null); | 78 | |
712 | 82 | 79 | QString mState; | |
713 | 83 | void disconnectAllSignals(const Tp::ConnectionPtr& conn); | 80 | QString mBusName; |
714 | 84 | void connectAllSignals(const Tp::ConnectionPtr& conn); | 81 | QString mObjectPath; |
715 | 85 | 82 | AccountEntry *mAccount; | |
708 | 86 | QMap<QString, QString> mStates; | ||
716 | 87 | }; | 83 | }; |
717 | 88 | 84 | ||
718 | 89 | #endif // USSDMANAGER_H | 85 | #endif // USSDMANAGER_H |
719 | 90 | 86 | ||
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 | 37 | void cleanup(); | 37 | void cleanup(); |
725 | 38 | void testConnected(); | 38 | void testConnected(); |
726 | 39 | void testAccounts(); | 39 | void testAccounts(); |
727 | 40 | void testPhoneAccounts(); | ||
728 | 40 | void testAccountSorting(); | 41 | void testAccountSorting(); |
729 | 41 | void testAccountIds(); | 42 | void testAccountIds(); |
730 | 42 | void testActiveAccounts(); | 43 | void testActiveAccounts(); |
731 | @@ -147,6 +148,37 @@ | |||
732 | 147 | QCOMPARE(TelepathyHelper::instance()->accounts()[1]->accountId(), second->accountId()); | 148 | QCOMPARE(TelepathyHelper::instance()->accounts()[1]->accountId(), second->accountId()); |
733 | 148 | } | 149 | } |
734 | 149 | 150 | ||
735 | 151 | void TelepathyHelperTest::testPhoneAccounts() | ||
736 | 152 | { | ||
737 | 153 | QCOMPARE(TelepathyHelper::instance()->phoneAccounts().count(), 1); | ||
738 | 154 | AccountEntry *phoneAccount = TelepathyHelper::instance()->phoneAccounts()[0]; | ||
739 | 155 | QVERIFY(phoneAccount->accountId() == mPhoneTpAccount->uniqueIdentifier()); | ||
740 | 156 | |||
741 | 157 | // now check that new phone accounts are captured | ||
742 | 158 | QSignalSpy phoneAccountsChangedSpy(TelepathyHelper::instance(), SIGNAL(phoneAccountsChanged())); | ||
743 | 159 | Tp::AccountPtr newAccount = addAccount("mock", "ofono", "extra"); | ||
744 | 160 | QVERIFY(!newAccount.isNull()); | ||
745 | 161 | |||
746 | 162 | QTRY_COMPARE(phoneAccountsChangedSpy.count(), 1); | ||
747 | 163 | QCOMPARE(TelepathyHelper::instance()->phoneAccounts().count(), 2); | ||
748 | 164 | |||
749 | 165 | bool accountFound = false; | ||
750 | 166 | Q_FOREACH(AccountEntry *entry, TelepathyHelper::instance()->phoneAccounts()) { | ||
751 | 167 | if (entry->accountId() == newAccount->uniqueIdentifier()) { | ||
752 | 168 | accountFound = true; | ||
753 | 169 | break; | ||
754 | 170 | } | ||
755 | 171 | } | ||
756 | 172 | QVERIFY(accountFound); | ||
757 | 173 | |||
758 | 174 | // now remove the extra phone account and make sure it is properly removed | ||
759 | 175 | phoneAccountsChangedSpy.clear(); | ||
760 | 176 | QVERIFY(removeAccount(newAccount)); | ||
761 | 177 | QTRY_COMPARE(phoneAccountsChangedSpy.count(), 1); | ||
762 | 178 | QCOMPARE(TelepathyHelper::instance()->phoneAccounts().count(), 1); | ||
763 | 179 | QCOMPARE(TelepathyHelper::instance()->phoneAccounts()[0]->accountId(), phoneAccount->accountId()); | ||
764 | 180 | } | ||
765 | 181 | |||
766 | 150 | void TelepathyHelperTest::testAccountSorting() | 182 | void TelepathyHelperTest::testAccountSorting() |
767 | 151 | { | 183 | { |
768 | 152 | // create two accounts with modem-objpath parameters and make sure they are listed first | 184 | // 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://