Merge lp:~boiko/telephony-service/contactwatcher_set_properties into lp:telephony-service
- contactwatcher_set_properties
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tiago Salem Herrmann |
Approved revision: | 1129 |
Merged at revision: | 1125 |
Proposed branch: | lp:~boiko/telephony-service/contactwatcher_set_properties |
Merge into: | lp:telephony-service |
Prerequisite: | lp:~tiagosh/telephony-service/fix-x-ofono-unknown |
Diff against target: |
315 lines (+100/-75) 2 files modified
Ubuntu/Telephony/contactwatcher.cpp (+89/-70) Ubuntu/Telephony/contactwatcher.h (+11/-5) |
To merge this branch: | bzr merge lp:~boiko/telephony-service/contactwatcher_set_properties |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tiago Salem Herrmann (community) | Approve | ||
PS Jenkins bot | continuous-integration | Approve | |
Review via email: mp+274311@code.launchpad.net |
This proposal supersedes a proposal from 2015-10-08.
Commit message
Make it possible to set all fields in the contact matcher.
Some components (like HistoryService's events and threads) provide a cached contact match value and are just interested in watching for changes.
Description of the change
Make it possible to set all fields in the contact matcher.
Some components (like HistoryService's events and threads) provide a cached contact match value and are just interested in watching for changes.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:1125
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:1126
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Tiago Salem Herrmann (tiagosh) wrote : Posted in a previous version of this proposal | # |
just two comments.
- 1129. By Gustavo Pichorim Boiko
-
Use the defined macros for unknown and private numbers.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:1128
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1129
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Tiago Salem Herrmann (tiagosh) wrote : | # |
Looks good.
thanks.
Preview Diff
1 | === modified file 'Ubuntu/Telephony/contactwatcher.cpp' | |||
2 | --- Ubuntu/Telephony/contactwatcher.cpp 2015-10-13 19:29:58 +0000 | |||
3 | +++ Ubuntu/Telephony/contactwatcher.cpp 2015-10-13 19:29:58 +0000 | |||
4 | @@ -53,6 +53,8 @@ | |||
5 | 53 | connect(ContactUtils::sharedManager(), | 53 | connect(ContactUtils::sharedManager(), |
6 | 54 | SIGNAL(contactsRemoved(QList<QContactId>)), | 54 | SIGNAL(contactsRemoved(QList<QContactId>)), |
7 | 55 | SLOT(onContactsRemoved(QList<QContactId>))); | 55 | SLOT(onContactsRemoved(QList<QContactId>))); |
8 | 56 | |||
9 | 57 | connect(this, SIGNAL(contactIdChanged()), SIGNAL(isUnknownChanged())); | ||
10 | 56 | } | 58 | } |
11 | 57 | 59 | ||
12 | 58 | ContactWatcher::~ContactWatcher() | 60 | ContactWatcher::~ContactWatcher() |
13 | @@ -65,8 +67,9 @@ | |||
14 | 65 | 67 | ||
15 | 66 | void ContactWatcher::startSearching() | 68 | void ContactWatcher::startSearching() |
16 | 67 | { | 69 | { |
19 | 68 | if (!mCompleted || mIdentifier.isEmpty()) { | 70 | if (!mCompleted || mIdentifier.isEmpty() || !mInteractive) { |
20 | 69 | // componenty is not ready yet or no identifier given | 71 | // component is not ready yet or no identifier given, |
21 | 72 | // or the number is not interactive and thus doesn't need contact info at all | ||
22 | 70 | return; | 73 | return; |
23 | 71 | } | 74 | } |
24 | 72 | 75 | ||
25 | @@ -112,6 +115,25 @@ | |||
26 | 112 | mRequest->start(); | 115 | mRequest->start(); |
27 | 113 | } | 116 | } |
28 | 114 | 117 | ||
29 | 118 | void ContactWatcher::clear() | ||
30 | 119 | { | ||
31 | 120 | setAlias(QString::null); | ||
32 | 121 | setContactId(QString::null); | ||
33 | 122 | setAvatar(QString::null); | ||
34 | 123 | setDetailProperties(QVariantMap()); | ||
35 | 124 | } | ||
36 | 125 | |||
37 | 126 | void ContactWatcher::updateAlias() | ||
38 | 127 | { | ||
39 | 128 | if (mIdentifier.isEmpty()) { | ||
40 | 129 | setAlias(QString::null); | ||
41 | 130 | } else if (mIdentifier.startsWith(OFONO_PRIVATE_NUMBER)) { | ||
42 | 131 | setAlias(C::dgettext("telephony-service", "Private Number")); | ||
43 | 132 | } else if (mIdentifier.startsWith(OFONO_UNKNOWN_NUMBER)) { | ||
44 | 133 | setAlias(C::dgettext("telephony-service", "Unknown Number")); | ||
45 | 134 | } | ||
46 | 135 | } | ||
47 | 136 | |||
48 | 115 | QVariantList ContactWatcher::wrapIntList(const QList<int> &list) | 137 | QVariantList ContactWatcher::wrapIntList(const QList<int> &list) |
49 | 116 | { | 138 | { |
50 | 117 | QVariantList resultList; | 139 | QVariantList resultList; |
51 | @@ -132,12 +154,21 @@ | |||
52 | 132 | 154 | ||
53 | 133 | QString ContactWatcher::contactId() const | 155 | QString ContactWatcher::contactId() const |
54 | 134 | { | 156 | { |
56 | 135 | QString id = mContactId.toString(); | 157 | return mContactId; |
57 | 158 | } | ||
58 | 159 | |||
59 | 160 | void ContactWatcher::setContactId(const QString &id) | ||
60 | 161 | { | ||
61 | 162 | if (id == mContactId) { | ||
62 | 163 | return; | ||
63 | 164 | } | ||
64 | 165 | |||
65 | 136 | if (id == QStringLiteral("qtcontacts:::")) { | 166 | if (id == QStringLiteral("qtcontacts:::")) { |
67 | 137 | return QString(); | 167 | mContactId = QString::null; |
68 | 138 | } else { | 168 | } else { |
70 | 139 | return id; | 169 | mContactId = id; |
71 | 140 | } | 170 | } |
72 | 171 | Q_EMIT contactIdChanged(); | ||
73 | 141 | } | 172 | } |
74 | 142 | 173 | ||
75 | 143 | QString ContactWatcher::avatar() const | 174 | QString ContactWatcher::avatar() const |
76 | @@ -145,11 +176,29 @@ | |||
77 | 145 | return mAvatar; | 176 | return mAvatar; |
78 | 146 | } | 177 | } |
79 | 147 | 178 | ||
80 | 179 | void ContactWatcher::setAvatar(const QString &avatar) | ||
81 | 180 | { | ||
82 | 181 | if (avatar == mAvatar) { | ||
83 | 182 | return; | ||
84 | 183 | } | ||
85 | 184 | mAvatar = avatar; | ||
86 | 185 | Q_EMIT avatarChanged(); | ||
87 | 186 | } | ||
88 | 187 | |||
89 | 148 | QString ContactWatcher::alias() const | 188 | QString ContactWatcher::alias() const |
90 | 149 | { | 189 | { |
91 | 150 | return mAlias; | 190 | return mAlias; |
92 | 151 | } | 191 | } |
93 | 152 | 192 | ||
94 | 193 | void ContactWatcher::setAlias(const QString &alias) | ||
95 | 194 | { | ||
96 | 195 | if (alias == mAlias) { | ||
97 | 196 | return; | ||
98 | 197 | } | ||
99 | 198 | mAlias = alias; | ||
100 | 199 | Q_EMIT aliasChanged(); | ||
101 | 200 | } | ||
102 | 201 | |||
103 | 153 | QString ContactWatcher::identifier() const | 202 | QString ContactWatcher::identifier() const |
104 | 154 | { | 203 | { |
105 | 155 | return mIdentifier; | 204 | return mIdentifier; |
106 | @@ -169,31 +218,19 @@ | |||
107 | 169 | mIdentifier = identifier; | 218 | mIdentifier = identifier; |
108 | 170 | Q_EMIT identifierChanged(); | 219 | Q_EMIT identifierChanged(); |
109 | 171 | 220 | ||
110 | 172 | if (mIdentifier.isEmpty() || isPrivate || isUnknown) { | ||
111 | 173 | mAlias.clear(); | ||
112 | 174 | mContactId = QContactId(); | ||
113 | 175 | mAvatar.clear(); | ||
114 | 176 | mDetailProperties.clear(); | ||
115 | 177 | |||
116 | 178 | if (isPrivate) { | ||
117 | 179 | mAlias = C::dgettext("telephony-service", "Private Number"); | ||
118 | 180 | } else if (isUnknown) { | ||
119 | 181 | mAlias = C::dgettext("telephony-service", "Unknown Number"); | ||
120 | 182 | } | ||
121 | 183 | |||
122 | 184 | Q_EMIT contactIdChanged(); | ||
123 | 185 | Q_EMIT avatarChanged(); | ||
124 | 186 | Q_EMIT aliasChanged(); | ||
125 | 187 | Q_EMIT detailPropertiesChanged(); | ||
126 | 188 | Q_EMIT isUnknownChanged(); | ||
127 | 189 | } else { | ||
128 | 190 | startSearching(); | ||
129 | 191 | } | ||
130 | 192 | |||
131 | 193 | if (isInteractive != mInteractive) { | 221 | if (isInteractive != mInteractive) { |
132 | 194 | mInteractive = isInteractive; | 222 | mInteractive = isInteractive; |
133 | 195 | Q_EMIT interactiveChanged(); | 223 | Q_EMIT interactiveChanged(); |
134 | 196 | } | 224 | } |
135 | 225 | |||
136 | 226 | if (mIdentifier.isEmpty() || isPrivate || isUnknown) { | ||
137 | 227 | updateAlias(); | ||
138 | 228 | setContactId(QString::null); | ||
139 | 229 | setAvatar(QString::null); | ||
140 | 230 | setDetailProperties(QVariantMap()); | ||
141 | 231 | } else { | ||
142 | 232 | startSearching(); | ||
143 | 233 | } | ||
144 | 197 | } | 234 | } |
145 | 198 | 235 | ||
146 | 199 | QVariantMap ContactWatcher::detailProperties() const | 236 | QVariantMap ContactWatcher::detailProperties() const |
147 | @@ -201,6 +238,15 @@ | |||
148 | 201 | return mDetailProperties; | 238 | return mDetailProperties; |
149 | 202 | } | 239 | } |
150 | 203 | 240 | ||
151 | 241 | void ContactWatcher::setDetailProperties(const QVariantMap &properties) | ||
152 | 242 | { | ||
153 | 243 | if (properties == mDetailProperties) { | ||
154 | 244 | return; | ||
155 | 245 | } | ||
156 | 246 | mDetailProperties = properties; | ||
157 | 247 | Q_EMIT detailPropertiesChanged(); | ||
158 | 248 | } | ||
159 | 249 | |||
160 | 204 | bool ContactWatcher::isUnknown() const | 250 | bool ContactWatcher::isUnknown() const |
161 | 205 | { | 251 | { |
162 | 206 | return mContactId.isNull(); | 252 | return mContactId.isNull(); |
163 | @@ -235,6 +281,7 @@ | |||
164 | 235 | void ContactWatcher::componentComplete() | 281 | void ContactWatcher::componentComplete() |
165 | 236 | { | 282 | { |
166 | 237 | mCompleted = true; | 283 | mCompleted = true; |
167 | 284 | updateAlias(); | ||
168 | 238 | startSearching(); | 285 | startSearching(); |
169 | 239 | } | 286 | } |
170 | 240 | 287 | ||
171 | @@ -258,19 +305,13 @@ | |||
172 | 258 | 305 | ||
173 | 259 | void ContactWatcher::onContactsRemoved(QList<QContactId> ids) | 306 | void ContactWatcher::onContactsRemoved(QList<QContactId> ids) |
174 | 260 | { | 307 | { |
186 | 261 | // if the current contact got removed, clear it before trying to search for a new one | 308 | Q_FOREACH(const QContactId &id, ids) { |
187 | 262 | if (ids.contains(mContactId)) { | 309 | if (id.toString() == mContactId) { |
188 | 263 | mAlias.clear(); | 310 | clear(); |
178 | 264 | mContactId = QContactId(); | ||
179 | 265 | mAvatar.clear(); | ||
180 | 266 | mDetailProperties.clear(); | ||
181 | 267 | Q_EMIT contactIdChanged(); | ||
182 | 268 | Q_EMIT avatarChanged(); | ||
183 | 269 | Q_EMIT aliasChanged(); | ||
184 | 270 | Q_EMIT detailPropertiesChanged(); | ||
185 | 271 | Q_EMIT isUnknownChanged(); | ||
189 | 272 | 311 | ||
191 | 273 | startSearching(); | 312 | startSearching(); |
192 | 313 | break; | ||
193 | 314 | } | ||
194 | 274 | } | 315 | } |
195 | 275 | } | 316 | } |
196 | 276 | 317 | ||
197 | @@ -306,32 +347,18 @@ | |||
198 | 306 | } | 347 | } |
199 | 307 | } | 348 | } |
200 | 308 | 349 | ||
219 | 309 | if (contact.id() != mContactId) { | 350 | setContactId(contact.id().toString()); |
220 | 310 | mContactId = contact.id(); | 351 | setAvatar(contact.detail<QContactAvatar>().imageUrl().toString()); |
221 | 311 | Q_EMIT contactIdChanged(); | 352 | setAlias(ContactUtils::formatContactName(contact)); |
222 | 312 | } | 353 | |
223 | 313 | 354 | QVariantMap detailProperties; | |
206 | 314 | QString newAvatar = contact.detail<QContactAvatar>().imageUrl().toString(); | ||
207 | 315 | if (newAvatar != mAvatar) { | ||
208 | 316 | mAvatar = newAvatar; | ||
209 | 317 | Q_EMIT avatarChanged(); | ||
210 | 318 | } | ||
211 | 319 | |||
212 | 320 | QString newAlias = ContactUtils::formatContactName(contact); | ||
213 | 321 | if (newAlias != mAlias) { | ||
214 | 322 | mAlias = newAlias; | ||
215 | 323 | Q_EMIT aliasChanged(); | ||
216 | 324 | Q_EMIT isUnknownChanged(); | ||
217 | 325 | } | ||
218 | 326 | |||
224 | 327 | Q_FOREACH(const QString &field, mAddressableFields) { | 355 | Q_FOREACH(const QString &field, mAddressableFields) { |
225 | 328 | if (field == "tel") { | 356 | if (field == "tel") { |
226 | 329 | Q_FOREACH(const QContactPhoneNumber phoneNumber, contact.details(QContactDetail::TypePhoneNumber)) { | 357 | Q_FOREACH(const QContactPhoneNumber phoneNumber, contact.details(QContactDetail::TypePhoneNumber)) { |
227 | 330 | if (PhoneUtils::comparePhoneNumbers(phoneNumber.number(), mIdentifier) > PhoneUtils::NO_MATCH) { | 358 | if (PhoneUtils::comparePhoneNumbers(phoneNumber.number(), mIdentifier) > PhoneUtils::NO_MATCH) { |
232 | 331 | mDetailProperties["type"] = (int)QContactDetail::TypePhoneNumber; | 359 | detailProperties["type"] = (int)QContactDetail::TypePhoneNumber; |
233 | 332 | mDetailProperties["phoneNumberSubTypes"] = wrapIntList(phoneNumber.subTypes()); | 360 | detailProperties["phoneNumberSubTypes"] = wrapIntList(phoneNumber.subTypes()); |
234 | 333 | mDetailProperties["phoneNumberContexts"] = wrapIntList(phoneNumber.contexts()); | 361 | detailProperties["phoneNumberContexts"] = wrapIntList(phoneNumber.contexts()); |
231 | 334 | Q_EMIT detailPropertiesChanged(); | ||
235 | 335 | break; | 362 | break; |
236 | 336 | } | 363 | } |
237 | 337 | } | 364 | } |
238 | @@ -339,6 +366,7 @@ | |||
239 | 339 | // FIXME: add proper support for more fields | 366 | // FIXME: add proper support for more fields |
240 | 340 | } | 367 | } |
241 | 341 | } | 368 | } |
242 | 369 | setDetailProperties(detailProperties); | ||
243 | 342 | } | 370 | } |
244 | 343 | } | 371 | } |
245 | 344 | 372 | ||
246 | @@ -351,16 +379,7 @@ | |||
247 | 351 | 379 | ||
248 | 352 | // if we got no results and we had a contact previously, we need to clear the data | 380 | // if we got no results and we had a contact previously, we need to clear the data |
249 | 353 | if (request->contacts().isEmpty() && !mContactId.isNull()) { | 381 | if (request->contacts().isEmpty() && !mContactId.isNull()) { |
260 | 354 | mAlias.clear(); | 382 | clear(); |
251 | 355 | mContactId = QContactId(); | ||
252 | 356 | mAvatar.clear(); | ||
253 | 357 | mDetailProperties.clear(); | ||
254 | 358 | |||
255 | 359 | Q_EMIT contactIdChanged(); | ||
256 | 360 | Q_EMIT avatarChanged(); | ||
257 | 361 | Q_EMIT aliasChanged(); | ||
258 | 362 | Q_EMIT detailPropertiesChanged(); | ||
259 | 363 | Q_EMIT isUnknownChanged(); | ||
261 | 364 | } | 383 | } |
262 | 365 | } | 384 | } |
263 | 366 | } | 385 | } |
264 | 367 | 386 | ||
265 | === modified file 'Ubuntu/Telephony/contactwatcher.h' | |||
266 | --- Ubuntu/Telephony/contactwatcher.h 2015-07-31 22:05:04 +0000 | |||
267 | +++ Ubuntu/Telephony/contactwatcher.h 2015-10-13 19:29:58 +0000 | |||
268 | @@ -36,14 +36,14 @@ | |||
269 | 36 | Q_OBJECT | 36 | Q_OBJECT |
270 | 37 | Q_INTERFACES(QQmlParserStatus) | 37 | Q_INTERFACES(QQmlParserStatus) |
271 | 38 | 38 | ||
275 | 39 | Q_PROPERTY(QString contactId READ contactId NOTIFY contactIdChanged) | 39 | Q_PROPERTY(QString contactId READ contactId WRITE setContactId NOTIFY contactIdChanged) |
276 | 40 | Q_PROPERTY(QString avatar READ avatar NOTIFY avatarChanged) | 40 | Q_PROPERTY(QString avatar READ avatar WRITE setAvatar NOTIFY avatarChanged) |
277 | 41 | Q_PROPERTY(QString alias READ alias NOTIFY aliasChanged) | 41 | Q_PROPERTY(QString alias READ alias WRITE setAlias NOTIFY aliasChanged) |
278 | 42 | Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) | 42 | Q_PROPERTY(QString identifier READ identifier WRITE setIdentifier NOTIFY identifierChanged) |
279 | 43 | Q_PROPERTY(QString phoneNumber READ identifier WRITE setIdentifier NOTIFY identifierChanged) | 43 | Q_PROPERTY(QString phoneNumber READ identifier WRITE setIdentifier NOTIFY identifierChanged) |
280 | 44 | // The details property changes according to the detail type. | 44 | // The details property changes according to the detail type. |
281 | 45 | // One property is always present on the map though, the "detailType" property. | 45 | // One property is always present on the map though, the "detailType" property. |
283 | 46 | Q_PROPERTY(QVariantMap detailProperties READ detailProperties NOTIFY detailPropertiesChanged) | 46 | Q_PROPERTY(QVariantMap detailProperties READ detailProperties WRITE setDetailProperties NOTIFY detailPropertiesChanged) |
284 | 47 | Q_PROPERTY(bool isUnknown READ isUnknown NOTIFY isUnknownChanged) | 47 | Q_PROPERTY(bool isUnknown READ isUnknown NOTIFY isUnknownChanged) |
285 | 48 | Q_PROPERTY(bool interactive READ interactive NOTIFY interactiveChanged) | 48 | Q_PROPERTY(bool interactive READ interactive NOTIFY interactiveChanged) |
286 | 49 | Q_PROPERTY(QStringList addressableFields READ addressableFields WRITE setAddressableFields NOTIFY addressableFieldsChanged) | 49 | Q_PROPERTY(QStringList addressableFields READ addressableFields WRITE setAddressableFields NOTIFY addressableFieldsChanged) |
287 | @@ -53,11 +53,15 @@ | |||
288 | 53 | ~ContactWatcher(); | 53 | ~ContactWatcher(); |
289 | 54 | 54 | ||
290 | 55 | QString contactId() const; | 55 | QString contactId() const; |
291 | 56 | void setContactId(const QString &id); | ||
292 | 56 | QString avatar() const; | 57 | QString avatar() const; |
293 | 58 | void setAvatar(const QString &avatar); | ||
294 | 57 | QString alias() const; | 59 | QString alias() const; |
295 | 60 | void setAlias(const QString &alias); | ||
296 | 58 | QString identifier() const; | 61 | QString identifier() const; |
297 | 59 | void setIdentifier(const QString &identifier); | 62 | void setIdentifier(const QString &identifier); |
298 | 60 | QVariantMap detailProperties() const; | 63 | QVariantMap detailProperties() const; |
299 | 64 | void setDetailProperties(const QVariantMap &properties); | ||
300 | 61 | bool isUnknown() const; | 65 | bool isUnknown() const; |
301 | 62 | bool interactive() const; | 66 | bool interactive() const; |
302 | 63 | 67 | ||
303 | @@ -91,9 +95,11 @@ | |||
304 | 91 | 95 | ||
305 | 92 | private: | 96 | private: |
306 | 93 | void startSearching(); | 97 | void startSearching(); |
307 | 98 | void clear(); | ||
308 | 99 | void updateAlias(); | ||
309 | 94 | 100 | ||
310 | 95 | QContactFetchRequest *mRequest; | 101 | QContactFetchRequest *mRequest; |
312 | 96 | QContactId mContactId; | 102 | QString mContactId; |
313 | 97 | QString mAvatar; | 103 | QString mAvatar; |
314 | 98 | QString mAlias; | 104 | QString mAlias; |
315 | 99 | QString mIdentifier; | 105 | QString mIdentifier; |
FAILED: Continuous integration, rev:1124 jenkins. qa.ubuntu. com/job/ telephony- service- ci/556/ jenkins. qa.ubuntu. com/job/ telephony- service- vivid-amd64- ci/228/ console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-armhf- ci/224/ console jenkins. qa.ubuntu. com/job/ telephony- service- vivid-i386- ci/224/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/telephony- service- ci/556/ rebuild
http://