2
* This file is part of buteo-syncfw package
4
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
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.
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.
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
25
#include "SyncResults.h"
26
#include "LogMacros.h"
27
#include <QDomDocument>
29
#include "ProfileEngineDefs.h"
34
// Private implementation class for SyncResults.
35
class SyncResultsPrivate
40
SyncResultsPrivate(const SyncResultsPrivate &aSource);
42
// List of target results.
43
QList<TargetResults> iTargetResults;
59
using namespace Buteo;
61
SyncResultsPrivate::SyncResultsPrivate()
62
: iTime(QDateTime::currentDateTime()),
68
SyncResultsPrivate::SyncResultsPrivate(const SyncResultsPrivate &aSource)
69
: iTargetResults(aSource.iTargetResults),
71
iResultCode(aSource.iResultCode),
72
iScheduled(aSource.iScheduled),
73
iTargetId(aSource.iTargetId)
77
SyncResults::SyncResults()
78
: d_ptr(new SyncResultsPrivate())
82
SyncResults::SyncResults(const SyncResults &aSource)
83
: d_ptr(new SyncResultsPrivate(*aSource.d_ptr))
87
SyncResults::SyncResults(QDateTime aTime, int aResultCode)
88
: d_ptr(new SyncResultsPrivate())
91
d_ptr->iResultCode = aResultCode;
94
SyncResults::SyncResults(const QDomElement &aRoot)
95
: d_ptr(new SyncResultsPrivate())
97
d_ptr->iTime = QDateTime::fromString(aRoot.attribute(ATTR_TIME), Qt::ISODate);
98
d_ptr->iResultCode = aRoot.attribute(ATTR_RESULT_CODE).toInt();
99
d_ptr->iScheduled = (aRoot.attribute(KEY_SYNC_SCHEDULED) == BOOLEAN_TRUE);
101
QDomElement target = aRoot.firstChildElement(TAG_TARGET_RESULTS);
102
for (; !target.isNull();
103
target = target.nextSiblingElement(TAG_TARGET_RESULTS))
105
d_ptr->iTargetResults.append(TargetResults(target));
109
SyncResults::~SyncResults()
115
SyncResults& SyncResults::operator=(const SyncResults &aRhs)
120
d_ptr = new SyncResultsPrivate(*aRhs.d_ptr);
126
QDomElement SyncResults::toXml(QDomDocument &aDoc) const
128
QDomElement root = aDoc.createElement(TAG_SYNC_RESULTS);
129
root.setAttribute(ATTR_TIME, d_ptr->iTime.toString(Qt::ISODate));
130
root.setAttribute(ATTR_RESULT_CODE, QString::number(d_ptr->iResultCode));
131
root.setAttribute(KEY_SYNC_SCHEDULED, d_ptr->iScheduled ? BOOLEAN_TRUE :
134
foreach (TargetResults tr, d_ptr->iTargetResults)
136
root.appendChild(tr.toXml(aDoc));
142
QList<TargetResults> SyncResults::targetResults() const
144
return d_ptr->iTargetResults;
147
void SyncResults::addTargetResults(const TargetResults &aResults)
149
d_ptr->iTargetResults.append(aResults);
152
QDateTime SyncResults::syncTime() const
157
int SyncResults::resultCode() const
159
return d_ptr->iResultCode;
162
void SyncResults::setResultCode(int aResultCode)
165
d_ptr->iResultCode = aResultCode;
168
void SyncResults::setTargetId(const QString& aTargetId)
170
d_ptr->iTargetId = aTargetId;
173
QString SyncResults::getTargetId() const
175
return d_ptr->iTargetId;
178
bool SyncResults::operator<(const SyncResults &aOther) const
180
return (d_ptr->iTime < aOther.d_ptr->iTime);
183
void SyncResults::setScheduled(bool aScheduled)
185
d_ptr->iScheduled = aScheduled;
188
bool SyncResults::isScheduled() const
190
return d_ptr->iScheduled;