diff --git a/src/webui/api/serialize/serialize_torrent.cpp b/src/webui/api/serialize/serialize_torrent.cpp index 23e53c6ee..a4979008b 100644 --- a/src/webui/api/serialize/serialize_torrent.cpp +++ b/src/webui/api/serialize/serialize_torrent.cpp @@ -32,6 +32,7 @@ #include "base/bittorrent/infohash.h" #include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/trackerentry.h" #include "base/utils/fs.h" namespace @@ -110,6 +111,7 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) {KEY_TORRENT_ADDED_ON, torrent.addedTime().toSecsSinceEpoch()}, {KEY_TORRENT_COMPLETION_ON, torrent.completedTime().toSecsSinceEpoch()}, {KEY_TORRENT_TRACKER, torrent.currentTracker()}, + {KEY_TORRENT_TRACKERS_COUNT, torrent.trackers().size()}, {KEY_TORRENT_DL_LIMIT, torrent.downloadLimit()}, {KEY_TORRENT_UP_LIMIT, torrent.uploadLimit()}, {KEY_TORRENT_AMOUNT_DOWNLOADED, torrent.totalDownload()}, diff --git a/src/webui/api/serialize/serialize_torrent.h b/src/webui/api/serialize/serialize_torrent.h index b02c6574c..af0a01bae 100644 --- a/src/webui/api/serialize/serialize_torrent.h +++ b/src/webui/api/serialize/serialize_torrent.h @@ -61,6 +61,7 @@ const char KEY_TORRENT_SAVE_PATH[] = "save_path"; const char KEY_TORRENT_ADDED_ON[] = "added_on"; const char KEY_TORRENT_COMPLETION_ON[] = "completion_on"; const char KEY_TORRENT_TRACKER[] = "tracker"; +const char KEY_TORRENT_TRACKERS_COUNT[] = "trackers_count"; const char KEY_TORRENT_DL_LIMIT[] = "dl_limit"; const char KEY_TORRENT_UP_LIMIT[] = "up_limit"; const char KEY_TORRENT_AMOUNT_DOWNLOADED[] = "downloaded"; diff --git a/src/webui/api/synccontroller.cpp b/src/webui/api/synccontroller.cpp index 8c5fe4621..5d1db5269 100644 --- a/src/webui/api/synccontroller.cpp +++ b/src/webui/api/synccontroller.cpp @@ -39,6 +39,7 @@ #include "base/bittorrent/peerinfo.h" #include "base/bittorrent/session.h" #include "base/bittorrent/torrenthandle.h" +#include "base/bittorrent/trackerentry.h" #include "base/global.h" #include "base/net/geoipmanager.h" #include "base/preferences.h" @@ -247,6 +248,22 @@ namespace syncData[i.key()] = map; } break; + case QVariant::StringList: + if (!prevData.contains(i.key())) { + // new list item found - append it to syncData + syncData[i.key()] = i.value(); + } + else { + QVariantList list; + QVariantList removedList; + processList(prevData[i.key()].toList(), i.value().toList(), list, removedList); + // existing list item found - remove it from prevData + prevData.remove(i.key()); + if (!list.isEmpty() || !removedList.isEmpty()) + // changed list item found - append entire list to syncData + syncData[i.key()] = i.value(); + } + break; default: Q_ASSERT(0); } @@ -354,6 +371,8 @@ SyncController::~SyncController() // - "torrents_removed": a list of hashes of removed torrents // - "categories": map of categories info // - "categories_removed": list of removed categories +// - "trackers": dictionary contains information about trackers +// - "trackers_removed": a list of removed trackers // - "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: @@ -414,6 +433,7 @@ void SyncController::maindataAction() QVariantMap lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncMainDataLastAcceptedResponse")).toMap(); QVariantHash torrents; + QHash trackers; for (const BitTorrent::TorrentHandle *torrent : asConst(session->torrents())) { const BitTorrent::InfoHash torrentHash = torrent->hash(); @@ -439,6 +459,10 @@ void SyncController::maindataAction() } } + for (const BitTorrent::TrackerEntry &tracker : asConst(torrent->trackers())) { + trackers[tracker.url()] << torrentHash; + } + torrents[torrentHash] = map; } data["torrents"] = torrents; @@ -459,6 +483,12 @@ void SyncController::maindataAction() tags << tag; data["tags"] = tags; + QVariantHash trackersHash; + for (auto i = trackers.constBegin(); i != trackers.constEnd(); ++i) { + trackersHash[i.key()] = i.value(); + } + data["trackers"] = trackersHash; + QVariantMap serverState = getTransferInfo(); serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled();