aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/e2ee/qolmaccount.cpp4
-rw-r--r--lib/e2ee/qolmerrors.cpp14
-rw-r--r--lib/e2ee/qolmerrors.h2
-rw-r--r--lib/e2ee/qolminboundsession.cpp4
-rw-r--r--lib/e2ee/qolmoutboundsession.cpp4
-rw-r--r--lib/e2ee/qolmsession.cpp4
-rw-r--r--lib/e2ee/qolmutility.cpp4
7 files changed, 13 insertions, 23 deletions
diff --git a/lib/e2ee/qolmaccount.cpp b/lib/e2ee/qolmaccount.cpp
index ffb004cc..a984f884 100644
--- a/lib/e2ee/qolmaccount.cpp
+++ b/lib/e2ee/qolmaccount.cpp
@@ -34,9 +34,7 @@ bool operator==(const IdentityKeys& lhs, const IdentityKeys& rhs)
// Convert olm error to enum
QOlmError lastError(OlmAccount *account) {
- const auto error_raw = olm_account_last_error(account);
-
- return fromString(error_raw);
+ return fromString(olm_account_last_error(account));
}
QByteArray getRandom(size_t bufferSize)
diff --git a/lib/e2ee/qolmerrors.cpp b/lib/e2ee/qolmerrors.cpp
index 568cf7fe..5a60b7e6 100644
--- a/lib/e2ee/qolmerrors.cpp
+++ b/lib/e2ee/qolmerrors.cpp
@@ -4,18 +4,20 @@
#include "qolmerrors.h"
-#include <cstring>
+#include "util.h"
+#include <QtCore/QLatin1String>
Quotient::QOlmError Quotient::fromString(const char* error_raw) {
- if (!strncmp(error_raw, "BAD_ACCOUNT_KEY", 15)) {
+ const QLatin1String error { error_raw };
+ if (error_raw == "BAD_ACCOUNT_KEY"_ls) {
return QOlmError::BadAccountKey;
- } else if (!strncmp(error_raw, "BAD_MESSAGE_KEY_ID", 18)) {
+ } else if (error_raw == "BAD_MESSAGE_KEY_ID"_ls) {
return QOlmError::BadMessageKeyId;
- } else if (!strncmp(error_raw, "INVALID_BASE64", 14)) {
+ } else if (error_raw == "INVALID_BASE64"_ls) {
return QOlmError::InvalidBase64;
- } else if (!strncmp(error_raw, "NOT_ENOUGH_RANDOM", 17)) {
+ } else if (error_raw == "NOT_ENOUGH_RANDOM"_ls) {
return QOlmError::NotEnoughRandom;
- } else if (!strncmp(error_raw, "OUTPUT_BUFFER_TOO_SMALL", 23)) {
+ } else if (error_raw == "OUTPUT_BUFFER_TOO_SMALL"_ls) {
return QOlmError::OutputBufferTooSmall;
} else {
return QOlmError::Unknown;
diff --git a/lib/e2ee/qolmerrors.h b/lib/e2ee/qolmerrors.h
index f2d77851..24e87d95 100644
--- a/lib/e2ee/qolmerrors.h
+++ b/lib/e2ee/qolmerrors.h
@@ -4,8 +4,6 @@
#pragma once
-#include <string>
-
namespace Quotient {
//! All errors that could be caused by an operation regarding Olm
//! Errors are named exactly like the ones in libolm.
diff --git a/lib/e2ee/qolminboundsession.cpp b/lib/e2ee/qolminboundsession.cpp
index 2c546875..9729c02d 100644
--- a/lib/e2ee/qolminboundsession.cpp
+++ b/lib/e2ee/qolminboundsession.cpp
@@ -8,9 +8,7 @@
using namespace Quotient;
QOlmError lastError(OlmInboundGroupSession *session) {
- const auto error_raw = olm_inbound_group_session_last_error(session);
-
- return fromString(error_raw);
+ return fromString(olm_inbound_group_session_last_error(session));
}
QOlmInboundGroupSession::QOlmInboundGroupSession(OlmInboundGroupSession *session)
diff --git a/lib/e2ee/qolmoutboundsession.cpp b/lib/e2ee/qolmoutboundsession.cpp
index 8494efdd..e75ab427 100644
--- a/lib/e2ee/qolmoutboundsession.cpp
+++ b/lib/e2ee/qolmoutboundsession.cpp
@@ -8,9 +8,7 @@
using namespace Quotient;
QOlmError lastError(OlmOutboundGroupSession *session) {
- const auto error_raw = olm_outbound_group_session_last_error(session);
-
- return fromString(error_raw);
+ return fromString(olm_outbound_group_session_last_error(session));
}
QOlmOutboundGroupSession::QOlmOutboundGroupSession(OlmOutboundGroupSession *session)
diff --git a/lib/e2ee/qolmsession.cpp b/lib/e2ee/qolmsession.cpp
index 575019b3..e575ff39 100644
--- a/lib/e2ee/qolmsession.cpp
+++ b/lib/e2ee/qolmsession.cpp
@@ -11,9 +11,7 @@
using namespace Quotient;
QOlmError lastError(OlmSession* session) {
- const auto error_raw = olm_session_last_error(session);
-
- return fromString(error_raw);
+ return fromString(olm_session_last_error(session));
}
Quotient::QOlmSession::~QOlmSession()
diff --git a/lib/e2ee/qolmutility.cpp b/lib/e2ee/qolmutility.cpp
index 13ee695e..303f6d75 100644
--- a/lib/e2ee/qolmutility.cpp
+++ b/lib/e2ee/qolmutility.cpp
@@ -10,9 +10,7 @@ using namespace Quotient;
// Convert olm error to enum
QOlmError lastError(OlmUtility *utility) {
- const auto error_raw = olm_utility_last_error(utility);
-
- return fromString(error_raw);
+ return fromString(olm_utility_last_error(utility));
}
QOlmUtility::QOlmUtility()