|
|
@ -82,50 +82,55 @@ namespace |
|
|
|
|
|
|
|
|
|
|
|
QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) |
|
|
|
QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QVariantMap ret; |
|
|
|
QVariantMap ret = { |
|
|
|
ret[KEY_TORRENT_HASH] = QString(torrent.hash()); |
|
|
|
{KEY_TORRENT_HASH, QString(torrent.hash())}, |
|
|
|
ret[KEY_TORRENT_NAME] = torrent.name(); |
|
|
|
{KEY_TORRENT_NAME, torrent.name()}, |
|
|
|
ret[KEY_TORRENT_MAGNET_URI] = torrent.toMagnetUri(); |
|
|
|
{KEY_TORRENT_MAGNET_URI, torrent.toMagnetUri()}, |
|
|
|
ret[KEY_TORRENT_SIZE] = torrent.wantedSize(); |
|
|
|
{KEY_TORRENT_SIZE, torrent.wantedSize()}, |
|
|
|
ret[KEY_TORRENT_PROGRESS] = torrent.progress(); |
|
|
|
{KEY_TORRENT_PROGRESS, torrent.progress()}, |
|
|
|
ret[KEY_TORRENT_DLSPEED] = torrent.downloadPayloadRate(); |
|
|
|
{KEY_TORRENT_DLSPEED, torrent.downloadPayloadRate()}, |
|
|
|
ret[KEY_TORRENT_UPSPEED] = torrent.uploadPayloadRate(); |
|
|
|
{KEY_TORRENT_UPSPEED, torrent.uploadPayloadRate()}, |
|
|
|
ret[KEY_TORRENT_QUEUE_POSITION] = static_cast<int>(torrent.queuePosition()); |
|
|
|
{KEY_TORRENT_QUEUE_POSITION, torrent.queuePosition()}, |
|
|
|
ret[KEY_TORRENT_SEEDS] = torrent.seedsCount(); |
|
|
|
{KEY_TORRENT_SEEDS, torrent.seedsCount()}, |
|
|
|
ret[KEY_TORRENT_NUM_COMPLETE] = torrent.totalSeedsCount(); |
|
|
|
{KEY_TORRENT_NUM_COMPLETE, torrent.totalSeedsCount()}, |
|
|
|
ret[KEY_TORRENT_LEECHS] = torrent.leechsCount(); |
|
|
|
{KEY_TORRENT_LEECHS, torrent.leechsCount()}, |
|
|
|
ret[KEY_TORRENT_NUM_INCOMPLETE] = torrent.totalLeechersCount(); |
|
|
|
{KEY_TORRENT_NUM_INCOMPLETE, torrent.totalLeechersCount()}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{KEY_TORRENT_STATE, torrentStateToString(torrent.state())}, |
|
|
|
|
|
|
|
{KEY_TORRENT_ETA, torrent.eta()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_SEQUENTIAL_DOWNLOAD, torrent.isSequentialDownload()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_FIRST_LAST_PIECE_PRIO, torrent.hasFirstLastPiecePriority()}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{KEY_TORRENT_CATEGORY, torrent.category()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_TAGS, torrent.tags().toList().join(", ")}, |
|
|
|
|
|
|
|
{KEY_TORRENT_SUPER_SEEDING, torrent.superSeeding()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_FORCE_START, torrent.isForced()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_SAVE_PATH, Utils::Fs::toNativePath(torrent.savePath())}, |
|
|
|
|
|
|
|
{KEY_TORRENT_ADDED_ON, torrent.addedTime().toTime_t()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_COMPLETION_ON, torrent.completedTime().toTime_t()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_TRACKER, torrent.currentTracker()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_DL_LIMIT, torrent.downloadLimit()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_UP_LIMIT, torrent.uploadLimit()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AMOUNT_DOWNLOADED, torrent.totalDownload()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AMOUNT_UPLOADED, torrent.totalUpload()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION, torrent.totalPayloadDownload()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AMOUNT_UPLOADED_SESSION, torrent.totalPayloadUpload()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AMOUNT_LEFT, torrent.incompletedSize()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AMOUNT_COMPLETED, torrent.completedSize()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_MAX_RATIO, torrent.maxRatio()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_MAX_SEEDING_TIME, torrent.maxSeedingTime()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_RATIO_LIMIT, torrent.ratioLimit()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_SEEDING_TIME_LIMIT, torrent.seedingTimeLimit()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_LAST_SEEN_COMPLETE_TIME, torrent.lastSeenComplete().toTime_t()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AUTO_TORRENT_MANAGEMENT, torrent.isAutoTMMEnabled()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_TIME_ACTIVE, torrent.activeTime()}, |
|
|
|
|
|
|
|
{KEY_TORRENT_AVAILABILITY, torrent.distributedCopies()}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{KEY_TORRENT_TOTAL_SIZE, torrent.totalSize()} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const qreal ratio = torrent.realRatio(); |
|
|
|
const qreal ratio = torrent.realRatio(); |
|
|
|
ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::TorrentHandle::MAX_RATIO) ? -1 : ratio; |
|
|
|
ret[KEY_TORRENT_RATIO] = (ratio > BitTorrent::TorrentHandle::MAX_RATIO) ? -1 : ratio; |
|
|
|
ret[KEY_TORRENT_STATE] = torrentStateToString(torrent.state()); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_ETA] = torrent.eta(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_SEQUENTIAL_DOWNLOAD] = torrent.isSequentialDownload(); |
|
|
|
|
|
|
|
if (torrent.hasMetadata()) |
|
|
|
|
|
|
|
ret[KEY_TORRENT_FIRST_LAST_PIECE_PRIO] = torrent.hasFirstLastPiecePriority(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_CATEGORY] = torrent.category(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_TAGS] = torrent.tags().toList().join(", "); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_SUPER_SEEDING] = torrent.superSeeding(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_FORCE_START] = torrent.isForced(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_SAVE_PATH] = Utils::Fs::toNativePath(torrent.savePath()); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_ADDED_ON] = torrent.addedTime().toTime_t(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_COMPLETION_ON] = torrent.completedTime().toTime_t(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_TRACKER] = torrent.currentTracker(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_DL_LIMIT] = torrent.downloadLimit(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_UP_LIMIT] = torrent.uploadLimit(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AMOUNT_DOWNLOADED] = torrent.totalDownload(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AMOUNT_UPLOADED] = torrent.totalUpload(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AMOUNT_DOWNLOADED_SESSION] = torrent.totalPayloadDownload(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AMOUNT_UPLOADED_SESSION] = torrent.totalPayloadUpload(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AMOUNT_LEFT] = torrent.incompletedSize(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AMOUNT_COMPLETED] = torrent.completedSize(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_MAX_RATIO] = torrent.maxRatio(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_MAX_SEEDING_TIME] = torrent.maxSeedingTime(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_RATIO_LIMIT] = torrent.ratioLimit(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_SEEDING_TIME_LIMIT] = torrent.seedingTimeLimit(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_LAST_SEEN_COMPLETE_TIME] = torrent.lastSeenComplete().toTime_t(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AUTO_TORRENT_MANAGEMENT] = torrent.isAutoTMMEnabled(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_TIME_ACTIVE] = torrent.activeTime(); |
|
|
|
|
|
|
|
ret[KEY_TORRENT_AVAILABILITY] = torrent.distributedCopies(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (torrent.isPaused() || torrent.isChecking()) { |
|
|
|
if (torrent.isPaused() || torrent.isChecking()) { |
|
|
|
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = 0; |
|
|
|
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = 0; |
|
|
@ -136,7 +141,5 @@ QVariantMap serialize(const BitTorrent::TorrentHandle &torrent) |
|
|
|
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = dt.toTime_t(); |
|
|
|
ret[KEY_TORRENT_LAST_ACTIVITY_TIME] = dt.toTime_t(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ret[KEY_TORRENT_TOTAL_SIZE] = torrent.totalSize(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|