Add compile definition to indicate using of libtorrent 2.0 (#15297)

The compile definition is temporary which will be removed when qbt
ditches libtorrent 1.x.
This commit is contained in:
Chocobo1 2021-08-08 13:27:22 +08:00 committed by GitHub
parent bed643e627
commit 138c911ef4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 85 additions and 93 deletions

View file

@ -96,18 +96,18 @@ namespace
// libtorrent section
LIBTORRENT_HEADER,
ASYNC_IO_THREADS,
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
HASHING_THREADS,
#endif
FILE_POOL_SIZE,
CHECKING_MEM_USAGE,
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
// cache
DISK_CACHE,
DISK_CACHE_TTL,
#endif
OS_CACHE,
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
COALESCE_RW,
#endif
PIECE_EXTENT_AFFINITY,
@ -199,7 +199,7 @@ void AdvancedSettings::saveAdvancedSettings()
#endif
// Async IO threads
session->setAsyncIOThreads(m_spinBoxAsyncIOThreads.value());
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
// Hashing threads
session->setHashingThreads(m_spinBoxHashingThreads.value());
#endif
@ -207,14 +207,14 @@ void AdvancedSettings::saveAdvancedSettings()
session->setFilePoolSize(m_spinBoxFilePoolSize.value());
// Checking Memory Usage
session->setCheckingMemUsage(m_spinBoxCheckingMemUsage.value());
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
// Disk write cache
session->setDiskCacheSize(m_spinBoxCache.value());
session->setDiskCacheTTL(m_spinBoxCacheTTL.value());
#endif
// Enable OS cache
session->setUseOSCache(m_checkBoxOsCache.isChecked());
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
// Coalesce reads & writes
session->setCoalesceReadWriteEnabled(m_checkBoxCoalesceRW.isChecked());
#endif
@ -321,7 +321,7 @@ void AdvancedSettings::saveAdvancedSettings()
session->setPeerTurnoverInterval(m_spinBoxPeerTurnoverInterval.value());
}
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
void AdvancedSettings::updateCacheSpinSuffix(int value)
{
if (value == 0)
@ -445,7 +445,7 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(ASYNC_IO_THREADS, (tr("Asynchronous I/O threads") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#aio_threads", "(?)"))
, &m_spinBoxAsyncIOThreads);
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
// Hashing threads
m_spinBoxHashingThreads.setMinimum(1);
m_spinBoxHashingThreads.setMaximum(1024);
@ -474,7 +474,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxCheckingMemUsage.setSuffix(tr(" MiB"));
addRow(CHECKING_MEM_USAGE, (tr("Outstanding memory when checking torrents") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#checking_mem_usage", "(?)"))
, &m_spinBoxCheckingMemUsage);
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
// Disk write cache
m_spinBoxCache.setMinimum(-1);
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
@ -502,7 +502,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_checkBoxOsCache.setChecked(session->useOSCache());
addRow(OS_CACHE, (tr("Enable OS cache") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode", "(?)"))
, &m_checkBoxOsCache);
#if (LIBTORRENT_VERSION_NUM < 20000)
#ifndef QBT_USES_LIBTORRENT2
// Coalesce reads & writes
m_checkBoxCoalesceRW.setChecked(session->isCoalesceReadWriteEnabled());
addRow(COALESCE_RW, (tr("Coalesce reads & writes") + ' ' + makeLink("https://www.libtorrent.org/reference-Settings.html#coalesce_reads", "(?)"))