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 <QSharedPointer>
29#include <QObject>
30#include <QVariantList>
31#include "TargetResults.h"
32
33class QDomDocument;
34class QDomElement;
35
36namespace Buteo {
37
57
58class SyncResultsPrivate;
59
67{
68 Q_GADGET
69 Q_PROPERTY(QDateTime syncTime READ syncTime CONSTANT)
70 Q_PROPERTY(MajorCode majorCode READ majorCode CONSTANT)
71 Q_PROPERTY(MinorCode minorCode READ minorCode CONSTANT)
72 Q_PROPERTY(bool scheduled READ isScheduled CONSTANT)
73 Q_PROPERTY(QString targetId READ getTargetId CONSTANT)
74 Q_PROPERTY(QVariantList results READ variantTargetResults CONSTANT)
75
76public:
81 enum MajorCode {
82 SYNC_RESULT_INVALID = -1,
83 SYNC_RESULT_SUCCESS = 0,
84 SYNC_RESULT_FAILED,
85 SYNC_RESULT_CANCELLED
86 };
87 Q_ENUM(MajorCode)
88
89
93 enum MinorCode {
94 // No error
95 NO_ERROR = 0,
96
97 // Sync completed but some unblocking issues appeared 3xx
98 ITEM_FAILURES = 301,
99
100 // Client/Configuration errors 4xx
101 INTERNAL_ERROR = 401,
102 AUTHENTICATION_FAILURE,
103 DATABASE_FAILURE,
104 PLUGIN_ERROR,
105 PLUGIN_TIMEOUT,
106
107 // Server/Network errors 5xx
108 ABORTED = 501,
109 CONNECTION_ERROR,
110 UNSUPPORTED_SYNC_TYPE,
111 UNSUPPORTED_STORAGE_TYPE,
112
113 // Context Error Code
114 LOW_BATTERY_POWER = 601,
115 POWER_SAVING_MODE,
116 OFFLINE_MODE,
117 BACKUP_IN_PROGRESS,
118 LOW_MEMORY
119 };
120 Q_ENUM(MinorCode)
121
122
127 SyncResults();
128
133 SyncResults(const SyncResults &aSource);
134
141 SyncResults(QDateTime aTime, MajorCode aMajorCode, MinorCode aMinorCode);
142
147 explicit SyncResults(const QDomElement &aRoot);
148
151 ~SyncResults();
152
157 SyncResults &operator=(const SyncResults &aRhs);
158
166 QDomElement toXml(QDomDocument &aDoc) const;
167
172 QString toString() const;
173
179
184 void addTargetResults(const TargetResults &aResults);
185
190 QDateTime syncTime() const;
191
196 MajorCode majorCode() const;
197
202 void setMajorCode(MajorCode aMajorCode);
203
208 MinorCode minorCode() const;
209
214 void setMinorCode(MinorCode aMinorCode);
215
216
221 void setTargetId(const QString &aTargetId);
222
225 QString getTargetId() const;
226
232 bool operator<(const SyncResults &aOther) const;
233
238 void setScheduled(bool aScheduled);
239
244 bool isScheduled() const;
245
246private:
247 QVariantList variantTargetResults() const;
248 QSharedPointer<SyncResultsPrivate> d_ptr;
249
250#ifdef SYNCFW_UNIT_TESTS
251 friend class ClientThreadTest;
252#endif
253};
254
255}
256
257Q_DECLARE_METATYPE(Buteo::SyncResults)
258
259#endif // SYNCRESULTS_H_2
Contains information about a completed synchronization session.
Definition SyncResults.h:67
void setScheduled(bool aScheduled)
Sets if the results are from a scheduled sync.
Definition SyncResults.cpp:214
QString getTargetId() const
Gets the remote target Id.
Definition SyncResults.cpp:204
void setMajorCode(MajorCode aMajorCode)
Sets the result code.
Definition SyncResults.cpp:182
MinorCode minorCode() const
Gets the failed reason.
Definition SyncResults.cpp:188
MajorCode
enum value
Definition SyncResults.h:81
void setTargetId(const QString &aTargetId)
Sets the remote target Id.
Definition SyncResults.cpp:199
MajorCode majorCode() const
Gets the result code.
Definition SyncResults.cpp:177
void setMinorCode(MinorCode aMinorCode)
Sets the failed Reason.
Definition SyncResults.cpp:193
bool operator<(const SyncResults &aOther) const
Compares two results objects by sync time.
Definition SyncResults.cpp:209
bool isScheduled() const
Checks if the results are from a scheduled sync.
Definition SyncResults.cpp:219
QString toString() const
Exports the sync results to QString.
Definition SyncResults.cpp:140
void addTargetResults(const TargetResults &aResults)
Adds target results to this object.
Definition SyncResults.cpp:167
SyncResults()
Constructs an empty sync results object.
Definition SyncResults.cpp:79
SyncResults & operator=(const SyncResults &aRhs)
Assignment operator.
Definition SyncResults.cpp:116
QDateTime syncTime() const
Gets the sync time.
Definition SyncResults.cpp:172
MinorCode
enum value
Definition SyncResults.h:93
QDomElement toXml(QDomDocument &aDoc) const
Exports the sync results to XML.
Definition SyncResults.cpp:125
~SyncResults()
Destructor.
Definition SyncResults.cpp:112
QList< TargetResults > targetResults() const
Gets the results of all targets.
Definition SyncResults.cpp:153
Sync results for one target.
Definition TargetResults.h:72
Definition SyncBackupAdaptor.h:40
int iLocalItemsModified
Definition SyncResults.h:41
int iRemoteItemsAdded
Definition SyncResults.h:44
int iRemoteItemsDeleted
Definition SyncResults.h:46
int iLocalItemsAdded
Definition SyncResults.h:40
int iLocalItemsDeleted
Definition SyncResults.h:42
int iRemoteItemsModified
Definition SyncResults.h:45