mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 09:13:08 -07:00
- Fixing indentation
- Stop catching SIGINT and SIGTERM once the application has exiting
This commit is contained in:
parent
78ba99778a
commit
99459dc55d
4 changed files with 952 additions and 940 deletions
|
@ -42,7 +42,7 @@
|
|||
#include "filterparserthread.h"
|
||||
#include "preferences.h"
|
||||
#ifndef DISABLE_GUI
|
||||
#include "geoip.h"
|
||||
#include "geoip.h"
|
||||
#endif
|
||||
#include "torrentpersistentdata.h"
|
||||
#include "httpserver.h"
|
||||
|
@ -1268,16 +1268,16 @@ QStringList Bittorrent::getPeerBanMessages() const {
|
|||
#ifdef DISABLE_GUI
|
||||
void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||
#else
|
||||
void Bittorrent::addConsoleMessage(QString msg, QColor color) {
|
||||
void Bittorrent::addConsoleMessage(QString msg, QColor color) {
|
||||
if(consoleMessages.size() > 100) {
|
||||
consoleMessages.removeFirst();
|
||||
}
|
||||
consoleMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - <font color='") + color.name() +QString::fromUtf8("'><i>") + msg + QString::fromUtf8("</i></font>"));
|
||||
#endif
|
||||
emit newConsoleMessage(QDateTime::currentDateTime().toString("dd/MM/yyyy hh:mm:ss") + " - " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
|
||||
void Bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
|
||||
if(peerBanMessages.size() > 100) {
|
||||
peerBanMessages.removeFirst();
|
||||
}
|
||||
|
@ -1285,9 +1285,9 @@ void Bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
|
|||
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was blocked due to your IP filter</i>", "x.y.z.w was blocked").arg(ip));
|
||||
else
|
||||
peerBanMessages.append(QString::fromUtf8("<font color='grey'>")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8("</font> - ")+tr("<font color='red'>%1</font> <i>was banned due to corrupt pieces</i>", "x.y.z.w was banned").arg(ip));
|
||||
}
|
||||
}
|
||||
|
||||
bool Bittorrent::isFilePreviewPossible(QString hash) const{
|
||||
bool Bittorrent::isFilePreviewPossible(QString hash) const{
|
||||
// See if there are supported files in the torrent
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if(!h.is_valid()) {
|
||||
|
@ -1302,9 +1302,9 @@ bool Bittorrent::isFilePreviewPossible(QString hash) const{
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
|
||||
void Bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
|
||||
QString dir_path = FSWatcher->directories().first();
|
||||
foreach(const QString &file, pathList) {
|
||||
QString fullPath = dir_path+QDir::separator()+file;
|
||||
|
@ -1315,17 +1315,17 @@ void Bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
|
|||
qDebug("Ignoring incomplete torrent file: %s", fullPath.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString Bittorrent::getDefaultSavePath() const {
|
||||
QString Bittorrent::getDefaultSavePath() const {
|
||||
return defaultSavePath;
|
||||
}
|
||||
}
|
||||
|
||||
bool Bittorrent::useTemporaryFolder() const {
|
||||
bool Bittorrent::useTemporaryFolder() const {
|
||||
return !defaultTempPath.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::setDefaultTempPath(QString temppath) {
|
||||
void Bittorrent::setDefaultTempPath(QString temppath) {
|
||||
if(defaultTempPath == temppath)
|
||||
return;
|
||||
if(temppath.isEmpty()) {
|
||||
|
@ -1350,10 +1350,10 @@ void Bittorrent::setDefaultTempPath(QString temppath) {
|
|||
}
|
||||
}
|
||||
defaultTempPath = temppath;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LIBTORRENT_0_15
|
||||
void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) {
|
||||
void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) {
|
||||
if(!h.is_valid() || !h.has_metadata()) return;
|
||||
std::vector<size_type> fp;
|
||||
h.file_progress(fp);
|
||||
|
@ -1376,10 +1376,10 @@ void Bittorrent::appendqBextensionToTorrent(QTorrentHandle h, bool append) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label) {
|
||||
void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_label, QString new_label) {
|
||||
if(!h.is_valid()) return;
|
||||
if(!appendLabelToSavePath) return;
|
||||
QString old_save_path = TorrentPersistentData::getSavePath(h.hash());
|
||||
|
@ -1406,9 +1406,9 @@ void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_labe
|
|||
h.move_storage(new_save_path);
|
||||
}
|
||||
emit savePathChanged(h);
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
||||
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
||||
if(!h.is_valid()) return;
|
||||
QString label = TorrentPersistentData::getLabel(h.hash());
|
||||
if(label.isEmpty()) return;
|
||||
|
@ -1424,9 +1424,9 @@ void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
|||
}
|
||||
emit savePathChanged(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::setAppendLabelToSavePath(bool append) {
|
||||
void Bittorrent::setAppendLabelToSavePath(bool append) {
|
||||
if(appendLabelToSavePath != append) {
|
||||
appendLabelToSavePath = !appendLabelToSavePath;
|
||||
if(appendLabelToSavePath) {
|
||||
|
@ -1439,10 +1439,10 @@ void Bittorrent::setAppendLabelToSavePath(bool append) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LIBTORRENT_0_15
|
||||
void Bittorrent::setAppendqBExtension(bool append) {
|
||||
void Bittorrent::setAppendqBExtension(bool append) {
|
||||
if(appendqBExtension != append) {
|
||||
appendqBExtension = !appendqBExtension;
|
||||
// append or remove .!qB extension for incomplete files
|
||||
|
@ -1453,11 +1453,11 @@ void Bittorrent::setAppendqBExtension(bool append) {
|
|||
appendqBextensionToTorrent(h, appendqBExtension);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Enable directory scanning
|
||||
void Bittorrent::enableDirectoryScanning(QString scan_dir) {
|
||||
// Enable directory scanning
|
||||
void Bittorrent::enableDirectoryScanning(QString scan_dir) {
|
||||
if(!scan_dir.isEmpty()) {
|
||||
QDir newDir(scan_dir);
|
||||
if(!newDir.exists()) {
|
||||
|
@ -1480,43 +1480,43 @@ void Bittorrent::enableDirectoryScanning(QString scan_dir) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable directory scanning
|
||||
void Bittorrent::disableDirectoryScanning() {
|
||||
// Disable directory scanning
|
||||
void Bittorrent::disableDirectoryScanning() {
|
||||
if(FSWatcher) {
|
||||
delete FSWatcher;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the ports range in which is chosen the port the Bittorrent
|
||||
// session will listen to
|
||||
void Bittorrent::setListeningPort(int port) {
|
||||
// Set the ports range in which is chosen the port the Bittorrent
|
||||
// session will listen to
|
||||
void Bittorrent::setListeningPort(int port) {
|
||||
std::pair<int,int> ports(port, port);
|
||||
s->listen_on(ports);
|
||||
}
|
||||
}
|
||||
|
||||
// Set download rate limit
|
||||
// -1 to disable
|
||||
void Bittorrent::setDownloadRateLimit(long rate) {
|
||||
// Set download rate limit
|
||||
// -1 to disable
|
||||
void Bittorrent::setDownloadRateLimit(long rate) {
|
||||
qDebug("Setting a global download rate limit at %ld", rate);
|
||||
s->set_download_rate_limit(rate);
|
||||
}
|
||||
}
|
||||
|
||||
session* Bittorrent::getSession() const{
|
||||
session* Bittorrent::getSession() const{
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
// Set upload rate limit
|
||||
// -1 to disable
|
||||
void Bittorrent::setUploadRateLimit(long rate) {
|
||||
// Set upload rate limit
|
||||
// -1 to disable
|
||||
void Bittorrent::setUploadRateLimit(long rate) {
|
||||
qDebug("set upload_limit to %fkb/s", rate/1024.);
|
||||
s->set_upload_rate_limit(rate);
|
||||
}
|
||||
}
|
||||
|
||||
// libtorrent allow to adjust ratio for each torrent
|
||||
// This function will apply to same ratio to all torrents
|
||||
void Bittorrent::setGlobalRatio(float ratio) {
|
||||
// libtorrent allow to adjust ratio for each torrent
|
||||
// This function will apply to same ratio to all torrents
|
||||
void Bittorrent::setGlobalRatio(float ratio) {
|
||||
if(ratio != -1 && ratio < 1.) ratio = 1.;
|
||||
if(ratio == -1) {
|
||||
// 0 means unlimited for libtorrent
|
||||
|
@ -1532,11 +1532,11 @@ void Bittorrent::setGlobalRatio(float ratio) {
|
|||
}
|
||||
h.set_ratio(ratio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Torrents will a ratio superior to the given value will
|
||||
// be automatically deleted
|
||||
void Bittorrent::setDeleteRatio(float ratio) {
|
||||
// Torrents will a ratio superior to the given value will
|
||||
// be automatically deleted
|
||||
void Bittorrent::setDeleteRatio(float ratio) {
|
||||
if(ratio != -1 && ratio < 1.) ratio = 1.;
|
||||
if(ratio_limit == -1 && ratio != -1) {
|
||||
Q_ASSERT(!BigRatioTimer);
|
||||
|
@ -1553,10 +1553,10 @@ void Bittorrent::setDeleteRatio(float ratio) {
|
|||
qDebug("* Set deleteRatio to %.1f", ratio_limit);
|
||||
deleteBigRatios();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set DHT port (>= 1000 or 0 if same as BT)
|
||||
void Bittorrent::setDHTPort(int dht_port) {
|
||||
// Set DHT port (>= 1000 or 0 if same as BT)
|
||||
void Bittorrent::setDHTPort(int dht_port) {
|
||||
if(dht_port == 0 || dht_port >= 1000) {
|
||||
if(dht_port == current_dht_port) return;
|
||||
struct dht_settings DHTSettings;
|
||||
|
@ -1565,10 +1565,10 @@ void Bittorrent::setDHTPort(int dht_port) {
|
|||
current_dht_port = dht_port;
|
||||
qDebug("Set DHT Port to %d", dht_port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Enable IP Filtering
|
||||
void Bittorrent::enableIPFilter(QString filter) {
|
||||
// Enable IP Filtering
|
||||
void Bittorrent::enableIPFilter(QString filter) {
|
||||
qDebug("Enabling IPFiler");
|
||||
if(!filterParser) {
|
||||
filterParser = new FilterParserThread(this, s);
|
||||
|
@ -1577,32 +1577,32 @@ void Bittorrent::enableIPFilter(QString filter) {
|
|||
filterPath = filter;
|
||||
filterParser->processFilterFile(filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Disable IP Filtering
|
||||
void Bittorrent::disableIPFilter() {
|
||||
// Disable IP Filtering
|
||||
void Bittorrent::disableIPFilter() {
|
||||
qDebug("Disabling IPFilter");
|
||||
s->set_ip_filter(ip_filter());
|
||||
if(filterParser) {
|
||||
delete filterParser;
|
||||
}
|
||||
filterPath = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Set BT session settings (user_agent)
|
||||
void Bittorrent::setSessionSettings(session_settings sessionSettings) {
|
||||
// Set BT session settings (user_agent)
|
||||
void Bittorrent::setSessionSettings(session_settings sessionSettings) {
|
||||
qDebug("Set session settings");
|
||||
s->set_settings(sessionSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// Set Proxy
|
||||
void Bittorrent::setPeerProxySettings(proxy_settings proxySettings) {
|
||||
// Set Proxy
|
||||
void Bittorrent::setPeerProxySettings(proxy_settings proxySettings) {
|
||||
qDebug("Set Peer Proxy settings");
|
||||
s->set_peer_proxy(proxySettings);
|
||||
s->set_dht_proxy(proxySettings);
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::setHTTPProxySettings(proxy_settings proxySettings) {
|
||||
void Bittorrent::setHTTPProxySettings(proxy_settings proxySettings) {
|
||||
s->set_tracker_proxy(proxySettings);
|
||||
s->set_web_seed_proxy(proxySettings);
|
||||
QString proxy_str;
|
||||
|
@ -1629,10 +1629,10 @@ void Bittorrent::setHTTPProxySettings(proxy_settings proxySettings) {
|
|||
qDebug("HTTP: proxy string: %s", proxy_str.toLocal8Bit().data());
|
||||
setenv("http_proxy", proxy_str.toLocal8Bit().data(), 1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Read alerts sent by the Bittorrent session
|
||||
void Bittorrent::readAlerts() {
|
||||
// Read alerts sent by the Bittorrent session
|
||||
void Bittorrent::readAlerts() {
|
||||
// look at session alerts and display some infos
|
||||
std::auto_ptr<alert> a = s->pop_alert();
|
||||
while (a.get()) {
|
||||
|
@ -1846,22 +1846,22 @@ void Bittorrent::readAlerts() {
|
|||
}
|
||||
a = s->pop_alert();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QHash<QString, TrackerInfos> Bittorrent::getTrackersInfo(QString hash) const{
|
||||
QHash<QString, TrackerInfos> Bittorrent::getTrackersInfo(QString hash) const{
|
||||
return trackersInfos.value(hash, QHash<QString, TrackerInfos>());
|
||||
}
|
||||
}
|
||||
|
||||
int Bittorrent::getListenPort() const{
|
||||
int Bittorrent::getListenPort() const{
|
||||
qDebug("LISTEN PORT: %d", s->listen_port());
|
||||
return s->listen_port();
|
||||
}
|
||||
}
|
||||
|
||||
session_status Bittorrent::getSessionStatus() const{
|
||||
session_status Bittorrent::getSessionStatus() const{
|
||||
return s->status();
|
||||
}
|
||||
}
|
||||
|
||||
QString Bittorrent::getSavePath(QString hash) {
|
||||
QString Bittorrent::getSavePath(QString hash) {
|
||||
QString savePath;
|
||||
if(TorrentTempData::hasTempData(hash)) {
|
||||
savePath = TorrentTempData::getSavePath(hash);
|
||||
|
@ -1905,12 +1905,12 @@ QString Bittorrent::getSavePath(QString hash) {
|
|||
}
|
||||
}
|
||||
return savePath;
|
||||
}
|
||||
}
|
||||
|
||||
// Take an url string to a torrent file,
|
||||
// download the torrent file to a tmp location, then
|
||||
// add it to download list
|
||||
void Bittorrent::downloadFromUrl(QString url) {
|
||||
// Take an url string to a torrent file,
|
||||
// download the torrent file to a tmp location, then
|
||||
// add it to download list
|
||||
void Bittorrent::downloadFromUrl(QString url) {
|
||||
addConsoleMessage(tr("Downloading '%1', please wait...", "e.g: Downloading 'xxx.torrent', please wait...").arg(url)
|
||||
#ifndef DISABLE_GUI
|
||||
, QPalette::WindowText
|
||||
|
@ -1919,19 +1919,19 @@ void Bittorrent::downloadFromUrl(QString url) {
|
|||
//emit aboutToDownloadFromUrl(url);
|
||||
// Launch downloader thread
|
||||
downloader->downloadUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::downloadFromURLList(const QStringList& urls) {
|
||||
void Bittorrent::downloadFromURLList(const QStringList& urls) {
|
||||
foreach(const QString &url, urls) {
|
||||
downloadFromUrl(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::addMagnetSkipAddDlg(QString uri) {
|
||||
void Bittorrent::addMagnetSkipAddDlg(QString uri) {
|
||||
addMagnetUri(uri, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
||||
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
||||
//emit aboutToDownloadFromUrl(url);
|
||||
QUrl qurl = QUrl::fromEncoded(url.toLocal8Bit());
|
||||
if(!save_path.isEmpty())
|
||||
|
@ -1939,10 +1939,10 @@ void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
|||
url_skippingDlg << qurl;
|
||||
// Launch downloader thread
|
||||
downloader->downloadUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
// Add to Bittorrent session the downloaded torrent file
|
||||
void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
||||
// Add to Bittorrent session the downloaded torrent file
|
||||
void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
||||
int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit()));
|
||||
if(index < 0) {
|
||||
// Add file to torrent download list
|
||||
|
@ -1951,26 +1951,26 @@ void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
|||
url_skippingDlg.removeAt(index);
|
||||
addTorrent(file_path, false, url, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return current download rate for the BT
|
||||
// session. Payload means that it only take into
|
||||
// account "useful" part of the rate
|
||||
float Bittorrent::getPayloadDownloadRate() const{
|
||||
// Return current download rate for the BT
|
||||
// session. Payload means that it only take into
|
||||
// account "useful" part of the rate
|
||||
float Bittorrent::getPayloadDownloadRate() const{
|
||||
session_status sessionStatus = s->status();
|
||||
return sessionStatus.payload_download_rate;
|
||||
}
|
||||
}
|
||||
|
||||
// Return current upload rate for the BT
|
||||
// session. Payload means that it only take into
|
||||
// account "useful" part of the rate
|
||||
float Bittorrent::getPayloadUploadRate() const{
|
||||
// Return current upload rate for the BT
|
||||
// session. Payload means that it only take into
|
||||
// account "useful" part of the rate
|
||||
float Bittorrent::getPayloadUploadRate() const{
|
||||
session_status sessionStatus = s->status();
|
||||
return sessionStatus.payload_upload_rate;
|
||||
}
|
||||
}
|
||||
|
||||
// Save DHT entry to hard drive
|
||||
void Bittorrent::saveDHTEntry() {
|
||||
// Save DHT entry to hard drive
|
||||
void Bittorrent::saveDHTEntry() {
|
||||
// Save DHT entry
|
||||
if(DHTEnabled) {
|
||||
try{
|
||||
|
@ -1983,16 +1983,16 @@ void Bittorrent::saveDHTEntry() {
|
|||
std::cerr << e.what() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bittorrent::applyEncryptionSettings(pe_settings se) {
|
||||
void Bittorrent::applyEncryptionSettings(pe_settings se) {
|
||||
qDebug("Applying encryption settings");
|
||||
s->set_pe_settings(se);
|
||||
}
|
||||
}
|
||||
|
||||
// Will fast resume torrents in
|
||||
// backup directory
|
||||
void Bittorrent::startUpTorrents() {
|
||||
// Will fast resume torrents in
|
||||
// backup directory
|
||||
void Bittorrent::startUpTorrents() {
|
||||
qDebug("Resuming unfinished torrents");
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
QDir torrentBackup(misc::BTBackupLocation());
|
||||
|
@ -2053,11 +2053,11 @@ void Bittorrent::startUpTorrents() {
|
|||
}
|
||||
}
|
||||
qDebug("Unfinished torrents resumed");
|
||||
}
|
||||
}
|
||||
|
||||
// Import torrents temp data from v1.4.0 or earlier: save_path, filtered pieces
|
||||
// TODO: Remove in qBittorrent v2.2.0
|
||||
void Bittorrent::importOldTempData(QString torrent_path) {
|
||||
// Import torrents temp data from v1.4.0 or earlier: save_path, filtered pieces
|
||||
// TODO: Remove in qBittorrent v2.2.0
|
||||
void Bittorrent::importOldTempData(QString torrent_path) {
|
||||
// Create torrent hash
|
||||
boost::intrusive_ptr<torrent_info> t;
|
||||
try {
|
||||
|
@ -2103,11 +2103,11 @@ void Bittorrent::importOldTempData(QString torrent_path) {
|
|||
}
|
||||
} catch(std::exception&) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Trackers, web seeds, speed limits
|
||||
// TODO: Remove in qBittorrent v2.2.0
|
||||
void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
|
||||
// Trackers, web seeds, speed limits
|
||||
// TODO: Remove in qBittorrent v2.2.0
|
||||
void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
|
||||
// Load trackers
|
||||
QDir torrentBackup(misc::BTBackupLocation());
|
||||
QFile tracker_file(torrentBackup.path()+QDir::separator()+ h.hash() + ".trackers");
|
||||
|
@ -2172,11 +2172,11 @@ void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
|
|||
h.set_upload_limit(speeds.at(1).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Import torrents from v1.4.0 or earlier
|
||||
// TODO: Remove in qBittorrent v2.2.0
|
||||
void Bittorrent::importOldTorrents() {
|
||||
// Import torrents from v1.4.0 or earlier
|
||||
// TODO: Remove in qBittorrent v2.2.0
|
||||
void Bittorrent::importOldTorrents() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
Q_ASSERT(!settings.value("v1_4_x_torrent_imported", false).toBool());
|
||||
// Import old torrent
|
||||
|
@ -2252,4 +2252,4 @@ void Bittorrent::importOldTorrents() {
|
|||
}
|
||||
settings.setValue("v1_4_x_torrent_imported", true);
|
||||
std::cout << "Successfully imported torrents from v1.4.x (or previous) instance" << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
#include <QUrl>
|
||||
#include <QStringList>
|
||||
#ifdef DISABLE_GUI
|
||||
#include <QCoreApplication>
|
||||
#include <QCoreApplication>
|
||||
#else
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
#endif
|
||||
#include <QPointer>
|
||||
|
||||
|
|
50
src/main.cpp
50
src/main.cpp
|
@ -33,23 +33,23 @@
|
|||
#include <QFile>
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
#include <QApplication>
|
||||
#include <QSplashScreen>
|
||||
#include <QPlastiqueStyle>
|
||||
#include "qgnomelook.h"
|
||||
#include <QMotifStyle>
|
||||
#include <QCDEStyle>
|
||||
#ifdef Q_WS_WIN
|
||||
#include <QWindowsXPStyle>
|
||||
#endif
|
||||
#ifdef Q_WS_MAC
|
||||
#include <QMacStyle>
|
||||
#endif
|
||||
#include "GUI.h"
|
||||
#include "ico.h"
|
||||
#include <QApplication>
|
||||
#include <QSplashScreen>
|
||||
#include <QPlastiqueStyle>
|
||||
#include "qgnomelook.h"
|
||||
#include <QMotifStyle>
|
||||
#include <QCDEStyle>
|
||||
#ifdef Q_WS_WIN
|
||||
#include <QWindowsXPStyle>
|
||||
#endif
|
||||
#ifdef Q_WS_MAC
|
||||
#include <QMacStyle>
|
||||
#endif
|
||||
#include "GUI.h"
|
||||
#include "ico.h"
|
||||
#else
|
||||
#include <QCoreApplication>
|
||||
#include "headlessloader.h"
|
||||
#include <QCoreApplication>
|
||||
#include "headlessloader.h"
|
||||
#endif
|
||||
|
||||
#include <QSettings>
|
||||
|
@ -67,12 +67,17 @@
|
|||
#include "preferences.h"
|
||||
|
||||
#ifdef DISABLE_GUI
|
||||
QCoreApplication *app;
|
||||
QCoreApplication *app;
|
||||
#else
|
||||
QApplication *app;
|
||||
QApplication *app;
|
||||
#endif
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
void sigintHandler(int) {
|
||||
qDebug("Catching SIGINT, exiting cleanly");
|
||||
app->exit();
|
||||
}
|
||||
|
||||
void sigtermHandler(int) {
|
||||
qDebug("Catching SIGTERM, exiting cleanly");
|
||||
app->exit();
|
||||
|
@ -246,7 +251,7 @@ int main(int argc, char *argv[]){
|
|||
#ifndef Q_WS_WIN
|
||||
signal(SIGABRT, sigabrtHandler);
|
||||
signal(SIGTERM, sigtermHandler);
|
||||
signal(SIGINT, sigtermHandler);
|
||||
signal(SIGINT, sigintHandler);
|
||||
signal(SIGSEGV, sigsegvHandler);
|
||||
#endif
|
||||
// Read torrents given on command line
|
||||
|
@ -264,6 +269,13 @@ int main(int argc, char *argv[]){
|
|||
HeadlessLoader *loader = new HeadlessLoader(torrentCmdLine);
|
||||
#endif
|
||||
int ret = app->exec();
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
// Application has exited, stop catching SIGINT and SIGTERM
|
||||
signal(SIGINT, 0);
|
||||
signal(SIGTERM, 0);
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_GUI
|
||||
delete window;
|
||||
qDebug("GUI was deleted!");
|
||||
|
|
18
src/misc.h
18
src/misc.h
|
@ -47,9 +47,9 @@
|
|||
#include <boost/date_time/posix_time/conversion.hpp>
|
||||
|
||||
#ifdef DISABLE_GUI
|
||||
#include <QCoreApplication>
|
||||
#include <QCoreApplication>
|
||||
#else
|
||||
#include <QApplication>
|
||||
#include <QApplication>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
|
@ -183,16 +183,16 @@ public:
|
|||
}
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
static QString getFullPath(const FSRef &ref)
|
||||
{
|
||||
static QString getFullPath(const FSRef &ref)
|
||||
{
|
||||
QByteArray ba(2048, 0);
|
||||
if (FSRefMakePath(&ref, reinterpret_cast<UInt8 *>(ba.data()), ba.size()) == noErr)
|
||||
return QString::fromUtf8(ba).normalized(QString::NormalizationForm_C);
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static QString QDesktopServicesDataLocation() {
|
||||
static QString QDesktopServicesDataLocation() {
|
||||
#ifdef Q_WS_WIN
|
||||
#if defined Q_WS_WINCE
|
||||
if (SHGetSpecialFolderPath(0, path, CSIDL_APPDATA, FALSE))
|
||||
|
@ -221,9 +221,9 @@ static QString QDesktopServicesDataLocation() {
|
|||
return xdgDataHome;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static QString QDesktopServicesCacheLocation() {
|
||||
static QString QDesktopServicesCacheLocation() {
|
||||
#ifdef Q_WS_WIN
|
||||
return QDesktopServicesDataLocation() + QLatin1String("\\cache");
|
||||
#else
|
||||
|
@ -244,7 +244,7 @@ static QString QDesktopServicesCacheLocation() {
|
|||
return xdgCacheHome;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static QString searchEngineLocation() {
|
||||
QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue