mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-14 08:48:17 +00:00
Keep on cleaning up
This commit is contained in:
parent
7d0581a7a5
commit
a9be841d2d
@ -2020,7 +2020,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) {
|
else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) {
|
||||||
addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->message().c_str())), "red");
|
addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(misc::toQString(p->message())), "red");
|
||||||
//emit UPnPError(QString(p->msg().c_str()));
|
//emit UPnPError(QString(p->msg().c_str()));
|
||||||
}
|
}
|
||||||
else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) {
|
else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) {
|
||||||
@ -2112,15 +2112,15 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
}
|
}
|
||||||
if(appendLabelToSavePath) {
|
if(appendLabelToSavePath) {
|
||||||
qDebug("appendLabelToSavePath is true");
|
qDebug("appendLabelToSavePath is true");
|
||||||
QString label = TorrentTempData::getLabel(hash);
|
const QString &label = TorrentTempData::getLabel(hash);
|
||||||
if(!label.isEmpty()) {
|
if(!label.isEmpty()) {
|
||||||
QDir save_dir(savePath);
|
const QDir &save_dir(savePath);
|
||||||
if(save_dir.dirName() != label) {
|
if(save_dir.dirName() != label) {
|
||||||
savePath = save_dir.absoluteFilePath(label);
|
savePath = save_dir.absoluteFilePath(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug("getSavePath, got save_path from temp data: %s", savePath.toLocal8Bit().data());
|
qDebug("getSavePath, got save_path from temp data: %s", qPrintable(savePath));
|
||||||
} else {
|
} else {
|
||||||
savePath = TorrentPersistentData::getSavePath(hash);
|
savePath = TorrentPersistentData::getSavePath(hash);
|
||||||
if(savePath.isEmpty()) {
|
if(savePath.isEmpty()) {
|
||||||
@ -2130,7 +2130,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
savePath = defaultSavePath;
|
savePath = defaultSavePath;
|
||||||
}
|
}
|
||||||
if(!fromScanDir && appendLabelToSavePath) {
|
if(!fromScanDir && appendLabelToSavePath) {
|
||||||
QString label = TorrentPersistentData::getLabel(hash);
|
const QString &label = TorrentPersistentData::getLabel(hash);
|
||||||
if(!label.isEmpty()) {
|
if(!label.isEmpty()) {
|
||||||
QDir save_dir(savePath);
|
QDir save_dir(savePath);
|
||||||
if(save_dir.dirName() != label) {
|
if(save_dir.dirName() != label) {
|
||||||
@ -2138,7 +2138,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug("getSavePath, got save_path from persistent data: %s", savePath.toLocal8Bit().data());
|
qDebug("getSavePath, got save_path from persistent data: %s", qPrintable(savePath));
|
||||||
}
|
}
|
||||||
// Clean path
|
// Clean path
|
||||||
savePath = misc::expandPath(savePath);
|
savePath = misc::expandPath(savePath);
|
||||||
@ -2147,7 +2147,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
QDir saveDir(savePath);
|
QDir saveDir(savePath);
|
||||||
if(!saveDir.exists()) {
|
if(!saveDir.exists()) {
|
||||||
if(!saveDir.mkpath(saveDir.absolutePath())) {
|
if(!saveDir.mkpath(saveDir.absolutePath())) {
|
||||||
std::cerr << "Couldn't create the save directory: " << saveDir.path().toLocal8Bit().data() << "\n";
|
std::cerr << "Couldn't create the save directory: " << qPrintable(saveDir.path()) << "\n";
|
||||||
// XXX: Do something else?
|
// XXX: Do something else?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2180,7 +2180,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
|
|
||||||
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
void Bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
|
||||||
//emit aboutToDownloadFromUrl(url);
|
//emit aboutToDownloadFromUrl(url);
|
||||||
QUrl qurl = QUrl::fromEncoded(url.toLocal8Bit());
|
const QUrl &qurl = QUrl::fromEncoded(url.toLocal8Bit());
|
||||||
if(!save_path.isEmpty())
|
if(!save_path.isEmpty())
|
||||||
savepath_fromurl[qurl] = save_path;
|
savepath_fromurl[qurl] = save_path;
|
||||||
url_skippingDlg << qurl;
|
url_skippingDlg << qurl;
|
||||||
@ -2190,7 +2190,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
|
|
||||||
// Add to Bittorrent session the downloaded torrent file
|
// Add to Bittorrent session the downloaded torrent file
|
||||||
void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
void Bittorrent::processDownloadedFile(QString url, QString file_path) {
|
||||||
int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit()));
|
const int index = url_skippingDlg.indexOf(QUrl::fromEncoded(url.toLocal8Bit()));
|
||||||
if(index < 0) {
|
if(index < 0) {
|
||||||
// Add file to torrent download list
|
// Add file to torrent download list
|
||||||
emit newDownloadedTorrent(file_path, url);
|
emit newDownloadedTorrent(file_path, url);
|
||||||
@ -2204,7 +2204,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
// session. Payload means that it only take into
|
// session. Payload means that it only take into
|
||||||
// account "useful" part of the rate
|
// account "useful" part of the rate
|
||||||
float Bittorrent::getPayloadDownloadRate() const{
|
float Bittorrent::getPayloadDownloadRate() const{
|
||||||
session_status sessionStatus = s->status();
|
const session_status &sessionStatus = s->status();
|
||||||
return sessionStatus.payload_download_rate;
|
return sessionStatus.payload_download_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2212,7 +2212,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
// session. Payload means that it only take into
|
// session. Payload means that it only take into
|
||||||
// account "useful" part of the rate
|
// account "useful" part of the rate
|
||||||
float Bittorrent::getPayloadUploadRate() const{
|
float Bittorrent::getPayloadUploadRate() const{
|
||||||
session_status sessionStatus = s->status();
|
const session_status &sessionStatus = s->status();
|
||||||
return sessionStatus.payload_upload_rate;
|
return sessionStatus.payload_upload_rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2222,7 +2222,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
if(DHTEnabled) {
|
if(DHTEnabled) {
|
||||||
try{
|
try{
|
||||||
entry dht_state = s->dht_state();
|
entry dht_state = s->dht_state();
|
||||||
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state")).toLocal8Bit().data(), std::ios_base::binary);
|
boost::filesystem::ofstream out((misc::cacheLocation()+QDir::separator()+QString::fromUtf8("dht_state")).toLocal8Bit().constData(), std::ios_base::binary);
|
||||||
out.unsetf(std::ios_base::skipws);
|
out.unsetf(std::ios_base::skipws);
|
||||||
bencode(std::ostream_iterator<char>(out), dht_state);
|
bencode(std::ostream_iterator<char>(out), dht_state);
|
||||||
qDebug("DHT entry saved");
|
qDebug("DHT entry saved");
|
||||||
@ -2242,8 +2242,8 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
void Bittorrent::startUpTorrents() {
|
void Bittorrent::startUpTorrents() {
|
||||||
qDebug("Resuming unfinished torrents");
|
qDebug("Resuming unfinished torrents");
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
QDir torrentBackup(misc::BTBackupLocation());
|
const QDir &torrentBackup(misc::BTBackupLocation());
|
||||||
QStringList known_torrents = TorrentPersistentData::knownTorrents();
|
const QStringList &known_torrents = TorrentPersistentData::knownTorrents();
|
||||||
|
|
||||||
if(known_torrents.empty() && !settings.value("v1_4_x_torrent_imported", false).toBool()) {
|
if(known_torrents.empty() && !settings.value("v1_4_x_torrent_imported", false).toBool()) {
|
||||||
qDebug("No known torrent, importing old torrents");
|
qDebug("No known torrent, importing old torrents");
|
||||||
@ -2255,11 +2255,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
// we switch the v1.5 way of resuming torrents on startup
|
// we switch the v1.5 way of resuming torrents on startup
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "*.torrent";
|
filters << "*.torrent";
|
||||||
QStringList torrents_on_hd = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
const QStringList &torrents_on_hd = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
foreach(QString hash, torrents_on_hd) {
|
foreach(QString hash, torrents_on_hd) {
|
||||||
hash.chop(8); // remove trailing .torrent
|
hash.chop(8); // remove trailing .torrent
|
||||||
if(!known_torrents.contains(hash)) {
|
if(!known_torrents.contains(hash)) {
|
||||||
std::cerr << "ERROR Detected!!! Adding back torrent " << hash.toLocal8Bit().data() << " which got lost for some reason." << std::endl;
|
std::cerr << "ERROR Detected!!! Adding back torrent " << qPrintable(hash) << " which got lost for some reason." << std::endl;
|
||||||
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true);
|
addTorrent(torrentBackup.path()+QDir::separator()+hash+".torrent", false, QString(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2275,14 +2275,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
} else {
|
} else {
|
||||||
filePath = torrentBackup.path()+QDir::separator()+hash+".torrent";
|
filePath = torrentBackup.path()+QDir::separator()+hash+".torrent";
|
||||||
}
|
}
|
||||||
int prio = TorrentPersistentData::getPriority(hash);
|
const int prio = TorrentPersistentData::getPriority(hash);
|
||||||
misc::insertSort2<QString>(hashes, qMakePair(prio, hash));
|
misc::insertSort2<QString>(hashes, qMakePair(prio, hash));
|
||||||
}
|
}
|
||||||
// Resume downloads
|
// Resume downloads
|
||||||
QPair<int, QString> couple;
|
QPair<int, QString> couple;
|
||||||
foreach(couple, hashes) {
|
foreach(couple, hashes) {
|
||||||
QString hash = couple.second;
|
const QString &hash = couple.second;
|
||||||
qDebug("Starting up torrent %s", hash.toLocal8Bit().data());
|
qDebug("Starting up torrent %s", qPrintable(hash));
|
||||||
if(TorrentPersistentData::isMagnet(hash)) {
|
if(TorrentPersistentData::isMagnet(hash)) {
|
||||||
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
||||||
} else {
|
} else {
|
||||||
@ -2292,7 +2292,7 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
} else {
|
} else {
|
||||||
// Resume downloads
|
// Resume downloads
|
||||||
foreach(const QString &hash, known_torrents) {
|
foreach(const QString &hash, known_torrents) {
|
||||||
qDebug("Starting up torrent %s", hash.toLocal8Bit().data());
|
qDebug("Starting up torrent %s", qPrintable(hash));
|
||||||
if(TorrentPersistentData::isMagnet(hash))
|
if(TorrentPersistentData::isMagnet(hash))
|
||||||
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
addMagnetUri(TorrentPersistentData::getMagnetUri(hash), true);
|
||||||
else
|
else
|
||||||
@ -2306,10 +2306,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
// TODO: Remove in qBittorrent v2.2.0
|
// TODO: Remove in qBittorrent v2.2.0
|
||||||
void Bittorrent::importOldTempData(QString torrent_path) {
|
void Bittorrent::importOldTempData(QString torrent_path) {
|
||||||
// Create torrent hash
|
// Create torrent hash
|
||||||
boost::intrusive_ptr<torrent_info> t;
|
|
||||||
try {
|
try {
|
||||||
t = new torrent_info(torrent_path.toLocal8Bit().data());
|
boost::intrusive_ptr<torrent_info> t = new torrent_info(torrent_path.toLocal8Bit().data());
|
||||||
QString hash = misc::toQString(t->info_hash());
|
const QString &hash = misc::toQString(t->info_hash());
|
||||||
// Load save path
|
// Load save path
|
||||||
QFile savepath_file(misc::BTBackupLocation()+QDir::separator()+hash+".savepath");
|
QFile savepath_file(misc::BTBackupLocation()+QDir::separator()+hash+".savepath");
|
||||||
QByteArray line;
|
QByteArray line;
|
||||||
@ -2317,9 +2316,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(savepath_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
line = savepath_file.readAll();
|
line = savepath_file.readAll();
|
||||||
savepath_file.close();
|
savepath_file.close();
|
||||||
qDebug(" -> Save path: %s", line.data());
|
qDebug(" -> Save path: %s", line.constData());
|
||||||
savePath = QString::fromUtf8(line.data());
|
savePath = QString::fromUtf8(line.data());
|
||||||
qDebug("Imported the following save path: %s", savePath.toLocal8Bit().data());
|
qDebug("Imported the following save path: %s", qPrintable(savePath));
|
||||||
TorrentTempData::setSavePath(hash, savePath);
|
TorrentTempData::setSavePath(hash, savePath);
|
||||||
}
|
}
|
||||||
// Load pieces priority
|
// Load pieces priority
|
||||||
@ -2327,9 +2326,9 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
if(pieces_file.exists()){
|
if(pieces_file.exists()){
|
||||||
// Read saved file
|
// Read saved file
|
||||||
if(pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QByteArray pieces_priorities = pieces_file.readAll();
|
const QByteArray &pieces_priorities = pieces_file.readAll();
|
||||||
pieces_file.close();
|
pieces_file.close();
|
||||||
QList<QByteArray> pieces_priorities_list = pieces_priorities.split('\n');
|
const QList<QByteArray> &pieces_priorities_list = pieces_priorities.split('\n');
|
||||||
std::vector<int> pp;
|
std::vector<int> pp;
|
||||||
for(int i=0; i<t->num_files(); ++i) {
|
for(int i=0; i<t->num_files(); ++i) {
|
||||||
int priority = pieces_priorities_list.at(i).toInt();
|
int priority = pieces_priorities_list.at(i).toInt();
|
||||||
@ -2356,14 +2355,14 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
// TODO: Remove in qBittorrent v2.2.0
|
// TODO: Remove in qBittorrent v2.2.0
|
||||||
void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
|
void Bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
|
||||||
// Load trackers
|
// Load trackers
|
||||||
QDir torrentBackup(misc::BTBackupLocation());
|
const QDir &torrentBackup(misc::BTBackupLocation());
|
||||||
QFile tracker_file(torrentBackup.path()+QDir::separator()+ h.hash() + ".trackers");
|
QFile tracker_file(torrentBackup.path()+QDir::separator()+ h.hash() + ".trackers");
|
||||||
if(tracker_file.exists()) {
|
if(tracker_file.exists()) {
|
||||||
if(tracker_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(tracker_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QStringList lines = QString::fromUtf8(tracker_file.readAll().data()).split("\n");
|
const QStringList &lines = QString::fromUtf8(tracker_file.readAll().data()).split("\n");
|
||||||
std::vector<announce_entry> trackers;
|
std::vector<announce_entry> trackers;
|
||||||
foreach(const QString &line, lines) {
|
foreach(const QString &line, lines) {
|
||||||
QStringList parts = line.split("|");
|
const QStringList &parts = line.split("|");
|
||||||
if(parts.size() != 2) continue;
|
if(parts.size() != 2) continue;
|
||||||
announce_entry t(parts[0].toStdString());
|
announce_entry t(parts[0].toStdString());
|
||||||
t.tier = parts[1].toInt();
|
t.tier = parts[1].toInt();
|
||||||
@ -2379,13 +2378,13 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
QFile urlseeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".urlseeds");
|
QFile urlseeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".urlseeds");
|
||||||
if(urlseeds_file.exists()) {
|
if(urlseeds_file.exists()) {
|
||||||
if(urlseeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(urlseeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QByteArray urlseeds_lines = urlseeds_file.readAll();
|
const QByteArray &urlseeds_lines = urlseeds_file.readAll();
|
||||||
urlseeds_file.close();
|
urlseeds_file.close();
|
||||||
QList<QByteArray> url_seeds = urlseeds_lines.split('\n');
|
const QList<QByteArray> &url_seeds = urlseeds_lines.split('\n');
|
||||||
// First remove from the torrent the url seeds that were deleted
|
// First remove from the torrent the url seeds that were deleted
|
||||||
// in a previous session
|
// in a previous session
|
||||||
QStringList seeds_to_delete;
|
QStringList seeds_to_delete;
|
||||||
QStringList existing_seeds = h.url_seeds();
|
const QStringList &existing_seeds = h.url_seeds();
|
||||||
foreach(const QString &existing_seed, existing_seeds) {
|
foreach(const QString &existing_seed, existing_seeds) {
|
||||||
if(!url_seeds.contains(existing_seed.toLocal8Bit())) {
|
if(!url_seeds.contains(existing_seed.toLocal8Bit())) {
|
||||||
seeds_to_delete << existing_seed;
|
seeds_to_delete << existing_seed;
|
||||||
@ -2408,11 +2407,11 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
QFile speeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".speedLimits");
|
QFile speeds_file(misc::BTBackupLocation()+QDir::separator()+h.hash()+".speedLimits");
|
||||||
if(speeds_file.exists()) {
|
if(speeds_file.exists()) {
|
||||||
if(speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
QByteArray speed_limits = speeds_file.readAll();
|
const QByteArray &speed_limits = speeds_file.readAll();
|
||||||
speeds_file.close();
|
speeds_file.close();
|
||||||
QList<QByteArray> speeds = speed_limits.split(' ');
|
const QList<QByteArray> &speeds = speed_limits.split(' ');
|
||||||
if(speeds.size() != 2) {
|
if(speeds.size() != 2) {
|
||||||
std::cerr << "Invalid .speedLimits file for " << h.hash().toStdString() << '\n';
|
std::cerr << "Invalid .speedLimits file for " << qPrintable(h.hash()) << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
h.set_download_limit(speeds.at(0).toInt());
|
h.set_download_limit(speeds.at(0).toInt());
|
||||||
@ -2427,19 +2426,17 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
Q_ASSERT(!settings.value("v1_4_x_torrent_imported", false).toBool());
|
Q_ASSERT(!settings.value("v1_4_x_torrent_imported", false).toBool());
|
||||||
// Import old torrent
|
// Import old torrent
|
||||||
QDir torrentBackup(misc::BTBackupLocation());
|
const QDir &torrentBackup(misc::BTBackupLocation());
|
||||||
QStringList fileNames;
|
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "*.torrent";
|
filters << "*.torrent";
|
||||||
fileNames = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
const QStringList &fileNames = torrentBackup.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
if(isQueueingEnabled()) {
|
if(isQueueingEnabled()) {
|
||||||
QList<QPair<int, QString> > filePaths;
|
QList<QPair<int, QString> > filePaths;
|
||||||
foreach(const QString &fileName, fileNames) {
|
foreach(const QString &fileName, fileNames) {
|
||||||
QString filePath = torrentBackup.path()+QDir::separator()+fileName;
|
QString filePath = torrentBackup.path()+QDir::separator()+fileName;
|
||||||
int prio = 99999;
|
int prio = 99999;
|
||||||
// Get priority
|
// Get priority
|
||||||
QString prioPath = filePath;
|
const QString &prioPath = filePath.replace(".torrent", ".prio");
|
||||||
prioPath.replace(".torrent", ".prio");
|
|
||||||
if(QFile::exists(prioPath)) {
|
if(QFile::exists(prioPath)) {
|
||||||
QFile prio_file(prioPath);
|
QFile prio_file(prioPath);
|
||||||
if(prio_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if(prio_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
@ -2463,12 +2460,12 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
h.set_sequential_download(TorrentTempData::isSequential(h.hash()));
|
h.set_sequential_download(TorrentTempData::isSequential(h.hash()));
|
||||||
}
|
}
|
||||||
applyFormerAttributeFiles(h);
|
applyFormerAttributeFiles(h);
|
||||||
QString savePath = TorrentTempData::getSavePath(h.hash());
|
const QString &savePath = TorrentTempData::getSavePath(h.hash());
|
||||||
// Save persistent data for new torrent
|
// Save persistent data for new torrent
|
||||||
TorrentPersistentData::saveTorrentPersistentData(h);
|
TorrentPersistentData::saveTorrentPersistentData(h);
|
||||||
// Save save_path
|
// Save save_path
|
||||||
if(!defaultTempPath.isEmpty() && !savePath.isNull()) {
|
if(!defaultTempPath.isEmpty() && !savePath.isNull()) {
|
||||||
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data());
|
qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath));
|
||||||
TorrentPersistentData::saveSavePath(h.hash(), savePath);
|
TorrentPersistentData::saveSavePath(h.hash(), savePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2487,12 +2484,12 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
|||||||
h.set_sequential_download(TorrentTempData::isSequential(h.hash()));
|
h.set_sequential_download(TorrentTempData::isSequential(h.hash()));
|
||||||
}
|
}
|
||||||
applyFormerAttributeFiles(h);
|
applyFormerAttributeFiles(h);
|
||||||
QString savePath = TorrentTempData::getSavePath(h.hash());
|
const QString &savePath = TorrentTempData::getSavePath(h.hash());
|
||||||
// Save persistent data for new torrent
|
// Save persistent data for new torrent
|
||||||
TorrentPersistentData::saveTorrentPersistentData(h);
|
TorrentPersistentData::saveTorrentPersistentData(h);
|
||||||
// Save save_path
|
// Save save_path
|
||||||
if(!defaultTempPath.isEmpty() && !savePath.isNull()) {
|
if(!defaultTempPath.isEmpty() && !savePath.isNull()) {
|
||||||
qDebug("addTorrent: Saving save_path in persistent data: %s", savePath.toLocal8Bit().data());
|
qDebug("addTorrent: Saving save_path in persistent data: %s", qPrintable(savePath));
|
||||||
TorrentPersistentData::saveSavePath(h.hash(), savePath);
|
TorrentPersistentData::saveSavePath(h.hash(), savePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
113
src/bittorrent.h
113
src/bittorrent.h
@ -89,62 +89,6 @@ public:
|
|||||||
class Bittorrent : public QObject {
|
class Bittorrent : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
|
||||||
// Bittorrent
|
|
||||||
session *s;
|
|
||||||
QPointer<QTimer> timerAlerts;
|
|
||||||
QPointer<BandwidthScheduler> bd_scheduler;
|
|
||||||
QMap<QUrl, QString> savepath_fromurl;
|
|
||||||
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
|
||||||
QStringList torrentsToPausedAfterChecking;
|
|
||||||
// Ratio
|
|
||||||
QPointer<QTimer> BigRatioTimer;
|
|
||||||
// HTTP
|
|
||||||
QPointer<downloadThread> downloader;
|
|
||||||
// File System
|
|
||||||
ScanFoldersModel *m_scanFolders;
|
|
||||||
// Console / Log
|
|
||||||
QStringList consoleMessages;
|
|
||||||
QStringList peerBanMessages;
|
|
||||||
// Settings
|
|
||||||
bool preAllocateAll;
|
|
||||||
bool addInPause;
|
|
||||||
float ratio_limit;
|
|
||||||
bool UPnPEnabled;
|
|
||||||
bool NATPMPEnabled;
|
|
||||||
bool LSDEnabled;
|
|
||||||
bool DHTEnabled;
|
|
||||||
int current_dht_port;
|
|
||||||
bool PeXEnabled;
|
|
||||||
bool queueingEnabled;
|
|
||||||
bool appendLabelToSavePath;
|
|
||||||
bool torrentExport;
|
|
||||||
#ifdef LIBTORRENT_0_15
|
|
||||||
bool appendqBExtension;
|
|
||||||
#endif
|
|
||||||
QString defaultSavePath;
|
|
||||||
QString defaultTempPath;
|
|
||||||
// ETA Computation
|
|
||||||
QPointer<QTimer> timerETA;
|
|
||||||
QHash<QString, QList<int> > ETA_samples;
|
|
||||||
// IP filtering
|
|
||||||
QPointer<FilterParserThread> filterParser;
|
|
||||||
QString filterPath;
|
|
||||||
// Web UI
|
|
||||||
QPointer<HttpServer> httpServer;
|
|
||||||
QList<QUrl> url_skippingDlg;
|
|
||||||
// Fast exit (async)
|
|
||||||
bool exiting;
|
|
||||||
// GeoIP
|
|
||||||
#ifndef DISABLE_GUI
|
|
||||||
bool geoipDBLoaded;
|
|
||||||
bool resolve_countries;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString());
|
|
||||||
bool initWebUi(QString username, QString password, int port);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor / Destructor
|
// Constructor / Destructor
|
||||||
Bittorrent();
|
Bittorrent();
|
||||||
@ -241,6 +185,10 @@ public slots:
|
|||||||
void configureSession();
|
void configureSession();
|
||||||
void banIP(QString ip);
|
void banIP(QString ip);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString());
|
||||||
|
bool initWebUi(QString username, QString password, int port);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void addTorrentsFromScanFolder(QStringList&);
|
void addTorrentsFromScanFolder(QStringList&);
|
||||||
void readAlerts();
|
void readAlerts();
|
||||||
@ -265,6 +213,59 @@ signals:
|
|||||||
void savePathChanged(QTorrentHandle &h);
|
void savePathChanged(QTorrentHandle &h);
|
||||||
void newConsoleMessage(QString msg);
|
void newConsoleMessage(QString msg);
|
||||||
void alternativeSpeedsModeChanged(bool alternative);
|
void alternativeSpeedsModeChanged(bool alternative);
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Bittorrent
|
||||||
|
session *s;
|
||||||
|
QPointer<QTimer> timerAlerts;
|
||||||
|
QPointer<BandwidthScheduler> bd_scheduler;
|
||||||
|
QMap<QUrl, QString> savepath_fromurl;
|
||||||
|
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||||
|
QStringList torrentsToPausedAfterChecking;
|
||||||
|
// Ratio
|
||||||
|
QPointer<QTimer> BigRatioTimer;
|
||||||
|
// HTTP
|
||||||
|
QPointer<downloadThread> downloader;
|
||||||
|
// File System
|
||||||
|
ScanFoldersModel *m_scanFolders;
|
||||||
|
// Console / Log
|
||||||
|
QStringList consoleMessages;
|
||||||
|
QStringList peerBanMessages;
|
||||||
|
// Settings
|
||||||
|
bool preAllocateAll;
|
||||||
|
bool addInPause;
|
||||||
|
float ratio_limit;
|
||||||
|
bool UPnPEnabled;
|
||||||
|
bool NATPMPEnabled;
|
||||||
|
bool LSDEnabled;
|
||||||
|
bool DHTEnabled;
|
||||||
|
int current_dht_port;
|
||||||
|
bool PeXEnabled;
|
||||||
|
bool queueingEnabled;
|
||||||
|
bool appendLabelToSavePath;
|
||||||
|
bool torrentExport;
|
||||||
|
#ifdef LIBTORRENT_0_15
|
||||||
|
bool appendqBExtension;
|
||||||
|
#endif
|
||||||
|
QString defaultSavePath;
|
||||||
|
QString defaultTempPath;
|
||||||
|
// ETA Computation
|
||||||
|
QPointer<QTimer> timerETA;
|
||||||
|
QHash<QString, QList<int> > ETA_samples;
|
||||||
|
// IP filtering
|
||||||
|
QPointer<FilterParserThread> filterParser;
|
||||||
|
QString filterPath;
|
||||||
|
// Web UI
|
||||||
|
QPointer<HttpServer> httpServer;
|
||||||
|
QList<QUrl> url_skippingDlg;
|
||||||
|
// Fast exit (async)
|
||||||
|
bool exiting;
|
||||||
|
// GeoIP
|
||||||
|
#ifndef DISABLE_GUI
|
||||||
|
bool geoipDBLoaded;
|
||||||
|
bool resolve_countries;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
68
src/misc.h
68
src/misc.h
@ -138,22 +138,22 @@ public:
|
|||||||
if(!destDir.mkpath(destDir.absolutePath())) return;
|
if(!destDir.mkpath(destDir.absolutePath())) return;
|
||||||
}
|
}
|
||||||
// List source directory
|
// List source directory
|
||||||
QFileInfoList content = sourceDir.entryInfoList();
|
const QFileInfoList &content = sourceDir.entryInfoList();
|
||||||
foreach(const QFileInfo& child, content) {
|
foreach(const QFileInfo& child, content) {
|
||||||
if(child.fileName()[0] == '.') continue;
|
if(child.fileName()[0] == '.') continue;
|
||||||
if(child.isDir()) {
|
if(child.isDir()) {
|
||||||
copyDir(child.absoluteFilePath(), dst_path+QDir::separator()+QDir(child.absoluteFilePath()).dirName());
|
copyDir(child.absoluteFilePath(), dst_path+QDir::separator()+QDir(child.absoluteFilePath()).dirName());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QString src_child_path = child.absoluteFilePath();
|
const QString &src_child_path = child.absoluteFilePath();
|
||||||
QString dest_child_path = destDir.absoluteFilePath(child.fileName());
|
const QString &dest_child_path = destDir.absoluteFilePath(child.fileName());
|
||||||
// Copy the file from src to dest
|
// Copy the file from src to dest
|
||||||
QFile::copy(src_child_path, dest_child_path);
|
QFile::copy(src_child_path, dest_child_path);
|
||||||
// Remove source file
|
// Remove source file
|
||||||
QFile::remove(src_child_path);
|
QFile::remove(src_child_path);
|
||||||
}
|
}
|
||||||
// Remove source folder
|
// Remove source folder
|
||||||
QString dir_name = sourceDir.dirName();
|
const QString &dir_name = sourceDir.dirName();
|
||||||
if(sourceDir.cdUp()) {
|
if(sourceDir.cdUp()) {
|
||||||
sourceDir.rmdir(dir_name);
|
sourceDir.rmdir(dir_name);
|
||||||
}
|
}
|
||||||
@ -163,15 +163,15 @@ public:
|
|||||||
// For backward compatibility
|
// For backward compatibility
|
||||||
// Remove after some releases
|
// Remove after some releases
|
||||||
static void moveToXDGFolders() {
|
static void moveToXDGFolders() {
|
||||||
QString old_qBtPath = QDir::homePath()+QDir::separator()+QString::fromUtf8(".qbittorrent") + QDir::separator();
|
const QString &old_qBtPath = QDir::homePath()+QDir::separator()+QString::fromUtf8(".qbittorrent") + QDir::separator();
|
||||||
if(QDir(old_qBtPath).exists()) {
|
if(QDir(old_qBtPath).exists()) {
|
||||||
// Copy BT_backup folder
|
// Copy BT_backup folder
|
||||||
QString old_BTBackupPath = old_qBtPath + "BT_backup";
|
const QString &old_BTBackupPath = old_qBtPath + "BT_backup";
|
||||||
if(QDir(old_BTBackupPath).exists()) {
|
if(QDir(old_BTBackupPath).exists()) {
|
||||||
copyDir(old_BTBackupPath, BTBackupLocation());
|
copyDir(old_BTBackupPath, BTBackupLocation());
|
||||||
}
|
}
|
||||||
// Copy search engine folder
|
// Copy search engine folder
|
||||||
QString old_searchPath = old_qBtPath + "search_engine";
|
const QString &old_searchPath = old_qBtPath + "search_engine";
|
||||||
if(QDir(old_searchPath).exists()) {
|
if(QDir(old_searchPath).exists()) {
|
||||||
copyDir(old_searchPath, searchEngineLocation());
|
copyDir(old_searchPath, searchEngineLocation());
|
||||||
}
|
}
|
||||||
@ -190,23 +190,25 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QString toValidFileSystemName(QString filename) {
|
static QString toValidFileSystemName(QString filename) {
|
||||||
qDebug("toValidFSName: %s", filename.toLocal8Bit().data());
|
qDebug("toValidFSName: %s", qPrintable(filename));
|
||||||
filename = filename.replace("\\", "/").trimmed();
|
filename = filename.replace("\\", "/").trimmed();
|
||||||
QRegExp regex("[/:?\"*<>|]");
|
const QRegExp regex("[/:?\"*<>|]");
|
||||||
filename = filename.replace(regex, " ").trimmed();
|
filename = filename.replace(regex, " ").trimmed();
|
||||||
qDebug("toValidFSName, result: %s", filename.toLocal8Bit().data());
|
qDebug("toValidFSName, result: %s", qPrintable(filename));
|
||||||
return filename;
|
return filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isValidFileSystemName(QString filename) {
|
static bool isValidFileSystemName(QString filename) {
|
||||||
filename = filename.replace("\\", "/").trimmed();
|
filename = filename.replace("\\", "/").trimmed();
|
||||||
if(filename.isEmpty()) return false;
|
if(filename.isEmpty()) return false;
|
||||||
QRegExp regex("[/:?\"*<>|]");
|
const QRegExp regex("[/:?\"*<>|]");
|
||||||
if(filename.contains(regex))
|
if(filename.contains(regex))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ported from Qt4 to drop dependency on QtGui */
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
static QString getFullPath(const FSRef &ref)
|
static QString getFullPath(const FSRef &ref)
|
||||||
{
|
{
|
||||||
@ -271,11 +273,13 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* End of Qt4 code */
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
// Get screen center
|
// Get screen center
|
||||||
static QPoint screenCenter(QWidget *win) {
|
static QPoint screenCenter(QWidget *win) {
|
||||||
int scrn = 0;
|
int scrn = 0;
|
||||||
QWidget *w = win->window();
|
const QWidget *w = win->window();
|
||||||
|
|
||||||
if(w)
|
if(w)
|
||||||
scrn = QApplication::desktop()->screenNumber(w);
|
scrn = QApplication::desktop()->screenNumber(w);
|
||||||
@ -290,7 +294,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static QString searchEngineLocation() {
|
static QString searchEngineLocation() {
|
||||||
QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
const QString &location = QDir::cleanPath(QDesktopServicesDataLocation()
|
||||||
+ QDir::separator() + "search_engine");
|
+ QDir::separator() + "search_engine");
|
||||||
QDir locationDir(location);
|
QDir locationDir(location);
|
||||||
if(!locationDir.exists())
|
if(!locationDir.exists())
|
||||||
@ -299,7 +303,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QString BTBackupLocation() {
|
static QString BTBackupLocation() {
|
||||||
QString location = QDir::cleanPath(QDesktopServicesDataLocation()
|
const QString &location = QDir::cleanPath(QDesktopServicesDataLocation()
|
||||||
+ QDir::separator() + "BT_backup");
|
+ QDir::separator() + "BT_backup");
|
||||||
QDir locationDir(location);
|
QDir locationDir(location);
|
||||||
if(!locationDir.exists())
|
if(!locationDir.exists())
|
||||||
@ -308,7 +312,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QString cacheLocation() {
|
static QString cacheLocation() {
|
||||||
QString location = QDir::cleanPath(QDesktopServicesCacheLocation());
|
const QString &location = QDir::cleanPath(QDesktopServicesCacheLocation());
|
||||||
QDir locationDir(location);
|
QDir locationDir(location);
|
||||||
if(!locationDir.exists())
|
if(!locationDir.exists())
|
||||||
locationDir.mkpath(locationDir.absolutePath());
|
locationDir.mkpath(locationDir.absolutePath());
|
||||||
@ -325,7 +329,7 @@ public:
|
|||||||
#ifndef Q_WS_WIN
|
#ifndef Q_WS_WIN
|
||||||
unsigned long long available;
|
unsigned long long available;
|
||||||
struct statfs stats;
|
struct statfs stats;
|
||||||
int ret = statfs ((dir_path.path()+"/.").toLocal8Bit().data(), &stats) ;
|
const int ret = statfs ((dir_path.path()+"/.").toLocal8Bit().data(), &stats) ;
|
||||||
if(ret == 0) {
|
if(ret == 0) {
|
||||||
available = ((unsigned long long)stats.f_bavail) *
|
available = ((unsigned long long)stats.f_bavail) *
|
||||||
((unsigned long long)stats.f_bsize) ;
|
((unsigned long long)stats.f_bsize) ;
|
||||||
@ -371,7 +375,7 @@ public:
|
|||||||
char i = 0;
|
char i = 0;
|
||||||
while(val >= 1024. && i++<6)
|
while(val >= 1024. && i++<6)
|
||||||
val /= 1024.;
|
val /= 1024.;
|
||||||
return QString(QByteArray::number(val, 'f', 1)) + " " + units[(int)i];
|
return QString::number(val, 'f', 1) + " " + units[(int)i];
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isPreviewable(QString extension){
|
static bool isPreviewable(QString extension){
|
||||||
@ -451,7 +455,7 @@ public:
|
|||||||
|
|
||||||
// Can't use template class for QString because >,< use unicode code for sorting
|
// Can't use template class for QString because >,< use unicode code for sorting
|
||||||
// which is not what a human would expect when sorting strings.
|
// which is not what a human would expect when sorting strings.
|
||||||
static void insertSortString(QList<QPair<int, QString> > &list, QPair<int, QString> value, Qt::SortOrder sortOrder) {
|
static void insertSortString(QList<QPair<int, QString> > &list, const QPair<int, QString> &value, Qt::SortOrder sortOrder) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
if(sortOrder == Qt::AscendingOrder) {
|
if(sortOrder == Qt::AscendingOrder) {
|
||||||
while(i < list.size() and QString::localeAwareCompare(value.second, list.at(i).second) > 0) {
|
while(i < list.size() and QString::localeAwareCompare(value.second, list.at(i).second) > 0) {
|
||||||
@ -467,11 +471,11 @@ public:
|
|||||||
|
|
||||||
static bool removeEmptyTree(QString path) {
|
static bool removeEmptyTree(QString path) {
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
foreach(QString child, dir.entryList(QDir::AllDirs)) {
|
foreach(const QString &child, dir.entryList(QDir::AllDirs)) {
|
||||||
if(child == "." || child == "..") continue;
|
if(child == "." || child == "..") continue;
|
||||||
return removeEmptyTree(dir.absoluteFilePath(child));
|
return removeEmptyTree(dir.absoluteFilePath(child));
|
||||||
}
|
}
|
||||||
QString dir_name = dir.dirName();
|
const QString &dir_name = dir.dirName();
|
||||||
if(dir.cdUp()) {
|
if(dir.cdUp()) {
|
||||||
return dir.rmdir(dir_name);
|
return dir.rmdir(dir_name);
|
||||||
}
|
}
|
||||||
@ -480,10 +484,10 @@ public:
|
|||||||
|
|
||||||
static QString magnetUriToName(QString magnet_uri) {
|
static QString magnetUriToName(QString magnet_uri) {
|
||||||
QString name = "";
|
QString name = "";
|
||||||
QRegExp regHex("dn=([^&]+)");
|
const QRegExp regHex("dn=([^&]+)");
|
||||||
int pos = regHex.indexIn(magnet_uri);
|
const int pos = regHex.indexIn(magnet_uri);
|
||||||
if(pos > -1) {
|
if(pos > -1) {
|
||||||
QString found = regHex.cap(1);
|
const QString &found = regHex.cap(1);
|
||||||
// URL decode
|
// URL decode
|
||||||
name = QUrl::fromPercentEncoding(found.toLocal8Bit()).replace("+", " ");
|
name = QUrl::fromPercentEncoding(found.toLocal8Bit()).replace("+", " ");
|
||||||
}
|
}
|
||||||
@ -492,32 +496,32 @@ public:
|
|||||||
|
|
||||||
static QString magnetUriToHash(QString magnet_uri) {
|
static QString magnetUriToHash(QString magnet_uri) {
|
||||||
QString hash = "";
|
QString hash = "";
|
||||||
QRegExp regHex("urn:btih:([0-9A-Za-z]+)");
|
const QRegExp regHex("urn:btih:([0-9A-Za-z]+)");
|
||||||
// Hex
|
// Hex
|
||||||
int pos = regHex.indexIn(magnet_uri);
|
int pos = regHex.indexIn(magnet_uri);
|
||||||
if(pos > -1) {
|
if(pos > -1) {
|
||||||
QString found = regHex.cap(1);
|
const QString &found = regHex.cap(1);
|
||||||
if(found.length() == 40) {
|
if(found.length() == 40) {
|
||||||
sha1_hash sha1(QString(QByteArray::fromHex(regHex.cap(1).toLocal8Bit())).toStdString());
|
const sha1_hash sha1(QString(QByteArray::fromHex(regHex.cap(1).toLocal8Bit())).toStdString());
|
||||||
qDebug("magnetUriToHash (Hex): hash: %s", sha1.to_string().c_str());
|
qDebug("magnetUriToHash (Hex): hash: %s", qPrintable(misc::toQString(sha1)));
|
||||||
return misc::toQString(sha1);
|
return misc::toQString(sha1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Base 32
|
// Base 32
|
||||||
QRegExp regBase32("urn:btih:([A-Za-z2-7=]+)");
|
const QRegExp regBase32("urn:btih:([A-Za-z2-7=]+)");
|
||||||
pos = regBase32.indexIn(magnet_uri);
|
pos = regBase32.indexIn(magnet_uri);
|
||||||
if(pos > -1) {
|
if(pos > -1) {
|
||||||
QString found = regBase32.cap(1);
|
const QString &found = regBase32.cap(1);
|
||||||
if(found.length() > 20 && (found.length()*5)%40 == 0) {
|
if(found.length() > 20 && (found.length()*5)%40 == 0) {
|
||||||
sha1_hash sha1(base32decode(regBase32.cap(1).toStdString()));
|
const sha1_hash sha1(base32decode(regBase32.cap(1).toStdString()));
|
||||||
hash = misc::toQString(sha1);
|
hash = misc::toQString(sha1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qDebug("magnetUriToHash (base32): hash: %s", hash.toLocal8Bit().data());
|
qDebug("magnetUriToHash (base32): hash: %s", qPrintable(hash));
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString boostTimeToQString(boost::optional<boost::posix_time::ptime> boostDate) {
|
static QString boostTimeToQString(const boost::optional<boost::posix_time::ptime> boostDate) {
|
||||||
if(!boostDate) return tr("Unknown");
|
if(!boostDate) return tr("Unknown");
|
||||||
struct std::tm tm = boost::posix_time::to_tm(*boostDate);
|
struct std::tm tm = boost::posix_time::to_tm(*boostDate);
|
||||||
return QDateTime::fromTime_t(mktime(&tm)).toString(Qt::DefaultLocaleLongDate);
|
return QDateTime::fromTime_t(mktime(&tm)).toString(Qt::DefaultLocaleLongDate);
|
||||||
|
Loading…
Reference in New Issue
Block a user