qTox  Version: nightly | Commit: bc751c8e1cac455f9690654fcfe0f560d2d7dfdd
toxfile.h
Go to the documentation of this file.
1 /*
2  Copyright © 2019 by The qTox Project Contributors
3 
4  This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6  qTox is libre software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  qTox is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with qTox. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "src/core/toxfilepause.h"
24 
25 #include <QString>
26 #include <memory>
27 #include <QCryptographicHash>
28 
29 class QFile;
30 class QTimer;
31 
32 struct ToxFile
33 {
34  // Note do not change values, these are directly inserted into the DB in their
35  // current form, changing order would mess up database state!
37  {
39  PAUSED = 1,
41  BROKEN = 3,
42  CANCELED = 4,
43  FINISHED = 5,
44  };
45 
46  // Note do not change values, these are directly inserted into the DB in their
47  // current form (can add fields though as db representation is an int)
48  enum FileDirection : bool
49  {
50  SENDING = 0,
51  RECEIVING = 1,
52  };
53 
54  ToxFile();
55  ToxFile(uint32_t FileNum, uint32_t FriendId, QString FileName, QString filePath,
56  uint64_t filesize, FileDirection Direction);
57 
58  bool operator==(const ToxFile& other) const;
59  bool operator!=(const ToxFile& other) const;
60 
61  void setFilePath(QString path);
62  bool open(bool write);
63 
64  uint8_t fileKind;
65  uint32_t fileNum;
66  uint32_t friendId;
67  QString fileName;
68  QString filePath;
69  std::shared_ptr<QFile> file;
72  QByteArray avatarData;
73  QByteArray resumeFileId;
74  std::shared_ptr<QCryptographicHash> hashGenerator = std::make_shared<QCryptographicHash>(QCryptographicHash::Sha256);
77 };
ToxFile::operator==
bool operator==(const ToxFile &other) const
Definition: toxfile.cpp:62
toxfilepause.h
ToxFile::BROKEN
@ BROKEN
Definition: toxfile.h:41
ToxFile::file
std::shared_ptr< QFile > file
Definition: toxfile.h:69
ToxFile::fileName
QString fileName
Definition: toxfile.h:67
ToxFile::avatarData
QByteArray avatarData
Definition: toxfile.h:72
ToxFile::fileNum
uint32_t fileNum
Definition: toxfile.h:65
ToxFile::TRANSMITTING
@ TRANSMITTING
Definition: toxfile.h:40
ToxFile::pauseStatus
ToxFilePause pauseStatus
Definition: toxfile.h:75
ToxFile::FileStatus
FileStatus
Definition: toxfile.h:36
toxfileprogress.h
ToxFile::progress
ToxFileProgress progress
Definition: toxfile.h:76
ToxFile::direction
FileDirection direction
Definition: toxfile.h:71
ToxFile::RECEIVING
@ RECEIVING
Definition: toxfile.h:51
ToxFile::hashGenerator
std::shared_ptr< QCryptographicHash > hashGenerator
Definition: toxfile.h:74
ToxFile::FileDirection
FileDirection
Definition: toxfile.h:48
ToxFile::INITIALIZING
@ INITIALIZING
Definition: toxfile.h:38
ToxFile::PAUSED
@ PAUSED
Definition: toxfile.h:39
ToxFile::CANCELED
@ CANCELED
Definition: toxfile.h:42
ToxFile::status
FileStatus status
Definition: toxfile.h:70
ToxFileProgress
Definition: toxfileprogress.h:26
ToxFile::FINISHED
@ FINISHED
Definition: toxfile.h:43
ToxFile::SENDING
@ SENDING
Definition: toxfile.h:50
ToxFilePause
Definition: toxfilepause.h:22
ToxFile::fileKind
uint8_t fileKind
Data file (default) or avatar.
Definition: toxfile.h:64
ToxFile::setFilePath
void setFilePath(QString path)
Definition: toxfile.cpp:73
ToxFile::friendId
uint32_t friendId
Definition: toxfile.h:66
ToxFile
Definition: toxfile.h:32
ToxFile::operator!=
bool operator!=(const ToxFile &other) const
Definition: toxfile.cpp:68
ToxFile::filePath
QString filePath
Definition: toxfile.h:68
ToxFile::resumeFileId
QByteArray resumeFileId
Definition: toxfile.h:73
ToxFile::ToxFile
ToxFile()
Definition: toxfile.cpp:37
ToxFile::open
bool open(bool write)
Definition: toxfile.cpp:79