1 | /* |
2 | * Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org> |
3 | * |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, but |
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 | * for more details. |
13 | */ |
14 | |
15 | #ifndef MIRALL_SYNCRESULT_H |
16 | #define MIRALL_SYNCRESULT_H |
17 | |
18 | #include <QStringList> |
19 | #include <QHash> |
20 | #include <QDateTime> |
21 | |
22 | #include "owncloudlib.h" |
23 | #include "syncfileitem.h" |
24 | |
25 | namespace OCC { |
26 | |
27 | /** |
28 | * @brief The SyncResult class |
29 | * @ingroup libsync |
30 | */ |
31 | class OWNCLOUDSYNC_EXPORT SyncResult |
32 | { |
33 | public: |
34 | enum Status { |
35 | Undefined, |
36 | NotYetStarted, |
37 | SyncPrepare, |
38 | SyncRunning, |
39 | SyncAbortRequested, |
40 | Success, |
41 | Problem, |
42 | Error, |
43 | SetupError, |
44 | Paused |
45 | }; |
46 | |
47 | SyncResult(); |
48 | void reset(); |
49 | |
50 | void appendErrorString(const QString &); |
51 | QString errorString() const; |
52 | QStringList errorStrings() const; |
53 | void clearErrors(); |
54 | |
55 | void setStatus(Status); |
56 | Status status() const; |
57 | QString statusString() const; |
58 | QDateTime syncTime() const; |
59 | void setFolder(const QString &folder); |
60 | QString folder() const; |
61 | |
62 | bool foundFilesNotSynced() const { return _foundFilesNotSynced; } |
63 | bool folderStructureWasChanged() const { return _folderStructureWasChanged; } |
64 | |
65 | int numNewItems() const { return _numNewItems; } |
66 | int numRemovedItems() const { return _numRemovedItems; } |
67 | int numUpdatedItems() const { return _numUpdatedItems; } |
68 | int numRenamedItems() const { return _numRenamedItems; } |
69 | int numNewConflictItems() const { return _numNewConflictItems; } |
70 | int numOldConflictItems() const { return _numOldConflictItems; } |
71 | void setNumOldConflictItems(int n) { _numOldConflictItems = n; } |
72 | int numErrorItems() const { return _numErrorItems; } |
73 | bool hasUnresolvedConflicts() const { return _numNewConflictItems + _numOldConflictItems > 0; } |
74 | |
75 | const SyncFileItemPtr &firstItemNew() const { return _firstItemNew; } |
76 | const SyncFileItemPtr &firstItemDeleted() const { return _firstItemDeleted; } |
77 | const SyncFileItemPtr &firstItemUpdated() const { return _firstItemUpdated; } |
78 | const SyncFileItemPtr &firstItemRenamed() const { return _firstItemRenamed; } |
79 | const SyncFileItemPtr &firstNewConflictItem() const { return _firstNewConflictItem; } |
80 | const SyncFileItemPtr &firstItemError() const { return _firstItemError; } |
81 | |
82 | void processCompletedItem(const SyncFileItemPtr &item); |
83 | |
84 | private: |
85 | Status _status; |
86 | SyncFileItemVector _syncItems; |
87 | QDateTime _syncTime; |
88 | QString _folder; |
89 | /** |
90 | * when the sync tool support this... |
91 | */ |
92 | QStringList _errors; |
93 | bool _foundFilesNotSynced; |
94 | bool _folderStructureWasChanged; |
95 | |
96 | // count new, removed and updated items |
97 | int _numNewItems; |
98 | int _numRemovedItems; |
99 | int _numUpdatedItems; |
100 | int _numRenamedItems; |
101 | int _numNewConflictItems; |
102 | int _numOldConflictItems; |
103 | int _numErrorItems; |
104 | |
105 | SyncFileItemPtr _firstItemNew; |
106 | SyncFileItemPtr _firstItemDeleted; |
107 | SyncFileItemPtr _firstItemUpdated; |
108 | SyncFileItemPtr _firstItemRenamed; |
109 | SyncFileItemPtr _firstNewConflictItem; |
110 | SyncFileItemPtr _firstItemError; |
111 | }; |
112 | } |
113 | |
114 | #endif |
115 | |