1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtContacts module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
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 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
40
****************************************************************************/
42
#include "qcontactsaverequest.h"
43
#include "qcontactrequests_p.h"
45
QT_BEGIN_NAMESPACE_CONTACTS
48
\class QContactSaveRequest
49
\brief The QContactSaveRequest class allows a client to asynchronously
50
request that certain contacts be saved to a contacts store.
52
For a QContactSaveRequest, the resultsAvailable() signal will be emitted when
53
either the individual item errors (which may be retrieved by calling errorMap()), or the resultant
54
contacts (which may be retrieved by calling contacts()), are updated, as well as if
55
the overall operation error (which may be retrieved by calling error()) is updated.
57
Please see the class documentation of QContactAbstractRequest for more information about
58
the usage of request classes and ownership semantics.
63
\ingroup contacts-requests
66
/*! Constructs a new contact save request whose parent is the specified \a parent */
67
QContactSaveRequest::QContactSaveRequest(QObject* parent)
68
: QContactAbstractRequest(new QContactSaveRequestPrivate, parent)
72
/*! Frees any memory used by this request */
73
QContactSaveRequest::~QContactSaveRequest()
75
QContactAbstractRequestPrivate::notifyEngine(this);
79
Sets the \a storageLocation where the new contacts will be saved to.
81
This is ignored for contacts which have already been saved. Instead,
82
those contacts are saved back to the storage location where they were
85
\sa QContactAbstractRequest::StorageLocation
89
void QContactSaveRequest::setStorageLocation(QContactAbstractRequest::StorageLocation storageLocation)
91
Q_D(QContactSaveRequest);
92
QMutexLocker ml(&d->m_mutex);
93
d->m_storageLocation = storageLocation;
97
Returns the storage location where the contacts will be saved to.
99
This is ignored for contacts which have already been saved. Instead,
100
those contacts are saved back to the storage location where they were
103
\sa QContactAbstractRequest::StorageLocation
104
\sa setStorageLocation()
106
QContactAbstractRequest::StorageLocation QContactSaveRequest::storageLocation() const
108
Q_D(const QContactSaveRequest);
109
QMutexLocker ml(&d->m_mutex);
110
return d->m_storageLocation;
114
Sets the contact to be saved to \a contact.
115
Equivalent to calling:
117
setContacts(QList<QContact>() << contact);
120
void QContactSaveRequest::setContact(const QContact& contact)
122
Q_D(QContactSaveRequest);
123
QMutexLocker ml(&d->m_mutex);
124
d->m_contacts.clear();
125
d->m_contacts.append(contact);
128
/*! Sets the list of contacts to be saved to \a contacts
130
void QContactSaveRequest::setContacts(const QList<QContact>& contacts)
132
Q_D(QContactSaveRequest);
133
QMutexLocker ml(&d->m_mutex);
134
d->m_contacts = contacts;
137
/*! Returns the list of contacts which will be saved if called prior to calling \c start(),
138
otherwise returns the list of contacts with their ids set appropriately (successfully
139
saved new contacts will have an id assigned).
141
QList<QContact> QContactSaveRequest::contacts() const
143
Q_D(const QContactSaveRequest);
144
QMutexLocker ml(&d->m_mutex);
145
return d->m_contacts;
148
/*! Returns the map of input contact list indices to errors which occurred
150
QMap<int, QContactManager::Error> QContactSaveRequest::errorMap() const
152
Q_D(const QContactSaveRequest);
153
QMutexLocker ml(&d->m_mutex);
158
Set the list of definitions to restrict saving to \a typeMask. This allows you to perform
159
partial save (and remove) operations on existing contacts.
161
If \a typeMask is empty (the default), no restrictions will apply, and the passed
162
in contacts will be saved as is. Otherwise, only details whose types are in
163
the typeMask will be saved. If a type is present in the list, but there are no
164
corresponding details in the contact passed into this request, any existing details in
165
the manager for that contact will be removed.
167
This is useful if you've used a fetch hint to fetch a partial contact from a manager
168
so that you can save changes to the details you actually fetched without removing
169
the details you didn't.
171
Additionally, when performing synchronization operations with other managers that don't
172
support the full range of details, you can restrict the update operation to only those
173
details so that you don't lose the extra details that are supported in this manager.
175
\note Some managers do not support partial updates natively, in which case the QtContacts
176
framework will emulate the functionality (fetching the whole contact, applying the
177
new restricted details, and saving the contact back).
179
void QContactSaveRequest::setTypeMask(const QList<QContactDetail::DetailType> &typeMask)
181
Q_D(QContactSaveRequest);
182
QMutexLocker ml(&d->m_mutex);
183
d->m_typeMask = typeMask;
187
Returns the list of definitions that this request will operate on.
189
If the list is empty, the request will operate on all details.
191
QList<QContactDetail::DetailType> QContactSaveRequest::typeMask() const
193
Q_D(const QContactSaveRequest);
194
QMutexLocker ml(&d->m_mutex);
195
return d->m_typeMask;
198
#include "moc_qcontactsaverequest.cpp"
200
QT_END_NAMESPACE_CONTACTS