Commit 2eee6542 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent cec24fdc
/*
* Copyright 2016 Kai Uwe Broulik <kde@privat.broulik.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* Copyright 2016 Kai Uwe Broulik <kde@privat.broulik.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QTimer>
......@@ -34,7 +34,8 @@ int main(int argc, char *argv[])
QCoreApplication app(argc, argv);
KLocalizedString::setApplicationDomain("kbroadcastnotification");
KAboutData aboutData(QStringLiteral("kbroadcastnotification"), i18n("Broadcast Notifications"),
KAboutData aboutData(QStringLiteral("kbroadcastnotification"),
i18n("Broadcast Notifications"),
QLatin1String(PROJECT_VERSION),
i18n("A tool that emits a notification for all users by sending it on the system DBus"),
KAboutLicense::GPL,
......@@ -44,13 +45,18 @@ int main(int argc, char *argv[])
QCommandLineParser parser;
aboutData.setupCommandLine(&parser);
QCommandLineOption applicationNameOption(QStringLiteral("application"), i18n("Name of the application that should be associated with this notification"), QStringLiteral("application"));
QCommandLineOption applicationNameOption(QStringLiteral("application"),
i18n("Name of the application that should be associated with this notification"),
QStringLiteral("application"));
parser.addOption(applicationNameOption);
QCommandLineOption summaryOption(QStringLiteral("summary"), i18n("A brief one-line summary of the notification"), QStringLiteral("summary"));
parser.addOption(summaryOption);
QCommandLineOption iconOption(QStringLiteral("icon"), i18n("Icon for the notification"), QStringLiteral("icon"));
parser.addOption(iconOption);
QCommandLineOption uidsOption(QStringLiteral("uids"), i18n("A comma-separated list of user IDs this notification should be sent to. If omitted, the notification will be sent to all users."), QStringLiteral("uids"));
QCommandLineOption uidsOption(
QStringLiteral("uids"),
i18n("A comma-separated list of user IDs this notification should be sent to. If omitted, the notification will be sent to all users."),
QStringLiteral("uids"));
parser.addOption(uidsOption);
QCommandLineOption timeoutOption(QStringLiteral("timeout"), i18n("Timeout for the notification"), QStringLiteral("timeout"));
parser.addOption(timeoutOption);
......
......@@ -30,20 +30,19 @@
#include <KAboutData>
#include <KAuthorized>
#include <KActivities/ResourceInstance>
#include <KCModuleProxy>
#include <QDebug>
#include <KLocalizedString>
#include <KServiceTypeTrader>
#include <KStartupInfo>
#include <KActivities/ResourceInstance>
#include <QDebug>
#include <kworkspace.h>
#include <KQuickAddons/QtQuickSettings>
#include <kworkspace.h>
#include <QIcon>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QIcon>
using namespace std;
......@@ -51,9 +50,7 @@ KService::List m_modules;
static bool caseInsensitiveLessThan(const KService::Ptr s1, const KService::Ptr s2)
{
const int compare = QString::compare(s1->desktopEntryName(),
s2->desktopEntryName(),
Qt::CaseInsensitive);
const int compare = QString::compare(s1->desktopEntryName(), s2->desktopEntryName(), Qt::CaseInsensitive);
return (compare < 0);
}
......@@ -61,25 +58,30 @@ static void listModules()
{
// First condition is what systemsettings does, second what kinfocenter does, make sure this is kept in sync
// We need the exist calls because otherwise the trader language aborts if the property doesn't exist and the second part of the or is not evaluated
const KService::List services = KServiceTypeTrader::self()->query( QStringLiteral("KCModule"), QStringLiteral("(exist [X-KDE-System-Settings-Parent-Category] and [X-KDE-System-Settings-Parent-Category] != '') or (exist [X-KDE-ParentApp] and [X-KDE-ParentApp] == 'kinfocenter')") );
for( KService::List::const_iterator it = services.constBegin(); it != services.constEnd(); ++it) {
const KService::List services =
KServiceTypeTrader::self()->query(QStringLiteral("KCModule"),
QStringLiteral("(exist [X-KDE-System-Settings-Parent-Category] and [X-KDE-System-Settings-Parent-Category] != '') or "
"(exist [X-KDE-ParentApp] and [X-KDE-ParentApp] == 'kinfocenter')"));
for (KService::List::const_iterator it = services.constBegin(); it != services.constEnd(); ++it) {
const KService::Ptr s = (*it);
if (!KAuthorized::authorizeControlModule(s->menuId()))
if (!KAuthorized::authorizeControlModule(s->menuId())) {
continue;
}
m_modules.append(s);
}
std::stable_sort(m_modules.begin(), m_modules.end(), caseInsensitiveLessThan);
}
static KService::Ptr locateModule(const QString& module)
static KService::Ptr locateModule(const QString &module)
{
QString path = module;
if (!path.endsWith(QLatin1String(".desktop")))
if (!path.endsWith(QLatin1String(".desktop"))) {
path += QStringLiteral(".desktop");
}
KService::Ptr service = KService::serviceByStorageId( path );
KService::Ptr service = KService::serviceByStorageId(path);
if (!service) {
return KService::Ptr();
}
......@@ -108,8 +110,7 @@ bool KCMShell::isRunning()
QDBusInterface iface(m_serviceName, QStringLiteral("/KCModule/dialog"), QStringLiteral("org.kde.KCMShellMultiDialog"));
QDBusReply<void> reply = iface.call(QStringLiteral("activate"), KStartupInfo::startupId());
if (!reply.isValid())
{
if (!reply.isValid()) {
qDebug() << "Calling D-Bus function dialog::activate() failed.";
return false; // Error, we have to do it ourselves.
}
......@@ -125,18 +126,17 @@ KCMShellMultiDialog::KCMShellMultiDialog(KPageDialog::FaceType dialogFace, QWidg
QDBusConnection::sessionBus().registerObject(QStringLiteral("/KCModule/dialog"), this, QDBusConnection::ExportScriptableSlots);
connect(this, &KCMShellMultiDialog::currentPageChanged,
this, [](KPageWidgetItem *newPage,KPageWidgetItem *oldPage) {
Q_UNUSED(oldPage);
KCModuleProxy *activeModule = newPage->widget()->findChild<KCModuleProxy *>();
if (activeModule) {
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("kcm:") + activeModule->moduleInfo().service()->storageId()),
QStringLiteral("org.kde.systemsettings"));
}
});
connect(this, &KCMShellMultiDialog::currentPageChanged, this, [](KPageWidgetItem *newPage, KPageWidgetItem *oldPage) {
Q_UNUSED(oldPage);
KCModuleProxy *activeModule = newPage->widget()->findChild<KCModuleProxy *>();
if (activeModule) {
KActivities::ResourceInstance::notifyAccessed(QUrl(QStringLiteral("kcm:") + activeModule->moduleInfo().service()->storageId()),
QStringLiteral("org.kde.systemsettings"));
}
});
}
void KCMShellMultiDialog::activate(const QByteArray& asn_id)
void KCMShellMultiDialog::activate(const QByteArray &asn_id)
{
#ifdef HAVE_X11
setAttribute(Qt::WA_NativeWindow, true);
......@@ -146,7 +146,7 @@ void KCMShellMultiDialog::activate(const QByteArray& asn_id)
void KCMShell::setServiceName(const QString &dbusName)
{
m_serviceName = QLatin1String( "org.kde.kcmshell_" ) + dbusName;
m_serviceName = QLatin1String("org.kde.kcmshell_") + dbusName;
QDBusConnection::sessionBus().registerService(m_serviceName);
}
......@@ -156,8 +156,7 @@ void KCMShell::waitForExit()
watcher->setConnection(QDBusConnection::sessionBus());
watcher->setWatchMode(QDBusServiceWatcher::WatchForOwnerChange);
watcher->addWatchedService(m_serviceName);
connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged,
this, &KCMShell::appExit);
connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged, this, &KCMShell::appExit);
exec();
}
......@@ -166,8 +165,7 @@ void KCMShell::appExit(const QString &appId, const QString &oldName, const QStri
Q_UNUSED(appId);
Q_UNUSED(newName);
if (!oldName.isEmpty())
{
if (!oldName.isEmpty()) {
qDebug() << "'" << appId << "' closed, quitting.";
qApp->quit();
}
......@@ -187,7 +185,8 @@ int main(int _argc, char *_argv[])
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
KAboutData aboutData(QStringLiteral("kcmshell5"), i18n("System Settings Module"),
KAboutData aboutData(QStringLiteral("kcmshell5"), //
i18n("System Settings Module"),
QLatin1String(PROJECT_VERSION),
i18n("A tool to start single system settings modules"),
KAboutLicense::GPL,
......@@ -195,10 +194,10 @@ int main(int _argc, char *_argv[])
aboutData.addAuthor(i18n("Frans Englich"), i18n("Maintainer"), QStringLiteral("frans.englich@kde.org"));
aboutData.addAuthor(i18n("Daniel Molkentin"), QString(), QStringLiteral("molkentin@kde.org"));
aboutData.addAuthor(i18n("Matthias Hoelzer-Kluepfel"),QString(), QStringLiteral("hoelzer@kde.org"));
aboutData.addAuthor(i18n("Matthias Elter"),QString(), QStringLiteral("elter@kde.org"));
aboutData.addAuthor(i18n("Matthias Ettrich"),QString(), QStringLiteral("ettrich@kde.org"));
aboutData.addAuthor(i18n("Waldo Bastian"),QString(), QStringLiteral("bastian@kde.org"));
aboutData.addAuthor(i18n("Matthias Hoelzer-Kluepfel"), QString(), QStringLiteral("hoelzer@kde.org"));
aboutData.addAuthor(i18n("Matthias Elter"), QString(), QStringLiteral("elter@kde.org"));
aboutData.addAuthor(i18n("Matthias Ettrich"), QString(), QStringLiteral("ettrich@kde.org"));
aboutData.addAuthor(i18n("Waldo Bastian"), QString(), QStringLiteral("bastian@kde.org"));
KAboutData::setApplicationData(aboutData);
QCommandLineParser parser;
......@@ -227,20 +226,22 @@ int main(int _argc, char *_argv[])
listModules();
int maxLen=0;
int maxLen = 0;
for (KService::List::ConstIterator it = m_modules.constBegin(); it != m_modules.constEnd(); ++it) {
int len = (*it)->desktopEntryName().length();
if (len > maxLen)
if (len > maxLen) {
maxLen = len;
}
}
for (KService::List::ConstIterator it = m_modules.constBegin(); it != m_modules.constEnd(); ++it) {
QString entry(QStringLiteral("%1 - %2"));
entry = entry.arg((*it)->desktopEntryName().leftJustified(maxLen, QLatin1Char(' ')))
.arg(!(*it)->comment().isEmpty() ? (*it)->comment()
: i18n("No description available"));
entry = entry
.arg((*it)->desktopEntryName().leftJustified(maxLen, QLatin1Char(' '))) //
.arg(!(*it)->comment().isEmpty() ? (*it)->comment() //
: i18n("No description available"));
cout << entry.toLocal8Bit().data() << endl;
}
......@@ -310,12 +311,12 @@ int main(int _argc, char *_argv[])
dlg->setWindowIcon(QIcon::fromTheme(parser.value(QStringLiteral("icon"))));
} else if (!parser.isSet(QStringLiteral("icon")) && !modules.isEmpty()) {
const QString iconName = modules.first()->icon();
dlg->setWindowIcon( QIcon::fromTheme(iconName) );
dlg->setWindowIcon(QIcon::fromTheme(iconName));
}
if (modules.count() == 1 && app.desktopFileName() == QLatin1String("org.kde.kcmshell5")) {
const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
QStringLiteral("kservices5/%1.desktop").arg(modules.first()->desktopEntryName()));
const QString path =
QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kservices5/%1.desktop").arg(modules.first()->desktopEntryName()));
if (!path.isEmpty()) {
app.setDesktopFileName(path);
}
......
......@@ -22,9 +22,9 @@
#ifndef MAIN_H
#define MAIN_H
#include <QApplication>
#include <KCMultiDialog>
#include <KPageDialog>
#include <QApplication>
/**
* The application instance for kcmshell.
......@@ -34,7 +34,10 @@ class KCMShell : public QApplication
Q_OBJECT
public:
KCMShell(int &argc, char** argv) : QApplication(argc, argv) {}
KCMShell(int &argc, char **argv)
: QApplication(argc, argv)
{
}
/**
* Sets m_serviceName basically to @p serviceName,
......@@ -42,7 +45,7 @@ public:
*
* @param serviceName name to set the D-BUS name to
*/
void setServiceName(const QString &serviceName );
void setServiceName(const QString &serviceName);
/**
* Waits until the last instance of kcmshell with the same
......@@ -59,19 +62,16 @@ private Q_SLOTS:
/**
*/
void appExit( const QString &appId, const QString &, const QString & );
void appExit(const QString &appId, const QString &, const QString &);
private:
/**
* The D-Bus name which actually is registered.
* For example "kcmshell_mouse".
*/
QString m_serviceName;
};
/**
* Essentially a plain KCMultiDialog, but has the additional functionality
* of allowing it to be told to request windows focus.
......@@ -84,7 +84,6 @@ class KCMShellMultiDialog : public KCMultiDialog
Q_CLASSINFO("D-Bus Interface", "org.kde.KCMShellMultiDialog")
public:
/**
* Constructor. Parameter @p dialogFace is passed to KCMultiDialog
* unchanged.
......@@ -97,8 +96,7 @@ public Q_SLOTS:
* Activate a module with id @p asn_id . This is used when
* black helicopters are spotted overhead.
*/
virtual Q_SCRIPTABLE void activate( const QByteArray& asn_id );
virtual Q_SCRIPTABLE void activate(const QByteArray &asn_id);
};
// vim: sw=4 et sts=4
......
......@@ -17,15 +17,15 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QCommandLineParser>
#include <QCommandLineOption>
#include <QDebug>
#include <KProcess>
#include <KLocalizedString>
#include <KProcess>
int main(int argc, char **argv)
{
......
......@@ -7,14 +7,14 @@
#include <config-kde-cli-tools.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/time.h>
#if defined(HAVE_SYS_WAIT_H)
#include <sys/wait.h>
#endif
......@@ -22,29 +22,29 @@
#include <sys/prctl.h>
#endif
#if HAVE_SYS_PROCCTL_H
#include <unistd.h>
#include <sys/procctl.h>
#include <unistd.h>
#endif
#include <QFileInfo>
#include <QApplication>
#include <QCommandLineParser>
#include <QFile>
#include <QFileInfo>
#include <QLoggingCategory>
#include <QCommandLineParser>
#include <QApplication>
#include <kconfiggroup.h>
#include <KSharedConfig>
#include <kaboutdata.h>
#include <kconfiggroup.h>
#include <klocalizedstring.h>
#include <kmessagebox.h>
#include <kuser.h>
#include <kshell.h>
#include <kstartupinfo.h>
#include <kuser.h>
#include <kwindowsystem.h>
#include <klocalizedstring.h>
#include <kaboutdata.h>
#include <kdesu/client.h>
#include <kdesu/defaults.h>
#include <kdesu/su.h>
#include <kdesu/client.h>
#include "sudlg.h"
......@@ -74,7 +74,7 @@ QByteArray dcopNetworkId()
}
#endif
static int startApp(QCommandLineParser& p);
static int startApp(QCommandLineParser &p);
int main(int argc, char *argv[])
{
......@@ -94,19 +94,20 @@ int main(int argc, char *argv[])
// anyway, i vote against removing it even when we have a proper gui
// implementation. -- ossi
QByteArray duser = qgetenv("ADMIN_ACCOUNT");
if (duser.isEmpty())
if (duser.isEmpty()) {
duser = "root";
}
KLocalizedString::setApplicationDomain("kdesu5");
KAboutData aboutData(QStringLiteral("kdesu"), i18n("KDE su"),
QLatin1String(Version), i18n("Runs a program with elevated privileges."),
KAboutLicense::Artistic,
i18n("Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"));
aboutData.addAuthor(i18n("Geert Jansen"), i18n("Maintainer"),
QStringLiteral("jansen@kde.org"), QStringLiteral("http://www.stack.nl/~geertj/"));
aboutData.addAuthor(i18n("Pietro Iglio"), i18n("Original author"),
QStringLiteral("iglio@fub.it"));
KAboutData aboutData(QStringLiteral("kdesu"),
i18n("KDE su"),
QLatin1String(Version),
i18n("Runs a program with elevated privileges."),
KAboutLicense::Artistic,
i18n("Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"));
aboutData.addAuthor(i18n("Geert Jansen"), i18n("Maintainer"), QStringLiteral("jansen@kde.org"), QStringLiteral("http://www.stack.nl/~geertj/"));
aboutData.addAuthor(i18n("Pietro Iglio"), i18n("Original author"), QStringLiteral("iglio@fub.it"));
app.setWindowIcon(QIcon::fromTheme(QStringLiteral("dialog-password")));
KAboutData::setApplicationData(aboutData);
......@@ -122,7 +123,8 @@ int main(int argc, char *argv[])
parser.addOption(QCommandLineOption(QStringLiteral("n"), i18n("Do not keep password")));
parser.addOption(QCommandLineOption(QStringLiteral("s"), i18n("Stop the daemon (forgets all passwords)")));
parser.addOption(QCommandLineOption(QStringLiteral("t"), i18n("Enable terminal output (no password keeping)")));
parser.addOption(QCommandLineOption(QStringLiteral("p"), i18n("Set priority value: 0 <= prio <= 100, 0 is lowest"), QStringLiteral("prio"), QStringLiteral("50")));
parser.addOption(
QCommandLineOption(QStringLiteral("p"), i18n("Set priority value: 0 <= prio <= 100, 0 is lowest"), QStringLiteral("prio"), QStringLiteral("50")));
parser.addOption(QCommandLineOption(QStringLiteral("r"), i18n("Use realtime scheduling")));
parser.addOption(QCommandLineOption(QStringLiteral("noignorebutton"), i18n("Do not display ignore button")));
parser.addOption(QCommandLineOption(QStringLiteral("i"), i18n("Specify icon to use in the password dialog"), QStringLiteral("icon name")));
......@@ -130,18 +132,24 @@ int main(int argc, char *argv[])
#ifdef HAVE_X11
/* KDialog originally used --embed for attaching the dialog box. However this is misleading and so we changed to --attach.
* For consistancy, we silently map --embed to --attach */
parser.addOption(QCommandLineOption(QStringLiteral("attach"), i18nc("Transient means that the kdesu app will be attached to the app specified by the winid so that it is like a dialog box rather than some separate program", "Makes the dialog transient for an X app specified by winid"), QStringLiteral("winid")));
parser.addOption(QCommandLineOption(QStringLiteral("attach"),
i18nc("Transient means that the kdesu app will be attached to the app specified by the winid so that it is like a "
"dialog box rather than some separate program",
"Makes the dialog transient for an X app specified by winid"),
QStringLiteral("winid")));
parser.addOption(QCommandLineOption(QStringLiteral("embed"), i18n("Embed into a window"), QStringLiteral("winid")));
#endif
//KApplication::disableAutoDcopRegistration();
// KApplication::disableAutoDcopRegistration();
// kdesu doesn't process SM events, so don't even connect to ksmserver
QByteArray session_manager = qgetenv( "SESSION_MANAGER" );
if (!session_manager.isEmpty())
unsetenv( "SESSION_MANAGER" );
QByteArray session_manager = qgetenv("SESSION_MANAGER");
if (!session_manager.isEmpty()) {
unsetenv("SESSION_MANAGER");
}
// but propagate it to the started app
if (!session_manager.isEmpty())
setenv( "SESSION_MANAGER", session_manager.data(), 1 );
if (!session_manager.isEmpty()) {
setenv("SESSION_MANAGER", session_manager.data(), 1);
}
{
#ifdef HAVE_X11
......@@ -155,31 +163,26 @@ int main(int argc, char *argv[])
aboutData.processCommandLine(&parser);
int result = startApp(parser);
if (result == 127)
{
if (result == 127) {
KMessageBox::sorry(nullptr, i18n("Cannot execute command '%1'.", QString::fromLocal8Bit(command)));
}
if (result == -2)
{
if (result == -2) {
KMessageBox::sorry(nullptr, i18n("Cannot execute command '%1'. It contains invalid characters.", QString::fromLocal8Bit(command)));
}
return result;
}
static int startApp(QCommandLineParser& p)
static int startApp(QCommandLineParser &p)
{
// Stop daemon and exit?
if (p.isSet(QStringLiteral("s")))
{
if (p.isSet(QStringLiteral("s"))) {
KDEsuClient client;
if (client.ping() == -1)
{
if (client.ping() == -1) {
qCCritical(category) << "Daemon not running -- nothing to stop\n";
p.showHelp(1);
}
if (client.stopServer() != -1)
{
if (client.stopServer() != -1) {
qCDebug(category) << "Daemon stopped\n";
exit(0);
}
......@@ -188,19 +191,20 @@ static int startApp(QCommandLineParser& p)
}
QString icon;
if ( p.isSet(QStringLiteral("i")))
if (p.isSet(QStringLiteral("i"))) {
icon = p.value(QStringLiteral("i"));
}
bool prompt = true;
if ( p.isSet(QStringLiteral("d")))
if (p.isSet(QStringLiteral("d"))) {
prompt = false;
}
// Get target uid
const QByteArray user = p.value(QStringLiteral("u")).toLocal8Bit();
QByteArray auth_user = user;
struct passwd *pw = getpwnam(user.constData());
if (pw == nullptr)
{
if (pw == nullptr) {
qCCritical(category) << "User " << user << " does not exist\n";
p.showHelp(1);
}
......@@ -208,27 +212,24 @@ static int startApp(QCommandLineParser& p)
bool change_uid = other_uid;
if (!change_uid) {
char *cur_user = getenv("USER");
if (!cur_user)
if (!cur_user) {
cur_user = getenv("LOGNAME");
}
change_uid = (!cur_user || user != cur_user);
}
// If file is writeable, do not change uid
QString file = p.value(QStringLiteral("f"));
if (other_uid && !file.isEmpty())
{
if (file.startsWith(QLatin1Char('/')))
{
if (other_uid && !file.isEmpty()) {
if (file.startsWith(QLatin1Char('/'))) {
file = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, file);
if (file.isEmpty())
{
if (file.isEmpty()) {
qCCritical(category) << "Config file not found: " << file;
p.showHelp(1);
}
}
QFileInfo fi(file);
if (!fi.exists())
{
if (!fi.exists()) {
qCCritical(category) << "File does not exist: " << file;
p.showHelp(1);
}
......@@ -239,46 +240,39 @@ static int startApp(QCommandLineParser& p)
QString tmp = p.value(QStringLiteral("p"));
bool ok;
int priority = tmp.toInt(&ok);
if (!ok || (priority < 0) || (priority > 100))
{
if (!ok || (priority < 0) || (priority > 100)) {
qCCritical(category) << i18n("Illegal priority: %1", tmp);
p.showHelp(1);
}
int scheduler = SuProcess::SchedNormal;
if (p.isSet(QStringLiteral("r")))
if (p.isSet(QStringLiteral("r"))) {