24 #include "private/authorizationmanager_p.h"
25 #include "private/authorizationrule_p.h"
27 #include <QtCore/QObject>
28 #include <QtCore/QTimer>
31 #include <klocalizedstring.h>
36 AuthorizationRulePrivate::AuthorizationRulePrivate(
const QString &serviceName,
const QString &credentialID,
37 AuthorizationRule *rule)
39 serviceName(serviceName),
40 credentialID(credentialID),
41 policy(AuthorizationRule::Deny),
42 targets(AuthorizationRule::Default),
43 persistence(AuthorizationRule::Transient)
47 AuthorizationRulePrivate::~AuthorizationRulePrivate()
51 bool AuthorizationRulePrivate::matches(
const QString &name,
const QString &
id)
const
53 if (serviceName == name && (credentialID ==
id)) {
68 void AuthorizationRulePrivate::scheduleChangedSignal()
70 QTimer::singleShot(0, q, SLOT(fireChangedSignal()));
73 void AuthorizationRulePrivate::fireChangedSignal()
83 AuthorizationRule::AuthorizationRule(
const QString &serviceName,
const QString &credentialID)
84 :
QObject(AuthorizationManager::self()),
85 d(new AuthorizationRulePrivate(serviceName, credentialID, this))
98 return i18n(
"Allow everybody access to %1.", d->serviceName);
99 }
else if (d->targets.testFlag(
AllUsers) && d->policy ==
Deny) {
100 return i18n(
"Deny everybody access to %1", d->serviceName);
102 return i18n(
"Allow %1 access to all services.",
credentials().name());
104 return i18n(
"Deny %1 access to all services.",
credentials().name());
105 }
else if (d->policy ==
Allow) {
106 return i18n(
"Allow access to %1, by %2.", d->serviceName,
credentials().name());
107 }
else if (d->policy ==
Deny) {
108 return i18n(
"Deny access to %1, by %2.", d->serviceName,
credentials().name());
110 return i18n(
"Allow access to %1, by %2?", d->serviceName,
credentials().name());
118 d->scheduleChangedSignal();
129 d->scheduleChangedSignal();
140 d->scheduleChangedSignal();
145 return d->persistence;
151 d->scheduleChangedSignal();
166 return d->serviceName;
171 #include "authorizationrule.moc"