1 Index: src/qtorrenthandle.h
2 ===================================================================
3 --- src/qtorrenthandle.h (revision 2069)
4 +++ src/qtorrenthandle.h (revision 2070)
8 float progress() const;
9 - const std::vector<bool>* pieces() const;
10 + bitfield pieces() const;
11 void get_download_queue(std::vector<partial_piece_info>& queue) const;
12 QString current_tracker() const;
13 bool is_valid() const;
15 int upload_limit() const;
16 int num_files() const;
17 bool has_metadata() const;
18 - entry write_resume_data() const;
19 + void save_resume_data() const;
20 QString file_at(unsigned int index) const;
21 size_type filesize_at(unsigned int index) const;
22 std::vector<announce_entry> const& trackers() const;
24 QString creator() const;
25 QString comment() const;
26 size_type total_failed_bytes() const;
27 - void file_progress(std::vector<float>& fp);
28 + void file_progress(std::vector<size_type>& fp);
29 size_type total_payload_download();
30 size_type total_payload_upload();
31 QStringList files_path() const;
33 void set_ratio(float ratio) const;
34 void replace_trackers(std::vector<announce_entry> const&) const;
35 void force_reannounce();
36 - void set_sequenced_download_threshold(int val);
37 + void set_sequential_download(bool);
38 void set_tracker_login(QString username, QString password);
41 Index: src/arborescence.h
42 ===================================================================
43 --- src/arborescence.h (revision 2069)
44 +++ src/arborescence.h (revision 2070)
49 - arborescence(torrent_info t) {
50 - torrent_info::file_iterator fi = t.begin_files();
51 - if(t.num_files() > 1) {
52 - root = new torrent_file(0, misc::toQString(t.name()), true);
53 + arborescence(boost::intrusive_ptr<torrent_info> t) {
54 + torrent_info::file_iterator fi = t->begin_files();
55 + if(t->num_files() > 1) {
56 + root = new torrent_file(0, misc::toQString(t->name()), true);
58 // XXX: Will crash if there is no file in torrent
59 - root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0);
60 + root = new torrent_file(0, misc::toQString(t->name()), false, fi->size, 0);
64 - while(fi != t.end_files()) {
65 + while(fi != t->end_files()) {
66 QString path = QDir::cleanPath(misc::toQString(fi->path.string()));
67 addFile(path, fi->size, i);
71 - qDebug("real size: %ld, tree size: %ld", (long)t.total_size(), (long)root->getSize());
72 - Q_ASSERT(root->getSize() == t.total_size());
73 + qDebug("real size: %ld, tree size: %ld", (long)t->total_size(), (long)root->getSize());
74 + Q_ASSERT(root->getSize() == t->total_size());
77 - arborescence(torrent_info t, std::vector<float> fp, int *prioritiesTab) {
78 + arborescence(torrent_info const& t, std::vector<size_type> fp, int *prioritiesTab) {
79 torrent_info::file_iterator fi = t.begin_files();
80 if(t.num_files() > 1) {
81 qDebug("More than one file in the torrent, setting a folder as root");
84 // XXX: Will crash if there is no file in torrent
85 qDebug("one file in the torrent, setting it as root with index 0");
86 - root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0], prioritiesTab[0]);
87 + root = new torrent_file(0, misc::toQString(t.name()), false, fi->size, 0, fp[0]/t.file_at(0).size, prioritiesTab[0]);
91 while(fi != t.end_files()) {
92 QString path = QDir::cleanPath(misc::toQString(fi->path.string()));
93 - addFile(path, fi->size, i, fp[i], prioritiesTab[i]);
94 + addFile(path, fi->size, i, fp[i]/t.file_at(i).size, prioritiesTab[i]);
98 Index: src/properties_imp.cpp
99 ===================================================================
100 --- src/properties_imp.cpp (revision 2069)
101 +++ src/properties_imp.cpp (revision 2070)
105 shareRatio->setText(QString(QByteArray::number(ratio, 'f', 1)));
106 - std::vector<float> fp;
107 + std::vector<size_type> fp;
109 int *prioritiesTab = loadPiecesPriorities();
110 // List files in torrent
111 @@ -669,11 +669,11 @@
112 QFile incremental_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".incremental"));
113 incremental_file.open(QIODevice::WriteOnly | QIODevice::Text);
114 incremental_file.close();
115 - h.set_sequenced_download_threshold(1);
116 + h.set_sequential_download(true);
119 QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental");
120 - h.set_sequenced_download_threshold(100); // Disabled
121 + h.set_sequential_download(false);
125 Index: src/eventmanager.cpp
126 ===================================================================
127 --- src/eventmanager.cpp (revision 2069)
128 +++ src/eventmanager.cpp (revision 2070)
130 case torrent_status::queued_for_checking:
131 event["state"] = QVariant("checking");
133 - case torrent_status::connecting_to_tracker:
134 - if(h.download_payload_rate() > 0)
135 - event["state"] = QVariant("downloading");
137 - event["state"] = QVariant("connecting");
139 case torrent_status::downloading:
140 case torrent_status::downloading_metadata:
141 if(h.download_payload_rate() > 0)
143 case torrent_status::queued_for_checking:
144 event["state"] = QVariant("checking");
146 - case torrent_status::connecting_to_tracker:
147 - if(h.download_payload_rate() > 0)
148 - event["state"] = QVariant("downloading");
150 - event["state"] = QVariant("connecting");
152 case torrent_status::downloading:
153 case torrent_status::downloading_metadata:
154 if(h.download_payload_rate() > 0)
155 Index: src/previewSelect.h
156 ===================================================================
157 --- src/previewSelect.h (revision 2069)
158 +++ src/previewSelect.h (revision 2070)
160 previewList->setItemDelegate(listDelegate);
161 previewList->header()->resizeSection(0, 200);
163 - std::vector<float> fp;
164 + std::vector<size_type> fp;
166 unsigned int nbFiles = h.num_files();
167 for(unsigned int i=0; i<nbFiles; ++i){
169 previewListModel->insertRow(row);
170 previewListModel->setData(previewListModel->index(row, NAME), QVariant(fileName));
171 previewListModel->setData(previewListModel->index(row, SIZE), QVariant((qlonglong)h.filesize_at(i)));
172 - previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i]));
173 + previewListModel->setData(previewListModel->index(row, PROGRESS), QVariant((double)fp[i]/h.filesize_at(i)));
177 Index: src/Icons/skin/connecting.png
178 ===================================================================
179 Cannot display: file marked as a binary type.
180 svn:mime-type = application/octet-stream
181 Index: src/webui/scripts/client.js
182 ===================================================================
183 --- src/webui/scripts/client.js (revision 2069)
184 +++ src/webui/scripts/client.js (revision 2070)
186 return '<img src="images/time.png"/>';
188 return '<img src="images/skin/downloading.png"/>';
190 - return '<img src="images/skin/connecting.png"/>';
192 return '<img src="images/skin/stalled.png"/>';
194 Index: src/bittorrent.cpp
195 ===================================================================
196 --- src/bittorrent.cpp (revision 2069)
197 +++ src/bittorrent.cpp (revision 2070)
199 #include "bittorrent.h"
201 #include "downloadThread.h"
202 -#include "deleteThread.h"
203 #include "filterParserThread.h"
205 #include <libtorrent/extensions/metadata_transfer.hpp>
207 s = new session(fingerprint("qB", VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, 0));
209 // Set severity level of libtorrent session
210 - s->set_severity_level(alert::info);
211 + s->set_alert_mask(alert::error_notification|alert::peer_notification|alert::port_mapping_notification|alert::storage_notification|alert::tracker_notification|alert::status_notification|alert::ip_block_notification);
212 // Enabling metadata plugin
213 s->add_extension(&create_metadata_plugin);
214 timerAlerts = new QTimer();
216 downloader = new downloadThread(this);
217 connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processDownloadedFile(QString, QString)));
218 connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString)));
219 - // File deleter (thread)
220 - deleter = new deleteThread(this);
225 // Disable directory scanning
226 disableDirectoryScanning();
227 // Delete our objects
229 delete fastResumeSaver;
234 qDebug("PreAllocateAll changed, reloading all torrents!");
236 - // Reload All unfinished torrents
238 - foreach(hash, unfinishedTorrents) {
239 - QTorrentHandle h = getTorrentHandle(hash);
240 - if(!h.is_valid()) {
241 - qDebug("/!\\ Error: Invalid handle");
244 - reloadTorrent(h, b);
250 QTorrentHandle h = getTorrentHandle(hash);
251 if(!h.is_valid()) return -1;
253 - case torrent_status::downloading:
254 - case torrent_status::connecting_to_tracker: {
255 + case torrent_status::downloading: {
256 if(!TorrentsStartTime.contains(hash)) return -1;
257 int timeElapsed = TorrentsStartTime.value(hash).secsTo(QDateTime::currentDateTime());
259 @@ -614,12 +599,11 @@
261 QString savePath = h.save_path();
262 QString fileName = h.name();
263 - arborescence *files_arb = 0;
265 - files_arb = new arborescence(h.get_torrent_info());
267 // Remove it from session
268 - s->remove_torrent(h.get_torrent_handle());
270 + s->remove_torrent(h.get_torrent_handle(), session::delete_files);
272 + s->remove_torrent(h.get_torrent_handle());
273 // Remove it from torrent backup directory
274 QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
277 QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".prio");
278 if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued"))
279 QFile::remove(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".queued");
280 - if(permanent && files_arb != 0) {
281 - // Remove from Hard drive
282 - qDebug("Removing this on hard drive: %s", qPrintable(savePath+QDir::separator()+fileName));
283 - // Deleting in a thread to avoid GUI freeze
284 - deleter->deleteTorrent(savePath, files_arb);
287 addConsoleMessage(tr("'%1' was removed permanently.", "'xxx.avi' was removed permanently.").arg(fileName));
290 // Add a torrent to the bittorrent session
291 void bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) {
294 bool fastResume=false;
295 QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
296 QString file, dest_file, scan_dir;
297 @@ -914,203 +891,164 @@
299 Q_ASSERT(!file.startsWith("http://", Qt::CaseInsensitive) && !file.startsWith("https://", Qt::CaseInsensitive) && !file.startsWith("ftp://", Qt::CaseInsensitive));
300 qDebug("Adding %s to download list", file.toUtf8().data());
301 - std::ifstream in(file.toUtf8().data(), std::ios_base::binary);
302 - in.unsetf(std::ios_base::skipws);
304 - // Decode torrent file
305 - entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
306 - // Getting torrent file informations
307 - boost::intrusive_ptr<torrent_info> t(new torrent_info(e));
308 - qDebug(" -> Hash: %s", misc::toString(t->info_hash()).c_str());
309 - qDebug(" -> Name: %s", t->name().c_str());
310 - QString hash = misc::toQString(t->info_hash());
311 - if(file.startsWith(torrentBackup.path())) {
312 + boost::intrusive_ptr<torrent_info> t;
314 + // Getting torrent file informations
315 + t = new torrent_info(file.toUtf8().data());
316 + } catch(std::exception&) {
317 + if(!from_url.isNull()) {
318 + addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
319 + //emit invalidTorrent(from_url);
320 + QFile::remove(file);
322 + addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
323 + //emit invalidTorrent(file);
325 + addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
327 + // Remove .corrupt file in case it already exists
328 + QFile::remove(file+".corrupt");
329 + //Rename file extension so that it won't display error message more than once
330 + QFile::rename(file,file+".corrupt");
333 + qDebug(" -> Hash: %s", misc::toString(t->info_hash()).c_str());
334 + qDebug(" -> Name: %s", t->name().c_str());
335 + QString hash = misc::toQString(t->info_hash());
336 + if(file.startsWith(torrentBackup.path())) {
338 QString old_hash = fi.baseName();
339 if(old_hash != hash){
340 - qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
341 + qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
344 - if(s->find_torrent(t->info_hash()).is_valid()) {
346 + // Check if torrent is already in download list
347 + if(s->find_torrent(t->info_hash()).is_valid()) {
348 qDebug("/!\\ Torrent is already in download list");
351 - if(!from_url.isNull()) {
352 - // If download from url, remove temp file
353 - QFile::remove(file);
354 - addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url));
355 - //emit duplicateTorrent(from_url);
357 - addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(file));
358 - //emit duplicateTorrent(file);
360 + if(!from_url.isNull()) {
361 + // If download from url, remove temp file
362 + QFile::remove(file);
363 + addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(from_url));
364 + //emit duplicateTorrent(from_url);
366 + addConsoleMessage(tr("'%1' is already in download list.", "e.g: 'xxx.avi' is already in download list.").arg(file));
367 + //emit duplicateTorrent(file);
370 - // Delete torrent from scan dir
371 - QFile::remove(file);
372 + // Delete torrent from scan dir
373 + QFile::remove(file);
377 - //Getting fast resume data if existing
378 - if(torrentBackup.exists(hash+".fastresume")) {
380 - std::stringstream strStream;
381 - strStream << hash.toStdString() << ".fastresume";
382 - boost::filesystem::ifstream resume_file(fs::path(torrentBackup.path().toUtf8().data()) / strStream.str(), std::ios_base::binary);
383 - resume_file.unsetf(std::ios_base::skipws);
384 - resume_data = bdecode(std::istream_iterator<char>(resume_file), std::istream_iterator<char>());
386 - }catch (invalid_encoding&) {}
387 - catch (fs::filesystem_error&) {}
389 - QString savePath = getSavePath(hash);
390 - // Save save_path to hard drive
391 - QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
392 - if(!savepath_file.exists()) {
394 + add_torrent_params p;
395 + //Getting fast resume data if existing
396 + std::vector<char> buf;
397 + if (load_file((torrentBackup.path()+hash+QString(".fastresume")).toUtf8().data(), buf) == 0) {
399 + p.resume_data = &buf;
401 + QString savePath = getSavePath(hash);
402 + // Save save_path to hard drive
403 + QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
404 + if(!savepath_file.exists()) {
405 savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
406 savepath_file.write(savePath.toUtf8());
407 savepath_file.close();
409 - // Adding files to bittorrent session
410 - if(preAllocateAll) {
411 - h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_allocate, true);
412 - qDebug(" -> Full allocation mode");
414 - h = s->add_torrent(t, fs::path(savePath.toUtf8().data()), resume_data, storage_mode_sparse, true);
415 - qDebug(" -> Sparse allocation mode");
417 - if(!h.is_valid()) {
419 + p.save_path = savePath.toUtf8().data();
421 + // Preallocate all?
423 + p.storage_mode = storage_mode_allocate;
425 + p.storage_mode = storage_mode_sparse;
428 + p.duplicate_is_error = false; // Already checked
429 + p.auto_managed = true;
430 + // Adding torrent to bittorrent session
431 + h = s->add_torrent(p);
432 + // Check if it worked
433 + if(!h.is_valid()) {
434 // No need to keep on, it failed.
435 qDebug("/!\\ Error: Invalid handle");
436 // If download from url, remove temp file
437 if(!from_url.isNull()) QFile::remove(file);
440 - // Connections limit per torrent
441 - h.set_max_connections(maxConnecsPerTorrent);
442 - // Uploads limit per torrent
443 - h.set_max_uploads(maxUploadsPerTorrent);
444 - // Load filtered files
445 - loadFilesPriorities(h);
446 - // Load custom url seeds
447 - loadWebSeeds(hash);
448 - // Load speed limit from hard drive
449 - loadTorrentSpeedLimits(hash);
451 - loadDownloadUploadForTorrent(hash);
453 - bool loaded_trackers = loadTrackerFile(hash);
454 - // Doing this to order trackers well
455 - if(!loaded_trackers) {
457 + // Connections limit per torrent
458 + h.set_max_connections(maxConnecsPerTorrent);
459 + // Uploads limit per torrent
460 + h.set_max_uploads(maxUploadsPerTorrent);
461 + // Load filtered files
462 + loadFilesPriorities(h);
463 + // Load custom url seeds
464 + loadWebSeeds(hash);
465 + // Load speed limit from hard drive
466 + loadTorrentSpeedLimits(hash);
468 + loadDownloadUploadForTorrent(hash);
470 + bool loaded_trackers = loadTrackerFile(hash);
471 + // Doing this to order trackers well
472 + if(!loaded_trackers) {
473 saveTrackerFile(hash);
474 loadTrackerFile(hash);
476 - QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent";
477 - if(file != newFile) {
479 + QString newFile = torrentBackup.path() + QDir::separator() + hash + ".torrent";
480 + if(file != newFile) {
481 // Delete file from torrentBackup directory in case it exists because
482 // QFile::copy() do not overwrite
483 QFile::remove(newFile);
484 // Copy it to torrentBackup directory
485 QFile::copy(file, newFile);
487 - // Incremental download
488 - if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
490 + // Incremental download
491 + if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
492 qDebug("Incremental download enabled for %s", t->name().c_str());
493 - h.set_sequenced_download_threshold(1);
495 - if((resumed || !addInPause) && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
496 + h.set_sequential_download(true);
498 + if((resumed || !addInPause) && !QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
499 // Start torrent because it was added in paused state
502 - if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
504 + if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".finished")) {
505 finishedTorrents << hash;
506 if(!resumed && queueingEnabled) {
507 - uploadQueue->append(hash);
508 - saveTorrentPriority(hash, uploadQueue->size()-1);
509 - updateUploadQueue();
510 + uploadQueue->append(hash);
511 + saveTorrentPriority(hash, uploadQueue->size()-1);
512 + updateUploadQueue();
516 unfinishedTorrents << hash;
517 if(!resumed && queueingEnabled) {
518 - downloadQueue->append(hash);
519 - saveTorrentPriority(hash, downloadQueue->size()-1);
520 - updateDownloadQueue();
521 + downloadQueue->append(hash);
522 + saveTorrentPriority(hash, downloadQueue->size()-1);
523 + updateDownloadQueue();
526 - // If download from url, remove temp file
527 - if(!from_url.isNull()) QFile::remove(file);
528 - // Delete from scan dir to avoid trying to download it again
531 + // If download from url, remove temp file
532 + if(!from_url.isNull()) QFile::remove(file);
533 + // Delete from scan dir to avoid trying to download it again
537 - // Send torrent addition signal
538 - if(!from_url.isNull()) {
540 + // Send torrent addition signal
541 + if(!from_url.isNull()) {
542 emit addedTorrent(h);
544 - addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url));
545 + addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(from_url));
547 - addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
549 + addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(from_url));
551 emit addedTorrent(h);
553 - addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file));
554 + addConsoleMessage(tr("'%1' resumed. (fast resume)", "'/home/y/xxx.torrent' was resumed. (fast resume)").arg(file));
556 - addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
558 - }catch (invalid_encoding& e) { // Raised by bdecode()
559 - std::cerr << "Could not decode file, reason: " << e.what() << '\n';
560 - // Display warning to tell user we can't decode the torrent file
561 - if(!from_url.isNull()) {
562 - addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
563 - //emit invalidTorrent(from_url);
564 - QFile::remove(file);
566 - addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
567 - //emit invalidTorrent(file);
569 - addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."),QString::fromUtf8("red"));
571 - // Remove .corrupt file in case it already exists
572 - QFile::remove(file+".corrupt");
573 - //Rename file extension so that it won't display error message more than once
574 - QFile::rename(file,file+".corrupt");
576 + addConsoleMessage(tr("'%1' added to download list.", "'/home/y/xxx.torrent' was added to download list.").arg(file));
578 - catch (invalid_torrent_file&) { // Raised by torrent_info constructor
579 - // Display warning to tell user we can't decode the torrent file
580 - if(!from_url.isNull()) {
581 - addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
582 - //emit invalidTorrent(from_url);
583 - qDebug("File path is: %s", file.toUtf8().data());
584 - QFile::remove(file);
586 - addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
587 - //emit invalidTorrent(file);
590 - // Remove .corrupt file in case it already exists
591 - QFile::remove(file+".corrupt");
592 - //Rename file extension so that it won't display error message more than once
593 - QFile::rename(file,file+".corrupt");
596 - catch (std::exception& e) {
597 - std::cerr << "Could not decode file, reason: " << e.what() << '\n';
598 - // Display warning to tell user we can't decode the torrent file
599 - if(!from_url.isNull()) {
600 - addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
601 - //emit invalidTorrent(from_url);
602 - QFile::remove(file);
604 - addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(file), QString::fromUtf8("red"));
605 - //emit invalidTorrent(file);
608 - // Remove .corrupt file in case it already exists
609 - QFile::remove(file+".corrupt");
610 - //Rename file extension so that it won't display error message more than once
611 - QFile::rename(file,file+".corrupt");
616 // Check in .priorities file if the user filtered files
617 @@ -1502,11 +1440,7 @@
618 // Remove old .fastresume data in case it exists
619 QFile::remove(torrentBackup.path()+QDir::separator()+hash + ".fastresume");
620 // Write fast resume data
621 - entry resumeData = h.write_resume_data();
622 - file = hash + ".fastresume";
623 - boost::filesystem::ofstream out(fs::path(torrentBackup.path().toUtf8().data()) / file.toUtf8().data(), std::ios_base::binary);
624 - out.unsetf(std::ios_base::skipws);
625 - bencode(std::ostream_iterator<char>(out), resumeData);
626 + h.save_resume_data();
629 saveDownloadUploadForTorrent(hash);
630 @@ -1762,9 +1696,21 @@
631 emit finishedTorrent(h);
634 + else if (save_resume_data_alert* p = dynamic_cast<save_resume_data_alert*>(a.get())) {
635 + QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
636 + QTorrentHandle h(p->handle);
637 + QString file = torrentBackup.path()+QDir::separator()+h.hash()+".torrent";
638 + TORRENT_ASSERT(p->resume_data);
639 + if (p->resume_data)
641 + boost::filesystem::ofstream out(fs::path(torrentBackup.path().toUtf8().data()) / file.toUtf8().data(), std::ios_base::binary);
642 + out.unsetf(std::ios_base::skipws);
643 + bencode(std::ostream_iterator<char>(out), *p->resume_data);
646 else if (file_error_alert* p = dynamic_cast<file_error_alert*>(a.get())) {
647 QTorrentHandle h(p->handle);
648 - qDebug("File Error: %s", p->msg().c_str());
649 + qDebug("File Error: %s", p->message().c_str());
651 emit fullDiskError(h);
653 @@ -1773,7 +1719,7 @@
654 addConsoleMessage(tr("Couldn't listen on any of the given ports."), QString::fromUtf8("red"));
655 //emit portListeningFailure();
657 - else if (tracker_alert* p = dynamic_cast<tracker_alert*>(a.get())) {
658 + else if (tracker_error_alert* p = dynamic_cast<tracker_error_alert*>(a.get())) {
660 QTorrentHandle h(p->handle);
662 @@ -1783,7 +1729,7 @@
663 qDebug("Received a tracker error for %s", p->url.c_str());
664 QHash<QString, QString> errors = trackersErrors.value(hash, QHash<QString, QString>());
665 // p->url requires at least libtorrent v0.13.1
666 - errors[misc::toQString(p->url)] = QString::fromUtf8(a->msg().c_str());
667 + errors[misc::toQString(p->url)] = QString::fromUtf8(a->message().c_str());
668 trackersErrors[hash] = errors;
670 emit trackerAuthenticationRequired(h);
671 @@ -1802,12 +1748,12 @@
674 else if (portmap_error_alert* p = dynamic_cast<portmap_error_alert*>(a.get())) {
675 - addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->msg().c_str())), QColor("red"));
676 + addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping failure, message: %1").arg(QString(p->message().c_str())), QColor("red"));
677 //emit UPnPError(QString(p->msg().c_str()));
679 else if (portmap_alert* p = dynamic_cast<portmap_alert*>(a.get())) {
680 - qDebug("UPnP Success, msg: %s", p->msg().c_str());
681 - addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping successful, message: %1").arg(QString(p->msg().c_str())), QColor("blue"));
682 + qDebug("UPnP Success, msg: %s", p->message().c_str());
683 + addConsoleMessage(tr("UPnP/NAT-PMP: Port mapping successful, message: %1").arg(QString(p->message().c_str())), QColor("blue"));
684 //emit UPnPSuccess(QString(p->msg().c_str()));
686 else if (peer_blocked_alert* p = dynamic_cast<peer_blocked_alert*>(a.get())) {
687 @@ -1821,13 +1767,13 @@
688 else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
689 QTorrentHandle h(p->handle);
691 - qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->msg().c_str());
692 + qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->message().c_str());
693 addConsoleMessage(tr("Fast resume data was rejected for torrent %1, checking again...").arg(h.name()), QString::fromUtf8("red"));
694 //emit fastResumeDataRejected(h.name());
697 else if (url_seed_alert* p = dynamic_cast<url_seed_alert*>(a.get())) {
698 - addConsoleMessage(tr("Url seed lookup failed for url: %1, message: %2").arg(QString::fromUtf8(p->url.c_str())).arg(QString::fromUtf8(p->msg().c_str())), QString::fromUtf8("red"));
699 + addConsoleMessage(tr("Url seed lookup failed for url: %1, message: %2").arg(QString::fromUtf8(p->url.c_str())).arg(QString::fromUtf8(p->message().c_str())), QString::fromUtf8("red"));
700 //emit urlSeedProblem(QString::fromUtf8(p->url.c_str()), QString::fromUtf8(p->msg().c_str()));
702 else if (torrent_checked_alert* p = dynamic_cast<torrent_checked_alert*>(a.get())) {
703 @@ -1853,72 +1799,6 @@
704 return trackersErrors.value(hash, QHash<QString, QString>());
707 -// Reload a torrent with full allocation mode
708 -void bittorrent::reloadTorrent(const QTorrentHandle &h, bool full_alloc) {
709 - qDebug("** Reloading a torrent");
710 - if(!h.is_valid()) {
711 - qDebug("/!\\ Error: Invalid handle");
714 - QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
715 - fs::path saveDir = h.save_path_boost();
716 - QString fileName = h.name();
717 - QString hash = h.hash();
718 - boost::intrusive_ptr<torrent_info> t(new torrent_info(h.get_torrent_info()));
719 - qDebug("Reloading torrent: %s", fileName.toUtf8().data());
721 - // Checking if torrentBackup Dir exists
722 - // create it if it is not
723 - if(! torrentBackup.exists()) {
724 - torrentBackup.mkpath(torrentBackup.path());
726 - // Extracting resume data
727 - if (h.has_metadata()) {
728 - // get fast resume data
729 - resumeData = h.write_resume_data();
732 - s->remove_torrent(h.get_torrent_handle());
733 - // Add torrent again to session
734 - unsigned int timeout = 0;
735 - while(h.is_valid() && timeout < 6) {
736 - qDebug("Waiting for the torrent to be removed...");
737 - SleeperThread::msleep(1000);
740 - QTorrentHandle new_h;
742 - new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_allocate);
743 - qDebug("Using full allocation mode");
745 - new_h = s->add_torrent(t, saveDir, resumeData, storage_mode_sparse);
746 - qDebug("Using sparse mode");
748 - // Connections limit per torrent
749 - new_h.set_max_connections(maxConnecsPerTorrent);
750 - // Uploads limit per torrent
751 - new_h.set_max_uploads(maxUploadsPerTorrent);
752 - // Load filtered Files
753 - loadFilesPriorities(new_h);
754 - // Load speed limit from hard drive
755 - loadTorrentSpeedLimits(hash);
756 - // Load custom url seeds
757 - loadWebSeeds(hash);
759 - loadDownloadUploadForTorrent(hash);
760 - // Pause torrent if it was paused last time
761 - if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".paused")) {
764 - // Incremental download
765 - if(QFile::exists(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".incremental")) {
766 - qDebug("Incremental download enabled for %s", fileName.toUtf8().data());
767 - new_h.set_sequenced_download_threshold(1);
773 int bittorrent::getListenPort() const{
774 return s->listen_port();
776 Index: src/torrentAddition.h
777 ===================================================================
778 --- src/torrentAddition.h (revision 2069)
779 +++ src/torrentAddition.h (revision 2070)
783 void showLoad(QString filePath, bool fromScanDir=false, QString from_url=QString::null){
784 - this->filePath = filePath;
785 - this->fromScanDir = fromScanDir;
786 - this->from_url = from_url;
787 - std::ifstream in(filePath.toUtf8().data(), std::ios_base::binary);
788 - in.unsetf(std::ios_base::skipws);
790 - // Decode torrent file
791 - entry e = bdecode(std::istream_iterator<char>(in), std::istream_iterator<char>());
792 + this->filePath = filePath;
793 + this->fromScanDir = fromScanDir;
794 + this->from_url = from_url;
795 // Getting torrent file informations
797 - nbFiles = t.num_files();
798 + boost::intrusive_ptr<torrent_info> t;
800 + t = new torrent_info(filePath.toUtf8().data());
801 + } catch(std::exception&) {
802 + if(!from_url.isNull()){
803 + BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
804 + QFile::remove(filePath);
806 + BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
810 + nbFiles = t->num_files();
812 - fileName = misc::toQString(t.name());
813 - hash = misc::toQString(t.info_hash());
814 + fileName = misc::toQString(t->name());
815 + hash = misc::toQString(t->info_hash());
816 // Use left() to remove .old extension
818 if(fileName.endsWith(QString::fromUtf8(".old"))){
819 - newFileName = fileName.left(fileName.size()-4);
820 + newFileName = fileName.left(fileName.size()-4);
822 - newFileName = fileName;
823 + newFileName = fileName;
825 fileNameLbl->setText(QString::fromUtf8("<center><b>")+newFileName+QString::fromUtf8("</b></center>"));
826 // List files in torrent
829 connect(PropListModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updatePriorities(QStandardItem*)));
830 torrentContentList->expandAll();
832 - catch (invalid_torrent_file&){ // Raised by torrent_info constructor
833 - // Display warning to tell user we can't decode the torrent file
834 - if(!from_url.isNull()){
835 - BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
836 - QFile::remove(filePath);
838 - BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
840 - BTSession->addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red"));
842 - // Remove .corrupt file in case it already exists
843 - QFile::remove(filePath+QString::fromUtf8(".corrupt"));
844 - //Rename file extension so that it won't display error message more than once
845 - QFile::rename(filePath,filePath+QString::fromUtf8(".corrupt"));
849 - catch(invalid_encoding& e){
850 - std::cerr << "Could not decode file, reason: " << e.what() << '\n';
851 - // Display warning to tell user we can't decode the torrent file
852 - if(!from_url.isNull()){
853 - BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
854 - QFile::remove(filePath);
856 - BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
858 - qDebug("path is %s", filePath.toUtf8().data());
859 - BTSession->addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red"));
861 - // Remove .corrupt file in case it already exists
862 - QFile::remove(filePath+QString::fromUtf8(".corrupt"));
863 - //Rename file extension so that it won't display error message more than once
864 - QFile::rename(filePath,filePath+QString::fromUtf8(".corrupt"));
868 - catch(std::exception& e){
869 - std::cerr << "Could not decode file, reason: " << e.what() << '\n';
870 - if(!from_url.isNull()){
871 - BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+from_url+QString::fromUtf8("'"), QString::fromUtf8("red"));
872 - QFile::remove(filePath);
874 - BTSession->addConsoleMessage(tr("Unable to decode torrent file:")+QString::fromUtf8(" '")+filePath+QString::fromUtf8("'"), QString::fromUtf8("red"));
876 - qDebug("path is %s", filePath.toUtf8().data());
877 - BTSession->addConsoleMessage(tr("This file is either corrupted or this isn't a torrent."), QString::fromUtf8("red"));
879 - // Remove .corrupt file in case it already exists
880 - QFile::remove(filePath+QString::fromUtf8(".corrupt"));
881 - //Rename file extension so that it won't display error message more than once
882 - QFile::rename(filePath,filePath+QString::fromUtf8(".corrupt"));
890 void addFilesToTree(torrent_file *root, QStandardItem *parent) {
891 Index: src/realprogressbarthread.cpp
892 ===================================================================
893 --- src/realprogressbarthread.cpp (revision 2069)
894 +++ src/realprogressbarthread.cpp (revision 2070)
896 size_type total_size = thandle.total_size();
897 size_type piece_length = thandle.piece_length();
898 int num_pieces = thandle.num_pieces();
899 - const std::vector<bool>* pieces = thandle.pieces();
900 + bitfield pieces = thandle.pieces();
901 //pieces not returned
903 + if (pieces.empty())
905 qDebug("pieces vector not returned");
909 qreal start = i * fraction;
910 qreal end = start + fraction;
916 Index: src/createtorrent_imp.cpp
917 ===================================================================
918 --- src/createtorrent_imp.cpp (revision 2069)
919 +++ src/createtorrent_imp.cpp (revision 2070)
921 #include <boost/filesystem/operations.hpp>
922 #include <boost/filesystem/path.hpp>
923 #include <boost/filesystem/fstream.hpp>
924 +#include <boost/bind.hpp>
926 #include <libtorrent/entry.hpp>
927 #include <libtorrent/bencode.hpp>
929 #include <libtorrent/storage.hpp>
930 #include <libtorrent/hasher.hpp>
931 #include <libtorrent/file_pool.hpp>
932 +#include <libtorrent/create_torrent.hpp>
934 #include "createtorrent_imp.h"
937 using namespace libtorrent;
938 using namespace boost::filesystem;
940 +// do not include files and folders whose
941 +// name starts with a .
942 +bool file_filter(boost::filesystem::path const& filename)
944 + if (filename.leaf()[0] == '.') return false;
945 + std::cerr << filename << std::endl;
949 createtorrent::createtorrent(QWidget *parent): QDialog(parent){
951 setAttribute(Qt::WA_DeleteOnClose);
952 - creatorThread = new torrentCreatorThread();
953 - connect(creatorThread, SIGNAL(creationSuccess(QString, const char*, QString)), this, SLOT(handleCreationSuccess(QString, const char*, QString)));
954 + creatorThread = new torrentCreatorThread(this);
955 + connect(creatorThread, SIGNAL(creationSuccess(QString, const char*)), this, SLOT(handleCreationSuccess(QString, const char*)));
956 connect(creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
957 connect(creatorThread, SIGNAL(updateProgress(int)), this, SLOT(updateProgressBar(int)));
958 + path::default_name_check(no_check);
966 -// Subfunction to add files to a torrent_info structure
967 -// Written by Arvid Norberg (libtorrent Author)
968 -void add_files(torrent_info& t, path const& p, path const& l){
969 - using boost::filesystem::path;
970 - using boost::filesystem::directory_iterator;
971 -#if BOOST_VERSION < 103600
972 - std::string const& leaf = l.leaf();
974 - std::string const& leaf = l.filename();
976 - if (leaf == ".." || leaf == ".") return;
978 - if (is_directory(f)) {
979 - for (directory_iterator i(f), end; i != end; ++i)
980 -#if BOOST_VERSION < 103600
981 - add_files(t, p, l / i->leaf());
983 - add_files(t, p, l / i->filename());
986 - qDebug("Adding %s", l.string().c_str());
987 - t.add_file(l, file_size(f));
991 QStringList createtorrent::allItems(QListWidget *list){
993 unsigned int nbItems = list->count();
994 @@ -191,17 +178,25 @@
998 -void createtorrent::handleCreationSuccess(QString path, const char* branch_path, QString hash) {
999 - if(checkStartSeeding->isChecked()) {
1000 - // Create save path file
1001 - QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
1002 - savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
1003 - savepath_file.write(branch_path);
1004 - savepath_file.close();
1005 - emit torrent_to_seed(path);
1007 - QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path);
1009 +void createtorrent::handleCreationSuccess(QString path, const char* branch_path) {
1010 + if(checkStartSeeding->isChecked()) {
1011 + // Create save path file
1012 + boost::intrusive_ptr<torrent_info> t;
1014 + t = new torrent_info(path.toUtf8().data());
1015 + } catch(std::exception&) {
1016 + QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
1019 + QString hash = misc::toQString(t->info_hash());
1020 + QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
1021 + savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
1022 + savepath_file.write(branch_path);
1023 + savepath_file.close();
1024 + emit torrent_to_seed(path);
1026 + QMessageBox::information(0, tr("Torrent creation"), tr("Torrent was created successfully:")+" "+path);
1030 void createtorrent::updateProgressBar(int progress) {
1031 @@ -224,58 +219,47 @@
1035 +void sendProgressUpdateSignal(int i, int num, QDialog *parent){
1036 + ((createtorrent*)parent)->updateProgressBar((int)(i*100./(float)num));
1039 void torrentCreatorThread::run() {
1040 emit updateProgress(0);
1041 char const* creator_str = "qBittorrent "VERSION;
1043 - boost::intrusive_ptr<torrent_info> t(new torrent_info);
1044 - ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary);
1045 - // Adding files to the torrent
1048 path full_path = complete(path(input_path.toUtf8().data()));
1049 -#if BOOST_VERSION < 103600
1050 - add_files(*t, full_path.branch_path(), full_path.leaf());
1052 - add_files(*t, full_path.branch_path(), full_path.filename());
1054 + // Adding files to the torrent
1055 + add_files(fs, full_path, file_filter);
1058 - t->set_piece_size(piece_size);
1059 + create_torrent t(fs, piece_size);
1063 foreach(seed, url_seeds){
1064 - t->add_url_seed(seed.toUtf8().data());
1065 + t.add_url_seed(seed.toUtf8().data());
1067 for(int i=0; i<trackers.size(); ++i){
1068 - t->add_tracker(trackers.at(i).toUtf8().data());
1069 + t.add_tracker(trackers.at(i).toUtf8().data());
1072 // calculate the hash for all pieces
1074 - boost::scoped_ptr<storage_interface> st(default_storage_constructor(t, full_path.branch_path(), fp));
1075 - int num = t->num_pieces();
1076 - std::vector<char> buf(piece_size);
1077 - for (int i = 0; i < num; ++i) {
1078 - st->read(&buf[0], i, 0, t->piece_size(i));
1079 - hasher h(&buf[0], t->piece_size(i));
1080 - t->set_hash(i, h.final());
1081 - emit updateProgress((int)(i*100./(float)num));
1084 + set_piece_hashes(t, full_path.branch_path(), boost::bind(&sendProgressUpdateSignal, _1, t.num_pieces(), parent));
1085 // Set qBittorrent as creator and add user comment to
1086 // torrent_info structure
1087 - t->set_creator(creator_str);
1088 - t->set_comment((const char*)comment.toUtf8());
1089 + t.set_creator(creator_str);
1090 + t.set_comment((const char*)comment.toUtf8());
1093 - t->set_priv(true);
1097 // create the torrent and print it to out
1098 - entry e = t->create_torrent();
1099 - libtorrent::bencode(std::ostream_iterator<char>(out), e);
1101 + ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary);
1102 + bencode(std::ostream_iterator<char>(out), t.generate());
1103 emit updateProgress(100);
1104 - emit creationSuccess(save_path, full_path.branch_path().string().c_str(), misc::toQString(t->info_hash()));
1105 + emit creationSuccess(save_path, full_path.branch_path().string().c_str());
1107 catch (std::exception& e){
1108 emit creationFailure(QString::fromUtf8(e.what()));
1109 Index: src/bittorrent.h
1110 ===================================================================
1111 --- src/bittorrent.h (revision 2069)
1112 +++ src/bittorrent.h (revision 2070)
1114 void enableNATPMP(bool b);
1115 void enableLSD(bool b);
1116 bool enableDHT(bool b);
1117 - void reloadTorrent(const QTorrentHandle &h, bool full_alloc);
1118 void setTimerScanInterval(int secs);
1119 void setMaxActiveDownloads(int val);
1120 void setMaxActiveTorrents(int val);
1122 ===================================================================
1123 --- src/src.pro (revision 2069)
1124 +++ src/src.pro (revision 2070)
1126 PropListDelegate.h previewSelect.h \
1127 PreviewListDelegate.h trackerLogin.h \
1128 downloadThread.h downloadFromURLImp.h \
1129 - torrentAddition.h deleteThread.h \
1130 + torrentAddition.h \
1131 bittorrent.h searchEngine.h \
1132 rss.h rss_imp.h FinishedTorrents.h \
1133 allocationDlg.h FinishedListDelegate.h \
1134 Index: src/downloadingTorrents.cpp
1135 ===================================================================
1136 --- src/downloadingTorrents.cpp (revision 2069)
1137 +++ src/downloadingTorrents.cpp (revision 2070)
1138 @@ -529,31 +529,6 @@
1139 DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
1142 - case torrent_status::connecting_to_tracker:
1143 - if(h.download_payload_rate() > 0) {
1144 - // Display "Downloading" status when connecting if download speed > 0
1145 - if(!downloadList->isColumnHidden(ETA)) {
1146 - DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)BTSession->getETA(hash)));
1148 - DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/downloading.png"))), Qt::DecorationRole);
1149 - setRowColor(row, QString::fromUtf8("green"));
1151 - if(!downloadList->isColumnHidden(ETA)) {
1152 - DLListModel->setData(DLListModel->index(row, ETA), QVariant((qlonglong)-1));
1154 - DLListModel->setData(DLListModel->index(row, NAME), QVariant(QIcon(QString::fromUtf8(":/Icons/skin/connecting.png"))), Qt::DecorationRole);
1155 - setRowColor(row, QString::fromUtf8("grey"));
1157 - if(!downloadList->isColumnHidden(PROGRESS)) {
1158 - DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)h.progress()));
1160 - if(!downloadList->isColumnHidden(DLSPEED)) {
1161 - DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)h.download_payload_rate()));
1163 - if(!downloadList->isColumnHidden(UPSPEED)) {
1164 - DLListModel->setData(DLListModel->index(row, UPSPEED), QVariant((double)h.upload_payload_rate()));
1167 case torrent_status::downloading:
1168 case torrent_status::downloading_metadata:
1169 if(h.download_payload_rate() > 0) {
1170 Index: src/qtorrenthandle.cpp
1171 ===================================================================
1172 --- src/qtorrenthandle.cpp (revision 2069)
1173 +++ src/qtorrenthandle.cpp (revision 2070)
1178 -const std::vector<bool>* QTorrentHandle::pieces() const {
1179 +bitfield QTorrentHandle::pieces() const {
1180 Q_ASSERT(h.is_valid());
1181 return h.status().pieces;
1184 return h.has_metadata();
1187 -entry QTorrentHandle::write_resume_data() const {
1188 +void QTorrentHandle::save_resume_data() const {
1189 Q_ASSERT(h.is_valid());
1190 - return h.write_resume_data();
1191 + return h.save_resume_data();
1194 QString QTorrentHandle::file_at(unsigned int index) const {
1196 return h.status().total_failed_bytes;
1199 -void QTorrentHandle::file_progress(std::vector<float>& fp) {
1200 +void QTorrentHandle::file_progress(std::vector<size_type>& fp) {
1201 Q_ASSERT(h.is_valid());
1202 return h.file_progress(fp);
1205 h.force_reannounce();
1208 -void QTorrentHandle::set_sequenced_download_threshold(int val) {
1209 +void QTorrentHandle::set_sequential_download(bool b) {
1210 Q_ASSERT(h.is_valid());
1211 - h.set_sequenced_download_threshold(val);
1212 + h.set_sequential_download(b);
1215 void QTorrentHandle::set_tracker_login(QString username, QString password) {
1216 Index: src/createtorrent_imp.h
1217 ===================================================================
1218 --- src/createtorrent_imp.h (revision 2069)
1219 +++ src/createtorrent_imp.h (revision 2070)
1227 - torrentCreatorThread() {}
1228 + torrentCreatorThread(QDialog *_parent) {
1231 ~torrentCreatorThread() {
1237 void creationFailure(QString msg);
1238 - void creationSuccess(QString path, const char* branch_path, QString hash);
1239 + void creationSuccess(QString path, const char* branch_path);
1240 void updateProgress(int progress);
1245 void torrent_to_seed(QString path);
1248 + void updateProgressBar(int progress);
1251 void on_createButton_clicked();
1252 void on_addFile_button_clicked();
1254 void on_addURLSeed_button_clicked();
1255 void on_removeURLSeed_button_clicked();
1256 void handleCreationFailure(QString msg);
1257 - void handleCreationSuccess(QString path, const char* branch_path, QString hash);
1258 - void updateProgressBar(int progress);
1259 + void handleCreationSuccess(QString path, const char* branch_path);
1263 Index: src/icons.qrc
1264 ===================================================================
1265 --- src/icons.qrc (revision 2069)
1266 +++ src/icons.qrc (revision 2070)
1268 <file>Icons/flags/united_kingdom.png</file>
1269 <file>Icons/skin/add.png</file>
1270 <file>Icons/skin/connected.png</file>
1271 - <file>Icons/skin/connecting.png</file>
1272 <file>Icons/skin/decrease.png</file>
1273 <file>Icons/skin/delete.png</file>
1274 <file>Icons/skin/delete_all.png</file>