|
|
@ -39,6 +39,7 @@ |
|
|
|
#include "base/bittorrent/peerinfo.h" |
|
|
|
#include "base/bittorrent/peerinfo.h" |
|
|
|
#include "base/bittorrent/session.h" |
|
|
|
#include "base/bittorrent/session.h" |
|
|
|
#include "base/bittorrent/torrenthandle.h" |
|
|
|
#include "base/bittorrent/torrenthandle.h" |
|
|
|
|
|
|
|
#include "base/bittorrent/trackerentry.h" |
|
|
|
#include "base/global.h" |
|
|
|
#include "base/global.h" |
|
|
|
#include "base/net/geoipmanager.h" |
|
|
|
#include "base/net/geoipmanager.h" |
|
|
|
#include "base/preferences.h" |
|
|
|
#include "base/preferences.h" |
|
|
@ -247,6 +248,22 @@ namespace |
|
|
|
syncData[i.key()] = map; |
|
|
|
syncData[i.key()] = map; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
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: |
|
|
|
default: |
|
|
|
Q_ASSERT(0); |
|
|
|
Q_ASSERT(0); |
|
|
|
} |
|
|
|
} |
|
|
@ -354,6 +371,8 @@ SyncController::~SyncController() |
|
|
|
// - "torrents_removed": a list of hashes of removed torrents
|
|
|
|
// - "torrents_removed": a list of hashes of removed torrents
|
|
|
|
// - "categories": map of categories info
|
|
|
|
// - "categories": map of categories info
|
|
|
|
// - "categories_removed": list of removed categories
|
|
|
|
// - "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
|
|
|
|
// - "server_state": map contains information about the state of the server
|
|
|
|
// The keys of the 'torrents' dictionary are hashes of torrents.
|
|
|
|
// The keys of the 'torrents' dictionary are hashes of torrents.
|
|
|
|
// Each value of the 'torrents' dictionary contains map. The map can contain following keys:
|
|
|
|
// 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(); |
|
|
|
QVariantMap lastAcceptedResponse = sessionManager()->session()->getData(QLatin1String("syncMainDataLastAcceptedResponse")).toMap(); |
|
|
|
|
|
|
|
|
|
|
|
QVariantHash torrents; |
|
|
|
QVariantHash torrents; |
|
|
|
|
|
|
|
QHash<QString, QStringList> trackers; |
|
|
|
for (const BitTorrent::TorrentHandle *torrent : asConst(session->torrents())) { |
|
|
|
for (const BitTorrent::TorrentHandle *torrent : asConst(session->torrents())) { |
|
|
|
const BitTorrent::InfoHash torrentHash = torrent->hash(); |
|
|
|
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; |
|
|
|
torrents[torrentHash] = map; |
|
|
|
} |
|
|
|
} |
|
|
|
data["torrents"] = torrents; |
|
|
|
data["torrents"] = torrents; |
|
|
@ -459,6 +483,12 @@ void SyncController::maindataAction() |
|
|
|
tags << tag; |
|
|
|
tags << tag; |
|
|
|
data["tags"] = tags; |
|
|
|
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(); |
|
|
|
QVariantMap serverState = getTransferInfo(); |
|
|
|
serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); |
|
|
|
serverState[KEY_TRANSFER_FREESPACEONDISK] = getFreeDiskSpace(); |
|
|
|
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); |
|
|
|
serverState[KEY_SYNC_MAINDATA_QUEUEING] = session->isQueueingSystemEnabled(); |
|
|
|