Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport changes to v4.6.x branch #19751

Merged
merged 24 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7b73d3f
Add I2P settings to WebUI
thalieht Oct 13, 2023
dc31e82
CI: Use dynamic MSVC run-time library
glassez Oct 17, 2023
4b56bdd
Combine CSS properties
Chocobo1 Oct 19, 2023
42d7465
Prevent crash due to race condition when adding magnet link
glassez Oct 28, 2023
a1317e2
Fix Enter key behavior when add new torrent
glassez Oct 28, 2023
a396e0d
WebUI: Fix duplicate scrollbar on Transfer List
AgentConDier Oct 29, 2023
bb6d69f
Remove "Physical memory (RAM) usage limit" option on macOS #19805
Chocobo1 Oct 29, 2023
31e0ab2
GHA CI: don't override cmake default CXXFLAGS
Chocobo1 Oct 27, 2023
3c0747f
Add missing main window icon
iomezk Oct 31, 2023
d5c0c09
Don't forget to delete TorrentContentAdaptor instance
glassez Oct 31, 2023
ee853d8
Fix .torrent file upload on iPadOS
vit9696 Nov 1, 2023
b284d40
Update size of selected files when selection is changed
glassez Nov 1, 2023
a14b50e
Correctly handle changing save path of torrent w/o metadata
glassez Nov 1, 2023
54dffa1
Allow to request torrents count via WebAPI
glassez Nov 2, 2023
837d39d
WebUI: Fix incorrect subcategory sorting
Bartuzen Nov 2, 2023
903173b
Always use QStyledItemDelegate as base of delegate classes
glassez Jul 21, 2023
c2dd53c
Use appropriate icon for "moving" torrents in transfer list
xavier2k6 Nov 4, 2023
c7dfc1d
Remove column span
Chocobo1 Aug 4, 2023
2c2252d
WebUI: Remove extra ')' in QBT_TR macro
itsnotv Nov 8, 2023
786c09e
Drop WebUI default credentials
glassez Nov 10, 2023
3007762
WebUI: Correctly set save path in RSS rules
glassez Nov 11, 2023
43300d9
WebUI: Minor optimizations to the login page
sledgehammer999 Mar 20, 2023
59d968e
Improve performance of getting torrent numbers via WebAPI
Chocobo1 Nov 12, 2023
b824889
Improve free disk space checking for WebAPI
glassez Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/ci_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,34 +90,35 @@ jobs:
--recurse-submodules `
https://github.com/arvidn/libtorrent.git
cd libtorrent
$env:CXXFLAGS+=" /guard:cf"
$env:LDFLAGS+=" /guard:cf"
cmake `
-B build `
-G "Ninja" `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_CXX_FLAGS=/guard:cf `
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
-DCMAKE_INSTALL_PREFIX="${{ env.libtorrent_path }}" `
-DCMAKE_TOOLCHAIN_FILE="${{ env.RUNVCPKG_VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" `
-DBOOST_ROOT="${{ env.boost_path }}" `
-DBUILD_SHARED_LIBS=OFF `
-Ddeprecated-functions=OFF `
-Dstatic_runtime=ON `
-Dstatic_runtime=OFF `
-DVCPKG_TARGET_TRIPLET=x64-windows-static-release
cmake --build build
cmake --install build

- name: Build qBittorrent
run: |
$env:CXXFLAGS+=" /WX"
cmake `
-B build `
-G "Ninja" `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_CXX_FLAGS="/WX" `
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
-DCMAKE_TOOLCHAIN_FILE="${{ env.RUNVCPKG_VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" `
-DBOOST_ROOT="${{ env.boost_path }}" `
-DLibtorrentRasterbar_DIR="${{ env.libtorrent_path }}/lib/cmake/LibtorrentRasterbar" `
-DMSVC_RUNTIME_DYNAMIC=OFF `
-DMSVC_RUNTIME_DYNAMIC=ON `
-DQT6=ON `
-DTESTING=ON `
-DVCPKG_TARGET_TRIPLET=x64-windows-static-release `
Expand Down
42 changes: 27 additions & 15 deletions src/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
#include "gui/mainwindow.h"
#include "gui/shutdownconfirmdialog.h"
#include "gui/uithememanager.h"
#include "gui/utils.h"
#include "gui/windowstate.h"

#ifdef Q_OS_WIN
Expand All @@ -106,6 +105,9 @@

#ifndef DISABLE_WEBUI
#include "webui/webui.h"
#ifdef DISABLE_GUI
#include "base/utils/password.h"
#endif
#endif

namespace
Expand Down Expand Up @@ -310,8 +312,8 @@ Application::Application(int &argc, char **argv)
if (isFileLoggerEnabled())
m_fileLogger = new FileLogger(fileLoggerPath(), isFileLoggerBackup(), fileLoggerMaxSize(), isFileLoggerDeleteOld(), fileLoggerAge(), static_cast<FileLogger::FileLogAgeType>(fileLoggerAgeType()));

if (m_commandLineArgs.webUiPort > 0) // it will be -1 when user did not set any value
Preferences::instance()->setWebUiPort(m_commandLineArgs.webUiPort);
if (m_commandLineArgs.webUIPort > 0) // it will be -1 when user did not set any value
Preferences::instance()->setWebUIPort(m_commandLineArgs.webUIPort);

if (m_commandLineArgs.torrentingPort > 0) // it will be -1 when user did not set any value
{
Expand Down Expand Up @@ -375,7 +377,7 @@ void Application::setMemoryWorkingSetLimit(const int size)
return;

m_storeMemoryWorkingSetLimit = size;
#ifdef QBT_USES_LIBTORRENT2
#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
applyMemoryWorkingSetLimit();
#endif
}
Expand Down Expand Up @@ -773,7 +775,7 @@ int Application::exec()
printf("%s\n", qUtf8Printable(loadingStr));
#endif

#ifdef QBT_USES_LIBTORRENT2
#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
applyMemoryWorkingSetLimit();
#endif

Expand Down Expand Up @@ -899,25 +901,28 @@ int Application::exec()
#endif // DISABLE_GUI

#ifndef DISABLE_WEBUI
#ifndef DISABLE_GUI
m_webui = new WebUI(this);
#ifdef DISABLE_GUI
#else
const Preferences *pref = Preferences::instance();
const QString tempPassword = pref->getWebUIPassword().isEmpty()
? Utils::Password::generate() : QString();
m_webui = new WebUI(this, (!tempPassword.isEmpty() ? Utils::Password::PBKDF2::generate(tempPassword) : QByteArray()));
if (m_webui->isErrored())
QCoreApplication::exit(EXIT_FAILURE);
connect(m_webui, &WebUI::fatalError, this, []() { QCoreApplication::exit(EXIT_FAILURE); });

const Preferences *pref = Preferences::instance();

const auto scheme = pref->isWebUiHttpsEnabled() ? u"https"_s : u"http"_s;
const auto url = u"%1://localhost:%2\n"_s.arg(scheme, QString::number(pref->getWebUiPort()));
const auto scheme = pref->isWebUIHttpsEnabled() ? u"https"_s : u"http"_s;
const auto url = u"%1://localhost:%2\n"_s.arg(scheme, QString::number(pref->getWebUIPort()));
const QString mesg = u"\n******** %1 ********\n"_s.arg(tr("Information"))
+ tr("To control qBittorrent, access the WebUI at: %1").arg(url);
printf("%s\n", qUtf8Printable(mesg));

if (pref->getWebUIPassword() == QByteArrayLiteral("ARQ77eY1NUZaQsuDHbIMCA==:0WMRkYTUWVT9wVvdDtHAjU9b3b7uB8NR1Gur2hmQCvCDpm39Q+PsJRJPaCU51dEiz+dTzh8qbPsL8WkFljQYFQ=="))
if (!tempPassword.isEmpty())
{
const QString warning = tr("The Web UI administrator username is: %1").arg(pref->getWebUiUsername()) + u'\n'
+ tr("The Web UI administrator password has not been changed from the default: %1").arg(u"adminadmin"_s) + u'\n'
+ tr("This is a security risk, please change your password in program preferences.") + u'\n';
const QString warning = tr("The WebUI administrator username is: %1").arg(pref->getWebUIUsername()) + u'\n'
+ tr("The WebUI administrator password was not set. A temporary password is provided for this session: %1").arg(tempPassword) + u'\n'
+ tr("You should set your own password in program preferences.") + u'\n';
printf("%s", qUtf8Printable(warning));
}
#endif // DISABLE_GUI
Expand Down Expand Up @@ -1080,7 +1085,7 @@ void Application::shutdownCleanup(QSessionManager &manager)
}
#endif

#ifdef QBT_USES_LIBTORRENT2
#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
void Application::applyMemoryWorkingSetLimit() const
{
const size_t MiB = 1024 * 1024;
Expand Down Expand Up @@ -1300,3 +1305,10 @@ void Application::cleanup()
Utils::Misc::shutdownComputer(m_shutdownAct);
}
}

#ifndef DISABLE_WEBUI
WebUI *Application::webUI() const
{
return m_webui;
}
#endif
6 changes: 5 additions & 1 deletion src/app/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,16 @@ private slots:
#endif

private:
#ifndef DISABLE_WEBUI
WebUI *webUI() const override;
#endif

void initializeTranslation();
void processParams(const QBtCommandLineParameters &params);
void runExternalProgram(const QString &programTemplate, const BitTorrent::Torrent *torrent) const;
void sendNotificationEmail(const BitTorrent::Torrent *torrent);

#ifdef QBT_USES_LIBTORRENT2
#if defined(QBT_USES_LIBTORRENT2) && !defined(Q_OS_MACOS)
void applyMemoryWorkingSetLimit() const;
#endif

Expand Down
10 changes: 5 additions & 5 deletions src/app/cmdoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ QBtCommandLineParameters::QBtCommandLineParameters(const QProcessEnvironment &en
#elif !defined(Q_OS_WIN)
, shouldDaemonize(DAEMON_OPTION.value(env))
#endif
, webUiPort(WEBUI_PORT_OPTION.value(env, -1))
, webUIPort(WEBUI_PORT_OPTION.value(env, -1))
, torrentingPort(TORRENTING_PORT_OPTION.value(env, -1))
, skipDialog(SKIP_DIALOG_OPTION.value(env))
, profileDir(PROFILE_OPTION.value(env))
Expand All @@ -373,7 +373,7 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)

if ((arg.startsWith(u"--") && !arg.endsWith(u".torrent"))
|| (arg.startsWith(u'-') && (arg.size() == 2)))
{
{
// Parse known parameters
if (arg == SHOW_HELP_OPTION)
{
Expand All @@ -387,8 +387,8 @@ QBtCommandLineParameters parseCommandLine(const QStringList &args)
#endif
else if (arg == WEBUI_PORT_OPTION)
{
result.webUiPort = WEBUI_PORT_OPTION.value(arg);
if ((result.webUiPort < 1) || (result.webUiPort > 65535))
result.webUIPort = WEBUI_PORT_OPTION.value(arg);
if ((result.webUIPort < 1) || (result.webUIPort > 65535))
throw CommandLineParameterError(QCoreApplication::translate("CMD Options", "%1 must specify a valid port (1 to 65535).")
.arg(u"--webui-port"_s));
}
Expand Down Expand Up @@ -509,7 +509,7 @@ QString makeUsage(const QString &prgName)
#endif
+ SHOW_HELP_OPTION.usage() + wrapText(QCoreApplication::translate("CMD Options", "Display this help message and exit")) + u'\n'
+ WEBUI_PORT_OPTION.usage(QCoreApplication::translate("CMD Options", "port"))
+ wrapText(QCoreApplication::translate("CMD Options", "Change the Web UI port"))
+ wrapText(QCoreApplication::translate("CMD Options", "Change the WebUI port"))
+ u'\n'
+ TORRENTING_PORT_OPTION.usage(QCoreApplication::translate("CMD Options", "port"))
+ wrapText(QCoreApplication::translate("CMD Options", "Change the torrenting port"))
Expand Down
2 changes: 1 addition & 1 deletion src/app/cmdoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct QBtCommandLineParameters
#elif !defined(Q_OS_WIN)
bool shouldDaemonize = false;
#endif
int webUiPort = -1;
int webUIPort = -1;
int torrentingPort = -1;
std::optional<bool> skipDialog;
Path profileDir;
Expand Down
7 changes: 6 additions & 1 deletion src/base/bittorrent/sessionimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,11 @@ bool SessionImpl::cancelDownloadMetadata(const TorrentID &id)
return false;

const lt::torrent_handle nativeHandle = downloadedMetadataIter.value();
m_downloadedMetadata.erase(downloadedMetadataIter);

if (!nativeHandle.is_valid())
return true;

#ifdef QBT_USES_LIBTORRENT2
const InfoHash infoHash {nativeHandle.info_hashes()};
if (infoHash.isHybrid())
Expand All @@ -2445,7 +2450,7 @@ bool SessionImpl::cancelDownloadMetadata(const TorrentID &id)
m_downloadedMetadata.remove((altID == downloadedMetadataIter.key()) ? id : altID);
}
#endif
m_downloadedMetadata.erase(downloadedMetadataIter);

m_nativeSession->remove_torrent(nativeHandle, lt::session::delete_files);
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/base/bittorrent/torrentimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,7 @@ void TorrentImpl::moveStorage(const Path &newPath, const MoveStorageContext cont
{
if (!hasMetadata())
{
m_savePath = newPath;
m_session->handleTorrentSavePathChanged(this);
return;
}
Expand Down
5 changes: 5 additions & 0 deletions src/base/interfaces/iapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
class QString;

class Path;
class WebUI;
struct QBtCommandLineParameters;

#ifdef Q_OS_WIN
Expand Down Expand Up @@ -83,4 +84,8 @@ class IApplication
virtual MemoryPriority processMemoryPriority() const = 0;
virtual void setProcessMemoryPriority(MemoryPriority priority) = 0;
#endif

#ifndef DISABLE_WEBUI
virtual WebUI *webUI() const = 0;
#endif
};