Progress: 25%.
This commit is contained in:
commit
2fd0d6d3d4
1 changed files with 917 additions and 0 deletions
69
torrentsession.h
Normal file
69
torrentsession.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
#ifndef TORRENTSESSION_H
|
||||
#define TORRENTSESSION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QLocalServer>
|
||||
#include <QLocalSocket>
|
||||
#include <QProcess>
|
||||
#include <filesystem>
|
||||
#include <QTimer>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
struct SearchItem;
|
||||
|
||||
class SocketManager: public QObject {
|
||||
Q_OBJECT
|
||||
QLocalServer *server = nullptr;
|
||||
QLocalSocket *socket = nullptr;
|
||||
public:
|
||||
SocketManager(QObject *parent = nullptr);
|
||||
signals:
|
||||
void status();
|
||||
void resume();
|
||||
void pause();
|
||||
void remove();
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void statusSignalFromTorrentSession(QByteArray data);
|
||||
|
||||
private slots:
|
||||
void addConnection();
|
||||
void commandFromClient();
|
||||
private:
|
||||
void sendSignalToTorrentSession(QString command);
|
||||
std::filesystem::path testDir(std::string dir_name, std::string file_format);
|
||||
std::string numToStr(int num);
|
||||
};
|
||||
|
||||
class TorrentSession : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
SearchItem *item = nullptr;
|
||||
std::filesystem::path download_path;
|
||||
enum class Status {
|
||||
Downloading,
|
||||
Paused,
|
||||
};
|
||||
SocketManager *manager = nullptr;
|
||||
QThread *socket_manager_thread = nullptr;
|
||||
QTimer start_timer;
|
||||
public:
|
||||
explicit TorrentSession(SearchItem it, std::filesystem::path download_path, QObject *parent = nullptr);
|
||||
int start();
|
||||
signals:
|
||||
void startSocketManager();
|
||||
void sendStatusSignalToSocketManager(QByteArray data);
|
||||
public slots:
|
||||
void sendStatus();
|
||||
void pause();
|
||||
void resume();
|
||||
void remove();
|
||||
private slots:
|
||||
void launchSession();
|
||||
signals:
|
||||
};
|
||||
|
||||
#endif // TORRENTSESSION_H
|
||||
Loading…
Reference in a new issue