Buteo Synchronization Framework
TargetResults.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 TARGETRESULTS_H
24#define TARGETRESULTS_H
25
26#include <QString>
27#include <QList>
28#include <QObject>
29
30class QDomDocument;
31class QDomElement;
32
33namespace Buteo {
34
35class TargetResultsPrivate;
36
38struct ItemCounts {
39 Q_GADGET
40 Q_PROPERTY(unsigned added MEMBER added)
41 Q_PROPERTY(unsigned deleted MEMBER deleted)
42 Q_PROPERTY(unsigned modified MEMBER modified)
43
44public:
46 unsigned added;
47
49 unsigned deleted;
50
52 unsigned modified;
53
55 ItemCounts() : added(0), deleted(0), modified(0) { };
56
58 ItemCounts(unsigned aAdded, unsigned aDeleted, unsigned aModified)
59 : added(aAdded), deleted(aDeleted), modified(aModified) {}
60};
61
68{
69 Q_GADGET
70 Q_PROPERTY(QString target READ targetName)
71 Q_PROPERTY(Buteo::ItemCounts local READ localItems)
72 Q_PROPERTY(Buteo::ItemCounts remote READ remoteItems)
73 Q_PROPERTY(QStringList localAdditions READ localAdditions)
74 Q_PROPERTY(QStringList localDeletions READ localDeletions)
75 Q_PROPERTY(QStringList localModifications READ localModifications)
76 Q_PROPERTY(QStringList localFailures READ localFailures)
77 Q_PROPERTY(QStringList remoteAdditions READ remoteAdditions)
78 Q_PROPERTY(QStringList remoteDeletions READ remoteDeletions)
79 Q_PROPERTY(QStringList remoteModifications READ remoteModifications)
80 Q_PROPERTY(QStringList remoteFailures READ remoteFailures)
81
82public:
83 enum ItemOperation {
84 ITEM_ADDED,
85 ITEM_DELETED,
86 ITEM_MODIFIED
87 };
88
89 enum ItemOperationStatus {
90 ITEM_OPERATION_SUCCEEDED,
91 ITEM_OPERATION_FAILED
92 };
93
95
100 TargetResults(const TargetResults &aSource);
101
108 TargetResults(const QString &aTargetName, ItemCounts aLocalItems = ItemCounts(),
109 ItemCounts aRemoteItems = ItemCounts());
110
115 explicit TargetResults(const QDomElement &aRoot);
116
120
126
134 QDomElement toXml(QDomDocument &aDoc) const;
135
140 QString targetName() const;
141
146 ItemCounts localItems() const;
147
152 ItemCounts remoteItems() const;
153
166 void addLocalDetails(const QString &aUid,
167 ItemOperation aOperation,
168 ItemOperationStatus aStatus = ITEM_OPERATION_SUCCEEDED,
169 const QString &aMessage = QString());
170
183 void addRemoteDetails(const QString &aUid,
184 ItemOperation aOperation,
185 ItemOperationStatus aStatus = ITEM_OPERATION_SUCCEEDED,
186 const QString &aMessage = QString());
187
197 QList<QString> localDetails(ItemOperation aOperation,
198 ItemOperationStatus aStatus) const;
199
205 Q_INVOKABLE QString localMessage(const QString &aUid) const;
206
216 QList<QString> remoteDetails(ItemOperation aOperation,
217 ItemOperationStatus aStatus) const;
218
224 Q_INVOKABLE QString remoteMessage(const QString &aUid) const;
225
226private:
227
228 QStringList localAdditions() const { return localDetails(ITEM_ADDED, ITEM_OPERATION_SUCCEEDED); }
229 QStringList localDeletions() const { return localDetails(ITEM_DELETED, ITEM_OPERATION_SUCCEEDED); }
230 QStringList localModifications() const { return localDetails(ITEM_MODIFIED, ITEM_OPERATION_SUCCEEDED); }
231 QStringList localFailures() const { return localDetails(ITEM_ADDED, ITEM_OPERATION_FAILED) + localDetails(ITEM_MODIFIED, ITEM_OPERATION_FAILED) + localDetails(ITEM_DELETED, ITEM_OPERATION_FAILED); }
232
233 QStringList remoteAdditions() const { return remoteDetails(ITEM_ADDED, ITEM_OPERATION_SUCCEEDED); }
234 QStringList remoteDeletions() const { return remoteDetails(ITEM_DELETED, ITEM_OPERATION_SUCCEEDED); }
235 QStringList remoteModifications() const { return remoteDetails(ITEM_MODIFIED, ITEM_OPERATION_SUCCEEDED); }
236 QStringList remoteFailures() const { return remoteDetails(ITEM_ADDED, ITEM_OPERATION_FAILED) + remoteDetails(ITEM_MODIFIED, ITEM_OPERATION_FAILED) + remoteDetails(ITEM_DELETED, ITEM_OPERATION_FAILED); }
237
238 TargetResultsPrivate *d_ptr;
239};
240
241}
242
243Q_DECLARE_METATYPE(Buteo::ItemCounts)
244Q_DECLARE_METATYPE(Buteo::TargetResults)
245
246#endif // TARGETRESULTS_H
Sync results for one target.
Definition TargetResults.h:68
TargetResults & operator=(const TargetResults &aRhs)
Assignment operator.
Definition TargetResults.cpp:193
ItemCounts remoteItems() const
Gets the counts of items added, deleted and modified at remote.
Definition TargetResults.cpp:251
void addRemoteDetails(const QString &aUid, ItemOperation aOperation, ItemOperationStatus aStatus=ITEM_OPERATION_SUCCEEDED, const QString &aMessage=QString())
Add some details on the remote changes done during the sync process.
Definition TargetResults.cpp:284
~TargetResults()
Destructor.
Definition TargetResults.cpp:187
QList< QString > localDetails(ItemOperation aOperation, ItemOperationStatus aStatus) const
Gets the details, if any for changes done local during a sync process.
Definition TargetResults.cpp:312
QDomElement toXml(QDomDocument &aDoc) const
Exports the target results to XML.
Definition TargetResults.cpp:203
void addLocalDetails(const QString &aUid, ItemOperation aOperation, ItemOperationStatus aStatus=ITEM_OPERATION_SUCCEEDED, const QString &aMessage=QString())
Add some details on the local changes done during the sync process.
Definition TargetResults.cpp:256
Q_INVOKABLE QString localMessage(const QString &aUid) const
Gets a possible message related to the a given item.
Definition TargetResults.cpp:327
QString targetName() const
Gets the target name.
Definition TargetResults.cpp:241
QList< QString > remoteDetails(ItemOperation aOperation, ItemOperationStatus aStatus) const
Gets the details, if any for changes done remote during a sync process.
Definition TargetResults.cpp:340
Q_INVOKABLE QString remoteMessage(const QString &aUid) const
Gets a possible message related to the a given item.
Definition TargetResults.cpp:354
ItemCounts localItems() const
Gets the counts of items added, deleted and modified locally.
Definition TargetResults.cpp:246
Definition SyncBackupAdaptor.h:40
Container for number of items added, deleted and modified.
Definition TargetResults.h:38
unsigned modified
No. of Items modified.
Definition TargetResults.h:42
ItemCounts(unsigned aAdded, unsigned aDeleted, unsigned aModified)
Constructor with 3 parameters.
Definition TargetResults.h:58
unsigned added
No. of Items added.
Definition TargetResults.h:40
unsigned deleted
No. of Items deleted.
Definition TargetResults.h:41