diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 4f7f3b5de..699bf5165 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -102,6 +102,7 @@ static const char KEY_TORRENT_STATE[] = "state"; static const char KEY_TORRENT_SEQUENTIAL_DOWNLOAD[] = "seq_dl"; static const char KEY_TORRENT_FIRST_LAST_PIECE_PRIO[] = "f_l_piece_prio"; static const char KEY_TORRENT_LABEL[] = "label"; +static const char KEY_TORRENT_SUPER_SEEDING[] = "super_seeding"; // Tracker keys static const char KEY_TRACKER_URL[] = "url"; @@ -565,6 +566,7 @@ QVariantMap toMap(const QTorrentHandle& h) if (h.has_metadata()) ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = h.first_last_piece_first(); ret[KEY_TORRENT_LABEL] = TorrentPersistentData::instance()->getLabel(h.hash()); + ret[KEY_TORRENT_SUPER_SEEDING] = status.super_seeding; return ret; } diff --git a/src/webui/webapplication.cpp b/src/webui/webapplication.cpp index 79fcfb0b0..545e1ef52 100644 --- a/src/webui/webapplication.cpp +++ b/src/webui/webapplication.cpp @@ -102,6 +102,7 @@ QMap > WebApplication::initialize ADD_ACTION(command, toggleAlternativeSpeedLimits); ADD_ACTION(command, toggleSequentialDownload); ADD_ACTION(command, toggleFirstLastPiecePrio); + ADD_ACTION(command, setSuperSeeding); ADD_ACTION(command, delete); ADD_ACTION(command, deletePerm); ADD_ACTION(command, increasePrio); @@ -541,6 +542,21 @@ void WebApplication::action_command_toggleFirstLastPiecePrio() } } +void WebApplication::action_command_setSuperSeeding() +{ + CHECK_URI(0); + CHECK_PARAMETERS("hashes" << "value"); + bool value = request().posts["value"] == "true"; + QStringList hashes = request().posts["hashes"].split("|"); + foreach (const QString &hash, hashes) { + try { + QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash); + h.super_seeding(value); + } + catch(invalid_handle&) {} + } +} + void WebApplication::action_command_delete() { CHECK_URI(0); diff --git a/src/webui/webapplication.h b/src/webui/webapplication.h index b4b6b9b3f..4b2e31b6d 100644 --- a/src/webui/webapplication.h +++ b/src/webui/webapplication.h @@ -76,6 +76,7 @@ private: void action_command_toggleAlternativeSpeedLimits(); void action_command_toggleSequentialDownload(); void action_command_toggleFirstLastPiecePrio(); + void action_command_setSuperSeeding(); void action_command_delete(); void action_command_deletePerm(); void action_command_increasePrio(); diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html index e60fa79e5..2f0edbf0f 100644 --- a/src/webui/www/private/index.html +++ b/src/webui/www/private/index.html @@ -111,6 +111,7 @@
  • QBT_TR(Limit upload rate...)QBT_TR QBT_TR(Limit upload rate...)QBT_TR
  • QBT_TR(Download in sequential order)QBT_TR QBT_TR(Download in sequential order)QBT_TR
  • QBT_TR(Download first and last piece first)QBT_TR QBT_TR(Download first and last piece first)QBT_TR
  • +
  • QBT_TR(Super seeding mode)QBT_TR QBT_TR(Super seeding mode)QBT_TR
  • QBT_TR(Force recheck)QBT_TR QBT_TR(Force recheck)QBT_TR
  • diff --git a/src/webui/www/public/scripts/contextmenu.js b/src/webui/www/public/scripts/contextmenu.js index 2aaff877d..72e60f5e7 100644 --- a/src/webui/www/public/scripts/contextmenu.js +++ b/src/webui/www/public/scripts/contextmenu.js @@ -136,6 +136,7 @@ var ContextMenu = new Class({ all_are_downloaded = true; all_are_paused = true; there_are_paused = false; + all_are_super_seeding = true; var h = myTable.selectedIds(); h.each(function(item, index){ @@ -153,6 +154,8 @@ var ContextMenu = new Class({ if (data['progress'] != 1.0) // not downloaded all_are_downloaded = false; + else if (data['super_seeding'] != true) + all_are_super_seeding = false; state = data['state']; if ((state != 'pausedUP') && (state != 'pausedDL')) @@ -174,6 +177,8 @@ var ContextMenu = new Class({ if (all_are_downloaded) { this.hideItem('SequentialDownload'); this.hideItem('FirstLastPiecePrio'); + this.showItem('SuperSeeding'); + this.setItemChecked('SuperSeeding', all_are_super_seeding); } else { if (!show_seq_dl && show_f_l_piece_prio) this.menu.getElement('a[href$=FirstLastPiecePrio]').parentNode.addClass('separator'); @@ -192,6 +197,8 @@ var ContextMenu = new Class({ this.setItemChecked('SequentialDownload', all_are_seq_dl); this.setItemChecked('FirstLastPiecePrio', all_are_f_l_piece_prio); + + this.hideItem('SuperSeeding'); } if (all_are_paused) { @@ -234,6 +241,10 @@ var ContextMenu = new Class({ return this; }, + getItemChecked: function(item) { + return '0' != this.menu.getElement('a[href$=' + item + ']').firstChild.style.opacity; + }, + //hide an item hideItem: function(item) { this.menu.getElement('a[href$=' + item + ']').parentNode.addClass('invisible'); diff --git a/src/webui/www/public/scripts/mocha-init.js b/src/webui/www/public/scripts/mocha-init.js index d14dbb669..b09dc4fc9 100644 --- a/src/webui/www/public/scripts/mocha-init.js +++ b/src/webui/www/public/scripts/mocha-init.js @@ -166,6 +166,21 @@ initializeWindows = function() { } }; + setSuperSeedingFN = function(val) { + var h = myTable.selectedIds(); + if (h.length) { + new Request({ + url: 'command/setSuperSeeding', + method: 'post', + data: { + value: val, + hashes: h.join("|") + } + }).send(); + updateMainData(); + } + }; + globalDownloadLimitFN = function() { new MochaUI.Window({ id: 'downloadLimitPage', diff --git a/src/webui/www/public/transferlist.html b/src/webui/www/public/transferlist.html index d12e2027a..b65dcd96a 100644 --- a/src/webui/www/public/transferlist.html +++ b/src/webui/www/public/transferlist.html @@ -51,6 +51,9 @@ }, FirstLastPiecePrio : function (element, ref) { toggleFirstLastPiecePrioFN(); + }, + SuperSeeding : function (element, ref) { + setSuperSeedingFN(!ref.getItemChecked('SuperSeeding')); } }, offsets : {