- Prepare a little headlessloader class

This commit is contained in:
Christophe Dumez 2009-12-15 11:59:48 +00:00
parent 3dc1107b40
commit 1923a51c59
3 changed files with 24 additions and 3 deletions

View file

@ -33,13 +33,29 @@
#include <QObject>
#include <QCoreApplication>
#include "preferences.h"
#include "bittorrent.h"
class HeadlessLoader: QObject {
Q_OBJECT
public:
HeadlessLoader() {
private:
Bittorrent *BTSession;
public:
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:

View file

@ -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

View file

@ -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();