|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 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 "qcontactdetaildefinitionsaverequest.h" |
|
43 #include "qcontactrequests_p.h" |
|
44 |
|
45 QTM_BEGIN_NAMESPACE |
|
46 |
|
47 /*! |
|
48 \class QContactDetailDefinitionSaveRequest |
|
49 \brief The QContactDetailDefinitionSaveRequest class allows a client to |
|
50 asynchronously request that certain detail definitions be saved in a |
|
51 contacts store. |
|
52 |
|
53 For a QContactDetailDefinitionSaveRequest, the resultsAvailable() signal will be emitted when |
|
54 either the individual item errors (which may be retrieved by calling errorMap()), or the resultant |
|
55 detail definitions (which may be retrieved by calling definitions()), are updated, as well as if |
|
56 the overall operation error (which may be retrieved by calling error()) is updated. |
|
57 |
|
58 Please see the class documentation of QContactAbstractRequest for more information about |
|
59 the usage of request classes and ownership semantics. |
|
60 |
|
61 \ingroup contacts-requests |
|
62 */ |
|
63 |
|
64 /*! Constructs a new detail definition save request whose parent is the specified \a parent */ |
|
65 QContactDetailDefinitionSaveRequest::QContactDetailDefinitionSaveRequest(QObject* parent) |
|
66 : QContactAbstractRequest(new QContactDetailDefinitionSaveRequestPrivate, parent) |
|
67 { |
|
68 } |
|
69 |
|
70 /*! Frees any memory used by this request */ |
|
71 QContactDetailDefinitionSaveRequest::~QContactDetailDefinitionSaveRequest() |
|
72 { |
|
73 QContactAbstractRequestPrivate::notifyEngine(this); |
|
74 } |
|
75 |
|
76 /*! |
|
77 Sets the definition to save to be the given \a definition. |
|
78 Equivalent to calling: |
|
79 \code |
|
80 setDefinitions(QList<QContactDetailDefinition>() << definition); |
|
81 \endcode |
|
82 */ |
|
83 void QContactDetailDefinitionSaveRequest::setDefinition(const QContactDetailDefinition& definition) |
|
84 { |
|
85 Q_D(QContactDetailDefinitionSaveRequest); |
|
86 QMutexLocker ml(&d->m_mutex); |
|
87 d->m_definitions.clear(); |
|
88 d->m_definitions.append(definition); |
|
89 } |
|
90 |
|
91 /*! Sets the definitions to save to be \a definitions */ |
|
92 void QContactDetailDefinitionSaveRequest::setDefinitions(const QList<QContactDetailDefinition>& definitions) |
|
93 { |
|
94 Q_D(QContactDetailDefinitionSaveRequest); |
|
95 QMutexLocker ml(&d->m_mutex); |
|
96 d->m_definitions = definitions; |
|
97 } |
|
98 |
|
99 /*! Returns the list of definitions that will be saved if called prior to calling \c start(), |
|
100 otherwise returns the list of detail definitions as they were saved in the contacts store */ |
|
101 QList<QContactDetailDefinition> QContactDetailDefinitionSaveRequest::definitions() const |
|
102 { |
|
103 Q_D(const QContactDetailDefinitionSaveRequest); |
|
104 QMutexLocker ml(&d->m_mutex); |
|
105 return d->m_definitions; |
|
106 } |
|
107 |
|
108 /*! Sets the type of contact for which detail definitions should be saved to \a contactType */ |
|
109 void QContactDetailDefinitionSaveRequest::setContactType(const QString& contactType) |
|
110 { |
|
111 Q_D(QContactDetailDefinitionSaveRequest); |
|
112 QMutexLocker ml(&d->m_mutex); |
|
113 d->m_contactType = contactType; |
|
114 } |
|
115 |
|
116 /*! Returns the type of contact for which detail definitions will be saved */ |
|
117 QString QContactDetailDefinitionSaveRequest::contactType() const |
|
118 { |
|
119 Q_D(const QContactDetailDefinitionSaveRequest); |
|
120 QMutexLocker ml(&d->m_mutex); |
|
121 return d->m_contactType; |
|
122 } |
|
123 |
|
124 /*! Returns the map of input definition list indices to errors which occurred */ |
|
125 QMap<int, QContactManager::Error> QContactDetailDefinitionSaveRequest::errorMap() const |
|
126 { |
|
127 Q_D(const QContactDetailDefinitionSaveRequest); |
|
128 QMutexLocker ml(&d->m_mutex); |
|
129 return d->m_errors; |
|
130 } |
|
131 |
|
132 #include "moc_qcontactdetaildefinitionsaverequest.cpp" |
|
133 |
|
134 QTM_END_NAMESPACE |