Debian Codegraph @

src/fdosecrets/objects/Session.h

raw
1 /*
2 * Copyright (C) 2018 Aetf <[email protected]>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 or (at your option)
7 * version 3 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef KEEPASSXC_FDOSECRETS_SESSION_H
19 #define KEEPASSXC_FDOSECRETS_SESSION_H
20
21 #include "fdosecrets/dbus/DBusObject.h"
22
23 namespace FdoSecrets
24 {
25 class CipherPair;
26 class Session : public DBusObject
27 {
28 Q_OBJECT
29 Q_CLASSINFO("D-Bus Interface", DBUS_INTERFACE_SECRET_SESSION_LITERAL)
30
31 explicit Session(QSharedPointer<CipherPair> cipher, const QString& peer, Service* parent);
32
33 public:
34 /**
35 * @brief Create a new instance of `Session`.
36 * @param cipher the negotiated cipher
37 * @param peer connecting peer
38 * @param parent the owning Service
39 * @return pointer to newly created Session, or nullptr if error
40 * This may be caused by
41 * - DBus path registration error
42 */
43 static Session* Create(QSharedPointer<CipherPair> cipher, const QString& peer, Service* parent);
44
45 Q_INVOKABLE DBusResult close();
46
47 /**
48 * Encode the secret struct. Note only the value field is encoded.
49 * @param input
50 * @return
51 */
52 Secret encode(const Secret& input) const;
53
54 /**
55 * Decode the secret struct.
56 * @param input
57 * @return
58 */
59 Secret decode(const Secret& input) const;
60
61 /**
62 * The peer application that opened this session
63 * @return
64 */
65 QString peer() const;
66
67 QString id() const;
68
69 Service* service() const;
70
71 signals:
72 /**
73 * The session is going to be closed
74 * @param sess
75 */
76 void aboutToClose();
77
78 private:
79 QSharedPointer<CipherPair> m_cipher;
80 QString m_peer;
81 QUuid m_id;
82 };
83
84 } // namespace FdoSecrets
85
86 #endif // KEEPASSXC_FDOSECRETS_SESSION_H