Browse Source

FEATURE: Trackers can be added from Web UI

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
4c34066727
  1. 1
      Changelog
  2. 18
      src/httpconnection.cpp
  3. 1
      src/webui.qrc
  4. 32
      src/webui/addtrackers.html
  5. 5
      src/webui/css/style.css
  6. 1
      src/webui/download.html
  7. 20
      src/webui/prop-trackers.html

1
Changelog

@ -9,6 +9,7 @@
- FEATURE: User can choose to include the protocol overhead in transfer limits - FEATURE: User can choose to include the protocol overhead in transfer limits
- FEATURE: Torrents can be automatically rechecked on completion - FEATURE: Torrents can be automatically rechecked on completion
- FEATURE: If 2 torrents have the same hash, add new trackers to the existing torrent - FEATURE: If 2 torrents have the same hash, add new trackers to the existing torrent
- FEATURE: Trackers can be added from Web UI
- COSMETIC: Improved style management - COSMETIC: Improved style management
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0 * Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0

18
src/httpconnection.cpp

@ -103,7 +103,7 @@ void HttpConnection::write()
} }
QString HttpConnection::translateDocument(QString data) { QString HttpConnection::translateDocument(QString data) {
std::string contexts[] = {"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "GUI", "MainWindow", "HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "options_imp", "Preferences"}; std::string contexts[] = {"TransferListFiltersWidget", "TransferListWidget", "PropertiesWidget", "GUI", "MainWindow", "HttpServer", "confirmDeletionDlg", "TrackerList", "TorrentFilesModel", "options_imp", "Preferences", "TrackersAdditionDlg"};
int i=0; int i=0;
bool found = false; bool found = false;
do { do {
@ -118,7 +118,7 @@ QString HttpConnection::translateDocument(QString data) {
do { do {
translation = qApp->translate(contexts[context_index].c_str(), word.toLocal8Bit().data(), 0, QCoreApplication::UnicodeUTF8, 1); translation = qApp->translate(contexts[context_index].c_str(), word.toLocal8Bit().data(), 0, QCoreApplication::UnicodeUTF8, 1);
++context_index; ++context_index;
}while(translation == word && context_index < 11); }while(translation == word && context_index < 12);
//qDebug("Translation is %s", translation.toUtf8().data()); //qDebug("Translation is %s", translation.toUtf8().data());
data = data.replace(i, regex.matchedLength(), translation); data = data.replace(i, regex.matchedLength(), translation);
i += translation.length(); i += translation.length();
@ -317,6 +317,20 @@ void HttpConnection::respondCommand(QString command)
} }
return; return;
} }
if(command == "addTrackers") {
QString hash = parser.post("hash");
if(!hash.isEmpty()) {
QTorrentHandle h = BTSession->getTorrentHandle(hash);
if(h.is_valid() && h.has_metadata()) {
QString urls = parser.post("urls");
QStringList list = urls.split('\n');
foreach(QString url, list) {
announce_entry e(url.toStdString());
h.add_tracker(e);
}
}
}
}
if(command == "upload") if(command == "upload")
{ {
QByteArray torrentfile = parser.torrent(); QByteArray torrentfile = parser.torrent();

1
src/webui.qrc

@ -2,6 +2,7 @@
<qresource> <qresource>
<file>webui/index.html</file> <file>webui/index.html</file>
<file>webui/download.html</file> <file>webui/download.html</file>
<file>webui/addtrackers.html</file>
<file>webui/upload.html</file> <file>webui/upload.html</file>
<file>webui/uploadframe.html</file> <file>webui/uploadframe.html</file>
<file>webui/about.html</file> <file>webui/about.html</file>

32
src/webui/addtrackers.html

@ -0,0 +1,32 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>_(Trackers addition dialog)</title>
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script type="text/javascript" src="scripts/mootools-1.2-core-yc.js" charset="utf-8"></script>
<script type="text/javascript" src="scripts/mootools-1.2-more.js" charset="utf-8"></script>
<script type="text/javascript">
window.addEvent('domready', function(){
$('trackersUrls').focus();
$('addTrackersButton').addEvent('click', function(e){
new Event(e).stop();
var hash = new URI().getData('hash');
new Request({url: '/command/addTrackers', method: 'post', data: {hash: hash, urls: $('trackersUrls').value},
onComplete: function() {
window.parent.document.getElementById('trackersPage').parentNode.removeChild(window.parent.document.getElementById('trackersPage'));
}
}).send();
});
});
</script>
</head>
<body>
<center>
<h1 class="vcenter">_(List of trackers to add (one per line):)</h1><br/>
<textarea name="list" id="trackersUrls" rows="10" cols="1"></textarea>
<br/>
<a id="addTrackersButton">_(Add)</a>
</center>
</body>
</html>

5
src/webui/css/style.css

@ -120,6 +120,11 @@ hr {
height:100%; height:100%;
} }
#trackersUrls {
width:90%;
height:100%;
}
#Filters ul { #Filters ul {
list-style-type: none; list-style-type: none;
} }

1
src/webui/download.html

@ -9,6 +9,7 @@
</head> </head>
<body> <body>
<center> <center>
<br/>
<h1 class="vcenter"><img class="vcenter" title="Download from URL" src="images/skin/url.png"/>_(Download Torrents from their URL or Magnet link)</h1> <h1 class="vcenter"><img class="vcenter" title="Download from URL" src="images/skin/url.png"/>_(Download Torrents from their URL or Magnet link)</h1>
<textarea name="list" id="urls" rows="10" cols="1"></textarea><p>_(Only one link per line)</p><a id=downButton>_(Download)</a> <textarea name="list" id="urls" rows="10" cols="1"></textarea><p>_(Only one link per line)</p><a id=downButton>_(Download)</a>
</center> </center>

20
src/webui/prop-trackers.html

@ -2,7 +2,7 @@
<table class="torrentTable" cellpadding="0" cellspacing="0"> <table class="torrentTable" cellpadding="0" cellspacing="0">
<thead> <thead>
<tr> <tr>
<th>_(URL)</th> <th>_(URL) <img src="images/oxygen/list-add.png" id="addTrackersPlus" style="width:16px;cursor:pointer;"/></th>
<th>_(Status)</th> <th>_(Status)</th>
<th>_(Peers)</th> <th>_(Peers)</th>
<th>_(Message)</th> <th>_(Message)</th>
@ -125,4 +125,22 @@ var trackersDynTable = new Class ({
tTable.setup($('trackersTable')); tTable.setup($('trackersTable'));
// Initial loading // Initial loading
loadTrackersData(); loadTrackersData();
// Add trackers code
$('addTrackersPlus').addEvent('click', function addTrackerDlg() {
if(current_hash.length == 0) return;
new MochaUI.Window({
id: 'trackersPage',
title: "_(Trackers addition dialog)",
loadMethod: 'iframe',
contentURL:'addtrackers.html?hash='+current_hash,
scrollbars: true,
resizable: false,
maximizable: false,
closable: true,
paddingVertical: 0,
paddingHorizontal: 0,
width: 500,
height: 250
});
});
</script> </script>

Loading…
Cancel
Save