Port kded.cpp from kDebug to qCDebug
Also using this opportunity to use a different namespace per component, in this case kdeconnect.kded (instead of just kdeconnect).
This commit is contained in:
parent
aead283da1
commit
54a1e3e7bf
2 changed files with 16 additions and 11 deletions
|
@ -21,28 +21,30 @@
|
||||||
#include "kded.h"
|
#include "kded.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include <KPluginFactory>
|
#include <KPluginFactory>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
|
|
||||||
#include "core/kdebugnamespace.h"
|
|
||||||
#include "config-kded.h"
|
#include "config-kded.h"
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin<Kded>();)
|
K_PLUGIN_FACTORY(KdeConnectFactory, registerPlugin<Kded>();)
|
||||||
K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect-kded"))
|
K_EXPORT_PLUGIN(KdeConnectFactory("kdeconnect", "kdeconnect-kded"))
|
||||||
|
|
||||||
|
Q_LOGGING_CATEGORY(KDECONNECT_KDED, "kdeconnect.kded")
|
||||||
|
|
||||||
Kded::Kded(QObject *parent, const QList<QVariant>&)
|
Kded::Kded(QObject *parent, const QList<QVariant>&)
|
||||||
: KDEDModule(parent)
|
: KDEDModule(parent)
|
||||||
, m_daemon(0)
|
, m_daemon(0)
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
|
||||||
kDebug(debugArea()) << "kded_kdeconnect started";
|
qDebug(KDECONNECT_KDED) << "kded_kdeconnect started";
|
||||||
}
|
}
|
||||||
|
|
||||||
Kded::~Kded()
|
Kded::~Kded()
|
||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
kDebug(debugArea()) << "kded_kdeconnect stopped";
|
qDebug(KDECONNECT_KDED) << "kded_kdeconnect stopped";
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kded::start()
|
void Kded::start()
|
||||||
|
@ -52,7 +54,7 @@ void Kded::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString daemon = QStringLiteral(KDECONNECTD_BIN);
|
const QString daemon = QStringLiteral(KDECONNECTD_BIN);
|
||||||
kDebug(debugArea()) << "Starting daemon " << daemon;
|
qDebug(KDECONNECT_KDED) << "Starting daemon " << daemon;
|
||||||
m_daemon = new KProcess(this);
|
m_daemon = new KProcess(this);
|
||||||
connect(m_daemon, SIGNAL(started()), SLOT(daemonStarted()));
|
connect(m_daemon, SIGNAL(started()), SLOT(daemonStarted()));
|
||||||
connect(m_daemon, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError)));
|
connect(m_daemon, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError)));
|
||||||
|
@ -84,24 +86,24 @@ void Kded::restart()
|
||||||
|
|
||||||
void Kded::onError(QProcess::ProcessError errorCode)
|
void Kded::onError(QProcess::ProcessError errorCode)
|
||||||
{
|
{
|
||||||
kError(debugArea()) << "Process error code=" << errorCode;
|
qCWarning(KDECONNECT_KDED) << "Process error code=" << errorCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Kded::daemonStarted()
|
void Kded::daemonStarted()
|
||||||
{
|
{
|
||||||
kDebug(debugArea()) << "Daemon successfuly started";
|
qDebug(KDECONNECT_KDED) << "Daemon successfuly started";
|
||||||
Q_EMIT started();
|
Q_EMIT started();
|
||||||
}
|
}
|
||||||
|
|
||||||
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(debugArea()) << "Process crashed with code=" << exitCode;
|
qCWarning(KDECONNECT_KDED) << "Process crashed with code=" << exitCode;
|
||||||
kError(debugArea()) << m_daemon->readAllStandardError();
|
qCWarning(KDECONNECT_KDED) << m_daemon->readAllStandardError();
|
||||||
kWarning(debugArea()) << "Restarting in 5 sec...";
|
qCWarning(KDECONNECT_KDED) << "Restarting in 5 sec...";
|
||||||
QTimer::singleShot(5000, this, SLOT(start()));
|
QTimer::singleShot(5000, this, SLOT(start()));
|
||||||
} else {
|
} else {
|
||||||
kWarning(debugArea()) << "Process finished with code=" << exitCode;
|
qCWarning(KDECONNECT_KDED) << "Process finished with code=" << exitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EMIT stopped();
|
Q_EMIT stopped();
|
||||||
|
@ -115,7 +117,7 @@ void Kded::checkIfDaemonTerminated()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_daemon->kill();
|
m_daemon->kill();
|
||||||
kWarning(debugArea()) << "Daemon killed";
|
qCWarning(KDECONNECT_KDED) << "Daemon killed";
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "kded.moc"
|
#include "kded.moc"
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <KDEDModule>
|
#include <KDEDModule>
|
||||||
#include <KProcess>
|
#include <KProcess>
|
||||||
|
|
||||||
|
#include <QLoggingCategory>
|
||||||
|
|
||||||
class Kded
|
class Kded
|
||||||
: public KDEDModule
|
: public KDEDModule
|
||||||
{
|
{
|
||||||
|
@ -54,4 +56,5 @@ private:
|
||||||
KProcess* m_daemon;
|
KProcess* m_daemon;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_LOGGING_CATEGORY(KDECONNECT_KDED)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue