2013-09-16 00:49:24 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
#ifndef SYNCFILEITEM_H
|
|
|
|
#define SYNCFILEITEM_H
|
|
|
|
|
|
|
|
#include <QVector>
|
2013-05-03 21:11:00 +04:00
|
|
|
#include <QString>
|
2014-03-26 21:02:25 +04:00
|
|
|
#include <QDateTime>
|
2013-05-16 15:54:22 +04:00
|
|
|
#include <QMetaType>
|
2013-01-15 23:41:52 +04:00
|
|
|
|
|
|
|
#include <csync.h>
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
class SyncFileItem {
|
|
|
|
public:
|
2013-10-04 17:13:36 +04:00
|
|
|
enum Direction {
|
2013-08-07 14:15:28 +04:00
|
|
|
None = 0,
|
|
|
|
Up,
|
2013-10-04 17:13:36 +04:00
|
|
|
Down };
|
2013-08-07 14:15:28 +04:00
|
|
|
|
2013-10-04 17:13:36 +04:00
|
|
|
enum Type {
|
2013-12-06 17:11:51 +04:00
|
|
|
UnknownType = 0,
|
|
|
|
File = CSYNC_FTW_TYPE_FILE,
|
2013-10-03 22:00:58 +04:00
|
|
|
Directory = CSYNC_FTW_TYPE_DIR,
|
2013-12-06 17:11:51 +04:00
|
|
|
SoftLink = CSYNC_FTW_TYPE_SLINK
|
2013-10-04 17:13:36 +04:00
|
|
|
};
|
2013-01-15 23:41:52 +04:00
|
|
|
|
2013-10-04 17:13:36 +04:00
|
|
|
enum Status {
|
|
|
|
NoStatus,
|
|
|
|
|
|
|
|
FatalError, ///< Error that causes the sync to stop
|
|
|
|
NormalError, ///< Error attached to a particular file
|
|
|
|
SoftError, ///< More like an information
|
|
|
|
|
|
|
|
Success, ///< The file was properly synced
|
|
|
|
Conflict, ///< The file was properly synced, but a conflict was created
|
2014-10-08 11:07:05 +04:00
|
|
|
FileIgnored, ///< The file is in the ignored list (or blacklisted with no retries left)
|
2014-06-23 15:56:17 +04:00
|
|
|
Restoration ///< The file was restored because what should have been done was not allowed
|
2013-10-04 17:13:36 +04:00
|
|
|
};
|
|
|
|
|
2014-06-20 14:54:46 +04:00
|
|
|
SyncFileItem() : _type(UnknownType), _direction(None), _isDirectory(false),
|
|
|
|
_instruction(CSYNC_INSTRUCTION_NONE), _modtime(0),
|
2014-10-08 11:36:47 +04:00
|
|
|
_size(0), _inode(0), _should_update_etag(false), _hasBlacklistEntry(false),
|
2014-06-07 13:49:46 +04:00
|
|
|
_status(NoStatus), _httpErrorCode(0), _requestDuration(0), _isRestoration(false) {}
|
2013-01-15 23:41:52 +04:00
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
friend bool operator==(const SyncFileItem& item1, const SyncFileItem& item2) {
|
|
|
|
return item1._file == item2._file;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend bool operator<(const SyncFileItem& item1, const SyncFileItem& item2) {
|
2013-05-15 17:22:20 +04:00
|
|
|
// Sort by destination
|
|
|
|
return item1.destination() < item2.destination();
|
2013-01-15 23:41:52 +04:00
|
|
|
}
|
|
|
|
|
2013-05-15 17:22:20 +04:00
|
|
|
QString destination() const {
|
2014-09-05 12:06:19 +04:00
|
|
|
if (!_renameTarget.isEmpty()) {
|
|
|
|
return _renameTarget;
|
|
|
|
}
|
|
|
|
return _file;
|
2013-05-15 17:22:20 +04:00
|
|
|
}
|
|
|
|
|
2013-02-14 19:25:00 +04:00
|
|
|
bool isEmpty() const {
|
|
|
|
return _file.isEmpty();
|
|
|
|
}
|
|
|
|
|
2014-10-13 19:23:42 +04:00
|
|
|
bool hasErrorStatus() const {
|
|
|
|
return _status == SyncFileItem::SoftError
|
|
|
|
|| _status == SyncFileItem::NormalError
|
|
|
|
|| _status == SyncFileItem::FatalError
|
|
|
|
|| !_errorString.isEmpty();
|
|
|
|
}
|
|
|
|
|
2013-10-04 17:13:36 +04:00
|
|
|
// Variables usefull for everybody
|
2013-01-15 23:41:52 +04:00
|
|
|
QString _file;
|
|
|
|
QString _renameTarget;
|
2013-10-04 17:13:36 +04:00
|
|
|
Type _type;
|
2014-03-20 17:56:31 +04:00
|
|
|
Direction _direction;
|
2013-05-03 21:11:00 +04:00
|
|
|
bool _isDirectory;
|
2013-10-04 17:13:36 +04:00
|
|
|
|
|
|
|
// Variables used by the propagator
|
2013-11-05 20:48:51 +04:00
|
|
|
QString _originalFile; // as it is in the csync tree
|
2013-10-04 17:13:36 +04:00
|
|
|
csync_instructions_e _instruction;
|
2013-10-25 15:28:48 +04:00
|
|
|
time_t _modtime;
|
|
|
|
QByteArray _etag;
|
|
|
|
quint64 _size;
|
2014-05-06 14:55:54 +04:00
|
|
|
quint64 _inode;
|
2013-11-15 16:53:18 +04:00
|
|
|
bool _should_update_etag;
|
2014-03-24 15:21:44 +04:00
|
|
|
QByteArray _fileId;
|
2014-06-06 17:24:17 +04:00
|
|
|
QByteArray _remotePerm;
|
2014-06-03 13:50:13 +04:00
|
|
|
QString _directDownloadUrl;
|
|
|
|
QString _directDownloadCookies;
|
2014-10-08 11:07:05 +04:00
|
|
|
|
|
|
|
/// Whether there's an entry in the blacklist table.
|
|
|
|
/// Note: that entry may have retries left, so this can be true
|
|
|
|
/// without the status being FileIgnored.
|
|
|
|
bool _hasBlacklistEntry;
|
2013-05-05 13:41:31 +04:00
|
|
|
|
2013-10-04 17:13:36 +04:00
|
|
|
// Variables usefull to report to the user
|
2014-03-26 21:02:25 +04:00
|
|
|
Status _status;
|
|
|
|
QString _errorString; // Contains a string only in case of error
|
|
|
|
int _httpErrorCode;
|
|
|
|
QString _responseTimeStamp;
|
|
|
|
quint64 _requestDuration;
|
2014-06-07 13:49:46 +04:00
|
|
|
bool _isRestoration; // The original operation was forbidden, and this is a restoration
|
2014-03-26 21:02:25 +04:00
|
|
|
|
|
|
|
struct {
|
|
|
|
quint64 _size;
|
|
|
|
time_t _modtime;
|
|
|
|
QByteArray _etag;
|
|
|
|
QByteArray _fileId;
|
|
|
|
enum csync_instructions_e _instruction;
|
2014-04-03 18:56:36 +04:00
|
|
|
quint64 _other_size;
|
|
|
|
time_t _other_modtime;
|
|
|
|
QByteArray _other_etag;
|
|
|
|
QByteArray _other_fileId;
|
2014-06-06 17:24:17 +04:00
|
|
|
QByteArray _other_remotePerm;
|
2014-04-03 18:56:36 +04:00
|
|
|
enum csync_instructions_e _other_instruction;
|
|
|
|
} log;
|
2013-01-15 23:41:52 +04:00
|
|
|
};
|
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
typedef QVector<SyncFileItem> SyncFileItemVector;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-08-14 17:36:34 +04:00
|
|
|
Q_DECLARE_METATYPE(Mirall::SyncFileItem)
|
2013-05-16 15:54:22 +04:00
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
#endif // SYNCFILEITEM_H
|