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>
|
2013-05-16 15:54:22 +04:00
|
|
|
#include <QMetaType>
|
2013-01-15 23:41:52 +04:00
|
|
|
|
|
|
|
#include <csync.h>
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
|
|
// FIXME: Unhack this.
|
|
|
|
class SyncFileItem {
|
|
|
|
public:
|
|
|
|
typedef enum {
|
2013-08-07 14:15:28 +04:00
|
|
|
None = 0,
|
|
|
|
Up,
|
|
|
|
Down } Direction;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
UnknownType,
|
|
|
|
File,
|
|
|
|
Directory,
|
|
|
|
SoftLink
|
|
|
|
} Type;
|
2013-01-15 23:41:52 +04:00
|
|
|
|
|
|
|
SyncFileItem() {}
|
|
|
|
|
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
|
|
|
// Delete at the end:
|
|
|
|
if (item1._instruction == CSYNC_INSTRUCTION_REMOVE && item2._instruction != CSYNC_INSTRUCTION_REMOVE)
|
|
|
|
return false;
|
|
|
|
if (item1._instruction != CSYNC_INSTRUCTION_REMOVE && item2._instruction == CSYNC_INSTRUCTION_REMOVE)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
return _instruction == CSYNC_INSTRUCTION_RENAME ? _renameTarget : _file;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-02-14 19:25:00 +04:00
|
|
|
bool isEmpty() const {
|
|
|
|
return _file.isEmpty();
|
|
|
|
}
|
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
// variables
|
|
|
|
QString _file;
|
|
|
|
QString _renameTarget;
|
2013-05-15 17:22:20 +04:00
|
|
|
QByteArray _originalFile; // as it is in the csync tree
|
2013-01-15 23:41:52 +04:00
|
|
|
csync_instructions_e _instruction;
|
|
|
|
Direction _dir;
|
2013-05-03 21:11:00 +04:00
|
|
|
bool _isDirectory;
|
|
|
|
time_t _modtime;
|
2013-05-06 18:59:11 +04:00
|
|
|
QByteArray _etag;
|
2013-08-14 21:59:16 +04:00
|
|
|
quint64 _size;
|
2013-05-05 13:41:31 +04:00
|
|
|
|
|
|
|
QString _errorString;
|
|
|
|
int _httpCode;
|
|
|
|
|
2013-08-07 14:15:28 +04:00
|
|
|
Type _type;
|
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
|