mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 13:48:05 -06:00
Initial port to libtorrent v0.16
This commit is contained in:
@@ -103,24 +103,19 @@ QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
|
||||
std::vector<int> priorities = h.file_priorities();
|
||||
std::vector<size_type> fp;
|
||||
h.file_progress(fp);
|
||||
torrent_info t = h.get_torrent_info();
|
||||
torrent_info::file_iterator fi;
|
||||
int i=0;
|
||||
for(fi=t.begin_files(); fi != t.end_files(); fi++) {
|
||||
for(int i=0; i<h.num_files(); ++i) {
|
||||
QVariantMap file;
|
||||
QString path = h.filepath(*fi);
|
||||
QString name = misc::fileName(path);
|
||||
file["name"] = name;
|
||||
file["size"] = misc::friendlyUnit((double)fi->size);
|
||||
if(fi->size > 0)
|
||||
file["progress"] = fp[i]/(double)fi->size;
|
||||
file["name"] = h.filename_at(i);
|
||||
libtorrent::size_type size = h.filesize_at(i);
|
||||
file["size"] = misc::friendlyUnit((double)size);
|
||||
if(size > 0)
|
||||
file["progress"] = fp[i]/(double)size;
|
||||
else
|
||||
file["progress"] = 1.; // Empty file...
|
||||
file["priority"] = priorities[i];
|
||||
if(i == 0)
|
||||
file["is_seed"] = h.is_seed();
|
||||
files << file;
|
||||
++i;
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
@@ -451,13 +451,21 @@ void HttpConnection::respondCommand(QString command)
|
||||
if(command == "getGlobalUpLimit") {
|
||||
generator.setStatusLine(200, "OK");
|
||||
generator.setContentTypeByExt("html");
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
generator.setMessage(QString::number(QBtSession::instance()->getSession()->settings().upload_rate_limit));
|
||||
#else
|
||||
generator.setMessage(QString::number(QBtSession::instance()->getSession()->upload_rate_limit()));
|
||||
#endif
|
||||
write();
|
||||
}
|
||||
if(command == "getGlobalDlLimit") {
|
||||
generator.setStatusLine(200, "OK");
|
||||
generator.setContentTypeByExt("html");
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
generator.setMessage(QString::number(QBtSession::instance()->getSession()->settings().download_rate_limit));
|
||||
#else
|
||||
generator.setMessage(QString::number(QBtSession::instance()->getSession()->download_rate_limit()));
|
||||
#endif
|
||||
write();
|
||||
}
|
||||
if(command == "getTorrentUpLimit") {
|
||||
@@ -501,13 +509,13 @@ void HttpConnection::respondCommand(QString command)
|
||||
if(command == "setGlobalUpLimit") {
|
||||
qlonglong limit = parser.post("limit").toLongLong();
|
||||
if(limit == 0) limit = -1;
|
||||
QBtSession::instance()->getSession()->set_upload_rate_limit(limit);
|
||||
QBtSession::instance()->setUploadRateLimit(limit);
|
||||
Preferences().setGlobalUploadLimit(limit/1024.);
|
||||
}
|
||||
if(command == "setGlobalDlLimit") {
|
||||
qlonglong limit = parser.post("limit").toLongLong();
|
||||
if(limit == 0) limit = -1;
|
||||
QBtSession::instance()->getSession()->set_download_rate_limit(limit);
|
||||
QBtSession::instance()->setDownloadRateLimit(limit);
|
||||
Preferences().setGlobalDownloadLimit(limit/1024.);
|
||||
}
|
||||
if(command == "pause") {
|
||||
|
||||
Reference in New Issue
Block a user