SyncResults.h
/*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef SYNCRESULTS_H_2
#define SYNCRESULTS_H_2
#include <QDateTime>
#include <QList>
#include <QSharedPointer>
#include <QObject>
#include <QVariantList>
#include "TargetResults.h"
class QDomDocument;
class QDomElement;
namespace Buteo {
struct DatabaseResults
{
int iLocalItemsAdded;
int iLocalItemsModified;
int iLocalItemsDeleted;
int iRemoteItemsAdded;
int iRemoteItemsModified;
int iRemoteItemsDeleted;
DatabaseResults()
: iLocalItemsAdded(0)
, iLocalItemsModified(0)
, iLocalItemsDeleted(0)
, iRemoteItemsAdded(0)
, iRemoteItemsModified(0)
, iRemoteItemsDeleted(0)
{}
};
class SyncResultsPrivate;
class SyncResults
{
Q_GADGET
Q_PROPERTY(QDateTime syncTime READ syncTime CONSTANT)
Q_PROPERTY(MajorCode majorCode READ majorCode CONSTANT)
Q_PROPERTY(MinorCode minorCode READ minorCode CONSTANT)
Q_PROPERTY(bool scheduled READ isScheduled CONSTANT)
Q_PROPERTY(QString targetId READ getTargetId CONSTANT)
Q_PROPERTY(QVariantList results READ variantTargetResults CONSTANT)
public:
enum MajorCode {
SYNC_RESULT_INVALID = -1,
SYNC_RESULT_SUCCESS = 0,
SYNC_RESULT_FAILED,
SYNC_RESULT_CANCELLED
};
Q_ENUM(MajorCode)
enum MinorCode {
// No error
NO_ERROR = 0,
// Sync completed but some unblocking issues appeared 3xx
ITEM_FAILURES = 301,
// Client/Configuration errors 4xx
INTERNAL_ERROR = 401,
AUTHENTICATION_FAILURE,
DATABASE_FAILURE,
PLUGIN_ERROR,
PLUGIN_TIMEOUT,
// Server/Network errors 5xx
ABORTED = 501,
CONNECTION_ERROR,
UNSUPPORTED_SYNC_TYPE,
UNSUPPORTED_STORAGE_TYPE,
// Context Error Code
LOW_BATTERY_POWER = 601,
POWER_SAVING_MODE,
OFFLINE_MODE,
BACKUP_IN_PROGRESS,
LOW_MEMORY
};
Q_ENUM(MinorCode)
SyncResults();
SyncResults(const SyncResults &aSource);
SyncResults(QDateTime aTime, MajorCode aMajorCode, MinorCode aMinorCode);
explicit SyncResults(const QDomElement &aRoot);
~SyncResults();
SyncResults &operator=(const SyncResults &aRhs);
QDomElement toXml(QDomDocument &aDoc) const;
QString toString() const;
QList<TargetResults> targetResults() const;
void addTargetResults(const TargetResults &aResults);
QDateTime syncTime() const;
MajorCode majorCode() const;
void setMajorCode(MajorCode aMajorCode);
MinorCode minorCode() const;
void setMinorCode(MinorCode aMinorCode);
void setTargetId(const QString &aTargetId);
QString getTargetId() const;
bool operator<(const SyncResults &aOther) const;
void setScheduled(bool aScheduled);
bool isScheduled() const;
private:
QVariantList variantTargetResults() const;
QSharedPointer<SyncResultsPrivate> d_ptr;
#ifdef SYNCFW_UNIT_TESTS
friend class ClientThreadTest;
#endif
};
}
Q_DECLARE_METATYPE(Buteo::SyncResults)
#endif // SYNCRESULTS_H_2
Buteo::SyncResults
Contains information about a completed synchronization session.
Definition SyncResults.h:67
Buteo::SyncResults::setScheduled
void setScheduled(bool aScheduled)
Sets if the results are from a scheduled sync.
Definition SyncResults.cpp:214
Buteo::SyncResults::getTargetId
QString getTargetId() const
Gets the remote target Id.
Definition SyncResults.cpp:204
Buteo::SyncResults::setMajorCode
void setMajorCode(MajorCode aMajorCode)
Sets the result code.
Definition SyncResults.cpp:182
Buteo::SyncResults::minorCode
MinorCode minorCode() const
Gets the failed reason.
Definition SyncResults.cpp:188
Buteo::SyncResults::MajorCode
MajorCode
enum value
Definition SyncResults.h:81
Buteo::SyncResults::setTargetId
void setTargetId(const QString &aTargetId)
Sets the remote target Id.
Definition SyncResults.cpp:199
Buteo::SyncResults::majorCode
MajorCode majorCode() const
Gets the result code.
Definition SyncResults.cpp:177
Buteo::SyncResults::setMinorCode
void setMinorCode(MinorCode aMinorCode)
Sets the failed Reason.
Definition SyncResults.cpp:193
Buteo::SyncResults::operator<
bool operator<(const SyncResults &aOther) const
Compares two results objects by sync time.
Definition SyncResults.cpp:209
Buteo::SyncResults::isScheduled
bool isScheduled() const
Checks if the results are from a scheduled sync.
Definition SyncResults.cpp:219
Buteo::SyncResults::toString
QString toString() const
Exports the sync results to QString.
Definition SyncResults.cpp:140
Buteo::SyncResults::addTargetResults
void addTargetResults(const TargetResults &aResults)
Adds target results to this object.
Definition SyncResults.cpp:167
Buteo::SyncResults::SyncResults
SyncResults()
Constructs an empty sync results object.
Definition SyncResults.cpp:79
Buteo::SyncResults::operator=
SyncResults & operator=(const SyncResults &aRhs)
Assignment operator.
Definition SyncResults.cpp:116
Buteo::SyncResults::syncTime
QDateTime syncTime() const
Gets the sync time.
Definition SyncResults.cpp:172
Buteo::SyncResults::MinorCode
MinorCode
enum value
Definition SyncResults.h:93
Buteo::SyncResults::toXml
QDomElement toXml(QDomDocument &aDoc) const
Exports the sync results to XML.
Definition SyncResults.cpp:125
Buteo::SyncResults::~SyncResults
~SyncResults()
Destructor.
Definition SyncResults.cpp:112
Buteo::SyncResults::targetResults
QList< TargetResults > targetResults() const
Gets the results of all targets.
Definition SyncResults.cpp:153
Buteo::TargetResults
Sync results for one target.
Definition TargetResults.h:72
QList
Definition SyncBackupAdaptor.h:40
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