Browse Source

Add ability to set super seeding mode for torrents

adaptive-webui-19844
buinsky 10 years ago
parent
commit
facab1681a
  1. 2
      src/webui/btjson.cpp
  2. 16
      src/webui/webapplication.cpp
  3. 1
      src/webui/webapplication.h
  4. 1
      src/webui/www/private/index.html
  5. 11
      src/webui/www/public/scripts/contextmenu.js
  6. 15
      src/webui/www/public/scripts/mocha-init.js
  7. 3
      src/webui/www/public/transferlist.html

2
src/webui/btjson.cpp

@ -102,6 +102,7 @@ static const char KEY_TORRENT_STATE[] = "state"; @@ -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) @@ -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;
}

16
src/webui/webapplication.cpp

@ -102,6 +102,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > WebApplication::initialize @@ -102,6 +102,7 @@ QMap<QString, QMap<QString, WebApplication::Action> > 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() @@ -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);

1
src/webui/webapplication.h

@ -76,6 +76,7 @@ private: @@ -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();

1
src/webui/www/private/index.html

@ -111,6 +111,7 @@ @@ -111,6 +111,7 @@
<li><a href="#UploadLimit"><img src="images/skin/seeding.png" alt="QBT_TR(Limit upload rate...)QBT_TR"/> QBT_TR(Limit upload rate...)QBT_TR</a></li>
<li class="separator"><a href="#SequentialDownload"><img src="theme/checked" alt="QBT_TR(Download in sequential order)QBT_TR"/> QBT_TR(Download in sequential order)QBT_TR</a></li>
<li><a href="#FirstLastPiecePrio"><img src="theme/checked" alt="QBT_TR(Download first and last piece first)QBT_TR"/> QBT_TR(Download first and last piece first)QBT_TR</a></li>
<li class="separator"><a href="#SuperSeeding"><img src="theme/checked" alt="QBT_TR(Super seeding mode)QBT_TR"/> QBT_TR(Super seeding mode)QBT_TR</a></li>
<li class="separator"><a href="#ForceRecheck"><img src="theme/document-edit-verify" alt="QBT_TR(Force recheck)QBT_TR"/> QBT_TR(Force recheck)QBT_TR</a></li>
</ul>
<div id="desktopFooterWrapper">

11
src/webui/www/public/scripts/contextmenu.js

@ -136,6 +136,7 @@ var ContextMenu = new Class({ @@ -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({ @@ -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({ @@ -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({ @@ -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({ @@ -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');

15
src/webui/www/public/scripts/mocha-init.js

@ -166,6 +166,21 @@ initializeWindows = function() { @@ -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',

3
src/webui/www/public/transferlist.html

@ -51,6 +51,9 @@ @@ -51,6 +51,9 @@
},
FirstLastPiecePrio : function (element, ref) {
toggleFirstLastPiecePrioFN();
},
SuperSeeding : function (element, ref) {
setSuperSeedingFN(!ref.getItemChecked('SuperSeeding'));
}
},
offsets : {

Loading…
Cancel
Save