Commit 3ff35903 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 14c23ed5
......@@ -23,21 +23,21 @@
#include "kwrited.h"
#include <QDebug>
#include <kaboutdata.h>
#include <klocalizedstring.h>
#include <knotification.h>
#include <kptydevice.h>
#include <kuser.h>
#include <knotification.h>
#include <klocalizedstring.h>
#include <kaboutdata.h>
#if defined(BUILD_AS_EXECUTABLE)
# include <QGuiApplication>
# include <QSessionManager>
# include <signal.h>
# include <sys/types.h>
# include <unistd.h>
#include <QGuiApplication>
#include <QSessionManager>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#else
# include <kpluginfactory.h>
# include <kpluginloader.h>
#include <kpluginfactory.h>
#include <kpluginloader.h>
#endif
static inline KAboutData aboutData()
......@@ -58,13 +58,13 @@ static void sigterm_handler(int signal)
int main(int argc, char **argv)
{
//drop elevated privileges temporarily
// drop elevated privileges temporarily
original_euid = geteuid();
original_egid = getegid();
seteuid(getuid());
setegid(getgid());
//install a signal handler to exit gracefully
// install a signal handler to exit gracefully
//(so that pty->logout() is called in ~KWrited())
signal(SIGTERM, sigterm_handler);
signal(SIGINT, sigterm_handler);
......@@ -86,7 +86,7 @@ int main(int argc, char **argv)
#else // BUILD_AS_EXECUTABLE
KWritedModule::KWritedModule(QObject* parent, const QList<QVariant>&)
KWritedModule::KWritedModule(QObject *parent, const QList<QVariant> &)
: KDEDModule(parent)
{
pro = new KWrited;
......@@ -97,22 +97,19 @@ KWritedModule::~KWritedModule()
delete pro;
}
K_PLUGIN_FACTORY_WITH_JSON(KWritedFactory,
"kwrited.json",
registerPlugin<KWritedModule>();
)
#endif //BUILD_AS_EXECUTABLE
K_PLUGIN_FACTORY_WITH_JSON(KWritedFactory, "kwrited.json", registerPlugin<KWritedModule>();)
#endif // BUILD_AS_EXECUTABLE
KWrited::KWrited() : QObject()
KWrited::KWrited()
: QObject()
{
pty = new KPtyDevice();
pty->open();
#if defined(BUILD_AS_EXECUTABLE)
dup2(pty->slaveFd(), 0); //HACK: login() from glibc requires this to login correctly
//restore elevated privileges
dup2(pty->slaveFd(), 0); // HACK: login() from glibc requires this to login correctly
// restore elevated privileges
seteuid(original_euid);
setegid(original_egid);
#endif
......@@ -120,19 +117,19 @@ KWrited::KWrited() : QObject()
pty->login(KUser(KUser::UseRealUserID).loginName().toLocal8Bit().data(), qgetenv("DISPLAY").constData());
#if defined(BUILD_AS_EXECUTABLE)
//drop privileges again
// drop privileges again
seteuid(getuid());
setegid(getgid());
#endif
connect(pty, &QIODevice::readyRead, this, &KWrited::block_in);
//qDebug() << "listening on device" << pty->ttyName();
// qDebug() << "listening on device" << pty->ttyName();
}
KWrited::~KWrited()
{
#if defined(BUILD_AS_EXECUTABLE)
//restore elevated privileges
// restore elevated privileges
seteuid(original_euid);
setegid(original_egid);
#endif
......@@ -140,7 +137,7 @@ KWrited::~KWrited()
pty->logout();
#if defined(BUILD_AS_EXECUTABLE)
//drop privileges again
// drop privileges again
seteuid(getuid());
setegid(getgid());
#endif
......@@ -151,18 +148,18 @@ KWrited::~KWrited()
void KWrited::block_in()
{
QByteArray buf = pty->readAll();
QString msg = QString::fromLocal8Bit( buf.constData(), buf.size() );
QString msg = QString::fromLocal8Bit(buf.constData(), buf.size());
msg.remove(QLatin1Char('\r'));
msg.remove(QLatin1Char('\a'));
msg = msg.trimmed();
KNotification *notification = new KNotification(QStringLiteral("NewMessage"), KNotification::Persistent);
#if !defined(BUILD_AS_EXECUTABLE)
notification->setComponentName( QStringLiteral("kwrited") );
notification->setComponentName(QStringLiteral("kwrited"));
#endif
notification->setText( msg );
notification->setFlags( KNotification::SkipGrouping );
connect(notification, &KNotification::closed, notification, &QObject::deleteLater );
notification->setText(msg);
notification->setFlags(KNotification::SkipGrouping);
connect(notification, &KNotification::closed, notification, &QObject::deleteLater);
notification->sendEvent();
}
......
......@@ -22,8 +22,8 @@
#ifndef KWRITED_H
#define KWRITED_H
#include <config-kwrited.h>
#include <QObject>
#include <config-kwrited.h>
class KPtyDevice;
class KWrited : public QObject
......@@ -37,19 +37,20 @@ private Q_SLOTS:
void block_in();
private:
KPtyDevice* pty;
KPtyDevice *pty;
};
#if !defined(BUILD_AS_EXECUTABLE)
# include <kdedmodule.h>
#include <kdedmodule.h>
class KWritedModule : public KDEDModule
{
public:
KWritedModule(QObject* parent, const QList<QVariant>&);
KWritedModule(QObject *parent, const QList<QVariant> &);
~KWritedModule() override;
private:
KWrited* pro;
KWrited *pro;
};
#endif
......
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