Add helper for remote widgets

svn path=/trunk/KDE/kdelibs/; revision=1018864
This commit is contained in:
Dario Freddi 2009-09-02 09:45:52 +00:00
parent 083c419616
commit 25dcae9cf1
4 changed files with 101 additions and 0 deletions

View File

@ -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)

View File

@ -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

52
remotewidgetshelper.cpp Normal file
View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 <QFile>
#include <QTextStream>
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)

36
remotewidgetshelper.h Normal file
View File

@ -0,0 +1,36 @@
/*
* main.h
*
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
*
* 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 <kauth.h>
using namespace KAuth;
class RemoteWidgetsHelper : public QObject
{
Q_OBJECT
public slots:
ActionReply save(const QVariantMap &map);
};
#endif // REMOTEWIDGETS_HELPER_H