Commit 363ac701 authored by Aaron J. Seigo's avatar Aaron J. Seigo

first run at this

parent 3798f024
project(active_settings_development)
find_package(KDE4 REQUIRED)
include(KDE4Defaults)
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories(${KDE4_INCLUDES} ../../../../components/settings)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
set(developmentsettings_SRCS
developmentsettingsplugin.cpp
)
kde4_add_plugin(active_settings_development ${developmentsettings_SRCS})
target_link_libraries(active_settings_development ${KDE4_PLASMA_LIBS} ${QT_QTDECLARATIVE_LIBRARY})
install(TARGETS active_settings_development DESTINATION ${PLUGIN_INSTALL_DIR})
# Time and Date
install(DIRECTORY package/ DESTINATION ${DATA_INSTALL_DIR}/plasma/packages/org.kde.active.settings.development)
install(FILES package/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR} RENAME org.kde.active.settings.development.desktop)
########### helper ###############
kde4_add_executable(active-sshd-helper sshdhelper.cpp ${helper_mocs})
target_link_libraries(active-sshd-helper ${KDE4_KDECORE_LIBS})
install(TARGETS active-sshd-helper DESTINATION ${LIBEXEC_INSTALL_DIR})
kde4_install_auth_helper_files(active-sshd-helper org.kde.active.sshdcontrol root)
kde4_install_auth_actions(org.kde.active.sshdcontrol active_dev_sshd.actions)
[Domain]
Name=SSH Remote Access
Icon=utilities-terminal
[org.kde.active.sshdcontrol.start]
Name=Activate sshd
Policy=yes
[org.kde.active.sshdcontrol.stop]
Name=Deactivate sshd
Policy=yes
/*
* Copyright 2012 Aaron Seigo <aseigo@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 "sshdhelper.h"
#include <QProcess>
#include <QFile>
#include <QDebug>
static const QLatin1String startCommand("systemctl start sshd.service");
static const QLatin1String startAtBootCommand("systemctl enabled sshd.service");
static const QLatin1String stopCommand("systemctl stop sshd.service");
static const QLatin1String stopAtBootCommand("systemctl disabled sshd.service");
SshdHelper::SshdHelper(QObject *parent)
: QObject(parent)
{
}
ActionReply SshdHelper::start(const QVariantMap &args)
{
int rv = QProcess::execute(startCommand);
if (rv == 0) {
rv = QProcess::execute(startAtBootCommand);
}
if (rv == 0) {
return ActionReply::SuccessReply;
} else {
ActionReply reply(ActionReply::HelperError);
reply.setErrorCode(rv);
return reply;
}
}
ActionReply SshdHelper::stop(const QVariantMap &args)
{
int rv = QProcess::execute(stopCommand);
if (rv == 0) {
rv = QProcess::execute(stopAtBootCommand);
}
if (rv == 0) {
return ActionReply::SuccessReply;
} else {
ActionReply reply(ActionReply::HelperError);
reply.setErrorCode(rv);
return reply;
}
}
KDE4_AUTH_HELPER_MAIN("org.kde.active.sshdcontrol", SshdHelper)
/*
* Copyright 2012 Aaron Seigo <aseigo@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 SSHD_HELPER_H
#define SSHD_HELPER_H
#include <kauth.h>
using namespace KAuth;
class SshdHelper : public QObject
{
Q_OBJECT
public:
SshdHelper(QObject *parent = 0);
public slots:
ActionReply start(const QVariantMap &map);
ActionReply stop(const QVariantMap &map);
};
#endif // SSHD_HELPER_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment