#include "actions/actions.h"
#include "action_data/action_data.h"
-#include <KDE/KAuthorized>
#include <KDE/KConfigGroup>
#include <KDE/KDebug>
#include <KDE/KRun>
}
case KUriFilterData::Executable:
{
- if (!KAuthorized::authorizeKAction("shell_access"))
- return;
if( !uri.hasArgsAndOptions())
{
KService::Ptr service = KService::serviceByDesktopName( cmd );
}
case KUriFilterData::Shell:
{
- if (!KAuthorized::authorizeKAction("shell_access"))
- return;
if( !KRun::runCommand(
cmd + ( uri.hasArgsAndOptions() ? uri.argsAndOptions() : "" ),
cmd, uri.iconName(), NULL )) {
m_actionCollection = new KActionCollection(this);
KAction* a = 0;
- if (KAuthorized::authorize(QLatin1String("run_command"))) {
- a = m_actionCollection->addAction(QLatin1String("Run Command"));
- a->setText(i18n("Run Command"));
- a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::Key_F2));
- connect(a, SIGNAL(triggered(bool)), SLOT(displayOrHide()));
-
- a = m_actionCollection->addAction(QLatin1String("Run Command on clipboard contents"));
- a->setText(i18n("Run Command on clipboard contents"));
- a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_F2));
- connect(a, SIGNAL(triggered(bool)), SLOT(displayWithClipboardContents()));
- }
+ a = m_actionCollection->addAction(QLatin1String("Run Command"));
+ a->setText(i18n("Run Command"));
+ a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::Key_F2));
+ connect(a, SIGNAL(triggered(bool)), SLOT(displayOrHide()));
+
+ a = m_actionCollection->addAction(QLatin1String("Run Command on clipboard contents"));
+ a->setText(i18n("Run Command on clipboard contents"));
+ a->setGlobalShortcut(KShortcut(Qt::ALT+Qt::SHIFT+Qt::Key_F2));
+ connect(a, SIGNAL(triggered(bool)), SLOT(displayWithClipboardContents()));
a = m_actionCollection->addAction(QLatin1String("Show System Activity"));
a->setText(i18n("Show System Activity"));
}
//Setup the interface after we have set up the actions
- //TODO: if !KAuthorized::authorize("run_comand") (and !"switch_user" i suppose?)
- // then we probably don't need the interface at all. would be another place
- // for some small improvements in footprint in that case
switch (KRunnerSettings::interface()) {
default:
case KRunnerSettings::EnumInterface::CommandOriented:
m_actionCollection->readSettings();
- if (KAuthorized::authorize(QLatin1String("run_command"))) {
- //m_runnerManager->setAllowedRunners(QStringList() << "shell");
- m_runnerManager->reloadConfiguration(); // pre-load the runners
-
- // Single runner mode actions shortcuts
-
- foreach (const QString &runnerId, m_runnerManager->singleModeAdvertisedRunnerIds()) {
- a = m_actionCollection->addAction(runnerId);
- a->setText(i18nc("Run krunner restricting the search only to runner %1", "Run Command (runner \"%1\" only)",
- m_runnerManager->runnerName(runnerId)));
- a->setGlobalShortcut(KShortcut());
- connect(a, SIGNAL(triggered(bool)), SLOT(singleRunnerModeActionTriggered()));
- }
+ //m_runnerManager->setAllowedRunners(QStringList() << "shell");
+ m_runnerManager->reloadConfiguration(); // pre-load the runners
+
+ // Single runner mode actions shortcuts
+
+ foreach (const QString &runnerId, m_runnerManager->singleModeAdvertisedRunnerIds()) {
+ a = m_actionCollection->addAction(runnerId);
+ a->setText(i18nc("Run krunner restricting the search only to runner %1", "Run Command (runner \"%1\" only)",
+ m_runnerManager->runnerName(runnerId)));
+ a->setGlobalShortcut(KShortcut());
+ connect(a, SIGNAL(triggered(bool)), SLOT(singleRunnerModeActionTriggered()));
}
}
void KRunnerApp::querySingleRunner(const QString& runnerId, const QString &term)
{
- if (!KAuthorized::authorize(QLatin1String("run_command"))) {
- return;
- }
-
m_runnerManager->setSingleModeRunnerId(runnerId);
m_runnerManager->setSingleMode(!runnerId.isEmpty());
void KRunnerApp::display()
{
- if (!KAuthorized::authorize(QLatin1String("run_command"))) {
- return;
- }
-
m_runnerManager->setSingleMode(false);
m_interface->display();
}
void KRunnerApp::displaySingleRunner(const QString &runnerId)
{
- if (!KAuthorized::authorize(QLatin1String("run_command"))) {
- return;
- }
-
m_runnerManager->setSingleModeRunnerId(runnerId);
m_runnerManager->setSingleMode(!runnerId.isEmpty());
m_interface->display();
void KRunnerApp::displayOrHide()
{
- if (!KAuthorized::authorize(QLatin1String("run_command"))) {
- m_interface->hide();
- return;
- }
-
if (!m_interface->isVisible()) {
m_runnerManager->setSingleMode(false);
}
void KRunnerApp::query(const QString &term)
{
- if (!KAuthorized::authorize(QLatin1String("run_command"))) {
- return;
- }
-
m_interface->display(term);
}
void KRunnerApp::displayWithClipboardContents()
{
- if (!KAuthorized::authorize(QLatin1String("run_command"))) {
- return;
- }
-
QString clipboardData = QApplication::clipboard()->text(QClipboard::Selection);
m_interface->display(clipboardData);
}
#include <kshell.h>
#include <KService>
#include <KServiceTypeTrader>
-#include <KAuthorized>
#include <KDesktopFile>
#include <KStandardDirs>
ScreenSaverWindow::ScreenSaverWindow(QWidget *parent)
: QWidget(parent),
m_startMousePos(-1, -1),
- m_forbidden(false),
m_openGLVisual(false)
{
setCursor(Qt::BlankCursor);
}
const QString file = KStandardDirs::locate("services", offers.first()->entryPath());
- const bool opengl = KAuthorized::authorizeKAction(QLatin1String( "opengl_screensavers" ));
- const bool manipulatescreen = KAuthorized::authorizeKAction(QLatin1String( "manipulatescreen_screensavers" ));
KDesktopFile config( file );
KConfigGroup desktopGroup = config.desktopGroup();
foreach (const QString &type, desktopGroup.readEntry("X-KDE-Type").split(QLatin1Char(';'))) {
- if (type == QLatin1String("ManipulateScreen")) {
- if (!manipulatescreen) {
- kDebug() << "Screensaver is type ManipulateScreen and ManipulateScreen is forbidden";
- m_forbidden = true;
- }
- } else if (type == QLatin1String("OpenGL")) {
+ if (type == QLatin1String("OpenGL")) {
m_openGLVisual = true;
- if (!opengl) {
- kDebug() << "Screensaver is type OpenGL and OpenGL is forbidden";
- m_forbidden = true;
- }
}
}
- kDebug() << "m_forbidden: " << (m_forbidden ? "true" : "false");
-
if (config.hasActionGroup(QLatin1String( "InWindow" )))
{
m_saverExec = config.actionGroup(QLatin1String( "InWindow" )).readPathEntry("Exec", QString());
//QString m_saverExec("kannasaver.kss --window-id=%w");
kDebug() << "Starting hack:" << m_saverExec;
- if (m_saverExec.isEmpty() || m_forbidden) {
+ if (m_saverExec.isEmpty()) {
return false;
}
QTimer *m_reactivateTimer;
- bool m_forbidden : 1;
bool m_openGLVisual : 1;
};
#include <QDBusServiceWatcher>
// KDE
-#include <KAuthorized>
#include <KConfigDialog>
#include <KProcess>
#include <KRun>
void HomerunLauncher::init()
{
- if (KService::serviceByStorageId("kde4-kmenuedit.desktop") && KAuthorized::authorize("action/menuedit")) {
+ if (KService::serviceByStorageId("kde4-kmenuedit.desktop")) {
QAction* menueditor = new QAction(i18n("Edit Applications..."), this);
actions.append(menueditor);
connect(menueditor, SIGNAL(triggered(bool)), this, SLOT(startMenuEditor()));
#include <QtGui/QGraphicsLinearLayout>
// KDE
-#include <KAuthorized>
#include <KIcon>
#include <KDebug>
#include <KConfigDialog>
void LauncherApplet::init()
{
- if (KService::serviceByStorageId("kde4-kmenuedit.desktop") && KAuthorized::authorize("action/menuedit")) {
+ if (KService::serviceByStorageId("kde4-kmenuedit.desktop")) {
QAction* menueditor = new QAction(i18n("Edit Applications..."), this);
d->actions.append(menueditor);
connect(menueditor, SIGNAL(triggered(bool)), this, SLOT(startMenuEditor()));
#include <QTimer>
// KDE
-#include <KAuthorized>
#include <KDebug>
#include <KJob>
#include <KService>
void LeaveItemHandler::runCommand()
{
- if (KAuthorized::authorize("run_command")) {
- QString interface("org.kde.krunner");
- org::kde::krunner::App krunner(interface, "/App", QDBusConnection::sessionBus());
- krunner.display();
- }
+ QString interface("org.kde.krunner");
+ org::kde::krunner::App krunner(interface, "/App", QDBusConnection::sessionBus());
+ krunner.display();
}
void LeaveItemHandler::logout()
#include <QTimer>
// KDE
-#include <KAuthorized>
#include <KDebug>
#include <KDiskFreeSpaceInfo>
#include <KIcon>
} else if (!parent.parent().isValid()) {
switch (parent.row()) {
case APPLICATIONS_ROW:
- if (KAuthorized::authorize("run_command")) {
- return d->appsList.size() + 1;
- } else {
- return d->appsList.size();
- }
+ return d->appsList.size() + 1;
break;
case BOOKMARKS_ROW:
return d->placesModel->rowCount();
#include <QModelIndex>
// KDE
-#include <KAuthorized>
#include <KDebug>
#include <KRun>
#include <KUrl>
{
public:
virtual bool openUrl(const KUrl& url) {
- if (url.protocol() == "run" && KAuthorized::authorize("run_command")) {
+ if (url.protocol() == "run") {
QString interface("org.kde.krunner");
org::kde::krunner::App krunner(interface, "/App", QDBusConnection::sessionBus());
krunner.display();
// KDE Libs
#include <KActionCollection>
-#include <KAuthorized>
#include <KBookmarkMenu>
#include <KCModuleInfo>
#include <KComboBox>
}
default: { //Default configuration
d->viewtypes << "RecentlyUsedApplications" << "Applications" << "Favorites";
- if (KAuthorized::authorize("run_command")) {
- d->viewtypes << "RunCommand";
- }
+ d->viewtypes << "RunCommand";
d->viewtypes << "Leave";
d->iconname = "start-here-kde";
}
Kickoff::UrlItemLauncher::addGlobalHandler(Kickoff::UrlItemLauncher::ExtensionHandler, "desktop", new Kickoff::ServiceItemHandler);
Kickoff::UrlItemLauncher::addGlobalHandler(Kickoff::UrlItemLauncher::ProtocolHandler, "leave", new Kickoff::LeaveItemHandler);
- if (KService::serviceByStorageId("kde4-kmenuedit.desktop") && KAuthorized::authorize("action/menuedit")) {
+ if (KService::serviceByStorageId("kde4-kmenuedit.desktop")) {
QAction* menueditor = new QAction(i18n("Edit Applications..."), this);
d->actions.append(menueditor);
connect(menueditor, SIGNAL(triggered(bool)), this, SLOT(startMenuEditor()));
}
}
} else if(vtname == "RunCommand") {
- if (KAuthorized::authorize("run_command")) {
- menuview->addAction(KIcon(d->viewIcon(RunCommand)), d->viewText(RunCommand))->setData(KUrl("leave:/run"));
- }
+ menuview->addAction(KIcon(d->viewIcon(RunCommand)), d->viewText(RunCommand))->setData(KUrl("leave:/run"));
} else if(vtname == "SwitchUser") {
menuview->addAction(KIcon(d->viewIcon(SwitchUser)), d->viewText(SwitchUser))->setData(KUrl("leave:/switch"));
} else if(vtname == "SaveSession") {
#include <Plasma/Package>
#include <Plasma/WindowEffects>
-#include <KAuthorized>
#include <KConfigDialog>
#include <taskmanager/groupmanager.h>
}
}
- if (!KAuthorized::authorizeKAction("kwin_rmb") || !item || !declItem) {
+ if (!item || !declItem) {
return;
}
#include <QVBoxLayout>
#include <KAction>
-#include <KAuthorized>
#include <KCrash>
#include <KDebug>
#include <KCmdLineArgs>
void PlasmaApp::showInteractiveConsole()
{
- if (KGlobal::config()->isImmutable() || !KAuthorized::authorize("plasma-desktop/scripting_console")) {
+ if (KGlobal::config()->isImmutable()) {
return;
}
}
}
}
-
- if (!KAuthorized::authorize("editable_desktop_icons")) {
- containment->setImmutability(Plasma::SystemImmutable);
- }
}
void PlasmaApp::containmentScreenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment *containment)
return c->corona()->action("add panel");
}
} else if (name == "_run_command") {
- if (KAuthorized::authorizeKAction("run_command")) {
- return m_runCommandAction;
- }
+ return m_runCommandAction;
} else if (name == "_lock_screen") {
if (KAuthorized::authorizeKAction("lock_screen")) {
return m_lockScreenAction;
void ContextMenu::runCommand()
{
- if (!KAuthorized::authorizeKAction("run_command")) {
- return;
- }
-
QString interface("org.kde.krunner");
org::kde::krunner::App krunner(interface, "/App", QDBusConnection::sessionBus());
krunner.display();
#include <QWidget>
#include <QPushButton>
-#include <KAuthorized>
#include <KDebug>
#ifdef Q_OS_UNIX
#include <KDE/SuProcess>
setObjectName( QLatin1String("Command" ));
setPriority(AbstractRunner::HighestPriority);
setHasRunOptions(true);
- m_enabled = KAuthorized::authorizeKAction("run_command") && KAuthorized::authorizeKAction("shell_access");
setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File |
Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::UnknownType |
Plasma::RunnerContext::Help);
void ShellRunner::match(Plasma::RunnerContext &context)
{
- if (!m_enabled) {
- return;
- }
-
if (context.type() == Plasma::RunnerContext::Executable ||
context.type() == Plasma::RunnerContext::ShellCommand) {
const QString term = context.query();
// filter match's id to remove runner's name
// as this is the command we want to run
- if (m_enabled) {
-#ifdef Q_OS_UNIX
- //kDebug() << m_asOtherUser << m_username << m_password;
- if (m_asOtherUser && !m_username.isEmpty()) {
- //TODO: provide some user feedback on failure
- QString exec;
- QString args;
- if (m_inTerminal) {
- // we have to reimplement this from KToolInvocation because we need to use KDESu
- KConfigGroup confGroup( KGlobal::config(), "General" );
- exec = confGroup.readPathEntry("TerminalApplication", "konsole");
- if (!exec.isEmpty()) {
- if (exec == "konsole") {
- args += " --noclose";
- } else if (exec == "xterm") {
- args += " -hold";
- }
-
- args += " -e " + context.query();
- }
- } else {
- const QStringList commandLine = KShell::splitArgs(context.query(), KShell::TildeExpand);
- if (!commandLine.isEmpty()) {
- exec = commandLine.at(0);
+ //kDebug() << m_asOtherUser << m_username << m_password;
+ if (m_asOtherUser && !m_username.isEmpty()) {
+ //TODO: provide some user feedback on failure
+ QString exec;
+ QString args;
+ if (m_inTerminal) {
+ // we have to reimplement this from KToolInvocation because we need to use KDESu
+ KConfigGroup confGroup( KGlobal::config(), "General" );
+ exec = confGroup.readPathEntry("TerminalApplication", "konsole");
+ if (!exec.isEmpty()) {
+ if (exec == "konsole") {
+ args += " --noclose";
+ } else if (exec == "xterm") {
+ args += " -hold";
}
- args = context.query().right(context.query().size() - commandLine.at(0).length());
+ args += " -e " + context.query();
+ }
+ } else {
+ const QStringList commandLine = KShell::splitArgs(context.query(), KShell::TildeExpand);
+ if (!commandLine.isEmpty()) {
+ exec = commandLine.at(0);
}
+ args = context.query().right(context.query().size() - commandLine.at(0).length());
+ }
+
+ if (!exec.isEmpty()) {
+ exec = KStandardDirs::findExe(exec);
+ exec.append(args);
if (!exec.isEmpty()) {
- exec = KStandardDirs::findExe(exec);
- exec.append(args);
- if (!exec.isEmpty()) {
- KDESu::SuProcess client(m_username.toLocal8Bit(), exec.toLocal8Bit());
- const QByteArray password = m_password.toLocal8Bit();
- //TODO handle errors like wrong password via KNotifications in 4.7
- client.exec(password.constData());
- }
+ KDESu::SuProcess client(m_username.toLocal8Bit(), exec.toLocal8Bit());
+ const QByteArray password = m_password.toLocal8Bit();
+ //TODO handle errors like wrong password via KNotifications in 4.7
+ client.exec(password.constData());
}
- } else
-#endif
- if (m_inTerminal) {
- KToolInvocation::invokeTerminal(context.query());
- } else {
- KRun::runCommand(context.query(), NULL);
}
+ } else if (m_inTerminal) {
+ KToolInvocation::invokeTerminal(context.query());
+ } else {
+ KRun::runCommand(context.query(), NULL);
}
// reset for the next run!
private:
QString m_username;
QString m_password;
- bool m_enabled;
bool m_inTerminal;
bool m_asOtherUser;
};