From 25dcae9cf1f75c402ce8b0697631648aff33ba34 Mon Sep 17 00:00:00 2001 From: Dario Freddi Date: Wed, 2 Sep 2009 09:45:52 +0000 Subject: [PATCH] Add helper for remote widgets svn path=/trunk/KDE/kdelibs/; revision=1018864 --- CMakeLists.txt | 9 +++++++ kcm_remotewidgets.actions | 4 +++ remotewidgetshelper.cpp | 52 +++++++++++++++++++++++++++++++++++++++ remotewidgetshelper.h | 36 +++++++++++++++++++++++++++ 4 files changed, 101 insertions(+) create mode 100644 kcm_remotewidgets.actions create mode 100644 remotewidgetshelper.cpp create mode 100644 remotewidgetshelper.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b6268490..9c9e83351 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -367,3 +367,12 @@ install(FILES plasma_popupapplet_fix_groups.upd DESTINATION ${KCONF_UPDATE_INSTA install(PROGRAMS plasma_popupapplet_fix_groups.pl DESTINATION ${KCONF_UPDATE_INSTALL_DIR}) install(FILES dataengineservice.operations DESTINATION ${DATA_INSTALL_DIR}/plasma/services) install(FILES plasmoidservice.operations DESTINATION ${DATA_INSTALL_DIR}/plasma/services) + +########### next target ############### + +include(MacroKAuth) + +kde4_auth_add_helper(kcmremotewidgetshelper org.kde.kcontrol.kcmremotewidgets root remotewidgetshelper.cpp) + +kde4_auth_register_actions(org.kde.kcontrol.kcmremotewidgets kcm_remotewidgets.actions) + diff --git a/kcm_remotewidgets.actions b/kcm_remotewidgets.actions new file mode 100644 index 000000000..d653c2ff2 --- /dev/null +++ b/kcm_remotewidgets.actions @@ -0,0 +1,4 @@ +[org.kde.kcontrol.kcmremotewidgets.save] +Name=Save remote widgets policies +Description=Prevents the system from saving plasma remote widgets policies +Policy=auth_admin diff --git a/remotewidgetshelper.cpp b/remotewidgetshelper.cpp new file mode 100644 index 000000000..537c08dcb --- /dev/null +++ b/remotewidgetshelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2009 Dario Freddi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "remotewidgetshelper.h" + +#include +#include + +ActionReply RemoteWidgetsHelper::save(const QVariantMap &args) +{ + QString filename = args["filename"].toString(); + QString source = args["source"].toString(); + + QFile file(filename); + if (!file.open(QIODevice::WriteOnly)) { + ActionReply reply = ActionReply::HelperErrorReply; + reply.setErrorCode(file.error()); + + return reply; + } + + QFile sfile(source); + if (!sfile.open(QIODevice::ReadOnly)) { + ActionReply reply = ActionReply::HelperErrorReply; + reply.setErrorCode(sfile.error()); + + return reply; + } + + QTextStream stream(&file); + stream << sfile.readAll(); + + return ActionReply::SuccessReply; +} + +KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmremotewidgets", RemoteWidgetsHelper) diff --git a/remotewidgetshelper.h b/remotewidgetshelper.h new file mode 100644 index 000000000..7fd447b03 --- /dev/null +++ b/remotewidgetshelper.h @@ -0,0 +1,36 @@ +/* + * main.h + * + * Copyright (C) 2009 Dario Freddi + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +#ifndef REMOTEWIDGETS_HELPER_H +#define REMOTEWIDGETS_HELPER_H + +#include + +using namespace KAuth; + +class RemoteWidgetsHelper : public QObject +{ + Q_OBJECT + + public slots: + ActionReply save(const QVariantMap &map); +}; + +#endif // REMOTEWIDGETS_HELPER_H