/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/


/*!

\page contactsasync.html

\title Contacts Asynchronous API

\tableofcontents


\section1 Introduction

The Contacts Asynchronous API enables a client to asynchronously fetch, update, or remove
contact, relationship or schema data from a contact manager.  Use of the asynchronous API
offers the programmer greater flexibility when requesting information from remote or
slow local datastores.

\section1 Using the API

The asynchronous API offered by the Contacts module is available through classes
derived from the QContactAbstractRequest class.  It consists of three major sections:
\list
  \o Contact Manipulation
  \o Relationship Manipulation
  \o Schema Manipulation
\endlist

The functionality offered by the synchronous API in these three categories is also
available through the asynchronous API.  There is one category of functionality
which is not provided by the asynchronous API which is provided by the synchronous
API: some information and reporting functionality is only provided through the
synchronous API.

For detailed information about the information and reporting functionality provided,
please refer to the documentation for the \l{Contacts Synchronous API}.

The functions to set and retrieve the id of the self-contact are also only provided by
the synchronous API.

\section2 Contact Manipulation

The most common type of operation that clients will perform involves retrieval or modification of contacts.
For in-depth information about contact manipulation, please refer to the \l{Contacts Synchronous API}.

There are four different types of operation which are supported by the asynchronous API:
\list
  \o Fetch contact ids
  \o Fetch contacts
  \o Save contacts (create or update)
  \o Remove contacts
\endlist

These operations are supported via the QContactLocalIdFetchRequest, QContactFetchRequest,
QContactSaveRequest and QContactRemoveRequest classes, respectively.

The synchronous API offered by the QContactManager class to allow manipulation of contacts consists
of the following functions:
\list
  \o contactIds(const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>()) const
  \o contactIds(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>()) const
  \o contacts(const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>(), const QContactFetchHint& fetchHint = QContactFetchHint()) const
  \o contacts(const QContactFilter& filter, const QList<QContactSortOrder>& sortOrders = QList<QContactSortOrder>(), const QContactFetchHint& fetchHint = QContactFetchHint()) const
  \o saveContacts(QList<QContact>* contacts, QMap<int, QContactManager::Error>* errorMap)
  \o removeContacts(QList<QContactLocalId>* contactIds, QMap<int, QContactManager::Error>* errorMap)
\endlist

\section3 \bold{Relationship Manipulation}

Contacts may be related in various ways.  The contacts API allows clients to define relationships between contacts.
For in-depth information about relationship manipulation, please refer to the \l{Contacts Synchronous API}.

There are three different types of operation which are supported by the asynchronous API:
\list
  \o Fetch relationships
  \o Save relationships (create or update, if supported by the backend)
  \o Remove relationships (if supported by the backend)
\endlist

These operations are supported via the QContactRelationshipFetchRequest,
QContactRelationshipSaveRequest and QContactRelationshipRemoveRequest classes respectively.

The synchronous API offered by the QContactManager class to allow manipulation of relationships
consists of the following functions:
\list
  \o relationships(const QContactId& participantId, QContactRelationshipFilter::Role role = QContactRelationshipFilter::Either) const;
  \o relationships(const QString& relationshipType = QString(), const QContactId& participantId = QContactId(), QContactRelationshipFilter::Role role = QContactRelationshipFilter::Either) const;
  \o saveRelationship(QContactRelationship* relationship);
  \o saveRelationships(QList<QContactRelationship>* relationships);
  \o removeRelationship(const QContactRelationship& relationship);
  \o removeRelationships(const QList<QContactRelationship>& relationships);
\endlist

\section2 Schema Manipulation

The schema supported by a plugin is the list of detail definitions which are supported by the plugin.
For in-depth information about the schema, please refer to the \l{Contacts Synchronous API}.

There are three different types of operation which are supported by the asynchronous API:
\list
  \o Fetch detail definitions
  \o Save detail definitions (create or update, if supported by the backend)
  \o Remove detail definitions (if supported by the backend)
\endlist

These operations are supported via the the QContactDetailDefinitionFetchRequest,
QContactDetailDefinitionSaveRequest and QContactDetailDefinitionRemoveRequest classes,
respectively.

The synchronous API offered by the QContactManager class to allow manipulation of the schema consists
of the following functions:
\list
  \o detailDefinitions(const QString& contactType = QContactType::TypeContact) const
  \o detailDefinition(const QString& definitionName, const QString& contactType = QContactType::TypeContact) const
  \o saveDetailDefinition(const QContactDetailDefinition& def, const QString& contactType = QContactType::TypeContact)
  \o removeDetailDefinition(const QString& definitionName, const QString& contactType = QContactType::TypeContact)
\endlist

\section1 Examples Of Usage

\section2 Fetching Contacts

The client sets up a request for contacts matching a specific criteria
from a particular manager.

Results from the request will be displayed to the user as they are
received.

    \snippet snippets/qtcontactsdocsample/qtcontactsdocsample.cpp Asynchronous contact request

\section2 Other Asynchronous Operations

All other asynchronous operations are performed in a similar manner to the
previous example. A request of the desired type (which is derived from
QContactAbstractRequest) is created, certain criteria are set which
determine the intent of the request, and the signals of the request
are connected to slots which deals with the results.  The request can then
be started.

*/
