[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:24:47 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=c8b547a

The following commit has been merged in the master branch:
commit c8b547aaef31fa3752cb8b43d0dc034186028ada
Author: Marcin Ziemiński <zieminn at gmail.com>
Date:   Sun Aug 10 16:19:08 2014 +0200

    Add new ways of peer authentication.
---
 lib/CMakeLists.txt           |   1 +
 lib/authenticationwizard.cpp | 422 +++++++++++++++++++++++++++++++++++++++++++
 lib/authenticationwizard.h   | 103 +++++++++++
 lib/channel-adapter.cpp      |  20 ++
 lib/channel-adapter.h        |   4 +-
 lib/chat-widget.cpp          |  94 +++++++---
 lib/chat-widget.h            |   7 +
 7 files changed, 626 insertions(+), 25 deletions(-)

diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 4c541af..e368194 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -23,6 +23,7 @@ set(ktpchat_SRCS
         proxy-service-interface.cpp
         proxy-service.cpp
         otr-utils.cpp
+        authenticationwizard.cpp
         )
 
 set(ktpchat_UI
diff --git a/lib/authenticationwizard.cpp b/lib/authenticationwizard.cpp
new file mode 100644
index 0000000..9a41202
--- /dev/null
+++ b/lib/authenticationwizard.cpp
@@ -0,0 +1,422 @@
+/*************************************************************************
+ * Copyright <2007 - 2013>  <Michael Zanetti> <mzanetti at kde.org>         *
+ * Copyright <2014>       <Marcin Ziemiński> <zieminn at gmail.com>         *
+ *                                                                       *
+ * This program is free software; you can redistribute it and/or         *
+ * modify it under the terms of the GNU General Public License as        *
+ * published by the Free Software Foundation; either version 2 of        *
+ * the License or (at your option) version 3 or any later version        *
+ * accepted by the membership of KDE e.V. (or its successor approved     *
+ * by the membership of KDE e.V.), which shall act as a proxy            *
+ * defined in Section 14 of version 3 of the license.                    *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#include "authenticationwizard.h"
+#include "channel-adapter.h"
+
+#include <KDebug>
+#include <KLocale>
+#include <KNotification>
+#include <KIconLoader>
+
+#include <QGroupBox>
+#include <QProgressBar>
+namespace
+{
+
+    class WaitPage: public QWizardPage
+    {
+        public:
+
+            WaitPage(const QString &text) : canContinue(false)
+        {
+            canContinue = false;
+            setTitle(i18nc("@title","Authenticating contact..."));
+            QVBoxLayout *layout = new QVBoxLayout();
+            layout->addWidget(new QLabel(text));
+            layout->addStretch();
+            QProgressBar *progressBar = new QProgressBar();
+            progressBar->setMinimum(0);
+            progressBar->setMaximum(0);
+            layout->addWidget(progressBar);
+            layout->addStretch();
+            setCommitPage(true);
+            setLayout(layout);
+        }
+
+            void ready()
+            {
+                canContinue = true;
+            }
+
+        protected:
+            virtual bool isComplete() const
+            {
+                return canContinue;
+            }
+
+        private:
+            bool canContinue;
+    };
+
+    QList<AuthenticationWizard*> wizardList;
+}
+
+AuthenticationWizard::AuthenticationWizard(
+        ChannelAdapter *chAdapter,
+        const QString &contact,
+        QWidget *parent,
+        bool initiate,
+        const QString &question)
+    : QWizard(parent),
+    chAdapter(chAdapter),
+    contact(contact),
+    question(question),
+    initiate(initiate)
+{
+
+	wizardList.append(this);
+	setAttribute(Qt::WA_DeleteOnClose);
+
+	setPage(Page_SelectMethod, createIntroPage());
+	setPage(Page_QuestionAnswer, createQAPage());
+	setPage(Page_SharedSecret, createSSPage());
+	setPage(Page_ManualVerification, createMVPage());
+	setPage(Page_Wait1, new WaitPage(i18n("Waiting for %1...", contact)));
+	setPage(Page_Wait2, new WaitPage(i18n("Checking if answers match...")));
+	setPage(Page_Final, createFinalPage());
+
+	if(!initiate) {
+		if(question.isEmpty()) {
+			setStartId(Page_SharedSecret);
+		} else {
+			setStartId(Page_QuestionAnswer);
+		}
+	}
+
+	connect(this, SIGNAL(rejected()), this, SLOT(cancelVerification()));
+	connect(rbQA, SIGNAL(clicked()), this, SLOT(updateInfoBox()));
+	connect(rbSS, SIGNAL(clicked()), this, SLOT(updateInfoBox()));
+	connect(rbMV, SIGNAL(clicked()), this, SLOT(updateInfoBox()));
+
+	updateInfoBox();
+
+	resize(rbMV->width() * 1.5, rbMV->width() * 0.75);
+	show();
+}
+
+
+AuthenticationWizard::~AuthenticationWizard()
+{
+	wizardList.removeAll(this);
+}
+
+AuthenticationWizard *AuthenticationWizard::findWizard(ChannelAdapter *chAdapter)
+{
+	for(int i = 0; i < wizardList.size(); i++) {
+		if(wizardList.at(i)->chAdapter == chAdapter) {
+			return wizardList.at(i);
+		}
+	}
+	return 0;
+}
+
+QWizardPage *AuthenticationWizard::createIntroPage()
+{
+
+	QWizardPage *page = new QWizardPage();
+	page->setTitle(i18nc("@title", "Select authentication method"));
+
+	rbQA = new QRadioButton(i18n("Question and Answer"));
+	rbSS = new QRadioButton(i18n("Shared Secret"));
+	rbMV = new QRadioButton(i18n("Manual fingerprint verification"));
+
+	QGroupBox *frame = new QGroupBox();
+	QVBoxLayout *frameLayout = new QVBoxLayout();
+	frame->setLayout(frameLayout);
+	infoLabel = new QLabel();
+	infoLabel->setWordWrap(true);
+	frameLayout->addWidget(infoLabel);
+
+	QVBoxLayout *layout = new QVBoxLayout();
+	layout->addWidget(rbQA);
+	layout->addWidget(rbSS);
+	layout->addWidget(rbMV);
+
+	layout->addSpacing(30);
+	layout->addWidget(frame);
+
+	page->setLayout(layout);
+
+	rbQA->setChecked(true);
+
+	return page;
+}
+
+QWizardPage *AuthenticationWizard::createQAPage()
+{
+	QWizardPage *page = new QWizardPage();
+	QGridLayout *layout = new QGridLayout();
+
+	if(initiate) {
+		page->setTitle(i18nc("@title", "Question and Answer"));
+
+		lQuestion = new QLabel(i18nc("@info", "Enter a question that only %1 is able to answer:",
+                    contact));
+		layout->addWidget(lQuestion);
+		leQuestion = new QLineEdit();
+		layout->addWidget(leQuestion);
+		lAnswer = new QLabel(i18nc("@info", "Enter the answer to your question:"));
+		layout->addWidget(lAnswer);
+	} else {
+		if(!question.isEmpty()) {
+			page->setTitle(i18nc("@info", "Authentication with %1", contact));
+			lQuestion = new QLabel(i18nc("@info", "%1 would like to verify your authentication."
+                        "Please answer the following question in the field below:", contact));
+			lQuestion->setWordWrap(true);
+			layout->addWidget(lQuestion);
+			lAnswer = new QLabel(question);
+			lAnswer->setWordWrap(true);
+			layout->addWidget(lAnswer);
+		}
+	}
+	leAnswer = new QLineEdit();
+	layout->addWidget(leAnswer);
+
+	page->setLayout(layout);
+	page->setCommitPage(true);
+	return page;
+}
+
+QWizardPage *AuthenticationWizard::createSSPage()
+{
+	QWizardPage *page = new QWizardPage();
+	QGridLayout *layout = new QGridLayout();
+
+	if(initiate) {
+		page->setTitle(i18nc("@title", "Shared Secret"));
+
+		layout->addWidget(new QLabel(i18nc("@info", "Enter a secret passphrase known only to you and %1:", contact)));
+	} else {
+        page->setTitle(i18nc("@title", "Authentication with %1", contact));
+		layout->addWidget(new QLabel(i18nc("@info", "Enter the secret passphrase known only to you and %1:", contact)));
+	}
+	leSecret = new QLineEdit();
+	layout->addWidget(leSecret);
+
+	page->setLayout(layout);
+	page->setCommitPage(true);
+	return page;
+}
+
+QWizardPage *AuthenticationWizard::createMVPage()
+{
+	QWizardPage *page = new QWizardPage();
+	page->setTitle(i18nc("@title", "Manual Verification"));
+
+	QGridLayout *layout = new QGridLayout();
+
+	QLabel *lMessage1 = new QLabel(i18nc("@info",
+                "Contact %1 via another secure channel and verify that the following fingerprint is correct:", contact));
+	lMessage1->setWordWrap(true);
+	layout->addWidget(lMessage1);
+	layout->addWidget(new QLabel(chAdapter->remoteFingerprint()));
+
+	cbManualAuth = new QComboBox();
+	cbManualAuth->addItem(i18nc("@item:inlistbox ...verified that", "I have not"));
+	cbManualAuth->addItem(i18nc("@item:inlistbox ...verified that", "I have"));
+	cbManualAuth->setSizeAdjustPolicy(QComboBox::AdjustToContents);
+
+	if(chAdapter->otrTrustLevel() == Tp::OTRTrustLevelPrivate) {
+		cbManualAuth->setCurrentIndex(1);
+	} else {
+		cbManualAuth->setCurrentIndex(0);
+	}
+
+	QLabel *lMessage2 = new QLabel(i18nc("@info:label I have...",
+                "verified that this is in fact the correct fingerprint for %1", contact));
+	lMessage2->setWordWrap(true);
+
+	QHBoxLayout *verifyLayout = new QHBoxLayout();
+	verifyLayout->addWidget(cbManualAuth);
+	verifyLayout->addWidget(lMessage2);
+
+	QFrame *frame = new QFrame();
+	frame->setLayout(verifyLayout);
+	layout->addWidget(frame);
+
+	page->setLayout(layout);
+	return page;
+
+}
+
+QWizardPage *AuthenticationWizard::createFinalPage()
+{
+	QWizardPage *page = new QWizardPage();
+	QGridLayout *layout = new QGridLayout();
+
+	lFinal = new QLabel();
+	lFinal->setWordWrap(true);
+	layout->addWidget(lFinal);
+	page->setLayout(layout);
+
+	return page;
+}
+
+int AuthenticationWizard::nextId() const
+{
+	if(currentId() == Page_SelectMethod) {
+		if(rbQA->isChecked())
+			return Page_QuestionAnswer;
+		if(rbSS->isChecked())
+			return Page_SharedSecret;
+		if(rbMV->isChecked())
+			return Page_ManualVerification;
+	}
+	if(currentId() == Page_SharedSecret || currentId() == Page_QuestionAnswer) {
+		if(initiate) {
+			return Page_Wait1;
+		} else {
+			return Page_Wait2;
+		}
+	}
+	if(currentId() == Page_Wait1) {
+		return Page_Wait2;
+	}
+	if(currentId() == Page_Wait2) {
+		return Page_Final;
+	}
+	return -1;
+}
+
+bool AuthenticationWizard::validateCurrentPage()
+{
+	kDebug() << "currentId:" << currentId();
+	switch(currentId()) {
+		case 1:
+			if(initiate) {
+                chAdapter->startPeerAuthenticationQA(leQuestion->text(), leAnswer->text());
+			} else {
+                chAdapter->respondPeerAuthentication(leAnswer->text());
+			}
+			break;
+		case 2:
+			if(initiate) {
+                chAdapter->startPeerAuthenticationSS(leSecret->text());
+			} else {
+                chAdapter->respondPeerAuthentication(leSecret->text());
+			}
+			break;
+		case 3:
+			if(cbManualAuth->currentIndex() == 0 ) {
+                chAdapter->trustFingerprint(chAdapter->remoteFingerprint(), false);
+			} else {
+                chAdapter->trustFingerprint(chAdapter->remoteFingerprint(), true);
+			}
+			break;
+	}
+	return true;
+}
+
+void AuthenticationWizard::cancelVerification()
+{
+	kDebug() << "cancelVerification...";
+	if(!initiate){
+        chAdapter->abortPeerAuthentication();
+	}
+}
+
+void AuthenticationWizard::nextState()
+{
+    kDebug();
+	if(currentId() == Page_Wait1) {
+		static_cast<WaitPage*>(currentPage())->ready();
+		next();
+	}
+}
+
+void AuthenticationWizard::finished(bool success)
+{
+	kDebug() << "authWizard finished";
+	if(currentId() == Page_Wait2){
+		kDebug() << "Yes, in wait_page2";
+		static_cast<WaitPage*>(currentPage())->ready();
+		next();
+		if(success) {
+			kDebug() << "auth succeeded";
+			currentPage()->setTitle(i18n("Authentication successful"));
+			if(!question.isEmpty()|| rbQA->isChecked()){
+				if(initiate){
+					kDebug() << "initiate";
+					lFinal->setText(i18n("The authentication with %1 was completed successfully."
+                                " The conversation is now secure.", contact));
+				} else {
+					kDebug() << "not initiate";
+                    lFinal->setText(i18n("<b>%1</b> has successfully authenticated you."
+                                " You may want to authenticate this contact as well by asking your own question.", contact));
+				}
+			} else {
+				lFinal->setText(i18n("The authentication with %1 was completed successfully. "
+                            "The conversation is now secure.", contact));
+			}
+		} else {
+			currentPage()->setTitle(i18n("Authentication failed"));
+			lFinal->setText(i18n("The authentication with %1 failed."
+                        " To make sure you are not talking to an imposter, try again using the manual fingerprint verification method."
+                        " Note that the conversation is now insecure.", contact));
+		}
+	}
+
+	setOption(QWizard::NoCancelButton, true);
+
+}
+
+void AuthenticationWizard::aborted()
+{
+	if(currentId() == Page_SharedSecret || currentId() == Page_QuestionAnswer) {
+		next();
+	}
+	if(currentId() == Page_Wait1){
+		next();
+	}
+	if(currentId() == Page_Wait2){
+		next();
+	}
+	currentPage()->setTitle(i18n("Authentication aborted"));
+	lFinal->setText(i18n("%1 has aborted the authentication process."
+                " To make sure you are not talking to an imposter, try again using the manual fingerprint verification method.", contact));
+
+	setOption(QWizard::NoCancelButton, true);
+}
+
+void AuthenticationWizard::updateInfoBox(){
+	if(rbQA->isChecked()) {
+		infoLabel->setText(i18n("Ask %1 a question, the answer to which is known only to you and them."
+                    " If the answer does not match, you may be talking to an imposter.", contact));
+	} else if(rbSS->isChecked()) {
+		infoLabel->setText(i18n("Pick a secret known only to you and %1. If the secret does not match, you may be talking to an imposter."
+                    " Do not send the secret through the chat window, or this authentication method could be compromised with ease.", contact));
+	} else {
+		infoLabel->setText(i18n("Verify %1's fingerprint manually. For example via a phone call or signed (and verified) email.", contact));
+	}
+}
+
+void AuthenticationWizard::notificationActivated( unsigned int id)
+{
+	kDebug() << "notificationActivated. ButtonId" << id;
+	if(id == 1) {
+		// raise the view to bring the chatwindow + authwizard to current desktop and on top
+        dynamic_cast<QWidget*>(QWizard::parent())->raise();
+		// now grab focus and keyboard again to the auth-wizard
+		setFocus(Qt::ActiveWindowFocusReason);
+		leAnswer->grabKeyboard();
+	}
+}
diff --git a/lib/authenticationwizard.h b/lib/authenticationwizard.h
new file mode 100644
index 0000000..d1cb5f7
--- /dev/null
+++ b/lib/authenticationwizard.h
@@ -0,0 +1,103 @@
+/*************************************************************************
+ * Copyright <2007 - 2013>  <Michael Zanetti> <mzanetti at kde.org>         *
+ * Copyright <2014>  <Marcin Ziemiński> <zieminn at gmail.com>              *
+ *                                                                       *
+ * This program is free software; you can redistribute it and/or         *
+ * modify it under the terms of the GNU General Public License as        *
+ * published by the Free Software Foundation; either version 2 of        *
+ * the License or (at your option) version 3 or any later version        *
+ * accepted by the membership of KDE e.V. (or its successor approved     *
+ * by the membership of KDE e.V.), which shall act as a proxy            *
+ * defined in Section 14 of version 3 of the license.                    *
+ *                                                                       *
+ * This program is distributed in the hope that it will be useful,       *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ * GNU General Public License for more details.                          *
+ *                                                                       *
+ * You should have received a copy of the GNU General Public License     *
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
+ *************************************************************************/
+
+#ifndef AUTHENTICATIONWIZARD_HEADER
+#define AUTHENTICATIONWIZARD_HEADER
+
+#include <KLineEdit>
+#include <KComboBox>
+#include <QLabel>
+#include <QVBoxLayout>
+#include <QWizard>
+#include <QRadioButton>
+
+class ChannelAdapter;
+
+class AuthenticationWizard: public QWizard
+{
+	Q_OBJECT
+public:
+	explicit AuthenticationWizard(
+            ChannelAdapter *chAdapter,
+            const QString &contact,
+            QWidget *parent = 0,
+            bool initiate = true,
+            const QString &question = QLatin1String(""));
+
+	~AuthenticationWizard();
+
+	static AuthenticationWizard *findWizard(ChannelAdapter *chAdapter);
+	void nextState();
+	void finished(bool success);
+	void aborted();
+
+protected:
+
+	virtual int nextId() const;
+	virtual bool validateCurrentPage();
+
+private:
+	enum {
+        Page_SelectMethod,
+        Page_QuestionAnswer,
+        Page_SharedSecret,
+        Page_ManualVerification,
+        Page_Wait1,
+        Page_Wait2,
+        Page_Final
+    };
+
+    ChannelAdapter *chAdapter;
+    const QString contact;
+
+	QString question;
+	bool initiate;
+
+	QLabel *lQuestion;
+	QLabel *lAnswer;
+	QLabel *lSecret;
+	QLabel *infoLabel;
+	QLabel *lFinal;
+
+	QLineEdit *leQuestion;
+	QLineEdit *leAnswer;
+	QLineEdit *leSecret;
+
+	QRadioButton *rbQA;
+	QRadioButton *rbSS;
+	QRadioButton *rbMV;
+
+	QComboBox *cbManualAuth;
+
+	QWizardPage *createIntroPage();
+	QWizardPage *createQAPage();
+	QWizardPage *createSSPage();
+	QWizardPage *createMVPage();
+	QWizardPage *createFinalPage();
+
+private Q_SLOTS:
+	void cancelVerification();
+	void updateInfoBox();
+	void notificationActivated(unsigned int);
+};
+
+
+#endif
diff --git a/lib/channel-adapter.cpp b/lib/channel-adapter.cpp
index 23b9ea6..8cd8d36 100644
--- a/lib/channel-adapter.cpp
+++ b/lib/channel-adapter.cpp
@@ -453,3 +453,23 @@ void ChannelAdapter::onPeerAuthenticationRequested(const QString &question)
         Q_EMIT peerAuthenticationRequestedQA(question);
     }
 }
+
+void ChannelAdapter::startPeerAuthenticationQA(const QString &question, const QString &answer)
+{
+    d->otrProxy->StartPeerAuthentication(question, answer);
+}
+
+void ChannelAdapter::startPeerAuthenticationSS(const QString &secret)
+{
+    startPeerAuthenticationQA(QLatin1String(""), secret);
+}
+
+void ChannelAdapter::respondPeerAuthentication(const QString &secret)
+{
+    d->otrProxy->RespondPeerAuthentication(secret);
+}
+
+void ChannelAdapter::abortPeerAuthentication()
+{
+    d->otrProxy->AbortPeerAuthentication();
+}
diff --git a/lib/channel-adapter.h b/lib/channel-adapter.h
index 6d2e70e..7b841d2 100644
--- a/lib/channel-adapter.h
+++ b/lib/channel-adapter.h
@@ -51,9 +51,9 @@ class ChannelAdapter : public QObject
         void initializeOTR();
         void stopOTR();
         /** question answer peer authentication */
-        void startPeerAuthenticationQA(const QString &secret);
+        void startPeerAuthenticationQA(const QString &question, const QString &answer);
         /** shared secret peer authentication*/
-        void startPeerAuthenticationSS(const QString &question, const QString &answer);
+        void startPeerAuthenticationSS(const QString &secret);
         void respondPeerAuthentication(const QString &secret);
         void abortPeerAuthentication();
 
diff --git a/lib/chat-widget.cpp b/lib/chat-widget.cpp
index 57a765b..6f91762 100644
--- a/lib/chat-widget.cpp
+++ b/lib/chat-widget.cpp
@@ -30,6 +30,7 @@
 #include "text-chat-config.h"
 #include "contact-delegate.h"
 #include "channel-adapter.h"
+#include "authenticationwizard.h"
 
 #include <QtGui/QKeyEvent>
 #include <QtGui/QAction>
@@ -692,30 +693,13 @@ void ChatWidget::stopOtrSession()
 void ChatWidget::authenticateBuddy()
 {
     if(!d->channel.isOTRsuppored()) return;
-    // TODO add smp
-    const QString fingerprint = d->channel.remoteFingerprint();
 
-    QString question = i18n("Is the following fingerprint for the contact %1 correct?
%2",
-            d->contactName, fingerprint);
-
-    int askResult = KMessageBox::questionYesNoCancel(this, question);
-    QDBusPendingReply<> result;
-    switch(askResult) {
-        case KMessageBox::Yes:
-            result = d->channel.trustFingerprint(fingerprint, true);
-            break;
-        case KMessageBox::No:
-            result = d->channel.trustFingerprint(fingerprint, false);
-            break;
-        default:
-            return;
-    }
-
-    result.waitForFinished();
-    if(result.isError()) {
-        kWarning() << "Could not set fingerprint trusted because of: " << result.error().name()
-            << " -> " << result.error().message();
-        KMessageBox::error(this, i18n(result.error().message().toLocal8Bit()));
+    AuthenticationWizard *wizard = AuthenticationWizard::findWizard(&d->channel);
+    if(wizard) {
+        wizard->raise();
+        wizard->showNormal();
+    } else {
+        new AuthenticationWizard(&d->channel, d->contactName, this, true);
     }
 }
 
@@ -725,6 +709,20 @@ void ChatWidget::setupOTR()
             SLOT(onOTRTrustLevelChanged(Tp::OTRTrustLevel, Tp::OTRTrustLevel)));
     connect(&d->channel, SIGNAL(sessionRefreshed()),
             SLOT(onOTRsessionRefreshed()));
+    connect(&d->channel, SIGNAL(peerAuthenticationRequestedQA(const QString&)),
+            SLOT(onPeerAuthenticationRequestedQA(const QString&)));
+    connect(&d->channel, SIGNAL(peerAuthenticationRequestedSS()),
+            SLOT(onPeerAuthenticationRequestedSS()));
+    connect(&d->channel, SIGNAL(peerAuthenticationConcluded(bool)),
+            SLOT(onPeerAuthenticationConcluded(bool)));
+    connect(&d->channel, SIGNAL(peerAuthenticationInProgress()),
+            SLOT(onPeerAuthenticationInProgress()));
+    connect(&d->channel, SIGNAL(peerAuthenticationAborted()),
+            SLOT(onPeerAuthenticationAborted()));
+    connect(&d->channel, SIGNAL(peerAuthenticationError()),
+            SLOT(onPeerAuthenticationFailed()));
+    connect(&d->channel, SIGNAL(peerAuthenticationCheated()),
+            SLOT(onPeerAuthenticationFailed()));
 }
 
 void ChatWidget::onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTrustLevel previous)
@@ -764,6 +762,56 @@ void ChatWidget::onOTRsessionRefreshed()
     d->ui.chatArea->addStatusMessage(i18n("Successfully refreshed OTR session"));
 }
 
+void ChatWidget::onPeerAuthenticationRequestedQA(const QString &question)
+{
+    new AuthenticationWizard(&d->channel, d->contactName, this, false, question);
+}
+
+void ChatWidget::onPeerAuthenticationRequestedSS()
+{
+    new AuthenticationWizard(&d->channel, d->contactName, this, false);
+}
+
+void ChatWidget::onPeerAuthenticationConcluded(bool authenticated)
+{
+    AuthenticationWizard *wizard = AuthenticationWizard::findWizard(&d->channel);
+    if(wizard) {
+        wizard->raise();
+        wizard->showNormal();
+        wizard->finished(authenticated);
+    }
+}
+
+void ChatWidget::onPeerAuthenticationInProgress()
+{
+    AuthenticationWizard *wizard = AuthenticationWizard::findWizard(&d->channel);
+    if(wizard) {
+        wizard->raise();
+        wizard->showNormal();
+        wizard->nextState();
+    }
+}
+
+void ChatWidget::onPeerAuthenticationAborted()
+{
+    AuthenticationWizard *wizard = AuthenticationWizard::findWizard(&d->channel);
+    if(wizard) {
+        wizard->raise();
+        wizard->showNormal();
+        wizard->aborted();
+    }
+}
+
+void ChatWidget::onPeerAuthenticationFailed()
+{
+    AuthenticationWizard *wizard = AuthenticationWizard::findWizard(&d->channel);
+    if(wizard) {
+        wizard->raise();
+        wizard->showNormal();
+        wizard->finished(false);
+    }
+}
+
 void ChatWidget::handleIncomingMessage(const Tp::ReceivedMessage &message, bool alreadyNotified)
 {
     kDebug() << title() << message.text();
diff --git a/lib/chat-widget.h b/lib/chat-widget.h
index e9a9b8a..c18d8be 100644
--- a/lib/chat-widget.h
+++ b/lib/chat-widget.h
@@ -232,8 +232,15 @@ private Q_SLOTS:
     void onShareProviderFinishedSuccess(ShareProvider *provider, const QString &imageUrl);
     void onShareProviderFinishedFailure(ShareProvider *provider, const QString &errorMessage);
     void onSendFileClicked();
+
     void onOTRTrustLevelChanged(Tp::OTRTrustLevel trustLevel, Tp::OTRTrustLevel previous);
     void onOTRsessionRefreshed();
+    void onPeerAuthenticationRequestedQA(const QString &question);
+    void onPeerAuthenticationRequestedSS();
+    void onPeerAuthenticationConcluded(bool authenticated);
+    void onPeerAuthenticationInProgress();
+    void onPeerAuthenticationAborted();
+    void onPeerAuthenticationFailed();
 
 private:
     /** connects necessary signals for the channel */

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list