1/*
2 * Copyright (C) by Klaas Freitag <freitag@owncloud.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#ifndef SYNCJOURNALFILERECORD_H
20#define SYNCJOURNALFILERECORD_H
21
22#include <QString>
23#include <QDateTime>
24
25#include "csync.h"
26#include "ocsynclib.h"
27#include "remotepermissions.h"
28#include "common/utility.h"
29
30namespace OCC {
31
32class SyncFileItem;
33
34/**
35 * @brief The SyncJournalFileRecord class
36 * @ingroup libsync
37 */
38class OCSYNC_EXPORT SyncJournalFileRecord
39{
40public:
41 SyncJournalFileRecord();
42
43 bool isValid() const
44 {
45 return !_path.isEmpty();
46 }
47
48 /** Returns the numeric part of the full id in _fileId.
49 *
50 * On the server this is sometimes known as the internal file id.
51 *
52 * It is used in the construction of private links.
53 */
54 QByteArray numericFileId() const;
55 QDateTime modDateTime() const { return Utility::qDateTimeFromTime_t(_modtime); }
56
57 QByteArray _path;
58 quint64 _inode;
59 qint64 _modtime;
60 ItemType _type;
61 QByteArray _etag;
62 QByteArray _fileId;
63 qint64 _fileSize;
64 RemotePermissions _remotePerm;
65 bool _serverHasIgnoredFiles;
66 QByteArray _checksumHeader;
67};
68
69bool OCSYNC_EXPORT
70operator==(const SyncJournalFileRecord &lhs,
71 const SyncJournalFileRecord &rhs);
72
73class OCSYNC_EXPORT SyncJournalErrorBlacklistRecord
74{
75public:
76 enum Category {
77 /// Normal errors have no special behavior
78 Normal = 0,
79 /// These get a special summary message
80 InsufficientRemoteStorage
81 };
82
83 SyncJournalErrorBlacklistRecord()
84 : _retryCount(0)
85 , _errorCategory(Category::Normal)
86 , _lastTryModtime(0)
87 , _lastTryTime(0)
88 , _ignoreDuration(0)
89 {
90 }
91
92 /// The number of times the operation was unsuccessful so far.
93 int _retryCount;
94
95 /// The last error string.
96 QString _errorString;
97 /// The error category. Sometimes used for special actions.
98 Category _errorCategory;
99
100 qint64 _lastTryModtime;
101 QByteArray _lastTryEtag;
102
103 /// The last time the operation was attempted (in s since epoch).
104 qint64 _lastTryTime;
105
106 /// The number of seconds the file shall be ignored.
107 qint64 _ignoreDuration;
108
109 QString _file;
110 QString _renameTarget;
111
112 /// The last X-Request-ID of the request that failled
113 QByteArray _requestId;
114
115 bool isValid() const;
116};
117
118/** Represents a conflict in the conflicts table.
119 *
120 * In the following the "conflict file" is the file that has the conflict
121 * tag in the filename, and the base file is the file that it's a conflict for.
122 * So if "a/foo.txt" is the base file, its conflict file could be
123 * "a/foo (conflicted copy 1234).txt".
124 */
125class OCSYNC_EXPORT ConflictRecord
126{
127public:
128 /** Path to the file with the conflict tag in the name
129 *
130 * The path is sync-folder relative.
131 */
132 QByteArray path;
133
134 /// File id of the base file
135 QByteArray baseFileId;
136
137 /** Modtime of the base file
138 *
139 * may not be available and be -1
140 */
141 qint64 baseModtime = -1;
142
143 /** Etag of the base file
144 *
145 * may not be available and empty
146 */
147 QByteArray baseEtag;
148
149 /**
150 * The path of the original file
151 *
152 * maybe be empty if not available
153 */
154 QByteArray basePath;
155
156
157 bool isValid() const { return !path.isEmpty(); }
158};
159}
160
161#endif // SYNCJOURNALFILERECORD_H
162