diff --git a/src/headlessloader.h b/src/headlessloader.h index cd4326c37..3d3988faa 100644 --- a/src/headlessloader.h +++ b/src/headlessloader.h @@ -33,13 +33,29 @@ #include #include +#include "preferences.h" +#include "bittorrent.h" class HeadlessLoader: QObject { Q_OBJECT + private: + Bittorrent *BTSession; + public: - HeadlessLoader() { + HeadlessLoader(QStringList torrentCmdLine) { + // Enable Web UI + Preferences::setWebUiEnabled(true); + // TODO: Listen on socket for parameters + // Instanciate Bittorrent Object + BTSession = new Bittorrent(); + // Resume unfinished torrents + BTSession->startUpTorrents(); + // TODO: Process command line parameter + } + ~HeadlessLoader() { + delete BTSession; } public slots: diff --git a/src/main.cpp b/src/main.cpp index 4a3a2116b..065d9a351 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -242,7 +242,7 @@ int main(int argc, char *argv[]){ #else // Load Headless class // TODO: by Frederic Lassabe - HeadlessLoader *loader = new HeadlessLoader(); + HeadlessLoader *loader = new HeadlessLoader(torrentCmdLine); #endif int ret = app->exec(); #ifndef DISABLE_GUI diff --git a/src/preferences.h b/src/preferences.h index 3e7f09130..3873bf22d 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -450,6 +450,11 @@ public: return settings.value("Preferences/WebUI/Enabled", false).toBool(); } + static void setWebUiEnabled(bool enabled) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue("Preferences/WebUI/Enabled", enabled); + } + static quint16 getWebUiPort() { QSettings settings("qBittorrent", "qBittorrent"); return settings.value("Preferences/WebUI/Port", 8080).toInt();