qtmobility/src/contacts/qcontactfetchhint.cpp
changeset 4 90517678cc4f
child 5 453da2cfceef
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include "qcontactfetchhint.h"
       
    43 #include "qcontactfetchhint_p.h"
       
    44 
       
    45 #include <QStringList>
       
    46 
       
    47 QTM_BEGIN_NAMESPACE
       
    48 
       
    49 /*!
       
    50   \class QContactFetchHint
       
    51   \brief The QContactFetchHint class provides hints to the manager about which contact
       
    52   information needs to be retrieved in an asynchronous fetch request or a synchronous
       
    53   function call.
       
    54 
       
    55   All of the hints may be ignored at the discretion of the manager, however if a manager
       
    56   is able to optimize retrieval of contacts due to hints, it may do so.  If a manager
       
    57   ignores a hint, it must retrieve the full set of data that the hint refers to.
       
    58 
       
    59   The fetch hint contains:
       
    60   \list
       
    61    \o a list of detail definition names which the client is interested
       
    62   in (empty if interested in all detail definitions)
       
    63    \o a list of relationship types which the client is interested in
       
    64   (empty if interested in all relationships)
       
    65    \o some optimization flags which allow the client to tell the backend if they are
       
    66   not interested in any relationships, any action preferences, or any binary blobs (images etc).
       
    67   \endlist
       
    68 
       
    69   Important note: a client should not make changes to a contact which has been retrieved
       
    70   using a fetch hint other than the default fetch hint.  Doing so will result in information
       
    71   loss when saving the contact back to the manager (as the "new" restricted contact will
       
    72   replace the previously saved contact in the backend).
       
    73  */
       
    74 
       
    75 /*!
       
    76   \enum QContactFetchHint::OptimizationHint
       
    77 
       
    78   This enum defines flags which may be set to inform the backend that the client does
       
    79   not require certain information.  The backend may safely ignore the hint, but then
       
    80   must return the full set of information relating to the optimization hint.
       
    81 
       
    82   \value AllRequired Tells the backend that all information is required
       
    83   \value NoRelationships Tells the backend that the client does not require retrieved contacts to include a cache of relationships
       
    84   \value NoActionPreferences Tells the backend that the client does not require retrieved contacts to include a cache of action preferences
       
    85   \value NoBinaryBlobs Tells the backend that the client does not require retrieved contacts to include binary blobs such as thumbnail images
       
    86  */
       
    87 
       
    88 /*!
       
    89   Constructs a new contact fetch hint which requests that the backend fetch all information
       
    90  */
       
    91 QContactFetchHint::QContactFetchHint()
       
    92     : d(new QContactFetchHintPrivate)
       
    93 {
       
    94 }
       
    95 
       
    96 /*!
       
    97   Constructs a new contact fetch hint as a copy of \a other
       
    98  */
       
    99 QContactFetchHint::QContactFetchHint(const QContactFetchHint &other)
       
   100     : d(other.d)
       
   101 {
       
   102 }
       
   103 
       
   104 /*!
       
   105   Frees any memory in use by the fetch hint
       
   106  */
       
   107 QContactFetchHint::~QContactFetchHint()
       
   108 {
       
   109 }
       
   110 
       
   111 /*!
       
   112   Assigns this fetch hint to be equal to the \a other fetch hint
       
   113  */
       
   114 QContactFetchHint& QContactFetchHint::operator=(const QContactFetchHint& other)
       
   115 {
       
   116     d = other.d;
       
   117     return *this;
       
   118 }
       
   119 
       
   120 /*!
       
   121   Returns the list of definition names that identify detail definitions of which details
       
   122   the manager should (at a minimum) retrieve when fetching contacts.
       
   123   This hint may be ignored by the backend, in which case it will return the full set of details for
       
   124   each contact retrieved.
       
   125 
       
   126   \sa setDetailDefinitionsHint()
       
   127  */
       
   128 QStringList QContactFetchHint::detailDefinitionsHint() const
       
   129 {
       
   130     return d->m_definitionsHint;
       
   131 }
       
   132 
       
   133 /*!
       
   134   Sets the list of definition names that identify detail definitions of which details
       
   135   the manager should (at a minimum) retrieve when fetching contacts to \a definitionNames.
       
   136   This hint may be ignored by the backend, in which case it will return the full set of details for
       
   137   each contact retrieved.
       
   138 
       
   139   \sa detailDefinitionsHint()
       
   140  */
       
   141 void QContactFetchHint::setDetailDefinitionsHint(const QStringList& definitionNames)
       
   142 {
       
   143     d->m_definitionsHint = definitionNames;
       
   144 }
       
   145 
       
   146 /*!
       
   147   Returns the list of relationship types that the manager should (at a minimum) retrieve
       
   148   when fetching contacts.
       
   149   This hint may be ignored by the backend, in which case it will return the full set of
       
   150   relationships for each contact retrieved.
       
   151 
       
   152   \sa setRelationshipTypesHint(), QContact::relationships()
       
   153  */
       
   154 QStringList QContactFetchHint::relationshipTypesHint() const
       
   155 {
       
   156     return d->m_relationshipsHint;
       
   157 }
       
   158 
       
   159 /*!
       
   160   Sets the list of relationship types that the manager should (at a minimum) retrieve
       
   161   when fetching contacts to \a relationshipTypes.
       
   162   This hint may be ignored by the backend, in which case it will return the full set of
       
   163   relationships for each contact retrieved.
       
   164 
       
   165   \sa relationshipTypesHint(), QContact::relationships()
       
   166  */
       
   167 void QContactFetchHint::setRelationshipTypesHint(const QStringList& relationshipTypes)
       
   168 {
       
   169     d->m_relationshipsHint = relationshipTypes;
       
   170 }
       
   171 
       
   172 /*!
       
   173   Returns the optimization hint flags specified by the client.
       
   174   These hints may be ignored by the backend, in which case it will return
       
   175   the full set of information accessible in a contact, including
       
   176   relationships, action preferences, and binary blobs.
       
   177 
       
   178   \sa setOptimizationHints()
       
   179  */
       
   180 QContactFetchHint::OptimizationHints QContactFetchHint::optimizationHints() const
       
   181 {
       
   182     return d->m_optimizationHints;
       
   183 }
       
   184 
       
   185 /*!
       
   186   Sets the optimization hint flags specified by the client to \a hints.
       
   187   These hints may be ignored by the backend, in which case it will return
       
   188   the full set of information accessible in a contact, including
       
   189   relationships, action preferences, and binary blobs.
       
   190 
       
   191   \sa optimizationHints()
       
   192  */
       
   193 void QContactFetchHint::setOptimizationHints(OptimizationHints hints)
       
   194 {
       
   195     d->m_optimizationHints = hints;
       
   196 }
       
   197 
       
   198 QTM_END_NAMESPACE