libQuotient
A Qt library for building matrix clients
keyimport.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2024 Tobias Fella <tobias.fella@kde.org>
2 // SPDX-License-Identifier: LGPL-2.0-or-later
3 
4 #pragma once
5 
6 #include <QObject>
7 
8 #include "expected.h"
9 #include "quotient_export.h"
10 
11 class TestKeyImport;
12 
13 namespace Quotient
14 {
15 class Connection;
16 }
17 
18 namespace Quotient
19 {
20 
21 class QUOTIENT_API KeyImport : public QObject
22 {
23  Q_OBJECT
24 
25 public:
26  enum Error {
27  Success,
28  InvalidPassphrase,
29  InvalidData,
30  OtherError,
31  };
32  Q_ENUM(Error)
33 
34  using QObject::QObject;
35 
36  Q_INVOKABLE Error importKeys(QString data, const QString& passphrase,
37  const Quotient::Connection* connection);
38  Q_INVOKABLE Quotient::Expected<QByteArray, Error> exportKeys(const QString& passphrase, const Quotient::Connection* connection);
39 
40  friend class ::TestKeyImport;
41 private:
42  Quotient::Expected<QJsonArray, Error> decrypt(QString data, const QString& passphrase);
43  Quotient::Expected<QByteArray, Error> encrypt(QJsonArray sessions, const QString& passphrase);
44 };
45 
46 }