Polkit-Qt-1
0.95.0
|
Convenience class for Qt/KDE applications. More...
#include <Authority>
Inherits QObject.
Public Types | |
enum | Result { Unknown = 0x00, Yes = 0x01, No = 0x02, Challenge = 0x03 } |
enum | AuthorizationFlag { None = 0x00, AllowUserInteraction = 0x01 } |
enum | ErrorCode { E_None = 0x00, E_GetAuthority = 0x01, E_CheckFailed = 0x02, E_WrongSubject = 0x03, E_UnknownResult = 0x04, E_EnumFailed = 0x05, E_RegisterFailed = 0x06, E_UnregisterFailed = 0x07, E_CookieOrIdentityEmpty = 0x08, E_AgentResponseFailed = 0x09, E_RevokeFailed = 0x0A } |
Signals | |
void | configChanged () |
void | consoleKitDBChanged () |
void | checkAuthorizationFinished (PolkitQt1::Authority::Result) |
void | enumerateActionsFinished (PolkitQt1::ActionDescription::List) |
void | registerAuthenticationAgentFinished (bool) |
void | unregisterAuthenticationAgentFinished (bool) |
void | authenticationAgentResponseFinished (bool) |
void | enumerateTemporaryAuthorizationsFinished (PolkitQt1::TemporaryAuthorization::List) |
void | revokeTemporaryAuthorizationsFinished (bool) |
void | revokeTemporaryAuthorizationFinished (bool) |
Public Member Functions | |
bool | hasError () const |
ErrorCode | lastError () const |
const QString | errorDetails () const |
void | clearError () |
PolkitAuthority * | polkitAuthority () const |
void | checkAuthorization (const QString &actionId, const Subject &subject, AuthorizationFlags flags) |
Result | checkAuthorizationSync (const QString &actionId, const Subject &subject, AuthorizationFlags flags) |
void | checkAuthorizationCancel () |
void | enumerateActions () |
ActionDescription::List | enumerateActionsSync () |
void | enumerateActionsCancel () |
void | registerAuthenticationAgent (const Subject &subject, const QString &locale, const QString &objectPath) |
bool | registerAuthenticationAgentSync (const Subject &subject, const QString &locale, const QString &objectPath) |
void | registerAuthenticationAgentCancel () |
void | unregisterAuthenticationAgent (const Subject &subject, const QString &objectPath) |
bool | unregisterAuthenticationAgentSync (const Subject &subject, const QString &objectPath) |
void | unregisterAuthenticationAgentCancel () |
void | authenticationAgentResponse (const QString &cookie, const Identity &identity) |
bool | authenticationAgentResponseSync (const QString &cookie, const PolkitQt1::Identity &identity) |
void | authenticationAgentResponseCancel () |
void | enumerateTemporaryAuthorizations (const Subject &subject) |
TemporaryAuthorization::List | enumerateTemporaryAuthorizationsSync (const Subject &subject) |
void | enumerateTemporaryAuthorizationsCancel () |
void | revokeTemporaryAuthorizations (const Subject &subject) |
bool | revokeTemporaryAuthorizationsSync (const Subject &subject) |
void | revokeTemporaryAuthorizationsCancel () |
void | revokeTemporaryAuthorization (const QString &id) |
bool | revokeTemporaryAuthorizationSync (const QString &id) |
void | revokeTemporaryAuthorizationCancel () |
Static Public Member Functions | |
static Authority * | instance (PolkitAuthority *authority=0) |
Returns the instance of Authority. More... | |
Friends | |
class | Private |
Convenience class for Qt/KDE applications.
This class is a singleton that provides makes easy the usage of PolKitAuthority. It emits configChanged() whenever PolicyKit files change (e.g. the PolicyKit.conf or .policy files) or when ConsoleKit reports activities changes.
Error codes for the authority class
Enumerator | |
---|---|
E_None | No error occurred |
E_GetAuthority | Authority cannot be obtained |
E_CheckFailed | Authority check failed |
E_WrongSubject | Wrong or empty subject was given |
E_UnknownResult | Action returned unknown result |
E_EnumFailed | Enumerating actions failed |
E_RegisterFailed | Registration of authentication agent failed |
E_UnregisterFailed | Unregistration of authentication agent failed |
E_CookieOrIdentityEmpty | Cookie or polkitqt1-identity.handled to the action is empty |
E_AgentResponseFailed | Response of auth agent failed |
E_RevokeFailed | Revoke temporary authorizations failed |
void PolkitQt1::Authority::authenticationAgentResponse | ( | const QString & | cookie, |
const Identity & | identity | ||
) |
Provide response that identity
successfully authenticated for the authentication request identified by cookie
.
cookie | The cookie passed to the authentication agent from the authority. |
identity | The identity that was authenticated. |
void PolkitQt1::Authority::authenticationAgentResponseCancel | ( | ) |
This method can be used to cancel the authenticationAgentResponseAsync method.
|
signal |
This signal is emitted when asynchronous method authenticationAgentResponse finishes.
The argument is true
if authority acknowledged the call, false
if error is set.
bool PolkitQt1::Authority::authenticationAgentResponseSync | ( | const QString & | cookie, |
const PolkitQt1::Identity & | identity | ||
) |
Provide response that identity
successfully authenticated for the authentication request identified by cookie
.
cookie | The cookie passed to the authentication agent from the authority. |
identity | The identity that was authenticated. |
true
if authority acknowledged the call, false
if error is set. void PolkitQt1::Authority::checkAuthorization | ( | const QString & | actionId, |
const Subject & | subject, | ||
AuthorizationFlags | flags | ||
) |
This function should be used by mechanisms (e.g.: helper applications). It returns the action should be carried out, so if the caller was actually authorized to perform it. The result is in form of a Result, so that you can have more control over the whole process, and detect an eventual error. Most of the times you simply want to check if the result is == to Result::Yes
, if you don't have specific needs.
It is CRITICAL that you call this function and check what it returns before doing anything in your helper, since otherwise you could be actually performing an action from an unknown or unauthorized caller.
When operation is finished, signal checkAuthorizationFinish is emitted with result of authorization check in its parameter.
actionId | the Id of the action in question |
subject | subject that the action is authorized for (e.g. unix process) |
flags | flags that influences the authorization checking |
Result::Yes
if the caller is authorized and the action should be performed otherwise
if the caller was not authorized and the action should not be performed, or an error has occurred void PolkitQt1::Authority::checkAuthorizationCancel | ( | ) |
This method can be used to cancel last authorization check.
|
signal |
This signal is emitted when asynchronous method checkAuthorization finishes.
The argument is the result of authorization.
Authority::Result PolkitQt1::Authority::checkAuthorizationSync | ( | const QString & | actionId, |
const Subject & | subject, | ||
AuthorizationFlags | flags | ||
) |
Synchronous version of the checkAuthorization method.
actionId | the Id of the action in question |
subject | subject that the action is authorized for (e.g. unix process) |
flags | flags that influences the authorization checking |
void PolkitQt1::Authority::clearError | ( | ) |
Use this method to clear the error message.
|
signal |
This signal will be emitted when a configuration file gets changed (e.g. /etc/PolicyKit/PolicyKit.conf or .policy files). Connect to this signal if you want to track down actions.
|
signal |
This signal is emitted when ConsoleKit configuration changes. This might happen when a session becomes active or inactive.
If you want to track your actions directly you should connect to this signal, as this might change the return value PolicyKit will give you.
void PolkitQt1::Authority::enumerateActions | ( | ) |
Asynchronously retrieves all registered actions.
When operation is finished, signal checkAuthorizationFinish is emitted with result of authorization check in its parameter.
void PolkitQt1::Authority::enumerateActionsCancel | ( | ) |
This method can be used to cancel enumeration of actions
|
signal |
This signal is emitted when asynchronous method enumerateActions finishes.
The argument is the list of all Action IDs.
ActionDescription::List PolkitQt1::Authority::enumerateActionsSync | ( | ) |
Synchronously retrieves all registered actions.
void PolkitQt1::Authority::enumerateTemporaryAuthorizations | ( | const Subject & | subject | ) |
Retrieves all temporary action that applies to subject
.
subject | the subject to get temporary authorizations for |
void PolkitQt1::Authority::enumerateTemporaryAuthorizationsCancel | ( | ) |
This method can be used to cancel the enumerateTemporaryAuthorizationsAsync method.
|
signal |
This signal is emmited when asynchronous method enumerateTemporaryAuthorizations finishes.
The argument is list of all temporary authorizations.
delete
operator. TemporaryAuthorization::List PolkitQt1::Authority::enumerateTemporaryAuthorizationsSync | ( | const Subject & | subject | ) |
Retrieves all temporary action that applies to subject
subject | the subject to get temporary authorizations for |
delete
operator.const QString PolkitQt1::Authority::errorDetails | ( | ) | const |
Get detail information about error that occurred.
bool PolkitQt1::Authority::hasError | ( | ) | const |
You should always call this method after every action. No action will be allowed if the object is in error state. Use clearError() to clear the error message.
true
if an error occurred, false
if the library is ready
|
static |
Returns the instance of Authority.
Returns the current instance of Authority. Call this function whenever you need to access the Authority class.
authority | use this if you want to set an explicit PolkitAuthority. If you don't know what this implies, simply ignore the parameter. In case you want to use it, be sure of streaming it the first time you call this function, otherwise it will have no effect. |
Authority::ErrorCode PolkitQt1::Authority::lastError | ( | ) | const |
PolkitAuthority * PolkitQt1::Authority::polkitAuthority | ( | ) | const |
Returns the current instance of PolkitAuthority. If you are handling it through Polkit-qt (which is quite likely, since you are calling this function), DO NOT use any PolicyKit API's specific method that modifies the instance on it, unless you're completely aware of what you're doing and of the possible consequencies. Use this instance only to gather information.
void PolkitQt1::Authority::registerAuthenticationAgent | ( | const Subject & | subject, |
const QString & | locale, | ||
const QString & | objectPath | ||
) |
Registers an authentication agent.
subject | caller subject |
locale | the locale of the authentication agent |
objectPath | the object path for the authentication agent |
void PolkitQt1::Authority::registerAuthenticationAgentCancel | ( | ) |
This method can be used to cancel the registration of the authentication agent.
|
signal |
This signal is emitted when asynchronous method registerAuthenticationAgent finishes.
The argument is true
if the Authentication agent has been successfully registered false
if the Authentication agent registration failed
bool PolkitQt1::Authority::registerAuthenticationAgentSync | ( | const Subject & | subject, |
const QString & | locale, | ||
const QString & | objectPath | ||
) |
Registers an authentication agent.
subject | caller subject |
locale | the locale of the authentication agent |
objectPath | the object path for the authentication agent |
true
if the Authentication agent has been successfully registered false
if the Authentication agent registration failed void PolkitQt1::Authority::revokeTemporaryAuthorization | ( | const QString & | id | ) |
Revokes temporary authorization by id
id | the identifier of the temporary authorization |
void PolkitQt1::Authority::revokeTemporaryAuthorizationCancel | ( | ) |
This method can be used to cancel the method revokeTemporaryAuthorizationAsync.
|
signal |
This signal is emmited when asynchronous method revokeTemporaryAuthorization finishes.
true
if the temporary authorization was revoked false
if the revoking failed void PolkitQt1::Authority::revokeTemporaryAuthorizations | ( | const Subject & | subject | ) |
Revokes all temporary authorizations that applies to subject
subject | the subject to revoke temporary authorizations from |
void PolkitQt1::Authority::revokeTemporaryAuthorizationsCancel | ( | ) |
This method can be used to cancel the method revokeTemporaryAuthorizationsAsync.
|
signal |
This signal is emmited when asynchronous method revokeTemporaryAuthorizations finishes.
The argument is true
if all temporary authorizations were revoked false
if the revoking failed
bool PolkitQt1::Authority::revokeTemporaryAuthorizationsSync | ( | const Subject & | subject | ) |
Revokes all temporary authorizations that applies to subject
subject | the subject to revoke temporary authorizations from |
true
if all temporary authorization were revoked false
if the revoking failed bool PolkitQt1::Authority::revokeTemporaryAuthorizationSync | ( | const QString & | id | ) |
Revokes temporary authorization by id
id | the identifier of the temporary authorization |
true
if the temporary authorization was revoked false
if the revoking failed void PolkitQt1::Authority::unregisterAuthenticationAgent | ( | const Subject & | subject, |
const QString & | objectPath | ||
) |
Unregisters an Authentication agent.
subject | caller subject |
objectPath | the object path for the Authentication agent |
true
if the Authentication agent has been successfully unregistered false
if the Authentication agent unregistration failed void PolkitQt1::Authority::unregisterAuthenticationAgentCancel | ( | ) |
This method can be used to cancel the unregistration of the authentication agent.
|
signal |
This signal is emitted when asynchronous method unregisterAuthenticationAgent finishes.
The argument is true
if the Authentication agent has been successfully unregistered false
if the Authentication agent unregistration failed
bool PolkitQt1::Authority::unregisterAuthenticationAgentSync | ( | const Subject & | subject, |
const QString & | objectPath | ||
) |
Unregisters an Authentication agent.
subject | caller subject |
objectPath | the object path for the Authentication agent |
true
if the Authentication agent has been successfully unregistered false
if the Authentication agent unregistration failed