-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a45297
Showing
19 changed files
with
4,093 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
project(kcmsystemd) | ||
set(KCM_SYSTEMD_VERSION_MAJOR "0") | ||
set(KCM_SYSTEMD_VERSION_MINOR "1") | ||
set(KCM_SYSTEMD_VERSION_PATCH "0") | ||
set(KCM_SYSTEMD_VERSION "${KCM_SYSTEMD_VERSION_MAJOR}.${KCM_SYSTEMD_VERSION_MINOR}.${KCM_SYSTEMD_VERSION_PATCH}") | ||
|
||
cmake_minimum_required(VERSION 2.6) | ||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) | ||
|
||
find_package(Qt4 4.6.0 REQUIRED) | ||
find_package(KDE4 4.4.0 REQUIRED) | ||
include(KDE4Defaults) | ||
|
||
include_directories( ${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ) | ||
include_directories( ${KDE4_INCLUDES} ) | ||
add_definitions( ${KDE4_DEFINITIONS} ) | ||
|
||
set(kcmsystemd_INCLUDE_DIRS ${KDE4_INCLUDES}) | ||
|
||
set(CMAKE_CXX_FLAGS "-fexceptions") | ||
|
||
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config.h) | ||
|
||
add_subdirectory(other) | ||
add_subdirectory(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef CONFIG_H | ||
#define CONFIG_H | ||
|
||
#define KCM_SYSTEMD_VERSION "@KCM_SYSTEMD_VERSION@" | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
install(FILES kcm_systemd.desktop DESTINATION ${SERVICES_INSTALL_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Desktop Entry] | ||
Icon=system-run | ||
Type=Service | ||
X-KDE-ServiceTypes=KCModule | ||
Exec=kcmshell4 kcm_systemd | ||
|
||
X-KDE-Library=kcm_systemd | ||
X-KDE-ParentApp=kcontrol | ||
X-KDE-System-Settings-Parent-Category=system-administration | ||
|
||
Name=Systemd | ||
Comment=Configure the systemd daemon | ||
X-KDE-Keywords=systemd | ||
Categories=Qt;KDE;X-KDE-settings-system; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[Dolphin] | ||
Timestamp=2013,8,13,12,32,11 | ||
Version=3 | ||
ViewMode=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
add_subdirectory(helper) | ||
|
||
set(kcmsystemd_INCLUDE_DIRS ${KDE4_INCLUDES}) | ||
|
||
set(kcmsystemd_SRCS kcmsystemd.cpp reslimits.cpp environ.cpp) | ||
|
||
find_package(Boost 1.45.0 COMPONENTS filesystem system) | ||
|
||
kde4_add_ui_files(kcmsystemd_SRCS ../ui/kcmsystemd.ui) | ||
kde4_add_ui_files(kcmsystemd_SRCS ../ui/reslimits.ui) | ||
kde4_add_ui_files(kcmsystemd_SRCS ../ui/environ.ui) | ||
|
||
include_directories(${kcmsystemd_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) | ||
link_directories(${Boost_LIBRARY_DIR}) | ||
kde4_add_plugin(kcm_systemd ${kcmsystemd_SRCS}) | ||
target_link_libraries(kcm_systemd ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${Boost_LIBRARIES}) | ||
install(TARGETS kcm_systemd DESTINATION ${PLUGIN_INSTALL_DIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2013 Ragnar Thomsen <rthomsen6@gmail.com> * | ||
* * | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. * | ||
*******************************************************************************/ | ||
|
||
#include "environ.h" | ||
#include "kcmsystemd.h" | ||
|
||
#include <QMessageBox> | ||
#include <QSignalMapper> | ||
|
||
int addedVars = 0; | ||
|
||
EnvironDialog::EnvironDialog (QWidget* parent, Qt::WFlags flags) : KDialog ( parent) | ||
{ | ||
// Initialize dialog window | ||
addedVars = 0; | ||
QWidget *widget = new QWidget(this); | ||
ui.setupUi(widget); | ||
setMainWidget( widget ); | ||
setWindowTitle(i18n("Set environment variables")); | ||
|
||
// create line edits for variables read from system.conf | ||
QListIterator<QPair<QString,QString> > i(kcmsystemd::environ); | ||
while (i.hasNext()) | ||
{ | ||
addedVars++; | ||
//QMessageBox::information(this, "Test", i.peekNext().first + "=" + i.peekNext().second); | ||
addNewVariable(addedVars, i.peekNext().first, i.peekNext().second); | ||
i.next(); | ||
} | ||
|
||
// button for adding a new variable | ||
connect(ui.btnNewVariable, SIGNAL(clicked()), this, SLOT(slotNewVariable())); | ||
} | ||
|
||
void EnvironDialog::slotButtonClicked(int button) | ||
{ | ||
if (button == KDialog::Ok) | ||
{ | ||
// empty "environ" | ||
kcmsystemd::environ.clear(); | ||
|
||
QPair<QString,QString> i; | ||
//QString test; | ||
|
||
// find all QLineEdits that contain "Name" | ||
QList<QLineEdit *> list = this->findChildren<QLineEdit *>(); | ||
foreach(QLineEdit *Name, list) | ||
{ | ||
if (Name->objectName().contains("Name")) | ||
{ | ||
QLineEdit *Value = this->findChild<QLineEdit *>(Name->objectName().section("Name",0,0) + "Value"); | ||
|
||
//test.append(Name->text() + "=" + Value->text() + " "); | ||
|
||
// If qlineedits not empty append them to "environ" | ||
if (!Name->text().trimmed().isEmpty() && !Value->text().trimmed().isEmpty()) | ||
{ | ||
i.first = Name->text(); | ||
i.second = Value->text(); | ||
kcmsystemd::environ.append(i); | ||
} | ||
} | ||
} | ||
|
||
// QMessageBox::information(this, "Test", test); | ||
} | ||
KDialog::slotButtonClicked(button); | ||
} | ||
|
||
// slot for button to add new variable | ||
void EnvironDialog::slotNewVariable() | ||
{ | ||
// each variable needs a numeric identifier so we can loop through them | ||
addedVars++; | ||
addNewVariable(addedVars,QString(""),QString("")); | ||
kcmsystemd::environChanged = 1; | ||
} | ||
|
||
void EnvironDialog::addNewVariable(int index, QString name, QString value) | ||
{ | ||
//QMessageBox::information(this, "Test", "Creating: " + QString::number(index)); | ||
QSignalMapper* signalMapper = new QSignalMapper (this); | ||
|
||
QLineEdit* leName = new QLineEdit (this); | ||
QLabel* lblEquals = new QLabel (this); | ||
QLineEdit* leValue = new QLineEdit (this); | ||
QPushButton* btnRm = new QPushButton ("Remove", this); | ||
ui.veLayoutVarNames->addWidget(leName); | ||
ui.veLayoutEquals->addWidget(lblEquals); | ||
ui.veLayoutVarValues->addWidget(leValue); | ||
ui.veLayoutRemoval->addWidget(btnRm); | ||
leName->setObjectName(QString::number(index)+"Name"); | ||
leName->show(); | ||
lblEquals->setObjectName(QString::number(index)+"Equals"); | ||
lblEquals->show(); | ||
leValue->setObjectName(QString::number(index)+"Value"); | ||
leValue->show(); | ||
btnRm->setObjectName(QString::number(index)+"Btn"); | ||
btnRm->show(); | ||
|
||
leName->setText(name); | ||
leValue->setText(value); | ||
lblEquals->setText("="); | ||
|
||
connect(btnRm, SIGNAL(clicked()), signalMapper, SLOT(map())); | ||
signalMapper->setMapping (btnRm, index); | ||
connect(signalMapper, SIGNAL(mapped(const int &)), this, SLOT(slotRemoveVariable(const int &))); | ||
} | ||
|
||
void EnvironDialog::slotRemoveVariable(const int &index) | ||
{ | ||
//QMessageBox::information(this, "Test", "Removing: " + QString::number(index)); | ||
QLineEdit *varName = this->findChild<QLineEdit *>(QString::number(index)+"Name"); | ||
if (varName) | ||
varName->hide(); | ||
delete varName; | ||
QLabel *varEquals = this->findChild<QLabel *>(QString::number(index)+"Equals"); | ||
if (varEquals) | ||
varEquals->hide(); | ||
delete varEquals; | ||
QLineEdit *varValue = this->findChild<QLineEdit *>(QString::number(index)+"Value"); | ||
if (varValue) | ||
varValue->hide(); | ||
delete varValue; | ||
QPushButton *varBtn = this->findChild<QPushButton *>(QString::number(index)+"Btn"); | ||
if (varBtn) | ||
varBtn->hide(); | ||
delete varBtn; | ||
addedVars--; | ||
kcmsystemd::environChanged = 1; | ||
layout()->setSizeConstraint(QLayout::SetFixedSize); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2013 Ragnar Thomsen <rthomsen6@gmail.com> * | ||
* * | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. * | ||
*******************************************************************************/ | ||
|
||
#ifndef ENVIRON_H | ||
#define ENVIRON_H | ||
|
||
#include "ui_environ.h" | ||
|
||
class EnvironDialog : public KDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit EnvironDialog(QWidget *parent=0, Qt::WFlags flags = 0); | ||
virtual void addNewVariable(int, QString, QString); | ||
|
||
private slots: | ||
void slotButtonClicked(int button); | ||
void slotNewVariable(); | ||
void slotRemoveVariable(const int &index); | ||
|
||
private: | ||
Ui::EnvironDialog ui; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Set Include Directories | ||
set(kcmsystemdhelper_INCLUDE_DIRS ${KDE4_INCLUDES}) | ||
|
||
# Set Sources | ||
set(kcmsystemdhelper_SRCS helper.cpp) | ||
|
||
# Set Link Libraries | ||
set(kcmsystemdhelper_LINK_LIBS ${KDE4_KDECORE_LIBS}) | ||
|
||
# Build & Link | ||
include_directories(${kcmsystemdhelper_INCLUDE_DIRS}) | ||
kde4_add_executable(kcmsystemdhelper ${kcmsystemdhelper_SRCS}) | ||
target_link_libraries(kcmsystemdhelper ${kcmsystemdhelper_LINK_LIBS}) | ||
|
||
# Install | ||
install(TARGETS kcmsystemdhelper DESTINATION ${LIBEXEC_INSTALL_DIR}) | ||
kde4_install_auth_helper_files(kcmsystemdhelper org.kde.kcontrol.kcmsystemd root) | ||
kde4_install_auth_actions(org.kde.kcontrol.kcmsystemd kcmsystemd.actions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2013 Ragnar Thomsen <rthomsen6@gmail.com> * | ||
* * | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. * | ||
*******************************************************************************/ | ||
|
||
#include "helper.h" | ||
|
||
#include <QDir> | ||
#include <QTextStream> | ||
|
||
#include <kdeversion.h> | ||
#include <KAuth/HelperSupport> | ||
|
||
#include "../config.h" | ||
|
||
ActionReply Helper::save(QVariantMap args) | ||
{ | ||
ActionReply reply; | ||
|
||
// Declare QStrings with file names and contents | ||
QString systemConfFileContents = args["systemConfFileContents"].toString(); | ||
QString journaldConfFileContents = args["journaldConfFileContents"].toString(); | ||
QString logindConfFileContents = args["logindConfFileContents"].toString(); | ||
|
||
// write system.conf | ||
//QMessageBox::information(this, QString("Title"), args["etcDir"].toString()); | ||
QFile sysFile(args["etcDir"].toString() + "/system.conf"); | ||
if (!sysFile.open(QIODevice::WriteOnly | QIODevice::Text)) { | ||
reply = ActionReply::HelperErrorReply; | ||
reply.addData("errorDescription", sysFile.errorString()); | ||
reply.setErrorCode(sysFile.error()); | ||
reply.addData("filename", "system.conf"); | ||
return reply; | ||
} | ||
QTextStream sysStream(&sysFile); | ||
sysStream << systemConfFileContents; | ||
sysFile.close(); | ||
|
||
// write journald.conf | ||
QFile jrnlFile(args["etcDir"].toString() + "/journald.conf"); | ||
if (!jrnlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { | ||
reply = ActionReply::HelperErrorReply; | ||
reply.setErrorCode(jrnlFile.error()); | ||
reply.addData("filename", "journald.conf"); | ||
return reply; | ||
} | ||
QTextStream jrnlStream(&jrnlFile); | ||
jrnlStream << journaldConfFileContents; | ||
jrnlFile.close(); | ||
|
||
// write logind.conf | ||
QFile loginFile(args["etcDir"].toString() + "/logind.conf"); | ||
if (!loginFile.open(QIODevice::WriteOnly | QIODevice::Text)) { | ||
reply = ActionReply::HelperErrorReply; | ||
reply.setErrorCode(loginFile.error()); | ||
reply.addData("filename", "logind.conf"); | ||
return reply; | ||
} | ||
QTextStream loginStream(&loginFile); | ||
loginStream << logindConfFileContents; | ||
loginFile.close(); | ||
|
||
// return a reply | ||
return reply; | ||
} | ||
|
||
KDE4_AUTH_HELPER_MAIN("org.kde.kcontrol.kcmsystemd", Helper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/******************************************************************************* | ||
* Copyright (C) 2013 Ragnar Thomsen <rthomsen6@gmail.com> * | ||
* * | ||
* 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 3 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, see <http://www.gnu.org/licenses/>. * | ||
*******************************************************************************/ | ||
|
||
#ifndef HELPER_H | ||
#define HELPER_H | ||
|
||
#include <kauth.h> | ||
using namespace KAuth; | ||
|
||
class Helper : public QObject | ||
{ | ||
Q_OBJECT | ||
public slots: | ||
ActionReply save(QVariantMap args); | ||
}; | ||
|
||
#endif |
Oops, something went wrong.