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 <QSharedPointer>
29#include <QObject>
30#include <QVariantList>
31#include "TargetResults.h"
32
33class QDomDocument;
34class QDomElement;
35
36namespace Buteo {
37
38 struct DatabaseResults {
39
40 int iLocalItemsAdded;
41 int iLocalItemsModified;
42 int iLocalItemsDeleted;
44 int iRemoteItemsAdded;
45 int iRemoteItemsModified;
46 int iRemoteItemsDeleted;
48 DatabaseResults() : iLocalItemsAdded(0), iLocalItemsModified(0), iLocalItemsDeleted(0),
49 iRemoteItemsAdded(0), iRemoteItemsModified(0), iRemoteItemsDeleted(0) { }
50
51};
52
53class SyncResultsPrivate;
54
61 class SyncResults
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
174 QList<TargetResults> targetResults() const;
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
244 QVariantList variantTargetResults() const;
245
246 QSharedPointer<SyncResultsPrivate> d_ptr;
247
248#ifdef SYNCFW_UNIT_TESTS
249 friend class ClientThreadTest;
250#endif
251
252};
253
254}
255
256Q_DECLARE_METATYPE(Buteo::SyncResults)
257
258#endif // SYNCRESULTS_H_2
Buteo::SyncResults
Contains information about a completed synchronization session.
Definition: SyncResults.h:62
Buteo::SyncResults::setScheduled
void setScheduled(bool aScheduled)
Sets if the results are from a scheduled sync.
Definition: SyncResults.cpp:219
Buteo::SyncResults::getTargetId
QString getTargetId() const
Gets the remote target Id.
Definition: SyncResults.cpp:209
Buteo::SyncResults::setMajorCode
void setMajorCode(MajorCode aMajorCode)
Sets the result code.
Definition: SyncResults.cpp:187
Buteo::SyncResults::MajorCode
MajorCode
enum value
Definition: SyncResults.h:77
Buteo::SyncResults::setTargetId
void setTargetId(const QString &aTargetId)
Sets the remote target Id.
Definition: SyncResults.cpp:204
Buteo::SyncResults::setMinorCode
void setMinorCode(MinorCode aMinorCode)
Sets the failed Reason.
Definition: SyncResults.cpp:198
Buteo::SyncResults::operator<
bool operator<(const SyncResults &aOther) const
Compares two results objects by sync time.
Definition: SyncResults.cpp:214
Buteo::SyncResults::isScheduled
bool isScheduled() const
Checks if the results are from a scheduled sync.
Definition: SyncResults.cpp:224
Buteo::SyncResults::toString
QString toString() const
Exports the sync results to QString.
Definition: SyncResults.cpp:144
Buteo::SyncResults::addTargetResults
void addTargetResults(const TargetResults &aResults)
Adds target results to this object.
Definition: SyncResults.cpp:172
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:119
Buteo::SyncResults::MinorCode
MinorCode
enum value
Definition: SyncResults.h:89
Buteo::SyncResults::toXml
QDomElement toXml(QDomDocument &aDoc) const
Exports the sync results to XML.
Definition: SyncResults.cpp:128
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:158
Buteo::TargetResults
Sync results for one target.
Definition: TargetResults.h:68
QList
Definition: SyncBackupAdaptor.h:40
Buteo::DatabaseResults
Definition: SyncResults.h:38
Buteo::DatabaseResults::iLocalItemsModified
int iLocalItemsModified
Definition: SyncResults.h:41
Buteo::DatabaseResults::iRemoteItemsAdded
int iRemoteItemsAdded
Definition: SyncResults.h:44
Buteo::DatabaseResults::iRemoteItemsDeleted
int iRemoteItemsDeleted
Definition: SyncResults.h:46
Buteo::DatabaseResults::iLocalItemsAdded
int iLocalItemsAdded
Definition: SyncResults.h:40
Buteo::DatabaseResults::iLocalItemsDeleted
int iLocalItemsDeleted
Definition: SyncResults.h:42
Buteo::DatabaseResults::iRemoteItemsModified
int iRemoteItemsModified
Definition: SyncResults.h:45