/usr/include/polkit-qt5-1/polkitqt1-authority.h is in libpolkit-qt5-1-dev 0.112.0-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | /*
* This file is part of the Polkit-qt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef POLKITQT1_AUTHORITY_H
#define POLKITQT1_AUTHORITY_H
#include "polkitqt1-export.h"
#include "polkitqt1-identity.h"
#include "polkitqt1-subject.h"
#include "polkitqt1-temporaryauthorization.h"
#include "polkitqt1-actiondescription.h"
#include <QtCore/QObject>
#include <QtCore/QMetaType>
typedef struct _PolkitAuthority PolkitAuthority;
class QStringList;
/**
* \namespace PolkitQt1 PolkitQt
*
* \brief Namespace wrapping Polkit-Qt classes
*
* This namespace wraps all Polkit-Qt classes.
*/
namespace PolkitQt1
{
/**
* \class Authority polkitqt1-authority.h Authority
* \author Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* \author Dario Freddi <drf@kde.org>
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief 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.
*
* \note This class is a singleton, its constructor is private.
* Call Authority::instance() to get an instance of the Authority object.
* Do not delete Authority::instance(), cleanup will be done automatically.
*/
class POLKITQT1_EXPORT Authority : public QObject
{
Q_OBJECT
Q_DISABLE_COPY(Authority)
Q_ENUMS(Result)
Q_ENUMS(ErrorCode)
public:
enum Result {
/** Result unknown */
Unknown = 0x00,
/** The subject is authorized for the specified action */
Yes = 0x01,
/** The subject is not authorized for the specified action */
No = 0x02,
/** The subject is authorized if more information is provided */
Challenge = 0x03
};
enum AuthorizationFlag {
/** No flags set **/
None = 0x00,
/** If the subject can obtain the authorization through authentication,
* and an authentication agent is available, then attempt to do so.
*
* Note, this means that the method used for checking authorization is likely
* to block for a long time. **/
AllowUserInteraction = 0x01
};
Q_DECLARE_FLAGS(AuthorizationFlags, AuthorizationFlag)
/** Error codes for the authority class */
enum ErrorCode {
/** No error occurred **/
E_None = 0x00,
/** Authority cannot be obtained **/
E_GetAuthority = 0x01,
/** Authority check failed **/
E_CheckFailed = 0x02,
/** Wrong or empty subject was given **/
E_WrongSubject = 0x03,
/** Action returned unknown result **/
E_UnknownResult = 0x04,
/** Enumerating actions failed **/
E_EnumFailed = 0x05,
/** Registration of authentication agent failed **/
E_RegisterFailed = 0x06,
/** Unregistration of authentication agent failed **/
E_UnregisterFailed = 0x07,
/** Cookie or polkitqt1-identity.handled to the action is empty **/
E_CookieOrIdentityEmpty = 0x08,
/** Response of auth agent failed **/
E_AgentResponseFailed = 0x09,
/** Revoke temporary authorizations failed **/
E_RevokeFailed = 0x0A
};
/**
* \brief Returns the instance of Authority
*
* Returns the current instance of Authority. Call this function whenever
* you need to access the Authority class.
*
* \note Authority is a singleton. Memory is handled by polkit-qt, so you just
* need to call this function to get a working instance of Authority.
* Don't delete the object after having used it.
*
* \param 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.
*
* \return The current authority instance
*/
static Authority *instance(PolkitAuthority *authority = 0);
~Authority();
/**
* 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.
*
* \see lastError
* \see clearError
*
* \return \c true if an error occurred, \c false if the library is ready
*/
bool hasError() const;
/**
* \return the code of last error
*/
ErrorCode lastError() const;
/**
* Get detail information about error that occurred.
*
* \return detail message
*/
const QString errorDetails() const;
/**
* Use this method to clear the error message.
*/
void clearError();
/**
* 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.
*
* \return the current PolkitAuthority instance
*/
PolkitAuthority *polkitAuthority() const;
/**
* 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 \c 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.
*
* \see checkAuthorizationSync Synchronous version of this method.
* \see checkAuthorizationFinished Signal that is emitted when this method finishes.
* \see checkAuthorizationCancel Use it to cancel execution of this method.
*
* \param actionId the Id of the action in question
* \param subject subject that the action is authorized for (e.g. unix process)
* \param flags flags that influences the authorization checking
*
* \return \c Result::Yes if the caller is authorized and the action should be performed
* \c otherwise if the caller was not authorized and the action should not be performed,
* or an error has occurred
*
*/
void checkAuthorization(const QString &actionId, const Subject &subject,
AuthorizationFlags flags);
/**
* Synchronous version of the checkAuthorization method.
*
* \param actionId the Id of the action in question
* \param subject subject that the action is authorized for (e.g. unix process)
* \param flags flags that influences the authorization checking
*
* \see checkAuthorization Asynchronous version of this method.
*/
Result checkAuthorizationSync(const QString &actionId, const Subject &subject,
AuthorizationFlags flags);
/**
* This method can be used to cancel last authorization check.
*/
void checkAuthorizationCancel();
/**
* Asynchronously retrieves all registered actions.
*
* When operation is finished, signal checkAuthorizationFinish is emitted
* with result of authorization check in its parameter.
*
* \see enumerateActionsSync Synchronous version of this method.
* \see enumerateActionsFinished Signal that is emitted when this method finishes.
* \see enumerateActionsCancel Use it to cancel execution of this method.
*/
void enumerateActions();
/**
* Synchronously retrieves all registered actions.
*
* \see enumerateActions Asynchronous version of this method.
*
* \return a list of Action IDs
*/
ActionDescription::List enumerateActionsSync();
/**
* This method can be used to cancel enumeration of actions
*/
void enumerateActionsCancel();
/**
* Registers an authentication agent.
*
* \see registerAuthenticationAgentSync Synchronous version of this method.
* \see registerAuthenticationAgentFinished Signal that is emitted when this method finishes.
* \see registerAuthenticationAgentCancel Use it to cancel execution of this method.
*
* \param subject caller subject
* \param locale the locale of the authentication agent
* \param objectPath the object path for the authentication agent
*/
void registerAuthenticationAgent(const Subject &subject, const QString &locale,
const QString &objectPath);
/**
* Registers an authentication agent.
*
* \see registerAuthenticationAgent Asynchronous version of this method.
*
* \param subject caller subject
* \param locale the locale of the authentication agent
* \param objectPath the object path for the authentication agent
*
* \return \c true if the Authentication agent has been successfully registered
* \c false if the Authentication agent registration failed
*/
bool registerAuthenticationAgentSync(const Subject &subject, const QString &locale,
const QString &objectPath);
/**
* This method can be used to cancel the registration of the authentication agent.
*/
void registerAuthenticationAgentCancel();
/**
* Unregisters an Authentication agent.
*
* \see unregisterAuthenticationAgentSync Synchronous version of this method.
* \see unregisterAuthenticationAgentFinished Signal that is emitted when this method finishes.
* \see unregisterAuthenticationAgentCancel Use it to cancel execution of this method.
*
* \param subject caller subject
* \param objectPath the object path for the Authentication agent
*
* \return \c true if the Authentication agent has been successfully unregistered
* \c false if the Authentication agent unregistration failed
*/
void unregisterAuthenticationAgent(const Subject &subject, const QString &objectPath);
/**
* Unregisters an Authentication agent.
*
* \see unregisterAuthenticationAgent Asynchronous version of this method.
*
* \param subject caller subject
* \param objectPath the object path for the Authentication agent
*
* \return \c true if the Authentication agent has been successfully unregistered
* \c false if the Authentication agent unregistration failed
*/
bool unregisterAuthenticationAgentSync(const Subject &subject, const QString &objectPath);
/**
* This method can be used to cancel the unregistration of the authentication agent.
*/
void unregisterAuthenticationAgentCancel();
/**
* Provide response that \p identity successfully authenticated for the authentication request identified by \p cookie.
*
* \see authenticationAgentResponseSync Synchronous version of this method.
* \see authenticationAgentResponseFinished Signal that is emitted when this method finishes.
* \see authenticationAgentResponseCancel Use it to cancel execution of this method.
*
* \param cookie The cookie passed to the authentication agent from the authority.
* \param identity The identity that was authenticated.
*/
void authenticationAgentResponse(const QString &cookie, const Identity &identity);
/**
* Provide response that \p identity successfully authenticated for the authentication request identified by \p cookie.
*
* \see authenticationAgentResponse Asynchronous version of this method.
*
* \param cookie The cookie passed to the authentication agent from the authority.
* \param identity The identity that was authenticated.
*
* \return \c true if authority acknowledged the call, \c false if error is set.
*
*/
bool authenticationAgentResponseSync(const QString& cookie, const PolkitQt1::Identity& identity);
/**
* This method can be used to cancel the authenticationAgentResponseAsync method.
*/
void authenticationAgentResponseCancel();
/**
* Retrieves all temporary action that applies to \p subject.
*
* \see enumerateTemporaryAuthorizationsSync Synchronous version of this method.
* \see enumerateTemporaryAuthorizationsFinished Signal that is emitted when this method finishes.
* \see enumerateTemporaryAuthorizationsCancel Use it to cancel execution of this method.
*
* \param subject the subject to get temporary authorizations for
*
*/
void enumerateTemporaryAuthorizations(const Subject &subject);
/**
* Retrieves all temporary action that applies to \p subject
*
* \see enumerateTemporaryAuthorizations Asynchronous version of this method.
*
* \param subject the subject to get temporary authorizations for
*
* \note Free all TemporaryAuthorization objects using \p delete operator.
*
* \return List of all temporary authorizations
*/
TemporaryAuthorization::List enumerateTemporaryAuthorizationsSync(const Subject &subject);
/**
* This method can be used to cancel the enumerateTemporaryAuthorizationsAsync method.
*/
void enumerateTemporaryAuthorizationsCancel();
/**
* Revokes all temporary authorizations that applies to \p subject
*
* \see revokeTemporaryAuthorizationsSync Synchronous version of this method.
* \see revokeTemporaryAuthorizationsFinished Signal that is emitted when this method finishes.
* \see revokeTemporaryAuthorizationsCancel Use it to cancel execution of this method.
* \param subject the subject to revoke temporary authorizations from
*/
void revokeTemporaryAuthorizations(const Subject &subject);
/**
* Revokes all temporary authorizations that applies to \p subject
*
* \see revokeTemporaryAuthorizations Asynchronous version of this method.
*
* \param subject the subject to revoke temporary authorizations from
*
* \return \c true if all temporary authorization were revoked
* \c false if the revoking failed
*/
bool revokeTemporaryAuthorizationsSync(const Subject &subject);
/**
* This method can be used to cancel the method revokeTemporaryAuthorizationsAsync.
*/
void revokeTemporaryAuthorizationsCancel();
/**
* Revokes temporary authorization by \p id
*
* \see revokeTemporaryAuthorizationSync Synchronous version of this method.
* \see revokeTemporaryAuthorizationFinished Signal that is emitted when this method finishes.
* \see revokeTemporaryAuthorizationCancel Use it to cancel execution of this method.
*
* \param id the identifier of the temporary authorization
*/
void revokeTemporaryAuthorization(const QString &id);
/**
* Revokes temporary authorization by \p id
*
* \see revokeTemporaryAuthorization Asynchronous version of this method.
*
* \param id the identifier of the temporary authorization
*
* \return \c true if the temporary authorization was revoked
* \c false if the revoking failed
*/
bool revokeTemporaryAuthorizationSync(const QString &id);
/**
* This method can be used to cancel the method revokeTemporaryAuthorizationAsync.
*/
void revokeTemporaryAuthorizationCancel();
Q_SIGNALS:
/**
* 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.
*/
void configChanged();
/**
* 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.
*
* \note If you use Action you'll probably prefer to
* use the dataChanged() signal to track Action changes.
*/
void consoleKitDBChanged();
/**
* This signal is emitted when asynchronous method checkAuthorization finishes.
*
* The argument is the result of authorization.
*/
void checkAuthorizationFinished(PolkitQt1::Authority::Result);
/**
* This signal is emitted when asynchronous method enumerateActions finishes.
*
* The argument is the list of all Action IDs.
*/
void enumerateActionsFinished(PolkitQt1::ActionDescription::List);
/**
* This signal is emitted when asynchronous method registerAuthenticationAgent finishes.
*
* The argument is \c true if the Authentication agent has been successfully registered
* \c false if the Authentication agent registration failed
*/
void registerAuthenticationAgentFinished(bool);
/**
* This signal is emitted when asynchronous method unregisterAuthenticationAgent finishes.
*
* The argument is \c true if the Authentication agent has been successfully unregistered
* \c false if the Authentication agent unregistration failed
*/
void unregisterAuthenticationAgentFinished(bool);
/**
* This signal is emitted when asynchronous method authenticationAgentResponse finishes.
*
* The argument is \c true if authority acknowledged the call, \c false if error is set.
*/
void authenticationAgentResponseFinished(bool);
/**
* This signal is emmited when asynchronous method enumerateTemporaryAuthorizations finishes.
*
* The argument is list of all temporary authorizations.
*
* \note Free all TemporaryAuthorization objects using \p delete operator.
*/
void enumerateTemporaryAuthorizationsFinished(PolkitQt1::TemporaryAuthorization::List);
/**
* This signal is emmited when asynchronous method revokeTemporaryAuthorizations finishes.
*
* The argument is \c true if all temporary authorizations were revoked
* \c false if the revoking failed
*/
void revokeTemporaryAuthorizationsFinished(bool);
/**
* This signal is emmited when asynchronous method revokeTemporaryAuthorization finishes.
* \return \c true if the temporary authorization was revoked
* \c false if the revoking failed
*/
void revokeTemporaryAuthorizationFinished(bool);
private:
explicit Authority(PolkitAuthority *context, QObject *parent = 0);
class Private;
friend class Private;
Private * const d;
Q_PRIVATE_SLOT(d, void dbusFilter(const QDBusMessage &message))
};
}
Q_DECLARE_OPERATORS_FOR_FLAGS(PolkitQt1::Authority::AuthorizationFlags)
Q_DECLARE_METATYPE(PolkitQt1::Authority::Result)
#endif
|