Browse Source

Fix tables appearance in Web UI

Fix empty array parsing in JSON
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
3172e1f530
  1. 1
      src/eventmanager.cpp
  2. 2
      src/httpconnection.cpp
  3. 4
      src/httpserver.cpp
  4. 3
      src/json.h
  5. 8
      src/webui/preferences_content.html
  6. 2
      src/webui/prop-files.html
  7. 2
      src/webui/prop-trackers.html

1
src/eventmanager.cpp

@ -152,6 +152,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const { @@ -152,6 +152,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
}
int i = 0;
foreach(const QString &new_folder, new_folders) {
qDebug("New watched folder: %s", qPrintable(new_folder));
// Update new folders
if(!old_folders.contains(new_folder)) {
BTSession->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));

2
src/httpconnection.cpp

@ -150,7 +150,7 @@ void HttpConnection::respond() { @@ -150,7 +150,7 @@ void HttpConnection::respond() {
write();
return;
}
qDebug("Auth: %s", qPrintable(auth.split(" ").first()));
//qDebug("Auth: %s", qPrintable(auth.split(" ").first()));
if (QString::compare(auth.split(" ").first(), "Digest", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth.toLocal8Bit(), parser.method())) {
// Update failed attempt counter
parent->increaseNbFailedAttemptsForIp(peer_ip);

4
src/httpserver.cpp

@ -177,12 +177,12 @@ void HttpServer::setAuthorization(QString _username, QString _password_ha1) { @@ -177,12 +177,12 @@ void HttpServer::setAuthorization(QString _username, QString _password_ha1) {
// Parse HTTP AUTH string
// http://tools.ietf.org/html/rfc2617
bool HttpServer::isAuthorized(QByteArray auth, QString method) const {
qDebug("AUTH string is %s", auth.data());
//qDebug("AUTH string is %s", auth.data());
// Get user name
QRegExp regex_user(".*username=\"([^\"]+)\".*"); // Must be a quoted string
if(regex_user.indexIn(auth) < 0) return false;
QString prop_user = regex_user.cap(1);
qDebug("AUTH: Proposed username is %s, real username is %s", prop_user.toLocal8Bit().data(), username.data());
//qDebug("AUTH: Proposed username is %s, real username is %s", prop_user.toLocal8Bit().data(), username.data());
if(prop_user != username) {
// User name is invalid, we can reject already
qDebug("AUTH-PROB: Username is invalid");

3
src/json.h

@ -109,6 +109,7 @@ namespace json { @@ -109,6 +109,7 @@ namespace json {
}
QVariantMap fromJson(QString json) {
qDebug("JSON is %s", qPrintable(json));
QVariantMap m;
if(json.startsWith("{") && json.endsWith("}")) {
json.chop(1);
@ -144,7 +145,7 @@ namespace json { @@ -144,7 +145,7 @@ namespace json {
if(value_str.startsWith("[") && value_str.endsWith("]")) {
value_str.chop(1);
value_str.replace(0, 1, "");
QStringList list_elems = value_str.split(",");
QStringList list_elems = value_str.split(",", QString::SkipEmptyParts);
QVariantList varlist;
foreach(QString list_val, list_elems) {
if(list_val.startsWith("\"") && list_val.endsWith("\"")) {

8
src/webui/preferences_content.html

@ -110,10 +110,10 @@ @@ -110,10 +110,10 @@
<tr>
<td></td>
<td>
<table style="border: 1px solid black; text-align: center" id="watched_folders_tab">
<thead><tr style="border: 1px solid black;"><th>_(Watched Folder)</th><th>_(Download here)</th></tr></thead>
<table style="text-align: center" border="1" id="watched_folders_tab">
<thead><tr><th>_(Watched Folder)</th><th>_(Download here)</th></tr></thead>
<tbody></tbody>
<tfoot><tr style="border: 1px solid black;"><td style="padding-top:4px;"><input type="text" id="new_watch_folder_txt"/></td><td style="padding-top:4px;"><input type="checkbox" id="new_watch_folder_dl" style="padding-left:18px;"/><img src="images/oxygen/list-add.png" alt="Add" style="padding-left:2px;width:16px;cursor:pointer;margin-right:-18px;" onclick="javascript:addWatchFolder();"/></td></tr></tfoot>
<tfoot><tr><td style="padding-top:4px;"><input type="text" id="new_watch_folder_txt"/></td><td style="padding-top:4px;"><input type="checkbox" id="new_watch_folder_dl" style="padding-left:18px;"/><img src="images/oxygen/list-add.png" alt="Add" style="padding-left:2px;width:16px;cursor:pointer;margin-right:-18px;" onclick="javascript:addWatchFolder();"/></td></tr></tfoot>
</table>
</td>
</tr>
@ -711,10 +711,12 @@ updatePeerProxyAuthSettings = function() { @@ -711,10 +711,12 @@ updatePeerProxyAuthSettings = function() {
getWatchedFolders = function() {
var nb_folders = $("watched_folders_tab").getChildren("tbody")[0].getChildren("tr").length;
alert(nb_folders);
var folders = Array();
var download_in_place = Array();
for(var i=0; i<nb_folders; i+=1) {
var folder_path = $('text_watch_'+i).get('value').trim();
alert(folder_path);
if(folder_path.length > 0) {
folders[folders.length] = folder_path;
if($defined($("cb_watch_"+i).get('checked')) && $("cb_watch_"+i).get('checked')) {

2
src/webui/prop-files.html

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<span id="torrentFiles">
<table class="torrentTable" cellpadding="0" cellspacing="0">
<table class="torrentTable" cellpadding="0" cellspacing="0" style="width: 100%">
<thead>
<tr>
<th><a id="all_files_cb" style="margin-right: 2px;" class="tristate" onclick="javascript:switchCBState()"></a>&nbsp;&nbsp;_(Downloaded)</th>

2
src/webui/prop-trackers.html

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<span id="trackers">
<table class="torrentTable" cellpadding="0" cellspacing="0">
<table class="torrentTable" cellpadding="0" cellspacing="0" style="width: 100%">
<thead>
<tr>
<th>_(URL) <img src="images/oxygen/list-add.png" id="addTrackersPlus" style="width:16px;cursor:pointer;"/></th>

Loading…
Cancel
Save