OSDN Git Service

generic: drop most of the KIOSK functionality
authorIvailo Monev <xakepa10@gmail.com>
Tue, 19 May 2015 05:25:12 +0000 (05:25 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Tue, 19 May 2015 05:25:12 +0000 (05:25 +0000)
15 files changed:
khotkeys/libkhotkeysprivate/actions/command_url_action.cpp
krunner/krunnerapp.cpp
ksmserver/screenlocker/greeter/screensaverwindow.cpp
ksmserver/screenlocker/greeter/screensaverwindow.h
plasma/desktop/applets/homerun/fullscreen/applet/homerunlauncher.cpp
plasma/desktop/applets/kickoff/applet/applet.cpp
plasma/desktop/applets/kickoff/core/itemhandlers.cpp
plasma/desktop/applets/kickoff/core/systemmodel.cpp
plasma/desktop/applets/kickoff/core/urlitemlauncher.cpp
plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp
plasma/desktop/applets/tasks/tasks.cpp
plasma/desktop/shell/plasmaapp.cpp
plasma/generic/containmentactions/contextmenu/menu.cpp
plasma/generic/runners/shell/shellrunner.cpp
plasma/generic/runners/shell/shellrunner.h

index 7bd0004..c167afb 100644 (file)
@@ -20,7 +20,6 @@
 #include "actions/actions.h"
 #include "action_data/action_data.h"
 
-#include <KDE/KAuthorized>
 #include <KDE/KConfigGroup>
 #include <KDE/KDebug>
 #include <KDE/KRun>
@@ -115,8 +114,6 @@ void CommandUrlAction::execute()
             }
         case KUriFilterData::Executable:
             {
-            if (!KAuthorized::authorizeKAction("shell_access"))
-                return;
             if( !uri.hasArgsAndOptions())
                 {
                 KService::Ptr service = KService::serviceByDesktopName( cmd );
@@ -130,8 +127,6 @@ void CommandUrlAction::execute()
             }
         case KUriFilterData::Shell:
             {
-            if (!KAuthorized::authorizeKAction("shell_access"))
-                return;
             if( !KRun::runCommand(
                 cmd + ( uri.hasArgsAndOptions() ? uri.argsAndOptions() : "" ),
                 cmd, uri.iconName(), NULL )) {
index 825400d..9983b66 100644 (file)
@@ -113,17 +113,15 @@ void KRunnerApp::initialize()
     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"));
@@ -138,9 +136,6 @@ void KRunnerApp::initialize()
     }
 
     //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:
@@ -163,19 +158,17 @@ void KRunnerApp::initialize()
 
 
     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()));
     }
 }
 
@@ -189,10 +182,6 @@ void KRunnerApp::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());
 
@@ -248,20 +237,12 @@ void KRunnerApp::showTaskManagerWithFilter(const QString &filterText)
 
 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();
@@ -269,11 +250,6 @@ void KRunnerApp::displaySingleRunner(const QString &runnerId)
 
 void KRunnerApp::displayOrHide()
 {
-    if (!KAuthorized::authorize(QLatin1String("run_command"))) {
-        m_interface->hide();
-        return;
-    }
-
     if (!m_interface->isVisible()) {
         m_runnerManager->setSingleMode(false);
     }
@@ -293,19 +269,11 @@ void KRunnerApp::displayOrHide()
 
 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);
 }
index 9a6f73c..e43b798 100644 (file)
@@ -34,7 +34,6 @@
 #include <kshell.h>
 #include <KService>
 #include <KServiceTypeTrader>
-#include <KAuthorized>
 #include <KDesktopFile>
 #include <KStandardDirs>
 
@@ -49,7 +48,6 @@ namespace ScreenLocker
 ScreenSaverWindow::ScreenSaverWindow(QWidget *parent)
     : QWidget(parent),
       m_startMousePos(-1, -1),
-      m_forbidden(false),
       m_openGLVisual(false)
 {
     setCursor(Qt::BlankCursor);
@@ -97,27 +95,14 @@ void ScreenSaverWindow::readSaver()
         }
         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());
@@ -190,7 +175,7 @@ bool ScreenSaverWindow::startXScreenSaver()
     //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;
     }
 
index 90214d8..3959977 100644 (file)
@@ -64,7 +64,6 @@ private:
 
     QTimer *m_reactivateTimer;
 
-    bool m_forbidden : 1;
     bool m_openGLVisual : 1;
 };
 
index 3d20fcc..e2274d1 100644 (file)
@@ -29,7 +29,6 @@
 #include <QDBusServiceWatcher>
 
 // KDE
-#include <KAuthorized>
 #include <KConfigDialog>
 #include <KProcess>
 #include <KRun>
@@ -57,7 +56,7 @@ HomerunLauncher::HomerunLauncher(QObject * parent, const QVariantList & args)
 
 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()));
index efb2334..d074899 100644 (file)
@@ -29,7 +29,6 @@
 #include <QtGui/QGraphicsLinearLayout>
 
 // KDE
-#include <KAuthorized>
 #include <KIcon>
 #include <KDebug>
 #include <KConfigDialog>
@@ -104,7 +103,7 @@ LauncherApplet::~LauncherApplet()
 
 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()));
index 7b61918..f3a7efb 100644 (file)
@@ -24,7 +24,6 @@
 #include <QTimer>
 
 // KDE
-#include <KAuthorized>
 #include <KDebug>
 #include <KJob>
 #include <KService>
@@ -117,11 +116,9 @@ bool LeaveItemHandler::openUrl(const KUrl& url)
 
 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()
index 7346046..a08d78d 100644 (file)
@@ -25,7 +25,6 @@
 #include <QTimer>
 
 // KDE
-#include <KAuthorized>
 #include <KDebug>
 #include <KDiskFreeSpaceInfo>
 #include <KIcon>
@@ -158,11 +157,7 @@ int SystemModel::rowCount(const QModelIndex &parent) const
     } 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();
index dc7be67..a69ebf1 100644 (file)
@@ -26,7 +26,6 @@
 #include <QModelIndex>
 
 // KDE
-#include <KAuthorized>
 #include <KDebug>
 #include <KRun>
 #include <KUrl>
@@ -54,7 +53,7 @@ class GenericItemHandler : public UrlItemHandler
 {
 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();
index 7bc5541..6d22d55 100644 (file)
@@ -39,7 +39,6 @@
 
 // KDE Libs
 #include <KActionCollection>
-#include <KAuthorized>
 #include <KBookmarkMenu>
 #include <KCModuleInfo>
 #include <KComboBox>
@@ -302,9 +301,7 @@ MenuLauncherApplet::MenuLauncherApplet(QObject *parent, const QVariantList &args
         }
         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";
         }
@@ -337,7 +334,7 @@ void MenuLauncherApplet::init()
     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()));
@@ -744,9 +741,7 @@ void MenuLauncherApplet::showMenu(bool pressed)
                     }
                 }
             } 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") {
index 12348f1..6ed394d 100644 (file)
@@ -30,7 +30,6 @@
 #include <Plasma/Package>
 #include <Plasma/WindowEffects>
 
-#include <KAuthorized>
 #include <KConfigDialog>
 
 #include <taskmanager/groupmanager.h>
@@ -216,7 +215,7 @@ void Tasks::itemContextMenu(int id)
         }
     }
 
-    if (!KAuthorized::authorizeKAction("kwin_rmb") || !item || !declItem) {
+    if (!item || !declItem) {
         return;
     }
 
index 3d71c84..b80f648 100644 (file)
@@ -43,7 +43,6 @@
 #include <QVBoxLayout>
 
 #include <KAction>
-#include <KAuthorized>
 #include <KCrash>
 #include <KDebug>
 #include <KCmdLineArgs>
@@ -376,7 +375,7 @@ void PlasmaApp::dashboardClosed()
 
 void PlasmaApp::showInteractiveConsole()
 {
-    if (KGlobal::config()->isImmutable() || !KAuthorized::authorize("plasma-desktop/scripting_console")) {
+    if (KGlobal::config()->isImmutable()) {
         return;
     }
 
@@ -1038,10 +1037,6 @@ void PlasmaApp::prepareContainment(Plasma::Containment *containment)
             }
         }
     }
-
-    if (!KAuthorized::authorize("editable_desktop_icons")) {
-        containment->setImmutability(Plasma::SystemImmutable);
-    }
 }
 
 void PlasmaApp::containmentScreenOwnerChanged(int wasScreen, int isScreen, Plasma::Containment *containment)
index 8b1bc16..b571bf1 100644 (file)
@@ -165,9 +165,7 @@ QAction *ContextMenu::action(const QString &name)
             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;
@@ -185,10 +183,6 @@ QAction *ContextMenu::action(const QString &name)
 
 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();
index 3f87bc9..68dd278 100644 (file)
@@ -21,7 +21,6 @@
 #include <QWidget>
 #include <QPushButton>
 
-#include <KAuthorized>
 #include <KDebug>
 #ifdef Q_OS_UNIX
 #include <KDE/SuProcess>
@@ -45,7 +44,6 @@ ShellRunner::ShellRunner(QObject *parent, const QVariantList &args)
     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);
@@ -59,10 +57,6 @@ ShellRunner::~ShellRunner()
 
 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();
@@ -83,52 +77,47 @@ void ShellRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryM
     // 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!
index 208f8dc..33c0538 100644 (file)
@@ -49,7 +49,6 @@ class ShellRunner : public Plasma::AbstractRunner
     private:
         QString m_username;
         QString m_password;
-        bool m_enabled;
         bool m_inTerminal;
         bool m_asOtherUser;
 };