[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/base/polkit-kde-1/kcmodules
From: Dario Freddi <drf () kde ! org>
Date: 2010-02-22 21:35:44
Message-ID: 1266874544.900972.13932.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1094512 by dafre:
Implement in the helper the basics for saving
Signed-off-by: Dario Freddi <drf@kde.org>
M +50 -1 helper/polkitkde1helper.cpp
M +2 -0 helper/polkitkde1helper.h
M +2 -0 polkitactions/explicitauthorizationdialog.cpp
--- trunk/extragear/base/polkit-kde-1/kcmodules/helper/polkitkde1helper.cpp #1094511:1094512
@@ -18,8 +18,13 @@
#include <QtDBus/QDBusConnection>
#include <PolkitQt1/Authority>
-#include <qdir.h>
+#include <QDir>
+bool orderByPriorityLessThan(const PKLAEntry &e1, const PKLAEntry &e2)
+{
+ return e1.fileOrder < e2.fileOrder;
+}
+
PolkitKde1Helper::PolkitKde1Helper(QObject* parent)
: QObject(parent)
{
@@ -179,3 +184,47 @@
return retlist;
}
+void PolkitKde1Helper::writePolicy(const QVariantList& policy)
+{
+ PKLAEntryList entries;
+ foreach (const QVariant &variant, policy) {
+ entries.append(variant.value<PKLAEntry>());
+ }
+ qSort(entries.begin(), entries.end(), orderByPriorityLessThan);
+
+ QSettings kdesettings("/etc/polkit-1/polkit-kde-1.conf", QSettings::IniFormat);
+ kdesettings.beginGroup("General");
+
+ QString path = QString("/var/lib/polkit-1/localauthority/%1-polkitkde/%2.conf")
+ .arg(kdesettings.value("PoliciesPriority",75).toInt()).arg(entries.first().action);
+
+ if (QFile::exists(path)) {
+ QFile::remove(path);
+ }
+
+ QString contents;
+
+ foreach (const PKLAEntry &entry, entries) {
+ contents.append(formatPKLAEntry(entry));
+ contents.append('\n');
+ }
+
+ QFile wfile(path);
+ wfile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
+ wfile.write(contents.toUtf8());
+ wfile.flush();
+ wfile.close();
+}
+
+QString PolkitKde1Helper::formatPKLAEntry(const PKLAEntry& entry)
+{
+ QString retstring;
+ retstring.append(QString("[%1]\n").arg(entry.title));
+ retstring.append(QString("Identity=%1\n").arg(entry.identity));
+ retstring.append(QString("Action=%1\n").arg(entry.action));
+ retstring.append(QString("ResultAny=%1\n").arg(entry.resultAny));
+ retstring.append(QString("ResultInactive=%1\n").arg(entry.resultInactive));
+ retstring.append(QString("ResultActive=%1\n").arg(entry.resultActive));
+ return retstring;
+}
+
--- trunk/extragear/base/polkit-kde-1/kcmodules/helper/polkitkde1helper.h #1094511:1094512
@@ -28,9 +28,11 @@
public Q_SLOTS:
void saveGlobalConfiguration(const QString &adminIdentities, int systemPriority, int policiesPriority);
QVariantList retrievePolicies();
+ void writePolicy(const QVariantList &policy);
private:
QVariantList entriesFromFile(int filePriority, const QString &fileContents);
+ QString formatPKLAEntry(const PKLAEntry &entry);
};
#endif // POLKITKDE1HELPER_H
--- trunk/extragear/base/polkit-kde-1/kcmodules/polkitactions/explicitauthorizationdialog.cpp #1094511:1094512
@@ -45,6 +45,8 @@
setMainWidget(widget);
setModal(true);
+ m_ui->addButton->setIcon(KIcon("list-add"));
+
m_identitiesLayout = new QVBoxLayout;
m_identitiesLayout->addStretch();
m_ui->scrollAreaWidgetContents->setLayout(m_identitiesLayout);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic