2015-04-24 08:32:09 +08:00
|
|
|
#include "src/core/corestructs.h"
|
|
|
|
#include "src/core/core.h"
|
2014-11-06 22:12:10 +08:00
|
|
|
#include <tox/tox.h>
|
2014-09-11 21:44:34 +08:00
|
|
|
#include <QFile>
|
2014-11-06 22:12:10 +08:00
|
|
|
#include <QRegularExpression>
|
|
|
|
|
2015-04-20 05:12:44 +08:00
|
|
|
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
|
2014-09-11 21:44:34 +08:00
|
|
|
|
2015-04-20 05:12:44 +08:00
|
|
|
ToxFile::ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction)
|
2015-04-24 21:31:30 +08:00
|
|
|
: fileKind{TOX_FILE_KIND_DATA}, fileNum(FileNum), friendId(FriendId), fileName{FileName},
|
|
|
|
filePath{FilePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0},
|
2015-06-08 17:46:38 +08:00
|
|
|
status{STOPPED}, direction{Direction}
|
2014-09-11 21:44:34 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-11-17 23:05:14 +08:00
|
|
|
bool ToxFile::operator==(const ToxFile &other) const
|
|
|
|
{
|
2014-11-18 03:08:55 +08:00
|
|
|
return (fileNum == other.fileNum) && (friendId == other.friendId) && (direction == other.direction);
|
2014-11-17 23:05:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ToxFile::operator!=(const ToxFile &other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2014-09-11 21:44:34 +08:00
|
|
|
void ToxFile::setFilePath(QString path)
|
|
|
|
{
|
|
|
|
filePath=path;
|
|
|
|
file->setFileName(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ToxFile::open(bool write)
|
|
|
|
{
|
|
|
|
return write ? file->open(QIODevice::ReadWrite) : file->open(QIODevice::ReadOnly);
|
|
|
|
}
|