Browse Source

Merge pull request #6475 from OpenGG/master

[WebUI-API] Add "skip_checking" and "paused" to "/command/download" and "/command/upload"
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
018574e546
  1. 4
      src/base/http/requestparser.cpp
  2. 2
      src/webui/abstractwebapplication.cpp
  3. 14
      src/webui/webapplication.cpp
  4. 13
      src/webui/www/public/download.html
  5. 2
      src/webui/www/public/scripts/mocha-init.js
  6. 13
      src/webui/www/public/upload.html

4
src/base/http/requestparser.cpp

@ -192,14 +192,14 @@ QList<QByteArray> RequestParser::splitMultipartData(const QByteArray& data, cons
start = end + sepLength; // skip first boundary start = end + sepLength; // skip first boundary
while ((end = data.indexOf(sep, start)) >= 0) { while ((end = data.indexOf(sep, start)) >= 0) {
ret << data.mid(start, end - start); ret << data.mid(start, end - EOL.length() - start);
start = end + sepLength; start = end + sepLength;
} }
// last or single part // last or single part
sep = boundary + "--" + EOL; sep = boundary + "--" + EOL;
if ((end = data.indexOf(sep, start)) >= 0) if ((end = data.indexOf(sep, start)) >= 0)
ret << data.mid(start, end - start); ret << data.mid(start, end - EOL.length() - start);
} }
return ret; return ret;

2
src/webui/abstractwebapplication.cpp

@ -252,7 +252,7 @@ void AbstractWebApplication::translateDocument(QString& data)
"options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel", "options_imp", "Preferences", "TrackersAdditionDlg", "ScanFoldersModel",
"PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc", "PropTabBar", "TorrentModel", "downloadFromURL", "MainWindow", "misc",
"StatusBar", "AboutDlg", "about", "PeerListWidget", "StatusFiltersWidget", "StatusBar", "AboutDlg", "about", "PeerListWidget", "StatusFiltersWidget",
"CategoryFiltersList", "TransferListDelegate" "CategoryFiltersList", "TransferListDelegate", "AddNewTorrentDialog"
}; };
const size_t context_count = sizeof(contexts) / sizeof(contexts[0]); const size_t context_count = sizeof(contexts) / sizeof(contexts[0]);
int i = 0; int i = 0;

14
src/webui/webapplication.cpp

@ -367,6 +367,8 @@ void WebApplication::action_command_download()
CHECK_URI(0); CHECK_URI(0);
QString urls = request().posts["urls"]; QString urls = request().posts["urls"];
QStringList list = urls.split('\n'); QStringList list = urls.split('\n');
bool skipChecking = request().posts["skip_checking"] == "true";
bool addPaused = request().posts["paused"] == "true";
QString savepath = request().posts["savepath"]; QString savepath = request().posts["savepath"];
QString category = request().posts["category"]; QString category = request().posts["category"];
QString cookie = request().posts["cookie"]; QString cookie = request().posts["cookie"];
@ -390,6 +392,11 @@ void WebApplication::action_command_download()
category = category.trimmed(); category = category.trimmed();
BitTorrent::AddTorrentParams params; BitTorrent::AddTorrentParams params;
// TODO: Check if destination actually exists
params.skipChecking = skipChecking;
params.addPaused = addPaused;
params.savePath = savepath; params.savePath = savepath;
params.category = category; params.category = category;
@ -406,6 +413,8 @@ void WebApplication::action_command_upload()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
CHECK_URI(0); CHECK_URI(0);
bool skipChecking = request().posts["skip_checking"] == "true";
bool addPaused = request().posts["paused"] == "true";
QString savepath = request().posts["savepath"]; QString savepath = request().posts["savepath"];
QString category = request().posts["category"]; QString category = request().posts["category"];
@ -423,6 +432,11 @@ void WebApplication::action_command_upload()
} }
else { else {
BitTorrent::AddTorrentParams params; BitTorrent::AddTorrentParams params;
// TODO: Check if destination actually exists
params.skipChecking = skipChecking;
params.addPaused = addPaused;
params.savePath = savepath; params.savePath = savepath;
params.category = category; params.category = category;
if (!BitTorrent::Session::instance()->addTorrent(torrentInfo, params)) { if (!BitTorrent::Session::instance()->addTorrent(torrentInfo, params)) {

13
src/webui/www/public/download.html

@ -29,6 +29,15 @@
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR</label> <label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR</label>
<input type="text" id="category" name="category" style="width: 16em;"/> <input type="text" id="category" name="category" style="width: 16em;"/>
</div> </div>
<div class="formRow">
<label for="start_torrent" class="leftLabelLarge">QBT_TR(Start torrent)QBT_TR</label>
<input type="checkbox" id="start_torrent" checked="checked" style="width: 16em;"/>
<input type="hidden" id="add_paused" name="paused" value="true" disabled="disabled"/>
</div>
<div class="formRow">
<label for="skip_checking" class="leftLabelLarge">QBT_TR(Skip hash check)QBT_TR</label>
<input type="checkbox" name="skip_checking" value="true" style="width: 16em;"/>
</div>
<div id="submitbutton" style="margin-top: 12px; text-align: center;"> <div id="submitbutton" style="margin-top: 12px; text-align: center;">
<button type="submit" id="submitButton">QBT_TR(Download)QBT_TR</button> <button type="submit" id="submitButton">QBT_TR(Download)QBT_TR</button>
</div> </div>
@ -47,6 +56,10 @@ $('download_frame').addEventListener("load", function() {
if (submitted) if (submitted)
window.parent.closeWindows(); window.parent.closeWindows();
}); });
$('start_torrent').addEventListener('change', function() {
$('add_paused').disabled = $('start_torrent').checked;
});
</script> </script>
<div id="download_spinner" class="mochaSpinner"></div> <div id="download_spinner" class="mochaSpinner"></div>
</body> </body>

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

@ -97,7 +97,7 @@ initializeWindows = function() {
paddingVertical: 0, paddingVertical: 0,
paddingHorizontal: 0, paddingHorizontal: 0,
width: 500, width: 500,
height: 200 height: 220
}); });
updateMainData(); updateMainData();
}); });

13
src/webui/www/public/upload.html

@ -25,6 +25,15 @@
<label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR</label> <label for="category" class="leftLabelLarge">QBT_TR(Category:)QBT_TR</label>
<input type="text" id="category" name="category"/ style="width: 16em;"/> <input type="text" id="category" name="category"/ style="width: 16em;"/>
</div> </div>
<div class="formRow">
<label for="start_torrent" class="leftLabelLarge">QBT_TR(Start torrent)QBT_TR</label>
<input type="checkbox" id="start_torrent" checked="checked" style="width: 16em;"/>
<input type="hidden" id="add_paused" name="paused" value="true" disabled="disabled"/>
</div>
<div class="formRow">
<label for="skip_checking" class="leftLabelLarge">QBT_TR(Skip hash check)QBT_TR</label>
<input type="checkbox" name="skip_checking" value="true" style="width: 16em;"/>
</div>
<div id="submitbutton" style="margin-top: 30px; text-align: center;"> <div id="submitbutton" style="margin-top: 30px; text-align: center;">
<button type="submit" style="font-size: 1em;">QBT_TR(Upload Torrents)QBT_TR</button> <button type="submit" style="font-size: 1em;">QBT_TR(Upload Torrents)QBT_TR</button>
</div> </div>
@ -43,6 +52,10 @@ $('upload_frame').addEventListener("load", function() {
if (submitted) if (submitted)
window.parent.closeWindows(); window.parent.closeWindows();
}); });
$('start_torrent').addEventListener('change', function() {
$('add_paused').disabled = $('start_torrent').checked;
});
</script> </script>
<div id="upload_spinner" class="mochaSpinner"></div> <div id="upload_spinner" class="mochaSpinner"></div>
</body> </body>

Loading…
Cancel
Save