From d17f21af45c39dad792e3d1e96e549d33a8bb179 Mon Sep 17 00:00:00 2001 From: buinsky Date: Thu, 29 Jan 2015 16:42:04 +0300 Subject: [PATCH] Queueing flag relocation in sync/maindata response --- src/webui/btjson.cpp | 13 ++++++++---- src/webui/www/public/scripts/client.js | 28 ++++++++++++++------------ 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/webui/btjson.cpp b/src/webui/btjson.cpp index 2f5cf515d..7d4acc167 100644 --- a/src/webui/btjson.cpp +++ b/src/webui/btjson.cpp @@ -144,6 +144,9 @@ static const char KEY_TRANSFER_UPRATELIMIT[] = "up_rate_limit"; static const char KEY_TRANSFER_DHT_NODES[] = "dht_nodes"; static const char KEY_TRANSFER_CONNECTION_STATUS[] = "connection_status"; +// Sync main data keys +static const char KEY_SYNC_MAINDATA_QUEUEING[] = "queueing"; + static const char KEY_FULL_UPDATE[] = "full_update"; static const char KEY_RESPONSE_ID[] = "rid"; static const char KEY_SUFFIX_REMOVED[] = "_removed"; @@ -274,8 +277,7 @@ QByteArray btjson::getTorrents(QString filter, QString label, * - "torrents_removed": a list of hashes of removed torrents * - "labels": list of labels * - "labels_removed": list of removed labels - * - "queueing": priority system usage flag - * - "server_state": map contains information about the status of the server + * - "server_state": map contains information about the state of the server * The keys of the 'torrents' dictionary are hashes of torrents. * Each value of the 'torrents' dictionary contains map. The map can contain following keys: * - "name": Torrent name @@ -302,6 +304,7 @@ QByteArray btjson::getTorrents(QString filter, QString label, * - "up_info_data: bytes uploaded * - "up_info_speed: upload speed * - "up_rate_limit: upload speed limit + * - "queueing": priority system usage flag */ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData, QVariantMap &lastAcceptedData) { @@ -321,14 +324,16 @@ QByteArray btjson::getSyncMainData(int acceptedResponseId, QVariantMap &lastData } data["torrents"] = torrents; - data["queueing"] = QBtSession::instance()->isQueueingEnabled(); QVariantList labels; foreach (QString s, Preferences::instance()->getTorrentLabels()) labels << s; data["labels"] = labels; - data["server_state"] = getTranserInfoMap(); + + QVariantMap serverState = getTranserInfoMap(); + serverState[KEY_SYNC_MAINDATA_QUEUEING] = QBtSession::instance()->isQueueingEnabled(); + data["server_state"] = serverState; return json::toJson(generateSyncData(acceptedResponseId, data, lastAcceptedData, lastData)); } diff --git a/src/webui/www/public/scripts/client.js b/src/webui/www/public/scripts/client.js index 9f3d07cc7..8f34665a3 100644 --- a/src/webui/www/public/scripts/client.js +++ b/src/webui/www/public/scripts/client.js @@ -27,6 +27,7 @@ myTable = new dynamicTable(); var updatePropertiesPanel = function(){}; var updateMainData = function(){}; var alternativeSpeedLimits = false; +var queueing_enabled = true; selected_filter = getLocalStorageItem('selected_filter', 'all'); selected_label = null; @@ -153,19 +154,6 @@ window.addEvent('load', function () { myTable.rows.erase(); if (response['rid']) syncMainDataLastResponseId = response['rid']; - if ('queueing' in response) { - var queueing_enabled = response['queueing']; - myTable.columns['priority'].force_hide = !queueing_enabled; - myTable.updateColumn('priority'); - if (queueing_enabled) { - $('queueingButtons').removeClass('invisible'); - $('queueingMenuItems').removeClass('invisible'); - } - else { - $('queueingButtons').addClass('invisible'); - $('queueingMenuItems').addClass('invisible'); - } - } if (response['torrents']) for (var key in response['torrents']) { response['torrents'][key]['hash'] = key; @@ -220,6 +208,20 @@ window.addEvent('load', function () { $('connectionStatus').src = 'images/skin/firewalled.png'; else $('connectionStatus').src = 'images/skin/disconnected.png'; + + if (queueing_enabled != serverState.queueing) { + queueing_enabled = serverState.queueing; + myTable.columns['priority'].force_hide = !queueing_enabled; + myTable.updateColumn('priority'); + if (queueing_enabled) { + $('queueingButtons').removeClass('invisible'); + $('queueingMenuItems').removeClass('invisible'); + } + else { + $('queueingButtons').addClass('invisible'); + $('queueingMenuItems').addClass('invisible'); + } + } }; var updateAltSpeedIcon = function(enabled) {