[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:08:21 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=e9cb017
The following commit has been merged in the master branch:
commit e9cb0176a40088c17e89d4911722753181413b85
Author: Marcin Ziemiński <zieminn at gmail.com>
Date: Thu Jul 31 21:29:15 2014 +0200
Fixed trust level initialization.
Signed-off-by: Marcin Ziemiński <zieminn at gmail.com>
---
otr-proxy/KTpProxy/otr-manager.cpp | 34 ++++++----------------------------
otr-proxy/KTpProxy/otr-session.cpp | 4 +---
otr-proxy/KTpProxy/otr-session.h | 1 -
otr-proxy/KTpProxy/otr-utils.h | 33 +++++++++++++++++++++++++++++++++
4 files changed, 40 insertions(+), 32 deletions(-)
diff --git a/otr-proxy/KTpProxy/otr-manager.cpp b/otr-proxy/KTpProxy/otr-manager.cpp
index 0c93eb3..06c867c 100644
--- a/otr-proxy/KTpProxy/otr-manager.cpp
+++ b/otr-proxy/KTpProxy/otr-manager.cpp
@@ -27,32 +27,6 @@ namespace OTR
namespace {
- void updateTrustLevel(Session *session, ConnContext *context)
- {
- if(context == nullptr) return;
-
- TrustLevel level = TrustLevel::NOT_PRIVATE;
- switch(context->msgstate) {
- case OTRL_MSGSTATE_PLAINTEXT:
- level = TrustLevel::NOT_PRIVATE;
- break;
- case OTRL_MSGSTATE_ENCRYPTED:
- {
- if(otrl_context_is_fingerprint_trusted(context->active_fingerprint)) {
- level = TrustLevel::VERIFIED;
- } else {
- level = TrustLevel::UNVERIFIED;
- }
- break;
- }
- case OTRL_MSGSTATE_FINISHED:
- level = TrustLevel::FINISHED;
- break;
- }
-
- session->onTrustLevelChanged(level, context);
- }
-
/** OTR ops functions ------------------------------------------------------------------------- */
OtrlPolicy policy(void *opdata, ConnContext *context)
{
@@ -126,13 +100,17 @@ namespace {
void gone_secure(void *opdata, ConnContext *context)
{
Session *session = reinterpret_cast<Session*>(opdata);
- updateTrustLevel(session, context);
+ session->onTrustLevelChanged(
+ OTR::utils::getTrustLevel(session->context(), session->userStateBox()->userState(), context->their_instance),
+ context);
}
void gone_insecure(void *opdata, ConnContext *context)
{
Session *session = reinterpret_cast<Session*>(opdata);
- updateTrustLevel(session, context);
+ session->onTrustLevelChanged(
+ OTR::utils::getTrustLevel(session->context(), session->userStateBox()->userState(), context->their_instance),
+ context);
}
void still_secure(void *opdata, ConnContext *context, int is_reply)
diff --git a/otr-proxy/KTpProxy/otr-session.cpp b/otr-proxy/KTpProxy/otr-session.cpp
index 03f4900..ca9fa1c 100644
--- a/otr-proxy/KTpProxy/otr-session.cpp
+++ b/otr-proxy/KTpProxy/otr-session.cpp
@@ -71,7 +71,6 @@ namespace OTR
Session::Session(const SessionContext &ctx, Manager *parent)
: instance(OTRL_INSTAG_BEST),
ctx(ctx),
- tlevel(TrustLevel::NOT_PRIVATE),
pr(parent)
{
userstate = pr->getUserState(ctx.accountId);
@@ -79,7 +78,7 @@ namespace OTR
TrustLevel Session::trustLevel() const
{
- return tlevel;
+ return OTR::utils::getTrustLevel(ctx, userstate->userState(), instance);
}
UserStateBox* Session::userStateBox() const
@@ -273,7 +272,6 @@ namespace OTR
if(context != nullptr) {
instance = context->their_instance;
}
- tlevel = trustLevel;
emit trustLevelChanged(trustLevel);
}
diff --git a/otr-proxy/KTpProxy/otr-session.h b/otr-proxy/KTpProxy/otr-session.h
index 485aade..2f5fd0c 100644
--- a/otr-proxy/KTpProxy/otr-session.h
+++ b/otr-proxy/KTpProxy/otr-session.h
@@ -101,7 +101,6 @@ namespace OTR
private:
otrl_instag_t instance;
SessionContext ctx;
- TrustLevel tlevel;
UserStateBox *userstate;
Manager *pr;
};
diff --git a/otr-proxy/KTpProxy/otr-utils.h b/otr-proxy/KTpProxy/otr-utils.h
index 4b26191..0ad4197 100644
--- a/otr-proxy/KTpProxy/otr-utils.h
+++ b/otr-proxy/KTpProxy/otr-utils.h
@@ -20,6 +20,8 @@
#ifndef KTP_PROXY_OTR_UTILS_HEADER
#define KTP_PROXY_OTR_UTILS_HEADER
+#include "otr-constants.h"
+
#include <QString>
#include <QStringList>
#include <QDBusObjectPath>
@@ -83,6 +85,37 @@ namespace utils
protocolFromAccountId(accountId) + QLatin1Char('/') +
accFromAccountId(accountId));
}
+
+ inline TrustLevel getTrustLevel(const SessionContext &ctx, OtrlUserState userState, otrl_instag_t instance)
+ {
+ ConnContext *context = otrl_context_find(
+ userState,
+ ctx.recipientName.toLocal8Bit(),
+ ctx.accountName.toLocal8Bit(),
+ ctx.protocol.toLocal8Bit(),
+ instance, 0, NULL, NULL, NULL);
+
+ if(context == nullptr) {
+ kWarning() << "Could not get trust level";
+ return TrustLevel::NOT_PRIVATE;
+ }
+
+ switch(context->msgstate) {
+ case OTRL_MSGSTATE_PLAINTEXT:
+ return TrustLevel::NOT_PRIVATE;
+ case OTRL_MSGSTATE_ENCRYPTED:
+ {
+ if(otrl_context_is_fingerprint_trusted(context->active_fingerprint)) {
+ return TrustLevel::VERIFIED;
+ } else {
+ return TrustLevel::UNVERIFIED;
+ }
+ }
+ case OTRL_MSGSTATE_FINISHED:
+ return TrustLevel::FINISHED;
+ }
+ return TrustLevel::NOT_PRIVATE;
+ }
}
}
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list