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
39
50
51};
52
53class SyncResultsPrivate;
54
62{
63 Q_GADGET
64 Q_PROPERTY(QDateTime syncTime READ syncTime CONSTANT)
65 Q_PROPERTY(MajorCode majorCode READ majorCode CONSTANT)
66 Q_PROPERTY(MinorCode minorCode READ minorCode CONSTANT)
67 Q_PROPERTY(bool scheduled READ isScheduled CONSTANT)
68 Q_PROPERTY(QString targetId READ getTargetId CONSTANT)
69 Q_PROPERTY(QVariantList results READ variantTargetResults CONSTANT)
70
71public:
72
77 enum MajorCode {
78 SYNC_RESULT_INVALID = -1,
79 SYNC_RESULT_SUCCESS = 0,
80 SYNC_RESULT_FAILED,
81 SYNC_RESULT_CANCELLED
82 };
83 Q_ENUM(MajorCode)
84
85
89 enum MinorCode {
90 // No error
91 NO_ERROR = 0,
92
93 // Sync completed but some unblocking issues appeared 3xx
94 ITEM_FAILURES = 301,
95
96 // Client/Configuration errors 4xx
97 INTERNAL_ERROR = 401,
98 AUTHENTICATION_FAILURE,
99 DATABASE_FAILURE,
100 PLUGIN_ERROR,
101 PLUGIN_TIMEOUT,
102
103 // Server/Network errors 5xx
104 ABORTED = 501,
105 CONNECTION_ERROR,
106 UNSUPPORTED_SYNC_TYPE,
107 UNSUPPORTED_STORAGE_TYPE,
108
109 // Context Error Code
110 LOW_BATTERY_POWER = 601,
111 POWER_SAVING_MODE,
112 OFFLINE_MODE,
113 BACKUP_IN_PROGRESS,
114 LOW_MEMORY
115 };
116 Q_ENUM(MinorCode)
117
118
123 SyncResults();
124
129 SyncResults(const SyncResults &aSource);
130
137 SyncResults(QDateTime aTime, MajorCode aMajorCode, MinorCode aMinorCode);
138
143 explicit SyncResults(const QDomElement &aRoot);
144
147 ~SyncResults();
148
153 SyncResults &operator=(const SyncResults &aRhs);
154
162 QDomElement toXml(QDomDocument &aDoc) const;
163
168 QString toString() const;
169
175
180 void addTargetResults(const TargetResults &aResults);
181
186 QDateTime syncTime() const;
187
192 MajorCode majorCode() const;
193
198 void setMajorCode(MajorCode aMajorCode);
199
204 MinorCode minorCode() const;
205
210 void setMinorCode(MinorCode aMinorCode);
211
212
217 void setTargetId(const QString &aTargetId);
218
221 QString getTargetId() const;
222
228 bool operator<(const SyncResults &aOther) const;
229
234 void setScheduled(bool aScheduled);
235
240 bool isScheduled() const;
241
242private:
243 QVariantList variantTargetResults() const;
244 QSharedPointer<SyncResultsPrivate> d_ptr;
245
246#ifdef SYNCFW_UNIT_TESTS
247 friend class ClientThreadTest;
248#endif
249};
250
251}
252
253Q_DECLARE_METATYPE(Buteo::SyncResults)
254
255#endif // SYNCRESULTS_H_2
Contains information about a completed synchronization session.
Definition: SyncResults.h:62
void setScheduled(bool aScheduled)
Sets if the results are from a scheduled sync.
Definition: SyncResults.cpp:219
QString getTargetId() const
Gets the remote target Id.
Definition: SyncResults.cpp:209
void setMajorCode(MajorCode aMajorCode)
Sets the result code.
Definition: SyncResults.cpp:187
MajorCode
enum value
Definition: SyncResults.h:77
void setTargetId(const QString &aTargetId)
Sets the remote target Id.
Definition: SyncResults.cpp:204
void setMinorCode(MinorCode aMinorCode)
Sets the failed Reason.
Definition: SyncResults.cpp:198
bool operator<(const SyncResults &aOther) const
Compares two results objects by sync time.
Definition: SyncResults.cpp:214
bool isScheduled() const
Checks if the results are from a scheduled sync.
Definition: SyncResults.cpp:224
QString toString() const
Exports the sync results to QString.
Definition: SyncResults.cpp:144
void addTargetResults(const TargetResults &aResults)
Adds target results to this object.
Definition: SyncResults.cpp:172
SyncResults()
Constructs an empty sync results object.
Definition: SyncResults.cpp:82
SyncResults & operator=(const SyncResults &aRhs)
Assignment operator.
Definition: SyncResults.cpp:119
MinorCode
enum value
Definition: SyncResults.h:89
QDomElement toXml(QDomDocument &aDoc) const
Exports the sync results to XML.
Definition: SyncResults.cpp:128
~SyncResults()
Destructor.
Definition: SyncResults.cpp:115
QList< TargetResults > targetResults() const
Gets the results of all targets.
Definition: SyncResults.cpp:158
Sync results for one target.
Definition: TargetResults.h:68
Definition: SyncBackupAdaptor.h:40
Definition: SyncResults.h:38
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