aboutsummaryrefslogtreecommitdiff
path: root/lib/olm/qolminboundsession.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/olm/qolminboundsession.cpp')
-rw-r--r--lib/olm/qolminboundsession.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/olm/qolminboundsession.cpp b/lib/olm/qolminboundsession.cpp
new file mode 100644
index 00000000..fbcaa802
--- /dev/null
+++ b/lib/olm/qolminboundsession.cpp
@@ -0,0 +1,30 @@
+// SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org>
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include <qolminboundsession.h>
+
+std::variant<QOlmInboundGroupSession, OlmInboundGroupSession> QOlmInboundGroupSession::create(const QString &key)
+{
+ auto olmInboundGroupSessionBuf = QByteArray(olm_inbound_group_session_size(), '0');
+
+ const auto olmInboundGroupSession = olm_inbound_group_session(olmInboundGroupSessionBuf.data());
+
+ QByteArray keyBuf = key.toUtf8();
+
+ const auto error = olm_init_inbound_group_session(olmInboundGroupSession, keyBuf.data(), keyBuf.size());
+
+ if (error == olm_error()) {
+ return
+ }
+
+ if create_error == errors::olm_error() {
+ Err(Self::last_error(olm_inbound_group_session_ptr))
+ } else {
+ Ok(OlmInboundGroupSession {
+ group_session_ptr: olm_inbound_group_session_ptr,
+ group_session_buf: olm_inbound_group_session_buf,
+ })
+ }
+
+}