216 { |
207 { |
217 return QContactManager::buildUri(managerName(), managerParameters()); |
208 return QContactManager::buildUri(managerName(), managerParameters()); |
218 } |
209 } |
219 |
210 |
220 /*! |
211 /*! |
221 Returns a list of contact ids sorted according to the given list of \a sortOrders. |
|
222 Depending on the backend, this operation may involve retrieving all the contacts. |
|
223 Any error which occurs will be saved in \a error. |
|
224 */ |
|
225 QList<QContactLocalId> QContactManagerEngine::contactIds(const QList<QContactSortOrder>& sortOrders, QContactManager::Error& error) const |
|
226 { |
|
227 Q_UNUSED(sortOrders); |
|
228 error = QContactManager::NotSupportedError; |
|
229 return QList<QContactLocalId>(); |
|
230 } |
|
231 |
|
232 /*! |
|
233 Returns a list of contact ids that match the given \a filter, sorted according to the given list of \a sortOrders. |
212 Returns a list of contact ids that match the given \a filter, sorted according to the given list of \a sortOrders. |
234 Depending on the backend, this filtering operation may involve retrieving all the contacts. |
213 Depending on the backend, this filtering operation may involve retrieving all the contacts. |
235 Any error which occurs will be saved in \a error. |
214 Any error which occurs will be saved in \a error. |
236 */ |
215 */ |
237 QList<QContactLocalId> QContactManagerEngine::contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error& error) const |
216 QList<QContactLocalId> QContactManagerEngine::contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, QContactManager::Error* error) const |
238 { |
217 { |
239 /* Slow way */ |
218 Q_UNUSED(filter); |
240 QList<QContactLocalId> ret; |
|
241 |
|
242 /* If the filter matches all ids, then return the list of all ids */ |
|
243 if (filter.type() == QContactFilter::DefaultFilter) { |
|
244 const QList<QContactLocalId>& allIds = contactIds(sortOrders, error); |
|
245 if (error != QContactManager::NoError) |
|
246 return ret; |
|
247 return allIds; |
|
248 } |
|
249 |
|
250 /* Otherwise, retrieve all contacts, test and return matching */ |
|
251 const QList<QContact>& all = contacts(sortOrders, QStringList(), error); |
|
252 |
|
253 if (error != QContactManager::NoError) |
|
254 return ret; |
|
255 |
|
256 for (int j = 0; j < all.count(); j++) { |
|
257 if (testFilter(filter, all.at(j))) |
|
258 ret << all.at(j).localId(); |
|
259 } |
|
260 |
|
261 return ret; |
|
262 } |
|
263 |
|
264 /*! |
|
265 Returns the list of contacts stored in the manager sorted according to the given list of \a sortOrders. |
|
266 If the given list of detail definition names \a definitionRestrictions is empty, each contact returned will include |
|
267 all of the details which are stored in it, otherwise only those details which are of a definition whose name is included |
|
268 in the \a definitionRestrictions list will be included. |
|
269 Any error which occurs will be saved in \a error. |
|
270 */ |
|
271 QList<QContact> QContactManagerEngine::contacts(const QList<QContactSortOrder>& sortOrders, const QStringList& definitionRestrictions, QContactManager::Error& error) const |
|
272 { |
|
273 Q_UNUSED(sortOrders); |
219 Q_UNUSED(sortOrders); |
274 Q_UNUSED(definitionRestrictions); |
220 |
275 error = QContactManager::NotSupportedError; |
221 *error = QContactManager::NotSupportedError; |
|
222 return QList<QContactLocalId>(); |
|
223 } |
|
224 |
|
225 /*! |
|
226 Returns the list of contacts which match the given \a filter stored in the manager sorted according to the given list of \a sortOrders. |
|
227 |
|
228 Any operation error which occurs will be saved in \a error. |
|
229 |
|
230 The \a fetchHint parameter describes the optimization hints that a manager may take. |
|
231 If the \a fetchHint is the default constructed hint, all existing details, relationships and action preferences |
|
232 in the matching contacts will be returned. A client should not make changes to a contact which has |
|
233 been retrieved using a fetch hint other than the default fetch hint. Doing so will result in information |
|
234 loss when saving the contact back to the manager (as the "new" restricted contact will |
|
235 replace the previously saved contact in the backend). |
|
236 |
|
237 \sa QContactFetchHint |
|
238 */ |
|
239 QList<QContact> QContactManagerEngine::contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, const QContactFetchHint& fetchHint, QContactManager::Error* error) const |
|
240 { |
|
241 Q_UNUSED(filter); |
|
242 Q_UNUSED(sortOrders); |
|
243 Q_UNUSED(fetchHint); |
|
244 *error = QContactManager::NotSupportedError; |
276 return QList<QContact>(); |
245 return QList<QContact>(); |
277 } |
246 } |
278 |
247 |
279 /*! |
248 /*! |
280 Returns a list of contacs that match the given \a filter, sorted according to the given list of \a sortOrders. |
|
281 Depending on the backend, this filtering operation may involve retrieving all the contacts. |
|
282 If the given list of detail definition names \a definitionRestrictions is empty, each contact returned will include |
|
283 all of the details which are stored in it, otherwise only those details which are of a definition whose name is included |
|
284 in the \a definitionRestrictions list will be included. |
|
285 Any error which occurs will be saved in \a error. |
|
286 */ |
|
287 QList<QContact> QContactManagerEngine::contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders, const QStringList& definitionRestrictions, QContactManager::Error& error) const |
|
288 { |
|
289 /* Slow way */ |
|
290 QList<QContact> ret; |
|
291 |
|
292 /* Retrieve each contact.. . . */ |
|
293 const QList<QContact>& all = contacts(sortOrders, definitionRestrictions, error); |
|
294 if (error != QContactManager::NoError) |
|
295 return ret; |
|
296 |
|
297 if (filter.type() == QContactFilter::DefaultFilter) |
|
298 return all; |
|
299 |
|
300 for (int j = 0; j < all.count(); j++) { |
|
301 if (testFilter(filter, all.at(j))) { |
|
302 ret << all.at(j); |
|
303 } |
|
304 } |
|
305 |
|
306 return ret; |
|
307 } |
|
308 |
|
309 /*! |
|
310 Returns the contact in the database identified by \a contactId. |
249 Returns the contact in the database identified by \a contactId. |
311 If the list of detail definition names \a definitionRestrictions given is non-empty, |
250 |
312 the contact returned will contain at least those details which are of a definition whose name is |
251 If the contact does not exist, an empty, default constructed QContact will be returned, |
313 contained in the \a definitionRestrictions list. |
252 and the \a error will be set to \c QContactManager::DoesNotExistError. |
314 Note that the returned contact may also contain other details, but this function guarantees that |
253 |
315 all details whose definition name is included in the given list of definition names \a definitionRestrictions |
254 Any operation error which occurs will be saved in \a error. |
316 will be included in the returned contact. |
255 |
317 |
256 The \a fetchHint parameter describes the optimization hints that a manager may take. |
318 The default implementation returns the entire contact. |
257 If the \a fetchHint is the default constructed hint, all existing details, relationships and action preferences |
319 |
258 in the matching contact will be returned. A client should not make changes to a contact which has |
320 Any errors encountered should be stored to \a error. |
259 been retrieved using a fetch hint other than the default fetch hint. Doing so will result in information |
321 */ |
260 loss when saving the contact back to the manager (as the "new" restricted contact will |
322 QContact QContactManagerEngine::contact(const QContactLocalId& contactId, const QStringList& definitionRestrictions, QContactManager::Error& error) const |
261 replace the previously saved contact in the backend). |
|
262 |
|
263 \sa QContactFetchHint |
|
264 */ |
|
265 QContact QContactManagerEngine::contact(const QContactLocalId& contactId, const QContactFetchHint& fetchHint, QContactManager::Error* error) const |
323 { |
266 { |
324 Q_UNUSED(contactId); |
267 Q_UNUSED(contactId); |
325 Q_UNUSED(definitionRestrictions); |
268 Q_UNUSED(fetchHint); |
326 error = QContactManager::NotSupportedError; |
269 *error = QContactManager::NotSupportedError; |
327 return QContact(); |
270 return QContact(); |
328 } |
271 } |
329 |
272 |
330 /*! |
273 /*! |
331 Sets the id of the "self" contact to the given \a contactId. |
274 Sets the id of the "self" contact to the given \a contactId. |
336 return false; if the backend does not support the |
279 return false; if the backend does not support the |
337 concept of a "self" contact, the \a error will be set to |
280 concept of a "self" contact, the \a error will be set to |
338 \c QContactManager::NotSupportedError and the function will |
281 \c QContactManager::NotSupportedError and the function will |
339 return false. |
282 return false. |
340 */ |
283 */ |
341 bool QContactManagerEngine::setSelfContactId(const QContactLocalId& contactId, QContactManager::Error& error) |
284 bool QContactManagerEngine::setSelfContactId(const QContactLocalId& contactId, QContactManager::Error* error) |
342 { |
285 { |
343 Q_UNUSED(contactId); |
286 Q_UNUSED(contactId); |
344 error = QContactManager::NotSupportedError; |
287 |
|
288 *error = QContactManager::NotSupportedError; |
345 return false; |
289 return false; |
346 } |
290 } |
347 |
291 |
348 /*! |
292 /*! |
349 Returns the id of the "self" contact which has previously been set. |
293 Returns the id of the "self" contact which has previously been set. |
350 If no "self" contact has been set, or if the self contact was removed |
294 If no "self" contact has been set, or if the self contact was removed |
351 from the manager after being set, or if the backend does not support |
295 from the manager after being set, or if the backend does not support |
352 the concept of a "self" contact, an invalid id will be returned |
296 the concept of a "self" contact, an invalid id will be returned |
353 and the \a error will be set to \c QContactManager::DoesNotExistError. |
297 and the \a error will be set to \c QContactManager::DoesNotExistError. |
354 */ |
298 */ |
355 QContactLocalId QContactManagerEngine::selfContactId(QContactManager::Error& error) const |
299 QContactLocalId QContactManagerEngine::selfContactId(QContactManager::Error* error) const |
356 { |
300 { |
357 error = QContactManager::DoesNotExistError; |
301 *error = QContactManager::DoesNotExistError; |
358 return QContactLocalId(); |
302 return QContactLocalId(); |
359 } |
303 } |
360 |
304 |
361 /*! |
305 /*! |
362 Returns a list of relationships of the given \a relationshipType in which the contact identified by the given \a participantId participates in the given \a role. |
306 Returns a list of relationships of the given \a relationshipType in which the contact identified by the given \a participantId participates in the given \a role. |
363 If \a participantId is the default-constructed id, \a role is ignored and all relationships of the given \a relationshipType are returned. |
307 If \a participantId is the default-constructed id, \a role is ignored and all relationships of the given \a relationshipType are returned. |
364 If \a relationshipType is empty, relationships of any type are returned. |
308 If \a relationshipType is empty, relationships of any type are returned. |
365 If no relationships of the given \a relationshipType in which the contact identified by the given \a participantId is involved in the given \a role exists, |
309 If no relationships of the given \a relationshipType in which the contact identified by the given \a participantId is involved in the given \a role exists, |
366 \a error is set to QContactManager::DoesNotExistError. |
310 \a error is set to QContactManager::DoesNotExistError. |
367 */ |
311 */ |
368 QList<QContactRelationship> QContactManagerEngine::relationships(const QString& relationshipType, const QContactId& participantId, QContactRelationshipFilter::Role role, QContactManager::Error& error) const |
312 QList<QContactRelationship> QContactManagerEngine::relationships(const QString& relationshipType, const QContactId& participantId, QContactRelationship::Role role, QContactManager::Error* error) const |
369 { |
313 { |
370 Q_UNUSED(relationshipType); |
314 Q_UNUSED(relationshipType); |
371 Q_UNUSED(participantId); |
315 Q_UNUSED(participantId); |
372 Q_UNUSED(role); |
316 Q_UNUSED(role); |
373 error = QContactManager::NotSupportedError; |
317 |
|
318 *error = QContactManager::NotSupportedError; |
374 return QList<QContactRelationship>(); |
319 return QList<QContactRelationship>(); |
|
320 } |
|
321 |
|
322 /*! |
|
323 Saves the given \a relationships in the database and returns true if the operation was successful. |
|
324 For any relationship which was unable to be saved, an entry into the \a errorMap will be created, |
|
325 with the key being the index into the input relationships list, and the value being the error which |
|
326 occurred for that index. |
|
327 |
|
328 The overall operation error will be saved in \a error. |
|
329 */ |
|
330 bool QContactManagerEngine::saveRelationships(QList<QContactRelationship>* relationships, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error) |
|
331 { |
|
332 Q_UNUSED(relationships); |
|
333 Q_UNUSED(errorMap); |
|
334 |
|
335 *error = QContactManager::NotSupportedError; |
|
336 return false; |
375 } |
337 } |
376 |
338 |
377 /*! |
339 /*! |
378 Saves the given \a relationship in the database. If the relationship already exists in the database, this function will |
340 Saves the given \a relationship in the database. If the relationship already exists in the database, this function will |
379 return \c false and the \a error will be set to \c QContactManager::AlreadyExistsError. |
341 return \c false and the \a error will be set to \c QContactManager::AlreadyExistsError. |
380 If the relationship is saved successfully, this function will return \c true and \a error will be set |
342 If the relationship is saved successfully, this function will return \c true and \a error will be set |
381 to \c QContactManager::NoError. Note that relationships cannot be updated directly using this function; in order |
343 to \c QContactManager::NoError. Note that relationships cannot be updated directly using this function; in order |
382 to update a relationship, you must remove the old relationship, make the required modifications, and then save it. |
344 to update a relationship, you must remove the old relationship, make the required modifications, and then save it. |
383 |
345 |
384 The given relationship is invalid if it is circular (one of the destination contacts is also the source contact), or |
346 The given relationship is invalid if it is circular (the first contact is the second contact), or |
385 if it references a non-existent local contact (either source or destination). If the given \a relationship is invalid, |
347 if it references a non-existent local contact (either the first or second contact). If the given \a relationship is invalid, |
386 the function will return \c false and the \a error will be set to \c QContactManager::InvalidRelationshipError. |
348 the function will return \c false and the \a error will be set to \c QContactManager::InvalidRelationshipError. |
387 If the given \a relationship could not be saved in the database (due to backend limitations) |
349 |
388 the function will return \c false and \a error will be set to \c QContactManager::NotSupportedError. |
350 The default implementation of this function converts the argument into a call to saveRelationships. |
389 |
351 */ |
390 If any destination contact manager URI is not set in the \a relationship, these will be |
352 bool QContactManagerEngine::saveRelationship(QContactRelationship *relationship, QContactManager::Error *error) |
391 automatically set to the URI of this manager, before the relationship is saved. |
353 { |
392 */ |
354 // Convert to a list op |
393 bool QContactManagerEngine::saveRelationship(QContactRelationship* relationship, QContactManager::Error& error) |
355 if (relationship) { |
394 { |
356 QList<QContactRelationship> list; |
395 Q_UNUSED(relationship); |
357 list.append(*relationship); |
396 error = QContactManager::NotSupportedError; |
358 |
397 return false; |
359 QMap<int, QContactManager::Error> errors; |
398 } |
360 bool ret = saveRelationships(&list, &errors, error); |
399 |
361 |
400 /*! |
362 if (errors.count() > 0) |
401 Saves the given \a relationships in the database and returns a list of error codes. Any error which occurs will be saved in \a error. |
363 *error = errors.begin().value(); |
402 */ |
364 |
403 QList<QContactManager::Error> QContactManagerEngine::saveRelationships(QList<QContactRelationship>* relationships, QContactManager::Error& error) |
365 *relationship = list.value(0); |
404 { |
366 return ret; |
405 Q_UNUSED(relationships); |
367 } else { |
406 error = QContactManager::NotSupportedError; |
368 *error = QContactManager::BadArgumentError; |
407 return QList<QContactManager::Error>(); |
369 return false; |
|
370 } |
408 } |
371 } |
409 |
372 |
410 /*! |
373 /*! |
411 Removes the given \a relationship from the manager. If the relationship exists in the manager, the relationship |
374 Removes the given \a relationship from the manager. If the relationship exists in the manager, the relationship |
412 will be removed, the \a error will be set to \c QContactManager::NoError and this function will return true. If no such |
375 will be removed, the \a error will be set to \c QContactManager::NoError and this function will return true. If no such |
413 relationship exists in the manager, the \a error will be set to \c QContactManager::DoesNotExistError and this function |
376 relationship exists in the manager, the \a error will be set to \c QContactManager::DoesNotExistError and this function |
414 will return false. |
377 will return false. |
415 |
378 |
416 The priority of the relationship is ignored when determining existence of the relationship. |
379 The default implementation of this function converts the argument into a call to removeRelationships |
417 */ |
380 */ |
418 bool QContactManagerEngine::removeRelationship(const QContactRelationship& relationship, QContactManager::Error& error) |
381 bool QContactManagerEngine::removeRelationship(const QContactRelationship& relationship, QContactManager::Error* error) |
419 { |
382 { |
420 Q_UNUSED(relationship); |
383 // Convert to a list op |
421 error = QContactManager::DoesNotExistError; |
384 QList<QContactRelationship> list; |
|
385 list.append(relationship); |
|
386 |
|
387 QMap<int, QContactManager::Error> errors; |
|
388 bool ret = removeRelationships(list, &errors, error); |
|
389 |
|
390 if (errors.count() > 0) |
|
391 *error = errors.begin().value(); |
|
392 |
|
393 return ret; |
|
394 } |
|
395 |
|
396 |
|
397 /*! |
|
398 Removes the given \a relationships from the database and returns true if the operation was successful. |
|
399 For any relationship which was unable to be removed, an entry into the \a errorMap will be created, |
|
400 with the key being the index into the input relationships list, and the value being the error which |
|
401 occurred for that index. |
|
402 |
|
403 The overall operation error will be saved in \a error. |
|
404 */ |
|
405 bool QContactManagerEngine::removeRelationships(const QList<QContactRelationship>& relationships, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error) |
|
406 { |
|
407 Q_UNUSED(relationships); |
|
408 Q_UNUSED(errorMap); |
|
409 |
|
410 *error = QContactManager::NotSupportedError; |
422 return false; |
411 return false; |
423 } |
|
424 |
|
425 /*! |
|
426 Removes the given \a relationships from the database and returns a list of error codes. Any error which occurs will be saved in \a error. |
|
427 */ |
|
428 QList<QContactManager::Error> QContactManagerEngine::removeRelationships(const QList<QContactRelationship>& relationships, QContactManager::Error& error) |
|
429 { |
|
430 Q_UNUSED(relationships); |
|
431 error = QContactManager::DoesNotExistError; |
|
432 return QList<QContactManager::Error>(); |
|
433 } |
412 } |
434 |
413 |
435 /*! |
414 /*! |
436 Synthesizes the display label of the given \a contact in a platform specific manner. |
415 Synthesizes the display label of the given \a contact in a platform specific manner. |
437 Any error that occurs will be stored in \a error. |
416 Any error that occurs will be stored in \a error. |
438 Returns the synthesized display label. |
417 Returns the synthesized display label. |
439 */ |
418 */ |
440 QString QContactManagerEngine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error& error) const |
419 QString QContactManagerEngine::synthesizedDisplayLabel(const QContact& contact, QContactManager::Error* error) const |
441 { |
420 { |
442 // synthesize the display name from the name of the contact, or, failing that, the organisation of the contact. |
421 // synthesize the display name from the name of the contact, or, failing that, the organisation of the contact. |
443 error = QContactManager::NoError; |
422 *error = QContactManager::NoError; |
444 QList<QContactDetail> allNames = contact.details(QContactName::DefinitionName); |
423 QList<QContactDetail> allNames = contact.details(QContactName::DefinitionName); |
445 |
424 |
446 const QLatin1String space(" "); |
425 const QLatin1String space(" "); |
447 |
426 |
448 // synthesize the display label from the name. |
427 // synthesize the display label from the name. |
495 if (!org.name().isEmpty()) { |
474 if (!org.name().isEmpty()) { |
496 return org.name(); |
475 return org.name(); |
497 } |
476 } |
498 } |
477 } |
499 |
478 |
500 error = QContactManager::UnspecifiedError; |
479 *error = QContactManager::UnspecifiedError; |
501 return QString(); |
480 return QString(); |
502 } |
481 } |
503 |
482 |
504 /*! |
483 /*! |
505 Returns a copy of the given contact \a contact with its display label set to \a displayLabel. |
484 Sets the contact display label of \a contact to the supplied \a displayLabel. |
|
485 |
506 This function does not touch the database in any way, and is purely a convenience to allow engine implementations to set the display label. |
486 This function does not touch the database in any way, and is purely a convenience to allow engine implementations to set the display label. |
507 */ |
487 */ |
508 QContact QContactManagerEngine::setContactDisplayLabel(const QString& displayLabel, const QContact& contact) const |
488 void QContactManagerEngine::setContactDisplayLabel(QContact* contact, const QString& displayLabel) |
509 { |
489 { |
510 QContact retn = contact; |
|
511 QContactDisplayLabel dl; |
490 QContactDisplayLabel dl; |
512 dl.setValue(QContactDisplayLabel::FieldLabel, displayLabel); |
491 dl.setValue(QContactDisplayLabel::FieldLabel, displayLabel); |
513 setDetailAccessConstraints(&dl, QContactDetail::Irremovable); |
492 setDetailAccessConstraints(&dl, QContactDetail::Irremovable); |
514 retn.d->m_details.replace(0, dl); |
493 contact->d->m_details.replace(0, dl); |
515 return retn; |
|
516 } |
494 } |
517 |
495 |
518 /*! |
496 /*! |
519 Returns true if the given \a feature is supported by this engine for contacts of the given \a contactType |
497 Returns true if the given \a feature is supported by this engine for contacts of the given \a contactType |
520 */ |
498 */ |
521 bool QContactManagerEngine::hasFeature(QContactManager::ManagerFeature feature, const QString& contactType) const |
499 bool QContactManagerEngine::hasFeature(QContactManager::ManagerFeature feature, const QString& contactType) const |
522 { |
500 { |
523 Q_UNUSED(feature); |
501 Q_UNUSED(feature); |
524 Q_UNUSED(contactType); |
502 Q_UNUSED(contactType); |
|
503 |
525 return false; |
504 return false; |
526 } |
505 } |
|
506 |
|
507 /*! |
|
508 Given an input \a filter, returns the canonical version of the filter. |
|
509 |
|
510 Some of the following transformations may be applied: |
|
511 \list |
|
512 \o Any QContactActionFilters are transformed into the corresponding |
|
513 QContactFilters returned by matching actions |
|
514 \o Any QContactInvalidFilters contained in a union filter will be removed |
|
515 \o Any default QContactFilters contained in an intersection filter will be removed |
|
516 \o Any QContactIntersectionFilters with a QContactInvalidFilter contained will be |
|
517 replaced with a QContactInvalidFilter |
|
518 \o Any QContactUnionFilters with a default QContactFilter contained will be replaced |
|
519 with a default QContactFilter |
|
520 \o An empty QContactIntersectionFilter will be replaced with a QContactDefaultFilter |
|
521 \o An empty QContactUnionFilter will be replaced with a QContactInvalidFilter |
|
522 \o An empty QContactLocalIdFilter will be replaced with a QContactInvalidFilter |
|
523 \o An intersection or union filter with a single entry will be replaced by that entry |
|
524 \o A QContactDetailFilter or QContactDetailRangeFilter with no definition name will be replaced with a QContactInvalidFilter |
|
525 \o A QContactDetailRangeFilter with no range specified will be converted to a QContactDetailFilter |
|
526 \endlist |
|
527 */ |
|
528 QContactFilter QContactManagerEngine::canonicalizedFilter(const QContactFilter &filter) |
|
529 { |
|
530 switch(filter.type()) { |
|
531 case QContactFilter::ActionFilter: |
|
532 { |
|
533 // Find any matching actions, and do a union filter on their filter objects |
|
534 QContactActionFilter af(filter); |
|
535 QList<QContactActionDescriptor> descriptors = QContactAction::actionDescriptors(af.actionName(), af.vendorName(), af.implementationVersion()); |
|
536 |
|
537 QList<QContactFilter> filters; |
|
538 // There's a small wrinkle if there's a value specified in the action filter |
|
539 // we have to adjust any contained QContactDetailFilters to have that value |
|
540 // or test if a QContactDetailRangeFilter contains this value already |
|
541 for (int j = 0; j < descriptors.count(); j++) { |
|
542 QContactAction* action = QContactAction::action(descriptors.at(j)); |
|
543 |
|
544 // Action filters are not allowed to return action filters, at all |
|
545 // it's too annoying to check for recursion |
|
546 QContactFilter d = action->contactFilter(af.value()); |
|
547 delete action; // clean up. |
|
548 if (!validateActionFilter(d)) |
|
549 continue; |
|
550 |
|
551 filters.append(d); |
|
552 } |
|
553 |
|
554 if (filters.count() == 0) |
|
555 return QContactInvalidFilter(); |
|
556 if (filters.count() == 1) |
|
557 return filters.first(); |
|
558 |
|
559 QContactUnionFilter f; |
|
560 f.setFilters(filters); |
|
561 return canonicalizedFilter(f); |
|
562 } |
|
563 break; |
|
564 |
|
565 case QContactFilter::IntersectionFilter: |
|
566 { |
|
567 QContactIntersectionFilter f(filter); |
|
568 QList<QContactFilter> filters = f.filters(); |
|
569 QList<QContactFilter>::iterator it = filters.begin(); |
|
570 |
|
571 // XXX in theory we can remove duplicates in a set filter |
|
572 while (it != filters.end()) { |
|
573 QContactFilter canon = canonicalizedFilter(*it); |
|
574 if (canon.type() == QContactFilter::DefaultFilter) { |
|
575 it = filters.erase(it); |
|
576 } else if (canon.type() == QContactFilter::InvalidFilter) { |
|
577 return QContactInvalidFilter(); |
|
578 } else { |
|
579 *it = canon; |
|
580 ++it; |
|
581 } |
|
582 } |
|
583 |
|
584 if (filters.count() == 0) |
|
585 return QContactFilter(); |
|
586 if (filters.count() == 1) |
|
587 return filters.first(); |
|
588 |
|
589 f.setFilters(filters); |
|
590 return f; |
|
591 } |
|
592 break; |
|
593 |
|
594 case QContactFilter::UnionFilter: |
|
595 { |
|
596 QContactUnionFilter f(filter); |
|
597 QList<QContactFilter> filters = f.filters(); |
|
598 QList<QContactFilter>::iterator it = filters.begin(); |
|
599 |
|
600 // XXX in theory we can remove duplicates in a set filter |
|
601 while (it != filters.end()) { |
|
602 QContactFilter canon = canonicalizedFilter(*it); |
|
603 if (canon.type() == QContactFilter::InvalidFilter) { |
|
604 it = filters.erase(it); |
|
605 } else if (canon.type() == QContactFilter::DefaultFilter) { |
|
606 return QContactFilter(); |
|
607 } else { |
|
608 *it = canon; |
|
609 ++it; |
|
610 } |
|
611 } |
|
612 |
|
613 if (filters.count() == 0) |
|
614 return QContactInvalidFilter(); |
|
615 if (filters.count() == 1) |
|
616 return filters.first(); |
|
617 |
|
618 f.setFilters(filters); |
|
619 return f; |
|
620 } |
|
621 break; |
|
622 |
|
623 case QContactFilter::LocalIdFilter: |
|
624 { |
|
625 QContactLocalIdFilter f(filter); |
|
626 if (f.ids().count() == 0) |
|
627 return QContactInvalidFilter(); |
|
628 } |
|
629 break; // fall through to return at end |
|
630 |
|
631 case QContactFilter::ContactDetailRangeFilter: |
|
632 { |
|
633 QContactDetailRangeFilter f(filter); |
|
634 if (f.detailDefinitionName().isEmpty()) |
|
635 return QContactInvalidFilter(); |
|
636 if (f.minValue() == f.maxValue() |
|
637 && f.rangeFlags() == (QContactDetailRangeFilter::ExcludeLower | QContactDetailRangeFilter::ExcludeUpper)) |
|
638 return QContactInvalidFilter(); |
|
639 if ((f.minValue().isNull() && f.maxValue().isNull()) || (f.minValue() == f.maxValue())) { |
|
640 QContactDetailFilter df; |
|
641 df.setDetailDefinitionName(f.detailDefinitionName(), f.detailFieldName()); |
|
642 df.setMatchFlags(f.matchFlags()); |
|
643 df.setValue(f.minValue()); |
|
644 return df; |
|
645 } |
|
646 } |
|
647 break; // fall through to return at end |
|
648 |
|
649 case QContactFilter::ContactDetailFilter: |
|
650 { |
|
651 QContactDetailFilter f(filter); |
|
652 if (f.detailDefinitionName().isEmpty()) |
|
653 return QContactInvalidFilter(); |
|
654 } |
|
655 break; // fall through to return at end |
|
656 |
|
657 default: |
|
658 break; // fall through to return at end |
|
659 } |
|
660 return filter; |
|
661 } |
|
662 |
527 |
663 |
528 /*! |
664 /*! |
529 Returns a whether the supplied \a filter can be implemented |
665 Returns a whether the supplied \a filter can be implemented |
530 natively by this engine. If not, the base class implementation |
666 natively by this engine. If not, the base class implementation |
531 will emulate the functionality. |
667 will emulate the functionality. |
532 */ |
668 */ |
533 bool QContactManagerEngine::isFilterSupported(const QContactFilter& filter) const |
669 bool QContactManagerEngine::isFilterSupported(const QContactFilter& filter) const |
534 { |
670 { |
535 Q_UNUSED(filter); |
671 Q_UNUSED(filter); |
|
672 |
536 return false; |
673 return false; |
537 } |
674 } |
538 |
675 |
539 /*! |
676 /*! |
540 Returns the list of data types supported by this engine. |
677 Returns the list of data types supported by this engine. |
825 f.setDataType(QVariant::StringList); |
968 f.setDataType(QVariant::StringList); |
826 fields.insert(QContactOnlineAccount::FieldCapabilities, f); |
969 fields.insert(QContactOnlineAccount::FieldCapabilities, f); |
827 f.setDataType(QVariant::String); |
970 f.setDataType(QVariant::String); |
828 fields.insert(QContactOnlineAccount::FieldAccountUri, f); |
971 fields.insert(QContactOnlineAccount::FieldAccountUri, f); |
829 fields.insert(QContactOnlineAccount::FieldServiceProvider, f); |
972 fields.insert(QContactOnlineAccount::FieldServiceProvider, f); |
830 fields.insert(QContactOnlineAccount::FieldNickname, f); |
|
831 fields.insert(QContactOnlineAccount::FieldStatusMessage, f); |
|
832 QVariantList presenceValues; |
|
833 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceAvailable)); |
|
834 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceHidden)); |
|
835 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceBusy)); |
|
836 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceAway)); |
|
837 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceExtendedAway)); |
|
838 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceUnknown)); |
|
839 presenceValues << QString(QLatin1String(QContactOnlineAccount::PresenceOffline)); |
|
840 f.setAllowableValues(presenceValues); |
|
841 fields.insert(QContactOnlineAccount::FieldPresence, f); |
|
842 f.setDataType(QVariant::StringList); |
973 f.setDataType(QVariant::StringList); |
843 f.setAllowableValues(contexts); |
974 f.setAllowableValues(contexts); |
844 fields.insert(QContactDetail::FieldContext, f); |
975 fields.insert(QContactDetail::FieldContext, f); |
845 f.setAllowableValues(QVariantList()); // allow any subtypes! |
976 f.setAllowableValues(QVariantList()); // allow any subtypes! |
846 fields.insert(QContactOnlineAccount::FieldSubTypes, f); |
977 fields.insert(QContactOnlineAccount::FieldSubTypes, f); |
847 d.setFields(fields); |
978 d.setFields(fields); |
848 d.setUnique(false); |
979 d.setUnique(false); |
849 retn.insert(d.name(), d); |
980 retn.insert(d.name(), d); |
850 |
981 |
851 // avatar |
982 // presence |
852 d.setName(QContactAvatar::DefinitionName); |
983 d.setName(QContactPresence::DefinitionName); |
853 fields.clear(); |
984 fields.clear(); |
|
985 f.setAllowableValues(QVariantList()); |
|
986 f.setDataType(QVariant::DateTime); |
|
987 fields.insert(QContactPresence::FieldTimestamp, f); |
854 f.setDataType(QVariant::String); |
988 f.setDataType(QVariant::String); |
855 f.setAllowableValues(QVariantList()); |
989 fields.insert(QContactPresence::FieldNickname, f); |
856 fields.insert(QContactAvatar::FieldAvatar, f); |
990 fields.insert(QContactPresence::FieldCustomMessage, f); |
857 |
991 fields.insert(QContactPresence::FieldPresenceStateText, f); |
858 f.setDataType(QVariant::Pixmap); |
992 QVariantList presenceValues; |
859 f.setAllowableValues(QVariantList()); |
993 presenceValues << QContactPresence::PresenceAvailable; |
860 fields.insert(QContactAvatar::FieldAvatarPixmap, f); |
994 presenceValues << QContactPresence::PresenceAway; |
861 |
995 presenceValues << QContactPresence::PresenceBusy; |
862 f.setDataType(QVariant::String); // only allowed to be a single subtype |
996 presenceValues << QContactPresence::PresenceExtendedAway; |
863 subTypes.clear(); |
997 presenceValues << QContactPresence::PresenceHidden; |
864 subTypes << QString(QLatin1String(QContactAvatar::SubTypeImage)); |
998 presenceValues << QContactPresence::PresenceOffline; |
865 subTypes << QString(QLatin1String(QContactAvatar::SubTypeTexturedMesh)); |
999 presenceValues << QContactPresence::PresenceUnknown; |
866 subTypes << QString(QLatin1String(QContactAvatar::SubTypeVideo)); |
1000 f.setAllowableValues(presenceValues); |
867 f.setAllowableValues(subTypes); |
1001 f.setDataType(QVariant::Int); |
868 fields.insert(QContactAvatar::FieldSubType, f); |
1002 fields.insert(QContactPresence::FieldPresenceState, f); |
|
1003 f.setAllowableValues(QVariantList()); |
|
1004 f.setDataType(QVariant::Url); |
|
1005 fields.insert(QContactPresence::FieldPresenceStateImageUrl, f); |
869 f.setDataType(QVariant::StringList); |
1006 f.setDataType(QVariant::StringList); |
870 f.setAllowableValues(contexts); |
1007 f.setAllowableValues(contexts); |
871 fields.insert(QContactDetail::FieldContext, f); |
1008 fields.insert(QContactDetail::FieldContext, f); |
872 d.setFields(fields); |
1009 d.setFields(fields); |
873 d.setUnique(false); |
1010 d.setUnique(false); |
|
1011 retn.insert(d.name(), d); |
|
1012 |
|
1013 // global presence |
|
1014 d.setName(QContactGlobalPresence::DefinitionName); |
|
1015 fields.clear(); |
|
1016 f.setAllowableValues(QVariantList()); |
|
1017 f.setDataType(QVariant::DateTime); |
|
1018 fields.insert(QContactGlobalPresence::FieldTimestamp, f); |
|
1019 f.setDataType(QVariant::String); |
|
1020 fields.insert(QContactGlobalPresence::FieldNickname, f); |
|
1021 fields.insert(QContactGlobalPresence::FieldCustomMessage, f); |
|
1022 fields.insert(QContactGlobalPresence::FieldPresenceStateText, f); |
|
1023 f.setAllowableValues(presenceValues); |
|
1024 f.setDataType(QVariant::Int); |
|
1025 fields.insert(QContactGlobalPresence::FieldPresenceState, f); |
|
1026 f.setAllowableValues(QVariantList()); |
|
1027 f.setDataType(QVariant::Url); |
|
1028 fields.insert(QContactGlobalPresence::FieldPresenceStateImageUrl, f); |
|
1029 f.setDataType(QVariant::StringList); |
|
1030 f.setAllowableValues(contexts); |
|
1031 fields.insert(QContactDetail::FieldContext, f); |
|
1032 d.setFields(fields); |
|
1033 d.setUnique(true); // unique and read only! |
|
1034 retn.insert(d.name(), d); |
|
1035 |
|
1036 // avatar |
|
1037 d.setName(QContactAvatar::DefinitionName); |
|
1038 fields.clear(); |
|
1039 f.setDataType(QVariant::Url); |
|
1040 f.setAllowableValues(QVariantList()); |
|
1041 fields.insert(QContactAvatar::FieldImageUrl, f); |
|
1042 fields.insert(QContactAvatar::FieldVideoUrl, f); |
|
1043 f.setDataType(QVariant::StringList); |
|
1044 f.setAllowableValues(contexts); |
|
1045 fields.insert(QContactDetail::FieldContext, f); |
|
1046 d.setFields(fields); |
|
1047 d.setUnique(false); |
|
1048 retn.insert(d.name(), d); |
|
1049 |
|
1050 // ringtone |
|
1051 d.setName(QContactRingtone::DefinitionName); |
|
1052 fields.clear(); |
|
1053 f.setDataType(QVariant::Url); |
|
1054 f.setAllowableValues(QVariantList()); |
|
1055 fields.insert(QContactRingtone::FieldAudioRingtoneUrl, f); |
|
1056 fields.insert(QContactRingtone::FieldVideoRingtoneUrl, f); |
|
1057 fields.insert(QContactRingtone::FieldVibrationRingtoneUrl, f); |
|
1058 f.setDataType(QVariant::StringList); |
|
1059 f.setAllowableValues(contexts); |
|
1060 fields.insert(QContactDetail::FieldContext, f); |
|
1061 d.setFields(fields); |
|
1062 d.setUnique(false); |
|
1063 retn.insert(d.name(), d); |
|
1064 |
|
1065 // thumbnail |
|
1066 d.setName(QContactThumbnail::DefinitionName); |
|
1067 fields.clear(); |
|
1068 f.setDataType(QVariant::Image); |
|
1069 f.setAllowableValues(QVariantList()); |
|
1070 fields.insert(QContactThumbnail::FieldThumbnail, f); |
|
1071 d.setFields(fields); |
|
1072 d.setUnique(true); // only one thumbnail, no context. |
874 retn.insert(d.name(), d); |
1073 retn.insert(d.name(), d); |
875 |
1074 |
876 // GeoLocation |
1075 // GeoLocation |
877 d.setName(QContactGeoLocation::DefinitionName); |
1076 d.setName(QContactGeoLocation::DefinitionName); |
878 fields.clear(); |
1077 fields.clear(); |
938 fields.insert(QContactDetail::FieldContext, f); |
1137 fields.insert(QContactDetail::FieldContext, f); |
939 d.setFields(fields); |
1138 d.setFields(fields); |
940 d.setUnique(false); |
1139 d.setUnique(false); |
941 retn.insert(d.name(), d); |
1140 retn.insert(d.name(), d); |
942 |
1141 |
|
1142 // tag |
|
1143 d.setName(QContactTag::DefinitionName); |
|
1144 fields.clear(); |
|
1145 f.setDataType(QVariant::String); |
|
1146 f.setAllowableValues(QVariantList()); |
|
1147 fields.insert(QContactTag::FieldTag, f); |
|
1148 f.setDataType(QVariant::StringList); |
|
1149 f.setAllowableValues(contexts); |
|
1150 fields.insert(QContactDetail::FieldContext, f); |
|
1151 d.setFields(fields); |
|
1152 d.setUnique(false); |
|
1153 retn.insert(d.name(), d); |
|
1154 |
943 // in the default schema, we have two contact types: TypeContact, TypeGroup. |
1155 // in the default schema, we have two contact types: TypeContact, TypeGroup. |
944 // the entire default schema is valid for both types. |
1156 // the entire default schema is valid for both types. |
945 QMap<QString, QMap<QString, QContactDetailDefinition> > retnSchema; |
1157 QMap<QString, QMap<QString, QContactDetailDefinition> > retnSchema; |
946 retnSchema.insert(QContactType::TypeContact, retn); |
1158 retnSchema.insert(QContactType::TypeContact, retn); |
947 retnSchema.insert(QContactType::TypeGroup, retn); |
1159 retnSchema.insert(QContactType::TypeGroup, retn); |
948 |
1160 |
949 return retnSchema; |
1161 return retnSchema; |
950 } |
1162 } |
951 |
1163 |
952 |
|
953 /*! |
|
954 Adds the given \a contact to the database if \a contact has a |
|
955 default-constructed id, or an id with the manager URI set to the URI of |
|
956 this manager and a local id of zero. |
|
957 |
|
958 If the manager URI of the id of the \a contact is neither empty nor equal to the URI of |
|
959 this manager, or local id of the \a contact is non-zero but does not exist in the |
|
960 manager, the operation will fail and \a error will be set to |
|
961 \c QContactManager::DoesNotExistError. |
|
962 |
|
963 Alternatively, the function will update the existing contact in the database if \a contact |
|
964 has a non-zero id and currently exists in the database. |
|
965 |
|
966 If the \a contact contains one or more details whose definitions have |
|
967 not yet been saved with the manager, the operation will fail and \a error will be |
|
968 set to \c QContactManager::UnsupportedError. |
|
969 |
|
970 If the \a contact has had its relationships reordered, the manager |
|
971 will check to make sure that every relationship that the contact is currently |
|
972 involved in is included in the reordered list, and that no relationships which |
|
973 either do not involve the contact, or have not been saved in the manager are |
|
974 included in the list. If these conditions are not met, the function will |
|
975 return \c false and \a error will be set to \c QContactManager::InvalidRelationshipError. |
|
976 |
|
977 The engine must automatically synthesize the display label of the contact when it is saved, |
|
978 by either using the built in \l synthesizedDisplayLabel() function or overriding it, and |
|
979 then calling \l setContactDisplayLabel(). |
|
980 |
|
981 Returns false on failure, or true on |
|
982 success. On successful save of a contact with an id of zero, its |
|
983 id will be set to a new, valid id with the manager URI set to the URI of |
|
984 this manager, and the local id set to a new, valid local id. |
|
985 |
|
986 This function is called by the contacts framework in both the |
|
987 single contact save and batch contact save, if the saveContacts |
|
988 function is not overridden. |
|
989 |
|
990 The backend must emit the appropriate signals to inform clients of changes |
|
991 to the database resulting from this operation. |
|
992 |
|
993 Any errors encountered during this operation should be stored to |
|
994 \a error. |
|
995 */ |
|
996 bool QContactManagerEngine::saveContact(QContact* contact, QContactManager::Error& error) |
|
997 { |
|
998 Q_UNUSED(contact); |
|
999 error = QContactManager::NotSupportedError; |
|
1000 return false; |
|
1001 } |
|
1002 |
|
1003 /*! |
1164 /*! |
1004 Checks that the given contact \a contact does not have details which |
1165 Checks that the given contact \a contact does not have details which |
1005 don't conform to a valid definition, violate uniqueness constraints, |
1166 don't conform to a valid definition, violate uniqueness constraints, |
1006 or contain values for nonexistent fields, and that the values contained are |
1167 or contain values for nonexistent fields, and that the values contained are |
1007 of the correct type for each field, and are allowable values for that field. |
1168 of the correct type for each field, and are allowable values for that field. |
1014 its details, otherwise returns false. |
1175 its details, otherwise returns false. |
1015 |
1176 |
1016 Any errors encountered during this operation should be stored to |
1177 Any errors encountered during this operation should be stored to |
1017 \a error. |
1178 \a error. |
1018 */ |
1179 */ |
1019 bool QContactManagerEngine::validateContact(const QContact& contact, QContactManager::Error& error) const |
1180 bool QContactManagerEngine::validateContact(const QContact& contact, QContactManager::Error* error) const |
1020 { |
1181 { |
1021 QList<QString> uniqueDefinitionIds; |
1182 QList<QString> uniqueDefinitionIds; |
1022 |
1183 |
1023 // check that each detail conforms to its definition as supported by this manager. |
1184 // check that each detail conforms to its definition as supported by this manager. |
1024 for (int i=0; i < contact.details().count(); i++) { |
1185 for (int i=0; i < contact.details().count(); i++) { |
1025 const QContactDetail& d = contact.details().at(i); |
1186 const QContactDetail& d = contact.details().at(i); |
1026 QVariantMap values = d.variantValues(); |
1187 QVariantMap values = d.variantValues(); |
1027 QContactDetailDefinition def = detailDefinition(d.definitionName(), contact.type(), error); |
1188 QContactDetailDefinition def = detailDefinition(d.definitionName(), contact.type(), error); |
1028 // check that the definition is supported |
1189 // check that the definition is supported |
1029 if (error != QContactManager::NoError) { |
1190 if (*error != QContactManager::NoError) { |
1030 error = QContactManager::InvalidDetailError; |
1191 *error = QContactManager::InvalidDetailError; |
1031 return false; // this definition is not supported. |
1192 return false; // this definition is not supported. |
1032 } |
1193 } |
1033 |
1194 |
1034 // check uniqueness |
1195 // check uniqueness |
1035 if (def.isUnique()) { |
1196 if (def.isUnique()) { |
1036 if (uniqueDefinitionIds.contains(def.name())) { |
1197 if (uniqueDefinitionIds.contains(def.name())) { |
1037 error = QContactManager::AlreadyExistsError; |
1198 *error = QContactManager::AlreadyExistsError; |
1038 return false; // can't have two of a unique detail. |
1199 return false; // can't have two of a unique detail. |
1039 } |
1200 } |
1040 uniqueDefinitionIds.append(def.name()); |
1201 uniqueDefinitionIds.append(def.name()); |
1041 } |
1202 } |
1042 |
1203 |
1043 QList<QString> keys = values.keys(); |
1204 QList<QString> keys = values.keys(); |
1044 for (int i=0; i < keys.count(); i++) { |
1205 for (int i=0; i < keys.count(); i++) { |
1045 const QString& key = keys.at(i); |
1206 const QString& key = keys.at(i); |
1046 // check that no values exist for nonexistent fields. |
1207 // check that no values exist for nonexistent fields. |
1047 if (!def.fields().contains(key)) { |
1208 if (!def.fields().contains(key)) { |
1048 error = QContactManager::InvalidDetailError; |
1209 *error = QContactManager::InvalidDetailError; |
1049 return false; // value for nonexistent field. |
1210 return false; // value for nonexistent field. |
1050 } |
1211 } |
1051 |
1212 |
1052 QContactDetailFieldDefinition field = def.fields().value(key); |
1213 QContactDetailFieldDefinition field = def.fields().value(key); |
1053 // check that the type of each value corresponds to the allowable field type |
1214 // check that the type of each value corresponds to the allowable field type |
1054 if (static_cast<int>(field.dataType()) != values.value(key).userType()) { |
1215 if (static_cast<int>(field.dataType()) != values.value(key).userType()) { |
1055 error = QContactManager::InvalidDetailError; |
1216 *error = QContactManager::InvalidDetailError; |
1056 return false; // type doesn't match. |
1217 return false; // type doesn't match. |
1057 } |
1218 } |
1058 |
1219 |
1059 // check that the value is allowable |
1220 // check that the value is allowable |
1060 // if the allowable values is an empty list, any are allowed. |
1221 // if the allowable values is an empty list, any are allowed. |
1091 false. |
1251 false. |
1092 |
1252 |
1093 Any errors encountered during this operation should be stored to |
1253 Any errors encountered during this operation should be stored to |
1094 \a error. |
1254 \a error. |
1095 */ |
1255 */ |
1096 bool QContactManagerEngine::validateDefinition(const QContactDetailDefinition& definition, QContactManager::Error& error) const |
1256 bool QContactManagerEngine::validateDefinition(const QContactDetailDefinition& definition, QContactManager::Error* error) const |
1097 { |
1257 { |
1098 if (definition.name().isEmpty()) { |
1258 if (definition.name().isEmpty()) { |
1099 error = QContactManager::BadArgumentError; |
1259 *error = QContactManager::BadArgumentError; |
1100 return false; |
1260 return false; |
1101 } |
1261 } |
1102 |
1262 |
1103 if (definition.fields().count() == 0) { |
1263 if (definition.fields().count() == 0) { |
1104 error = QContactManager::BadArgumentError; |
1264 *error = QContactManager::BadArgumentError; |
1105 return false; |
1265 return false; |
1106 } |
1266 } |
1107 |
1267 |
1108 // Check each field now |
1268 // Check each field now |
1109 QList<QVariant::Type> types = supportedDataTypes(); |
1269 QList<QVariant::Type> types = supportedDataTypes(); |
1110 QMapIterator<QString, QContactDetailFieldDefinition> it(definition.fields()); |
1270 QMapIterator<QString, QContactDetailFieldDefinition> it(definition.fields()); |
1111 while(it.hasNext()) { |
1271 while(it.hasNext()) { |
1112 it.next(); |
1272 it.next(); |
1113 if (it.key().isEmpty()) { |
1273 if (it.key().isEmpty()) { |
1114 error = QContactManager::BadArgumentError; |
1274 *error = QContactManager::BadArgumentError; |
1115 return false; |
1275 return false; |
1116 } |
1276 } |
1117 |
1277 |
1118 if (!types.contains(it.value().dataType())) { |
1278 if (!types.contains(it.value().dataType())) { |
1119 error = QContactManager::BadArgumentError; |
1279 *error = QContactManager::BadArgumentError; |
1120 return false; |
1280 return false; |
1121 } |
1281 } |
1122 |
1282 |
1123 // Check that each allowed value is the same type |
1283 // Check that each allowed value is the same type |
1124 for (int i=0; i < it.value().allowableValues().count(); i++) { |
1284 for (int i=0; i < it.value().allowableValues().count(); i++) { |
1125 if (it.value().allowableValues().at(i).type() != it.value().dataType()) { |
1285 if (it.value().allowableValues().at(i).type() != it.value().dataType()) { |
1126 error = QContactManager::BadArgumentError; |
1286 *error = QContactManager::BadArgumentError; |
1127 return false; |
1287 return false; |
1128 } |
1288 } |
1129 } |
1289 } |
1130 } |
1290 } |
1131 error = QContactManager::NoError; |
1291 *error = QContactManager::NoError; |
1132 return true; |
1292 return true; |
1133 } |
1293 } |
1134 |
1294 |
1135 /*! |
1295 /*! |
1136 Remove the contact identified by \a contactId from the database, |
1296 Returns the registered detail definitions which are valid for contacts whose type is of the given \a contactType in this engine. |
1137 and removes the contact from any relationships in which it was involved. |
|
1138 Returns true if the contact was removed successfully, otherwise |
|
1139 returns false. |
|
1140 |
|
1141 The backend must emit the appropriate signals to inform clients of changes |
|
1142 to the database resulting from this operation. |
|
1143 |
1297 |
1144 Any errors encountered during this operation should be stored to |
1298 Any errors encountered during this operation should be stored to |
1145 \a error. |
1299 \a error. |
1146 */ |
1300 */ |
1147 bool QContactManagerEngine::removeContact(const QContactLocalId& contactId, QContactManager::Error& error) |
1301 QMap<QString, QContactDetailDefinition> QContactManagerEngine::detailDefinitions(const QString& contactType, QContactManager::Error* error) const |
1148 { |
|
1149 Q_UNUSED(contactId); |
|
1150 error = QContactManager::NotSupportedError; |
|
1151 return false; |
|
1152 } |
|
1153 |
|
1154 /*! |
|
1155 Returns the registered detail definitions which are valid for contacts whose type is of the given \a contactType in this engine. |
|
1156 |
|
1157 Any errors encountered during this operation should be stored to |
|
1158 \a error. |
|
1159 */ |
|
1160 QMap<QString, QContactDetailDefinition> QContactManagerEngine::detailDefinitions(const QString& contactType, QContactManager::Error& error) const |
|
1161 { |
1302 { |
1162 Q_UNUSED(contactType); |
1303 Q_UNUSED(contactType); |
1163 error = QContactManager::NotSupportedError; |
1304 *error = QContactManager::NotSupportedError; |
1164 return QMap<QString, QContactDetailDefinition>(); |
1305 return QMap<QString, QContactDetailDefinition>(); |
1165 } |
1306 } |
1166 |
1307 |
1167 /*! |
1308 /*! |
1168 Returns the definition identified by the given \a definitionName that |
1309 Returns the definition identified by the given \a definitionName that |
1258 Any errors encountered during this operation should be stored to |
1462 Any errors encountered during this operation should be stored to |
1259 \a error. |
1463 \a error. |
1260 |
1464 |
1261 \sa QContactManager::saveContact() |
1465 \sa QContactManager::saveContact() |
1262 */ |
1466 */ |
1263 bool QContactManagerEngine::saveContacts(QList<QContact>* contacts, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error& error) |
1467 bool QContactManagerEngine::saveContacts(QList<QContact>* contacts, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error) |
1264 { |
1468 { |
1265 if(errorMap) { |
1469 Q_UNUSED(contacts); |
1266 errorMap->clear(); |
1470 Q_UNUSED(errorMap); |
1267 } |
1471 *error = QContactManager::NotSupportedError; |
1268 |
1472 return false; |
1269 if (!contacts) { |
|
1270 error = QContactManager::BadArgumentError; |
|
1271 return false; |
|
1272 } |
|
1273 |
|
1274 QContactManager::Error functionError = QContactManager::NoError; |
|
1275 for (int i = 0; i < contacts->count(); i++) { |
|
1276 QContact current = contacts->at(i); |
|
1277 if (!saveContact(¤t, error)) { |
|
1278 functionError = error; |
|
1279 if (errorMap) { |
|
1280 errorMap->insert(i, functionError); |
|
1281 } |
|
1282 } else { |
|
1283 (*contacts)[i] = current; |
|
1284 } |
|
1285 } |
|
1286 |
|
1287 error = functionError; |
|
1288 return (functionError == QContactManager::NoError); |
|
1289 } |
1473 } |
1290 |
1474 |
1291 /*! |
1475 /*! |
1292 Remove every contact whose id is contained in the list of contacts ids |
1476 Remove every contact whose id is contained in the list of contacts ids |
1293 \a contactIds. Returns true if all contacts were removed successfully, |
1477 \a contactIds. Returns true if all contacts were removed successfully, |
1294 otherwise false. |
1478 otherwise false. |
|
1479 |
|
1480 Any contact that was removed successfully will have the relationships |
|
1481 in which it was involved removed also. |
1295 |
1482 |
1296 The manager might populate \a errorMap (the map of indices of the \a contactIds list to |
1483 The manager might populate \a errorMap (the map of indices of the \a contactIds list to |
1297 the error which occurred when saving the contact at that index) for every |
1484 the error which occurred when saving the contact at that index) for every |
1298 index for which the contact could not be removed, if it is able. |
1485 index for which the contact could not be removed, if it is able. |
1299 The \l QContactManager::error() function will |
1486 The \l QContactManager::error() function will |
1300 only return \c QContactManager::NoError if all contacts were removed |
1487 only return \c QContactManager::NoError if all contacts were removed |
1301 successfully. |
1488 successfully. |
1302 |
1489 |
1303 For each contact that was removed succesfully, the corresponding |
1490 If the list contains ids which do not identify a valid contact in the manager, the function will |
1304 id in the \a contactIds list will be retained but set to zero. The id of contacts |
1491 remove any contacts which are identified by ids in the \a contactIds list, insert |
1305 that were not successfully removed will be left alone. |
1492 \c QContactManager::DoesNotExist entries into the \a errorMap for the indices of invalid ids |
1306 |
1493 in the \a contactIds list, return false, and set the overall operation error to |
1307 Any contact that was removed successfully will have the relationships |
1494 \c QContactManager::DoesNotExistError. |
1308 in which it was involved removed also. |
|
1309 |
1495 |
1310 Any errors encountered during this operation should be stored to |
1496 Any errors encountered during this operation should be stored to |
1311 \a error. |
1497 \a error. |
1312 |
1498 |
1313 \sa QContactManager::removeContact() |
1499 \sa QContactManager::removeContact() |
1314 */ |
1500 */ |
1315 bool QContactManagerEngine::removeContacts(QList<QContactLocalId>* contactIds, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error& error) |
1501 bool QContactManagerEngine::removeContacts(const QList<QContactLocalId>& contactIds, QMap<int, QContactManager::Error>* errorMap, QContactManager::Error* error) |
1316 { |
1502 { |
1317 if(errorMap) { |
1503 Q_UNUSED(contactIds); |
1318 errorMap->clear(); |
1504 Q_UNUSED(errorMap); |
|
1505 *error = QContactManager::NotSupportedError; |
|
1506 return false; |
|
1507 } |
|
1508 |
|
1509 /*! |
|
1510 Returns a pruned or modified version of the \a original contact which is valid and can be saved in the manager. |
|
1511 The returned contact might have entire details removed or arbitrarily changed. The cache of relationships |
|
1512 in the contact are ignored entirely when considering compatibility with the backend, as they are |
|
1513 saved and validated separately. Any error which occurs will be saved to \a error. |
|
1514 */ |
|
1515 QContact QContactManagerEngine::compatibleContact(const QContact& original, QContactManager::Error* error) const |
|
1516 { |
|
1517 QContact conforming; |
|
1518 QContactManager::Error tempError; |
|
1519 QList<QString> uniqueDefinitionIds; |
|
1520 QList<QContactDetail> allDetails = original.details(); |
|
1521 QMap<QString, QContactDetailDefinition> defs = detailDefinitions(original.type(), &tempError); |
|
1522 for (int j = 0; j < allDetails.size(); j++) { |
|
1523 // check that the detail conforms to the definition in this manager. |
|
1524 // if so, then add it to the conforming contact to be returned. if not, prune it. |
|
1525 const QContactDetail& d = allDetails.at(j); |
|
1526 |
|
1527 QVariantMap values = d.variantValues(); |
|
1528 QContactDetailDefinition def = detailDefinition(d.definitionName(), original.type(), &tempError); |
|
1529 // check that the definition is supported |
|
1530 if (*error != QContactManager::NoError) { |
|
1531 continue; // this definition is not supported. |
|
1532 } |
|
1533 |
|
1534 // check uniqueness |
|
1535 if (def.isUnique()) { |
|
1536 if (uniqueDefinitionIds.contains(def.name())) { |
|
1537 continue; // can't have two of a unique detail. |
|
1538 } |
|
1539 uniqueDefinitionIds.append(def.name()); |
|
1540 } |
|
1541 |
|
1542 bool addToConforming = true; |
|
1543 QList<QString> keys = values.keys(); |
|
1544 for (int i=0; i < keys.count(); i++) { |
|
1545 const QString& key = keys.at(i); |
|
1546 // check that no values exist for nonexistent fields. |
|
1547 if (!def.fields().contains(key)) { |
|
1548 addToConforming = false; |
|
1549 break; // value for nonexistent field. |
|
1550 } |
|
1551 |
|
1552 QContactDetailFieldDefinition field = def.fields().value(key); |
|
1553 // check that the type of each value corresponds to the allowable field type |
|
1554 if (static_cast<int>(field.dataType()) != values.value(key).userType()) { |
|
1555 addToConforming = false; |
|
1556 break; // type doesn't match. |
|
1557 } |
|
1558 |
|
1559 // check that the value is allowable |
|
1560 // if the allowable values is an empty list, any are allowed. |
|
1561 if (!field.allowableValues().isEmpty()) { |
|
1562 // if the field datatype is a list, check that it contains only allowable values |
|
1563 if (field.dataType() == QVariant::List || field.dataType() == QVariant::StringList) { |
|
1564 QList<QVariant> innerValues = values.value(key).toList(); |
|
1565 for (int i = 0; i < innerValues.size(); i++) { |
|
1566 if (!field.allowableValues().contains(innerValues.at(i))) { |
|
1567 addToConforming = false; |
|
1568 break; // value not allowed. |
|
1569 } |
|
1570 } |
|
1571 } else if (!field.allowableValues().contains(values.value(key))) { |
|
1572 // the datatype is not a list; the value wasn't allowed. |
|
1573 addToConforming = false; |
|
1574 break; // value not allowed. |
|
1575 } |
|
1576 } |
|
1577 } |
|
1578 |
|
1579 // if it conforms to this manager's schema, save it in the conforming contact |
|
1580 // else, ignore it (prune it out of the conforming contact). |
|
1581 if (addToConforming) { |
|
1582 QContactDetail saveCopy = d; |
|
1583 conforming.saveDetail(&saveCopy); |
|
1584 } |
1319 } |
1585 } |
1320 |
1586 |
1321 if (!contactIds) { |
1587 if (!conforming.isEmpty()) |
1322 error = QContactManager::BadArgumentError; |
1588 *error = QContactManager::NoError; |
1323 return false; |
1589 else |
1324 } |
1590 *error = QContactManager::DoesNotExistError; |
1325 |
1591 return conforming; |
1326 QContactManager::Error functionError = QContactManager::NoError; |
|
1327 for (int i = 0; i < contactIds->count(); i++) { |
|
1328 QContactLocalId current = contactIds->at(i); |
|
1329 if (!removeContact(current, error)) { |
|
1330 functionError = error; |
|
1331 if (errorMap) { |
|
1332 errorMap->insert(i, functionError); |
|
1333 } |
|
1334 } else { |
|
1335 (*contactIds)[i] = 0; |
|
1336 } |
|
1337 } |
|
1338 |
|
1339 error = functionError; |
|
1340 return (functionError == QContactManager::NoError); |
|
1341 } |
1592 } |
1342 |
1593 |
1343 /*! |
1594 /*! |
1344 Compares \a first against \a second. If the types are |
1595 Compares \a first against \a second. If the types are |
1345 strings (QVariant::String), the \a sensitivity argument controls |
1596 strings (QVariant::String), the \a sensitivity argument controls |
1459 |
1710 |
1460 /* Case sensitivity, for those parts that use it */ |
1711 /* Case sensitivity, for those parts that use it */ |
1461 Qt::CaseSensitivity cs = (cdf.matchFlags() & QContactFilter::MatchCaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive; |
1712 Qt::CaseSensitivity cs = (cdf.matchFlags() & QContactFilter::MatchCaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive; |
1462 |
1713 |
1463 /* See what flags are requested, since we're looking at a value */ |
1714 /* See what flags are requested, since we're looking at a value */ |
1464 if (cdf.matchFlags() & (QContactFilter::MatchEndsWith | QContactFilter::MatchStartsWith | QContactFilter::MatchContains | QContactFilter::MatchFixedString)) { |
1715 if (cdf.matchFlags() & QContactFilter::MatchPhoneNumber) { |
|
1716 /* Doing phone number filtering. We hand roll an implementation here, backends will obviously want to override this. */ |
|
1717 QString input = cdf.value().toString(); |
|
1718 |
|
1719 /* preprocess the input - ignore any non-digits (doesn't perform ITU-T collation */ |
|
1720 QString preprocessedInput; |
|
1721 for (int i = 0; i < input.size(); i++) { |
|
1722 QChar current = input.at(i).toLower(); |
|
1723 if (current.isDigit()) preprocessedInput.append(current); |
|
1724 // note: we ignore characters like '+', 'p', 'w', '*' and '#' which may be important. |
|
1725 } |
|
1726 |
|
1727 /* Look at every detail in the set of details and compare */ |
|
1728 for (int j = 0; j < details.count(); j++) { |
|
1729 const QContactDetail& detail = details.at(j); |
|
1730 const QString& valueString = detail.value(cdf.detailFieldName()); |
|
1731 QString preprocessedValueString; |
|
1732 for (int i = 0; i < valueString.size(); i++) { |
|
1733 QChar current = valueString.at(i).toLower(); |
|
1734 if (current.isDigit()) preprocessedValueString.append(current); |
|
1735 // note: we ignore characters like '+', 'p', 'w', '*' and '#' which may be important. |
|
1736 } |
|
1737 |
|
1738 // if the matchflags input don't require a particular criteria to pass, we assume that it has passed. |
|
1739 // the "default" match strategy is an "endsWith" strategy. |
|
1740 bool me = (cdf.matchFlags() & 7) == QContactFilter::MatchExactly; |
|
1741 bool mc = (cdf.matchFlags() & 7) == QContactFilter::MatchContains; |
|
1742 bool msw = (cdf.matchFlags() & 7) == QContactFilter::MatchStartsWith; |
|
1743 bool mew = (cdf.matchFlags() & 7) == QContactFilter::MatchEndsWith; |
|
1744 |
|
1745 bool mer = (me ? preprocessedValueString == preprocessedInput : true); |
|
1746 bool mcr = (mc ? preprocessedValueString.contains(preprocessedInput) : true); |
|
1747 bool mswr = (msw ? preprocessedValueString.startsWith(preprocessedInput) : true); |
|
1748 bool mewr = (mew ? preprocessedValueString.endsWith(preprocessedInput) : true); |
|
1749 if (mewr && mswr && mcr && mer) { |
|
1750 return true; // this detail meets all of the criteria which were required, and hence must match. |
|
1751 } |
|
1752 } |
|
1753 } else if (cdf.matchFlags() & QContactFilter::MatchKeypadCollation) { |
|
1754 // XXX TODO: not sure about the filtering semantics for MatchKeypadCollation. |
|
1755 QString input = cdf.value().toString(); |
|
1756 |
|
1757 /* Look at every detail in the set of details and compare */ |
|
1758 for (int j = 0; j < details.count(); j++) { |
|
1759 const QContactDetail& detail = details.at(j); |
|
1760 const QString& valueString = detail.value(cdf.detailFieldName()).toLower(); |
|
1761 |
|
1762 // preprocess the valueString |
|
1763 QString preprocessedValue; |
|
1764 for (int i = 0; i < valueString.size(); i++) { |
|
1765 // we use ITU-T keypad collation by default. |
|
1766 QChar currentValueChar = valueString.at(i); |
|
1767 if (currentValueChar == QLatin1Char('a') || currentValueChar == QLatin1Char('b') || currentValueChar == QLatin1Char('c')) |
|
1768 preprocessedValue.append(QLatin1Char('2')); |
|
1769 else if (currentValueChar == QLatin1Char('d') || currentValueChar == QLatin1Char('e') || currentValueChar == QLatin1Char('f')) |
|
1770 preprocessedValue.append(QLatin1Char('3')); |
|
1771 else if (currentValueChar == QLatin1Char('g') || currentValueChar == QLatin1Char('h') || currentValueChar == QLatin1Char('i')) |
|
1772 preprocessedValue.append(QLatin1Char('4')); |
|
1773 else if (currentValueChar == QLatin1Char('j') || currentValueChar == QLatin1Char('k') || currentValueChar == QLatin1Char('l')) |
|
1774 preprocessedValue.append(QLatin1Char('5')); |
|
1775 else if (currentValueChar == QLatin1Char('m') || currentValueChar == QLatin1Char('n') || currentValueChar == QLatin1Char('o')) |
|
1776 preprocessedValue.append(QLatin1Char('6')); |
|
1777 else if (currentValueChar == QLatin1Char('p') || currentValueChar == QLatin1Char('q') || currentValueChar == QLatin1Char('r') || currentValueChar == QLatin1Char('s')) |
|
1778 preprocessedValue.append(QLatin1Char('7')); |
|
1779 else if (currentValueChar == QLatin1Char('t') || currentValueChar == QLatin1Char('u') || currentValueChar == QLatin1Char('v')) |
|
1780 preprocessedValue.append(QLatin1Char('8')); |
|
1781 else if (currentValueChar == QLatin1Char('w') || currentValueChar == QLatin1Char('x') || currentValueChar == QLatin1Char('y') || currentValueChar == QLatin1Char('z')) |
|
1782 preprocessedValue.append(QLatin1Char('9')); |
|
1783 else |
|
1784 preprocessedValue.append(currentValueChar); |
|
1785 } |
|
1786 |
|
1787 bool me = (cdf.matchFlags() & 7) == QContactFilter::MatchExactly; |
|
1788 bool mc = (cdf.matchFlags() & 7) == QContactFilter::MatchContains; |
|
1789 bool msw = (cdf.matchFlags() & 7) == QContactFilter::MatchStartsWith; |
|
1790 bool mew = (cdf.matchFlags() & 7) == QContactFilter::MatchEndsWith; |
|
1791 |
|
1792 bool mer = (me ? preprocessedValue == input : true); |
|
1793 bool mcr = (mc ? preprocessedValue.contains(input) : true); |
|
1794 bool mswr = (msw ? preprocessedValue.startsWith(input) : true); |
|
1795 bool mewr = (mew ? preprocessedValue.endsWith(input) : true); |
|
1796 if (mewr && mswr && mcr && mer) { |
|
1797 return true; // this detail meets all of the criteria which were required, and hence must match. |
|
1798 } |
|
1799 } |
|
1800 } else if (cdf.matchFlags() & (QContactFilter::MatchEndsWith | QContactFilter::MatchStartsWith | QContactFilter::MatchContains | QContactFilter::MatchFixedString)) { |
1465 /* We're strictly doing string comparisons here */ |
1801 /* We're strictly doing string comparisons here */ |
1466 bool matchStarts = (cdf.matchFlags() & 7) == QContactFilter::MatchStartsWith; |
1802 bool matchStarts = (cdf.matchFlags() & 7) == QContactFilter::MatchStartsWith; |
1467 bool matchEnds = (cdf.matchFlags() & 7) == QContactFilter::MatchEndsWith; |
1803 bool matchEnds = (cdf.matchFlags() & 7) == QContactFilter::MatchEndsWith; |
1468 bool matchContains = (cdf.matchFlags() & 7) == QContactFilter::MatchContains; |
1804 bool matchContains = (cdf.matchFlags() & 7) == QContactFilter::MatchContains; |
1469 |
1805 |
1883 return false; |
2221 return false; |
1884 } |
2222 } |
1885 |
2223 |
1886 /*! |
2224 /*! |
1887 Updates the given asynchronous request \a req by setting the new \a state |
2225 Updates the given asynchronous request \a req by setting the new \a state |
1888 of the request. It then causes the stateChanged() signal to be emitted by the request. |
2226 of the request. If the new state is different, the stateChanged() signal |
|
2227 will be emitted by the request. |
1889 */ |
2228 */ |
1890 void QContactManagerEngine::updateRequestState(QContactAbstractRequest* req, QContactAbstractRequest::State state) |
2229 void QContactManagerEngine::updateRequestState(QContactAbstractRequest* req, QContactAbstractRequest::State state) |
1891 { |
2230 { |
1892 req->d_ptr->m_state = state; |
2231 if (req->d_ptr->m_state != state) { |
1893 emit req->stateChanged(state); |
2232 req->d_ptr->m_state = state; |
|
2233 emit req->stateChanged(state); |
|
2234 } |
1894 } |
2235 } |
1895 |
2236 |
1896 /*! |
2237 /*! |
1897 Updates the given QContactLocalIdFetchRequest \a req with the latest results \a result, and operation error \a error. |
2238 Updates the given QContactLocalIdFetchRequest \a req with the latest results \a result, and operation error \a error. |
|
2239 In addition, the state of the request will be changed to \a newState. |
|
2240 |
1898 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2241 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1899 */ |
2242 |
1900 void QContactManagerEngine::updateContactLocalIdFetchRequest(QContactLocalIdFetchRequest* req, const QList<QContactLocalId>& result, QContactManager::Error error) |
2243 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2244 */ |
|
2245 void QContactManagerEngine::updateContactLocalIdFetchRequest(QContactLocalIdFetchRequest* req, const QList<QContactLocalId>& result, QContactManager::Error error, QContactAbstractRequest::State newState) |
1901 { |
2246 { |
1902 QContactLocalIdFetchRequestPrivate* rd = static_cast<QContactLocalIdFetchRequestPrivate*>(req->d_ptr); |
2247 QContactLocalIdFetchRequestPrivate* rd = static_cast<QContactLocalIdFetchRequestPrivate*>(req->d_ptr); |
1903 req->d_ptr->m_error = error; |
2248 req->d_ptr->m_error = error; |
1904 rd->m_ids = result; |
2249 rd->m_ids = result; |
|
2250 bool emitState = rd->m_state != newState; |
|
2251 rd->m_state = newState; |
1905 emit req->resultsAvailable(); |
2252 emit req->resultsAvailable(); |
|
2253 if (emitState) |
|
2254 emit req->stateChanged(newState); |
1906 } |
2255 } |
1907 |
2256 |
1908 /*! |
2257 /*! |
1909 Updates the given QContactFetchRequest \a req with the latest results \a result, and operation error \a error. |
2258 Updates the given QContactFetchRequest \a req with the latest results \a result, and operation error \a error. |
|
2259 In addition, the state of the request will be changed to \a newState. |
|
2260 |
1910 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2261 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1911 */ |
2262 |
1912 void QContactManagerEngine::updateContactFetchRequest(QContactFetchRequest* req, const QList<QContact>& result, QContactManager::Error error) |
2263 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2264 */ |
|
2265 void QContactManagerEngine::updateContactFetchRequest(QContactFetchRequest* req, const QList<QContact>& result, QContactManager::Error error, QContactAbstractRequest::State newState) |
1913 { |
2266 { |
1914 QContactFetchRequestPrivate* rd = static_cast<QContactFetchRequestPrivate*>(req->d_ptr); |
2267 QContactFetchRequestPrivate* rd = static_cast<QContactFetchRequestPrivate*>(req->d_ptr); |
1915 req->d_ptr->m_error = error; |
2268 req->d_ptr->m_error = error; |
1916 rd->m_contacts = result; |
2269 rd->m_contacts = result; |
|
2270 bool emitState = rd->m_state != newState; |
|
2271 rd->m_state = newState; |
1917 emit req->resultsAvailable(); |
2272 emit req->resultsAvailable(); |
|
2273 if (emitState) |
|
2274 emit req->stateChanged(newState); |
1918 } |
2275 } |
1919 |
2276 |
1920 /*! |
2277 /*! |
1921 Updates the given QContactRemoveRequest \a req with the operation error \a error, and map of input index to individual error \a errorMap. |
2278 Updates the given QContactRemoveRequest \a req with the operation error \a error, and map of input index to individual error \a errorMap. |
|
2279 In addition, the state of the request will be changed to \a newState. |
|
2280 |
1922 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2281 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1923 */ |
2282 |
1924 void QContactManagerEngine::updateContactRemoveRequest(QContactRemoveRequest* req, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2283 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2284 */ |
|
2285 void QContactManagerEngine::updateContactRemoveRequest(QContactRemoveRequest* req, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
1925 { |
2286 { |
1926 QContactRemoveRequestPrivate* rd = static_cast<QContactRemoveRequestPrivate*>(req->d_ptr); |
2287 QContactRemoveRequestPrivate* rd = static_cast<QContactRemoveRequestPrivate*>(req->d_ptr); |
1927 req->d_ptr->m_error = error; |
2288 req->d_ptr->m_error = error; |
1928 rd->m_errors = errorMap; |
2289 rd->m_errors = errorMap; |
|
2290 bool emitState = rd->m_state != newState; |
|
2291 rd->m_state = newState; |
1929 emit req->resultsAvailable(); |
2292 emit req->resultsAvailable(); |
|
2293 if (emitState) |
|
2294 emit req->stateChanged(newState); |
1930 } |
2295 } |
1931 |
2296 |
1932 /*! |
2297 /*! |
1933 Updates the given QContactSaveRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
2298 Updates the given QContactSaveRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
|
2299 In addition, the state of the request will be changed to \a newState. |
|
2300 |
1934 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2301 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1935 */ |
2302 |
1936 void QContactManagerEngine::updateContactSaveRequest(QContactSaveRequest* req, const QList<QContact>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2303 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2304 */ |
|
2305 void QContactManagerEngine::updateContactSaveRequest(QContactSaveRequest* req, const QList<QContact>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
1937 { |
2306 { |
1938 QContactSaveRequestPrivate* rd = static_cast<QContactSaveRequestPrivate*>(req->d_ptr); |
2307 QContactSaveRequestPrivate* rd = static_cast<QContactSaveRequestPrivate*>(req->d_ptr); |
1939 req->d_ptr->m_error = error; |
2308 req->d_ptr->m_error = error; |
1940 rd->m_errors = errorMap; |
2309 rd->m_errors = errorMap; |
1941 rd->m_contacts = result; |
2310 rd->m_contacts = result; |
|
2311 bool emitState = rd->m_state != newState; |
|
2312 rd->m_state = newState; |
1942 emit req->resultsAvailable(); |
2313 emit req->resultsAvailable(); |
|
2314 if (emitState) |
|
2315 emit req->stateChanged(newState); |
1943 } |
2316 } |
1944 |
2317 |
1945 /*! |
2318 /*! |
1946 Updates the given QContactDetailDefinitionSaveRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
2319 Updates the given QContactDetailDefinitionSaveRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
|
2320 In addition, the state of the request will be changed to \a newState. |
|
2321 |
1947 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2322 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1948 */ |
2323 |
1949 void QContactManagerEngine::updateDefinitionSaveRequest(QContactDetailDefinitionSaveRequest* req, const QList<QContactDetailDefinition>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2324 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2325 */ |
|
2326 void QContactManagerEngine::updateDefinitionSaveRequest(QContactDetailDefinitionSaveRequest* req, const QList<QContactDetailDefinition>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
1950 { |
2327 { |
1951 QContactDetailDefinitionSaveRequestPrivate* rd = static_cast<QContactDetailDefinitionSaveRequestPrivate*>(req->d_ptr); |
2328 QContactDetailDefinitionSaveRequestPrivate* rd = static_cast<QContactDetailDefinitionSaveRequestPrivate*>(req->d_ptr); |
1952 req->d_ptr->m_error = error; |
2329 req->d_ptr->m_error = error; |
1953 rd->m_errors = errorMap; |
2330 rd->m_errors = errorMap; |
1954 rd->m_definitions = result; |
2331 rd->m_definitions = result; |
|
2332 bool emitState = rd->m_state != newState; |
|
2333 rd->m_state = newState; |
1955 emit req->resultsAvailable(); |
2334 emit req->resultsAvailable(); |
|
2335 if (emitState) |
|
2336 emit req->stateChanged(newState); |
1956 } |
2337 } |
1957 |
2338 |
1958 /*! |
2339 /*! |
1959 Updates the given QContactDetailDefinitionRemoveRequest \a req with the operation error \a error, and map of input index to individual error \a errorMap. |
2340 Updates the given QContactDetailDefinitionRemoveRequest \a req with the operation error \a error, and map of input index to individual error \a errorMap. |
|
2341 In addition, the state of the request will be changed to \a newState. |
|
2342 |
1960 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2343 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1961 */ |
2344 |
1962 void QContactManagerEngine::updateDefinitionRemoveRequest(QContactDetailDefinitionRemoveRequest* req, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2345 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2346 */ |
|
2347 void QContactManagerEngine::updateDefinitionRemoveRequest(QContactDetailDefinitionRemoveRequest* req, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
1963 { |
2348 { |
1964 QContactDetailDefinitionRemoveRequestPrivate* rd = static_cast<QContactDetailDefinitionRemoveRequestPrivate*>(req->d_ptr); |
2349 QContactDetailDefinitionRemoveRequestPrivate* rd = static_cast<QContactDetailDefinitionRemoveRequestPrivate*>(req->d_ptr); |
1965 req->d_ptr->m_error = error; |
2350 req->d_ptr->m_error = error; |
1966 rd->m_errors = errorMap; |
2351 rd->m_errors = errorMap; |
|
2352 bool emitState = rd->m_state != newState; |
|
2353 rd->m_state = newState; |
1967 emit req->resultsAvailable(); |
2354 emit req->resultsAvailable(); |
|
2355 if (emitState) |
|
2356 emit req->stateChanged(newState); |
1968 } |
2357 } |
1969 |
2358 |
1970 /*! |
2359 /*! |
1971 Updates the given QContactDetailDefinitionFetchRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
2360 Updates the given QContactDetailDefinitionFetchRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
|
2361 In addition, the state of the request will be changed to \a newState. |
|
2362 |
1972 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2363 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1973 */ |
2364 |
1974 void QContactManagerEngine::updateDefinitionFetchRequest(QContactDetailDefinitionFetchRequest* req, const QMap<QString, QContactDetailDefinition>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2365 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2366 */ |
|
2367 void QContactManagerEngine::updateDefinitionFetchRequest(QContactDetailDefinitionFetchRequest* req, const QMap<QString, QContactDetailDefinition>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
1975 { |
2368 { |
1976 QContactDetailDefinitionFetchRequestPrivate* rd = static_cast<QContactDetailDefinitionFetchRequestPrivate*>(req->d_ptr); |
2369 QContactDetailDefinitionFetchRequestPrivate* rd = static_cast<QContactDetailDefinitionFetchRequestPrivate*>(req->d_ptr); |
1977 req->d_ptr->m_error = error; |
2370 req->d_ptr->m_error = error; |
1978 rd->m_errors = errorMap; |
2371 rd->m_errors = errorMap; |
1979 rd->m_definitions = result; |
2372 rd->m_definitions = result; |
|
2373 bool emitState = rd->m_state != newState; |
|
2374 rd->m_state = newState; |
1980 emit req->resultsAvailable(); |
2375 emit req->resultsAvailable(); |
|
2376 if (emitState) |
|
2377 emit req->stateChanged(newState); |
1981 } |
2378 } |
1982 |
2379 |
1983 /*! |
2380 /*! |
1984 Updates the given QContactRelationshipSaveRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
2381 Updates the given QContactRelationshipSaveRequest \a req with the latest results \a result, operation error \a error, and map of input index to individual error \a errorMap. |
|
2382 In addition, the state of the request will be changed to \a newState. |
|
2383 |
1985 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2384 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1986 */ |
2385 |
1987 void QContactManagerEngine::updateRelationshipSaveRequest(QContactRelationshipSaveRequest* req, const QList<QContactRelationship>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2386 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2387 */ |
|
2388 void QContactManagerEngine::updateRelationshipSaveRequest(QContactRelationshipSaveRequest* req, const QList<QContactRelationship>& result, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
1988 { |
2389 { |
1989 QContactRelationshipSaveRequestPrivate* rd = static_cast<QContactRelationshipSaveRequestPrivate*>(req->d_ptr); |
2390 QContactRelationshipSaveRequestPrivate* rd = static_cast<QContactRelationshipSaveRequestPrivate*>(req->d_ptr); |
1990 req->d_ptr->m_error = error; |
2391 req->d_ptr->m_error = error; |
1991 rd->m_errors = errorMap; |
2392 rd->m_errors = errorMap; |
1992 rd->m_relationships = result; |
2393 rd->m_relationships = result; |
|
2394 bool emitState = rd->m_state != newState; |
|
2395 rd->m_state = newState; |
1993 emit req->resultsAvailable(); |
2396 emit req->resultsAvailable(); |
|
2397 if (emitState) |
|
2398 emit req->stateChanged(newState); |
1994 } |
2399 } |
1995 |
2400 |
1996 /*! |
2401 /*! |
1997 Updates the given QContactRelationshipRemoveRequest \a req with the operation error \a error, and map of input index to individual error \a errorMap. |
2402 Updates the given QContactRelationshipRemoveRequest \a req with the operation error \a error, and map of input index to individual error \a errorMap. |
|
2403 In addition, the state of the request will be changed to \a newState. |
|
2404 |
1998 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2405 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
1999 */ |
2406 |
2000 void QContactManagerEngine::updateRelationshipRemoveRequest(QContactRelationshipRemoveRequest* req, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap) |
2407 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2408 */ |
|
2409 void QContactManagerEngine::updateRelationshipRemoveRequest(QContactRelationshipRemoveRequest* req, QContactManager::Error error, const QMap<int, QContactManager::Error>& errorMap, QContactAbstractRequest::State newState) |
2001 { |
2410 { |
2002 QContactRelationshipRemoveRequestPrivate* rd = static_cast<QContactRelationshipRemoveRequestPrivate*>(req->d_ptr); |
2411 QContactRelationshipRemoveRequestPrivate* rd = static_cast<QContactRelationshipRemoveRequestPrivate*>(req->d_ptr); |
2003 req->d_ptr->m_error = error; |
2412 req->d_ptr->m_error = error; |
2004 rd->m_errors = errorMap; |
2413 rd->m_errors = errorMap; |
|
2414 bool emitState = rd->m_state != newState; |
|
2415 rd->m_state = newState; |
2005 emit req->resultsAvailable(); |
2416 emit req->resultsAvailable(); |
|
2417 if (emitState) |
|
2418 emit req->stateChanged(newState); |
2006 } |
2419 } |
2007 |
2420 |
2008 /*! |
2421 /*! |
2009 Updates the given QContactRelationshipFetchRequest \a req with the latest results \a result, and operation error \a error. |
2422 Updates the given QContactRelationshipFetchRequest \a req with the latest results \a result, and operation error \a error. |
|
2423 In addition, the state of the request will be changed to \a newState. |
|
2424 |
2010 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2425 It then causes the request to emit its resultsAvailable() signal to notify clients of the request progress. |
2011 */ |
2426 |
2012 void QContactManagerEngine::updateRelationshipFetchRequest(QContactRelationshipFetchRequest* req, const QList<QContactRelationship>& result, QContactManager::Error error) |
2427 If the new request state is different from the previous state, the stateChanged() signal will also be emitted from the request. |
|
2428 */ |
|
2429 void QContactManagerEngine::updateRelationshipFetchRequest(QContactRelationshipFetchRequest* req, const QList<QContactRelationship>& result, QContactManager::Error error, QContactAbstractRequest::State newState) |
2013 { |
2430 { |
2014 QContactRelationshipFetchRequestPrivate* rd = static_cast<QContactRelationshipFetchRequestPrivate*>(req->d_ptr); |
2431 QContactRelationshipFetchRequestPrivate* rd = static_cast<QContactRelationshipFetchRequestPrivate*>(req->d_ptr); |
2015 req->d_ptr->m_error = error; |
2432 req->d_ptr->m_error = error; |
2016 rd->m_relationships = result; |
2433 rd->m_relationships = result; |
|
2434 bool emitState = rd->m_state != newState; |
|
2435 rd->m_state = newState; |
2017 emit req->resultsAvailable(); |
2436 emit req->resultsAvailable(); |
|
2437 if (emitState) |
|
2438 emit req->stateChanged(newState); |
2018 } |
2439 } |
2019 |
2440 |
2020 #include "moc_qcontactmanagerengine.cpp" |
2441 #include "moc_qcontactmanagerengine.cpp" |
2021 |
2442 |
2022 QTM_END_NAMESPACE |
2443 QTM_END_NAMESPACE |