From 1811ec6cab02ec4dc1445cc6adb5f738a3fa6edc Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Sat, 18 Aug 2012 17:33:51 +0200 Subject: [PATCH 1/4] Optional daemon-mode for qbittorrent-nox --- doc/qbittorrent-nox.1 | 2 +- src/main.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/doc/qbittorrent-nox.1 b/doc/qbittorrent-nox.1 index 2fcc644e0..531e49d79 100644 --- a/doc/qbittorrent-nox.1 +++ b/doc/qbittorrent-nox.1 @@ -8,7 +8,7 @@ qBittorrent\-nox \- a command line Bittorrent client written in C++ / Qt4 .SH "SYNOPSIS" -\fBqbittorrent\-nox\fR [\-\-webui-port=x] [TORRENT_FILE | URL]... +\fBqbittorrent\-nox\fR [\-\-d|\-\-daemon] [\-\-webui-port=x] [TORRENT_FILE | URL]... \fBqbittorrent\-nox\fR \-\-help diff --git a/src/main.cpp b/src/main.cpp index 8aef644d0..54ecab20e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,6 +74,8 @@ public: std::cout << '\t' << prg_name << " --version: " << qPrintable(tr("displays program version")) << std::endl; #ifndef DISABLE_GUI std::cout << '\t' << prg_name << " --no-splash: " << qPrintable(tr("disable splash screen")) << std::endl; +#else + std::cout << '\t' << prg_name << " -d | --daemon: " << qPrintable(tr("run in daemon-mode (background)")) << std::endl; #endif std::cout << '\t' << prg_name << " --help: " << qPrintable(tr("displays this help message")) << std::endl; std::cout << '\t' << prg_name << " --webui-port=x: " << qPrintable(tr("changes the webui port (current: %1)").arg(QString::number(Preferences().getWebUiPort()))) << std::endl; @@ -158,6 +160,20 @@ int main(int argc, char *argv[]) { // Create Application QString uid = misc::getUserIDString(); #ifdef DISABLE_GUI + bool becomedaemon = false; + for(int i=1; i Date: Sat, 18 Aug 2012 18:03:03 +0200 Subject: [PATCH 2/4] shouldDaemonize en qcritical --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 54ecab20e..27ea1bcb3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -160,18 +160,18 @@ int main(int argc, char *argv[]) { // Create Application QString uid = misc::getUserIDString(); #ifdef DISABLE_GUI - bool becomedaemon = false; + bool shouldDaemonize = false; for(int i=1; i Date: Sat, 18 Aug 2012 18:11:27 +0200 Subject: [PATCH 3/4] Completed previous commit Added some suggestions for the previous commit from Christophe Dumez and made sure the argument directly after -d is looked at. --- src/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 27ea1bcb3..795c274bf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -168,12 +168,9 @@ int main(int argc, char *argv[]) { for(int j=i; j Date: Sat, 18 Aug 2012 18:34:36 +0200 Subject: [PATCH 4/4] forgot to change the string --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 795c274bf..0787aa5e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -201,7 +201,7 @@ int main(int argc, char *argv[]) { bool no_splash = false; #else if(shouldDaemonize && daemon(1, 0) != 0) { - qCritical("Something went wrong while transforming into a daemon, exiting..."); + qCritical("Something went wrong while daemonizing, exiting..."); return EXIT_FAILURE; } #endif