qtmobility/src/contacts/requests/qcontactrelationshipfetchrequest.cpp
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     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 "qcontactrelationshipfetchrequest.h"
       
    43 #include "qcontactrelationship.h"
       
    44 #include "qcontactrelationshipfilter.h"
       
    45 #include "qcontactrequests_p.h"
       
    46 
       
    47 QTM_BEGIN_NAMESPACE
       
    48 
       
    49 /*!
       
    50   \class QContactRelationshipFetchRequest
       
    51 
       
    52   \brief The QContactRelationshipFetchRequest class allows a client to
       
    53   asynchronously request relationships from a contacts store manager.
       
    54 
       
    55   For a QContactRelationshipFetchRequest, the resultsAvailable() signal will be emitted when the resultant
       
    56   relationships (which may be retrieved by calling relationships()), are updated, as well as if
       
    57   the overall operation error (which may be retrieved by calling error()) is updated.
       
    58 
       
    59   \ingroup contacts-requests
       
    60  */
       
    61 
       
    62 /*! Constructs a new relationship fetch request
       
    63  */
       
    64 QContactRelationshipFetchRequest::QContactRelationshipFetchRequest()
       
    65     : QContactAbstractRequest(new QContactRelationshipFetchRequestPrivate)
       
    66 {
       
    67 }
       
    68 
       
    69 /*! Cleans up the memory in use by this relationship fetch request
       
    70  */
       
    71 QContactRelationshipFetchRequest::~QContactRelationshipFetchRequest()
       
    72 {
       
    73 }
       
    74 
       
    75 /*! Sets the source contact criterion of the fetch request to \a firstId.
       
    76     If \a firstId is the default-constructed id, or the first contact id is not set,
       
    77     the request will fetch relationships involving any first contact.
       
    78 */
       
    79 void QContactRelationshipFetchRequest::setFirst(const QContactId& firstId)
       
    80 {
       
    81     Q_D(QContactRelationshipFetchRequest);
       
    82     d->m_first = firstId;
       
    83 }
       
    84 
       
    85 /*! Returns the source contact criterion of the fetch request
       
    86  */
       
    87 QContactId QContactRelationshipFetchRequest::first() const
       
    88 {
       
    89     Q_D(const QContactRelationshipFetchRequest);
       
    90     return d->m_first;
       
    91 }
       
    92 
       
    93 /*! Sets the relationship type criterion of the fetch request to \a relationshipType.
       
    94     If \a relationshipType is empty, or the relationship type is not set,
       
    95     the request will fetch relationships of any type.
       
    96 */
       
    97 void QContactRelationshipFetchRequest::setRelationshipType(const QString& relationshipType)
       
    98 {
       
    99     Q_D(QContactRelationshipFetchRequest);
       
   100     d->m_relationshipType = relationshipType;
       
   101 }
       
   102 
       
   103 /*! Returns the relationship type criterion of the fetch request
       
   104  */
       
   105 QString QContactRelationshipFetchRequest::relationshipType() const
       
   106 {
       
   107     Q_D(const QContactRelationshipFetchRequest);
       
   108     return d->m_relationshipType;
       
   109 }
       
   110 
       
   111 /*! Sets the destination contact criterion of the fetch request to \a secondId.
       
   112     If \a secondId is the default-constructed id, or the second contact id is not set,
       
   113     the request will fetch relationships involving any second contact.
       
   114 */
       
   115 void QContactRelationshipFetchRequest::setSecond(const QContactId& secondId)
       
   116 {
       
   117     Q_D(QContactRelationshipFetchRequest);
       
   118     d->m_second = secondId;
       
   119 }
       
   120 
       
   121 /*! Returns the destination contact criterion of the fetch request
       
   122  */
       
   123 QContactId QContactRelationshipFetchRequest::second() const
       
   124 {
       
   125     Q_D(const QContactRelationshipFetchRequest);
       
   126     return d->m_second;
       
   127 }
       
   128 
       
   129 /*!
       
   130   \internal
       
   131   Sets the participant criterion of the fetch request to \a
       
   132   participantUri.  If the \a participantUri references a contact in
       
   133   the manager from which the relationships are being fetched and the
       
   134   \a role is \c QContactRelationshipFilter::Either, a relationship
       
   135   will match the criterion if the contact appears in the relationship
       
   136   as either the source or a destination contact.  If the \a
       
   137   participantUri references a contact in a different manager to the
       
   138   one from which the relationships are being fetched and the \a role
       
   139   is \c QContactRelationshipFilter::Either, a relationship will match
       
   140   the criterion only if the contact appears in the relationship as a
       
   141   destination contact.  If the \a participantUri references a contact
       
   142   in a different manager to the one from which the relationships are
       
   143   being fetched and the \a role is \c
       
   144   QContactRelationshipFilter::Source, no relationships will be
       
   145   fetched.
       
   146   
       
   147   If the \a participantUri consists of an empty manager URI and the
       
   148   zero contact id, or if the participant criterion is not set, the
       
   149   request will fetch relationships involving any participant.
       
   150  */
       
   151 void QContactRelationshipFetchRequest::setParticipant(const QContactId& participantUri, QContactRelationshipFilter::Role role)
       
   152 {
       
   153     Q_D(QContactRelationshipFetchRequest);
       
   154     d->m_participantUri = participantUri;
       
   155     d->m_role = role;
       
   156 }
       
   157 
       
   158 /*!
       
   159   \internal
       
   160   Returns the participant criterion of the fetch request
       
   161  */
       
   162 QContactId QContactRelationshipFetchRequest::participant() const
       
   163 {
       
   164     Q_D(const QContactRelationshipFetchRequest);
       
   165     return d->m_participantUri;
       
   166 }
       
   167 
       
   168 /*!
       
   169   \internal
       
   170   Returns the role of the participant criterion of the fetch request
       
   171  */
       
   172 QContactRelationshipFilter::Role QContactRelationshipFetchRequest::participantRole() const
       
   173 {
       
   174     Q_D(const QContactRelationshipFetchRequest);
       
   175     return d->m_role;
       
   176 }
       
   177 
       
   178 /*! Returns the list of relationships that was the result of the request
       
   179  */
       
   180 QList<QContactRelationship> QContactRelationshipFetchRequest::relationships() const
       
   181 {
       
   182     Q_D(const QContactRelationshipFetchRequest);
       
   183     return d->m_relationships;
       
   184 }
       
   185 
       
   186 #include "moc_qcontactrelationshipfetchrequest.cpp"
       
   187 
       
   188 QTM_END_NAMESPACE