diff --git a/src/backends/polkit-1/kauth-policy-gen-polkit1.cpp b/src/backends/polkit-1/kauth-policy-gen-polkit1.cpp index f24d052..fc4204a 100644 --- a/src/backends/polkit-1/kauth-policy-gen-polkit1.cpp +++ b/src/backends/polkit-1/kauth-policy-gen-polkit1.cpp @@ -1,121 +1,121 @@ /* * Copyright (C) 2008 Nicola Gigante * Copyright (C) 2009-2010 Dario Freddi * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 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 Lesser 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 #include #include #include const char header[] = "" "\n" "\n" "\n"; const char policy_tag[] = "" " \n" " %1\n" " %2\n" " \n"; const char dent[] = " "; void output(QList actions, const QMap &domain) { QTextStream out(stdout); out.setCodec("UTF-8"); out << header; // Blacklisted characters + replacements QMap< QChar, QString > blacklist; blacklist.insert(QLatin1Char('&'), QLatin1String("&")); if (domain.contains(QLatin1String("vendor"))) { QString vendor = domain[QLatin1String("vendor")]; for (QMap< QChar, QString >::const_iterator blI = blacklist.constBegin(), total = blacklist.constEnd(); blI != total; ++blI) { vendor.replace(blI.key(), blI.value()); } out << "" << vendor << "\n"; } if (domain.contains(QLatin1String("vendorurl"))) { out << "" << domain[QLatin1String("vendorurl")] << "\n"; } if (domain.contains(QLatin1String("icon"))) { out << "" << domain[QLatin1String("icon")] << "\n"; } Q_FOREACH (const Action &action, actions) { out << dent << "\n"; // Not a typo, messages and descriptions are actually inverted for (QMap< QString, QString >::const_iterator i = action.messages.constBegin(); i != action.messages.constEnd(); ++i) { out << dent << dent << "::const_iterator blI; QString description = i.value(); for (blI = blacklist.constBegin(); blI != blacklist.constEnd(); ++blI) { description.replace(blI.key(), blI.value()); } out << '>' << description << "\n"; } QMap< QString, QString >::const_iterator i; for (QMap< QString, QString >::const_iterator i = action.descriptions.constBegin(); i != action.descriptions.constEnd(); ++i) { out << dent << dent << "::const_iterator blI; QString message = i.value(); for (blI = blacklist.constBegin(); blI != blacklist.constEnd(); ++blI) { message.replace(blI.key(), blI.value()); } out << '>' << message << "\n"; } QString policy = action.policy; QString policyInactive = action.policyInactive.isEmpty() ? QLatin1String("no") : action.policyInactive; if (!action.persistence.isEmpty() && policy != QLatin1String("yes") && policy != QLatin1String("no")) { policy += QLatin1String("_keep"); } if (!action.persistence.isEmpty() && policyInactive != QLatin1String("yes") && policyInactive != QLatin1String("no")) { policyInactive += QLatin1String("_keep"); } - out << QString(QLatin1String(policy_tag)).arg(policyInactive).arg(policy); + out << QString(QLatin1String(policy_tag)).arg(policyInactive, policy); out << dent << "\n"; } out << "\n"; }