summaryrefslogtreecommitdiffstats
path: root/core/polkit-tqt-temporaryauthorization.h
blob: 016ff9a1de6b823b78254fac2c48cfdd4565f9a7 (plain)
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
/*
 * This file is part of the PolKit-tqt project
 * 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 POLKIT_TQT_TEMPORARY_AUTHORIZATION_H
#define POLKIT_TQT_TEMPORARY_AUTHORIZATION_H

#include "polkit-tqt-export.h"
#include "polkit-tqt-subject.h"

typedef struct _PolkitTemporaryAuthorization PolkitTemporaryAuthorization;

class TQDateTime;
class TQString;
template<typename> class TQValueList;


/**
 * \namespace PolkitTQt PolkitTQt
 *
 * \brief Namespace wrapping PolicyKit-TQt classes
 *
 * This namespace wraps all PolicyKit-TQt classes.
 */
namespace PolkitTQt
{

/**
 * \class TemporaryAuthorization polkit-tqt-temporaryauthorization.h TemporaryAuthorization
 * \author Radek Novacek <rnovacek@redhat.com>
 *
 * \brief This class represents PolicyKit temporary authorization
 *
 * This class encapsulates the PolkitTemporaryAuthorization interface.
 */
class POLKIT_TQT_EXPORT TemporaryAuthorization
{
  public:
    typedef TQValueList<TemporaryAuthorization> List;
		 
    TemporaryAuthorization();
    TemporaryAuthorization(const TemporaryAuthorization &other);
    ~TemporaryAuthorization();

    /**
     * Creates TemporaryAuthorization object from PolkitTemporaryAuthorization
     *
     * \warning It shouldn't be used directly unless you are completely aware of what are you doing
     *
     * \param pkTemporaryAuthorization PolkitTemporaryAuthorization object
     */
    TemporaryAuthorization(PolkitTemporaryAuthorization *pkTemporaryAuthorization);

    TemporaryAuthorization& operator=(const TemporaryAuthorization &other);

    /**
     * \brief Gets the identifier for the authorization.
     *
     * This identifier can be user by the revokeTemporaryAuthorization function
     *
     * \return Unique identifier for the authorization
     */
    TQString id() const;

    /**
     * \brief Gets the identifier of the action that authorization is for
     *
     * \return String that identifies the action
     */
    TQString actionId() const;

    /**
     * \brief Gets the subject that authorization is for
     *
     * \return A Subject.
     */
    Subject subject() const;

    /**
     * \brief Gets the time when authorization was obtained
     *
     * \return Time of obtaining the authorization
     */
    TQDateTime obtainedAt() const;

    /**
     * \brief Gets the time when authorizaton will expire
     *
     * \return Time of expiration
     */
    TQDateTime expirationTime() const;

    /**
     * \brief Revoke temporary authorization
     *
     * \return \c true Authorization has been revoked
     *         \c false Revoking authorization failed
     */
    bool revoke();

  private:
    class Data;
    Data *d;
};

}

#endif