mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-20 09:41:19 -05:00
More work on assets (not compiling)
This commit is contained in:
@@ -111,15 +111,29 @@ std::string TorrentSynchronization::directory() {
|
||||
}
|
||||
|
||||
void TorrentSynchronization::start() {
|
||||
size_t torrentId = _torrentClient->addMagnetLink(_magnetLink, directory());
|
||||
resolve();
|
||||
return;
|
||||
if (_enabled) {
|
||||
return;
|
||||
}
|
||||
_enabled = true;
|
||||
_torrentId = _torrentClient->addMagnetLink(
|
||||
_magnetLink,
|
||||
directory(),
|
||||
[this](TorrentClient::Progress p) {
|
||||
updateTorrentProgress(p);
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
void TorrentSynchronization::cancel() {
|
||||
if (_enabled) {
|
||||
_torrentClient->removeTorrent(_torrentId);
|
||||
_enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
void TorrentSynchronization::clear() {
|
||||
// Todo: remove directory!
|
||||
}
|
||||
|
||||
|
||||
@@ -135,4 +149,8 @@ bool TorrentSynchronization::nTotalBytesIsKnown() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void TorrentSynchronization::updateTorrentProgress(TorrentClient::Progress p) {
|
||||
// TODO: implement this
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef __OPENSPACE_MODULE_SYNC___TORRENTSYNCHRONIZATION___H__
|
||||
#define __OPENSPACE_MODULE_SYNC___TORRENTSYNCHRONIZATION___H__
|
||||
|
||||
#include <modules/sync/torrentclient.h>
|
||||
|
||||
#include <openspace/util/resourcesynchronization.h>
|
||||
#include <openspace/documentation/documentation.h>
|
||||
|
||||
@@ -54,6 +56,10 @@ public:
|
||||
bool nTotalBytesIsKnown() override;
|
||||
|
||||
private:
|
||||
void updateTorrentProgress(TorrentClient::Progress p);
|
||||
|
||||
std::atomic_bool _enabled = false;
|
||||
size_t _torrentId;
|
||||
std::string uniformResourceName() const;
|
||||
std::string _identifier;
|
||||
std::string _magnetLink;
|
||||
|
||||
@@ -101,7 +101,7 @@ void TorrentClient::pollAlerts() {
|
||||
}
|
||||
}
|
||||
|
||||
size_t TorrentClient::addTorrentFile(std::string torrentFile, std::string destination) {
|
||||
size_t TorrentClient::addTorrentFile(std::string torrentFile, std::string destination, TorrentProgressCallback cb) {
|
||||
if (!_session) {
|
||||
LERROR("Torrent session not initialized when adding torrent");
|
||||
return -1;
|
||||
@@ -122,7 +122,8 @@ size_t TorrentClient::addTorrentFile(std::string torrentFile, std::string destin
|
||||
return id;
|
||||
}
|
||||
|
||||
size_t TorrentClient::addMagnetLink(std::string magnetLink, std::string destination) {
|
||||
size_t TorrentClient::addMagnetLink(std::string magnetLink, std::string destination, TorrentProgressCallback cb) {
|
||||
// TODO: register callback!
|
||||
if (!_session) {
|
||||
LERROR("Torrent session not initialized when adding torrent");
|
||||
return -1;
|
||||
|
||||
@@ -48,11 +48,17 @@ public:
|
||||
libtorrent::torrent_handle handle;
|
||||
};
|
||||
|
||||
struct Progress {
|
||||
|
||||
};
|
||||
|
||||
using TorrentProgressCallback = std::function<void(Progress)>;
|
||||
|
||||
TorrentClient();
|
||||
~TorrentClient();
|
||||
void initialize();
|
||||
size_t addTorrentFile(std::string torrentFile, std::string destination);
|
||||
size_t addMagnetLink(std::string magnetLink, std::string destination);
|
||||
size_t addTorrentFile(std::string torrentFile, std::string destination, TorrentProgressCallback cb);
|
||||
size_t addMagnetLink(std::string magnetLink, std::string destination, TorrentProgressCallback cb);
|
||||
void removeTorrent(size_t id);
|
||||
void pollAlerts();
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user