Buteo Synchronization Framework: SyncResults.h Source File

Buteo Synchronization Framework

SyncResults.h
1 /*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23 #ifndef SYNCRESULTS_H_2
24 #define SYNCRESULTS_H_2
25
26 #include <QDateTime>
27 #include <QList>
28 #include "TargetResults.h"
29
30 class QDomDocument;
31 class QDomElement;
32
33 namespace Buteo {
34
35 struct DatabaseResults {
36
37 int iLocalItemsAdded;
38 int iLocalItemsModified;
39 int iLocalItemsDeleted;
41 int iRemoteItemsAdded;
42 int iRemoteItemsModified;
43 int iRemoteItemsDeleted;
45 DatabaseResults() : iLocalItemsAdded(0), iLocalItemsModified(0), iLocalItemsDeleted(0),
46 iRemoteItemsAdded(0), iRemoteItemsModified(0), iRemoteItemsDeleted(0) { }
47
48 };
49
50 class SyncResultsPrivate;
51
58 class SyncResults
59 {
60 public:
61
66 enum MajorCode {
67 SYNC_RESULT_INVALID = -1,
68 SYNC_RESULT_SUCCESS = 0,
69 SYNC_RESULT_FAILED,
70 SYNC_RESULT_CANCELLED
71 };
72
77 enum MinorCode {
78
79 //NO-Error
80 NO_ERROR = 0,
81
82 //These error codes are mapped to syncAgentConsts.h
83 // Successful 3xx
84 SYNC_FINISHED = 301,
85
86 // Client/Configuration errors 4xx
87 INTERNAL_ERROR = 401,
88 AUTHENTICATION_FAILURE,
89 DATABASE_FAILURE,
90 PLUGIN_ERROR,
91 PLUGIN_TIMEOUT,
92
93 // Server/Network errors 5xx
94 SUSPENDED = 501,
95 ABORTED,
96 CONNECTION_ERROR,
97 INVALID_SYNCML_MESSAGE,
98 UNSUPPORTED_SYNC_TYPE,
99 UNSUPPORTED_STORAGE_TYPE,
100 //Upto here
101
102 //Context Error Code
103 LOW_BATTERY_POWER = 601,
104 POWER_SAVING_MODE,
105 OFFLINE_MODE,
106 BACKUP_IN_PROGRESS,
107 LOW_MEMORY
108 };
109
115 SyncResults();
116
121 SyncResults(const SyncResults &aSource);
122
129 SyncResults(QDateTime aTime, MajorCode aMajorCode, MinorCode aMinorCode);
130
135 explicit SyncResults(const QDomElement &aRoot);
136
139 ~SyncResults();
140
145 SyncResults &operator=(const SyncResults &aRhs);
146
154 QDomElement toXml(QDomDocument &aDoc) const;
155
160 QString toString() const;
161
166 QList<TargetResults> targetResults() const;
167
172 void addTargetResults(const TargetResults &aResults);
173
178 QDateTime syncTime() const;
179
184 MajorCode majorCode() const;
185
190 void setMajorCode(MajorCode aMajorCode);
191
196 MinorCode minorCode() const;
197
202 void setMinorCode(MinorCode aMinorCode);
203
204
209 void setTargetId(const QString &aTargetId);
210
213 QString getTargetId() const;
214
220 bool operator<(const SyncResults &aOther) const;
221
226 void setScheduled(bool aScheduled);
227
232 bool isScheduled() const;
233
234 private:
235
236 SyncResultsPrivate *d_ptr;
237
238 #ifdef SYNCFW_UNIT_TESTS
239 friend class ClientThreadTest;
240 #endif
241
242 };
243
244 }
245 #endif // SYNCRESULTS_H_2
Buteo::SyncResults
Contains information about a completed synchronization session.
Definition: SyncResults.h:59
Buteo::SyncResults::setScheduled
void setScheduled(bool aScheduled)
Sets if the results are from a scheduled sync.
Definition: SyncResults.cpp:213
Buteo::SyncResults::getTargetId
QString getTargetId() const
Gets the remote target Id.
Definition: SyncResults.cpp:203
Buteo::SyncResults::setMajorCode
void setMajorCode(MajorCode aMajorCode)
Sets the result code.
Definition: SyncResults.cpp:181
Buteo::SyncResults::minorCode
MinorCode minorCode() const
Gets the failed reason.
Definition: SyncResults.cpp:187
Buteo::SyncResults::MajorCode
MajorCode
enum value
Definition: SyncResults.h:66
Buteo::SyncResults::setTargetId
void setTargetId(const QString &aTargetId)
Sets the remote target Id.
Definition: SyncResults.cpp:198
Buteo::SyncResults::majorCode
MajorCode majorCode() const
Gets the result code.
Definition: SyncResults.cpp:176
Buteo::SyncResults::setMinorCode
void setMinorCode(MinorCode aMinorCode)
Sets the failed Reason.
Definition: SyncResults.cpp:192
Buteo::SyncResults::operator<
bool operator<(const SyncResults &aOther) const
Compares two results objects by sync time.
Definition: SyncResults.cpp:208
Buteo::SyncResults::isScheduled
bool isScheduled() const
Checks if the results are from a scheduled sync.
Definition: SyncResults.cpp:218
Buteo::SyncResults::toString
QString toString() const
Exports the sync results to QString.
Definition: SyncResults.cpp:147
Buteo::SyncResults::addTargetResults
void addTargetResults(const TargetResults &aResults)
Adds target results to this object.
Definition: SyncResults.cpp:166
Buteo::SyncResults::SyncResults
SyncResults()
Constructs an empty sync results object.
Definition: SyncResults.cpp:82
Buteo::SyncResults::operator=
SyncResults & operator=(const SyncResults &aRhs)
Assignment operator.
Definition: SyncResults.cpp:121
Buteo::SyncResults::syncTime
QDateTime syncTime() const
Gets the sync time.
Definition: SyncResults.cpp:171
Buteo::SyncResults::MinorCode
MinorCode
enum value
Definition: SyncResults.h:77
Buteo::SyncResults::toXml
QDomElement toXml(QDomDocument &aDoc) const
Exports the sync results to XML.
Definition: SyncResults.cpp:131
Buteo::SyncResults::~SyncResults
~SyncResults()
Destructor.
Definition: SyncResults.cpp:115
Buteo::SyncResults::targetResults
QList< TargetResults > targetResults() const
Gets the results of all targets.
Definition: SyncResults.cpp:161
Buteo::TargetResults
Sync results for one target.
Definition: TargetResults.h:61
QList
Definition: SyncBackupAdaptor.h:40
Buteo::DatabaseResults
Definition: SyncResults.h:35
Buteo::DatabaseResults::iLocalItemsModified
int iLocalItemsModified
Definition: SyncResults.h:38
Buteo::DatabaseResults::iRemoteItemsAdded
int iRemoteItemsAdded
Definition: SyncResults.h:41
Buteo::DatabaseResults::iRemoteItemsDeleted
int iRemoteItemsDeleted
Definition: SyncResults.h:43
Buteo::DatabaseResults::iLocalItemsAdded
int iLocalItemsAdded
Definition: SyncResults.h:37
Buteo::DatabaseResults::iLocalItemsDeleted
int iLocalItemsDeleted
Definition: SyncResults.h:39
Buteo::DatabaseResults::iRemoteItemsModified
int iRemoteItemsModified
Definition: SyncResults.h:42