1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtContacts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#include "qcontactrelationshipfetchrequest.h"
35
36#include "qcontactrequests_p.h"
37
38QT_BEGIN_NAMESPACE_CONTACTS
39
40/*!
41 \class QContactRelationshipFetchRequest
42
43 \brief The QContactRelationshipFetchRequest class allows a client to
44 asynchronously request relationships from a contacts store manager.
45
46 For a QContactRelationshipFetchRequest, the resultsAvailable() signal will be emitted when the resultant
47 relationships (which may be retrieved by calling relationships()), are updated, as well as if
48 the overall operation error (which may be retrieved by calling error()) is updated.
49
50 Please see the class documentation of QContactAbstractRequest for more information about
51 the usage of request classes and ownership semantics.
52
53
54 \inmodule QtContacts
55
56 \ingroup contacts-requests
57 */
58
59/*! Constructs a new relationship fetch request whose parent is the specified \a parent
60 */
61QContactRelationshipFetchRequest::QContactRelationshipFetchRequest(QObject* parent)
62 : QContactAbstractRequest(new QContactRelationshipFetchRequestPrivate, parent)
63{
64}
65
66/*! Frees any memory used by this request */
67QContactRelationshipFetchRequest::~QContactRelationshipFetchRequest()
68{
69}
70
71/*! Sets the source contact criterion of the fetch request to \a firstContactId.
72 If \a firstContactId is default-constructed, or the first contact is not set,
73 the request will fetch relationships involving any first contact.
74*/
75void QContactRelationshipFetchRequest::setFirst(const QContactId& firstContactId)
76{
77 Q_D(QContactRelationshipFetchRequest);
78 QMutexLocker ml(&d->m_mutex);
79 d->m_first = firstContactId;
80}
81
82/*! Returns the ID of the source contact criterion of the fetch request
83 */
84QContactId QContactRelationshipFetchRequest::first() const
85{
86 Q_D(const QContactRelationshipFetchRequest);
87 QMutexLocker ml(&d->m_mutex);
88 return d->m_first;
89}
90
91/*! Sets the relationship type criterion of the fetch request to \a relationshipType.
92 If \a relationshipType is empty, or the relationship type is not set,
93 the request will fetch relationships of any type.
94*/
95void QContactRelationshipFetchRequest::setRelationshipType(const QString& relationshipType)
96{
97 Q_D(QContactRelationshipFetchRequest);
98 QMutexLocker ml(&d->m_mutex);
99 d->m_relationshipType = relationshipType;
100}
101
102/*! Returns the relationship type criterion of the fetch request
103 */
104QString QContactRelationshipFetchRequest::relationshipType() const
105{
106 Q_D(const QContactRelationshipFetchRequest);
107 QMutexLocker ml(&d->m_mutex);
108 return d->m_relationshipType;
109}
110
111/*! Sets the destination contact criterion of the fetch request to \a secondContactId.
112 If \a secondContactId is default-constructed or the second contact is not set,
113 the request will fetch relationships involving any second contact.
114*/
115void QContactRelationshipFetchRequest::setSecond(const QContactId& secondContactId)
116{
117 Q_D(QContactRelationshipFetchRequest);
118 QMutexLocker ml(&d->m_mutex);
119 d->m_second = secondContactId;
120}
121
122/*! Returns the ID of the destination contact criterion of the fetch request
123 */
124QContactId QContactRelationshipFetchRequest::second() const
125{
126 Q_D(const QContactRelationshipFetchRequest);
127 QMutexLocker ml(&d->m_mutex);
128 return d->m_second;
129}
130
131
132/*! Returns the list of relationships that was the result of the request
133 */
134QList<QContactRelationship> QContactRelationshipFetchRequest::relationships() const
135{
136 Q_D(const QContactRelationshipFetchRequest);
137 QMutexLocker ml(&d->m_mutex);
138 return d->m_relationships;
139}
140
141#include "moc_qcontactrelationshipfetchrequest.cpp"
142
143QT_END_NAMESPACE_CONTACTS
144

source code of qtpim/src/contacts/requests/qcontactrelationshipfetchrequest.cpp