Commit 10a18679 authored by Àlex Fiestas's avatar Àlex Fiestas

Adapt coding style to kdelibs

Using kdelibs style is not enforced but it is nice to use so all
kde hackers can work on this code without feeling out of place.
parent 566a671b
...@@ -46,8 +46,7 @@ Kded::~Kded() ...@@ -46,8 +46,7 @@ Kded::~Kded()
bool Kded::start() bool Kded::start()
{ {
if (m_daemon) if (m_daemon) {
{
return true; return true;
} }
...@@ -61,34 +60,31 @@ bool Kded::start() ...@@ -61,34 +60,31 @@ bool Kded::start()
m_daemon->setProgram(daemon); m_daemon->setProgram(daemon);
m_daemon->setOutputChannelMode(KProcess::SeparateChannels); m_daemon->setOutputChannelMode(KProcess::SeparateChannels);
m_daemon->start(); m_daemon->start();
if (!m_daemon->waitForStarted(2000)) //FIXME: KDEDs should be non-blocking, do we really need to wait for it to start? if (!m_daemon->waitForStarted(2000)) {//FIXME: KDEDs should be non-blocking, do we really need to wait for it to start?
{
kError(kdeconnect_kded()) << "Can't start " << daemon; kError(kdeconnect_kded()) << "Can't start " << daemon;
return false; return false;
} }
m_daemon->closeReadChannel(KProcess::StandardOutput); m_daemon->closeReadChannel(KProcess::StandardOutput);
kDebug(kdeconnect_kded()) << "Daemon successfuly started"; kDebug(kdeconnect_kded()) << "Daemon successfuly started";
return true; return true;
} }
void Kded::stop() void Kded::stop()
{ {
if (m_daemon) if (!m_daemon) {
{ return true;
m_daemon->terminate(); }
if (m_daemon->waitForFinished(10000))
{ m_daemon->terminate();
kDebug(kdeconnect_kded()) << "Daemon successfuly stopped"; if (m_daemon->waitForFinished(10000)) {
} kDebug(kdeconnect_kded()) << "Daemon successfuly stopped";
else } else {
{ m_daemon->kill();
m_daemon->kill(); kWarning(kdeconnect_kded()) << "Daemon killed";
kWarning(kdeconnect_kded()) << "Daemon killed";
}
m_daemon = 0;
} }
m_daemon = 0;
} }
bool Kded::restart() bool Kded::restart()
...@@ -104,17 +100,15 @@ void Kded::onError(QProcess::ProcessError errorCode) ...@@ -104,17 +100,15 @@ void Kded::onError(QProcess::ProcessError errorCode)
void Kded::onFinished(int exitCode, QProcess::ExitStatus status) void Kded::onFinished(int exitCode, QProcess::ExitStatus status)
{ {
if (status == QProcess::CrashExit) if (status == QProcess::CrashExit) {
{
kError(kdeconnect_kded()) << "Process crashed with code=" << exitCode; kError(kdeconnect_kded()) << "Process crashed with code=" << exitCode;
kError(kdeconnect_kded()) << m_daemon->readAllStandardError(); kError(kdeconnect_kded()) << m_daemon->readAllStandardError();
kWarning(kdeconnect_kded()) << "Restarting in 5 sec..."; kWarning(kdeconnect_kded()) << "Restarting in 5 sec...";
QTimer::singleShot(5000, this, SLOT(start())); QTimer::singleShot(5000, this, SLOT(start()));
} } else {
else
{
kWarning(kdeconnect_kded()) << "Process finished with code=" << exitCode; kWarning(kdeconnect_kded()) << "Process finished with code=" << exitCode;
} }
m_daemon = 0; m_daemon = 0;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment