mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
Big code clean up
This commit is contained in:
parent
f53fe96191
commit
290932e128
33 changed files with 465 additions and 527 deletions
|
@ -126,7 +126,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), for
|
|||
// Fix Tool bar layout
|
||||
toolBar->layout()->setSpacing(7);
|
||||
// Creating Bittorrent session
|
||||
BTSession = new Bittorrent();
|
||||
BTSession = new QBtSession();
|
||||
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&, QString)), this, SLOT(fullDiskError(QTorrentHandle&, QString)));
|
||||
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&)));
|
||||
connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "ui_mainwindow.h"
|
||||
#include "qtorrenthandle.h"
|
||||
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class QTimer;
|
||||
class downloadFromURL;
|
||||
class SearchEngine;
|
||||
|
@ -140,7 +140,7 @@ protected:
|
|||
private:
|
||||
QFileSystemWatcher *executable_watcher;
|
||||
// Bittorrent
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
|
||||
// GUI related
|
||||
QTimer *guiUpdater;
|
||||
|
|
|
@ -40,10 +40,10 @@ class consoleDlg : public QDialog, private Ui_ConsoleDlg{
|
|||
Q_OBJECT
|
||||
|
||||
private:
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
|
||||
public:
|
||||
consoleDlg(QWidget *parent, Bittorrent* _BTSession) : QDialog(parent) {
|
||||
consoleDlg(QWidget *parent, QBtSession* _BTSession) : QDialog(parent) {
|
||||
setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setModal(true);
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
// Enable Web UI
|
||||
Preferences::setWebUiEnabled(true);
|
||||
// Instanciate Bittorrent Object
|
||||
BTSession = new Bittorrent();
|
||||
BTSession = new QBtSession();
|
||||
connect(BTSession, SIGNAL(newConsoleMessage(QString)), this, SLOT(displayConsoleMessage(QString)));
|
||||
// Resume unfinished torrents
|
||||
BTSession->startUpTorrents();
|
||||
|
@ -103,7 +103,7 @@ public slots:
|
|||
}
|
||||
|
||||
private:
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -76,6 +76,10 @@ public:
|
|||
return QString(o.str().c_str());
|
||||
}
|
||||
|
||||
static inline sha1_hash toSha1Hash(QString hash) {
|
||||
return sha1_hash(qPrintable(hash));
|
||||
}
|
||||
|
||||
static void chmod644(const QDir& folder);
|
||||
|
||||
static inline QString removeLastPathPart(QString path) {
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
#define SELECTED_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px;background-color: rgb(255, 208, 105); margin-left: 3px; margin-right: 3px;}"
|
||||
#endif
|
||||
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession):
|
||||
PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, QBtSession* BTSession):
|
||||
QWidget(parent), transferList(transferList), main_window(main_window), BTSession(BTSession) {
|
||||
setupUi(this);
|
||||
state = VISIBLE;
|
||||
|
@ -206,7 +206,7 @@ QTorrentHandle PropertiesWidget::getCurrentTorrent() const {
|
|||
return h;
|
||||
}
|
||||
|
||||
Bittorrent* PropertiesWidget::getBTSession() const {
|
||||
QBtSession* PropertiesWidget::getBTSession() const {
|
||||
return BTSession;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
class TransferListWidget;
|
||||
class QTimer;
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class TorrentFilesModel;
|
||||
class PropListDelegate;
|
||||
class QAction;
|
||||
|
@ -60,7 +60,7 @@ private:
|
|||
GUI *main_window;
|
||||
QTorrentHandle h;
|
||||
QTimer *refreshTimer;
|
||||
Bittorrent* BTSession;
|
||||
QBtSession* BTSession;
|
||||
SlideState state;
|
||||
TorrentFilesModel *PropListModel;
|
||||
PropListDelegate *PropDelegate;
|
||||
|
@ -71,10 +71,10 @@ private:
|
|||
PieceAvailabilityBar *pieces_availability;
|
||||
|
||||
public:
|
||||
PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession);
|
||||
PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, QBtSession* BTSession);
|
||||
~PropertiesWidget();
|
||||
QTorrentHandle getCurrentTorrent() const;
|
||||
Bittorrent* getBTSession() const;
|
||||
QBtSession* getBTSession() const;
|
||||
TrackerList* getTrackerList() const { return trackerList; }
|
||||
PeerListWidget* getPeerList() const { return peersList; }
|
||||
QTreeView* getFilesList() const { return filesList; }
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -62,13 +62,13 @@ class HttpServer;
|
|||
class BandwidthScheduler;
|
||||
class ScanFoldersModel;
|
||||
|
||||
class Bittorrent : public QObject {
|
||||
class QBtSession : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Constructor / Destructor
|
||||
Bittorrent();
|
||||
~Bittorrent();
|
||||
QBtSession();
|
||||
~QBtSession();
|
||||
QTorrentHandle getTorrentHandle(QString hash) const;
|
||||
std::vector<torrent_handle> getTorrents() const;
|
||||
bool isFilePreviewPossible(QString fileHash) const;
|
||||
|
@ -166,6 +166,10 @@ public slots:
|
|||
protected:
|
||||
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString::null, QString root_folder=QString::null);
|
||||
bool initWebUi(QString username, QString password, int port);
|
||||
bool loadFastResumeData(QString hash, std::vector<char> &buf);
|
||||
void loadTorrentSettings(QTorrentHandle h);
|
||||
void loadTorrentTempData(QTorrentHandle h, QString savePath, bool magnet);
|
||||
add_torrent_params initializeAddTorrentParams(QString hash);
|
||||
|
||||
protected slots:
|
||||
void addTorrentsFromScanFolder(QStringList&);
|
||||
|
@ -178,6 +182,7 @@ protected slots:
|
|||
void autoRunExternalProgram(QTorrentHandle h, bool async=true);
|
||||
void cleanUpAutoRunProcess(int);
|
||||
void mergeTorrents(QTorrentHandle h_ex, boost::intrusive_ptr<torrent_info> t);
|
||||
void exportTorrentFile(QTorrentHandle h);
|
||||
|
||||
signals:
|
||||
void addedTorrent(QTorrentHandle& h);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "feeddownloader.h"
|
||||
|
||||
FeedDownloaderDlg::FeedDownloaderDlg(QWidget *parent, QString feed_url, QString feed_name, Bittorrent* BTSession):
|
||||
FeedDownloaderDlg::FeedDownloaderDlg(QWidget *parent, QString feed_url, QString feed_name, QBtSession* BTSession):
|
||||
QDialog(parent), feed_url(feed_url), feed_name(feed_name), BTSession(BTSession), selected_filter(QString::null)
|
||||
{
|
||||
setupUi(this);
|
||||
|
|
|
@ -52,7 +52,7 @@ class FeedDownloaderDlg : public QDialog, private Ui_FeedDownloader{
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FeedDownloaderDlg(QWidget *parent, QString feed_url, QString feed_name, Bittorrent* BTSession);
|
||||
FeedDownloaderDlg(QWidget *parent, QString feed_url, QString feed_name, QBtSession* BTSession);
|
||||
~FeedDownloaderDlg();
|
||||
|
||||
protected slots:
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
QString feed_url;
|
||||
QString feed_name;
|
||||
RssFilters filters;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
QString selected_filter; // name
|
||||
|
||||
};
|
||||
|
|
|
@ -585,7 +585,7 @@ void RSSImp::updateRefreshInterval(unsigned int val) {
|
|||
rssmanager->updateRefreshInterval(val);
|
||||
}
|
||||
|
||||
RSSImp::RSSImp(Bittorrent *BTSession) : QWidget(), BTSession(BTSession){
|
||||
RSSImp::RSSImp(QBtSession *BTSession) : QWidget(), BTSession(BTSession){
|
||||
setupUi(this);
|
||||
|
||||
rssmanager = new RssManager(BTSession);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
#include "ui_rss.h"
|
||||
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class FeedListWidget;
|
||||
class QTreeWidgetItem;
|
||||
class RssFolder;
|
||||
|
@ -46,7 +46,7 @@ class RSSImp : public QWidget, public Ui::RSS{
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RSSImp(Bittorrent *BTSession);
|
||||
RSSImp(QBtSession *BTSession);
|
||||
~RSSImp();
|
||||
|
||||
public slots:
|
||||
|
@ -83,7 +83,7 @@ protected slots:
|
|||
|
||||
private:
|
||||
RssManager *rssmanager;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
FeedListWidget *listStreams;
|
||||
QTreeWidgetItem* previous_news;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "rssarticle.h"
|
||||
#include "feeddownloader.h"
|
||||
|
||||
RssFeed::RssFeed(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSession, QString _url): parent(parent), rssmanager(rssmanager), BTSession(BTSession), alias(""), iconPath(":/Icons/rss16.png"), refreshed(false), downloadFailure(false), currently_loading(false) {
|
||||
RssFeed::RssFeed(RssFolder* parent, RssManager *rssmanager, QBtSession *BTSession, QString _url): parent(parent), rssmanager(rssmanager), BTSession(BTSession), alias(""), iconPath(":/Icons/rss16.png"), refreshed(false), downloadFailure(false), currently_loading(false) {
|
||||
qDebug("RSSStream constructed");
|
||||
QIniSettings qBTRSS("qBittorrent", "qBittorrent-rss");
|
||||
url = QUrl(_url).toString();
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "rssfile.h"
|
||||
|
||||
class RssManager;
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
|
||||
class RssFeed: public RssFile, public QHash<QString, RssArticle*> {
|
||||
Q_OBJECT
|
||||
|
@ -44,7 +44,7 @@ class RssFeed: public RssFile, public QHash<QString, RssArticle*> {
|
|||
private:
|
||||
RssFolder *parent;
|
||||
RssManager *rssmanager;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
QString title;
|
||||
QString link;
|
||||
QString description;
|
||||
|
@ -63,7 +63,7 @@ public slots:
|
|||
void setDownloadFailed();
|
||||
|
||||
public:
|
||||
RssFeed(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSession, QString _url);
|
||||
RssFeed(RssFolder* parent, RssManager *rssmanager, QBtSession *BTSession, QString _url);
|
||||
~RssFeed();
|
||||
RssFolder* getParent() const { return parent; }
|
||||
void setParent(RssFolder* _parent) { parent = _parent; }
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include "rssmanager.h"
|
||||
#include "rssfeed.h"
|
||||
|
||||
RssFolder::RssFolder(RssFolder *parent, RssManager *rssmanager, Bittorrent *BTSession, QString name): parent(parent), rssmanager(rssmanager), BTSession(BTSession), name(name) {
|
||||
RssFolder::RssFolder(RssFolder *parent, RssManager *rssmanager, QBtSession *BTSession, QString name): parent(parent), rssmanager(rssmanager), BTSession(BTSession), name(name) {
|
||||
downloader = new downloadThread(this);
|
||||
connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processFinishedDownload(QString, QString)));
|
||||
connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include "rssfile.h"
|
||||
|
||||
class RssArticle;
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class downloadThread;
|
||||
class RssManager;
|
||||
class RssFeed;
|
||||
|
@ -45,7 +45,7 @@ class RssFolder: public RssFile, public QHash<QString, RssFile*> {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RssFolder(RssFolder *parent, RssManager *rssmanager, Bittorrent *BTSession, QString name);
|
||||
RssFolder(RssFolder *parent, RssManager *rssmanager, QBtSession *BTSession, QString name);
|
||||
~RssFolder();
|
||||
RssFolder* getParent() const { return parent; }
|
||||
void setParent(RssFolder* _parent) { parent = _parent; }
|
||||
|
@ -80,7 +80,7 @@ private:
|
|||
RssFolder *parent;
|
||||
RssManager *rssmanager;
|
||||
downloadThread *downloader;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
QString name;
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "rssfeed.h"
|
||||
#include "rssarticle.h"
|
||||
|
||||
RssManager::RssManager(Bittorrent *BTSession): RssFolder(0, this, BTSession, QString::null) {
|
||||
RssManager::RssManager(QBtSession *BTSession): RssFolder(0, this, BTSession, QString::null) {
|
||||
loadStreamList();
|
||||
connect(&newsRefresher, SIGNAL(timeout()), this, SLOT(refreshAll()));
|
||||
refreshInterval = Preferences::getRSSRefreshInterval();
|
||||
|
|
|
@ -39,7 +39,7 @@ class RssManager: public RssFolder {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RssManager(Bittorrent *BTSession);
|
||||
RssManager(QBtSession *BTSession);
|
||||
~RssManager();
|
||||
static void insertSortElem(QList<RssArticle*> &list, RssArticle *item);
|
||||
static QList<RssArticle*> sortNewsList(const QList<RssArticle*>& news_list);
|
||||
|
@ -59,7 +59,7 @@ signals:
|
|||
private:
|
||||
QTimer newsRefresher;
|
||||
unsigned int refreshInterval;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
#define SEARCHHISTORY_MAXSIZE 50
|
||||
|
||||
/*SEARCH ENGINE START*/
|
||||
SearchEngine::SearchEngine(GUI *parent, Bittorrent *BTSession) : QWidget(parent), BTSession(BTSession), parent(parent) {
|
||||
SearchEngine::SearchEngine(GUI *parent, QBtSession *BTSession) : QWidget(parent), BTSession(BTSession), parent(parent) {
|
||||
setupUi(this);
|
||||
// new qCompleter to the search pattern
|
||||
startSearchHistory();
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "searchtab.h"
|
||||
#include "supportedengines.h"
|
||||
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class downloadThread;
|
||||
class QTimer;
|
||||
class SearchEngine;
|
||||
|
@ -60,7 +60,7 @@ private:
|
|||
unsigned long nb_search_results;
|
||||
QPointer<QCompleter> searchCompleter;
|
||||
QStringListModel searchHistory;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
SupportedEngines *supported_engines;
|
||||
QTimer *searchTimeout;
|
||||
QPointer<SearchTab> currentSearchTab;
|
||||
|
@ -75,7 +75,7 @@ private:
|
|||
#endif
|
||||
|
||||
public:
|
||||
SearchEngine(GUI *parent, Bittorrent *BTSession);
|
||||
SearchEngine(GUI *parent, QBtSession *BTSession);
|
||||
~SearchEngine();
|
||||
QString selectedCategory() const;
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ private:
|
|||
QTimer *refreshTimer;
|
||||
QWidget *container;
|
||||
QGridLayout *layout;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
|
||||
public:
|
||||
StatusBar(QStatusBar *bar, Bittorrent *BTSession): bar(bar), BTSession(BTSession) {
|
||||
StatusBar(QStatusBar *bar, QBtSession *BTSession): bar(bar), BTSession(BTSession) {
|
||||
connect(BTSession, SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
|
||||
container = new QWidget();
|
||||
layout = new QGridLayout(container);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include "torrentadditiondlg.h"
|
||||
|
||||
torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession) : QDialog((QWidget*)parent), old_label(""), hidden_height(0), cursor_pos(-1) {
|
||||
torrentAdditionDialog::torrentAdditionDialog(GUI *parent, QBtSession* _BTSession) : QDialog((QWidget*)parent), old_label(""), hidden_height(0), cursor_pos(-1) {
|
||||
setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&)));
|
||||
|
|
|
@ -62,7 +62,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession);
|
||||
torrentAdditionDialog(GUI *parent, QBtSession* _BTSession);
|
||||
~torrentAdditionDialog();
|
||||
void readSettings();
|
||||
void saveSettings();
|
||||
|
@ -96,7 +96,7 @@ signals:
|
|||
void torrentPaused(QTorrentHandle &h);
|
||||
|
||||
private:
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
QString fileName;
|
||||
QString hash;
|
||||
QString filePath;
|
||||
|
|
|
@ -45,13 +45,13 @@ class TorrentTempData {
|
|||
public:
|
||||
static bool hasTempData(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
return all_data.contains(hash);
|
||||
}
|
||||
|
||||
static void deleteTempData(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
if(all_data.contains(hash)) {
|
||||
all_data.remove(hash);
|
||||
settings.setValue("torrents-tmp", all_data);
|
||||
|
@ -60,8 +60,8 @@ public:
|
|||
|
||||
static void setFilesPriority(QString hash, const std::vector<int> &pp) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
std::vector<int>::const_iterator pp_it = pp.begin();
|
||||
QStringList pieces_priority;
|
||||
while(pp_it != pp.end()) {
|
||||
|
@ -75,8 +75,8 @@ public:
|
|||
|
||||
static void setFilesPath(QString hash, const QStringList &path_list) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["files_path"] = path_list;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents-tmp", all_data);
|
||||
|
@ -84,8 +84,8 @@ public:
|
|||
|
||||
static void setSavePath(QString hash, QString save_path) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["save_path"] = save_path;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents-tmp", all_data);
|
||||
|
@ -93,8 +93,8 @@ public:
|
|||
|
||||
static void setLabel(QString hash, QString label) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
qDebug("Saving label %s to tmp data", label.toLocal8Bit().data());
|
||||
data["label"] = label;
|
||||
all_data[hash] = data;
|
||||
|
@ -103,8 +103,8 @@ public:
|
|||
|
||||
static void setSequential(QString hash, bool sequential) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["sequential"] = sequential;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents-tmp", all_data);
|
||||
|
@ -112,19 +112,16 @@ public:
|
|||
|
||||
static bool isSequential(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
if(data.contains("sequential"))
|
||||
return data["sequential"].toBool();
|
||||
return false;
|
||||
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("sequential", false).toBool();
|
||||
}
|
||||
|
||||
#if LIBTORRENT_VERSION_MINOR > 14
|
||||
static void setSeedingMode(QString hash,bool seed){
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["seeding"] = seed;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents-tmp", all_data);
|
||||
|
@ -132,53 +129,42 @@ public:
|
|||
|
||||
static bool isSeedingMode(QString hash){
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
if(data.contains("seeding"))
|
||||
return data["seeding"].toBool();
|
||||
return false;
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("seeding", false).toBool();
|
||||
}
|
||||
#endif
|
||||
|
||||
static QString getSavePath(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
if(data.contains("save_path"))
|
||||
return data["save_path"].toString();
|
||||
qDebug("Warning Temp::getSavePath returns null string!");
|
||||
return QString::null;
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("save_path").toString();
|
||||
}
|
||||
|
||||
static QStringList getFilesPath(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
if(data.contains("files_path"))
|
||||
return data["files_path"].toStringList();
|
||||
return QStringList();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("files_path").toStringList();
|
||||
}
|
||||
|
||||
static QString getLabel(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
qDebug("Got label %s from tmp data", data.value("label", "").toString().toLocal8Bit().data());
|
||||
return data.value("label", "").toString();
|
||||
}
|
||||
|
||||
static std::vector<int> getFilesPriority(QString hash) {
|
||||
static void getFilesPriority(QString hash, std::vector<int> &fp) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents-tmp", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
std::vector<int> fp;
|
||||
if(data.contains("files_priority")) {
|
||||
QList<int> list_var = misc::intListfromStringList(data["files_priority"].toStringList());
|
||||
foreach(int var, list_var) {
|
||||
fp.push_back(var);
|
||||
}
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
const QList<int> list_var = misc::intListfromStringList(data.value("files_priority").toStringList());
|
||||
foreach(const int &var, list_var) {
|
||||
fp.push_back(var);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -187,22 +173,22 @@ public:
|
|||
|
||||
static bool isKnownTorrent(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
return all_data.contains(hash);
|
||||
}
|
||||
|
||||
static QStringList knownTorrents() {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
return all_data.keys();
|
||||
}
|
||||
|
||||
static void setAddedDate(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
if(!data.contains("add_date")) {
|
||||
data.insert("add_date", QDateTime::currentDateTime());
|
||||
data["add_date"] = QDateTime::currentDateTime();
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
@ -210,9 +196,9 @@ public:
|
|||
|
||||
static QDateTime getAddedDate(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QDateTime dt = data.value("add_date", QDateTime()).toDateTime();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
QDateTime dt = data.value("add_date").toDateTime();
|
||||
if(!dt.isValid()) {
|
||||
setAddedDate(hash);
|
||||
dt = QDateTime::currentDateTime();
|
||||
|
@ -222,89 +208,86 @@ public:
|
|||
|
||||
static void setErrorState(QString hash, bool has_error) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
data.insert("has_error", has_error);
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["has_error"] = has_error;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
||||
static bool hasError(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("has_error", false).toBool();
|
||||
}
|
||||
|
||||
static void setRootFolder(QString hash, QString root_folder) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
data.insert("root_folder", root_folder);
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["root_folder"] = root_folder;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
||||
static QString getRootFolder(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
return data.value("root_folder", QString()).toString();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("root_folder").toString();
|
||||
}
|
||||
|
||||
static void setPreviousSavePath(QString hash, QString previous_path) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
data.insert("previous_path", previous_path);
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["previous_path"] = previous_path;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
||||
static QString getPreviousPath(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
return data.value("previous_path", QString()).toString();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("previous_path").toString();
|
||||
}
|
||||
|
||||
static void saveSeedDate(const QTorrentHandle &h) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
|
||||
if(h.is_seed())
|
||||
data.insert("seed_date", QDateTime::currentDateTime());
|
||||
data["seed_date"] = QDateTime::currentDateTime();
|
||||
else
|
||||
data.insert("seed_date", QDateTime());
|
||||
data.remove("seed_date");
|
||||
all_data[h.hash()] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
|
||||
static QDateTime getSeedDate(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
return data.value("seed_date", QDateTime()).toDateTime();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("seed_date").toDateTime();
|
||||
}
|
||||
|
||||
static void deletePersistentData(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
if(all_data.contains(hash)) {
|
||||
all_data.remove(hash);
|
||||
settings.setValue("torrents", all_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void saveTorrentPersistentData(const QTorrentHandle &h, bool is_magnet = false) {
|
||||
static void saveTorrentPersistentData(const QTorrentHandle &h, QString save_path = QString::null, bool is_magnet = false) {
|
||||
Q_ASSERT(h.is_valid());
|
||||
qDebug("Saving persistent data for %s", h.hash().toLocal8Bit().data());
|
||||
// First, remove temp data
|
||||
TorrentTempData::deleteTempData(h.hash());
|
||||
Q_ASSERT(!TorrentTempData::hasTempData(h.hash()));
|
||||
qDebug("Saving persistent data for %s", qPrintable(h.hash()));
|
||||
// Save persistent data
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data;
|
||||
data["is_magnet"] = is_magnet;
|
||||
if(is_magnet) {
|
||||
|
@ -312,13 +295,20 @@ public:
|
|||
}
|
||||
data["seed"] = h.is_seed();
|
||||
data["priority"] = h.queue_position();
|
||||
data["save_path"] = h.save_path();
|
||||
if(save_path.isEmpty())
|
||||
data["save_path"] = h.save_path();
|
||||
else
|
||||
data["save_path"] = save_path; // Override torrent save path (e.g. because it is a temp dir)
|
||||
// Label
|
||||
data["label"] = TorrentTempData::getLabel(h.hash());
|
||||
// Save data
|
||||
all_data[h.hash()] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
qDebug("TorrentPersistentData: Saving save_path %s, hash: %s", h.save_path().toLocal8Bit().data(), h.hash().toLocal8Bit().data());
|
||||
qDebug("TorrentPersistentData: Saving save_path %s, hash: %s", qPrintable(h.save_path()), qPrintable(h.hash()));
|
||||
// Set Added date
|
||||
setAddedDate(h.hash());
|
||||
// Finally, remove temp data
|
||||
TorrentTempData::deleteTempData(h.hash());
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
@ -327,8 +317,8 @@ public:
|
|||
Q_ASSERT(!hash.isEmpty());
|
||||
qDebug("TorrentPersistentData::saveSavePath(%s)", qPrintable(save_path));
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["save_path"] = save_path;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
|
@ -338,8 +328,8 @@ public:
|
|||
static void saveLabel(QString hash, QString label) {
|
||||
Q_ASSERT(!hash.isEmpty());
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["label"] = label;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
|
@ -348,8 +338,8 @@ public:
|
|||
static void saveName(QString hash, QString name) {
|
||||
Q_ASSERT(!hash.isEmpty());
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
data["name"] = name;
|
||||
all_data[hash] = data;
|
||||
settings.setValue("torrents", all_data);
|
||||
|
@ -357,7 +347,7 @@ public:
|
|||
|
||||
static void savePriority(const QTorrentHandle &h) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
|
||||
data["priority"] = h.queue_position();
|
||||
all_data[h.hash()] = data;
|
||||
|
@ -366,7 +356,7 @@ public:
|
|||
|
||||
static void saveSeedStatus(const QTorrentHandle &h) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
QHash<QString, QVariant> data = all_data[h.hash()].toHash();
|
||||
bool was_seed = data.value("seed", false).toBool();
|
||||
if(was_seed != h.is_seed()) {
|
||||
|
@ -383,53 +373,53 @@ public:
|
|||
// Getters
|
||||
static QString getSavePath(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
//qDebug("TorrentPersistentData: getSavePath %s", data["save_path"].toString().toLocal8Bit().data());
|
||||
return data["save_path"].toString();
|
||||
return data.value("save_path").toString();
|
||||
}
|
||||
|
||||
static QString getLabel(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("label", "").toString();
|
||||
}
|
||||
|
||||
static QString getName(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("name", "").toString();
|
||||
}
|
||||
|
||||
static int getPriority(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
return data["priority"].toInt();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("priority", -1).toInt();
|
||||
}
|
||||
|
||||
static bool isSeed(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("seed", false).toBool();
|
||||
}
|
||||
|
||||
static bool isMagnet(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
return data["is_magnet"].toBool();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
return data.value("is_magnet", false).toBool();
|
||||
}
|
||||
|
||||
static QString getMagnetUri(QString hash) {
|
||||
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume"));
|
||||
QHash<QString, QVariant> all_data = settings.value("torrents", QHash<QString, QVariant>()).toHash();
|
||||
QHash<QString, QVariant> data = all_data[hash].toHash();
|
||||
Q_ASSERT(data["is_magnet"].toBool());
|
||||
return data["magnet_uri"].toString();
|
||||
const QHash<QString, QVariant> all_data = settings.value("torrents").toHash();
|
||||
const QHash<QString, QVariant> data = all_data.value(hash).toHash();
|
||||
Q_ASSERT(data.value("is_magnet", false).toBool());
|
||||
return data.value("magnet_uri").toString();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
#include "qinisettings.h"
|
||||
|
||||
TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent *_BTSession):
|
||||
TransferListWidget::TransferListWidget(QWidget *parent, GUI *main_window, QBtSession *_BTSession):
|
||||
QTreeView(parent), BTSession(_BTSession), main_window(main_window) {
|
||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
||||
// Create and apply delegate
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
class QStandardItemModel;
|
||||
class QSortFilterProxyModel;
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class QTimer;
|
||||
class TransferListDelegate;
|
||||
class GUI;
|
||||
|
@ -48,7 +48,7 @@ class TransferListWidget: public QTreeView {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TransferListWidget(QWidget *parent, GUI *main_window, Bittorrent* BTSession);
|
||||
TransferListWidget(QWidget *parent, GUI *main_window, QBtSession* BTSession);
|
||||
~TransferListWidget();
|
||||
int getNbTorrents() const;
|
||||
QStandardItemModel* getSourceModel() const;
|
||||
|
@ -134,7 +134,7 @@ private:
|
|||
QSortFilterProxyModel *nameFilterModel;
|
||||
QSortFilterProxyModel *statusFilterModel;
|
||||
QSortFilterProxyModel *labelFilterModel;
|
||||
Bittorrent* BTSession;
|
||||
QBtSession* BTSession;
|
||||
QTimer *refreshTimer;
|
||||
GUI *main_window;
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
|
||||
EventManager::EventManager(QObject *parent, Bittorrent *BTSession)
|
||||
EventManager::EventManager(QObject *parent, QBtSession *BTSession)
|
||||
: QObject(parent), BTSession(BTSession)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -36,20 +36,20 @@
|
|||
#include <QHash>
|
||||
#include <QVariant>
|
||||
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
|
||||
class EventManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QHash<QString, QVariantMap> event_list;
|
||||
Bittorrent* BTSession;
|
||||
QBtSession* BTSession;
|
||||
|
||||
protected:
|
||||
void update(QVariantMap event);
|
||||
|
||||
public:
|
||||
EventManager(QObject *parent, Bittorrent* BTSession);
|
||||
EventManager(QObject *parent, QBtSession* BTSession);
|
||||
QList<QVariantMap> getEventList() const;
|
||||
QVariantMap getPropGeneralInfo(QString hash) const;
|
||||
QList<QVariantMap> getPropTrackersInfo(QString hash) const;
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include <QRegExp>
|
||||
#include <QTemporaryFile>
|
||||
|
||||
HttpConnection::HttpConnection(QTcpSocket *socket, Bittorrent *BTSession, HttpServer *parent)
|
||||
HttpConnection::HttpConnection(QTcpSocket *socket, QBtSession *BTSession, HttpServer *parent)
|
||||
: QObject(parent), socket(socket), parent(parent), BTSession(BTSession)
|
||||
{
|
||||
socket->setParent(this);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
class QTcpSocket;
|
||||
class HttpServer;
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
|
||||
class HttpConnection : public QObject
|
||||
{
|
||||
|
@ -46,7 +46,7 @@ class HttpConnection : public QObject
|
|||
private:
|
||||
QTcpSocket *socket;
|
||||
HttpServer *parent;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
|
||||
protected:
|
||||
HttpRequestParser parser;
|
||||
|
@ -69,7 +69,7 @@ class HttpConnection : public QObject
|
|||
void recheckAllTorrents();
|
||||
|
||||
public:
|
||||
HttpConnection(QTcpSocket *socket, Bittorrent* BTSession, HttpServer *parent);
|
||||
HttpConnection(QTcpSocket *socket, QBtSession* BTSession, HttpServer *parent);
|
||||
~HttpConnection();
|
||||
QString translateDocument(QString data);
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ void HttpServer::resetNbFailedAttemptsForIp(QString ip) {
|
|||
client_failed_attempts.remove(ip);
|
||||
}
|
||||
|
||||
HttpServer::HttpServer(Bittorrent *_BTSession, int msec, QObject* parent) : QTcpServer(parent) {
|
||||
HttpServer::HttpServer(QBtSession *_BTSession, int msec, QObject* parent) : QTcpServer(parent) {
|
||||
username = Preferences::getWebUiUsername().toLocal8Bit();
|
||||
password_ha1 = Preferences::getWebUiPassword().toLocal8Bit();
|
||||
connect(this, SIGNAL(newConnection()), this, SLOT(newHttpConnection()));
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include <QHash>
|
||||
#include "preferences.h"
|
||||
|
||||
class Bittorrent;
|
||||
class QBtSession;
|
||||
class QTimer;
|
||||
class EventManager;
|
||||
|
||||
|
@ -48,7 +48,7 @@ class HttpServer : public QTcpServer {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
HttpServer(Bittorrent *BTSession, int msec, QObject* parent = 0);
|
||||
HttpServer(QBtSession *BTSession, int msec, QObject* parent = 0);
|
||||
~HttpServer();
|
||||
void setAuthorization(QString username, QString password_ha1);
|
||||
bool isAuthorized(QByteArray auth, QString method) const;
|
||||
|
@ -66,7 +66,7 @@ private slots:
|
|||
private:
|
||||
QByteArray username;
|
||||
QByteArray password_ha1;
|
||||
Bittorrent *BTSession;
|
||||
QBtSession *BTSession;
|
||||
EventManager *manager;
|
||||
QTimer *timer;
|
||||
QHash<QString, int> client_failed_attempts;
|
||||
|
|
Loading…
Reference in a new issue