qDebug(), qInfo(), qWarning(), qCritical(), qFatal() expect %s arguments
to be UTF-8 encoded, while qPrintable() converts to local 8-bit encoding.
Therefore qUtf8Printable() should be used for logging strings instead of
qPrintable().
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.