|
|
@ -53,149 +53,157 @@ class HttpServer; |
|
|
|
class bittorrent : public QObject { |
|
|
|
class bittorrent : public QObject { |
|
|
|
Q_OBJECT |
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
session *s; |
|
|
|
// Bittorrent
|
|
|
|
QPointer<FileSystemWatcher> FSWatcher; |
|
|
|
session *s; |
|
|
|
QPointer<QTimer> timerAlerts; |
|
|
|
QPointer<QTimer> timerAlerts; |
|
|
|
QPointer<QTimer> BigRatioTimer; |
|
|
|
QHash<QString, QString> savepath_fromurl; |
|
|
|
bool DHTEnabled; |
|
|
|
QHash<QString, QHash<QString, QString> > trackersErrors; |
|
|
|
QPointer<downloadThread> downloader; |
|
|
|
// Ratio
|
|
|
|
QString defaultSavePath; |
|
|
|
QPointer<QTimer> BigRatioTimer; |
|
|
|
QString defaultTempPath; |
|
|
|
// HTTP
|
|
|
|
QHash<QString, QHash<QString, QString> > trackersErrors; |
|
|
|
QPointer<downloadThread> downloader; |
|
|
|
QStringList consoleMessages; |
|
|
|
// File System
|
|
|
|
QStringList peerBanMessages; |
|
|
|
QPointer<FileSystemWatcher> FSWatcher; |
|
|
|
bool preAllocateAll; |
|
|
|
// Console / Log
|
|
|
|
bool addInPause; |
|
|
|
QStringList consoleMessages; |
|
|
|
float ratio_limit; |
|
|
|
QStringList peerBanMessages; |
|
|
|
bool UPnPEnabled; |
|
|
|
// Settings
|
|
|
|
bool NATPMPEnabled; |
|
|
|
bool preAllocateAll; |
|
|
|
bool LSDEnabled; |
|
|
|
bool addInPause; |
|
|
|
QPointer<FilterParserThread> filterParser; |
|
|
|
float ratio_limit; |
|
|
|
QString filterPath; |
|
|
|
bool UPnPEnabled; |
|
|
|
bool queueingEnabled; |
|
|
|
bool NATPMPEnabled; |
|
|
|
QStringList url_skippingDlg; |
|
|
|
bool LSDEnabled; |
|
|
|
QHash<QString, QString> savepath_fromurl; |
|
|
|
bool DHTEnabled; |
|
|
|
bool resolve_countries; |
|
|
|
bool queueingEnabled; |
|
|
|
bool geoipDBLoaded; |
|
|
|
QString defaultSavePath; |
|
|
|
QPointer<QTimer> timerETA; |
|
|
|
QString defaultTempPath; |
|
|
|
QHash<QString, QList<int> > ETA_samples; |
|
|
|
// GeoIP
|
|
|
|
// Web UI
|
|
|
|
bool resolve_countries; |
|
|
|
QPointer<HttpServer> httpServer; |
|
|
|
bool geoipDBLoaded; |
|
|
|
|
|
|
|
// ETA Computation
|
|
|
|
|
|
|
|
QPointer<QTimer> timerETA; |
|
|
|
|
|
|
|
QHash<QString, QList<int> > ETA_samples; |
|
|
|
|
|
|
|
// IP filtering
|
|
|
|
|
|
|
|
QPointer<FilterParserThread> filterParser; |
|
|
|
|
|
|
|
QString filterPath; |
|
|
|
|
|
|
|
// Web UI
|
|
|
|
|
|
|
|
QPointer<HttpServer> httpServer; |
|
|
|
|
|
|
|
QStringList url_skippingDlg; |
|
|
|
|
|
|
|
|
|
|
|
protected: |
|
|
|
protected: |
|
|
|
QString getSavePath(QString hash); |
|
|
|
QString getSavePath(QString hash); |
|
|
|
bool initWebUi(QString username, QString password, int port); |
|
|
|
bool initWebUi(QString username, QString password, int port); |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
// Constructor / Destructor
|
|
|
|
// Constructor / Destructor
|
|
|
|
bittorrent(); |
|
|
|
bittorrent(); |
|
|
|
~bittorrent(); |
|
|
|
~bittorrent(); |
|
|
|
QTorrentHandle getTorrentHandle(QString hash) const; |
|
|
|
QTorrentHandle getTorrentHandle(QString hash) const; |
|
|
|
std::vector<torrent_handle> getTorrents() const; |
|
|
|
std::vector<torrent_handle> getTorrents() const; |
|
|
|
bool isFilePreviewPossible(QString fileHash) const; |
|
|
|
bool isFilePreviewPossible(QString fileHash) const; |
|
|
|
bool isDHTEnabled() const; |
|
|
|
bool isDHTEnabled() const; |
|
|
|
float getPayloadDownloadRate() const; |
|
|
|
float getPayloadDownloadRate() const; |
|
|
|
float getPayloadUploadRate() const; |
|
|
|
float getPayloadUploadRate() const; |
|
|
|
session_status getSessionStatus() const; |
|
|
|
session_status getSessionStatus() const; |
|
|
|
int getListenPort() const; |
|
|
|
int getListenPort() const; |
|
|
|
float getRealRatio(QString hash) const; |
|
|
|
float getRealRatio(QString hash) const; |
|
|
|
session* getSession() const; |
|
|
|
session* getSession() const; |
|
|
|
QHash<QString, QString> getTrackersErrors(QString hash) const; |
|
|
|
QHash<QString, QString> getTrackersErrors(QString hash) const; |
|
|
|
bool has_filtered_files(QString hash) const; |
|
|
|
bool has_filtered_files(QString hash) const; |
|
|
|
bool hasActiveTorrents() const; |
|
|
|
bool hasActiveTorrents() const; |
|
|
|
bool isQueueingEnabled() const; |
|
|
|
bool isQueueingEnabled() const; |
|
|
|
int getMaximumActiveDownloads() const; |
|
|
|
int getMaximumActiveDownloads() const; |
|
|
|
int getMaximumActiveTorrents() const; |
|
|
|
int getMaximumActiveTorrents() const; |
|
|
|
int loadTorrentPriority(QString hash); |
|
|
|
int loadTorrentPriority(QString hash); |
|
|
|
QStringList getConsoleMessages() const; |
|
|
|
QStringList getConsoleMessages() const; |
|
|
|
QStringList getPeerBanMessages() const; |
|
|
|
QStringList getPeerBanMessages() const; |
|
|
|
qlonglong getETA(QString hash); |
|
|
|
qlonglong getETA(QString hash); |
|
|
|
bool useTemporaryFolder() const; |
|
|
|
bool useTemporaryFolder() const; |
|
|
|
QString getDefaultSavePath() const; |
|
|
|
QString getDefaultSavePath() const; |
|
|
|
|
|
|
|
|
|
|
|
public slots: |
|
|
|
public slots: |
|
|
|
QTorrentHandle addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false); |
|
|
|
QTorrentHandle addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false); |
|
|
|
QTorrentHandle addMagnetUri(QString magnet_uri, bool resumed=false); |
|
|
|
QTorrentHandle addMagnetUri(QString magnet_uri, bool resumed=false); |
|
|
|
void importOldTorrents(); |
|
|
|
void importOldTorrents(); |
|
|
|
void applyFormerAttributeFiles(QTorrentHandle h); |
|
|
|
void applyFormerAttributeFiles(QTorrentHandle h); |
|
|
|
void importOldTempData(QString torrent_path); |
|
|
|
void importOldTempData(QString torrent_path); |
|
|
|
void loadSessionState(); |
|
|
|
void loadSessionState(); |
|
|
|
void saveSessionState(); |
|
|
|
void saveSessionState(); |
|
|
|
void downloadFromUrl(QString url); |
|
|
|
void downloadFromUrl(QString url); |
|
|
|
void deleteTorrent(QString hash, bool delete_local_files = false); |
|
|
|
void deleteTorrent(QString hash, bool delete_local_files = false); |
|
|
|
void startUpTorrents(); |
|
|
|
void startUpTorrents(); |
|
|
|
/* Needed by Web UI */ |
|
|
|
/* Needed by Web UI */ |
|
|
|
void pauseAllTorrents(); |
|
|
|
void pauseAllTorrents(); |
|
|
|
void pauseTorrent(QString hash); |
|
|
|
void pauseTorrent(QString hash); |
|
|
|
void resumeTorrent(QString hash); |
|
|
|
void resumeTorrent(QString hash); |
|
|
|
void resumeAllTorrents(); |
|
|
|
void resumeAllTorrents(); |
|
|
|
/* End Web UI */ |
|
|
|
/* End Web UI */ |
|
|
|
void saveDHTEntry(); |
|
|
|
void saveDHTEntry(); |
|
|
|
void preAllocateAllFiles(bool b); |
|
|
|
void preAllocateAllFiles(bool b); |
|
|
|
void saveFastResumeData(); |
|
|
|
void saveFastResumeData(); |
|
|
|
void enableDirectoryScanning(QString scan_dir); |
|
|
|
void enableDirectoryScanning(QString scan_dir); |
|
|
|
void disableDirectoryScanning(); |
|
|
|
void disableDirectoryScanning(); |
|
|
|
void enableIPFilter(QString filter); |
|
|
|
void enableIPFilter(QString filter); |
|
|
|
void disableIPFilter(); |
|
|
|
void disableIPFilter(); |
|
|
|
void setQueueingEnabled(bool enable); |
|
|
|
void setQueueingEnabled(bool enable); |
|
|
|
void handleDownloadFailure(QString url, QString reason); |
|
|
|
void handleDownloadFailure(QString url, QString reason); |
|
|
|
void loadWebSeeds(QString fileHash); |
|
|
|
void loadWebSeeds(QString fileHash); |
|
|
|
void downloadUrlAndSkipDialog(QString url, QString save_path=QString::null); |
|
|
|
void downloadUrlAndSkipDialog(QString url, QString save_path=QString::null); |
|
|
|
// Session configuration - Setters
|
|
|
|
// Session configuration - Setters
|
|
|
|
void setListeningPort(int port); |
|
|
|
void setListeningPort(int port); |
|
|
|
void setMaxConnections(int maxConnec); |
|
|
|
void setMaxConnections(int maxConnec); |
|
|
|
void setMaxConnectionsPerTorrent(int max); |
|
|
|
void setMaxConnectionsPerTorrent(int max); |
|
|
|
void setMaxUploadsPerTorrent(int max); |
|
|
|
void setMaxUploadsPerTorrent(int max); |
|
|
|
void setDownloadRateLimit(long rate); |
|
|
|
void setDownloadRateLimit(long rate); |
|
|
|
void setUploadRateLimit(long rate); |
|
|
|
void setUploadRateLimit(long rate); |
|
|
|
void setGlobalRatio(float ratio); |
|
|
|
void setGlobalRatio(float ratio); |
|
|
|
void setDeleteRatio(float ratio); |
|
|
|
void setDeleteRatio(float ratio); |
|
|
|
void setDHTPort(int dht_port); |
|
|
|
void setDHTPort(int dht_port); |
|
|
|
void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true); |
|
|
|
void setProxySettings(proxy_settings proxySettings, bool trackers=true, bool peers=true, bool web_seeds=true, bool dht=true); |
|
|
|
void setSessionSettings(session_settings sessionSettings); |
|
|
|
void setSessionSettings(session_settings sessionSettings); |
|
|
|
void startTorrentsInPause(bool b); |
|
|
|
void startTorrentsInPause(bool b); |
|
|
|
void setDefaultSavePath(QString savepath); |
|
|
|
void setDefaultTempPath(QString temppath); |
|
|
|
void setDefaultTempPath(QString temppath); |
|
|
|
void applyEncryptionSettings(pe_settings se); |
|
|
|
void applyEncryptionSettings(pe_settings se); |
|
|
|
void loadFilesPriorities(QTorrentHandle& h); |
|
|
|
void loadFilesPriorities(QTorrentHandle& h); |
|
|
|
void setDownloadLimit(QString hash, long val); |
|
|
|
void setDownloadLimit(QString hash, long val); |
|
|
|
void setUploadLimit(QString hash, long val); |
|
|
|
void setUploadLimit(QString hash, long val); |
|
|
|
void enableUPnP(bool b); |
|
|
|
void enableUPnP(bool b); |
|
|
|
void enableNATPMP(bool b); |
|
|
|
void enableNATPMP(bool b); |
|
|
|
void enableLSD(bool b); |
|
|
|
void enableLSD(bool b); |
|
|
|
bool enableDHT(bool b); |
|
|
|
bool enableDHT(bool b); |
|
|
|
void addConsoleMessage(QString msg, QColor color=QApplication::palette().color(QPalette::WindowText)); |
|
|
|
void addConsoleMessage(QString msg, QColor color=QApplication::palette().color(QPalette::WindowText)); |
|
|
|
void addPeerBanMessage(QString msg, bool from_ipfilter); |
|
|
|
void addPeerBanMessage(QString msg, bool from_ipfilter); |
|
|
|
void processDownloadedFile(QString, QString); |
|
|
|
void processDownloadedFile(QString, QString); |
|
|
|
void saveTrackerFile(QString hash); |
|
|
|
void saveTrackerFile(QString hash); |
|
|
|
void addMagnetSkipAddDlg(QString uri); |
|
|
|
void addMagnetSkipAddDlg(QString uri); |
|
|
|
void downloadFromURLList(const QStringList& urls); |
|
|
|
void downloadFromURLList(const QStringList& urls); |
|
|
|
void configureSession(); |
|
|
|
void configureSession(); |
|
|
|
void banIP(QString ip); |
|
|
|
void banIP(QString ip); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected slots: |
|
|
|
protected slots: |
|
|
|
void addTorrentsFromScanFolder(QStringList&); |
|
|
|
void addTorrentsFromScanFolder(QStringList&); |
|
|
|
void readAlerts(); |
|
|
|
void readAlerts(); |
|
|
|
void loadTrackerFile(QString hash); |
|
|
|
void loadTrackerFile(QString hash); |
|
|
|
void deleteBigRatios(); |
|
|
|
void deleteBigRatios(); |
|
|
|
void takeETASamples(); |
|
|
|
void takeETASamples(); |
|
|
|
|
|
|
|
|
|
|
|
signals: |
|
|
|
signals: |
|
|
|
void addedTorrent(QTorrentHandle& h); |
|
|
|
void addedTorrent(QTorrentHandle& h); |
|
|
|
void deletedTorrent(QString hash); |
|
|
|
void deletedTorrent(QString hash); |
|
|
|
void pausedTorrent(QTorrentHandle& h); |
|
|
|
void pausedTorrent(QTorrentHandle& h); |
|
|
|
void resumedTorrent(QTorrentHandle& h); |
|
|
|
void resumedTorrent(QTorrentHandle& h); |
|
|
|
void finishedTorrent(QTorrentHandle& h); |
|
|
|
void finishedTorrent(QTorrentHandle& h); |
|
|
|
void fullDiskError(QTorrentHandle& h, QString msg); |
|
|
|
void fullDiskError(QTorrentHandle& h, QString msg); |
|
|
|
void trackerError(QString hash, QString time, QString msg); |
|
|
|
void trackerError(QString hash, QString time, QString msg); |
|
|
|
void trackerAuthenticationRequired(QTorrentHandle& h); |
|
|
|
void trackerAuthenticationRequired(QTorrentHandle& h); |
|
|
|
void newDownloadedTorrent(QString path, QString url); |
|
|
|
void newDownloadedTorrent(QString path, QString url); |
|
|
|
void updateFileSize(QString hash); |
|
|
|
void updateFileSize(QString hash); |
|
|
|
void downloadFromUrlFailure(QString url, QString reason); |
|
|
|
void downloadFromUrlFailure(QString url, QString reason); |
|
|
|
void torrentFinishedChecking(QTorrentHandle& h); |
|
|
|
void torrentFinishedChecking(QTorrentHandle& h); |
|
|
|
void metadataReceived(QTorrentHandle &h); |
|
|
|
void metadataReceived(QTorrentHandle &h); |
|
|
|
void torrentPaused(QTorrentHandle &h); |
|
|
|
void torrentPaused(QTorrentHandle &h); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|