We stored reference to parameters object in main(), but that object gets
deleted when we reset Application object upon entering daemon mode.
Change reference to copy to fix that.
write() is declared with __attribute__ ((__warn_unused_result__)) and as
such we shall check its return value. Took opportunity and adjusted
error reporting a bit: if writing to stderr fails, try to write to
stdout.
Arguments include adding torrents as paused/started, skiping hash check, setting category, downloading in sequential order, downloading first and last pieces first, and skipping the 'add new torrent' dialog. Added TriStateBoolOption class for specifying options that don't have a default value when unused (e.g. add-paused). Also improved command line usage text to include more information, have better organization, and not exceed 80 columns in width. Also also added firstLastPiecePriority field to BitTorrent::AddTorrentData, and modified TorrentHandle so that if first/last piece priority should be on, it will be toggled on after the torrent's metadata has loaded.
Commit dd0537d changed torrents startup code adding alerts processing
into it. Therefore alerts were processed before UI code subscribed to
signals and therefore part of alerts was not reflected in the UI.
Thus here we do not start torrents in Session constructor, but do that
from Application::exec() after UI was constructed and is ready to process
signals.
Conditionally change absolute paths to relative in the fastresume data files.
The condition is specified by user via a command line parameter and
paths are relative to the profile dir.
On Windows the convertion to relative path is performed if the path and
the profile are on the same drive only.
This allows to pass options via environment variables. The variable name
is constructed from parameter name by transforming the name to upper
case and prefixing "QBT_".
It may be useful to have different configurations either for portable
versions or for debugging purposes. To implement this we add two
options, avaliable via command line switches
1. An option to change configuration name ("--configuration"). The name
supplied via this option is appended to
QCoreApplication::applicationName() to form "qBittorrent_<conf_name>"
name for the configuration files.
2. An option to provide a path do directory where all the settings are
stored (kind of profile directory). There is a shortcut "--portable"
which means "use directory 'profile' near the executable location".
In order to implement that we have to perform initialisation of the
profile directories before the SettingStorage and Preferences singletones
are initialised. Thus, options parsing shall be performed without defaults
read from preferences.
Count matched function names, and if there are no, point out to the user
that the stacktrace is useless. If not all stactrace elements contain
function names, suggest user that installing debug packages may improve
the stacktrace usefulness.
Since Apple made difficult for users to set PATH and /usr/bin/python
is almost unusable, I simply add /usr/local/bin before default PATH
to pick up Homebrew Python.
On macOS 10.12 Sierra, Apple changed the behaviour of CFPreferencesSetValue()
truncating data after a null character. https://bugreports.qt.io/browse/QTBUG-56344
Due to this, we have to move from native plist to IniFormat.