mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-24 02:42:50 +00:00
generic: adjust to authorization changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
27b1b53595
commit
1212fc79f7
40 changed files with 285 additions and 459 deletions
|
@ -36,7 +36,6 @@
|
||||||
#include <KToggleAction>
|
#include <KToggleAction>
|
||||||
#include <KIO/NetAccess>
|
#include <KIO/NetAccess>
|
||||||
#include <KToolInvocation>
|
#include <KToolInvocation>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <KMenu>
|
#include <KMenu>
|
||||||
#include <KInputDialog>
|
#include <KInputDialog>
|
||||||
#include <KProtocolInfo>
|
#include <KProtocolInfo>
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
#include <kservice.h>
|
#include <kservice.h>
|
||||||
#include <kaboutdata.h>
|
#include <kaboutdata.h>
|
||||||
#include <kpluginfactory.h>
|
#include <kpluginfactory.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(KateKonsoleFactory, registerPlugin<KateKonsolePlugin>();)
|
K_PLUGIN_FACTORY(KateKonsoleFactory, registerPlugin<KateKonsolePlugin>();)
|
||||||
K_EXPORT_PLUGIN(KateKonsoleFactory(KAboutData("katekonsole","katekonsoleplugin",ki18n("Konsole"), "0.1", ki18n("Embedded Konsole"), KAboutData::License_LGPL_V2)) )
|
K_EXPORT_PLUGIN(KateKonsoleFactory(KAboutData("katekonsole","katekonsoleplugin",ki18n("Konsole"), "0.1", ki18n("Embedded Konsole"), KAboutData::License_LGPL_V2)) )
|
||||||
|
|
|
@ -27,21 +27,17 @@
|
||||||
#include <kiconloader.h>
|
#include <kiconloader.h>
|
||||||
#include <ktexteditor/document.h>
|
#include <ktexteditor/document.h>
|
||||||
#include <ktexteditor/view.h>
|
#include <ktexteditor/view.h>
|
||||||
|
|
||||||
#include <kparts/part.h>
|
#include <kparts/part.h>
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
|
|
||||||
#include <kurl.h>
|
#include <kurl.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
#include <KToolInvocation>
|
#include <KToolInvocation>
|
||||||
|
|
||||||
#include <kpluginfactory.h>
|
#include <kpluginfactory.h>
|
||||||
#include <kpluginloader.h>
|
#include <kpluginloader.h>
|
||||||
#include <kaboutdata.h>
|
#include <kaboutdata.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(KateMailFilesFactory, registerPlugin<KateMailFilesPlugin>();)
|
K_PLUGIN_FACTORY(KateMailFilesFactory, registerPlugin<KateMailFilesPlugin>();)
|
||||||
K_EXPORT_PLUGIN(KateMailFilesFactory(KAboutData("katemailfilesplugin","katemailfilesplugin",ki18n("Mail Files"), "0.1", ki18n("Support mailing files"), KAboutData::License_LGPL_V2)) )
|
K_EXPORT_PLUGIN(KateMailFilesFactory(KAboutData("katemailfilesplugin","katemailfilesplugin",ki18n("Mail Files"), "0.1", ki18n("Support mailing files"), KAboutData::License_LGPL_V2)) )
|
||||||
|
|
|
@ -34,9 +34,7 @@
|
||||||
#include <klineedit.h>
|
#include <klineedit.h>
|
||||||
#include <kinputdialog.h>
|
#include <kinputdialog.h>
|
||||||
#include <kprocess.h>
|
#include <kprocess.h>
|
||||||
|
|
||||||
#include <kpluginfactory.h>
|
#include <kpluginfactory.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
|
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KApplication>
|
#include <KApplication>
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KCmdLineArgs>
|
#include <KCmdLineArgs>
|
||||||
#include <KCModuleInfo>
|
#include <KCModuleInfo>
|
||||||
#include <KCMultiDialog>
|
#include <KCMultiDialog>
|
||||||
|
@ -65,8 +64,6 @@ static void listModules()
|
||||||
it != services.end(); ++it)
|
it != services.end(); ++it)
|
||||||
{
|
{
|
||||||
const KService::Ptr s = (*it);
|
const KService::Ptr s = (*it);
|
||||||
if (!KAuthorized::authorizeControlModule(s->menuId()))
|
|
||||||
continue;
|
|
||||||
m_modules.append(s);
|
m_modules.append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kauthhelpersupport.h>
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -159,7 +158,7 @@ ClockHelper::CH_Error ClockHelper::tzreset()
|
||||||
return NoError;
|
return NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionReply ClockHelper::save(const QVariantMap &args)
|
int ClockHelper::save(const QVariantMap &args)
|
||||||
{
|
{
|
||||||
bool _ntp = args.value("ntp").toBool();
|
bool _ntp = args.value("ntp").toBool();
|
||||||
bool _date = args.value("date").toBool();
|
bool _date = args.value("date").toBool();
|
||||||
|
@ -179,13 +178,7 @@ ActionReply ClockHelper::save(const QVariantMap &args)
|
||||||
if( _tzreset )
|
if( _tzreset )
|
||||||
ret |= tzreset();
|
ret |= tzreset();
|
||||||
|
|
||||||
if (ret == NoError) {
|
return ret;
|
||||||
return ActionReply::SuccessReply;
|
|
||||||
} else {
|
|
||||||
ActionReply reply(ActionReply::HelperError);
|
|
||||||
reply.setErrorCode(ret);
|
|
||||||
return reply;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmclock", ClockHelper)
|
K_AUTH_MAIN("org.kde.kcontrol.kcmclock", ClockHelper)
|
||||||
|
|
|
@ -21,11 +21,9 @@
|
||||||
#ifndef CLOCK_HELPER_H
|
#ifndef CLOCK_HELPER_H
|
||||||
#define CLOCK_HELPER_H
|
#define CLOCK_HELPER_H
|
||||||
|
|
||||||
#include <kauthactionreply.h>
|
#include <kauthorization.h>
|
||||||
|
|
||||||
using namespace KAuth;
|
class ClockHelper : public KAuthorization
|
||||||
|
|
||||||
class ClockHelper : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -39,7 +37,7 @@ class ClockHelper : public QObject
|
||||||
};
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
ActionReply save(const QVariantMap &map);
|
int save(const QVariantMap &map);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CH_Error ntp(const QStringList& ntpServers, bool ntpEnabled);
|
CH_Error ntp(const QStringList& ntpServers, bool ntpEnabled);
|
||||||
|
|
|
@ -32,14 +32,13 @@
|
||||||
#include <kpluginloader.h>
|
#include <kpluginloader.h>
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
|
#include <kauthorization.h>
|
||||||
|
|
||||||
#include "moc_main.cpp"
|
#include "moc_main.cpp"
|
||||||
|
|
||||||
#include "dtime.h"
|
#include "dtime.h"
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
|
|
||||||
#include <kauthaction.h>
|
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(KlockModuleFactory, registerPlugin<KclockModule>();)
|
K_PLUGIN_FACTORY(KlockModuleFactory, registerPlugin<KclockModule>();)
|
||||||
K_EXPORT_PLUGIN(KlockModuleFactory("kcmkclock"))
|
K_EXPORT_PLUGIN(KlockModuleFactory("kcmkclock"))
|
||||||
|
|
||||||
|
@ -76,7 +75,11 @@ KclockModule::KclockModule(QWidget *parent, const QVariantList &)
|
||||||
|
|
||||||
setButtons(Help|Apply);
|
setButtons(Help|Apply);
|
||||||
|
|
||||||
setNeedsAuthorization(true);
|
|
||||||
|
if (!KAuthorization::isAuthorized("org.kde.kcontrol.kcmclock")) {
|
||||||
|
setUseRootOnlyMessage(true);
|
||||||
|
setRootOnlyMessage(i18n("You are not allowed to save the configuration"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KclockModule::save()
|
void KclockModule::save()
|
||||||
|
@ -86,19 +89,17 @@ void KclockModule::save()
|
||||||
QVariantMap helperargs;
|
QVariantMap helperargs;
|
||||||
dtime->save( helperargs );
|
dtime->save( helperargs );
|
||||||
|
|
||||||
Action *action = authAction();
|
int reply = KAuthorization::execute(
|
||||||
action->setArguments(helperargs);
|
"org.kde.kcontrol.kcmclock", "save", helperargs
|
||||||
|
);
|
||||||
|
|
||||||
ActionReply reply = action->execute();
|
if (reply != KAuthorization::NoError) {
|
||||||
|
if (reply < KAuthorization::NoError) {
|
||||||
if (reply.failed()) {
|
KMessageBox::error(this, i18n("Unable to authenticate/execute the action: %1", KAuthorization::errorString(reply)));
|
||||||
if (reply.type() == ActionReply::KAuthError) {
|
|
||||||
KMessageBox::error(this, i18n("Unable to authenticate/execute the action: %1, %2", reply.errorCode(), reply.errorDescription()));
|
|
||||||
} else {
|
} else {
|
||||||
dtime->processHelperErrors(reply.errorCode());
|
dtime->processHelperErrors(reply);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
QDBusMessage msg = QDBusMessage::createSignal("/org/kde/kcmshell_clock", "org.kde.kcmshell_clock", "clockUpdated");
|
QDBusMessage msg = QDBusMessage::createSignal("/org/kde/kcmshell_clock", "org.kde.kcmshell_clock", "clockUpdated");
|
||||||
QDBusConnection::sessionBus().send(msg);
|
QDBusConnection::sessionBus().send(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,7 @@
|
||||||
#include <QtCore/qdir.h>
|
#include <QtCore/qdir.h>
|
||||||
#include <QtCore/qcoreapplication.h>
|
#include <QtCore/qcoreapplication.h>
|
||||||
|
|
||||||
#include <kauthaction.h>
|
#include <kauthorization.h>
|
||||||
#include <kauthhelpersupport.h>
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <kio/global.h>
|
#include <kio/global.h>
|
||||||
#include <kde_file.h>
|
#include <kde_file.h>
|
||||||
|
@ -947,24 +946,22 @@ bool FontInst::findFont(const QString &family, quint32 style, EFolder folder,
|
||||||
|
|
||||||
int FontInst::performAction(const QVariantMap &args)
|
int FontInst::performAction(const QVariantMap &args)
|
||||||
{
|
{
|
||||||
KAuth::Action action("org.kde.fontinst.manage");
|
|
||||||
|
|
||||||
action.setHelperID("org.kde.fontinst");
|
|
||||||
action.setArguments(args);
|
|
||||||
KFI_DBUG << "Call " << args["method"].toString() << " on helper";
|
KFI_DBUG << "Call " << args["method"].toString() << " on helper";
|
||||||
itsFontListTimer->stop();
|
itsFontListTimer->stop();
|
||||||
itsConnectionsTimer->stop();
|
itsConnectionsTimer->stop();
|
||||||
KAuth::ActionReply reply = action.execute();
|
int reply = KAuthorization::execute(
|
||||||
|
"org.kde.fontinst", "manage", args
|
||||||
|
);
|
||||||
|
|
||||||
switch(reply.type())
|
switch(reply)
|
||||||
{
|
{
|
||||||
case KAuth::ActionReply::KAuthError:
|
case KAuthorization::AuthorizationError:
|
||||||
KFI_DBUG << "KAuth failed - error code:" << reply.errorCode();
|
KFI_DBUG << "KAuth failed - error code:" << reply;
|
||||||
return KIO::ERR_COULD_NOT_AUTHENTICATE;
|
return KIO::ERR_COULD_NOT_AUTHENTICATE;
|
||||||
case KAuth::ActionReply::HelperError:
|
case KAuthorization::HelperError:
|
||||||
KFI_DBUG << "Helper failed - error code:" << reply.errorCode();
|
KFI_DBUG << "Helper failed - error code:" << reply;
|
||||||
return (int)reply.errorCode();
|
return reply;
|
||||||
case KAuth::ActionReply::Success:
|
case KAuthorization::NoError:
|
||||||
KFI_DBUG << "Success!";
|
KFI_DBUG << "Success!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <QtCore/qtextcodec.h>
|
#include <QtCore/qtextcodec.h>
|
||||||
#include <QtCore/qcoreapplication.h>
|
#include <QtCore/qcoreapplication.h>
|
||||||
#include <kio/global.h>
|
#include <kio/global.h>
|
||||||
#include <kauthhelpersupport.h>
|
|
||||||
#include <kde_file.h>
|
#include <kde_file.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -40,7 +39,7 @@
|
||||||
|
|
||||||
#define KFI_DBUG kDebug() << time(0L)
|
#define KFI_DBUG kDebug() << time(0L)
|
||||||
|
|
||||||
KDE4_AUTH_HELPER_MAIN("org.kde.fontinst", KFI::Helper)
|
K_AUTH_MAIN("org.kde.fontinst", KFI::Helper)
|
||||||
|
|
||||||
namespace KFI
|
namespace KFI
|
||||||
{
|
{
|
||||||
|
@ -109,7 +108,7 @@ Helper::~Helper()
|
||||||
theFontFolder.saveDisabled();
|
theFontFolder.saveDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionReply Helper::manage(const QVariantMap &args)
|
int Helper::manage(const QVariantMap &args)
|
||||||
{
|
{
|
||||||
int result=KIO::ERR_UNSUPPORTED_ACTION;
|
int result=KIO::ERR_UNSUPPORTED_ACTION;
|
||||||
QString method=args["method"].toString();
|
QString method=args["method"].toString();
|
||||||
|
@ -134,11 +133,9 @@ ActionReply Helper::manage(const QVariantMap &args)
|
||||||
KFI_DBUG << "Uknown action";
|
KFI_DBUG << "Uknown action";
|
||||||
|
|
||||||
if(FontInst::STATUS_OK==result)
|
if(FontInst::STATUS_OK==result)
|
||||||
return ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
|
|
||||||
ActionReply reply(ActionReply::HelperError);
|
return result;
|
||||||
reply.setErrorCode(result);
|
|
||||||
return reply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Helper::install(const QVariantMap &args)
|
int Helper::install(const QVariantMap &args)
|
||||||
|
|
|
@ -24,29 +24,27 @@
|
||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <kauthactionreply.h>
|
|
||||||
|
|
||||||
using namespace KAuth;
|
#include <kauthorization.h>
|
||||||
|
|
||||||
namespace KFI
|
namespace KFI
|
||||||
{
|
{
|
||||||
|
|
||||||
class Helper : public QObject
|
class Helper : public KAuthorization
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Helper();
|
Helper();
|
||||||
~Helper();
|
~Helper();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
|
|
||||||
ActionReply manage(const QVariantMap &args);
|
int manage(const QVariantMap &args);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int install(const QVariantMap &args);
|
int install(const QVariantMap &args);
|
||||||
int uninstall(const QVariantMap &args);
|
int uninstall(const QVariantMap &args);
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
|
|
||||||
using namespace KAuth;
|
|
||||||
|
|
||||||
K_PLUGIN_FACTORY(WorkspaceOptionsModuleFactory, registerPlugin<WorkspaceOptionsModule>();)
|
K_PLUGIN_FACTORY(WorkspaceOptionsModuleFactory, registerPlugin<WorkspaceOptionsModule>();)
|
||||||
K_EXPORT_PLUGIN(WorkspaceOptionsModuleFactory("kcmworkspaceoptions"))
|
K_EXPORT_PLUGIN(WorkspaceOptionsModuleFactory("kcmworkspaceoptions"))
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kauthaction.h>
|
|
||||||
#include <kimageio.h>
|
#include <kimageio.h>
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
#include <kstyle.h>
|
#include <kstyle.h>
|
||||||
#include <kglobalsettings.h>
|
#include <kglobalsettings.h>
|
||||||
|
#include <kauthorization.h>
|
||||||
#include <kaboutdata.h>
|
#include <kaboutdata.h>
|
||||||
#include <kpluginfactory.h>
|
#include <kpluginfactory.h>
|
||||||
#include <kpluginloader.h>
|
#include <kpluginloader.h>
|
||||||
|
@ -62,7 +62,10 @@ KCMGreeter::KCMGreeter(QWidget* parent, const QVariantList& args)
|
||||||
about->addAuthor(ki18n("Ivailo Monev"), KLocalizedString(), "xakepa10@gmail.com");
|
about->addAuthor(ki18n("Ivailo Monev"), KLocalizedString(), "xakepa10@gmail.com");
|
||||||
setAboutData(about);
|
setAboutData(about);
|
||||||
|
|
||||||
setNeedsAuthorization(true);
|
if (!KAuthorization::isAuthorized("org.kde.kcontrol.kcmkgreeter")) {
|
||||||
|
setUseRootOnlyMessage(true);
|
||||||
|
setRootOnlyMessage(i18n("You are not allowed to save the configuration"));
|
||||||
|
}
|
||||||
|
|
||||||
load();
|
load();
|
||||||
|
|
||||||
|
@ -146,19 +149,20 @@ void KCMGreeter::load()
|
||||||
|
|
||||||
void KCMGreeter::save()
|
void KCMGreeter::save()
|
||||||
{
|
{
|
||||||
KAuth::Action kgreeteraction("org.kde.kcontrol.kcmkgreeter.save");
|
QVariantMap kgreeterarguments;
|
||||||
kgreeteraction.setHelperID("org.kde.kcontrol.kcmkgreeter");
|
kgreeterarguments.insert("font", fontchooser->font().toString());
|
||||||
kgreeteraction.addArgument("font", fontchooser->font().toString());
|
kgreeterarguments.insert("style", stylesbox->itemData(stylesbox->currentIndex()).toString());
|
||||||
kgreeteraction.addArgument("style", stylesbox->itemData(stylesbox->currentIndex()).toString());
|
kgreeterarguments.insert("colorscheme", colorsbox->itemData(colorsbox->currentIndex()).toString());
|
||||||
kgreeteraction.addArgument("colorscheme", colorsbox->itemData(colorsbox->currentIndex()).toString());
|
kgreeterarguments.insert("cursortheme", cursorbox->itemData(cursorbox->currentIndex()).toString());
|
||||||
kgreeteraction.addArgument("cursortheme", cursorbox->itemData(cursorbox->currentIndex()).toString());
|
kgreeterarguments.insert("background", backgroundrequester->url().path());
|
||||||
kgreeteraction.addArgument("background", backgroundrequester->url().path());
|
kgreeterarguments.insert("rectangle", rectanglerequester->url().path());
|
||||||
kgreeteraction.addArgument("rectangle", rectanglerequester->url().path());
|
int kgreeterreply = KAuthorization::execute(
|
||||||
KAuth::ActionReply kgreeterreply = kgreeteraction.execute();
|
"org.kde.kcontrol.kcmkgreeter", "save", kgreeterarguments
|
||||||
// qDebug() << kgreeterreply.errorCode() << kgreeterreply.errorDescription();
|
);
|
||||||
|
// qDebug() << kgreeterreply;
|
||||||
|
|
||||||
if (kgreeterreply != KAuth::ActionReply::SuccessReply) {
|
if (kgreeterreply != KAuthorization::NoError) {
|
||||||
KMessageBox::error(this, kgreeterreply.errorDescription());
|
KMessageBox::error(this, i18n("Could not save settings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
enableTest(true);
|
enableTest(true);
|
||||||
|
|
|
@ -19,16 +19,16 @@
|
||||||
#include "kgreeterhelper.h"
|
#include "kgreeterhelper.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <kauthhelpersupport.h>
|
#include <kdebug.h>
|
||||||
|
|
||||||
#include "config-workspace.h"
|
#include "config-workspace.h"
|
||||||
|
|
||||||
ActionReply KGreeterHelper::save(const QVariantMap ¶meters)
|
int KGreeterHelper::save(const QVariantMap ¶meters)
|
||||||
{
|
{
|
||||||
if (!parameters.contains("font") || !parameters.contains("style")
|
if (!parameters.contains("font") || !parameters.contains("style")
|
||||||
|| !parameters.contains("colorscheme") || !parameters.contains("cursortheme")
|
|| !parameters.contains("colorscheme") || !parameters.contains("cursortheme")
|
||||||
|| !parameters.contains("background") || !parameters.contains("rectangle")) {
|
|| !parameters.contains("background") || !parameters.contains("rectangle")) {
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString colorscheme = parameters.value("colorscheme").toString();
|
QString colorscheme = parameters.value("colorscheme").toString();
|
||||||
|
@ -48,13 +48,11 @@ ActionReply KGreeterHelper::save(const QVariantMap ¶meters)
|
||||||
kgreetersettings.setValue("greeter/background", parameters.value("background"));
|
kgreetersettings.setValue("greeter/background", parameters.value("background"));
|
||||||
kgreetersettings.setValue("greeter/rectangle", parameters.value("rectangle"));
|
kgreetersettings.setValue("greeter/rectangle", parameters.value("rectangle"));
|
||||||
if (kgreetersettings.status() != QSettings::NoError) {
|
if (kgreetersettings.status() != QSettings::NoError) {
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << "Could not save settings";
|
||||||
errorreply.setErrorDescription("Could not save settings");
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(1);
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmkgreeter", KGreeterHelper)
|
K_AUTH_MAIN("org.kde.kcontrol.kcmkgreeter", KGreeterHelper)
|
||||||
|
|
|
@ -19,16 +19,13 @@
|
||||||
#ifndef KGREETERHELPER_H
|
#ifndef KGREETERHELPER_H
|
||||||
#define KGREETERHELPER_H
|
#define KGREETERHELPER_H
|
||||||
|
|
||||||
#include <kauthactionreply.h>
|
#include <kauthorization.h>
|
||||||
|
|
||||||
// methods return type must be ActionReply otherwise QMetaObject::invokeMethod() fails
|
class KGreeterHelper : public KAuthorization
|
||||||
using namespace KAuth;
|
|
||||||
|
|
||||||
class KGreeterHelper : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public slots:
|
public slots:
|
||||||
ActionReply save(const QVariantMap ¶meters);
|
int save(const QVariantMap ¶meters);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KGREETERHELPER_H
|
#endif // KGREETERHELPER_H
|
||||||
|
|
|
@ -9,7 +9,6 @@ Actions=NewWindow;
|
||||||
X-DocPath=konsole/index.html
|
X-DocPath=konsole/index.html
|
||||||
X-DBUS-StartupType=Multi
|
X-DBUS-StartupType=Multi
|
||||||
X-KDE-StartupNotify=true
|
X-KDE-StartupNotify=true
|
||||||
X-KDE-AuthorizeAction=shell_access
|
|
||||||
|
|
||||||
Name=Konsole
|
Name=Konsole
|
||||||
Name[af]=Konsole
|
Name[af]=Konsole
|
||||||
|
|
|
@ -3,7 +3,6 @@ Type=Service
|
||||||
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
|
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
|
||||||
MimeType=inode/directory;
|
MimeType=inode/directory;
|
||||||
Actions=openTerminalHere;
|
Actions=openTerminalHere;
|
||||||
X-KDE-AuthorizeAction=shell_access
|
|
||||||
|
|
||||||
[Desktop Action openTerminalHere]
|
[Desktop Action openTerminalHere]
|
||||||
TryExec=konsole
|
TryExec=konsole
|
||||||
|
|
|
@ -10,8 +10,6 @@ X-KDE-BrowserView-Toggable=true
|
||||||
X-KDE-BrowserView-ToggableView-Orientation=horizontal
|
X-KDE-BrowserView-ToggableView-Orientation=horizontal
|
||||||
X-KDE-BrowserView-FollowActive=true
|
X-KDE-BrowserView-FollowActive=true
|
||||||
|
|
||||||
X-KDE-AuthorizeAction=shell_access
|
|
||||||
|
|
||||||
Name=Terminal Emulator
|
Name=Terminal Emulator
|
||||||
Name[af]=Terminaal Emulasie
|
Name[af]=Terminaal Emulasie
|
||||||
Name[ar]=محاكي طرفية
|
Name[ar]=محاكي طرفية
|
||||||
|
|
|
@ -3,7 +3,6 @@ Type=Service
|
||||||
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
|
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
|
||||||
MimeType=application/x-executable;
|
MimeType=application/x-executable;
|
||||||
Actions=runInKonsole;
|
Actions=runInKonsole;
|
||||||
X-KDE-AuthorizeAction=shell_access
|
|
||||||
|
|
||||||
[Desktop Action runInKonsole]
|
[Desktop Action runInKonsole]
|
||||||
TryExec=konsole
|
TryExec=konsole
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <KAction>
|
#include <KAction>
|
||||||
#include <KActionCollection>
|
#include <KActionCollection>
|
||||||
#include <KCrash>
|
#include <KCrash>
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
#include <KWindowSystem>
|
#include <KWindowSystem>
|
||||||
|
|
||||||
|
@ -128,12 +127,10 @@ void KRunnerApp::initialize()
|
||||||
a->setGlobalShortcut(KShortcut(Qt::CTRL+Qt::Key_Escape));
|
a->setGlobalShortcut(KShortcut(Qt::CTRL+Qt::Key_Escape));
|
||||||
connect(a, SIGNAL(triggered(bool)), SLOT(showTaskManager()));
|
connect(a, SIGNAL(triggered(bool)), SLOT(showTaskManager()));
|
||||||
|
|
||||||
if (KAuthorized::authorize(QLatin1String("switch_user"))) {
|
a = m_actionCollection->addAction(QLatin1String("Switch User"));
|
||||||
a = m_actionCollection->addAction(QLatin1String("Switch User"));
|
a->setText(i18n("Switch User"));
|
||||||
a->setText(i18n("Switch User"));
|
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Insert));
|
||||||
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Insert));
|
connect(a, SIGNAL(triggered(bool)), SLOT(switchUser()));
|
||||||
connect(a, SIGNAL(triggered(bool)), SLOT(switchUser()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//Setup the interface after we have set up the actions
|
//Setup the interface after we have set up the actions
|
||||||
switch (KRunnerSettings::interface()) {
|
switch (KRunnerSettings::interface()) {
|
||||||
|
|
|
@ -64,7 +64,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
|
@ -1015,29 +1014,27 @@ void KSMServer::wmChanged()
|
||||||
|
|
||||||
void KSMServer::setupShortcuts()
|
void KSMServer::setupShortcuts()
|
||||||
{
|
{
|
||||||
if (KAuthorized::authorize("logout")) {
|
KActionCollection* actionCollection = new KActionCollection(this);
|
||||||
KActionCollection* actionCollection = new KActionCollection(this);
|
KAction* a;
|
||||||
KAction* a;
|
a = actionCollection->addAction("Log Out");
|
||||||
a = actionCollection->addAction("Log Out");
|
a->setText(i18n("Log Out"));
|
||||||
a->setText(i18n("Log Out"));
|
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Delete));
|
||||||
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_Delete));
|
connect(a, SIGNAL(triggered(bool)), SLOT(defaultLogout()));
|
||||||
connect(a, SIGNAL(triggered(bool)), SLOT(defaultLogout()));
|
|
||||||
|
|
||||||
a = actionCollection->addAction("Log Out Without Confirmation");
|
a = actionCollection->addAction("Log Out Without Confirmation");
|
||||||
a->setText(i18n("Log Out Without Confirmation"));
|
a->setText(i18n("Log Out Without Confirmation"));
|
||||||
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Delete));
|
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_Delete));
|
||||||
connect(a, SIGNAL(triggered(bool)), SLOT(logoutWithoutConfirmation()));
|
connect(a, SIGNAL(triggered(bool)), SLOT(logoutWithoutConfirmation()));
|
||||||
|
|
||||||
a = actionCollection->addAction("Halt Without Confirmation");
|
a = actionCollection->addAction("Halt Without Confirmation");
|
||||||
a->setText(i18n("Halt Without Confirmation"));
|
a->setText(i18n("Halt Without Confirmation"));
|
||||||
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown));
|
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageDown));
|
||||||
connect(a, SIGNAL(triggered(bool)), SLOT(haltWithoutConfirmation()));
|
connect(a, SIGNAL(triggered(bool)), SLOT(haltWithoutConfirmation()));
|
||||||
|
|
||||||
a = actionCollection->addAction("Reboot Without Confirmation");
|
a = actionCollection->addAction("Reboot Without Confirmation");
|
||||||
a->setText(i18n("Reboot Without Confirmation"));
|
a->setText(i18n("Reboot Without Confirmation"));
|
||||||
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageUp));
|
a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::SHIFT+Qt::Key_PageUp));
|
||||||
connect(a, SIGNAL(triggered(bool)), SLOT(rebootWithoutConfirmation()));
|
connect(a, SIGNAL(triggered(bool)), SLOT(rebootWithoutConfirmation()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSMServer::defaultLogout()
|
void KSMServer::defaultLogout()
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kconfig.h>
|
#include <kconfig.h>
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <kmimetype.h>
|
#include <kmimetype.h>
|
||||||
#include <kuser.h>
|
#include <kuser.h>
|
||||||
#include <kde_file.h>
|
#include <kde_file.h>
|
||||||
|
@ -347,15 +346,6 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const
|
||||||
u.setRef(ref);
|
u.setRef(ref);
|
||||||
u.setQuery(query);
|
u.setQuery(query);
|
||||||
|
|
||||||
if (!KAuthorized::authorizeUrlAction( QLatin1String("open"), KUrl(), u))
|
|
||||||
{
|
|
||||||
// No authorization, we pretend it's a file will get
|
|
||||||
// an access denied error later on.
|
|
||||||
setFilteredUri( data, u );
|
|
||||||
setUriType( data, KUriFilterData::LocalFile );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can be abs path to file or directory, or to executable with args
|
// Can be abs path to file or directory, or to executable with args
|
||||||
bool isDir = S_ISDIR( buff.st_mode );
|
bool isDir = S_ISDIR( buff.st_mode );
|
||||||
if( !isDir && access ( QFile::encodeName(path).data(), X_OK) == 0 )
|
if( !isDir && access ( QFile::encodeName(path).data(), X_OK) == 0 )
|
||||||
|
@ -477,14 +467,6 @@ bool KShortUriFilter::filterUri( KUriFilterData& data ) const
|
||||||
u.setPath(path);
|
u.setPath(path);
|
||||||
u.setRef(ref);
|
u.setRef(ref);
|
||||||
|
|
||||||
if (!KAuthorized::authorizeUrlAction( QL1S("open"), KUrl(), u))
|
|
||||||
{
|
|
||||||
// No authorization, we pretend it exists and will get
|
|
||||||
// an access denied error later on.
|
|
||||||
setFilteredUri( data, u );
|
|
||||||
setUriType( data, KUriFilterData::LocalFile );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
//kDebug(7023) << "fileNotFound -> ERROR";
|
//kDebug(7023) << "fileNotFound -> ERROR";
|
||||||
setErrorMsg( data, i18n( "<qt>The file or folder <b>%1</b> does not exist.</qt>", data.uri().prettyUrl() ) );
|
setErrorMsg( data, i18n( "<qt>The file or folder <b>%1</b> does not exist.</qt>", data.uri().prettyUrl() ) );
|
||||||
setUriType( data, KUriFilterData::Error );
|
setUriType( data, KUriFilterData::Error );
|
||||||
|
|
|
@ -68,7 +68,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <kactioncollection.h>
|
#include <kactioncollection.h>
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
|
|
||||||
|
@ -137,8 +136,6 @@ bool UserActionsMenu::isMenuClient(const Client *c) const
|
||||||
|
|
||||||
void UserActionsMenu::show(const QRect &pos, const QWeakPointer<Client> &cl)
|
void UserActionsMenu::show(const QRect &pos, const QWeakPointer<Client> &cl)
|
||||||
{
|
{
|
||||||
if (!KAuthorized::authorizeKAction("kwin_rmb"))
|
|
||||||
return;
|
|
||||||
if (cl.isNull())
|
if (cl.isNull())
|
||||||
return;
|
return;
|
||||||
if (isShown()) // recursion
|
if (isShown()) // recursion
|
||||||
|
@ -214,10 +211,10 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer<Cl
|
||||||
QStringList configModules(bool controlCenter)
|
QStringList configModules(bool controlCenter)
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << "kwindecoration";
|
args << "kwindecoration";
|
||||||
if (controlCenter)
|
if (controlCenter) {
|
||||||
args << "kwinoptions";
|
args << "kwinoptions";
|
||||||
else if (KAuthorized::authorizeControlModule("kde-kwinoptions.desktop"))
|
} else {
|
||||||
args << "kwinactions" << "kwinfocus" << "kwinmoving" << "kwinadvanced"
|
args << "kwinactions" << "kwinfocus" << "kwinmoving" << "kwinadvanced"
|
||||||
<< "kwinrules" << "kwincompositing"
|
<< "kwinrules" << "kwincompositing"
|
||||||
#ifdef KWIN_BUILD_TABBOX
|
#ifdef KWIN_BUILD_TABBOX
|
||||||
|
@ -227,6 +224,7 @@ QStringList configModules(bool controlCenter)
|
||||||
<< "kwinscreenedges"
|
<< "kwinscreenedges"
|
||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
}
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,8 +316,7 @@ void UserActionsMenu::init()
|
||||||
action = advancedMenu->addAction(i18n("S&pecial Application Settings..."));
|
action = advancedMenu->addAction(i18n("S&pecial Application Settings..."));
|
||||||
action->setIcon(KIcon("preferences-system-windows-actions"));
|
action->setIcon(KIcon("preferences-system-windows-actions"));
|
||||||
action->setData(Options::ApplicationRulesOp);
|
action->setData(Options::ApplicationRulesOp);
|
||||||
if (!KGlobal::config()->isImmutable() &&
|
if (!KGlobal::config()->isImmutable()) {
|
||||||
!KAuthorized::authorizeControlModules(configModules(true)).isEmpty()) {
|
|
||||||
advancedMenu->addSeparator();
|
advancedMenu->addSeparator();
|
||||||
action = advancedMenu->addAction(i18nc("Entry in context menu of window decoration to open the configuration module of KWin",
|
action = advancedMenu->addAction(i18nc("Entry in context menu of window decoration to open the configuration module of KWin",
|
||||||
"Window &Manager Settings..."));
|
"Window &Manager Settings..."));
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
// For doDrop
|
// For doDrop
|
||||||
#include <kicon.h>
|
#include <kicon.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <kglobalsettings.h>
|
#include <kglobalsettings.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <ksettings.h>
|
#include <ksettings.h>
|
||||||
#include <kdesktopfile.h>
|
#include <kdesktopfile.h>
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <kacceleratormanager.h>
|
#include <kacceleratormanager.h>
|
||||||
|
|
||||||
|
|
|
@ -23,19 +23,18 @@
|
||||||
#include "helper.h"
|
#include "helper.h"
|
||||||
#include "processes_local_p.h"
|
#include "processes_local_p.h"
|
||||||
|
|
||||||
#include <kauthhelpersupport.h>
|
|
||||||
|
|
||||||
KSysGuardProcessListHelper::KSysGuardProcessListHelper()
|
KSysGuardProcessListHelper::KSysGuardProcessListHelper()
|
||||||
{
|
{
|
||||||
qRegisterMetaType<QList<long long> >();
|
qRegisterMetaType<QList<long long> >();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The functions here run as ROOT. So be careful. DO NOT TRUST THE INPUTS TO BE SANE. */
|
/* The functions here run as ROOT. So be careful. DO NOT TRUST THE INPUTS TO BE SANE. */
|
||||||
#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toLongLong(); if(pid < 0) return KAuth::ActionReply::HelperErrorReply;
|
#define GET_PID(i) parameters.value(QString("pid%1").arg(i), -1).toLongLong(); if(pid < 0) return KAuthorization::HelperError;
|
||||||
|
|
||||||
KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
|
int KSysGuardProcessListHelper::renice(QVariantMap parameters)
|
||||||
|
{
|
||||||
if(!parameters.contains("nicevalue") || !parameters.contains("pidcount"))
|
if(!parameters.contains("nicevalue") || !parameters.contains("pidcount"))
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
|
|
||||||
KSysGuard::ProcessesLocal processes;
|
KSysGuard::ProcessesLocal processes;
|
||||||
int niceValue = parameters.value("nicevalue").toInt();
|
int niceValue = parameters.value("nicevalue").toInt();
|
||||||
|
@ -45,15 +44,17 @@ KAuth::ActionReply KSysGuardProcessListHelper::renice(QVariantMap parameters) {
|
||||||
qlonglong pid = GET_PID(i);
|
qlonglong pid = GET_PID(i);
|
||||||
success = processes.setNiceness(pid, niceValue) && success;
|
success = processes.setNiceness(pid, niceValue) && success;
|
||||||
}
|
}
|
||||||
if(success)
|
if (success) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
else
|
}
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
}
|
}
|
||||||
|
|
||||||
KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters) {
|
int KSysGuardProcessListHelper::changecpuscheduler(QVariantMap parameters)
|
||||||
if(!parameters.contains("cpuScheduler") || !parameters.contains("cpuSchedulerPriority") || !parameters.contains("pidcount"))
|
{
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
if (!parameters.contains("cpuScheduler") || !parameters.contains("cpuSchedulerPriority") || !parameters.contains("pidcount")) {
|
||||||
|
return KAuthorization::HelperError;
|
||||||
|
}
|
||||||
|
|
||||||
KSysGuard::ProcessesLocal processes;
|
KSysGuard::ProcessesLocal processes;
|
||||||
int cpuScheduler = parameters.value("cpuScheduler").toInt();
|
int cpuScheduler = parameters.value("cpuScheduler").toInt();
|
||||||
|
@ -65,11 +66,11 @@ KAuth::ActionReply KSysGuardProcessListHelper::changecpuscheduler(QVariantMap pa
|
||||||
qlonglong pid = GET_PID(i);
|
qlonglong pid = GET_PID(i);
|
||||||
success = processes.setScheduler(pid, cpuScheduler, cpuSchedulerPriority) && success;
|
success = processes.setScheduler(pid, cpuScheduler, cpuSchedulerPriority) && success;
|
||||||
}
|
}
|
||||||
if(success)
|
if (success) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
else
|
}
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
|
|
||||||
}
|
}
|
||||||
KDE4_AUTH_HELPER_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper)
|
K_AUTH_MAIN("org.kde.ksysguard.processlisthelper", KSysGuardProcessListHelper)
|
||||||
|
|
||||||
|
|
|
@ -20,21 +20,19 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <kauthactionreply.h>
|
#include <kauthorization.h>
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
using namespace KAuth;
|
|
||||||
|
|
||||||
/* The functions here run as ROOT. So be careful. */
|
/* The functions here run as ROOT. So be careful. */
|
||||||
|
|
||||||
class KSysGuardProcessListHelper : public QObject {
|
class KSysGuardProcessListHelper : public KAuthorization
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
KSysGuardProcessListHelper();
|
KSysGuardProcessListHelper();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
ActionReply renice(QVariantMap parameters);
|
int renice(QVariantMap parameters);
|
||||||
ActionReply changecpuscheduler(QVariantMap parameters);
|
int changecpuscheduler(QVariantMap parameters);
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( QList<long long> )
|
Q_DECLARE_METATYPE( QList<long long> )
|
||||||
|
|
|
@ -46,9 +46,7 @@
|
||||||
|
|
||||||
#include <signal.h> //For SIGTERM
|
#include <signal.h> //For SIGTERM
|
||||||
|
|
||||||
#include <kauthaction.h>
|
#include <kauthorization.h>
|
||||||
#include <kauthactionreply.h>
|
|
||||||
#include <kauthhelpersupport.h>
|
|
||||||
#include <kaction.h>
|
#include <kaction.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <kmessagebox.h>
|
#include <kmessagebox.h>
|
||||||
|
@ -187,9 +185,6 @@ struct KSysGuardProcessListPrivate {
|
||||||
/** The number rows and their children for the given parent in the mFilterModel model */
|
/** The number rows and their children for the given parent in the mFilterModel model */
|
||||||
int totalRowCount(const QModelIndex &parent) const;
|
int totalRowCount(const QModelIndex &parent) const;
|
||||||
|
|
||||||
/** Helper function to setup 'action' with the given pids */
|
|
||||||
void setupKAuthAction(KAuth::Action *action, const QList<long long> & pids) const;
|
|
||||||
|
|
||||||
/** fire a timer event if we are set to use our internal timer*/
|
/** fire a timer event if we are set to use our internal timer*/
|
||||||
void fireTimerEvent();
|
void fireTimerEvent();
|
||||||
|
|
||||||
|
@ -389,16 +384,6 @@ int KSysGuardProcessListPrivate::totalRowCount(const QModelIndex &parent ) const
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KSysGuardProcessListPrivate::setupKAuthAction(KAuth::Action *action, const QList<long long> & pids) const
|
|
||||||
{
|
|
||||||
action->setHelperID("org.kde.ksysguard.processlisthelper");
|
|
||||||
|
|
||||||
int processCount = pids.count();
|
|
||||||
for(int i = 0; i < processCount; i++) {
|
|
||||||
action->addArgument(QString("pid%1").arg(i), pids[i]);
|
|
||||||
}
|
|
||||||
action->addArgument("pidcount", processCount);
|
|
||||||
}
|
|
||||||
void KSysGuardProcessList::selectionChanged()
|
void KSysGuardProcessList::selectionChanged()
|
||||||
{
|
{
|
||||||
int numSelected = d->mUi->treeView->selectionModel()->selectedRows().size();
|
int numSelected = d->mUi->treeView->selectionModel()->selectedRows().size();
|
||||||
|
@ -1010,18 +995,24 @@ bool KSysGuardProcessList::reniceProcesses(const QList<long long> &pids, int nic
|
||||||
if(unreniced_pids.isEmpty()) return true; //All processes were reniced successfully
|
if(unreniced_pids.isEmpty()) return true; //All processes were reniced successfully
|
||||||
if(!d->mModel.isLocalhost()) return false; //We can't use kauth to renice non-localhost processes
|
if(!d->mModel.isLocalhost()) return false; //We can't use kauth to renice non-localhost processes
|
||||||
|
|
||||||
|
QVariantMap actionarguments;
|
||||||
|
int processCount = unreniced_pids.count();
|
||||||
|
for(int i = 0; i < processCount; i++) {
|
||||||
|
actionarguments.insert(QString("pid%1").arg(i), unreniced_pids[i]);
|
||||||
|
}
|
||||||
|
actionarguments.insert("pidcount", processCount);
|
||||||
|
actionarguments.insert("nicevalue", niceValue);
|
||||||
|
int reply = KAuthorization::execute(
|
||||||
|
"org.kde.ksysguard.processlisthelper", "renice", actionarguments
|
||||||
|
);
|
||||||
|
|
||||||
KAuth::Action action("org.kde.ksysguard.processlisthelper.renice");
|
if (reply == KAuthorization::NoError) {
|
||||||
action.setParentWidget(window());
|
|
||||||
d->setupKAuthAction(&action, unreniced_pids);
|
|
||||||
action.addArgument("nicevalue", niceValue);
|
|
||||||
KAuth::ActionReply reply = action.execute();
|
|
||||||
|
|
||||||
if (reply == KAuth::ActionReply::SuccessReply) {
|
|
||||||
updateList();
|
updateList();
|
||||||
} else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
|
} else if (reply == KAuthorization::AuthorizationError) {
|
||||||
KMessageBox::sorry(this, i18n("You do not have the permission to renice the process and there "
|
KMessageBox::sorry(this, i18n("You do not have the permission to crenice the process."));
|
||||||
"was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
|
return false;
|
||||||
|
} else {
|
||||||
|
KMessageBox::sorry(this, i18n("There was a problem trying to renice the process"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1135,18 +1126,25 @@ bool KSysGuardProcessList::changeCpuScheduler(const QList< long long> &pids, KSy
|
||||||
if(unchanged_pids.isEmpty()) return true;
|
if(unchanged_pids.isEmpty()) return true;
|
||||||
if(!d->mModel.isLocalhost()) return false; //We can't use KAuth to affect non-localhost processes
|
if(!d->mModel.isLocalhost()) return false; //We can't use KAuth to affect non-localhost processes
|
||||||
|
|
||||||
KAuth::Action action("org.kde.ksysguard.processlisthelper.changecpuscheduler");
|
QVariantMap actionarguments;
|
||||||
action.setParentWidget(window());
|
int processCount = unchanged_pids.count();
|
||||||
d->setupKAuthAction(&action, unchanged_pids);
|
for(int i = 0; i < processCount; i++) {
|
||||||
action.addArgument("cpuScheduler", (int)newCpuSched);
|
actionarguments.insert(QString("pid%1").arg(i), unchanged_pids[i]);
|
||||||
action.addArgument("cpuSchedulerPriority", newCpuSchedPriority);
|
}
|
||||||
KAuth::ActionReply reply = action.execute();
|
actionarguments.insert("pidcount", processCount);
|
||||||
|
actionarguments.insert("cpuScheduler", (int)newCpuSched);
|
||||||
|
actionarguments.insert("cpuSchedulerPriority", newCpuSchedPriority);
|
||||||
|
int reply = KAuthorization::execute(
|
||||||
|
"org.kde.ksysguard.processlisthelper", "changecpuscheduler", actionarguments
|
||||||
|
);
|
||||||
|
|
||||||
if (reply == KAuth::ActionReply::SuccessReply) {
|
if (reply == KAuthorization::NoError) {
|
||||||
updateList();
|
updateList();
|
||||||
} else if (reply != KAuth::ActionReply::UserCancelled && reply != KAuth::ActionReply::AuthorizationDenied) {
|
} else if (reply == KAuthorization::AuthorizationError) {
|
||||||
KMessageBox::sorry(this, i18n("You do not have the permission to change the CPU Scheduler for the process and there "
|
KMessageBox::sorry(this, i18n("You do not have the permission to change the CPU Scheduler for the process."));
|
||||||
"was a problem trying to run as root. Error %1 %2", reply.errorCode(), reply.errorDescription()));
|
return false;
|
||||||
|
} else {
|
||||||
|
KMessageBox::sorry(this, i18n("There was a problem trying to change the CPU Scheduler for the process"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include <QtGui/QCheckBox>
|
#include <QtGui/QCheckBox>
|
||||||
|
|
||||||
// KDE
|
// KDE
|
||||||
#include <kauthorized.h>
|
|
||||||
#include <khistorycombobox.h>
|
#include <khistorycombobox.h>
|
||||||
#include <kdesktopfile.h>
|
#include <kdesktopfile.h>
|
||||||
#include <klineedit.h>
|
#include <klineedit.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
|
||||||
// KDE
|
// KDE
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KIcon>
|
#include <KIcon>
|
||||||
|
@ -119,29 +118,22 @@ void LeaveModel::updateModel()
|
||||||
QStandardItem *sessionOptions = new QStandardItem(i18n("Session"));
|
QStandardItem *sessionOptions = new QStandardItem(i18n("Session"));
|
||||||
|
|
||||||
// Logout
|
// Logout
|
||||||
const bool canLogout = KAuthorized::authorizeKAction("logout") && KAuthorized::authorize("logout");
|
QStandardItem *logoutOption = createStandardItem("leave:/logoutonly");
|
||||||
if (canLogout) {
|
sessionOptions->appendRow(logoutOption);
|
||||||
QStandardItem *logoutOption = createStandardItem("leave:/logoutonly");
|
|
||||||
sessionOptions->appendRow(logoutOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock
|
// Lock
|
||||||
if (KAuthorized::authorizeKAction("lock_screen")) {
|
QStandardItem *lockOption = createStandardItem("leave:/lock");
|
||||||
QStandardItem *lockOption = createStandardItem("leave:/lock");
|
sessionOptions->appendRow(lockOption);
|
||||||
sessionOptions->appendRow(lockOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save Session
|
// Save Session
|
||||||
if (canLogout) {
|
KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General");
|
||||||
KConfigGroup c(KSharedConfig::openConfig("ksmserverrc", KConfig::NoGlobals), "General");
|
if (c.readEntry("loginMode") == "restoreSavedSession") {
|
||||||
if (c.readEntry("loginMode") == "restoreSavedSession") {
|
QStandardItem *saveSessionOption = createStandardItem("leave:/savesession");
|
||||||
QStandardItem *saveSessionOption = createStandardItem("leave:/savesession");
|
sessionOptions->appendRow(saveSessionOption);
|
||||||
sessionOptions->appendRow(saveSessionOption);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch User
|
// Switch User
|
||||||
if (KDisplayManager().isSwitchable() && KAuthorized::authorize(QLatin1String("switch_user"))) {
|
if (KDisplayManager().isSwitchable()) {
|
||||||
QStandardItem *switchUserOption = createStandardItem("leave:/switch");
|
QStandardItem *switchUserOption = createStandardItem("leave:/switch");
|
||||||
sessionOptions->appendRow(switchUserOption);
|
sessionOptions->appendRow(switchUserOption);
|
||||||
}
|
}
|
||||||
|
@ -170,20 +162,18 @@ void LeaveModel::updateModel()
|
||||||
addSystemSession = true;
|
addSystemSession = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canLogout) {
|
if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeReboot)) {
|
||||||
if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeReboot)) {
|
// Restart
|
||||||
// Restart
|
QStandardItem *restartOption = createStandardItem("leave:/restart");
|
||||||
QStandardItem *restartOption = createStandardItem("leave:/restart");
|
systemOptions->appendRow(restartOption);
|
||||||
systemOptions->appendRow(restartOption);
|
addSystemSession = true;
|
||||||
addSystemSession = true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeHalt)) {
|
if (KWorkSpace::canShutDown(KWorkSpace::ShutdownConfirmDefault, KWorkSpace::ShutdownTypeHalt)) {
|
||||||
// Shutdown
|
// Shutdown
|
||||||
QStandardItem *shutDownOption = createStandardItem("leave:/shutdown");
|
QStandardItem *shutDownOption = createStandardItem("leave:/shutdown");
|
||||||
systemOptions->appendRow(shutDownOption);
|
systemOptions->appendRow(shutDownOption);
|
||||||
addSystemSession = true;
|
addSystemSession = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
appendRow(sessionOptions);
|
appendRow(sessionOptions);
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QtCore/qtimer.h>
|
#include <QtCore/qtimer.h>
|
||||||
|
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KIcon>
|
#include <KIcon>
|
||||||
#include <KMenu>
|
#include <KMenu>
|
||||||
|
@ -167,13 +166,9 @@ QAction *ContextMenu::action(const QString &name)
|
||||||
} else if (name == "_run_command") {
|
} else if (name == "_run_command") {
|
||||||
return m_runCommandAction;
|
return m_runCommandAction;
|
||||||
} else if (name == "_lock_screen") {
|
} else if (name == "_lock_screen") {
|
||||||
if (KAuthorized::authorizeKAction("lock_screen")) {
|
return m_lockScreenAction;
|
||||||
return m_lockScreenAction;
|
|
||||||
}
|
|
||||||
} else if (name == "_logout") {
|
} else if (name == "_logout") {
|
||||||
if (KAuthorized::authorizeKAction("logout")) {
|
return m_logoutAction;
|
||||||
return m_logoutAction;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//FIXME: remove action: make removal of current activity possible
|
//FIXME: remove action: make removal of current activity possible
|
||||||
return c->action(name);
|
return c->action(name);
|
||||||
|
@ -190,10 +185,6 @@ void ContextMenu::runCommand()
|
||||||
|
|
||||||
void ContextMenu::lockScreen()
|
void ContextMenu::lockScreen()
|
||||||
{
|
{
|
||||||
if (!KAuthorized::authorizeKAction("lock_screen")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString interface("org.freedesktop.ScreenSaver");
|
QString interface("org.freedesktop.ScreenSaver");
|
||||||
org::freedesktop::ScreenSaver screensaver(interface, "/ScreenSaver",
|
org::freedesktop::ScreenSaver screensaver(interface, "/ScreenSaver",
|
||||||
QDBusConnection::sessionBus());
|
QDBusConnection::sessionBus());
|
||||||
|
@ -220,10 +211,6 @@ void ContextMenu::startLogout()
|
||||||
|
|
||||||
void ContextMenu::logout()
|
void ContextMenu::logout()
|
||||||
{
|
{
|
||||||
if (!KAuthorized::authorizeKAction("logout")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KWorkSpace::requestShutDown();
|
KWorkSpace::requestShutDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#include <QDBusPendingReply>
|
#include <QDBusPendingReply>
|
||||||
|
|
||||||
#include <KAuthorized>
|
|
||||||
|
|
||||||
// kde-workspace/libs
|
// kde-workspace/libs
|
||||||
#include <kworkspace/kworkspace.h>
|
#include <kworkspace/kworkspace.h>
|
||||||
|
|
||||||
|
@ -49,15 +47,11 @@ void PowerManagementJob::start()
|
||||||
//kDebug() << "starting operation ... " << operation;
|
//kDebug() << "starting operation ... " << operation;
|
||||||
|
|
||||||
if (operation == "lockScreen") {
|
if (operation == "lockScreen") {
|
||||||
if (KAuthorized::authorizeKAction("lock_screen")) {
|
#warning TODO: error check
|
||||||
const QString interface("org.freedesktop.ScreenSaver");
|
const QString interface("org.freedesktop.ScreenSaver");
|
||||||
QDBusInterface screensaver(interface, "/ScreenSaver");
|
QDBusInterface screensaver(interface, "/ScreenSaver");
|
||||||
screensaver.asyncCall("Lock");
|
screensaver.asyncCall("Lock");
|
||||||
setResult(true);
|
setResult(true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
kDebug() << "operation denied " << operation;
|
|
||||||
setResult(false);
|
|
||||||
return;
|
return;
|
||||||
} else if (operation == "suspend" || operation == "suspendToRam") {
|
} else if (operation == "suspend" || operation == "suspendToRam") {
|
||||||
if (!Solid::PowerManagement::supportedSleepStates().contains(Solid::PowerManagement::SuspendState)) {
|
if (!Solid::PowerManagement::supportedSleepStates().contains(Solid::PowerManagement::SuspendState)) {
|
||||||
|
|
|
@ -43,9 +43,6 @@ enforced security
|
||||||
|
|
||||||
This is security that doesn't rely on plasmoid developers. Mostly it's about disabling access to features via the scripting API, so that plasmoids using that API absolutely cannot use the disabled features.
|
This is security that doesn't rely on plasmoid developers. Mostly it's about disabling access to features via the scripting API, so that plasmoids using that API absolutely cannot use the disabled features.
|
||||||
|
|
||||||
it'd be nice if we could use KAuthorized to enforce some stuff on the c++ applets... I tried, but didn't get anywhere.
|
|
||||||
|
|
||||||
|
|
||||||
misc
|
misc
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
|
|
||||||
#include "sessionrunner.h"
|
#include "sessionrunner.h"
|
||||||
|
|
||||||
|
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KLocale>
|
#include <KLocale>
|
||||||
#include <KMessageBox>
|
#include <KMessageBox>
|
||||||
|
@ -38,18 +36,13 @@ SessionRunner::SessionRunner(QObject *parent, const QVariantList &args)
|
||||||
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File |
|
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File |
|
||||||
Plasma::RunnerContext::NetworkLocation);
|
Plasma::RunnerContext::NetworkLocation);
|
||||||
|
|
||||||
m_canLogout = KAuthorized::authorizeKAction("logout") && KAuthorized::authorize("logout");
|
addSyntax(Plasma::RunnerSyntax(i18nc("log out command", "logout"),
|
||||||
if (m_canLogout) {
|
i18n("Logs out, exiting the current desktop session")));
|
||||||
addSyntax(Plasma::RunnerSyntax(i18nc("log out command", "logout"),
|
addSyntax(Plasma::RunnerSyntax(i18nc("shutdown computer command", "shutdown"),
|
||||||
i18n("Logs out, exiting the current desktop session")));
|
i18n("Turns off the computer")));
|
||||||
addSyntax(Plasma::RunnerSyntax(i18nc("shutdown computer command", "shutdown"),
|
|
||||||
i18n("Turns off the computer")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (KAuthorized::authorizeKAction("lock_screen") && m_canLogout) {
|
addSyntax(Plasma::RunnerSyntax(i18nc("lock screen command", "lock"),
|
||||||
addSyntax(Plasma::RunnerSyntax(i18nc("lock screen command", "lock"),
|
i18n("Locks the current sessions and starts the screen saver")));
|
||||||
i18n("Locks the current sessions and starts the screen saver")));
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasma::RunnerSyntax rebootSyntax(i18nc("restart computer command", "restart"), i18n("Reboots the computer"));
|
Plasma::RunnerSyntax rebootSyntax(i18nc("restart computer command", "restart"), i18n("Reboots the computer"));
|
||||||
rebootSyntax.addExampleQuery(i18nc("restart computer command", "reboot"));
|
rebootSyntax.addExampleQuery(i18nc("restart computer command", "reboot"));
|
||||||
|
@ -76,10 +69,6 @@ SessionRunner::~SessionRunner()
|
||||||
|
|
||||||
void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QString& term)
|
void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QString& term)
|
||||||
{
|
{
|
||||||
if (!m_canLogout) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (term.compare(i18nc("log out command","logout"), Qt::CaseInsensitive) == 0 ||
|
if (term.compare(i18nc("log out command","logout"), Qt::CaseInsensitive) == 0 ||
|
||||||
term.compare(i18n("log out"), Qt::CaseInsensitive) == 0) {
|
term.compare(i18n("log out"), Qt::CaseInsensitive) == 0) {
|
||||||
Plasma::QueryMatch match(this);
|
Plasma::QueryMatch match(this);
|
||||||
|
@ -107,15 +96,13 @@ void SessionRunner::matchCommands(QList<Plasma::QueryMatch> &matches, const QStr
|
||||||
match.setRelevance(0.9);
|
match.setRelevance(0.9);
|
||||||
matches << match;
|
matches << match;
|
||||||
} else if (term.compare(i18nc("lock screen command","lock"), Qt::CaseInsensitive) == 0) {
|
} else if (term.compare(i18nc("lock screen command","lock"), Qt::CaseInsensitive) == 0) {
|
||||||
if (KAuthorized::authorizeKAction("lock_screen")) {
|
Plasma::QueryMatch match(this);
|
||||||
Plasma::QueryMatch match(this);
|
match.setText(i18n("Lock the screen"));
|
||||||
match.setText(i18n("Lock the screen"));
|
match.setIcon(KIcon("system-lock-screen"));
|
||||||
match.setIcon(KIcon("system-lock-screen"));
|
match.setData(LockAction);
|
||||||
match.setData(LockAction);
|
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
match.setRelevance(0.9);
|
||||||
match.setRelevance(0.9);
|
matches << match;
|
||||||
matches << match;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,8 +142,7 @@ void SessionRunner::match(Plasma::RunnerContext &context)
|
||||||
term.compare(i18n("switch user"), Qt::CaseInsensitive) == 0 ||
|
term.compare(i18n("switch user"), Qt::CaseInsensitive) == 0 ||
|
||||||
term.compare(i18n("new session"), Qt::CaseInsensitive) == 0;
|
term.compare(i18n("new session"), Qt::CaseInsensitive) == 0;
|
||||||
|
|
||||||
if (switchUser &&
|
if (switchUser && dm.isSwitchable()) {
|
||||||
KAuthorized::authorizeKAction("start_new_session") && dm.isSwitchable()) {
|
|
||||||
Plasma::QueryMatch match(this);
|
Plasma::QueryMatch match(this);
|
||||||
match.setType(Plasma::QueryMatch::ExactMatch);
|
match.setType(Plasma::QueryMatch::ExactMatch);
|
||||||
match.setIcon(KIcon("system-switch-user"));
|
match.setIcon(KIcon("system-switch-user"));
|
||||||
|
|
|
@ -46,7 +46,6 @@ class SessionRunner : public Plasma::AbstractRunner
|
||||||
|
|
||||||
QString m_triggerWord;
|
QString m_triggerWord;
|
||||||
KDisplayManager dm;
|
KDisplayManager dm;
|
||||||
bool m_canLogout;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
K_EXPORT_PLASMA_RUNNER(sessions, SessionRunner)
|
K_EXPORT_PLASMA_RUNNER(sessions, SessionRunner)
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtCore/qsharedpointer.h>
|
#include <QtCore/qsharedpointer.h>
|
||||||
|
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
#include <KIconLoader>
|
#include <KIconLoader>
|
||||||
|
|
||||||
|
@ -175,19 +174,15 @@ void DesktopToolBox::init()
|
||||||
this, SLOT(updateTheming()));
|
this, SLOT(updateTheming()));
|
||||||
Plasma::ToolTipManager::self()->registerWidget(this);
|
Plasma::ToolTipManager::self()->registerWidget(this);
|
||||||
|
|
||||||
if (KAuthorized::authorizeKAction("logout")) {
|
QAction *action = new QAction(i18n("Leave..."), this);
|
||||||
QAction *action = new QAction(i18n("Leave..."), this);
|
action->setIcon(KIcon("system-shutdown"));
|
||||||
action->setIcon(KIcon("system-shutdown"));
|
connect(action, SIGNAL(triggered()), this, SLOT(startLogout()));
|
||||||
connect(action, SIGNAL(triggered()), this, SLOT(startLogout()));
|
addTool(action);
|
||||||
addTool(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (KAuthorized::authorizeKAction("lock_screen")) {
|
action = new QAction(i18n("Lock Screen"), this);
|
||||||
QAction *action = new QAction(i18n("Lock Screen"), this);
|
action->setIcon(KIcon("system-lock-screen"));
|
||||||
action->setIcon(KIcon("system-lock-screen"));
|
connect(action, SIGNAL(triggered(bool)), this, SLOT(lockScreen()));
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(lockScreen()));
|
addTool(action);
|
||||||
addTool(action);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize DesktopToolBox::cornerSize() const
|
QSize DesktopToolBox::cornerSize() const
|
||||||
|
@ -780,10 +775,6 @@ void DesktopToolBox::lockScreen()
|
||||||
setShowing(false);
|
setShowing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!KAuthorized::authorizeKAction("lock_screen")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString interface("org.freedesktop.ScreenSaver");
|
const QString interface("org.freedesktop.ScreenSaver");
|
||||||
QDBusInterface screensaver(interface, "/ScreenSaver");
|
QDBusInterface screensaver(interface, "/ScreenSaver");
|
||||||
screensaver.asyncCall("Lock");
|
screensaver.asyncCall("Lock");
|
||||||
|
@ -813,10 +804,6 @@ void DesktopToolBox::startLogout()
|
||||||
|
|
||||||
void DesktopToolBox::logout()
|
void DesktopToolBox::logout()
|
||||||
{
|
{
|
||||||
if (!KAuthorized::authorizeKAction("logout")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
KWorkSpace::requestShutDown();
|
KWorkSpace::requestShutDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kdesktopfileactions.h>
|
#include <kdesktopfileactions.h>
|
||||||
#include <kpassworddialog.h>
|
#include <kpassworddialog.h>
|
||||||
#include <kauthaction.h>
|
#include <kauthorization.h>
|
||||||
#include <kpluginfactory.h>
|
#include <kpluginfactory.h>
|
||||||
#include <kpluginloader.h>
|
#include <kpluginloader.h>
|
||||||
#include <solid/block.h>
|
#include <solid/block.h>
|
||||||
|
@ -53,21 +53,18 @@ static int doMount(const QString &deviceuuid, const QString &devicenode, const Q
|
||||||
return int(Solid::ErrorType::OperationFailed);
|
return int(Solid::ErrorType::OperationFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
KAuth::Action mountaction("org.kde.soliduiserver.mountunmounthelper.mount");
|
QVariantMap mountarguments;
|
||||||
mountaction.setHelperID("org.kde.soliduiserver.mountunmounthelper");
|
mountarguments.insert("device", devicenode);
|
||||||
mountaction.addArgument("device", devicenode);
|
mountarguments.insert("mountpoint", mountpoint);
|
||||||
mountaction.addArgument("mountpoint", mountpoint);
|
mountarguments.insert("fstype", devicefstype);
|
||||||
mountaction.addArgument("fstype", devicefstype);
|
int mountreply = KAuthorization::execute(
|
||||||
KAuth::ActionReply mountreply = mountaction.execute();
|
"org.kde.soliduiserver.mountunmounthelper", "mount", mountarguments
|
||||||
// qDebug() << "mount" << mountreply.errorCode() << mountreply.errorDescription();
|
);
|
||||||
|
// qDebug() << "mount" << mountreply;
|
||||||
|
|
||||||
if (mountreply == KAuth::ActionReply::SuccessReply) {
|
if (mountreply == KAuthorization::NoError) {
|
||||||
return int(Solid::ErrorType::NoError);
|
return int(Solid::ErrorType::NoError);
|
||||||
}
|
} else if (mountreply == KAuthorization::AuthorizationError) {
|
||||||
|
|
||||||
if (mountreply == KAuth::ActionReply::UserCancelled) {
|
|
||||||
return int(Solid::ErrorType::UserCanceled);
|
|
||||||
} else if (mountreply == KAuth::ActionReply::AuthorizationDenied) {
|
|
||||||
return int(Solid::ErrorType::UnauthorizedOperation);
|
return int(Solid::ErrorType::UnauthorizedOperation);
|
||||||
}
|
}
|
||||||
return int(Solid::ErrorType::OperationFailed);
|
return int(Solid::ErrorType::OperationFailed);
|
||||||
|
@ -75,19 +72,16 @@ static int doMount(const QString &deviceuuid, const QString &devicenode, const Q
|
||||||
|
|
||||||
static int doUnmount(const QString &devicemountpoint)
|
static int doUnmount(const QString &devicemountpoint)
|
||||||
{
|
{
|
||||||
KAuth::Action unmountaction("org.kde.soliduiserver.mountunmounthelper.unmount");
|
QVariantMap unmountarguments;
|
||||||
unmountaction.setHelperID("org.kde.soliduiserver.mountunmounthelper");
|
unmountarguments.insert("mountpoint", devicemountpoint);
|
||||||
unmountaction.addArgument("mountpoint", devicemountpoint);
|
int unmountreply = KAuthorization::execute(
|
||||||
KAuth::ActionReply unmountreply = unmountaction.execute();
|
"org.kde.soliduiserver.mountunmounthelper", "unmount", unmountarguments
|
||||||
// qDebug() << "unmount" << unmountreply.errorCode() << unmountreply.errorDescription();
|
);
|
||||||
|
// qDebug() << "unmount" << unmountreply;
|
||||||
|
|
||||||
if (unmountreply == KAuth::ActionReply::SuccessReply) {
|
if (unmountreply == KAuthorization::NoError) {
|
||||||
return int(Solid::ErrorType::NoError);
|
return int(Solid::ErrorType::NoError);
|
||||||
}
|
} else if (unmountreply == KAuthorization::AuthorizationError) {
|
||||||
|
|
||||||
if (unmountreply == KAuth::ActionReply::UserCancelled) {
|
|
||||||
return int(Solid::ErrorType::UserCanceled);
|
|
||||||
} else if (unmountreply == KAuth::ActionReply::AuthorizationDenied) {
|
|
||||||
return int(Solid::ErrorType::UnauthorizedOperation);
|
return int(Solid::ErrorType::UnauthorizedOperation);
|
||||||
}
|
}
|
||||||
return int(Solid::ErrorType::OperationFailed);
|
return int(Solid::ErrorType::OperationFailed);
|
||||||
|
@ -201,20 +195,18 @@ int SolidUiServer::mountDevice(const QString &udi)
|
||||||
return int(Solid::ErrorType::UserCanceled);
|
return int(Solid::ErrorType::UserCanceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
KAuth::Action cryptopenaction("org.kde.soliduiserver.mountunmounthelper.cryptopen");
|
QVariantMap cryptopenarguments;
|
||||||
cryptopenaction.setHelperID("org.kde.soliduiserver.mountunmounthelper");
|
cryptopenarguments.insert("device", devicenode);
|
||||||
cryptopenaction.addArgument("device", devicenode);
|
cryptopenarguments.insert("name", deviceuuid);
|
||||||
cryptopenaction.addArgument("name", deviceuuid);
|
cryptopenarguments.insert("password", passworddialog.password().toLocal8Bit().toHex());
|
||||||
cryptopenaction.addArgument("password", passworddialog.password().toLocal8Bit().toHex());
|
int cryptopenreply = KAuthorization::execute(
|
||||||
KAuth::ActionReply cryptopenreply = cryptopenaction.execute();
|
"org.kde.soliduiserver.mountunmounthelper", "cryptopen", cryptopenarguments
|
||||||
|
);
|
||||||
|
// qDebug() << "cryptopen" << cryptopenreply;
|
||||||
|
|
||||||
// qDebug() << "cryptopen" << cryptopenreply.errorCode() << cryptopenreply.errorDescription();
|
if (cryptopenreply == KAuthorization::AuthorizationError) {
|
||||||
|
|
||||||
if (cryptopenreply == KAuth::ActionReply::UserCancelled) {
|
|
||||||
return int(Solid::ErrorType::UserCanceled);
|
|
||||||
} else if (cryptopenreply == KAuth::ActionReply::AuthorizationDenied) {
|
|
||||||
return int(Solid::ErrorType::UnauthorizedOperation);
|
return int(Solid::ErrorType::UnauthorizedOperation);
|
||||||
} else if (cryptopenreply != KAuth::ActionReply::SuccessReply) {
|
} else if (cryptopenreply != KAuthorization::NoError) {
|
||||||
return int(Solid::ErrorType::OperationFailed);
|
return int(Solid::ErrorType::OperationFailed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,10 +220,11 @@ int SolidUiServer::mountDevice(const QString &udi)
|
||||||
|
|
||||||
const int mountresult = doMount(deviceuuid, devicenode, storagevolume->fsType());
|
const int mountresult = doMount(deviceuuid, devicenode, storagevolume->fsType());
|
||||||
if (mountresult != int(Solid::ErrorType::NoError) && didcryptopen) {
|
if (mountresult != int(Solid::ErrorType::NoError) && didcryptopen) {
|
||||||
KAuth::Action cryptcloseaction("org.kde.soliduiserver.mountunmounthelper.cryptclose");
|
QVariantMap cryptclosearguments;
|
||||||
cryptcloseaction.setHelperID("org.kde.soliduiserver.mountunmounthelper");
|
cryptclosearguments.insert("name", deviceuuid);
|
||||||
cryptcloseaction.addArgument("name", deviceuuid);
|
(void)KAuthorization::execute(
|
||||||
cryptcloseaction.execute();
|
"org.kde.soliduiserver.mountunmounthelper", "cryptclose", cryptclosearguments
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return mountresult;
|
return mountresult;
|
||||||
}
|
}
|
||||||
|
@ -251,18 +244,16 @@ int SolidUiServer::unmountDevice(const QString &udi)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storagevolume->usage() == Solid::StorageVolume::Encrypted) {
|
if (storagevolume->usage() == Solid::StorageVolume::Encrypted) {
|
||||||
KAuth::Action cryptcloseaction("org.kde.soliduiserver.mountunmounthelper.cryptclose");
|
QVariantMap cryptclosearguments;
|
||||||
cryptcloseaction.setHelperID("org.kde.soliduiserver.mountunmounthelper");
|
cryptclosearguments.insert("name", storagevolume->uuid());
|
||||||
cryptcloseaction.addArgument("name", storagevolume->uuid());
|
int cryptclosereply = KAuthorization::execute(
|
||||||
KAuth::ActionReply cryptclosereply = cryptcloseaction.execute();
|
"org.kde.soliduiserver.mountunmounthelper", "cryptclose", cryptclosearguments
|
||||||
|
);
|
||||||
|
// qDebug() << "cryptclose" << cryptclosereply;
|
||||||
|
|
||||||
// qDebug() << "cryptclose" << cryptclosereply.errorCode() << cryptclosereply.errorDescription();
|
if (cryptclosereply == KAuthorization::AuthorizationError) {
|
||||||
|
|
||||||
if (cryptclosereply == KAuth::ActionReply::UserCancelled) {
|
|
||||||
return int(Solid::ErrorType::UserCanceled);
|
|
||||||
} else if (cryptclosereply == KAuth::ActionReply::AuthorizationDenied) {
|
|
||||||
return int(Solid::ErrorType::UnauthorizedOperation);
|
return int(Solid::ErrorType::UnauthorizedOperation);
|
||||||
} else if (cryptclosereply != KAuth::ActionReply::SuccessReply) {
|
} else if (cryptclosereply != KAuthorization::NoError) {
|
||||||
return int(Solid::ErrorType::OperationFailed);
|
return int(Solid::ErrorType::OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
#include "soliduiserver_helper.h"
|
#include "soliduiserver_helper.h"
|
||||||
|
|
||||||
#include <kauthhelpersupport.h>
|
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
|
||||||
|
@ -31,18 +30,16 @@
|
||||||
# include <errno.h>
|
# include <errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KAuth::ActionReply SolidUiServerHelper::cryptopen(const QVariantMap ¶meters)
|
int SolidUiServerHelper::cryptopen(const QVariantMap ¶meters)
|
||||||
{
|
{
|
||||||
if (!parameters.contains("device") || !parameters.contains("name") || !parameters.contains("password")) {
|
if (!parameters.contains("device") || !parameters.contains("name") || !parameters.contains("password")) {
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString cryptbin = KStandardDirs::findRootExe("cryptsetup");
|
const QString cryptbin = KStandardDirs::findRootExe("cryptsetup");
|
||||||
if (cryptbin.isEmpty()) {
|
if (cryptbin.isEmpty()) {
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << "cryptsetup is missing";
|
||||||
errorreply.setErrorDescription("cryptsetup is missing");
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(1);
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString device = parameters.value("device").toString();
|
const QString device = parameters.value("device").toString();
|
||||||
|
@ -57,30 +54,26 @@ KAuth::ActionReply SolidUiServerHelper::cryptopen(const QVariantMap ¶meters)
|
||||||
cryptproc.waitForFinished();
|
cryptproc.waitForFinished();
|
||||||
|
|
||||||
if (cryptproc.exitCode() == 0) {
|
if (cryptproc.exitCode() == 0) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
QString crypterror = cryptproc.readAllStandardError();
|
QString crypterror = cryptproc.readAllStandardError();
|
||||||
if (crypterror.isEmpty()) {
|
if (crypterror.isEmpty()) {
|
||||||
crypterror = cryptproc.readAllStandardOutput();
|
crypterror = cryptproc.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << crypterror;
|
||||||
errorreply.setErrorDescription(crypterror);
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(cryptproc.exitCode());
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KAuth::ActionReply SolidUiServerHelper::cryptclose(const QVariantMap ¶meters)
|
int SolidUiServerHelper::cryptclose(const QVariantMap ¶meters)
|
||||||
{
|
{
|
||||||
if (!parameters.contains("name")) {
|
if (!parameters.contains("name")) {
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString cryptbin = KStandardDirs::findRootExe("cryptsetup");
|
const QString cryptbin = KStandardDirs::findRootExe("cryptsetup");
|
||||||
if (cryptbin.isEmpty()) {
|
if (cryptbin.isEmpty()) {
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << "cryptsetup is missing";
|
||||||
errorreply.setErrorDescription("cryptsetup is missing");
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(1);
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString name = parameters.value("name").toString();
|
const QString name = parameters.value("name").toString();
|
||||||
|
@ -91,23 +84,21 @@ KAuth::ActionReply SolidUiServerHelper::cryptclose(const QVariantMap ¶meters
|
||||||
cryptproc.waitForFinished();
|
cryptproc.waitForFinished();
|
||||||
|
|
||||||
if (cryptproc.exitCode() == 0) {
|
if (cryptproc.exitCode() == 0) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
QString crypterror = cryptproc.readAllStandardError();
|
QString crypterror = cryptproc.readAllStandardError();
|
||||||
if (crypterror.isEmpty()) {
|
if (crypterror.isEmpty()) {
|
||||||
crypterror = cryptproc.readAllStandardOutput();
|
crypterror = cryptproc.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << crypterror;
|
||||||
errorreply.setErrorDescription(crypterror);
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(cryptproc.exitCode());
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KAuth::ActionReply SolidUiServerHelper::mount(const QVariantMap ¶meters)
|
int SolidUiServerHelper::mount(const QVariantMap ¶meters)
|
||||||
{
|
{
|
||||||
if (!parameters.contains("device") || !parameters.contains("mountpoint")
|
if (!parameters.contains("device") || !parameters.contains("mountpoint")
|
||||||
|| !parameters.contains("fstype")) {
|
|| !parameters.contains("fstype")) {
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString device = parameters.value("device").toString();
|
const QString device = parameters.value("device").toString();
|
||||||
|
@ -138,14 +129,11 @@ KAuth::ActionReply SolidUiServerHelper::mount(const QVariantMap ¶meters)
|
||||||
0, NULL
|
0, NULL
|
||||||
);
|
);
|
||||||
if (mountresult == 0) {
|
if (mountresult == 0) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
const int savederrno = errno;
|
const int savederrno = errno;
|
||||||
// qDebug() << Q_FUNC_INFO << qt_error_string(savederrno);
|
kWarning() << qt_error_string(savederrno);
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorDescription(qt_error_string(savederrno));
|
|
||||||
errorreply.setErrorCode(savederrno);
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
#endif // Q_OS_LINUX
|
#endif // Q_OS_LINUX
|
||||||
|
|
||||||
|
@ -156,22 +144,20 @@ KAuth::ActionReply SolidUiServerHelper::mount(const QVariantMap ¶meters)
|
||||||
mountproc.waitForFinished();
|
mountproc.waitForFinished();
|
||||||
|
|
||||||
if (mountproc.exitCode() == 0) {
|
if (mountproc.exitCode() == 0) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
QString mounterror = mountproc.readAllStandardError();
|
QString mounterror = mountproc.readAllStandardError();
|
||||||
if (mounterror.isEmpty()) {
|
if (mounterror.isEmpty()) {
|
||||||
mounterror = mountproc.readAllStandardOutput();
|
mounterror = mountproc.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << mounterror;
|
||||||
errorreply.setErrorDescription(mounterror);
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(mountproc.exitCode());
|
|
||||||
return errorreply;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KAuth::ActionReply SolidUiServerHelper::unmount(const QVariantMap ¶meters)
|
int SolidUiServerHelper::unmount(const QVariantMap ¶meters)
|
||||||
{
|
{
|
||||||
if (!parameters.contains("mountpoint")) {
|
if (!parameters.contains("mountpoint")) {
|
||||||
return KAuth::ActionReply::HelperErrorReply;
|
return KAuthorization::HelperError;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString mountpoint = parameters.value("mountpoint").toString();
|
const QString mountpoint = parameters.value("mountpoint").toString();
|
||||||
|
@ -180,13 +166,11 @@ KAuth::ActionReply SolidUiServerHelper::unmount(const QVariantMap ¶meters)
|
||||||
const QByteArray mountpointbytes = mountpoint.toLocal8Bit();;
|
const QByteArray mountpointbytes = mountpoint.toLocal8Bit();;
|
||||||
const int umountresult = ::umount2(mountpointbytes.constData(), MNT_DETACH);
|
const int umountresult = ::umount2(mountpointbytes.constData(), MNT_DETACH);
|
||||||
if (umountresult == 0) {
|
if (umountresult == 0) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
const int savederrno = errno;
|
const int savederrno = errno;
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << qt_error_string(savederrno);
|
||||||
errorreply.setErrorDescription(qt_error_string(savederrno));
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(savederrno);
|
|
||||||
return errorreply;
|
|
||||||
#else
|
#else
|
||||||
const QStringList umountargs = QStringList() << mountpoint;
|
const QStringList umountargs = QStringList() << mountpoint;
|
||||||
QProcess umountproc;
|
QProcess umountproc;
|
||||||
|
@ -195,17 +179,15 @@ KAuth::ActionReply SolidUiServerHelper::unmount(const QVariantMap ¶meters)
|
||||||
umountproc.waitForFinished();
|
umountproc.waitForFinished();
|
||||||
|
|
||||||
if (umountproc.exitCode() == 0) {
|
if (umountproc.exitCode() == 0) {
|
||||||
return KAuth::ActionReply::SuccessReply;
|
return KAuthorization::NoError;
|
||||||
}
|
}
|
||||||
QString umounterror = umountproc.readAllStandardError();
|
QString umounterror = umountproc.readAllStandardError();
|
||||||
if (umounterror.isEmpty()) {
|
if (umounterror.isEmpty()) {
|
||||||
umounterror = umountproc.readAllStandardOutput();
|
umounterror = umountproc.readAllStandardOutput();
|
||||||
}
|
}
|
||||||
KAuth::ActionReply errorreply(KAuth::ActionReply::HelperError);
|
kWarning() << umounterror;
|
||||||
errorreply.setErrorDescription(umounterror);
|
return KAuthorization::HelperError;
|
||||||
errorreply.setErrorCode(umountproc.exitCode());
|
|
||||||
return errorreply;
|
|
||||||
#endif // Q_OS_LINUX
|
#endif // Q_OS_LINUX
|
||||||
}
|
}
|
||||||
|
|
||||||
KDE4_AUTH_HELPER_MAIN("org.kde.soliduiserver.mountunmounthelper", SolidUiServerHelper)
|
K_AUTH_MAIN("org.kde.soliduiserver.mountunmounthelper", SolidUiServerHelper)
|
||||||
|
|
|
@ -19,20 +19,16 @@
|
||||||
#ifndef SOLIDUISERVER_HELPER_H
|
#ifndef SOLIDUISERVER_HELPER_H
|
||||||
#define SOLIDUISERVER_HELPER_H
|
#define SOLIDUISERVER_HELPER_H
|
||||||
|
|
||||||
#include <kauthactionreply.h>
|
#include <kauthorization.h>
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
// methods return type must be ActionReply otherwise QMetaObject::invokeMethod() fails
|
class SolidUiServerHelper : public KAuthorization
|
||||||
using namespace KAuth;
|
|
||||||
|
|
||||||
class SolidUiServerHelper : public QObject
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
ActionReply cryptopen(const QVariantMap ¶meters);
|
int cryptopen(const QVariantMap ¶meters);
|
||||||
ActionReply cryptclose(const QVariantMap ¶meters);
|
int cryptclose(const QVariantMap ¶meters);
|
||||||
ActionReply mount(const QVariantMap ¶meters);
|
int mount(const QVariantMap ¶meters);
|
||||||
ActionReply unmount(const QVariantMap ¶meters);
|
int unmount(const QVariantMap ¶meters);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SOLIDUISERVER_HELPER_H
|
#endif // SOLIDUISERVER_HELPER_H
|
||||||
|
|
|
@ -35,14 +35,12 @@
|
||||||
#include <KAboutData>
|
#include <KAboutData>
|
||||||
#include <KPageWidget>
|
#include <KPageWidget>
|
||||||
#include <KPushButton>
|
#include <KPushButton>
|
||||||
#include <KAuthorized>
|
|
||||||
#include <KMessageBox>
|
#include <KMessageBox>
|
||||||
#include <KCModuleInfo>
|
#include <KCModuleInfo>
|
||||||
#include <KCModuleProxy>
|
#include <KCModuleProxy>
|
||||||
#include <KStandardGuiItem>
|
#include <KStandardGuiItem>
|
||||||
#include <KDialogButtonBox>
|
#include <KDialogButtonBox>
|
||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
#include <kauthaction.h>
|
|
||||||
|
|
||||||
#include "MenuItem.h"
|
#include "MenuItem.h"
|
||||||
|
|
||||||
|
@ -156,10 +154,6 @@ void ModuleView::addModule( KCModuleInfo *module )
|
||||||
kWarning() << "ModuleInfo has no associated KService" ;
|
kWarning() << "ModuleInfo has no associated KService" ;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( !KAuthorized::authorizeControlModule( module->service()->menuId() ) ) {
|
|
||||||
kWarning() << "Not authorised to load module" ;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if( module->service()->noDisplay() ) {
|
if( module->service()->noDisplay() ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -263,7 +257,6 @@ bool ModuleView::resolveChanges(KCModuleProxy * currentProxy)
|
||||||
void ModuleView::closeModules()
|
void ModuleView::closeModules()
|
||||||
{
|
{
|
||||||
d->pageChangeSupressed = true;
|
d->pageChangeSupressed = true;
|
||||||
d->mApply->setAuthAction( 0 ); // Ensure KAuth knows that authentication is now pointless...
|
|
||||||
QMap<KPageWidgetItem*, KCModuleInfo*>::iterator page = d->mModules.begin();
|
QMap<KPageWidgetItem*, KCModuleInfo*>::iterator page = d->mModules.begin();
|
||||||
QMap<KPageWidgetItem*, KCModuleInfo*>::iterator pageEnd = d->mModules.end();
|
QMap<KPageWidgetItem*, KCModuleInfo*>::iterator pageEnd = d->mModules.end();
|
||||||
for ( ; page != pageEnd; ++page ) {
|
for ( ; page != pageEnd; ++page ) {
|
||||||
|
@ -341,23 +334,15 @@ void ModuleView::activeModuleChanged(KPageWidgetItem * current, KPageWidgetItem
|
||||||
void ModuleView::stateChanged()
|
void ModuleView::stateChanged()
|
||||||
{
|
{
|
||||||
KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() );
|
KCModuleProxy * activeModule = d->mPages.value( d->mPageWidget->currentPage() );
|
||||||
KAuth::Action * moduleAction = 0;
|
|
||||||
bool change = false;
|
bool change = false;
|
||||||
if( activeModule ) {
|
if( activeModule ) {
|
||||||
change = activeModule->changed();
|
change = activeModule->changed();
|
||||||
|
|
||||||
disconnect( d->mApply, SIGNAL(authorized(KAuth::Action*)), this, SLOT(moduleSave()) );
|
|
||||||
disconnect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) );
|
disconnect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) );
|
||||||
if( activeModule->realModule()->authAction() ) {
|
connect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) );
|
||||||
connect( d->mApply, SIGNAL(authorized(KAuth::Action*)), this, SLOT(moduleSave()) );
|
|
||||||
moduleAction = activeModule->realModule()->authAction();
|
|
||||||
} else {
|
|
||||||
connect( d->mApply, SIGNAL(clicked()), this, SLOT(moduleSave()) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePageIconHeader( d->mPageWidget->currentPage() );
|
updatePageIconHeader( d->mPageWidget->currentPage() );
|
||||||
d->mApply->setAuthAction( moduleAction );
|
|
||||||
d->mApply->setEnabled( change );
|
d->mApply->setEnabled( change );
|
||||||
d->mReset->setEnabled( change );
|
d->mReset->setEnabled( change );
|
||||||
emit moduleChanged( change );
|
emit moduleChanged( change );
|
||||||
|
|
Loading…
Add table
Reference in a new issue